Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: prevent scroll jump when toggling focus mode

Abdullah Atta3b363a1b20be
diff --git a/apps/web/src/components/editor/tiptap.tsx b/apps/web/src/components/editor/tiptap.tsx
index b504f506a..e58a74a31 100644
--- a/apps/web/src/components/editor/tiptap.tsx
+++ b/apps/web/src/components/editor/tiptap.tsx
@@ -410,7 +410,10 @@ function Portal(props: PropsWithChildren<{ containerId?: string }>) {
function toIEditor(editor: Editor): IEditor {
return {
- focus: () => editor.current?.commands.focus("start"),
+ focus: ({ position, scrollIntoView } = {}) =>
+ editor.current?.commands.focus(position, {
+ scrollIntoView
+ }),
undo: () => editor.current?.commands.undo(),
redo: () => editor.current?.commands.redo(),
getMediaHashes: () => {
diff --git a/apps/web/src/components/editor/types.ts b/apps/web/src/components/editor/types.ts
index f87c8f815..8821d80ea 100644
--- a/apps/web/src/components/editor/types.ts
+++ b/apps/web/src/components/editor/types.ts
@@ -27,7 +27,10 @@ export type NoteStatistics = {
};
export interface IEditor {
- focus: () => void;
+ focus: (options?: {
+ position?: "start" | "end";
+ scrollIntoView?: boolean;
+ }) => void;
undo: () => void;
redo: () => void;
getMediaHashes: () => string[];