Liyuan Li 5 سال پیش
والد
کامیت
8745ef2983
7فایلهای تغییر یافته به همراه84 افزوده شده و 70 حذف شده
  1. 2 0
      CHANGELOG.md
  2. 1 0
      demo/index.js
  3. 5 0
      src/assets/scss/_sv.scss
  4. 1 0
      src/index.ts
  5. 1 0
      src/ts/constants.ts
  6. 1 0
      src/ts/markdown/setLute.ts
  7. 73 70
      types/index.d.ts

+ 2 - 0
CHANGELOG.md

@@ -79,6 +79,7 @@
 
 ### v3.4.7 / 2020-08-xx
 
+* [719](https://github.com/Vanessa219/vditor/issues/719) 支持 ==Mark== 标记语法 `引入特性`
 * [711](https://github.com/Vanessa219/vditor/issues/711) 调试工具栏图颜色不适配暗黑主题 `改进功能`
 * [718](https://github.com/Vanessa219/vditor/issues/718) 脚注太长浮层渲染溢出 `修复缺陷`
 * [716](https://github.com/Vanessa219/vditor/issues/716) insertValue 无法插入html文本 `改进功能`
@@ -124,6 +125,7 @@
 * 文档修改
   * 3.4.2 `options.hint.at` => "options.hint.extend: IHintExtend[]"
   * 3.4.7 删除线快捷键修改为 `⌘-D`
+  * 3.4.8 添加 `options.preview.markdown.mark` 配置
 
 ### v3.3.12 / 2020-07-28
 

+ 1 - 0
demo/index.js

@@ -62,6 +62,7 @@ window.vditor = new Vditor('vditor', {
   preview: {
     markdown: {
       toc: true,
+      mark: true,
     },
   },
   toolbarConfig: {

+ 5 - 0
src/assets/scss/_sv.scss

@@ -62,6 +62,11 @@
     text-decoration: line-through;
   }
 
+  .mark:not(.vditor-sv__marker) {
+    background-color: yellow;
+    color: black;
+  }
+
   .h1 {
     font-size: 1.75em;
     line-height: 44px;

+ 1 - 0
src/index.ts

@@ -113,6 +113,7 @@ class Vditor extends VditorMethod {
                     inlineMathDigit: this.vditor.options.preview.math.inlineDigit,
                     linkBase: this.vditor.options.preview.markdown.linkBase,
                     listStyle: this.vditor.options.preview.markdown.listStyle,
+                    mark: this.vditor.options.preview.markdown.mark,
                     paragraphBeginningSpace: this.vditor.options.preview.markdown.paragraphBeginningSpace,
                     sanitize: this.vditor.options.preview.markdown.sanitize,
                     toc: this.vditor.options.preview.markdown.toc,

+ 1 - 0
src/ts/constants.ts

@@ -30,6 +30,7 @@ export abstract class Constants {
         footnotes: true,
         linkBase: "",
         listStyle: false,
+        mark: false,
         paragraphBeginningSpace: false,
         sanitize: true,
         toc: false,

+ 1 - 0
src/ts/markdown/setLute.ts

@@ -14,6 +14,7 @@ export const setLute = (options: ILuteOptions) => {
     lute.SetChineseParagraphBeginningSpace(options.paragraphBeginningSpace);
     lute.SetRenderListStyle(options.listStyle);
     lute.SetLinkBase(options.linkBase);
+    lute.SetMark(options.mark);
     if (options.lazyLoadImage) {
         lute.SetImageLazyLoading(options.lazyLoadImage);
     }

+ 73 - 70
types/index.d.ts

@@ -100,109 +100,110 @@ interface ILuteOptions extends IMarkdownConfig {
     inlineMathDigit: boolean;
     lazyLoadImage?: string;
 }
-declare class Lute {
-  public static WalkStop: number;
-  public static WalkSkipChildren: number;
-  public static WalkContinue: number;
-  public static Version: string;
-  public static Caret: string;
-
-  public static New(): Lute;
-
-  public static GetHeadingID(node: ILuteNode): string;
 
-  private constructor();
-
-  public SetJSRenderers(options?: {
-    renderers: {
-        HTML2VditorDOM?: ILuteRender,
-        HTML2VditorIRDOM?: ILuteRender,
-        HTML2Md?: ILuteRender,
-        Md2HTML?: ILuteRender,
-        Md2VditorDOM?: ILuteRender,
-        Md2VditorIRDOM?: ILuteRender,
-        Md2VditorSVDOM?: ILuteRender,
-    },
-  }): void;
+declare class Lute {
+    public static WalkStop: number;
+    public static WalkSkipChildren: number;
+    public static WalkContinue: number;
+    public static Version: string;
+    public static Caret: string;
+
+    public static New(): Lute;
+
+    public static GetHeadingID(node: ILuteNode): string;
+
+    private constructor();
+
+    public SetJSRenderers(options?: {
+        renderers: {
+            HTML2VditorDOM?: ILuteRender,
+            HTML2VditorIRDOM?: ILuteRender,
+            HTML2Md?: ILuteRender,
+            Md2HTML?: ILuteRender,
+            Md2VditorDOM?: ILuteRender,
+            Md2VditorIRDOM?: ILuteRender,
+            Md2VditorSVDOM?: ILuteRender,
+        },
+    }): void;
 
-  public SetChineseParagraphBeginningSpace(enable: boolean): void;
+    public SetChineseParagraphBeginningSpace(enable: boolean): void;
 
-  public SetRenderListStyle(enable: boolean): void;
+    public SetRenderListStyle(enable: boolean): void;
 
-  public SetLinkBase(url: string): void;
+    public SetLinkBase(url: string): void;
 
-  public SetSanitize(enable: boolean): void;
+    public SetMark(enable: boolean): void;
 
-  public SetHeadingAnchor(enable: boolean): void;
+    public SetSanitize(enable: boolean): void;
 
-  public SetImageLazyLoading(imagePath: string): void;
+    public SetHeadingAnchor(enable: boolean): void;
 
-  public SetInlineMathAllowDigitAfterOpenMarker(enable: boolean): void;
+    public SetImageLazyLoading(imagePath: string): void;
 
-  public SetToC(enable: boolean): void;
+    public SetInlineMathAllowDigitAfterOpenMarker(enable: boolean): void;
 
-  public SetFootnotes(enable: boolean): void;
+    public SetToC(enable: boolean): void;
 
-  public SetAutoSpace(enable: boolean): void;
+    public SetFootnotes(enable: boolean): void;
 
-  public SetChinesePunct(enable: boolean): void;
+    public SetAutoSpace(enable: boolean): void;
 
-  public SetFixTermTypo(enable: boolean): void;
+    public SetChinesePunct(enable: boolean): void;
 
-  public SetEmojiSite(emojiSite: string): void;
+    public SetFixTermTypo(enable: boolean): void;
 
-  public SetVditorCodeBlockPreview(enable: boolean): void;
+    public SetEmojiSite(emojiSite: string): void;
 
-  public PutEmojis(emojis: IObject): void;
+    public SetVditorCodeBlockPreview(enable: boolean): void;
 
-  public GetEmojis(): IObject;
+    public PutEmojis(emojis: IObject): void;
 
-  public FormatMd(markdown: string): string;
+    public GetEmojis(): IObject;
 
-  // debugger md
-  public RenderEChartsJSON(text: string): string;
+    // debugger md
+    public RenderEChartsJSON(text: string): string;
 
-  // md 转换为 html
-  public Md2HTML(markdown: string): string;
+    // md 转换为 html
+    public Md2HTML(markdown: string): string;
 
-  // 粘贴时将 html 转换为 md
-  public HTML2Md(html: string): string;
+    // 粘贴时将 html 转换为 md
+    public HTML2Md(html: string): string;
 
-  // wysiwyg 转换为 html
-  public VditorDOM2HTML(vhtml: string): string;
+    // wysiwyg 转换为 html
+    public VditorDOM2HTML(vhtml: string): string;
 
-  // wysiwyg 输入渲染
-  public SpinVditorDOM(html: string): string;
+    // wysiwyg 输入渲染
+    public SpinVditorDOM(html: string): string;
 
-  // 粘贴时将 html 转换为 wysiwyg
-  public HTML2VditorDOM(html: string): string;
+    // 粘贴时将 html 转换为 wysiwyg
+    public HTML2VditorDOM(html: string): string;
 
-  // 将 wysiwyg 转换为 md
-  public VditorDOM2Md(html: string): string;
+    // 将 wysiwyg 转换为 md
+    public VditorDOM2Md(html: string): string;
 
-  // 将 md 转换为 wysiwyg
-  public Md2VditorDOM(markdown: string): string;
+    // 将 md 转换为 wysiwyg
+    public Md2VditorDOM(markdown: string): string;
 
-  // ir 输入渲染
-  public SpinVditorIRDOM(markdown: string): string;
+    // ir 输入渲染
+    public SpinVditorIRDOM(markdown: string): string;
 
-  // ir 获取 md
-  public VditorIRDOM2Md(html: string): string;
+    // ir 获取 md
+    public VditorIRDOM2Md(html: string): string;
 
-  // md 转换为 ir
-  public Md2VditorIRDOM(text: string): string;
+    // md 转换为 ir
+    public Md2VditorIRDOM(text: string): string;
 
-  // 获取 HTML
-  public VditorIRDOM2HTML(html: string): string;
+    // 获取 HTML
+    public VditorIRDOM2HTML(html: string): string;
 
-  // 粘贴时将 html 转换为 sv
-  public HTML2VditorIRDOM(html: string): string;
+    // 粘贴时将 html 转换为 sv
+    public HTML2VditorIRDOM(html: string): string;
 
-  // sv 输入渲染
-  public SpinVditorSVDOM(text: string): string;
+    // sv 输入渲染
+    public SpinVditorSVDOM(text: string): string;
 
-  // 粘贴是 md 转换为 sv
-  public Md2VditorSVDOM(text: string): string;
+    // 粘贴是 md 转换为 sv
+    public Md2VditorSVDOM(text: string): string;
 }
 
 declare const webkitAudioContext: {
@@ -347,6 +348,8 @@ interface IMarkdownConfig {
     linkBase?: string;
     /** 为列表添加标记,以便[自定义列表样式](https://github.com/Vanessa219/vditor/issues/390) 默认值:false */
     listStyle?: boolean;
+    /** 支持 mark 标记 */
+    mark?: boolean;
 }
 
 /** @link https://hacpai.com/article/1549638745630#options-preview */