Skip to content

Commit 0a760fd

Browse files
[lexical-clipboard] Fix: copy correct selection when editor in different window/document (#7822)
1 parent 212ee96 commit 0a760fd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/lexical-clipboard/src/clipboard.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ export async function copyToClipboard(
468468

469469
const rootElement = editor.getRootElement();
470470
const editorWindow = editor._window || window;
471-
const windowDocument = window.document;
471+
const windowDocument = editorWindow.document;
472472
const domSelection = getDOMSelection(editorWindow);
473473
if (rootElement === null || domSelection === null) {
474474
return false;
@@ -489,7 +489,7 @@ export async function copyToClipboard(
489489
if (objectKlassEquals(secondEvent, ClipboardEvent)) {
490490
removeListener();
491491
if (clipboardEventTimeout !== null) {
492-
window.clearTimeout(clipboardEventTimeout);
492+
editorWindow.clearTimeout(clipboardEventTimeout);
493493
clipboardEventTimeout = null;
494494
}
495495
resolve($copyToClipboardEvent(editor, secondEvent, data));
@@ -501,7 +501,7 @@ export async function copyToClipboard(
501501
);
502502
// If the above hack execCommand hack works, this timeout code should never fire. Otherwise,
503503
// the listener will be quickly freed so that the user can reuse it again
504-
clipboardEventTimeout = window.setTimeout(() => {
504+
clipboardEventTimeout = editorWindow.setTimeout(() => {
505505
removeListener();
506506
clipboardEventTimeout = null;
507507
resolve(false);

0 commit comments

Comments
 (0)