diff --git a/packages/editor/src/type.ts b/packages/editor/src/type.ts index 5ce8589a..c63bfd40 100644 --- a/packages/editor/src/type.ts +++ b/packages/editor/src/type.ts @@ -681,11 +681,14 @@ export interface TreeNodeData { } export type AsyncBeforeHook, C extends Record any>> = { - [K in Value[number]]?: (...args: Parameters) => Promise>; + [K in Value[number]]?: (...args: Parameters) => Promise> | Parameters; }; export type AsyncAfterHook, C extends Record any>> = { - [K in Value[number]]?: (result: Awaited>, ...args: Parameters) => ReturnType; + [K in Value[number]]?: ( + result: Awaited>, + ...args: Parameters + ) => ReturnType | Awaited>; }; export type SyncBeforeHook, C extends Record any>> = { diff --git a/playground/src/pages/Editor.vue b/playground/src/pages/Editor.vue index 3e06bf62..f5420adc 100644 --- a/playground/src/pages/Editor.vue +++ b/playground/src/pages/Editor.vue @@ -227,7 +227,7 @@ asyncLoadJs(`${VITE_ENTRY_PATH}/ds-value/index.umd.cjs`).then(() => { save(); editorService.usePlugin({ - beforeDoAdd: async (config: MNode, parent: MContainer) => { + beforeDoAdd: (config: MNode, parent: MContainer) => { if (config.type === 'overlay') { config.style = { ...config.style,