Ver Fonte

feat: hint支持异步 (#1097)

myml há 4 anos atrás
pai
commit
cd76666db8
2 ficheiros alterados com 3 adições e 3 exclusões
  1. 2 2
      src/ts/hint/index.ts
  2. 1 1
      types/index.d.ts

+ 2 - 2
src/ts/hint/index.ts

@@ -59,8 +59,8 @@ export class Hint {
                 vditor.options.hint.extend.forEach((item) => {
                 vditor.options.hint.extend.forEach((item) => {
                     if (item.key === this.splitChar) {
                     if (item.key === this.splitChar) {
                         clearTimeout(this.timeId);
                         clearTimeout(this.timeId);
-                        this.timeId = window.setTimeout(() => {
-                            this.genHTML(item.hint(key), key, vditor);
+                        this.timeId = window.setTimeout(async () => {
+                            this.genHTML(await item.hint(key), key, vditor);
                         }, vditor.options.hint.delay);
                         }, vditor.options.hint.delay);
                     }
                     }
                 });
                 });

+ 1 - 1
types/index.d.ts

@@ -537,7 +537,7 @@ interface IHintData {
 interface IHintExtend {
 interface IHintExtend {
     key: string;
     key: string;
 
 
-    hint?(value: string): IHintData[];
+    hint?(value: string): IHintData[] | Promise<IHintData[]>;
 }
 }
 
 
 /** @link https://ld246.com/article/1549638745630#options-hint */
 /** @link https://ld246.com/article/1549638745630#options-hint */