From 742e42d65b43331cd6864e39d22c50931318d114 Mon Sep 17 00:00:00 2001 From: PJ Date: Mon, 10 Aug 2026 18:36:18 +0530 Subject: [PATCH] feat(editor): keep the caret clear of the floating toolbar --- src/editor/Editor.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/editor/Editor.tsx b/src/editor/Editor.tsx index 006017f..6ab7b94 100644 --- a/src/editor/Editor.tsx +++ b/src/editor/Editor.tsx @@ -21,6 +21,8 @@ interface Cached { scroll: number; } +const SCROLL_KEEPOUT = { top: 32, right: 0, bottom: 96, left: 0 }; + function buildState(editor: TiptapEditor, content: JSONContent, onError: (error: Error) => void): EditorState { const base = editor.view.state; try { @@ -49,7 +51,11 @@ export function Editor({ bookId, chapterId, content, onChange, onReady, onConten content, immediatelyRender: false, enableContentCheck: true, - editorProps: { attributes: { class: "prose" } }, + editorProps: { + attributes: { class: "prose" }, + scrollThreshold: SCROLL_KEEPOUT, + scrollMargin: SCROLL_KEEPOUT, + }, onContentError: ({ error }) => onContentErrorRef.current(error), onUpdate: ({ editor }) => onChangeRef.current(editor.getJSON()), });