Browse Source

:recycle: fix #868

Vanessa 5 years ago
parent
commit
601535fb06
3 changed files with 20 additions and 0 deletions
  1. 1 0
      CHANGELOG.md
  2. 13 0
      src/ts/toolbar/EditMode.ts
  3. 6 0
      types/index.d.ts

+ 1 - 0
CHANGELOG.md

@@ -88,6 +88,7 @@
 
 ### v3.7.4 / 2020-12-xx
 
+* [868](https://github.com/Vanessa219/vditor/issues/868) 将 Markdown 引擎选项拆分为解析选项和渲染选项 `改进功能`
 * [869](https://github.com/Vanessa219/vditor/issues/869) 移除 options.preview.markdown. chinesePunct 配置 `开发重构`
 * 文档修改
   * 3.7.4

+ 13 - 0
src/ts/toolbar/EditMode.ts

@@ -52,6 +52,10 @@ export const setEditMode = (vditor: IVditor, type: string, event: Event | string
         vditor.wysiwyg.element.parentElement.style.display = "none";
         vditor.ir.element.parentElement.style.display = "block";
 
+        vditor.lute.SetVditorIR(true);
+        vditor.lute.SetVditorWYSIWYG(false);
+        vditor.lute.SetVditorSV(false);
+
         vditor.currentMode = "ir";
         vditor.ir.element.innerHTML = vditor.lute.Md2VditorIRDOM(markdownText);
         processAfterRender(vditor, {
@@ -78,6 +82,10 @@ export const setEditMode = (vditor: IVditor, type: string, event: Event | string
         vditor.wysiwyg.element.parentElement.style.display = "block";
         vditor.ir.element.parentElement.style.display = "none";
 
+        vditor.lute.SetVditorIR(false);
+        vditor.lute.SetVditorWYSIWYG(true);
+        vditor.lute.SetVditorSV(false);
+
         vditor.currentMode = "wysiwyg";
 
         setPadding(vditor);
@@ -103,6 +111,11 @@ export const setEditMode = (vditor: IVditor, type: string, event: Event | string
         } else if (vditor.options.preview.mode === "editor") {
             vditor.sv.element.style.display = "block";
         }
+
+        vditor.lute.SetVditorIR(false);
+        vditor.lute.SetVditorWYSIWYG(false);
+        vditor.lute.SetVditorSV(true);
+
         vditor.currentMode = "sv";
         let svHTML = processSpinVditorSVDOM(markdownText, vditor);
         if (svHTML === "<div data-block='0'></div>") {

+ 6 - 0
types/index.d.ts

@@ -134,6 +134,12 @@ declare class Lute {
 
     public SetLinkBase(url: string): void;
 
+    public SetVditorIR(enable: boolean): void;
+
+    public SetVditorSV(enable: boolean): void;
+
+    public SetVditorWYSIWYG(enable: boolean): void;
+
     public SetLinkPrefix(url: string): void;
 
     public SetMark(enable: boolean): void;