Skip to content

Commit

Permalink
hook 兼容非 Promise 返回值 (#378)
Browse files Browse the repository at this point in the history
  • Loading branch information
ylx252 authored May 10, 2024
1 parent 0fe8ce8 commit 8717a66
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/core/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ class Editor extends EventEmitter {
if (hook) {
this.hooksEntity[hookName].tapPromise(plugin.pluginName + hookName, function () {
// eslint-disable-next-line prefer-rest-params
return hook.apply(plugin, [...arguments]);
const result = hook.apply(plugin, [...arguments]);
// hook 兼容非 Promise 返回值
return result instanceof Promise ? result : Promise.resolve(result);
});
}
});
Expand Down

0 comments on commit 8717a66

Please sign in to comment.