diff --git a/apps/mobile/app/hooks/use-app-events.tsx b/apps/mobile/app/hooks/use-app-events.tsx index 5e95c4a1e..bb38d651f 100644 --- a/apps/mobile/app/hooks/use-app-events.tsx +++ b/apps/mobile/app/hooks/use-app-events.tsx @@ -541,6 +541,8 @@ export const useAppEvents = () => { console.error(e); } } + //@ts-ignore + globalThis["IS_SHARE_EXTENSION"] = false; } else { SettingsService.appEnteredBackground(); const id = useTabStore.getState().getCurrentNoteId(); diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor-events.ts b/apps/mobile/app/screens/editor/tiptap/use-editor-events.ts index a90088a0e..416c65fec 100644 --- a/apps/mobile/app/screens/editor/tiptap/use-editor-events.ts +++ b/apps/mobile/app/screens/editor/tiptap/use-editor-events.ts @@ -549,7 +549,7 @@ export const useEditorEvents = ( const hash = (editorMessage.value as Attachment)?.hash; const attachment = await db.attachments?.attachment(hash); if (!attachment) return; - if (attachment.type.startsWith("image/")) { + if (attachment.mimeType.startsWith("image/")) { eSendEvent("ImagePreview", editorMessage.value); } else { eSendEvent("PDFPreview", attachment); @@ -585,7 +585,11 @@ export const useEditorEvents = ( ); eSendEvent(eEditorTabFocused, editorMessage.tabId); - if (!editorMessage.value && editorMessage.noteId) { + + if ( + (!editorMessage.value || editor.currentLoadingNoteId.current) && + editorMessage.noteId + ) { if (!useSettingStore.getState().isAppLoading) { const note = await db.notes.note(editorMessage.noteId); if (note) { diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor.ts b/apps/mobile/app/screens/editor/tiptap/use-editor.ts index fb081920e..2b76ba162 100644 --- a/apps/mobile/app/screens/editor/tiptap/use-editor.ts +++ b/apps/mobile/app/screens/editor/tiptap/use-editor.ts @@ -389,6 +389,7 @@ export const useEditor = ( blockIdRef.current = event.blockId; } state.current.currentlyEditing = true; + if ( !state.current.ready && (await isEditorLoaded( @@ -412,6 +413,13 @@ export const useEditor = ( if (!event.item) return; const item = event.item; + const currentTab = useTabStore + .getState() + .getTab(useTabStore.getState().currentTab); + if (currentTab?.previewTab && item.id !== currentTab.noteId) { + await commands.setLoading(true, useTabStore.getState().currentTab); + } + const noteIsLocked = (await db.vaults.itemExists(event.item as ItemReference)) && !(event.item as NoteWithContent).content; @@ -455,6 +463,7 @@ export const useEditor = ( // console.log("tab id did not match after focus in 1000ms"); // return; // } + currentLoadingNoteId.current = item.id; console.log("Waiting for tab to focus"); return; } @@ -775,6 +784,7 @@ export const useEditor = ( onContentChanged, editorId: editorId, overlay, - postMessage + postMessage, + currentLoadingNoteId }; }; diff --git a/packages/editor-mobile/src/components/editor.tsx b/packages/editor-mobile/src/components/editor.tsx index 005917c28..ce3ccd44e 100644 --- a/packages/editor-mobile/src/components/editor.tsx +++ b/packages/editor-mobile/src/components/editor.tsx @@ -181,7 +181,8 @@ const Tiptap = ({ const _editor = useTiptap(tiptapOptions, [tiptapOptions]); const update = useCallback(() => { - logger("info", "update content"); + logger("info", "LOADING NOTE..."); + _editor.commands.setTextSelection(0); setTick((tick) => tick + 1); setTimeout(() => { const noteState = tabRef.current.noteId @@ -208,7 +209,7 @@ const Tiptap = ({ ); setTimeout(() => { editorControllers[tabRef.current.id]?.setLoading(false); - }); + }, 300); }, []); const controller = useEditorController({ @@ -263,10 +264,10 @@ const Tiptap = ({ ) { editorControllers[tabRef.current.id]?.setLoading(true); } - post( EventTypes.tabFocused, - !!globalThis.editorControllers[tabRef.current.id]?.content.current, + !!globalThis.editorControllers[tabRef.current.id]?.content.current && + !editorControllers[tabRef.current.id]?.loading, tabRef.current.id, state.getCurrentNoteId() ); @@ -377,7 +378,7 @@ const Tiptap = ({ onScroll={controller.scroll} ref={containerRef} style={{ - overflowY: "scroll", + overflowY: controller.loading ? "hidden" : "scroll", height: "100%", display: "block", position: "relative" @@ -386,16 +387,21 @@ const Tiptap = ({ {settings.noHeader || tab.locked ? null : ( <> - - <StatusBar container={containerRef} /> + + {controller.loading ? null : ( + <> + <Title + titlePlaceholder={controller.titlePlaceholder} + readonly={settings.readonly} + controller={controllerRef} + title={controller.title} + fontFamily={settings.fontFamily} + dateFormat={settings.dateFormat} + timeFormat={settings.timeFormat} + /> + <StatusBar container={containerRef} /> + </> + )} </> )} @@ -585,6 +591,54 @@ const Tiptap = ({ </> ) : ( <> + <div + style={{ + height: 25, + width: "94%", + backgroundColor: colors.secondary.background, + borderRadius: 5, + marginTop: 10 + }} + /> + + <div + style={{ + flexDirection: "row", + display: "flex", + gap: 10 + }} + > + <div + style={{ + height: 12, + width: 40, + backgroundColor: colors.secondary.background, + borderRadius: 5, + marginTop: 10 + }} + /> + + <div + style={{ + height: 12, + width: 50, + backgroundColor: colors.secondary.background, + borderRadius: 5, + marginTop: 10 + }} + /> + + <div + style={{ + height: 12, + width: 100, + backgroundColor: colors.secondary.background, + borderRadius: 5, + marginTop: 10 + }} + /> + </div> + <div style={{ height: 16, diff --git a/packages/editor-mobile/src/hooks/useEditorController.ts b/packages/editor-mobile/src/hooks/useEditorController.ts index 6c8c909f3..800feded2 100644 --- a/packages/editor-mobile/src/hooks/useEditorController.ts +++ b/packages/editor-mobile/src/hooks/useEditorController.ts @@ -244,7 +244,7 @@ export function useEditorController({ } case "native:html": htmlContentRef.current = value; - logger("info", "loading html"); + logger("info", "LOADING NOTE HTML"); if (!editor) break; update(); countWords(0);