Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

Revert "Use in-app mobile editor navigation"

yoma5df276bd4cad
diff --git a/apps/web/src/components/EditorPane.tsx b/apps/web/src/components/EditorPane.tsx
index 9531a06d..a7090dd2 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 (
- <MobileNativeEditorPane
- {...props}
- onExitMobileNativeEdit={() => setMobileNativeEditMemoId(null)}
- />
+ <div className="flex h-full min-h-0 items-center justify-center bg-white text-sm font-medium text-slate-400">
+ 打开编辑器
+ </div>
);
}
@@ -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 3bbfab57..0db23ffa 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;
@@ -1255,6 +1263,9 @@ export const WorkspaceApp = ({
setSelectedMemoId(data.memo.id);
setActivePane("editor");
+ if (!isDesktopViewport()) {
+ openStandaloneMobileEditor(data.memo.id);
+ }
},
});
diff --git a/apps/web/src/mobile-edit.tsx b/apps/web/src/mobile-edit.tsx
index f945f9a1..6dc99bd1 100644
--- a/apps/web/src/mobile-edit.tsx
+++ b/apps/web/src/mobile-edit.tsx
@@ -333,7 +333,16 @@ const MobileTiptapEditorApp = () => {
}, [persistLocalDraft, saveNow, setSaveStateStable]);
const navigateBack = useCallback(() => {
- window.location.replace(returnTo);
+ const referrerUrl = document.referrer ? new URL(document.referrer) : null;
+ const canRestorePreviousPage = Boolean(referrerUrl && referrerUrl.origin === window.location.origin && window.history.length > 1);
+
+ if (!canRestorePreviousPage) {
+ window.location.replace(returnTo);
+ return;
+ }
+
+ const currentState = window.history.state as { edgeeverMobileEditorBackGuard?: boolean } | null;
+ window.history.go(currentState?.edgeeverMobileEditorBackGuard ? -2 : -1);
}, [returnTo]);
const leavePage = useCallback(async () => {