mirror of
https://git.mirrors.martin98.com/https://github.com/open-webui/open-webui
synced 2025-08-17 09:05:55 +08:00
enh: iframe sandbox policy setting
This commit is contained in:
parent
af0d99b2a3
commit
0a69db291d
@ -4,7 +4,7 @@
|
|||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
const dispatch = createEventDispatcher();
|
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 XMark from '../icons/XMark.svelte';
|
||||||
import { copyToClipboard, createMessagesList } from '$lib/utils';
|
import { copyToClipboard, createMessagesList } from '$lib/utils';
|
||||||
import ArrowsPointingOut from '../icons/ArrowsPointingOut.svelte';
|
import ArrowsPointingOut from '../icons/ArrowsPointingOut.svelte';
|
||||||
@ -305,7 +305,11 @@
|
|||||||
title="Content"
|
title="Content"
|
||||||
srcdoc={contents[selectedContentIdx].content}
|
srcdoc={contents[selectedContentIdx].content}
|
||||||
class="w-full border-0 h-full rounded-none"
|
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}
|
on:load={iframeLoadHandler}
|
||||||
></iframe>
|
></iframe>
|
||||||
{:else if contents[selectedContentIdx].type === 'svg'}
|
{:else if contents[selectedContentIdx].type === 'svg'}
|
||||||
|
@ -63,6 +63,9 @@
|
|||||||
|
|
||||||
let webSearch = null;
|
let webSearch = null;
|
||||||
|
|
||||||
|
let iframeSandboxAllowSameOrigin = false;
|
||||||
|
let iframeSandboxAllowForms = false;
|
||||||
|
|
||||||
const toggleExpandDetails = () => {
|
const toggleExpandDetails = () => {
|
||||||
expandDetails = !expandDetails;
|
expandDetails = !expandDetails;
|
||||||
saveSettings({ expandDetails });
|
saveSettings({ expandDetails });
|
||||||
@ -245,6 +248,16 @@
|
|||||||
saveSettings({ webSearch: webSearch });
|
saveSettings({ webSearch: webSearch });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const toggleIframeSandboxAllowSameOrigin = async () => {
|
||||||
|
iframeSandboxAllowSameOrigin = !iframeSandboxAllowSameOrigin;
|
||||||
|
saveSettings({ iframeSandboxAllowSameOrigin });
|
||||||
|
};
|
||||||
|
|
||||||
|
const toggleIframeSandboxAllowForms = async () => {
|
||||||
|
iframeSandboxAllowForms = !iframeSandboxAllowForms;
|
||||||
|
saveSettings({ iframeSandboxAllowForms });
|
||||||
|
};
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
titleAutoGenerate = $settings?.title?.auto ?? true;
|
titleAutoGenerate = $settings?.title?.auto ?? true;
|
||||||
autoTags = $settings.autoTags ?? true;
|
autoTags = $settings.autoTags ?? true;
|
||||||
@ -746,7 +759,9 @@
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div class=" py-0.5 flex w-full justify-between">
|
<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
|
<button
|
||||||
class="p-1 px-3 text-xs flex rounded-sm transition"
|
class="p-1 px-3 text-xs flex rounded-sm transition"
|
||||||
@ -850,6 +865,46 @@
|
|||||||
</div>
|
</div>
|
||||||
</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 class=" my-1.5 text-sm font-medium">{$i18n.t('Voice')}</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user