Van 6 år sedan
förälder
incheckning
2575f2f256
3 ändrade filer med 12 tillägg och 3 borttagningar
  1. 4 1
      CHANGELOG.md
  2. 3 1
      src/ts/types/index.d.ts
  3. 5 1
      src/ts/upload/index.ts

+ 4 - 1
CHANGELOG.md

@@ -2,6 +2,9 @@
 
 ### 升级
 
+* v1.8
+  * getHTML 方法移除参数
+  * md2html 仅保留第一个参数
 * v1.7
   * `option.preivew.show?: boolean` => `option.preivew.mode?: string`
   * 移除 option.editorName
@@ -9,13 +12,13 @@
 ### TODO
 
 * [121](https://github.com/b3log/vditor/issues/121) 所见即所得 `feature`
-* [119](https://github.com/b3log/vditor/issues/119) file upload 
 
 ### v1.8.0 / 2019-09-03
 
 * [123](https://github.com/b3log/vditor/issues/123) 添加 format 功能 `feature`
 * [122](https://github.com/b3log/vditor/issues/122) 添加 emojiRender 和 highlightRender 接口 `feature`
 * [120](https://github.com/b3log/vditor/issues/120) markdown-it 切换为 lute `enhancement`
+* [119](https://github.com/b3log/vditor/issues/119) 提供服务端返回数据格式化接口 `feature`
 * [117](https://github.com/b3log/vditor/issues/117) 支持站点、视频、音频解析 `feature`
 * [112](https://github.com/b3log/vditor/issues/112) :xxx: 需根据对应的 emoji 渲染为 emoji,而非 :xxx: `feature`
 

+ 3 - 1
src/ts/types/index.d.ts

@@ -70,6 +70,8 @@ interface IUpload {
     validate?(files: File[]): string | boolean;
 
     handler?(files: File[]): string | null;
+
+    format?(files: FileList | DataTransferItemList | File[], responseText: string): string
 }
 
 interface IMenuItem {
@@ -265,7 +267,7 @@ declare class IVditorConstructor {
 
     public html2md(value: string): string;
 
-    public getHTML(enableHighlight?: boolean): string;
+    public getHTML(): string;
 
     public tip(text: string, time?: number): void;
 

+ 5 - 1
src/ts/upload/index.ts

@@ -179,7 +179,11 @@ const uploadFiles = (vditor: IVditor, files: FileList | DataTransferItemList | F
                 if (vditor.options.upload.success) {
                     vditor.options.upload.success(vditor.editor.element, xhr.responseText);
                 } else {
-                    genUploadedLabel(vditor.editor.element, xhr.responseText, vditor);
+                    let responseText =  xhr.responseText
+                    if (vditor.options.upload.format) {
+                        responseText = vditor.options.upload.format(files, xhr.responseText)
+                    }
+                    genUploadedLabel(vditor.editor.element, responseText, vditor);
                 }
             } else {
                 if (vditor.options.upload.error) {