瀏覽代碼

:recycle: fix #529

Liyuan Li 5 年之前
父節點
當前提交
e55bb216dd
共有 9 個文件被更改,包括 21 次插入51 次删除
  1. 2 0
      CHANGELOG.md
  2. 9 12
      README.md
  3. 6 5
      demo/index.js
  4. 0 3
      src/ts/i18n/index.ts
  5. 3 3
      src/ts/toolbar/EditMode.ts
  6. 0 16
      src/ts/toolbar/Format.ts
  7. 1 1
      src/ts/toolbar/Preview.ts
  8. 0 4
      src/ts/toolbar/index.ts
  9. 0 7
      src/ts/util/Options.ts

+ 2 - 0
CHANGELOG.md

@@ -68,6 +68,7 @@
 
 ### v3.3.4 / 2020-07-xx
 
+* [529](https://github.com/Vanessa219/vditor/issues/529) 移除格式化按钮 `改进功能`
 * [526](https://github.com/Vanessa219/vditor/issues/526) 字符串中带有 \ 符号时,从 \ 后面,但不是行尾 Backspace 删除字符到达 \ 时处理异常 `修复缺陷`
 * [517](https://github.com/Vanessa219/vditor/issues/517) Duplicate CSS(render.html) `修复缺陷`
 * [522](https://github.com/Vanessa219/vditor/issues/522) 从 WPS Office 复制文本,粘贴异常 `修复缺陷`
@@ -75,6 +76,7 @@
 * [516](https://github.com/Vanessa219/vditor/issues/516) 高亮自动填写功能未生效问题 `修复缺陷`
 * [355](https://github.com/Vanessa219/vditor/issues/355) 新增 VditorSVDOM 渲染器 `引入特新`
 * 移除 `options.keymap`
+* 移除工具栏上的格式化功能
 
 ### v3.3.3 / 2020-06-23
 

File diff suppressed because it is too large
+ 9 - 12
README.md


+ 6 - 5
demo/index.js

@@ -78,11 +78,12 @@ window.vditor = new Vditor('vditor', {
       'j': 'https://unpkg.com/[email protected]/dist/images/emoji/j.png',
     },
     at: (key) => {
-      return [{
-        value: '@Vanessa',
-        html: '<img src="https://avatars0.githubusercontent.com/u/970828?s=60&v=4"/> Vanessa'
-      }]
-    }
+      return [
+        {
+          value: '@Vanessa',
+          html: '<img src="https://avatars0.githubusercontent.com/u/970828?s=60&v=4"/> Vanessa',
+        }]
+    },
   },
   tab: '\t',
   upload: {

+ 0 - 3
src/ts/i18n/index.ts

@@ -25,7 +25,6 @@ export const i18n: II18n = {
         "export": "Export",
         "fileTypeError": "file type is error",
         "footnoteRef": "Footnote Ref",
-        "format": "Format",
         "fullscreen": "Toggle Fullscreen",
         "generate": "Generating",
         "headings": "Headings",
@@ -99,7 +98,6 @@ export const i18n: II18n = {
         "export": "내보내기",
         "fileTypeError": "지원하지않습니다.",
         "footnoteRef": "각주참조",
-        "format": "형식",
         "fullscreen": "전체화면",
         "generate": "생성",
         "headings": "제목크기",
@@ -173,7 +171,6 @@ export const i18n: II18n = {
         "export": "导出",
         "fileTypeError": "文件类型不允许上传",
         "footnoteRef": "脚注标识",
-        "format": "格式化",
         "fullscreen": "全屏切换",
         "generate": "生成中",
         "headings": "标题",

+ 3 - 3
src/ts/toolbar/EditMode.ts

@@ -46,7 +46,7 @@ export const setEditMode = (vditor: IVditor, type: string, event: Event | string
     disableToolbar(vditor.toolbar.elements, ["outdent", "indent"]);
 
     if (type === "ir") {
-        hideToolbar(vditor.toolbar.elements, ["format", "both"]);
+        hideToolbar(vditor.toolbar.elements, ["both"]);
         showToolbar(vditor.toolbar.elements, ["outdent", "indent", "outline", "insert-before", "insert-after"]);
         vditor.irUndo.resetIcon(vditor);
         vditor.sv.element.style.display = "none";
@@ -73,7 +73,7 @@ export const setEditMode = (vditor: IVditor, type: string, event: Event | string
             IRHighlightToolbar(vditor);
         }
     } else if (type === "wysiwyg") {
-        hideToolbar(vditor.toolbar.elements, ["format", "both"]);
+        hideToolbar(vditor.toolbar.elements, ["both"]);
         showToolbar(vditor.toolbar.elements, ["outdent", "indent", "outline", "insert-before", "insert-after"]);
         vditor.wysiwygUndo.resetIcon(vditor);
         vditor.sv.element.style.display = "none";
@@ -96,7 +96,7 @@ export const setEditMode = (vditor: IVditor, type: string, event: Event | string
         }
         vditor.wysiwyg.popover.style.display = "none";
     } else if (type === "sv") {
-        showToolbar(vditor.toolbar.elements, ["format", "both"]);
+        showToolbar(vditor.toolbar.elements, ["both"]);
         hideToolbar(vditor.toolbar.elements, ["outdent", "indent", "outline", "insert-before", "insert-after"]);
         vditor.undo.resetIcon(vditor);
         vditor.wysiwyg.element.parentElement.style.display = "none";

+ 0 - 16
src/ts/toolbar/Format.ts

@@ -1,16 +0,0 @@
-import {getMarkdown} from "../markdown/getMarkdown";
-import {formatRender} from "../sv/formatRender";
-import {getEventName} from "../util/compatibility";
-import {getSelectPosition} from "../util/selection";
-import {MenuItem} from "./MenuItem";
-
-export class Format extends MenuItem {
-    constructor(vditor: IVditor, menuItem: IMenuItem) {
-        super(vditor, menuItem);
-        this.element.children[0].addEventListener(getEventName(), (event) => {
-            event.preventDefault();
-            formatRender(vditor,  vditor.lute.FormatMd( getMarkdown(vditor)),
-                getSelectPosition(vditor.sv.element, getSelection().getRangeAt(0)));
-        });
-    }
-}

+ 1 - 1
src/ts/toolbar/Preview.ts

@@ -18,7 +18,7 @@ export class Preview extends MenuItem {
                 return;
             }
 
-            const toolbars = Constants.EDIT_TOOLBARS.concat(["both", "format", "edit-mode", "devtools"]);
+            const toolbars = Constants.EDIT_TOOLBARS.concat(["both", "edit-mode", "devtools"]);
             if (btnElement.classList.contains("vditor-menu--current")) {
                 btnElement.classList.remove("vditor-menu--current");
                 if (vditor.currentMode === "sv") {

+ 0 - 4
src/ts/toolbar/index.ts

@@ -10,7 +10,6 @@ import {Divider} from "./Divider";
 import {EditMode} from "./EditMode";
 import {Emoji} from "./Emoji";
 import {Export} from "./Export";
-import {Format} from "./Format";
 import {Fullscreen} from "./Fullscreen";
 import {Headings} from "./Headings";
 import {Help} from "./Help";
@@ -127,9 +126,6 @@ export class Toolbar {
             case "info":
                 menuItemObj = new Info(vditor, menuItem);
                 break;
-            case "format":
-                menuItemObj = new Format(vditor, menuItem);
-                break;
             case "edit-mode":
                 menuItemObj = new EditMode(vditor, menuItem);
                 break;

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

@@ -22,7 +22,6 @@ import linkSVG from "../../assets/icons/link.svg";
 import listSVG from "../../assets/icons/list.svg";
 import moreSVG from "../../assets/icons/more.svg";
 import orderedListVG from "../../assets/icons/ordered-list.svg";
-import formatSVG from "../../assets/icons/outdent.svg";
 import outdentSVG from "../../assets/icons/outdent.svg";
 import previewSVG from "../../assets/icons/preview.svg";
 import quoteSVG from "../../assets/icons/quote.svg";
@@ -142,7 +141,6 @@ export class Options {
                     "export",
                     "outline",
                     "preview",
-                    "format",
                     "devtools",
                     "info",
                     "help",
@@ -328,11 +326,6 @@ export class Options {
         icon: previewSVG,
         name: "preview",
         tipPosition: "nw",
-    }, {
-        hotkey: "⌘-⇧-F",
-        icon: formatSVG,
-        name: "format",
-        tipPosition: "nw",
     }, {
         icon: outlinerSVG,
         name: "outline",

Some files were not shown because too many files changed in this diff