From abbb7a57f9da16920bd162c5fb7b90f5f1f26c58 Mon Sep 17 00:00:00 2001 From: James Fitzsimmons Date: Wed, 17 Sep 2025 12:37:10 +1000 Subject: [PATCH] [lexical-clipboard] Fix: copy from editor's window when editor in different window --- packages/lexical-clipboard/src/clipboard.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/lexical-clipboard/src/clipboard.ts b/packages/lexical-clipboard/src/clipboard.ts index e531235a1f8..6d8bea9b0bd 100644 --- a/packages/lexical-clipboard/src/clipboard.ts +++ b/packages/lexical-clipboard/src/clipboard.ts @@ -468,7 +468,7 @@ export async function copyToClipboard( const rootElement = editor.getRootElement(); const editorWindow = editor._window || window; - const windowDocument = window.document; + const windowDocument = editorWindow.document; const domSelection = getDOMSelection(editorWindow); if (rootElement === null || domSelection === null) { return false; @@ -489,7 +489,7 @@ export async function copyToClipboard( if (objectKlassEquals(secondEvent, ClipboardEvent)) { removeListener(); if (clipboardEventTimeout !== null) { - window.clearTimeout(clipboardEventTimeout); + editorWindow.clearTimeout(clipboardEventTimeout); clipboardEventTimeout = null; } resolve($copyToClipboardEvent(editor, secondEvent, data)); @@ -501,7 +501,7 @@ export async function copyToClipboard( ); // If the above hack execCommand hack works, this timeout code should never fire. Otherwise, // the listener will be quickly freed so that the user can reuse it again - clipboardEventTimeout = window.setTimeout(() => { + clipboardEventTimeout = editorWindow.setTimeout(() => { removeListener(); clipboardEventTimeout = null; resolve(false);