Improve pasting performance for large amounts of content https://github.com/siyuan-note/siyuan/issues/15306

This commit is contained in:
Daniel 2025-07-26 21:24:28 +08:00
parent 9d392bd663
commit 7c692e8273
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
4 changed files with 362 additions and 187 deletions

View file

@ -4,10 +4,12 @@ import {transaction, updateTransaction} from "../wysiwyg/transaction";
import {getContenteditableElement} from "../wysiwyg/getBlock";
import {
fixTableRange,
focusBlock, focusByRange,
focusBlock,
focusByRange,
focusByWbr,
getEditorRange,
getSelectionOffset, setLastNodeRange,
getSelectionOffset,
setLastNodeRange,
} from "./selection";
import {Constants} from "../../constants";
import {highlightRender} from "../render/highlightRender";
@ -257,7 +259,9 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,
// 移动端插入嵌入块时,获取到的 range 为旧值
useProtyleRange = false,
// 在开头粘贴块则插入上方
insertByCursor = false) => {
insertByCursor = false,
// 是否需要再次 spin
spin = true) => {
if (html === "") {
return;
}
@ -364,7 +368,7 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,
}
let innerHTML = unSpinHTML || // 在 table 中插入需要使用转换好的行内元素 https://github.com/siyuan-note/siyuan/issues/9358
protyle.lute.SpinBlockDOM(html) || // 需要再 spin 一次 https://github.com/siyuan-note/siyuan/issues/7118
(spin && protyle.lute.SpinBlockDOM(html)) || // 需要再 spin 一次 https://github.com/siyuan-note/siyuan/issues/7118
html; // 空格会被 Spin 不再,需要使用原文
// 粘贴纯文本时会进行内部转义,这里需要进行反转义 https://github.com/siyuan-note/siyuan/issues/10620
innerHTML = innerHTML.replace(/;;;lt;;;/g, "<").replace(/;;;gt;;;/g, ">");