1
0
Эх сурвалжийг харах

:art: fix https://github.com/Vanessa219/vditor/issues/1422

Vanessa 2 жил өмнө
parent
commit
53ca8f9a0e

+ 1 - 0
CHANGELOG.md

@@ -109,6 +109,7 @@
 
 ### v3.9.4 / 2023-07
 
+* [支持自动链接配置 `gfmAutoLink`](https://github.com/Vanessa219/vditor/issues/1422) `引入特性`
 * [订正多语言繁体中的文案错误](https://github.com/Vanessa219/vditor/pull/1421) `文档相关`
 * [修正多语言中英语的错误](https://github.com/Vanessa219/vditor/pull/1416) `文档相关`
 * [IR, SV 模式下输入内容后立即点击工具栏下拉无反应](https://github.com/Vanessa219/vditor/issues/1414) `改进功能`

+ 1 - 0
README.md

@@ -313,6 +313,7 @@ new Vditor('vditor', {
 |   | 说明 | 默认值 |
 | - | - | - |
 | autoSpace | 自动空格 | false |
+| gfmAutoLink | 自动链接 | true |
 | fixTermTypo | 自动矫正术语 | false |
 | toc | 插入目录 | false |
 | footnotes | 脚注 | true |

+ 1 - 0
README_en_US.md

@@ -297,6 +297,7 @@ new Vditor('vditor', {
 |   | Explanation | Default |
 | - | - | - |
 | autoSpace | Autospace | false |
+| gfmAutoLink | Automatic link | true |
 | fixTermTypo | Automatically correct terminology | false |
 | toc | Insert Table of Contents | false |
 | footnotes | Footnotes | true |

+ 1 - 0
src/index.ts

@@ -477,6 +477,7 @@ class Vditor extends VditorMethod {
         ).then(() => {
             this.vditor.lute = setLute({
                 autoSpace: this.vditor.options.preview.markdown.autoSpace,
+                gfmAutoLink: this.vditor.options.preview.markdown.gfmAutoLink,
                 codeBlockPreview: this.vditor.options.preview.markdown
                     .codeBlockPreview,
                 emojiSite: this.vditor.options.hint.emojiPath,

+ 1 - 0
src/ts/constants.ts

@@ -32,6 +32,7 @@ export abstract class Constants {
   public static readonly CDN = `https://unpkg.com/vditor@${VDITOR_VERSION}`;
   public static readonly MARKDOWN_OPTIONS = {
     autoSpace: false,
+    gfmAutoLink: true,
     codeBlockPreview: true,
     fixTermTypo: false,
     footnotes: true,

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

@@ -47,6 +47,7 @@ export const md2html = (mdText: string, options?: IPreviewOptions) => {
     return addScript(`${mergedOptions.cdn}/dist/js/lute/lute.min.js`, "vditorLuteScript").then(() => {
         const lute = setLute({
             autoSpace: mergedOptions.markdown.autoSpace,
+            gfmAutoLink: mergedOptions.markdown.gfmAutoLink,
             codeBlockPreview: mergedOptions.markdown.codeBlockPreview,
             emojiSite: mergedOptions.emojiPath,
             emojis: mergedOptions.customEmoji,

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

@@ -16,6 +16,7 @@ export const setLute = (options: ILuteOptions) => {
     lute.SetLinkBase(options.linkBase);
     lute.SetLinkPrefix(options.linkPrefix);
     lute.SetMark(options.mark);
+    lute.SetGFMAutoLink(options.gfmAutoLink);
     if (options.lazyLoadImage) {
         lute.SetImageLazyLoading(options.lazyLoadImage);
     }

+ 4 - 0
types/index.d.ts

@@ -154,6 +154,8 @@ declare class Lute {
 
     public SetMark(enable: boolean): void;
 
+    public SetGFMAutoLink(enable: boolean): void;
+
     public SetSanitize(enable: boolean): void;
 
     public SetHeadingAnchor(enable: boolean): void;
@@ -469,6 +471,8 @@ interface IMarkdownConfig {
     listStyle?: boolean;
     /** 支持 mark 标记 */
     mark?: boolean;
+    /** 支持自动链接 */
+    gfmAutoLink?: boolean;
 }
 
 /** @link https://ld246.com/article/1549638745630#options-preview */