Skip to content

Commit

Permalink
⬆️
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Dec 6, 2020
1 parent fea8839 commit af0916e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/ts/markdown/outlineRender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const outlineRender = (contentElement: HTMLElement, targetElement: Elemen
lute.SetToC(true);
tempElement.innerHTML = lute.HTML2VditorDOM("<p>[ToC]</p>" + tocHTML);
}
const headingsElement = tempElement.firstElementChild.querySelectorAll("li > span[data-target-id]")
const headingsElement = tempElement.firstElementChild.querySelectorAll("li > span[data-target-id]");
headingsElement.forEach((item, index) => {
if (item.nextElementSibling && item.nextElementSibling.tagName === "UL") {
item.insertAdjacentHTML("afterbegin", "<svg class='vditor-outline__action'><use xlink:href='#vditor-icon-down'></use></svg>");
Expand Down
36 changes: 19 additions & 17 deletions src/ts/undo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,10 @@ class Undo {
});
highlightToolbar(vditor);

vditor[vditor.currentMode].element.querySelectorAll(`.vditor-${vditor.currentMode}__preview[data-render='2']`).forEach((item: HTMLElement) => {
processCodeRender(item, vditor);
});
vditor[vditor.currentMode].element.querySelectorAll(`.vditor-${vditor.currentMode}__preview[data-render='2']`)
.forEach((item: HTMLElement) => {
processCodeRender(item, vditor);
});

if (this[vditor.currentMode].undoStack.length > 1) {
enableToolbar(vditor.toolbar.elements, ["undo"]);
Expand Down Expand Up @@ -223,20 +224,21 @@ class Undo {
}
// 移除数学公式、echart 渲染 https://github.com/siyuan-note/siyuan/issues/537
const cloneElement = vditor.ir.element.cloneNode(true) as HTMLElement;
cloneElement.querySelectorAll(`.vditor-${vditor.currentMode}__preview[data-render='1']`).forEach((item: HTMLElement) => {
if (item.firstElementChild.classList.contains("language-echarts") ||
item.firstElementChild.classList.contains("language-mindmap")) {
item.firstElementChild.removeAttribute("_echarts_instance_");
item.firstElementChild.removeAttribute("data-processed");
item.firstElementChild.innerHTML = item.previousElementSibling.firstElementChild.innerHTML;
item.setAttribute("data-render", "2");
}
if (item.firstElementChild.classList.contains("language-math")) {
item.setAttribute("data-render", "2");
item.firstElementChild.textContent = item.firstElementChild.getAttribute("data-math");
item.firstElementChild.removeAttribute("data-math");
}
});
cloneElement.querySelectorAll(`.vditor-${vditor.currentMode}__preview[data-render='1']`)
.forEach((item: HTMLElement) => {
if (item.firstElementChild.classList.contains("language-echarts") ||
item.firstElementChild.classList.contains("language-mindmap")) {
item.firstElementChild.removeAttribute("_echarts_instance_");
item.firstElementChild.removeAttribute("data-processed");
item.firstElementChild.innerHTML = item.previousElementSibling.firstElementChild.innerHTML;
item.setAttribute("data-render", "2");
}
if (item.firstElementChild.classList.contains("language-math")) {
item.setAttribute("data-render", "2");
item.firstElementChild.textContent = item.firstElementChild.getAttribute("data-math");
item.firstElementChild.removeAttribute("data-math");
}
});
const text = vditor[vditor.currentMode].element.innerHTML;
vditor[vditor.currentMode].element.querySelectorAll(".vditor-wbr").forEach((item) => {
item.remove();
Expand Down

0 comments on commit af0916e

Please sign in to comment.