Skip to content

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

feat(demo): default editor outline to expanded in demo mode

tianma-if94c3dab56dc2
diff --git a/apps/web/src/components/EditorPane.tsx b/apps/web/src/components/EditorPane.tsx
index d2737498..2c49e7c7 100644
--- a/apps/web/src/components/EditorPane.tsx
+++ b/apps/web/src/components/EditorPane.tsx
@@ -331,6 +331,7 @@ type EditorPaneProps = {
pluginHost: EdgeEverPluginHost;
pluginNavigationRequest?: { id: number; noteId: string; search: string } | null;
onOpenExecutionCenter: () => void;
+ demoMode?: boolean;
};
type RichEditorPaneProps = EditorPaneProps & {
@@ -408,6 +409,7 @@ const RichEditorPane = ({
pluginHost,
pluginNavigationRequest,
onOpenExecutionCenter,
+ demoMode = false,
onRequestMobileNativeEdit,
}: RichEditorPaneProps) => {
const { t, i18n } = useTranslation();
@@ -487,7 +489,9 @@ const RichEditorPane = ({
const [desktopReadingProtection, setDesktopReadingProtection] = useState(readDesktopReadingProtectionPreference);
const [mobilePlainText, setMobilePlainText] = useState("");
const [mobileToolbarOpen, setMobileToolbarOpen] = useState(false);
- const [editorOutlineCollapsed, setEditorOutlineCollapsed] = useState(readEditorOutlineCollapsedPreference);
+ const [editorOutlineCollapsed, setEditorOutlineCollapsed] = useState(() =>
+ readEditorOutlineCollapsedPreference({ defaultCollapsed: !demoMode })
+ );
const [phonePreviewOpen, setPhonePreviewOpen] = useState(readEditorPhonePreviewPreference);
const [memoIdCopyNotice, setMemoIdCopyNotice] = useState<{ status: "copied" | "error"; id: string } | null>(null);
const handledSaveAndSyncTokenRef = useRef(saveAndSyncToken);
diff --git a/apps/web/src/components/WorkspaceApp.tsx b/apps/web/src/components/WorkspaceApp.tsx
index 370501aa..3315d292 100644
--- a/apps/web/src/components/WorkspaceApp.tsx
+++ b/apps/web/src/components/WorkspaceApp.tsx
@@ -66,6 +66,7 @@ import {
MIN_MEMO_LIST_WIDTH_PX,
MAX_MEMO_LIST_WIDTH_PX,
DEFAULT_MEMO_LIST_WIDTH_PX,
+ EDITOR_OUTLINE_COLLAPSED_STORAGE_KEY,
isTextEntryTarget,
getSearchShortcutScope,
getShortcutActionForEvent,
@@ -474,6 +475,11 @@ export const WorkspaceApp = ({
return { previousSelectedMemoId };
},
onSuccess: async () => {
+ try {
+ window.localStorage.removeItem(EDITOR_OUTLINE_COLLAPSED_STORAGE_KEY);
+ } catch {
+ // Local storage can be unavailable in private or restricted browser contexts.
+ }
setDemoResetConfirmationOpen(false);
queryClient.removeQueries({ queryKey: ["memo"] });
await Promise.all([
@@ -3555,6 +3561,7 @@ export const WorkspaceApp = ({
/>
) : (
<EditorPane
+ demoMode={demoMode}
onOpenExecutionCenter={handleOpenExecutionCenter}
memo={selectedMemo}
repository={repository}
diff --git a/apps/web/src/components/editor/editor-pane-helpers.test.mjs b/apps/web/src/components/editor/editor-pane-helpers.test.mjs
index 784e84e8..36f707b2 100644
--- a/apps/web/src/components/editor/editor-pane-helpers.test.mjs
+++ b/apps/web/src/components/editor/editor-pane-helpers.test.mjs
@@ -88,3 +88,15 @@ describe("block handle drop wiring", () => {
expect(source).toContain("isInternalNodeDrag: Boolean(view.dragging)");
});
});
+
+describe("editor outline demo preference wiring", () => {
+ test("defaults outline to expanded in demo mode when unset and resets on demo restore", () => {
+ const editorSource = readFileSync(new URL("../EditorPane.tsx", import.meta.url), "utf8");
+ const workspaceSource = readFileSync(new URL("../WorkspaceApp.tsx", import.meta.url), "utf8");
+
+ expect(editorSource).toContain("readEditorOutlineCollapsedPreference({ defaultCollapsed: !demoMode })");
+ expect(workspaceSource).toContain("demoMode={demoMode}");
+ expect(workspaceSource).toContain("window.localStorage.removeItem(EDITOR_OUTLINE_COLLAPSED_STORAGE_KEY)");
+ });
+});
+
diff --git a/apps/web/src/lib/app-helpers.test.mjs b/apps/web/src/lib/app-helpers.test.mjs
index d3d4dde8..5f6345ba 100644
--- a/apps/web/src/lib/app-helpers.test.mjs
+++ b/apps/web/src/lib/app-helpers.test.mjs
@@ -263,12 +263,16 @@ describe("editor outline preference", () => {
test("defaults to collapsed and only expands for an explicit false value", () => {
const values = installLocalStorage();
expect(readEditorOutlineCollapsedPreference()).toBe(true);
+ expect(readEditorOutlineCollapsedPreference({ defaultCollapsed: false })).toBe(false);
+ expect(readEditorOutlineCollapsedPreference({ defaultCollapsed: true })).toBe(true);
values.set(EDITOR_OUTLINE_COLLAPSED_STORAGE_KEY, "true");
expect(readEditorOutlineCollapsedPreference()).toBe(true);
+ expect(readEditorOutlineCollapsedPreference({ defaultCollapsed: false })).toBe(true);
values.set(EDITOR_OUTLINE_COLLAPSED_STORAGE_KEY, "false");
expect(readEditorOutlineCollapsedPreference()).toBe(false);
+ expect(readEditorOutlineCollapsedPreference({ defaultCollapsed: true })).toBe(false);
});
test("persists collapsed and expanded states", () => {
diff --git a/apps/web/src/lib/app-helpers.ts b/apps/web/src/lib/app-helpers.ts
index 973503f9..5bfeb034 100644
--- a/apps/web/src/lib/app-helpers.ts
+++ b/apps/web/src/lib/app-helpers.ts
@@ -383,11 +383,14 @@ export const writeDesktopReadingProtectionPreference = (enabled: boolean) => {
}
};
-export const readEditorOutlineCollapsedPreference = () => {
+export const readEditorOutlineCollapsedPreference = (options?: { defaultCollapsed?: boolean }) => {
try {
- return window.localStorage.getItem(EDITOR_OUTLINE_COLLAPSED_STORAGE_KEY) !== "false";
+ const value = window.localStorage.getItem(EDITOR_OUTLINE_COLLAPSED_STORAGE_KEY);
+ if (value === "false") return false;
+ if (value === "true") return true;
+ return options?.defaultCollapsed ?? true;
} catch {
- return true;
+ return options?.defaultCollapsed ?? true;
}
};