mirror of
https://gitee.com/mafgwo/stackedit
synced 2024-11-16 11:42:23 +08:00
优化预览header生成
This commit is contained in:
parent
96ea8cd0db
commit
b4c9407b06
|
@ -233,9 +233,18 @@ const editorSvc = Object.assign(new Vue(), editorSvcDiscussions, editorSvcUtils,
|
|||
const clonedElt = headingElt.cloneNode(true);
|
||||
clonedElt.removeAttribute('id');
|
||||
sectionTocElt.appendChild(clonedElt);
|
||||
// 创建一个新的 <span> 元素
|
||||
const contentElt = document.createElement('span');
|
||||
contentElt.className = 'content';
|
||||
// 将原始内容移动到新的 <span> 元素中
|
||||
while (headingElt.firstChild) {
|
||||
contentElt.appendChild(headingElt.firstChild);
|
||||
}
|
||||
const prefixElt = document.createElement('span');
|
||||
prefixElt.className = 'prefix';
|
||||
headingElt.insertBefore(prefixElt, headingElt.firstChild);
|
||||
// 将新的 <span> 元素替换原始元素
|
||||
headingElt.appendChild(contentElt);
|
||||
const suffixElt = document.createElement('span');
|
||||
suffixElt.className = 'suffix';
|
||||
headingElt.appendChild(suffixElt);
|
||||
|
|
Loading…
Reference in New Issue
Block a user