Skip to content

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

feat(web): redesign editor outline style and fix navigation scrolling v1.6.4

tianma-ifdc1798b829b1
diff --git a/apps/web/src/components/EditorOutline.tsx b/apps/web/src/components/EditorOutline.tsx
index 8f772a37..264b686b 100644
--- a/apps/web/src/components/EditorOutline.tsx
+++ b/apps/web/src/components/EditorOutline.tsx
@@ -1,8 +1,9 @@
import { useCallback, useEffect, useState } from "react";
import type { Editor } from "@tiptap/react";
-import { ChevronDown, ListTree } from "lucide-react";
+import { ChevronDown } from "lucide-react";
import { useTranslation } from "react-i18next";
import { cn } from "@/lib/utils";
+import { EDITOR_OUTLINE_WIDTH } from "@/lib/workspace-ui";
type OutlineItem = {
level: number;
@@ -15,6 +16,11 @@ type EditorOutlineProps = {
scrollContainer: HTMLDivElement | null;
};
+const stripLeadingEmoji = (str: string): string => {
+ const leadingEmojiRegex = /^(?:(?:[\u0030-\u0039#*]\uFE0F?\u20E3|\p{Extended_Pictographic}|[\u2460-\u24FF\u2600-\u27BF\u2B00-\u2BFF])[\uFE00-\uFE0F\u200D]*\s*)+/u;
+ return str.replace(leadingEmojiRegex, "").trim() || str;
+};
+
const getOutlineItems = (editor: Editor): OutlineItem[] => {
const items: OutlineItem[] = [];
@@ -114,7 +120,35 @@ export const EditorOutline = ({ editor, scrollContainer }: EditorOutlineProps) =
return;
}
- editor.chain().focus().setTextSelection(item.pos + 1).scrollIntoView().run();
+ let domElement: HTMLElement | null = null;
+ const domNode = editor.view.nodeDOM(item.pos);
+ if (domNode instanceof HTMLElement) {
+ domElement = domNode;
+ } else {
+ try {
+ const domAtPos = editor.view.domAtPos(item.pos);
+ if (domAtPos.node instanceof HTMLElement) {
+ domElement = domAtPos.node;
+ } else if (domAtPos.node.parentElement instanceof HTMLElement) {
+ domElement = domAtPos.node.parentElement;
+ }
+ } catch {
+ // ignore DOM resolution error
+ }
+ }
+
+ if (domElement) {
+ domElement.scrollIntoView({ behavior: "smooth", block: "start" });
+ }
+
+ try {
+ const maxPos = editor.state.doc.content.size;
+ const targetPos = Math.min(item.pos + 1, maxPos);
+ editor.chain().focus().setTextSelection(targetPos).run();
+ } catch {
+ // ignore selection positioning error
+ }
+
setActivePos(item.pos);
};
@@ -123,41 +157,61 @@ export const EditorOutline = ({ editor, scrollContainer }: EditorOutlineProps) =
}
return (
- <aside className="sticky top-0 h-fit max-h-[calc(100vh-8rem)] w-56 shrink-0 overflow-y-auto border-r border-slate-200 bg-slate-50/80 px-4 py-5" aria-label={t("editor.outline")}>
- <div className="flex items-center gap-2">
- <ListTree className="h-4 w-4 shrink-0 text-slate-500" aria-hidden="true" />
+ <aside
+ className="sticky top-6 h-fit max-h-[calc(100vh-8rem)] shrink-0 select-none overflow-y-auto py-2"
+ style={{ width: EDITOR_OUTLINE_WIDTH }}
+ aria-label={t("editor.outline")}
+ >
+ <div className="mb-3 flex items-center justify-between">
<button
type="button"
- className="flex min-w-0 flex-1 items-center gap-2 text-left text-xs font-semibold uppercase tracking-wide text-slate-600"
+ className="group flex items-center gap-1.5 text-left text-[11px] font-bold uppercase tracking-wider text-slate-400 transition-colors hover:text-slate-600"
onClick={() => setCollapsed((value) => !value)}
aria-expanded={!collapsed}
>
<span>{t("editor.outline")}</span>
- <ChevronDown className={cn("h-3.5 w-3.5 transition-transform", collapsed && "-rotate-90")} aria-hidden="true" />
+ <ChevronDown
+ className={cn(
+ "h-3 w-3 text-slate-400 transition-transform duration-200 group-hover:text-slate-600",
+ collapsed && "-rotate-90"
+ )}
+ aria-hidden="true"
+ />
</button>
- <span className="text-xs text-slate-400">{items.length}</span>
</div>
+
{!collapsed && (
- <nav className="mt-3" aria-label={t("editor.outline")}>
- <ol className="space-y-0.5">
- {items.map((item) => (
- <li key={item.pos}>
- <button
- type="button"
- className={cn(
- "block w-full truncate rounded px-2 py-1 text-left text-sm transition-colors",
- activePos === item.pos
- ? "bg-emerald-100 font-medium text-emerald-800"
- : "text-slate-600 hover:bg-slate-100 hover:text-slate-900"
+ <nav className="relative pl-3.5" aria-label={t("editor.outline")}>
+ <div className="absolute left-0 top-0 bottom-0 w-[1px] bg-slate-200/80" aria-hidden="true" />
+ <ol className="space-y-1.5">
+ {items.map((item) => {
+ const isActive = activePos === item.pos;
+ const displayText = stripLeadingEmoji(item.text);
+ return (
+ <li key={item.pos} className="relative flex items-center">
+ {isActive && (
+ <span
+ className="absolute left-0 top-0.5 bottom-0.5 w-[2px] -translate-x-[0.5px] rounded-full bg-sky-500 transition-all duration-200"
+ aria-hidden="true"
+ />
)}
- style={{ paddingLeft: `${8 + Math.max(0, item.level - 1) * 14}px` }}
- onClick={() => jumpToHeading(item)}
- title={item.text}
- >
- {item.text}
- </button>
- </li>
- ))}
+ <button
+ type="button"
+ className={cn(
+ "block w-full truncate text-left text-[13px] leading-snug transition-colors duration-150 py-0.5",
+ isActive
+ ? "font-medium text-slate-900"
+ : "text-slate-500 hover:text-slate-800"
+ )}
+ style={{ paddingLeft: `${Math.max(0, item.level - 1) * 12}px` }}
+ onClick={() => jumpToHeading(item)}
+ title={item.text}
+ >
+ {displayText}
+ </button>
+ </li>
+ );
+ })}
</ol>
</nav>
)}
diff --git a/apps/web/src/components/EditorPane.tsx b/apps/web/src/components/EditorPane.tsx
index 6d08000f..d860937a 100644
--- a/apps/web/src/components/EditorPane.tsx
+++ b/apps/web/src/components/EditorPane.tsx
@@ -2968,11 +2968,8 @@ const RichEditorPane = ({
useMobilePlainTextEditor ? "overflow-visible" : "overflow-y-auto"
)}
>
- <div className="flex min-h-full items-stretch">
- {!isMobileViewport && !useMobilePlainTextEditor && !useMarkdownSourceEditor && (
- <EditorOutline editor={editor} scrollContainer={editorScrollContainer} />
- )}
- <div className="min-w-0 flex-1">
+ <div className="flex min-h-full items-start w-full gap-8 px-6 py-6 sm:px-10">
+ <div className="min-w-0 flex-1 max-w-[var(--editor-content-max-width,880px)]">
{useMobilePlainTextEditor ? (
<>
<textarea
@@ -3024,6 +3021,9 @@ const RichEditorPane = ({
<EditorContent editor={editor} />
)}
</div>
+ {!isMobileViewport && !useMobilePlainTextEditor && !useMarkdownSourceEditor && (
+ <EditorOutline editor={editor} scrollContainer={editorScrollContainer} />
+ )}
</div>
</div>
diff --git a/apps/web/src/lib/workspace-ui.ts b/apps/web/src/lib/workspace-ui.ts
index 35f1c94b..fcee0b85 100644
--- a/apps/web/src/lib/workspace-ui.ts
+++ b/apps/web/src/lib/workspace-ui.ts
@@ -1 +1,9 @@
export const WORKSPACE_PAGE_TITLE_CLASSNAME = "text-sm font-semibold leading-5 text-slate-900";
+
+/**
+ * Editor Layout Constants
+ * - EDITOR_OUTLINE_WIDTH: Width of the left document outline (TOC) panel (default: 260px)
+ * - EDITOR_CONTENT_MAX_WIDTH: Maximum width of the document editor content area (default: 800px)
+ */
+export const EDITOR_OUTLINE_WIDTH = "300px";
+export const EDITOR_CONTENT_MAX_WIDTH = "880px";
diff --git a/apps/web/src/styles/globals.css b/apps/web/src/styles/globals.css
index 265da0c3..fdf3d877 100644
--- a/apps/web/src/styles/globals.css
+++ b/apps/web/src/styles/globals.css
@@ -42,6 +42,8 @@
--editor-body-font-size: 0.9375rem;
--editor-body-line-height: 1.6;
--editor-paragraph-spacing: 0.45rem;
+ --editor-outline-width: 300px;
+ --editor-content-max-width: 880px;
--card: 0 0% 100%;
--card-foreground: 224 71% 4%;
@@ -174,14 +176,14 @@ textarea {
.ProseMirror {
width: 100%;
- max-width: 1080px;
- margin: 0 auto;
+ max-width: var(--editor-content-max-width, 880px);
+ margin: 0;
color: #000;
font-size: var(--editor-body-font-size);
line-height: var(--editor-body-line-height);
min-height: 100%;
outline: none;
- padding: 24px 28px 56px;
+ padding: 8px 12px 56px;
}
.ProseMirror .edgeever-search-match {
diff --git a/package.json b/package.json
index f9a76671..52e9b8f0 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "edgeever",
- "version": "1.6.3",
+ "version": "1.6.4",
"private": true,
"type": "module",
"workspaces": [