浏览代码

:art: add footnote options

Van 5 年之前
父节点
当前提交
09561c6349
共有 4 个文件被更改,包括 9 次插入3 次删除
  1. 1 1
      CHANGELOG.md
  2. 2 0
      src/ts/markdown/md2html.ts
  3. 4 1
      src/ts/types/index.d.ts
  4. 2 1
      src/ts/util/Options.ts

+ 1 - 1
CHANGELOG.md

@@ -127,7 +127,7 @@
   * 引用快捷键修改
   * 移除 index-preview.html, index-preview.js 文件
   * 添加 graphvizRender
-  * 添加 option.preview.markdown.toc
+  * 添加 option.preview.markdown.toc/footnotes
   * 添加 option.hideToolbar
   * options.preview.markdown.autoSpace/chinesePunct/fixTermTypo 默认值设置为 false
 

+ 2 - 0
src/ts/markdown/md2html.ts

@@ -19,6 +19,7 @@ export const loadLuteJs = (vditor: IVditor | string) => {
         vditor.lute.SetInlineMathAllowDigitAfterOpenMarker(vditor.options.preview.math.inlineDigit);
         vditor.lute.SetAutoSpace(vditor.options.preview.markdown.autoSpace);
         vditor.lute.SetToC(vditor.options.preview.markdown.toc);
+        vditor.lute.SetFootnotes(vditor.options.preview.markdown.footnotes);
         vditor.lute.SetChinesePunct(vditor.options.preview.markdown.chinesePunct);
         vditor.lute.SetFixTermTypo(vditor.options.preview.markdown.fixTermTypo);
     }
@@ -41,6 +42,7 @@ export const md2htmlByPreview = (mdText: string, options?: IPreviewOptions) => {
     lute.SetInlineMathAllowDigitAfterOpenMarker(options.math.inlineDigit);
     lute.SetAutoSpace(options.markdown.autoSpace);
     lute.SetToC(options.markdown.toc);
+    lute.SetFootnotes(options.markdown.footnotes);
     lute.SetChinesePunct(options.markdown.chinesePunct);
     lute.SetFixTermTypo(options.markdown.fixTermTypo);
     return lute.Md2HTML(mdText);

+ 4 - 1
src/ts/types/index.d.ts

@@ -12,7 +12,7 @@ interface ILuteRender {
                 Type: number,
             },
         }
-    },               entering: boolean) => [string, number];
+    }, entering: boolean) => [string, number];
 }
 
 interface ILute {
@@ -33,6 +33,8 @@ interface ILute {
 
     SetToC(enable: boolean): void;
 
+    SetFootnotes(enable: boolean): void;
+
     SetAutoSpace(enable: boolean): void;
 
     SetChinesePunct(enable: boolean): void;
@@ -160,6 +162,7 @@ interface IMarkdownConfig {
     fixTermTypo?: boolean;
     chinesePunct?: boolean;
     toc?: boolean;
+    footnotes?: boolean;
 }
 
 interface IPreview {

+ 2 - 1
src/ts/util/Options.ts

@@ -45,7 +45,8 @@ export class Options {
                 autoSpace: false,
                 chinesePunct: false,
                 fixTermTypo: false,
-                toc: true,
+                footnotes: true,
+                toc: false,
             },
             math: {
                 engine: "KaTeX",