Browse Source

:sparkles: add method

Liyuan Li 5 years ago
parent
commit
1664e1e41d
3 changed files with 6 additions and 1 deletions
  1. 1 0
      CHANGELOG.md
  2. 5 0
      src/index.ts
  3. 0 1
      src/ts/upload/setHeaders.ts

+ 1 - 0
CHANGELOG.md

@@ -102,6 +102,7 @@
   * md2html 改为异步
   * 添加 `options.preview.markdown.codeBlockPreview`
   * 为 `options.toolbar` 添加 `className`
+  * 添加 getCurrentMode 方法
 
 ### v2.3.0 / 2020-03-12
 

+ 5 - 0
src/index.ts

@@ -141,6 +141,11 @@ class Vditor extends VditorMethod {
         return getMarkdown(this.vditor);
     }
 
+    /** 获取编辑器当前编辑模式 */
+    public getCurrentMode() {
+        return this.vditor.currentMode;
+    }
+
     /** 聚焦到编辑器 */
     public focus() {
         if (this.vditor.currentMode === "sv") {

+ 0 - 1
src/ts/upload/setHeaders.ts

@@ -3,6 +3,5 @@ export const setHeaders = (vditor: IVditor, xhr: XMLHttpRequest) => {
         Object.keys(vditor.options.upload.headers).forEach((key) => {
             xhr.setRequestHeader(key, vditor.options.upload.headers[key]);
         });
-        xhr.setRequestHeader("X-Mode", vditor.currentMode);
     }
 };