From d8d8f3bed90f2e6f205ef208e965669e4e4907ef Mon Sep 17 00:00:00 2001 From: KKK <42832987+fernfei@users.noreply.github.com> Date: Wed, 3 Apr 2024 10:57:17 +0800 Subject: [PATCH 1/4] Fix: paste single image --- common/clipboard_base.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/common/clipboard_base.js b/common/clipboard_base.js index 4b077d1a65..023f425570 100644 --- a/common/clipboard_base.js +++ b/common/clipboard_base.js @@ -241,6 +241,13 @@ } else { + const _html_has_image = function (document) { + return "" === document.body.innerText.trim() && !!document.querySelector("img") + }; + const is_html_outputting_single_mage = function (htmlStr) { + const document = (new DOMParser).parseFromString(htmlStr, "text/html"); + return _html_has_image(document) + }; var _clipboard = (e && e.clipboardData) ? e.clipboardData : window.clipboardData; if (!_clipboard || !_clipboard.getData) return false; @@ -264,7 +271,7 @@ } var _html_format = isDisableRawPaste ? "" : this.ClosureParams.getData("text/html"); - if (_html_format && _html_format != "") + if (_html_format && _html_format != "" && !is_html_outputting_single_mage(_html_format)) { var nIndex = _html_format.indexOf(""); if (-1 != nIndex) From 04b5dc0f362f42d81aa9372c7603398fc641cd5d Mon Sep 17 00:00:00 2001 From: KKK <42832987+fernfei@users.noreply.github.com> Date: Thu, 4 Apr 2024 17:21:52 +0800 Subject: [PATCH 2/4] const change car --- common/clipboard_base.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/clipboard_base.js b/common/clipboard_base.js index 023f425570..e8d1517fb4 100644 --- a/common/clipboard_base.js +++ b/common/clipboard_base.js @@ -241,10 +241,10 @@ } else { - const _html_has_image = function (document) { + var _html_has_image = function (document) { return "" === document.body.innerText.trim() && !!document.querySelector("img") }; - const is_html_outputting_single_mage = function (htmlStr) { + var is_html_outputting_single_mage = function (htmlStr) { const document = (new DOMParser).parseFromString(htmlStr, "text/html"); return _html_has_image(document) }; From 2a82e3279e29f59647789081602a696de9deebe2 Mon Sep 17 00:00:00 2001 From: KKK <42832987+fernfei@users.noreply.github.com> Date: Thu, 4 Apr 2024 17:27:16 +0800 Subject: [PATCH 3/4] Update clipboard_base.js --- common/clipboard_base.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/clipboard_base.js b/common/clipboard_base.js index e8d1517fb4..3bdc705ab0 100644 --- a/common/clipboard_base.js +++ b/common/clipboard_base.js @@ -245,7 +245,7 @@ return "" === document.body.innerText.trim() && !!document.querySelector("img") }; var is_html_outputting_single_mage = function (htmlStr) { - const document = (new DOMParser).parseFromString(htmlStr, "text/html"); + var document = (new DOMParser).parseFromString(htmlStr, "text/html"); return _html_has_image(document) }; var _clipboard = (e && e.clipboardData) ? e.clipboardData : window.clipboardData; From c1057772a8e5cd017bd4139c0fbd056bf8a80d6e Mon Sep 17 00:00:00 2001 From: KKK <42832987+fernfei@users.noreply.github.com> Date: Mon, 8 Apr 2024 13:13:38 +0800 Subject: [PATCH 4/4] update code --- common/clipboard_base.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/clipboard_base.js b/common/clipboard_base.js index 3bdc705ab0..042ab7933c 100644 --- a/common/clipboard_base.js +++ b/common/clipboard_base.js @@ -241,10 +241,10 @@ } else { - var _html_has_image = function (document) { + function _html_has_image(document) { return "" === document.body.innerText.trim() && !!document.querySelector("img") }; - var is_html_outputting_single_mage = function (htmlStr) { + function _is_html_outputting_single_mage(htmlStr) { var document = (new DOMParser).parseFromString(htmlStr, "text/html"); return _html_has_image(document) }; @@ -271,7 +271,7 @@ } var _html_format = isDisableRawPaste ? "" : this.ClosureParams.getData("text/html"); - if (_html_format && _html_format != "" && !is_html_outputting_single_mage(_html_format)) + if (_html_format && _html_format != "" && !_is_html_outputting_single_mage(_html_format)) { var nIndex = _html_format.indexOf(""); if (-1 != nIndex)