Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/core/src/blocks/utils/listItemEnterHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ export const handleEnter = (
} else if (blockContent.node.childCount > 0) {
return editor.transact((tr) => {
tr.deleteSelection();
tr.scrollIntoView();
return splitBlockTr(tr, tr.selection.from, true);
});
});
}

return false;
Expand Down
15 changes: 15 additions & 0 deletions packages/core/src/editor/BlockNoteEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,20 @@ export interface BlockNoteEditorOptions<
*/
domAttributes?: Partial<BlockNoteDOMAttributes>;

/**
* 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<EditorOptions["editorProps"]>,
"attributes" | "transformPasted"
>;
Comment on lines +123 to +135
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that I want to expose this @Wqrld, can you explain what you would be using this for? If it is just for scrollMargin, I think we could set that default within BlockNote instead of having to expose this whole config on our API surface for it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is indeed just for scrollmargin and scrollthreshold. Any way that exposes those in some way or another works for me.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What values are you using for those? I don't think I would expose that low-level of a concept. I would just pick a value that makes sense for BlockNote already

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was playing around with 72 for scrollmargin and 0 for scrollThreshold. What feels right depends a bit on the font and editor size so i prefer to make it configurable (with good defaults)


/**
* Options for configuring the drop cursor behavior when dragging and dropping blocks.
* Allows customization of cursor appearance and drop position computation through hooks.
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,7 @@ export const KeyboardShortcutsExtension = Extension.create<{
selectionAtBlockStart,
),
)
.scrollIntoView()
.run();

return true;
Expand Down