Skip to content

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

mobile: fix jump to block

Ammar Ahmedb849861146a0
diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor.ts b/apps/mobile/app/screens/editor/tiptap/use-editor.ts
index e18954e8c..fb081920e 100644
--- a/apps/mobile/app/screens/editor/tiptap/use-editor.ts
+++ b/apps/mobile/app/screens/editor/tiptap/use-editor.ts
@@ -385,7 +385,9 @@ export const useEditor = (
tabId?: number;
blockId?: string;
}) => {
- blockIdRef.current = event.blockId;
+ if (event.blockId) {
+ blockIdRef.current = event.blockId;
+ }
state.current.currentlyEditing = true;
if (
!state.current.ready &&
@@ -424,6 +426,13 @@ export const useEditor = (
locked: noteIsLocked
});
useTabStore.getState().focusTab(tabId);
+ setTimeout(() => {
+ if (blockIdRef.current) {
+ console.log("scrolling to block", blockIdRef.current);
+ commands.scrollIntoViewById(blockIdRef.current);
+ blockIdRef.current = undefined;
+ }
+ }, 150);
}
console.log("Note already loaded, focusing the tab");
} else {
@@ -497,8 +506,11 @@ export const useEditor = (
10000
);
+ console.log("blockId", blockIdRef.current);
+
setTimeout(() => {
if (blockIdRef.current) {
+ console.log("scrolling to block", blockIdRef.current);
commands.scrollIntoViewById(blockIdRef.current);
blockIdRef.current = undefined;
}