Skip to content

How can I scroll the page to keep the input cursor in the middle of the screen? #2264

Discussion options

You must be logged in to vote

While the solution above works, it makes the editor jump on initialization (at least with collaborative editing on) because of updates to the editor state.

Using the scrollThreshold and scrollMargin editorProps is the native Prosemirror way.

  const editor = useEditor(
    {
      extensions: [YOUR_TIPTAP_EXTENSIONS],
      editorProps: {
        scrollThreshold: 80,
        scrollMargin: 80,
      },
    },
  );

You can adjust the numbers as you please.

Refs:
https://prosemirror.net/docs/ref/#view.EditorProps.scrollThreshold
https://prosemirror.net/docs/ref/#view.EditorProps.scrollMargin
https://discuss.prosemirror.net/t/how-to-keep-the-caret-at-a-distance-from-the-bottom-of-the-window/3…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by nperez0111
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants