Browse Source

🎨 https://github.com/Vanessa219/vditor/issues/1850 (#1853)

Co-authored-by: V <[email protected]>
Yu-Core 1 month ago
parent
commit
a6841fca26
8 changed files with 21 additions and 2 deletions
  1. 5 2
      CHANGELOG.md
  2. 2 0
      README.md
  3. 2 0
      README_en_US.md
  4. 2 0
      src/index.ts
  5. 2 0
      src/ts/constants.ts
  6. 2 0
      src/ts/markdown/previewRender.ts
  7. 2 0
      src/ts/markdown/setLute.ts
  8. 4 0
      types/index.d.ts

+ 5 - 2
CHANGELOG.md

@@ -3,6 +3,8 @@
 ### 升级
 
 * 3.11
+  * 添加 options.preview.markdown.sup
+  * 添加 options.preview.markdown.sub
   * 添加 options.customWysiwygToolbar
   * 添加 options.upload.base64ToLink
   * 添加 options.upload.xhr
@@ -28,9 +30,10 @@
 
 * [open issues](https://github.com/Vanessa219/vditor/issues)
 
-### v3.11.3
+### v3.11.3 / 2025-09
 
-* [升级 mermaid.js 11.6.0 至 11.11.0](https://github.com/Vanessa219/vditor/issues/1857)
+* [支持上标下标配置 `sup` `sub`](https://github.com/Vanessa219/vditor/issues/1850) `引入特性`
+* [升级 mermaid.js 11.6.0 至 11.11.0](https://github.com/Vanessa219/vditor/issues/1857) `改进功能`
 
 ### v3.11.2 / 2025-09-02
 

+ 2 - 0
README.md

@@ -334,6 +334,8 @@ new Vditor('vditor', {
 | linkBase | 链接相对路径前缀 | '' |
 | linkPrefix | 链接强制前缀 | '' |
 | mark | 启用 mark 标记 | false |
+| sup | 上标 | false |
+| sub | 下标 | false |
 
 #### options.preview.theme
 

+ 2 - 0
README_en_US.md

@@ -318,6 +318,8 @@ new Vditor('vditor', {
 | linkBase | link relative path prefix | '' |
 | linkPrefix | link prefix | '' |
 | mark | enable mark tag | false |
+| sup | superscript | false |
+| sub | subscript | false |
 
 #### options.preview.math
 

+ 2 - 0
src/index.ts

@@ -543,6 +543,8 @@ class Vditor extends VditorMethod {
                 paragraphBeginningSpace: this.vditor.options.preview.markdown
                     .paragraphBeginningSpace,
                 sanitize: this.vditor.options.preview.markdown.sanitize,
+                sub: this.vditor.options.preview.markdown.sub,
+                sup: this.vditor.options.preview.markdown.sup,
                 toc: this.vditor.options.preview.markdown.toc,
             });
 

+ 2 - 0
src/ts/constants.ts

@@ -62,6 +62,8 @@ export abstract class Constants {
         mathBlockPreview: true,
         paragraphBeginningSpace: false,
         sanitize: true,
+        sub: false,
+        sup: false,
         toc: false,
     };
     public static readonly HLJS_OPTIONS = {

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

@@ -75,6 +75,8 @@ export const md2html = (mdText: string, options?: IPreviewOptions) => {
             mathBlockPreview: mergedOptions.markdown.mathBlockPreview,
             paragraphBeginningSpace: mergedOptions.markdown.paragraphBeginningSpace,
             sanitize: mergedOptions.markdown.sanitize,
+            sub: mergedOptions.markdown.sub,
+            sup: mergedOptions.markdown.sup,
             toc: mergedOptions.markdown.toc,
         });
         if (options?.renderers) {

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

@@ -20,5 +20,7 @@ export const setLute = (options: ILuteOptions) => {
     if (options.lazyLoadImage) {
         lute.SetImageLazyLoading(options.lazyLoadImage);
     }
+    lute.SetSup(options.sup);
+    lute.SetSub(options.sub);
     return lute;
 };

+ 4 - 0
types/index.d.ts

@@ -526,6 +526,10 @@ interface IMarkdownConfig {
     mark?: boolean;
     /** 支持自动链接 */
     gfmAutoLink?: boolean;
+    /** 支持上标 */
+    sup?: boolean;
+    /** 支持下标 */
+    sub?: boolean;
 }
 
 /** @link https://ld246.com/article/1549638745630#options-preview */