Liyuan Li 5 rokov pred
rodič
commit
dd7578c454

+ 1 - 0
CHANGELOG.md

@@ -66,6 +66,7 @@
 
 ### v3.2.10 / 2020-05-xx
 
+* [431](https://github.com/Vanessa219/vditor/issues/431) 链接、图片相对路径支持 `引入特性`
 * [430](https://github.com/Vanessa219/vditor/issues/430) cursor location when press ctrl+b after checkbox `修复缺陷`
 * [429](https://github.com/Vanessa219/vditor/issues/429) localStorage被禁用时,报错 `修复缺陷`
 * [427](https://github.com/Vanessa219/vditor/issues/427) headings 大小调整 `改进功能`

+ 1 - 0
src/index.ts

@@ -113,6 +113,7 @@ class Vditor extends VditorMethod {
                 footnotes: this.vditor.options.preview.markdown.footnotes,
                 headingAnchor: false,
                 inlineMathDigit: this.vditor.options.preview.math.inlineDigit,
+                linkBase: this.vditor.options.preview.markdown.linkBase,
                 listMarker: this.vditor.options.preview.markdown.listMarker,
                 paragraphBeginningSpace: this.vditor.options.preview.markdown.paragraphBeginningSpace,
                 sanitize: this.vditor.options.preview.markdown.sanitize,

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

@@ -34,6 +34,7 @@ const mergeOptions = (options?: IPreviewOptions) => {
             codeBlockPreview: true,
             fixTermTypo: false,
             footnotes: true,
+            linkBase: "",
             listMarker: false,
             paragraphBeginningSpace: false,
             sanitize: true,
@@ -79,6 +80,7 @@ export const md2html = (mdText: string, options?: IPreviewOptions) => {
             headingAnchor: mergedOptions.anchor !== 0,
             inlineMathDigit: mergedOptions.math.inlineDigit,
             lazyLoadImage: mergedOptions.lazyLoadImage,
+            linkBase: mergedOptions.markdown.linkBase,
             listMarker: mergedOptions.markdown.listMarker,
             paragraphBeginningSpace: mergedOptions.markdown.paragraphBeginningSpace,
             sanitize: mergedOptions.markdown.sanitize,

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

@@ -14,6 +14,7 @@ export const setLute = (options: ILuteOptions) => {
     lute.SetSanitize(options.sanitize);
     lute.SetChineseParagraphBeginningSpace(options.paragraphBeginningSpace);
     lute.SetRenderListMarker(options.listMarker);
+    lute.SetLinkBase(options.linkBase);
     if (options.lazyLoadImage) {
         lute.SetImageLazyLoading(options.lazyLoadImage);
     }

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

@@ -87,6 +87,7 @@ export class Options {
                 codeBlockPreview: true,
                 fixTermTypo: false,
                 footnotes: true,
+                linkBase: "",
                 listMarker: false,
                 sanitize: true,
                 setext: false,

+ 4 - 0
types/index.d.ts

@@ -124,6 +124,8 @@ interface ILute {
 
     SetRenderListMarker(enable: boolean): void;
 
+    SetLinkBase(url: string): void;
+
     SetSanitize(enable: boolean): void;
 
     SetHeadingAnchor(enable: boolean): void;
@@ -327,6 +329,8 @@ interface IMarkdownConfig {
     sanitize: boolean;
     /** 内容主题。默认值:light */
     theme?: string;
+    /** 链接前缀。默认值:'' */
+    linkBase?: string;
     /** 为列表添加标记,以便[自定义列表样式](https://github.com/Vanessa219/vditor/issues/390) 默认值:false */
     listMarker?: boolean;
 }