Liyuan Li 5 years ago
parent
commit
f3d454218b
2 changed files with 16 additions and 0 deletions
  1. 1 0
      CHANGELOG.md
  2. 15 0
      src/ts/undo/index.ts

+ 1 - 0
CHANGELOG.md

@@ -81,6 +81,7 @@
 
 ### v3.5.3 / 2020-09-xx
 
+* [752](https://github.com/Vanessa219/vditor/issues/752) 图表和脑图 undo bug `修复缺陷`
 * [749](https://github.com/Vanessa219/vditor/issues/749) 即时渲染模式转义符 \ 改进 `改进功能`
 
 ### v3.5.2 / 2020-09-06

+ 15 - 0
src/ts/undo/index.ts

@@ -6,6 +6,8 @@ import {execAfterRender} from "../util/fixBrowserBehavior";
 import {highlightToolbar} from "../util/highlightToolbar";
 import {processCodeRender} from "../util/processCode";
 import {setRangeByWbr, setSelectionFocus} from "../util/selection";
+import {chartRender} from "../markdown/chartRender";
+import {mindmapRender} from "../markdown/mindmapRender";
 
 interface IUndo {
     hasUndo: boolean;
@@ -171,6 +173,19 @@ class Undo {
         });
         highlightToolbar(vditor);
 
+        vditor.ir.element.querySelectorAll(".vditor-ir__preview .language-echarts").forEach((item: HTMLElement) => {
+            item.innerHTML = item.parentElement.previousElementSibling.firstElementChild.innerHTML;
+            item.removeAttribute("_echarts_instance_");
+            item.removeAttribute("data-processed");
+            chartRender(item.parentElement, vditor.options.cdn);
+        });
+        vditor.ir.element.querySelectorAll(".vditor-ir__preview .language-mindmap").forEach((item: HTMLElement) => {
+            item.innerHTML = item.parentElement.previousElementSibling.firstElementChild.innerHTML;
+            item.removeAttribute("_echarts_instance_");
+            item.removeAttribute("data-processed");
+            mindmapRender(item.parentElement, vditor.options.cdn);
+        });
+
         if (this[vditor.currentMode].undoStack.length > 1) {
             enableToolbar(vditor.toolbar.elements, ["undo"]);
         } else {