Skip to content

Commit 3ac4922

Browse files
Add public command to close the AI toolbar (#2380)
1 parent ce119b2 commit 3ac4922

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
### `@liveblocks/tiptap`
44

5-
- Fix `FloatingToolbar` focus behavior in Safari.
5+
- Add `closeAi` Tiptap command to manually close the AI toolbar.
66
- Fix `AiToolbar` focus behavior in Safari.
7+
- Fix `FloatingToolbar` focus behavior in Safari.
78

89
### `@liveblocks/lexical`
910

packages/liveblocks-react-tiptap/src/ai/AiExtension.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ export const AiExtension = Extension.create<
169169
return true;
170170
},
171171

172+
closeAi: () => () => {
173+
(this.editor.commands as unknown as AiCommands).$closeAiToolbar();
174+
175+
return true;
176+
},
177+
172178
$acceptAiToolbarResponse:
173179
() =>
174180
({ tr, view }: CommandProps) => {

packages/liveblocks-react-tiptap/src/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,16 @@ export type CommentsCommands<ReturnType = boolean> = {
265265
};
266266

267267
export type AiCommands<ReturnType = boolean> = {
268+
/**
269+
* Open the AI toolbar, with an optional prompt.
270+
*/
268271
askAi: (prompt?: string) => ReturnType;
269272

273+
/**
274+
* Close the AI toolbar.
275+
*/
276+
closeAi: () => ReturnType;
277+
270278
// Transitions (see AiToolbarState)
271279

272280
/**

0 commit comments

Comments
 (0)