From f728a1fc7b970b247f54714b7fd031720fd9a92f Mon Sep 17 00:00:00 2001 From: zjxxxxxxxxx <43126836+zjxxxxxxxxx@users.noreply.github.com> Date: Sat, 7 Dec 2024 13:13:31 +0800 Subject: [PATCH] fix: Non-enabled state triggers rendering --- .changeset/empty-cherries-pay.md | 5 +++++ packages/client/src/bridge/boxModelBridge.ts | 5 ++++- packages/client/src/bridge/codeSourceBridge.ts | 5 ++++- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 .changeset/empty-cherries-pay.md 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/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: [