mirror of
https://github.com/priyanshujain/margin.git
synced 2026-10-02 19:17:03 +00:00
feat(editor): keep the caret clear of the floating toolbar
This commit is contained in:
1 parent
abcd133b19
commit
742e42d65b
1 file changed
+7
-1
@@ -21,6 +21,8 @@ interface Cached {
|
|||||||
scroll: number;
|
scroll: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SCROLL_KEEPOUT = { top: 32, right: 0, bottom: 96, left: 0 };
|
||||||
|
|
||||||
function buildState(editor: TiptapEditor, content: JSONContent, onError: (error: Error) => void): EditorState {
|
function buildState(editor: TiptapEditor, content: JSONContent, onError: (error: Error) => void): EditorState {
|
||||||
const base = editor.view.state;
|
const base = editor.view.state;
|
||||||
try {
|
try {
|
||||||
@@ -49,7 +51,11 @@ export function Editor({ bookId, chapterId, content, onChange, onReady, onConten
|
|||||||
content,
|
content,
|
||||||
immediatelyRender: false,
|
immediatelyRender: false,
|
||||||
enableContentCheck: true,
|
enableContentCheck: true,
|
||||||
editorProps: { attributes: { class: "prose" } },
|
editorProps: {
|
||||||
|
attributes: { class: "prose" },
|
||||||
|
scrollThreshold: SCROLL_KEEPOUT,
|
||||||
|
scrollMargin: SCROLL_KEEPOUT,
|
||||||
|
},
|
||||||
onContentError: ({ error }) => onContentErrorRef.current(error),
|
onContentError: ({ error }) => onContentErrorRef.current(error),
|
||||||
onUpdate: ({ editor }) => onChangeRef.current(editor.getJSON()),
|
onUpdate: ({ editor }) => onChangeRef.current(editor.getJSON()),
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user