Browse Source

:recycle: fix #626

Liyuan Li 5 years ago
parent
commit
13b0b04161

+ 2 - 0
CHANGELOG.md

@@ -68,7 +68,9 @@
 
 ### v3.3.12 / 2020-07-xx
 
+* [626](https://github.com/Vanessa219/vditor/issues/626) 去除 Setext 标题解析开关 `开发重构`
 * [451](https://github.com/Vanessa219/vditor/issues/451) IR 模式保留 Emoji 原始输入 `改进功能`
+* 移除 `options.preview.markdown.setext`
 
 ### v3.3.11 / 2020-07-24
 

+ 0 - 1
README.md

@@ -302,7 +302,6 @@ new Vditor('vditor', {
 | toc | 插入目录 | false |
 | footnotes | 脚注 | true |
 | codeBlockPreview | wysiwyg 和 ir 模式下是否对代码块进行渲染 | true |
-| setext | 是否解析 setext 标题 | true |
 | paragraphBeginningSpace | 段落开头空两个 | false |
 | sanitize | 是否启用过滤 XSS | true |
 | listStyle | 为列表添加 data-style 属性 | false |

+ 0 - 1
README_en_US.md

@@ -287,7 +287,6 @@ new Vditor('vditor', {
 | toc | Insert Table of Contents | false |
 | footnotes | Footnotes | true |
 | codeBlockPreview |Whether to render code blocks in wysiwyg and ir modes | true |
-| setext | Whether to parse the setext header | true |
 | paragraphBeginningSpace | Two spaces before the paragraph | false |
 | sanitize | Use XSS | true |
 | listStyle | add data-style attribute | false |

+ 0 - 1
src/index.ts

@@ -115,7 +115,6 @@ class Vditor extends VditorMethod {
                     listStyle: this.vditor.options.preview.markdown.listStyle,
                     paragraphBeginningSpace: this.vditor.options.preview.markdown.paragraphBeginningSpace,
                     sanitize: this.vditor.options.preview.markdown.sanitize,
-                    setext: this.vditor.options.preview.markdown.setext,
                     toc: this.vditor.options.preview.markdown.toc,
                 });
 

+ 0 - 1
src/ts/constants.ts

@@ -32,7 +32,6 @@ export abstract class Constants {
         listStyle: false,
         paragraphBeginningSpace: false,
         sanitize: true,
-        setext: true,
         toc: false,
     };
     public static readonly HLJS_OPTIONS = {

+ 1 - 1
src/ts/ir/input.ts

@@ -15,7 +15,7 @@ export const input = (vditor: IVditor, range: Range, ignoreSpace = false) => {
     // 前后可以输入空格
     if (blockElement && !ignoreSpace) {
         if (isHrMD(blockElement.innerHTML) ||
-            isHeadingMD(blockElement.innerHTML, vditor.options.preview.markdown.setext)) {
+            isHeadingMD(blockElement.innerHTML)) {
             return;
         }
 

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

@@ -53,7 +53,6 @@ export const md2html = (mdText: string, options?: IPreviewOptions) => {
             listStyle: mergedOptions.markdown.listStyle,
             paragraphBeginningSpace: mergedOptions.markdown.paragraphBeginningSpace,
             sanitize: mergedOptions.markdown.sanitize,
-            setext: mergedOptions.markdown.setext,
             toc: mergedOptions.markdown.toc,
         });
         if (options?.renderers) {

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

@@ -10,7 +10,6 @@ export const setLute = (options: ILuteOptions) => {
     lute.SetChinesePunct(options.chinesePunct);
     lute.SetFixTermTypo(options.fixTermTypo);
     lute.SetVditorCodeBlockPreview(options.codeBlockPreview);
-    lute.SetSetext(options.setext);
     lute.SetSanitize(options.sanitize);
     lute.SetChineseParagraphBeginningSpace(options.paragraphBeginningSpace);
     lute.SetRenderListStyle(options.listStyle);

+ 2 - 5
src/ts/util/fixBrowserBehavior.ts

@@ -375,10 +375,7 @@ export const isHrMD = (text: string) => {
     return false;
 };
 
-export const isHeadingMD = (text: string, setext: boolean) => {
-    if (!setext) {
-        return false;
-    }
+export const isHeadingMD = (text: string) => {
     // - =
     const textArray = text.trimRight().split("\n");
     text = textArray.pop();
@@ -564,7 +561,7 @@ export const fixMarkdown = (event: KeyboardEvent, vditor: IVditor, pElement: HTM
             return true;
         }
 
-        if (isHeadingMD(pElement.innerHTML, vditor.options.preview.markdown.setext)) {
+        if (isHeadingMD(pElement.innerHTML)) {
             // heading 渲染
             pElement.outerHTML = vditor.lute.SpinVditorDOM(pElement.innerHTML + '<p data-block="0"><wbr>\n</p>');
             setRangeByWbr(vditor[vditor.currentMode].element, range);

+ 1 - 1
src/ts/wysiwyg/index.ts

@@ -212,7 +212,7 @@ class WYSIWYG {
 
             if ((startSpace && !blockElement.querySelector(".language-mindmap"))
                 || endSpace || isHrMD(blockElement.innerHTML) ||
-                isHeadingMD(blockElement.innerHTML, vditor.options.preview.markdown.setext)) {
+                isHeadingMD(blockElement.innerHTML)) {
                 return;
             }
 

+ 0 - 4
types/index.d.ts

@@ -152,8 +152,6 @@ interface ILute {
 
     SetEmojiSite(emojiSite: string): void;
 
-    SetSetext(enable: boolean): void;
-
     SetVditorCodeBlockPreview(enable: boolean): void;
 
     PutEmojis(emojis: IObject): void;
@@ -343,8 +341,6 @@ interface IMarkdownConfig {
     footnotes?: boolean;
     /** wysiwyg & ir 模式代码块是否渲染。默认值: true */
     codeBlockPreview: boolean;
-    /** 是否解析 setext 标题。默认值: true */
-    setext: boolean;
     /** 是否启用过滤 XSS。默认值: true */
     sanitize: boolean;
     /** 链接前缀。默认值:'' */