From 4d7989493d72a2bc9ef756bb6eb00461415d31a2 Mon Sep 17 00:00:00 2001 From: AmjedNazzal Date: Fri, 20 Oct 2023 17:39:17 +0300 Subject: [PATCH 1/6] Issue28820 --- src/libs/Clipboard/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/Clipboard/index.js b/src/libs/Clipboard/index.js index 6fbaa8eccd31..2f7b647d9eeb 100644 --- a/src/libs/Clipboard/index.js +++ b/src/libs/Clipboard/index.js @@ -62,7 +62,7 @@ function setHTMLSync(html, text) { if (isComposer) { firstAnchorChild.setSelectionRange(originalSelection.start, originalSelection.end, originalSelection.direction); - } else { + } else if (originalSelection.anchorNode && originalSelection.focusNode) { selection.setBaseAndExtent(originalSelection.anchorNode, originalSelection.anchorOffset, originalSelection.focusNode, originalSelection.focusOffset); } From 7e54a427733aa41eed51b8c49d415ef6722a6674 Mon Sep 17 00:00:00 2001 From: AmjedNazzal Date: Thu, 26 Oct 2023 09:56:56 +0300 Subject: [PATCH 2/6] Fix issue #28820 --- src/libs/Clipboard/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/Clipboard/index.js b/src/libs/Clipboard/index.js index 2f7b647d9eeb..efbf69bd4145 100644 --- a/src/libs/Clipboard/index.js +++ b/src/libs/Clipboard/index.js @@ -64,7 +64,7 @@ function setHTMLSync(html, text) { firstAnchorChild.setSelectionRange(originalSelection.start, originalSelection.end, originalSelection.direction); } else if (originalSelection.anchorNode && originalSelection.focusNode) { selection.setBaseAndExtent(originalSelection.anchorNode, originalSelection.anchorOffset, originalSelection.focusNode, originalSelection.focusOffset); - } + } document.body.removeChild(node); } From 0246e29cb81054d03951a79362db4cd97c7c735d Mon Sep 17 00:00:00 2001 From: AmjedNazzal Date: Thu, 26 Oct 2023 09:58:00 +0300 Subject: [PATCH 3/6] Fix issue #28820 --- src/libs/Clipboard/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/Clipboard/index.js b/src/libs/Clipboard/index.js index efbf69bd4145..2f7b647d9eeb 100644 --- a/src/libs/Clipboard/index.js +++ b/src/libs/Clipboard/index.js @@ -64,7 +64,7 @@ function setHTMLSync(html, text) { firstAnchorChild.setSelectionRange(originalSelection.start, originalSelection.end, originalSelection.direction); } else if (originalSelection.anchorNode && originalSelection.focusNode) { selection.setBaseAndExtent(originalSelection.anchorNode, originalSelection.anchorOffset, originalSelection.focusNode, originalSelection.focusOffset); - } + } document.body.removeChild(node); } From 3a43d132852ff871a0cd528322ffab52f05539af Mon Sep 17 00:00:00 2001 From: Amjed Nazzal <74202751+AmjedNazzal@users.noreply.github.com> Date: Fri, 27 Oct 2023 18:46:26 +0300 Subject: [PATCH 4/6] Fix issue #Issue28820 - adding comment --- src/libs/Clipboard/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/Clipboard/index.js b/src/libs/Clipboard/index.js index 2f7b647d9eeb..a8c0995bae48 100644 --- a/src/libs/Clipboard/index.js +++ b/src/libs/Clipboard/index.js @@ -63,6 +63,7 @@ function setHTMLSync(html, text) { if (isComposer) { firstAnchorChild.setSelectionRange(originalSelection.start, originalSelection.end, originalSelection.direction); } else if (originalSelection.anchorNode && originalSelection.focusNode) { + // We are adding a check for anchorNode and focusNode to prevent null values from being passed to setBaseAndExtent as per recent changes in Safari selection.setBaseAndExtent(originalSelection.anchorNode, originalSelection.anchorOffset, originalSelection.focusNode, originalSelection.focusOffset); } From 90f1631e1f503b4b81d336fb02c5762145a08277 Mon Sep 17 00:00:00 2001 From: Amjed Nazzal <74202751+AmjedNazzal@users.noreply.github.com> Date: Mon, 30 Oct 2023 12:32:27 +0300 Subject: [PATCH 5/6] Fix issue #Issue28820 - editing comment --- src/libs/Clipboard/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/Clipboard/index.js b/src/libs/Clipboard/index.js index a8c0995bae48..0d9cca9b64b5 100644 --- a/src/libs/Clipboard/index.js +++ b/src/libs/Clipboard/index.js @@ -63,7 +63,8 @@ function setHTMLSync(html, text) { if (isComposer) { firstAnchorChild.setSelectionRange(originalSelection.start, originalSelection.end, originalSelection.direction); } else if (originalSelection.anchorNode && originalSelection.focusNode) { - // We are adding a check for anchorNode and focusNode to prevent null values from being passed to setBaseAndExtent as per recent changes in Safari + // When copying to clipboard here, since there will be no user selection the original values of anchorNode and focusNode will be null + // We are adding a check to prevent null values from being passed to setBaseAndExtent as per the standards of the Selection api https://w3c.github.io/selection-api/#dom-selection-setbaseandextent selection.setBaseAndExtent(originalSelection.anchorNode, originalSelection.anchorOffset, originalSelection.focusNode, originalSelection.focusOffset); } From 82bf64e9af7f777c3750b1c4e8ec998a6006a85e Mon Sep 17 00:00:00 2001 From: Amjed Nazzal <74202751+AmjedNazzal@users.noreply.github.com> Date: Tue, 31 Oct 2023 01:49:00 +0300 Subject: [PATCH 6/6] Fix issue #Issue28820 - Small change --- src/libs/Clipboard/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/Clipboard/index.js b/src/libs/Clipboard/index.js index 0d9cca9b64b5..eee0d11f4fe3 100644 --- a/src/libs/Clipboard/index.js +++ b/src/libs/Clipboard/index.js @@ -63,8 +63,8 @@ function setHTMLSync(html, text) { if (isComposer) { firstAnchorChild.setSelectionRange(originalSelection.start, originalSelection.end, originalSelection.direction); } else if (originalSelection.anchorNode && originalSelection.focusNode) { - // When copying to clipboard here, since there will be no user selection the original values of anchorNode and focusNode will be null - // We are adding a check to prevent null values from being passed to setBaseAndExtent as per the standards of the Selection api https://w3c.github.io/selection-api/#dom-selection-setbaseandextent + // When copying to the clipboard here, the original values of anchorNode and focusNode will be null since there will be no user selection. + // We are adding a check to prevent null values from being passed to setBaseAndExtent, in accordance with the standards of the Selection API as outlined here: https://w3c.github.io/selection-api/#dom-selection-setbaseandextent. selection.setBaseAndExtent(originalSelection.anchorNode, originalSelection.anchorOffset, originalSelection.focusNode, originalSelection.focusOffset); }