diff --git a/web/src/components/molecules/PluginEditor/core/hooks.ts b/web/src/components/molecules/PluginEditor/core/hooks.ts index 8d66590d8c..15460c6bfc 100644 --- a/web/src/components/molecules/PluginEditor/core/hooks.ts +++ b/web/src/components/molecules/PluginEditor/core/hooks.ts @@ -187,6 +187,11 @@ export default () => { [], ); + const useExperimentalSandbox = useMemo( + () => new URLSearchParams(window.location.search).has("useSandbox"), + [], + ); + return { sourceCode, layers, @@ -197,6 +202,7 @@ export default () => { showAlignSystem, showInfobox, engineMeta, + useExperimentalSandbox, setSourceCode, setMode, setInfoboxSize, diff --git a/web/src/components/molecules/PluginEditor/core/index.tsx b/web/src/components/molecules/PluginEditor/core/index.tsx index 80aa201044..9511c7b655 100644 --- a/web/src/components/molecules/PluginEditor/core/index.tsx +++ b/web/src/components/molecules/PluginEditor/core/index.tsx @@ -19,6 +19,7 @@ const PluginEditor: React.FC = () => { showInfobox, layers, engineMeta, + useExperimentalSandbox, setSourceCode, setMode, setInfoboxSize, @@ -48,6 +49,7 @@ const PluginEditor: React.FC = () => { widgetAlignSystem={widgets.alignSystem} layers={layers} meta={engineMeta} + useExperimentalSandbox={useExperimentalSandbox} />
{ [], ); + const useExperimentalSandbox = useMemo(() => { + return !!sceneProperty?.experimental?.experimental_sandbox; + }, [sceneProperty]); + return { sceneId, rootLayerId, @@ -319,6 +323,7 @@ export default (isBuilt?: boolean) => { widgetAlignEditorActivated, engineMeta, layerSelectionReason, + useExperimentalSandbox, selectLayer, selectBlock, onBlockChange, diff --git a/web/src/components/organisms/EarthEditor/core/CanvasArea/index.tsx b/web/src/components/organisms/EarthEditor/core/CanvasArea/index.tsx index 6d62c751d1..bbc3a71e60 100644 --- a/web/src/components/organisms/EarthEditor/core/CanvasArea/index.tsx +++ b/web/src/components/organisms/EarthEditor/core/CanvasArea/index.tsx @@ -32,6 +32,7 @@ const CanvasArea: React.FC = ({ isBuilt, inEditor }) => { widgetAlignEditorActivated, engineMeta, layerSelectionReason, + useExperimentalSandbox, selectLayer, selectBlock, onBlockChange, @@ -83,6 +84,7 @@ const CanvasArea: React.FC = ({ isBuilt, inEditor }) => { widgetAlignSystemEditing={widgetAlignEditorActivated} meta={engineMeta} layerSelectionReason={layerSelectionReason} + useExperimentalSandbox={useExperimentalSandbox} onLayerSelect={selectLayer} onCameraChange={onCameraChange} onWidgetLayoutUpdate={onWidgetUpdate} diff --git a/web/src/core/Crust/Plugins/PluginFrame/PluginIFrame/index.tsx b/web/src/core/Crust/Plugins/PluginFrame/PluginIFrame/index.tsx index 62d3ada2fb..f01b273243 100644 --- a/web/src/core/Crust/Plugins/PluginFrame/PluginIFrame/index.tsx +++ b/web/src/core/Crust/Plugins/PluginFrame/PluginIFrame/index.tsx @@ -2,7 +2,9 @@ import { forwardRef, ForwardRefRenderFunction, IframeHTMLAttributes, ReactNode, import type { RefObject } from "react"; import { createPortal } from "react-dom"; +import useExperimentalSandbox from "../../useExperimentalSandbox"; import IFrame, { AutoResize } from "../IFrame"; +import SafeIframe from "../SafeIFrame"; import useHooks, { Ref } from "./hooks"; @@ -50,21 +52,38 @@ const PluginIFrame: ForwardRefRenderFunction = ( handleLoad, } = useHooks({ ready, ref, visible, type, enabled, onRender }); + const experimentalSandbox = useExperimentalSandbox(); + const children = ( <> {html ? ( -