Skip to content

Commit f521e36

Browse files
authored
feat(core): add the ability to autofocus on the editor element (#2018)
1 parent eb3ee28 commit f521e36

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

packages/core/src/editor/BlockNoteEditor.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
createDocument,
44
EditorOptions,
55
Extension,
6+
FocusPosition,
67
getSchema,
78
InputRule,
89
isNodeSelection,
@@ -156,6 +157,13 @@ export type BlockNoteEditorOptions<
156157
*/
157158
animations?: boolean;
158159

160+
/**
161+
* Whether the editor should be focused automatically when it's created.
162+
*
163+
* @default false
164+
*/
165+
autofocus?: FocusPosition;
166+
159167
/**
160168
* When enabled, allows for collaboration between multiple users.
161169
* See [Real-time Collaboration](https://www.blocknotejs.org/docs/advanced/real-time-collaboration) for more info.
@@ -850,6 +858,7 @@ export class BlockNoteEditor<
850858
...blockNoteTipTapOptions,
851859
...newOptions._tiptapOptions,
852860
element: null,
861+
autofocus: newOptions.autofocus ?? false,
853862
extensions: tiptapExtensions,
854863
editorProps: {
855864
...newOptions._tiptapOptions?.editorProps,

0 commit comments

Comments
 (0)