From 97b8d3c288336362326df46e7e4232b656b40478 Mon Sep 17 00:00:00 2001 From: "xiaoqi.cxq" Date: Wed, 18 Oct 2023 10:09:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AF=BC=E5=87=BA=E4=B8=AD?= =?UTF-8?q?=E7=9A=84header=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/exportSvc.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/services/exportSvc.js b/src/services/exportSvc.js index 03507ed0..4106474e 100644 --- a/src/services/exportSvc.js +++ b/src/services/exportSvc.js @@ -116,9 +116,18 @@ export default { // Make TOC const allHeaders = containerElt.querySelectorAll('h1,h2,h3,h4,h5,h6'); Array.prototype.slice.call(allHeaders).forEach((headingElt) => { + // 创建一个新的 元素 + const contentElt = document.createElement('span'); + contentElt.className = 'content'; + // 将原始内容移动到新的 元素中 + while (headingElt.firstChild) { + contentElt.appendChild(headingElt.firstChild); + } const prefixElt = document.createElement('span'); prefixElt.className = 'prefix'; headingElt.insertBefore(prefixElt, headingElt.firstChild); + // 将新的 元素替换原始元素 + headingElt.appendChild(contentElt); const suffixElt = document.createElement('span'); suffixElt.className = 'suffix'; headingElt.appendChild(suffixElt);