From 1e1864ef744a05bc113bdd731ff34764fca28ebc Mon Sep 17 00:00:00 2001 From: Liyuan Li Date: Fri, 27 Mar 2020 12:58:36 +0800 Subject: [PATCH] :bug: fix #246 --- CHANGELOG.md | 4 ++++ src/ts/toolbar/EditMode.ts | 13 +++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d2eefca9..4fd0231a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,10 @@ * [open issues](https://github.com/Vanessa219/vditor/issues) +### v3.0.6 / 2020-03-xx + +* [246](https://github.com/Vanessa219/vditor/issues/246) 报错index.min.js:27 `修复缺陷` + ### v3.0.5 / 2020-03-26 * [235](https://github.com/Vanessa219/vditor/pull/235) 修复父元素自定义行高时工具栏垂直不居中 `修复缺陷` diff --git a/src/ts/toolbar/EditMode.ts b/src/ts/toolbar/EditMode.ts index f55202c4f..c1815fac2 100644 --- a/src/ts/toolbar/EditMode.ts +++ b/src/ts/toolbar/EditMode.ts @@ -22,6 +22,13 @@ export const setEditMode = (vditor: IVditor, type: string, event?: Event) => { if (vditor.devtools) { vditor.devtools.renderEchart(vditor); } + if (vditor.preview) { + if ((vditor.currentPreviewMode === "both" || vditor.currentPreviewMode === "preview") && type === "sv") { + vditor.preview.element.style.display = "block"; + } else { + vditor.preview.element.style.display = "none"; + } + } const allToolbar = ["emoji", "headings", "bold", "italic", "strike", "link", "list", "ordered-list", "check", "line", "quote", "code", "inline-code", "upload", "record", "table"]; enableToolbar(vditor.toolbar.elements, allToolbar); @@ -31,7 +38,6 @@ export const setEditMode = (vditor: IVditor, type: string, event?: Event) => { hideToolbar(vditor.toolbar.elements, ["format", "both", "preview"]); vditor.irUndo.resetIcon(vditor); vditor.sv.element.style.display = "none"; - vditor.preview.element.style.display = "none"; vditor.wysiwyg.element.parentElement.style.display = "none"; vditor.ir.element.parentElement.style.display = "block"; @@ -57,7 +63,6 @@ export const setEditMode = (vditor: IVditor, type: string, event?: Event) => { hideToolbar(vditor.toolbar.elements, ["format", "both", "preview"]); vditor.wysiwygUndo.resetIcon(vditor); vditor.sv.element.style.display = "none"; - vditor.preview.element.style.display = "none"; vditor.wysiwyg.element.parentElement.style.display = "block"; vditor.ir.element.parentElement.style.display = "none"; @@ -77,15 +82,11 @@ export const setEditMode = (vditor: IVditor, type: string, event?: Event) => { vditor.ir.element.parentElement.style.display = "none"; if (vditor.currentPreviewMode === "both") { vditor.sv.element.style.display = "block"; - vditor.preview.element.style.display = "block"; } else if (vditor.currentPreviewMode === "preview") { vditor.sv.element.style.display = "none"; - vditor.preview.element.style.display = "block"; } else if (vditor.currentPreviewMode === "editor") { vditor.sv.element.style.display = "block"; - vditor.preview.element.style.display = "none"; } - const wysiwygMD = getMarkdown(vditor); vditor.currentMode = "sv"; formatRender(vditor, wysiwygMD, undefined);