mirror of
https://github.com/open-webui/open-webui
synced 2025-06-16 19:31:52 +00:00
enh: iframe sandbox policy setting
This commit is contained in:
parent
af0d99b2a3
commit
0a69db291d
@ -4,7 +4,7 @@
|
||||
const i18n = getContext('i18n');
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
import { chatId, showArtifacts, showControls } from '$lib/stores';
|
||||
import { chatId, settings, showArtifacts, showControls } from '$lib/stores';
|
||||
import XMark from '../icons/XMark.svelte';
|
||||
import { copyToClipboard, createMessagesList } from '$lib/utils';
|
||||
import ArrowsPointingOut from '../icons/ArrowsPointingOut.svelte';
|
||||
@ -305,7 +305,11 @@
|
||||
title="Content"
|
||||
srcdoc={contents[selectedContentIdx].content}
|
||||
class="w-full border-0 h-full rounded-none"
|
||||
sandbox="allow-scripts allow-forms allow-same-origin"
|
||||
sandbox="allow-scripts{($settings?.iframeSandboxAllowForms ?? false)
|
||||
? ' allow-forms'
|
||||
: ''}{($settings?.iframeSandboxAllowSameOrigin ?? false)
|
||||
? ' allow-same-origin'
|
||||
: ''}"
|
||||
on:load={iframeLoadHandler}
|
||||
></iframe>
|
||||
{:else if contents[selectedContentIdx].type === 'svg'}
|
||||
|
@ -63,6 +63,9 @@
|
||||
|
||||
let webSearch = null;
|
||||
|
||||
let iframeSandboxAllowSameOrigin = false;
|
||||
let iframeSandboxAllowForms = false;
|
||||
|
||||
const toggleExpandDetails = () => {
|
||||
expandDetails = !expandDetails;
|
||||
saveSettings({ expandDetails });
|
||||
@ -245,6 +248,16 @@
|
||||
saveSettings({ webSearch: webSearch });
|
||||
};
|
||||
|
||||
const toggleIframeSandboxAllowSameOrigin = async () => {
|
||||
iframeSandboxAllowSameOrigin = !iframeSandboxAllowSameOrigin;
|
||||
saveSettings({ iframeSandboxAllowSameOrigin });
|
||||
};
|
||||
|
||||
const toggleIframeSandboxAllowForms = async () => {
|
||||
iframeSandboxAllowForms = !iframeSandboxAllowForms;
|
||||
saveSettings({ iframeSandboxAllowForms });
|
||||
};
|
||||
|
||||
onMount(async () => {
|
||||
titleAutoGenerate = $settings?.title?.auto ?? true;
|
||||
autoTags = $settings.autoTags ?? true;
|
||||
@ -746,7 +759,9 @@
|
||||
|
||||
<div>
|
||||
<div class=" py-0.5 flex w-full justify-between">
|
||||
<div class=" self-center text-xs">{$i18n.t('Haptic Feedback')}</div>
|
||||
<div class=" self-center text-xs">
|
||||
{$i18n.t('Haptic Feedback')} ({$i18n.t('Android')})
|
||||
</div>
|
||||
|
||||
<button
|
||||
class="p-1 px-3 text-xs flex rounded-sm transition"
|
||||
@ -850,6 +865,46 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class=" py-0.5 flex w-full justify-between">
|
||||
<div class=" self-center text-xs">{$i18n.t('iframe Sandbox Allow Same Origin')}</div>
|
||||
|
||||
<button
|
||||
class="p-1 px-3 text-xs flex rounded-sm transition"
|
||||
on:click={() => {
|
||||
toggleIframeSandboxAllowSameOrigin();
|
||||
}}
|
||||
type="button"
|
||||
>
|
||||
{#if iframeSandboxAllowSameOrigin === true}
|
||||
<span class="ml-2 self-center">{$i18n.t('On')}</span>
|
||||
{:else}
|
||||
<span class="ml-2 self-center">{$i18n.t('Off')}</span>
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class=" py-0.5 flex w-full justify-between">
|
||||
<div class=" self-center text-xs">{$i18n.t('iframe Sandbox Allow Forms')}</div>
|
||||
|
||||
<button
|
||||
class="p-1 px-3 text-xs flex rounded-sm transition"
|
||||
on:click={() => {
|
||||
toggleIframeSandboxAllowForms();
|
||||
}}
|
||||
type="button"
|
||||
>
|
||||
{#if iframeSandboxAllowForms === true}
|
||||
<span class="ml-2 self-center">{$i18n.t('On')}</span>
|
||||
{:else}
|
||||
<span class="ml-2 self-center">{$i18n.t('Off')}</span>
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class=" my-1.5 text-sm font-medium">{$i18n.t('Voice')}</div>
|
||||
|
||||
<div>
|
||||
|
Loading…
Reference in New Issue
Block a user