Vanessa 2025-03-23 15:17:44 +08:00
parent 3348fd5f47
commit c2d17ec929

View File

@ -84,7 +84,7 @@ export const getPlainText = (blockElement: HTMLElement, isNested = false) => {
text += Lute.UnEscapeHTMLStr(blockElement.getAttribute("data-content")); text += Lute.UnEscapeHTMLStr(blockElement.getAttribute("data-content"));
} else if (["NodeHeading", "NodeParagraph", "NodeCodeBlock"].includes(dataType)) { } else if (["NodeHeading", "NodeParagraph", "NodeCodeBlock"].includes(dataType)) {
text += blockElement.querySelector("[spellcheck]").textContent; text += blockElement.querySelector("[spellcheck]").textContent;
} else if (dataType ==="NodeTable") { } else if (dataType === "NodeTable") {
blockElement.querySelectorAll("th, td").forEach((item) => { blockElement.querySelectorAll("th, td").forEach((item) => {
text += item.textContent.trim() + "\t"; text += item.textContent.trim() + "\t";
if (!item.nextElementSibling) { if (!item.nextElementSibling) {
@ -178,7 +178,7 @@ export const pasteAsPlainText = async (protyle: IProtyle) => {
/// #endif /// #endif
if (localFiles.length === 0) { if (localFiles.length === 0) {
// Inline-level elements support pasted as plain text https://github.com/siyuan-note/siyuan/issues/8010 // Inline-level elements support pasted as plain text https://github.com/siyuan-note/siyuan/issues/8010
navigator.clipboard.readText().then(textPlain => { let textPlain = await readText();
if (getSelection().rangeCount > 0) { if (getSelection().rangeCount > 0) {
const range = getSelection().getRangeAt(0); const range = getSelection().getRangeAt(0);
if (hasClosestByAttribute(range.startContainer, "data-type", "code") || hasClosestByClassName(range.startContainer, "hljs")) { if (hasClosestByAttribute(range.startContainer, "data-type", "code") || hasClosestByClassName(range.startContainer, "hljs")) {
@ -211,7 +211,6 @@ export const pasteAsPlainText = async (protyle: IProtyle) => {
// insertHTML 会进行内部反转义 // insertHTML 会进行内部反转义
insertHTML(content, protyle, false, false, true); insertHTML(content, protyle, false, false, true);
filterClipboardHint(protyle, textPlain); filterClipboardHint(protyle, textPlain);
});
} }
}; };