diff --git a/app/src/protyle/util/insertHTML.ts b/app/src/protyle/util/insertHTML.ts index 4945e33fb..03d22bb40 100644 --- a/app/src/protyle/util/insertHTML.ts +++ b/app/src/protyle/util/insertHTML.ts @@ -7,7 +7,7 @@ import {focusBlock, getEditorRange, focusByWbr, fixTableRange} from "./selection import {mathRender} from "../markdown/mathRender"; import {Constants} from "../../constants"; -export const insertHTML = (html: string, protyle: IProtyle, isBlock = false, splitSpan = true) => { +export const insertHTML = (html: string, protyle: IProtyle, isBlock = false) => { if (html === "") { return; } @@ -73,7 +73,9 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false, spl } // 粘贴带样式的行内元素到另一个行内元素中需进行切割 const spanElement = range.startContainer.nodeType === 3 ? range.startContainer.parentElement: range.startContainer as HTMLElement; - if (splitSpan && spanElement.tagName === "SPAN" && spanElement.isSameNode( range.endContainer.nodeType === 3 ? range.endContainer.parentElement: range.endContainer)) { + if (spanElement.tagName === "SPAN" && spanElement.isSameNode( range.endContainer.nodeType === 3 ? range.endContainer.parentElement: range.endContainer) && + tempElement.content.querySelector("span") // 粘贴纯文本不需切割 https://ld246.com/article/1665556907936 + ) { const afterElement = document.createElement("span"); const attributes = spanElement.attributes; for (let i = 0; i < attributes.length; i++) { diff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.ts index 673e279ce..c22001791 100644 --- a/app/src/protyle/util/paste.ts +++ b/app/src/protyle/util/paste.ts @@ -50,7 +50,7 @@ export const pasteAsPlainText = async (protyle:IProtyle) => { uploadLocalFiles(localFiles, protyle, false); writeText(""); } else { - insertHTML(protyle.lute.BlockDOM2Content(protyle.lute.InlineMd2BlockDOM(clipboard.readText())), protyle, false, false); + insertHTML(protyle.lute.BlockDOM2Content(protyle.lute.InlineMd2BlockDOM(clipboard.readText())), protyle, false); } /// #endif };