Skip to content

Commit e3a0c27

Browse files
committed
Changed file panel extension state from object with block ID string to just block ID string
1 parent 3e894b4 commit e3a0c27

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
lines changed

packages/core/src/extensions/FilePanel/FilePanel.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@ import {
44
} from "../../editor/BlockNoteExtension.js";
55

66
export const FilePanelExtension = createExtension(({ editor }) => {
7-
const store = createStore({
8-
blockId: undefined as string | undefined,
9-
});
7+
const store = createStore<string | undefined>(undefined);
108

119
function closeMenu() {
12-
store.setState({
13-
blockId: undefined,
14-
});
10+
store.setState(undefined);
1511
}
1612

1713
return {
@@ -39,9 +35,7 @@ export const FilePanelExtension = createExtension(({ editor }) => {
3935
},
4036
closeMenu,
4137
showMenu(blockId: string) {
42-
store.setState({
43-
blockId,
44-
});
38+
store.setState(blockId);
4539
},
4640
} as const;
4741
});

packages/core/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,8 @@ export const KeyboardShortcutsExtension = Extension.create<{
493493
this.options.tabBehavior !== "prefer-indent" &&
494494
(this.options.editor.getExtension(FormattingToolbarExtension)?.store
495495
.state ||
496-
this.options.editor.getExtension(FilePanelExtension)?.store.state
497-
.blockId)
496+
this.options.editor.getExtension(FilePanelExtension)?.store
497+
.state !== undefined)
498498
// TODO need to check if the link toolbar is open or another alternative entirely
499499
) {
500500
// don't handle tabs if a toolbar is shown, so we can tab into / out of it
@@ -507,8 +507,8 @@ export const KeyboardShortcutsExtension = Extension.create<{
507507
this.options.tabBehavior !== "prefer-indent" &&
508508
(this.options.editor.getExtension(FormattingToolbarExtension)?.store
509509
.state ||
510-
this.options.editor.getExtension(FilePanelExtension)?.store.state
511-
.blockId)
510+
this.options.editor.getExtension(FilePanelExtension)?.store
511+
.state !== undefined)
512512
// TODO need to check if the link toolbar is open or another alternative entirely
513513
// other menu types?
514514
) {

packages/react/src/components/FilePanel/FilePanelController.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ export const FilePanelController = (props: {
1616
const editor = useBlockNoteEditor<any, any, any>();
1717

1818
const filePanel = useExtension(FilePanelExtension);
19-
const blockId = useExtensionState(FilePanelExtension, {
20-
selector: (state) => state.blockId,
21-
});
19+
const blockId = useExtensionState(FilePanelExtension);
2220

2321
const floatingUIOptions = useMemo<FloatingUIOptions>(
2422
() => ({

0 commit comments

Comments
 (0)