From 158ef57f8e68b3b31b0ee67daff5a517f2fddc74 Mon Sep 17 00:00:00 2001 From: yoma Date: Wed, 8 Jul 2026 02:19:14 +0800 Subject: [PATCH] Extract mobile editor navigation helper --- apps/web/src/components/EditorPane.tsx | 9 +-------- apps/web/src/components/WorkspaceApp.tsx | 9 +-------- apps/web/src/lib/mobile-editor.ts | 7 +++++++ 3 files changed, 9 insertions(+), 16 deletions(-) create mode 100644 apps/web/src/lib/mobile-editor.ts diff --git a/apps/web/src/components/EditorPane.tsx b/apps/web/src/components/EditorPane.tsx index a7090dd2..06857095 100644 --- a/apps/web/src/components/EditorPane.tsx +++ b/apps/web/src/components/EditorPane.tsx @@ -50,6 +50,7 @@ import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from "@ import { EditorToolbar } from "./EditorToolbar"; import { RevisionHistoryDialog } from "./dialogs/RevisionHistoryDialog"; import { api } from "@/lib/api"; +import { openStandaloneMobileEditor } from "@/lib/mobile-editor"; import { cn, formatDateTime, parseTagsText } from "@/lib/utils"; import { docToMarkdown, markdownToDoc, type Notebook, type MemoDetail, type TiptapDoc } from "@edgeever/shared"; import { compressImageForUpload } from "@/lib/image-compression"; @@ -467,14 +468,6 @@ type RichEditorPaneProps = EditorPaneProps & { onRequestMobileNativeEdit?: () => void; }; -const openStandaloneMobileEditor = (memoId: string) => { - const params = new URLSearchParams({ - memoId, - returnTo: "/", - }); - window.location.href = `/mobile-edit.html#${params.toString()}`; -}; - const MobileNativeEditorPane = ({ memo, notebooks, diff --git a/apps/web/src/components/WorkspaceApp.tsx b/apps/web/src/components/WorkspaceApp.tsx index b241162f..28b3bc8b 100644 --- a/apps/web/src/components/WorkspaceApp.tsx +++ b/apps/web/src/components/WorkspaceApp.tsx @@ -27,6 +27,7 @@ import { import { MemoListPane, MemoSelectionActionBar } from "./MemoListPane"; import { AppConfirmDialog, MemoDeleteConfirmDialog, NotebookNameDialog } from "./dialogs/ConfirmDialogs"; import { api } from "@/lib/api"; +import { openStandaloneMobileEditor } from "@/lib/mobile-editor"; import { cn } from "@/lib/utils"; import { createExcerpt, docToText, type Notebook, type AuthUser, type MemoSummary, type MemoDetail } from "@edgeever/shared"; import type { @@ -79,14 +80,6 @@ const isStandaloneApp = () => window.matchMedia("(display-mode: fullscreen)").matches || Boolean((navigator as Navigator & { standalone?: boolean }).standalone); -const openStandaloneMobileEditor = (memoId: string) => { - const params = new URLSearchParams({ - memoId, - returnTo: "/", - }); - window.location.href = `/mobile-edit.html#${params.toString()}`; -}; - const getVerticalScrollContainer = (target: EventTarget | null) => { let element = target instanceof HTMLElement ? target : null; diff --git a/apps/web/src/lib/mobile-editor.ts b/apps/web/src/lib/mobile-editor.ts new file mode 100644 index 00000000..37ff08e2 --- /dev/null +++ b/apps/web/src/lib/mobile-editor.ts @@ -0,0 +1,7 @@ +export const openStandaloneMobileEditor = (memoId: string) => { + const params = new URLSearchParams({ + memoId, + returnTo: "/", + }); + window.location.href = `/mobile-edit.html#${params.toString()}`; +};