From 8a54f4599cf561ea317fb6a1ebd81262f467c67f Mon Sep 17 00:00:00 2001 From: tianma-if Date: Sun, 26 Jul 2026 17:06:34 +0800 Subject: [PATCH] fix(web): expand editor content when outline is collapsed --- apps/web/src/components/EditorOutline.tsx | 7 ++++--- apps/web/src/components/EditorPane.tsx | 14 ++++++++++++-- apps/web/src/lib/workspace-ui.ts | 1 + package.json | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/apps/web/src/components/EditorOutline.tsx b/apps/web/src/components/EditorOutline.tsx index 06bdbdc9..a12a250e 100644 --- a/apps/web/src/components/EditorOutline.tsx +++ b/apps/web/src/components/EditorOutline.tsx @@ -14,6 +14,8 @@ type OutlineItem = { type EditorOutlineProps = { editor: Editor | null; scrollContainer: HTMLDivElement | null; + collapsed: boolean; + onCollapsedChange: (collapsed: boolean) => void; }; const stripLeadingEmoji = (str: string): string => { @@ -42,10 +44,9 @@ const getOutlineItems = (editor: Editor): OutlineItem[] => { return items; }; -export const EditorOutline = ({ editor, scrollContainer }: EditorOutlineProps) => { +export const EditorOutline = ({ editor, scrollContainer, collapsed, onCollapsedChange }: EditorOutlineProps) => { const { t } = useTranslation(); const [items, setItems] = useState([]); - const [collapsed, setCollapsed] = useState(false); const [activePos, setActivePos] = useState(null); const refresh = useCallback(() => { @@ -174,7 +175,7 @@ export const EditorOutline = ({ editor, scrollContainer }: EditorOutlineProps) = "group flex items-center text-left text-[11px] font-bold uppercase tracking-wider text-slate-400 transition-colors hover:text-slate-600", collapsed ? "h-7 w-7 justify-center rounded-md hover:bg-slate-100" : "gap-1.5" )} - onClick={() => setCollapsed((value) => !value)} + onClick={() => onCollapsedChange(!collapsed)} aria-expanded={!collapsed} aria-label={t(collapsed ? "editor.showOutline" : "editor.hideOutline")} title={t(collapsed ? "editor.showOutline" : "editor.hideOutline")} diff --git a/apps/web/src/components/EditorPane.tsx b/apps/web/src/components/EditorPane.tsx index 06df6b49..733403cf 100644 --- a/apps/web/src/components/EditorPane.tsx +++ b/apps/web/src/components/EditorPane.tsx @@ -67,6 +67,7 @@ import { RevisionHistoryDialog } from "./dialogs/RevisionHistoryDialog"; import { api } from "@/lib/api"; import { consumeStandaloneMobileEditorReturn, openStandaloneMobileEditor } from "@/lib/mobile-editor"; import { cn, formatDateTime, parseTagsText } from "@/lib/utils"; +import { EDITOR_CONTENT_MAX_WIDTH, EDITOR_CONTENT_MAX_WIDTH_COLLAPSED } from "@/lib/workspace-ui"; import { countMemoCharacters, docToMarkdown, @@ -1167,6 +1168,7 @@ const RichEditorPane = ({ const [isMarkdownMode, setIsMarkdownMode] = useState(false); const [mobileToolbarOpen, setMobileToolbarOpen] = useState(false); const [mobileImeDebugOpen, setMobileImeDebugOpen] = useState(false); + const [editorOutlineCollapsed, setEditorOutlineCollapsed] = useState(false); const [mobileImeDebugActiveElement, setMobileImeDebugActiveElement] = useState(getActiveElementLabel); const [mobileImeDebugEvents, setMobileImeDebugEvents] = useState([]); const [wechatCopyState, setWechatCopyState] = useState<"idle" | "copying" | "copied" | "error">("idle"); @@ -2981,8 +2983,11 @@ const RichEditorPane = ({ "min-w-0 flex-1 transition-[max-width] duration-200", desktopFocusMode ? "max-w-[960px]" - : "max-w-[var(--editor-content-max-width,880px)]" + : "max-w-none" )} + style={!desktopFocusMode ? { + maxWidth: editorOutlineCollapsed ? EDITOR_CONTENT_MAX_WIDTH_COLLAPSED : EDITOR_CONTENT_MAX_WIDTH, + } : undefined} > {useMobilePlainTextEditor ? ( <> @@ -3036,7 +3041,12 @@ const RichEditorPane = ({ )} {!isMobileViewport && !useMobilePlainTextEditor && !useMarkdownSourceEditor && ( - + )} diff --git a/apps/web/src/lib/workspace-ui.ts b/apps/web/src/lib/workspace-ui.ts index fcee0b85..57b393c4 100644 --- a/apps/web/src/lib/workspace-ui.ts +++ b/apps/web/src/lib/workspace-ui.ts @@ -7,3 +7,4 @@ export const WORKSPACE_PAGE_TITLE_CLASSNAME = "text-sm font-semibold leading-5 t */ export const EDITOR_OUTLINE_WIDTH = "300px"; export const EDITOR_CONTENT_MAX_WIDTH = "880px"; +export const EDITOR_CONTENT_MAX_WIDTH_COLLAPSED = "1200px"; diff --git a/package.json b/package.json index c9c3cbbb..a3116f73 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "edgeever", - "version": "1.6.10", + "version": "1.6.11", "private": true, "type": "module", "workspaces": [