diff --git a/apps/web/public/mobile-edit.html b/apps/web/public/mobile-edit.html new file mode 100644 index 00000000..bd51d562 --- /dev/null +++ b/apps/web/public/mobile-edit.html @@ -0,0 +1,391 @@ + + + + + + 编辑笔记 - EdgeEver + + + +
+ +
+ 加载中 + +
+
+ +
+
+ +
+ +
+ +
+ + + + diff --git a/apps/web/src/components/EditorPane.tsx b/apps/web/src/components/EditorPane.tsx index 9531a06d..85a64884 100644 --- a/apps/web/src/components/EditorPane.tsx +++ b/apps/web/src/components/EditorPane.tsx @@ -467,6 +467,14 @@ 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, @@ -945,6 +953,12 @@ export const EditorPane = (props: EditorPaneProps) => { (mobileDefaultEditRequested || mobileNativeEditMemoId === props.memo.id) ); + useEffect(() => { + if (isMobileViewport && mobileDefaultEditRequested && props.memo?.id) { + openStandaloneMobileEditor(props.memo.id); + } + }, [isMobileViewport, mobileDefaultEditRequested, props.memo?.id]); + useEffect(() => { const mediaQuery = window.matchMedia(MOBILE_EDITOR_QUERY); const updateMobileViewport = () => setIsMobileViewport(mediaQuery.matches); @@ -961,10 +975,9 @@ export const EditorPane = (props: EditorPaneProps) => { if (mobileNativeEditingActive) { return ( - setMobileNativeEditMemoId(null)} - /> +
+ 打开编辑器 +
); } @@ -975,6 +988,7 @@ export const EditorPane = (props: EditorPaneProps) => { onRequestMobileNativeEdit={() => { if (props.memo?.id && !readOnly) { setMobileNativeEditMemoId(props.memo.id); + openStandaloneMobileEditor(props.memo.id); } }} /> diff --git a/apps/web/src/components/WorkspaceApp.tsx b/apps/web/src/components/WorkspaceApp.tsx index 42f429e1..4558d56a 100644 --- a/apps/web/src/components/WorkspaceApp.tsx +++ b/apps/web/src/components/WorkspaceApp.tsx @@ -79,6 +79,14 @@ 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; @@ -1168,6 +1176,10 @@ export const WorkspaceApp = ({ setCreatedMemoEditId(data.memo.id); setSelectedMemoId(data.memo.id); setActivePane("editor"); + + if (!isDesktopViewport()) { + openStandaloneMobileEditor(data.memo.id); + } }, });