Skip to content

Commit

Permalink
refactor(editor): update FacetType action to return a Promise and adj…
Browse files Browse the repository at this point in the history
…ust menu-bubble.tsx to await action

Update the FacetType action to be a function returning a Promise, to better handle asynchronous actions. Correspondingly, modify menu-bubble.tsx to await the action's completion before focusing the editor view.
  • Loading branch information
phodal committed Nov 1, 2024
1 parent 45172d9 commit 0fb3909
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions web/core/lib/editor/defs/custom-action.type.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Editor } from '@tiptap/core';

export enum FacetType {
TOOLBAR_MENU = 0,
BUBBLE_MENU = 1,
Expand Down Expand Up @@ -161,7 +163,7 @@ export interface PromptAction {
/**
* The icon of the prompt, will be displayed in the menu
*/
icon?: any;
icon?: never;
/**
* The description of the prompt, will be displayed in the menu
*/
Expand All @@ -177,6 +179,6 @@ export interface PromptAction {
/**
* Menu Action
*/
action?: (context: any) => void;
action?: (editor: Editor) => Promise<void>;
}

3 changes: 2 additions & 1 deletion web/core/lib/editor/menu/menu-bubble.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ export const MenuBubble = ({ editor, customActions } : {
editor.commands?.setAdvice(newComment.id);
editor.commands?.setAdviceCommand(newComment);
} else {
menu.action?.(editor);
await menu.action?.(editor);
setLoading(false);
}

editor.view?.focus();
Expand Down

0 comments on commit 0fb3909

Please sign in to comment.