diff --git a/src/lib/components/chat/Artifacts.svelte b/src/lib/components/chat/Artifacts.svelte index 8873181ee..b15f38d22 100644 --- a/src/lib/components/chat/Artifacts.svelte +++ b/src/lib/components/chat/Artifacts.svelte @@ -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} > {:else if contents[selectedContentIdx].type === 'svg'} diff --git a/src/lib/components/chat/Settings/Interface.svelte b/src/lib/components/chat/Settings/Interface.svelte index 668cc9f90..192b8d39d 100644 --- a/src/lib/components/chat/Settings/Interface.svelte +++ b/src/lib/components/chat/Settings/Interface.svelte @@ -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 @@