diff --git a/.changeset/empty-cherries-pay.md b/.changeset/empty-cherries-pay.md new file mode 100644 index 00000000..4d84f693 --- /dev/null +++ b/.changeset/empty-cherries-pay.md @@ -0,0 +1,5 @@ +--- +'@open-editor/client': patch +--- + +Fix for non-enabled state triggering rendering diff --git a/.codesandbox/tasks.json b/.codesandbox/tasks.json index 1aef6006..2625b0e4 100644 --- a/.codesandbox/tasks.json +++ b/.codesandbox/tasks.json @@ -6,13 +6,23 @@ "command": "pnpm install:ci" }, { - "name": "Build packages", + "name": "Build Packages", "command": "pnpm build" }, { - "name": "Create tasks", + "name": "Create Tasks", "command": "pnpm tasks" } ], - "tasks": {} + "tasks": { + "vite-react": { + "name": "Preview vite-react", + "command": "pnpm --filter @playground/vite-react dev", + "runAtStart": true, + "preview": { + "port": 4003, + "prLink": "direct" + } + } + } } diff --git a/packages/client/src/bridge/boxModelBridge.ts b/packages/client/src/bridge/boxModelBridge.ts index 1621efaf..1edf66c1 100644 --- a/packages/client/src/bridge/boxModelBridge.ts +++ b/packages/client/src/bridge/boxModelBridge.ts @@ -2,12 +2,15 @@ import { crossIframeBridge } from '../utils/crossIframeBridge'; import { isTopWindow, whenTopWindow } from '../utils/topWindow'; import { onMessage, postMessage } from '../utils/message'; import { type BoxLines, type BoxRect, getBoxModel } from '../inspector/getBoxModel'; +import { inspectorState } from '../inspector/inspectorState'; import { BOX_MODEL_CROSS_IFRAME } from '../constants'; export const boxModelBridge = crossIframeBridge<[BoxRect, BoxLines]>({ setup() { onMessage<[BoxRect, BoxLines]>(BOX_MODEL_CROSS_IFRAME, (args) => { - boxModelBridge.emit(args, isTopWindow); + if (inspectorState.isEnable) { + boxModelBridge.emit(args, isTopWindow); + } }); }, emitMiddlewares: [ diff --git a/packages/client/src/bridge/codeSourceBridge.ts b/packages/client/src/bridge/codeSourceBridge.ts index 2e4b8857..08ac83ff 100644 --- a/packages/client/src/bridge/codeSourceBridge.ts +++ b/packages/client/src/bridge/codeSourceBridge.ts @@ -1,13 +1,16 @@ import { crossIframeBridge } from '../utils/crossIframeBridge'; import { topWindow, whenTopWindow } from '../utils/topWindow'; import { onMessage, postMessage } from '../utils/message'; +import { inspectorState } from '../inspector/inspectorState'; import { type CodeSource } from '../resolve'; import { CODE_SOURCE_CROSS_IFRAME } from '../constants'; export const codeSourceBridge = crossIframeBridge<[CodeSource | undefined]>({ setup() { onMessage<[CodeSource | undefined]>(CODE_SOURCE_CROSS_IFRAME, (args) => { - codeSourceBridge.emit(args, true); + if (inspectorState.isEnable) { + codeSourceBridge.emit(args, true); + } }); }, emitMiddlewares: [ diff --git a/scripts/create-codesandbox-tasks.ts b/scripts/create-codesandbox-tasks.ts index a161113e..f1a533c6 100644 --- a/scripts/create-codesandbox-tasks.ts +++ b/scripts/create-codesandbox-tasks.ts @@ -10,10 +10,9 @@ function main() { let port = 4000; playgrounds.forEach((name) => { - const task = `@playground/${name}`; taskJson.tasks[name] = { - name: `Preview ${task}`, - command: `pnpm --filter ${task} dev`, + name: `Preview ${name}`, + command: `pnpm --filter @playground/${name} dev`, runAtStart: true, preview: { port: port++,