Browse Source

:bug: debug size

Van 5 years ago
parent
commit
a6c15a779f
4 changed files with 23 additions and 12 deletions
  1. 8 8
      src/ts/markdown/md2html.ts
  2. 2 0
      src/ts/toolbar/EditMode.ts
  3. 11 4
      src/ts/ui/initUI.ts
  4. 2 0
      src/ts/ui/setTheme.ts

+ 8 - 8
src/ts/markdown/md2html.ts

@@ -2,15 +2,15 @@ import {VDITOR_VERSION} from "../constants";
 import {addScript} from "../util/addScript";
 
 export const loadLuteJs = (vditor: IVditor | string) => {
-    let cdn = `https://cdn.jsdelivr.net/npm/vditor@${VDITOR_VERSION}`;
-    if (typeof vditor === "string" && vditor) {
-        cdn = vditor;
-    } else if (typeof vditor === "object" && vditor.options.cdn) {
-        cdn = vditor.options.cdn;
-    }
-    addScript(`${cdn}/dist/js/lute/lute.min.js`, "vditorLuteScript");
+    // let cdn = `https://cdn.jsdelivr.net/npm/vditor@${VDITOR_VERSION}`;
+    // if (typeof vditor === "string" && vditor) {
+    //     cdn = vditor;
+    // } else if (typeof vditor === "object" && vditor.options.cdn) {
+    //     cdn = vditor.options.cdn;
+    // }
+    // addScript(`${cdn}/dist/js/lute/lute.min.js`, "vditorLuteScript");
     // addScript(`/src/js/lute/lute.min.js`, "vditorLuteScript");
-    // addScript(`http://192.168.80.35:9090/lute.min.js?${new Date().getTime()}`, "vditorLuteScript");
+    addScript(`http://192.168.80.35:9090/lute.min.js?${new Date().getTime()}`, "vditorLuteScript");
 
     if (vditor && typeof vditor === "object" && !vditor.lute) {
         vditor.lute = Lute.New();

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

@@ -5,6 +5,7 @@ import {getMarkdown} from "../util/getMarkdown";
 import {renderDomByMd} from "../wysiwyg/renderDomByMd";
 import {MenuItem} from "./MenuItem";
 import {enableToolbar, hidePanel, hideToolbar, removeCurrentToolbar, showToolbar} from "./setToolbar";
+import {setPadding} from "../ui/initUI";
 
 export const setEditMode = (event: Event, vditor: IVditor, type: string) => {
     event.preventDefault();
@@ -16,6 +17,7 @@ export const setEditMode = (event: Event, vditor: IVditor, type: string) => {
     if (vditor.devtools && vditor.devtools.ASTChart && vditor.devtools.element.style.display === "block") {
         vditor.devtools.ASTChart.resize();
     }
+    setPadding(vditor);
     if (type === "ir") {
         hideToolbar(vditor.toolbar.elements, ["format", "both", "preview"]);
         vditor.editor.element.style.display = "none";

+ 11 - 4
src/ts/ui/initUI.ts

@@ -60,10 +60,17 @@ export const initUI = (vditor: IVditor) => {
 };
 
 export const setPadding = (vditor: IVditor) => {
-    const padding = (vditor.wysiwyg.element.parentElement.parentElement.clientWidth
-        - vditor.options.preview.maxWidth) / 2;
-    vditor.wysiwyg.element.style.padding = `10px ${Math.max(35, padding)}px`;
-    vditor.ir.element.style.padding = `10px ${Math.max(35, padding)}px`;
+    if (vditor.wysiwyg.element.parentElement.style.display !== "none") {
+        const padding = (vditor.wysiwyg.element.parentElement.clientWidth
+            - vditor.options.preview.maxWidth) / 2;
+        vditor.wysiwyg.element.style.padding = `10px ${Math.max(35, padding)}px`;
+    }
+
+    if (vditor.ir.element.parentElement.style.display !== "none") {
+        const padding = (vditor.ir.element.parentElement.clientWidth
+            - vditor.options.preview.maxWidth) / 2;
+        vditor.ir.element.style.padding = `10px ${Math.max(35, padding)}px`;
+    }
 };
 
 const afterRender = (vditor: IVditor, contentElement: HTMLElement) => {

+ 2 - 0
src/ts/ui/setTheme.ts

@@ -6,11 +6,13 @@ export const setTheme = (vditor: IVditor) => {
             vditor.preview.element.firstElementChild.classList.add("vditor-reset--dark");
         }
         vditor.wysiwyg.element.classList.add("vditor-reset--dark");
+        vditor.ir.element.classList.add("vditor-reset--dark");
     } else {
         vditorElement.classList.remove("vditor--dark");
         if (vditor.preview) {
             vditor.preview.element.firstElementChild.classList.remove("vditor-reset--dark");
         }
         vditor.wysiwyg.element.classList.remove("vditor-reset--dark");
+        vditor.ir.element.classList.remove("vditor-reset--dark");
     }
 };