@blocknote/react
Version:
A "Notion-style" block-based extensible text editor built on top of Prosemirror and Tiptap.
20 lines (18 loc) • 510 B
text/typescript
import {
BlockNoteEditor,
BlockSchema,
InlineContentSchema,
StyleSchema,
} from "@blocknote/core";
import { useEditorState } from "./useEditorState.js";
export function useSelectedBlocks<
BSchema extends BlockSchema,
ISchema extends InlineContentSchema,
SSchema extends StyleSchema,
>(editor?: BlockNoteEditor<BSchema, ISchema, SSchema>) {
return useEditorState({
editor,
selector: ({ editor }) =>
editor.getSelection()?.blocks || [editor.getTextCursorPosition().block],
});
}