From cc32c7dd7e24b6a56796b4448a83f42d07908df0 Mon Sep 17 00:00:00 2001 From: Neil Jenkins Date: Tue, 3 Oct 2023 11:13:02 +1100 Subject: [PATCH] Fix empty string on clipboard if plainTextOnly If extractRangeToClipboard was called with a toPlainText fn and plainTextOnly=true, and there was a selection that was not just inside a single text node, it was not actually getting the text to add to the clipboard. --- source/Clipboard.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/source/Clipboard.ts b/source/Clipboard.ts index 5675bdd..f42d5de 100644 --- a/source/Clipboard.ts +++ b/source/Clipboard.ts @@ -91,10 +91,8 @@ const extractRangeToClipboard = ( } } - // Get Text version of data - if (plainTextOnly) { - // Do nothing; we were copying plain text to start - } else if (toPlainText && html !== undefined) { + // Get Text version of data if converting from HTML + if (toPlainText && html !== undefined) { text = toPlainText(html); }