diff --git a/src/ts/sv/inputEvent.ts b/src/ts/sv/inputEvent.ts index b4fb8a541..787ff1518 100644 --- a/src/ts/sv/inputEvent.ts +++ b/src/ts/sv/inputEvent.ts @@ -151,7 +151,8 @@ export const inputEvent = (vditor: IVditor, event?: InputEvent) => { // 添加脚注 vditor.sv.element.querySelectorAll("[data-type='footnotes-link']").forEach((item, index) => { - if (index === 0 && item && !(blockElement as HTMLElement).isEqualNode(item.parentElement)) { + // 加入所有脚注便于渲染引用 + if (item && !(blockElement as HTMLElement).isEqualNode(item.parentElement)) { html += "\n" + item.parentElement.textContent; item.parentElement.remove(); } @@ -181,20 +182,10 @@ export const inputEvent = (vditor: IVditor, event?: InputEvent) => { } // 脚注合并后添加的末尾 - let firstFootnoteElement: Element; - const allFootnoteElement = vditor.sv.element.querySelectorAll("[data-type='footnotes-link']"); - allFootnoteElement.forEach((item, index) => { - if (index === 0) { - firstFootnoteElement = item.parentElement; - } else { - firstFootnoteElement.lastElementChild.remove(); - firstFootnoteElement.insertAdjacentHTML("beforeend", `${item.parentElement.innerHTML}`); - item.parentElement.remove(); - } - }); - if (allFootnoteElement.length > 0) { - vditor.sv.element.insertAdjacentElement("beforeend", firstFootnoteElement); - } + vditor.sv.element.querySelectorAll("[data-type='footnotes-link']") + .forEach((item, index) => { + vditor.sv.element.insertAdjacentElement("beforeend", item.parentElement) + }); setRangeByWbr(vditor.sv.element, range); diff --git a/src/ts/sv/process.ts b/src/ts/sv/process.ts index b58855969..46b1a33d8 100644 --- a/src/ts/sv/process.ts +++ b/src/ts/sv/process.ts @@ -17,14 +17,9 @@ export const processPaste = (vditor: IVditor, text: string) => { blockElement = vditor.sv.element; } let spinHTML = vditor.lute.SpinVditorSVDOM(blockElement.textContent) - if (spinHTML.indexOf('data-type="footnotes-link"') > -1 || - spinHTML.indexOf('data-type="link-ref-defs-block"') > -1) { - spinHTML = "
" + spinHTML + "
"; - } else { - spinHTML = "
" + - spinHTML.replace(/
\n<\/span><\/span>
\n<\/span><\/span>
\n

\n
<') + - "
"; - } + spinHTML = "
" + + spinHTML.replace(/
\n<\/span><\/span>
\n<\/span><\/span>
\n

\n
<') + + "
"; if (blockElement.isEqualNode(vditor.sv.element)) { blockElement.innerHTML = spinHTML; } else { @@ -56,14 +51,9 @@ export const getSideByType = (spanNode: Node, type: string, isPrevious = true) = export const processSpinVditorSVDOM = (html: string, vditor: IVditor) => { log("SpinVditorSVDOM", html, "argument", vditor.options.debugger); const spinHTML = vditor.lute.SpinVditorSVDOM(html) - if (spinHTML.indexOf('data-type="footnotes-link"') > -1 || - spinHTML.indexOf('data-type="link-ref-defs-block"') > -1) { - html = "
" + spinHTML + "
"; - } else { - html = "
" + - spinHTML.replace(/
\n<\/span><\/span>
\n<\/span><\/span>
\n

\n
<') + - "
"; - } + html = "
" + + spinHTML.replace(/
\n<\/span><\/span>
\n<\/span><\/span>
\n

\n
<') + + "
"; log("SpinVditorSVDOM", html, "result", vditor.options.debugger); return html; };