diff --git a/packages/core/src/blocks/utils/listItemEnterHandler.ts b/packages/core/src/blocks/utils/listItemEnterHandler.ts index ceb383a611..edd470513f 100644 --- a/packages/core/src/blocks/utils/listItemEnterHandler.ts +++ b/packages/core/src/blocks/utils/listItemEnterHandler.ts @@ -34,7 +34,9 @@ export const handleEnter = ( } else if (blockContent.node.childCount > 0) { return editor.transact((tr) => { tr.deleteSelection(); - return splitBlockTr(tr, tr.selection.from, true); + const result = splitBlockTr(tr, tr.selection.from, true); + tr.scrollIntoView(); + return result; }); } diff --git a/packages/core/src/editor/BlockNoteEditor.ts b/packages/core/src/editor/BlockNoteEditor.ts index e4888f50f6..71c8e0b8f2 100644 --- a/packages/core/src/editor/BlockNoteEditor.ts +++ b/packages/core/src/editor/BlockNoteEditor.ts @@ -120,6 +120,20 @@ export interface BlockNoteEditorOptions< */ domAttributes?: Partial; + /** + * Additional ProseMirror editor props to pass to the underlying editor view. + * Use this to configure options such as `scrollMargin`, `scrollThreshold`, + * `handleDOMEvents`, and other + * [ProseMirror EditorProps](https://prosemirror.net/docs/ref/#view.EditorProps). + * + * Note: `attributes` (use {@link domAttributes} instead) and `transformPasted` + * are managed by BlockNote and cannot be overridden here. + */ + editorProps?: Omit< + NonNullable, + "attributes" | "transformPasted" + >; + /** * Options for configuring the drop cursor behavior when dragging and dropping blocks. * Allows customization of cursor appearance and drop position computation through hooks. @@ -520,6 +534,7 @@ export class BlockNoteEditor< extensions: tiptapExtensions, editorProps: { ...newOptions._tiptapOptions?.editorProps, + ...newOptions.editorProps, attributes: { // As of TipTap v2.5.0 the tabIndex is removed when the editor is not // editable, so you can't focus it. We want to revert this as we have diff --git a/packages/core/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts b/packages/core/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts index 44bda036bb..061d0dd88d 100644 --- a/packages/core/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +++ b/packages/core/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts @@ -922,6 +922,7 @@ export const KeyboardShortcutsExtension = Extension.create<{ selectionAtBlockStart, ), ) + .scrollIntoView() .run(); return true;