Van пре 6 година
родитељ
комит
2d2f46acd4
4 измењених фајлова са 14 додато и 14 уклоњено
  1. 1 1
      CHANGELOG.md
  2. 2 2
      src/ts/i18n/index.ts
  3. 3 3
      src/ts/markdown/codeRender.ts
  4. 8 8
      src/ts/preview/index.ts

+ 1 - 1
CHANGELOG.md

@@ -1,6 +1,6 @@
 ## Vditor change log
 ## Vditor change log
 
 
-### v1.5.11 / 2019-07-06
+### v1.5.12 / 2019-07-09
 
 
 * [73](https://github.com/b3log/vditor/issues/73) iframe 添加 max-width `enhancement`
 * [73](https://github.com/b3log/vditor/issues/73) iframe 添加 max-width `enhancement`
 * [72](https://github.com/b3log/vditor/issues/72) 当编辑器父元素为 position: fix 时 hit 计算错误 `bug`
 * [72](https://github.com/b3log/vditor/issues/72) 当编辑器父元素为 position: fix 时 hit 计算错误 `bug`

+ 2 - 2
src/ts/i18n/index.ts

@@ -19,6 +19,7 @@ export const i18n: II18n = {
         "nameEmpty": "Name is empty",
         "nameEmpty": "Name is empty",
         "ordered-list": "Order List",
         "ordered-list": "Order List",
         "over": "over",
         "over": "over",
+        "performanceTip": "Real-time preview requires ${x}ms, you can close it",
         "preview": "Preview",
         "preview": "Preview",
         "quote": "Quote",
         "quote": "Quote",
         "record": "Start Record/End Record",
         "record": "Start Record/End Record",
@@ -29,7 +30,6 @@ export const i18n: II18n = {
         "undo": "Undo",
         "undo": "Undo",
         "upload": "Upload image or file",
         "upload": "Upload image or file",
         "uploading": "uploading...",
         "uploading": "uploading...",
-        "performanceTip": "Real-time preview requires ${x}ms, you can close it"
     },
     },
     zh_CN: {
     zh_CN: {
         "bold": "粗体",
         "bold": "粗体",
@@ -51,6 +51,7 @@ export const i18n: II18n = {
         "nameEmpty": "文件名不能为空",
         "nameEmpty": "文件名不能为空",
         "ordered-list": "有序列表",
         "ordered-list": "有序列表",
         "over": "超过",
         "over": "超过",
+        "performanceTip": "实时预览需 ${x}ms,可点击预览按钮进行关闭",
         "preview": "预览",
         "preview": "预览",
         "quote": "引用",
         "quote": "引用",
         "record": "开始录音/结束录音",
         "record": "开始录音/结束录音",
@@ -61,6 +62,5 @@ export const i18n: II18n = {
         "undo": "撤销",
         "undo": "撤销",
         "upload": "上传图片或文件",
         "upload": "上传图片或文件",
         "uploading": "上传中...",
         "uploading": "上传中...",
-        "performanceTip": "实时预览需 ${x}ms,可点击预览按钮进行关闭"
     },
     },
 };
 };

+ 3 - 3
src/ts/markdown/codeRender.ts

@@ -2,7 +2,7 @@ import copySVG from "../../assets/icons/copy.svg";
 import {i18n} from "../i18n/index";
 import {i18n} from "../i18n/index";
 
 
 export const codeRender = (element: HTMLElement, lang: (keyof II18nLang)) => {
 export const codeRender = (element: HTMLElement, lang: (keyof II18nLang)) => {
-    element.querySelectorAll("pre > code").forEach((e: HTMLElement, index:number) => {
+    element.querySelectorAll("pre > code").forEach((e: HTMLElement, index: number) => {
         if (e.className.indexOf("language-mermaid") > -1 || e.className.indexOf("language-echarts") > -1) {
         if (e.className.indexOf("language-mermaid") > -1 || e.className.indexOf("language-echarts") > -1) {
             return;
             return;
         }
         }
@@ -12,8 +12,8 @@ export const codeRender = (element: HTMLElement, lang: (keyof II18nLang)) => {
         }
         }
 
 
         // 避免预览区在渲染后由于代码块过多产生性能问题 https://github.com/b3log/vditor/issues/67
         // 避免预览区在渲染后由于代码块过多产生性能问题 https://github.com/b3log/vditor/issues/67
-        if (element.className.indexOf('vditor-preview') > -1 && index > 5) {
-            return
+        if (element.className.indexOf("vditor-preview") > -1 && index > 5) {
+            return;
         }
         }
 
 
         const divElement = document.createElement("div");
         const divElement = document.createElement("div");

+ 8 - 8
src/ts/preview/index.ts

@@ -1,9 +1,9 @@
+import {i18n} from "../i18n/index";
 import {chartRender} from "../markdown/chartRender";
 import {chartRender} from "../markdown/chartRender";
 import {codeRender} from "../markdown/codeRender";
 import {codeRender} from "../markdown/codeRender";
 import {mathRender} from "../markdown/mathRender";
 import {mathRender} from "../markdown/mathRender";
 import {mermaidRender} from "../markdown/mermaidRender";
 import {mermaidRender} from "../markdown/mermaidRender";
 import {md2html} from "../markdown/render";
 import {md2html} from "../markdown/render";
-import {i18n} from "../i18n/index";
 
 
 export class Preview {
 export class Preview {
     public element: HTMLElement;
     public element: HTMLElement;
@@ -22,10 +22,10 @@ export class Preview {
 
 
     public render(vditor: IVditor, value?: string) {
     public render(vditor: IVditor, value?: string) {
         if (this.element.style.display === "none") {
         if (this.element.style.display === "none") {
-            if (vditor.upload.element.getAttribute('data-type') === 'renderPerformance') {
+            if (vditor.upload.element.getAttribute("data-type") === "renderPerformance") {
                 vditor.upload.element.style.opacity = "0";
                 vditor.upload.element.style.opacity = "0";
                 vditor.upload.element.className = "vditor-upload";
                 vditor.upload.element.className = "vditor-upload";
-                vditor.upload.element.removeAttribute('data-type')
+                vditor.upload.element.removeAttribute("data-type");
             }
             }
             return;
             return;
         }
         }
@@ -42,7 +42,7 @@ export class Preview {
 
 
         clearTimeout(vditor.mdTimeoutId);
         clearTimeout(vditor.mdTimeoutId);
         vditor.mdTimeoutId = window.setTimeout(() => {
         vditor.mdTimeoutId = window.setTimeout(() => {
-            const renderStartTime = new Date().getTime()
+            const renderStartTime = new Date().getTime();
             if (vditor.options.preview.url) {
             if (vditor.options.preview.url) {
                 const xhr = new XMLHttpRequest();
                 const xhr = new XMLHttpRequest();
                 xhr.open("POST", vditor.options.preview.url);
                 xhr.open("POST", vditor.options.preview.url);
@@ -81,18 +81,18 @@ export class Preview {
         mermaidRender(vditor.preview.element);
         mermaidRender(vditor.preview.element);
         codeRender(vditor.preview.element, vditor.options.lang);
         codeRender(vditor.preview.element, vditor.options.lang);
         chartRender(vditor.preview.element);
         chartRender(vditor.preview.element);
-        const time = (new Date().getTime() - startTime)
+        const time = (new Date().getTime() - startTime);
         if ((new Date().getTime() - startTime) > 1000) {
         if ((new Date().getTime() - startTime) > 1000) {
             // https://github.com/b3log/vditor/issues/67
             // https://github.com/b3log/vditor/issues/67
             vditor.upload.element.style.opacity = "1";
             vditor.upload.element.style.opacity = "1";
-            vditor.upload.element.setAttribute('data-type', 'renderPerformance')
+            vditor.upload.element.setAttribute("data-type", "renderPerformance");
             vditor.upload.element.className = "vditor-upload vditor-upload--tip";
             vditor.upload.element.className = "vditor-upload vditor-upload--tip";
-            vditor.upload.element.children[0].innerHTML = i18n[vditor.options.lang].performanceTip.replace('${x}',
+            vditor.upload.element.children[0].innerHTML = i18n[vditor.options.lang].performanceTip.replace("${x}",
                 time.toString());
                 time.toString());
         } else {
         } else {
             vditor.upload.element.style.opacity = "0";
             vditor.upload.element.style.opacity = "0";
             vditor.upload.element.className = "vditor-upload";
             vditor.upload.element.className = "vditor-upload";
-            vditor.upload.element.removeAttribute('data-type')
+            vditor.upload.element.removeAttribute("data-type");
         }
         }
     }
     }
 }
 }