AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
refactor(web): share editor metadata chrome
tianma-ifc7fadef36e5b
diff --git a/apps/web/src/components/DiagramEditorPane.test.mjs b/apps/web/src/components/DiagramEditorPane.test.mjsindex add64e3c..22ea52da 100644--- a/apps/web/src/components/DiagramEditorPane.test.mjs+++ b/apps/web/src/components/DiagramEditorPane.test.mjs@@ -3,6 +3,7 @@ import { readFileSync } from "node:fs";const source = readFileSync(new URL("./DiagramEditorPane.tsx", import.meta.url), "utf8");const toolbarSource = readFileSync(new URL("./DiagramToolbar.tsx", import.meta.url), "utf8");+const topRowLeadingSource = readFileSync(new URL("./MemoEditorTopRowLeading.tsx", import.meta.url), "utf8");const globalStyles = readFileSync(new URL("../styles/globals.css", import.meta.url), "utf8");describe("diagram editor keyboard workflow", () => {@@ -39,7 +40,8 @@ describe("diagram editor keyboard workflow", () => {describe("diagram editor canvas surface", () => {test("uses the common note header and capability-aware more menu", () => {- expect(source).toContain('<span className="hidden truncate text-xs text-slate-400 sm:inline">{updatedLabel}</span>');+ expect(source).toContain("<MemoEditorTopRowLeading");+ expect(topRowLeadingSource).toContain('<span className="hidden truncate text-xs text-slate-400 sm:inline">{updatedLabel}</span>');expect(source).not.toContain('t("editor.updatedAt", { time: updatedLabel })');expect(source).toContain("onToggleDesktopFocusMode");expect(source).not.toContain("onOpenPreviousMemo");@@ -61,7 +63,9 @@ describe("diagram editor canvas surface", () => {expect(source).toContain("EDITOR_LOCAL_SAVE_DELAY_MS");expect(source).toContain("window.setTimeout(() => saveRef.current(), EDITOR_LOCAL_SAVE_DELAY_MS)");expect(source).toContain("nodeEditor !== null");- expect(source).toContain("[dirty, dirtyVersion, editSessionReady, nodeEditor, readOnly, saveFailed, saving]");+ expect(source).toContain("[dirtyVersion, editSessionReady, editorDirty, nodeEditor, readOnly, saveFailed, saving]");+ expect(source).toContain("tags: nextTags");+ expect(source).toContain("setTagsDirty(hasNewTagChanges)");expect(source).toContain("!readOnly && saveFailed");expect(source).toContain('t("diagram.retrySave")');expect(source).not.toContain('<Save className="h-4 w-4" />');@@ -258,7 +262,7 @@ describe("diagram editor canvas surface", () => {test("keeps the desktop header compact without shrinking mobile controls", () => {expect(source).toContain("MEMO_EDITOR_TOP_ROW_CLASS_NAME");- expect(source).toContain("MEMO_EDITOR_TITLE_ROW_CLASS_NAME");+ expect(source).toContain("MEMO_EDITOR_TITLE_REGION_CLASS_NAME");expect(toolbarSource).toContain("<MemoEditorToolbarRow");});diff --git a/apps/web/src/components/DiagramEditorPane.tsx b/apps/web/src/components/DiagramEditorPane.tsxindex af9bc494..602fb680 100644--- a/apps/web/src/components/DiagramEditorPane.tsx+++ b/apps/web/src/components/DiagramEditorPane.tsx@@ -43,8 +43,6 @@ import {Link2,LockKeyhole,LoaderCircle,- Maximize2,- Minimize2,MonitorSmartphone,Network,Pencil,@@ -80,6 +78,7 @@ import {type DiagramTheme,type MemoDetail,type MemoEditSession,+ type Notebook,} from "@edgeever/shared";import { Button } from "@/components/ui/button";import { Input } from "@/components/ui/input";@@ -89,8 +88,10 @@ import { ShareMemoDialog } from "@/components/dialogs/ShareMemoDialog";import { ClipboardCopyNotice } from "@/components/ClipboardCopyNotice";import { DiagramToolbar, DiagramToolbarAddTrigger } from "@/components/DiagramToolbar";import { MemoEditorHeaderActions } from "@/components/MemoEditorHeaderActions";+import { MemoEditorMetadataRow } from "@/components/MemoEditorMetadataRow";+import { MemoEditorTopRowLeading } from "@/components/MemoEditorTopRowLeading";import {- MEMO_EDITOR_TITLE_ROW_CLASS_NAME,+ MEMO_EDITOR_TITLE_REGION_CLASS_NAME,MEMO_EDITOR_TOP_ROW_CLASS_NAME,} from "@/components/MemoEditorChromeDensity";import { EditorNoteSearchBar } from "@/components/editor/EditorNoteSearchBar";@@ -99,7 +100,7 @@ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparaimport { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";import { useAppearanceTheme } from "@/components/ThemeProvider";import { api } from "@/lib/api";-import { EDITOR_LOCAL_SAVE_DELAY_MS } from "@/lib/app-helpers";+import { EDITOR_LOCAL_SAVE_DELAY_MS, getNotebookMoveOptions } from "@/lib/app-helpers";import { copyTextToClipboard } from "@/lib/clipboard";import {compactArchitectureNodeSize,@@ -116,10 +117,11 @@ import { isLocalMemoId } from "@/lib/local-mirror";import { isBrowserOffline } from "@/lib/network-status";import { statusSettleMotion } from "@/lib/motion";import type { EdgeEverRepository } from "@/lib/repository";-import { cn, formatDateTime } from "@/lib/utils";+import { cn, formatDateTime, parseTagsText } from "@/lib/utils";type DiagramEditorPaneProps = {memo: MemoDetail;+ notebooks: Notebook[];repository: EdgeEverRepository;readOnly: boolean;desktopFocusMode: boolean;@@ -1009,6 +1011,7 @@ const applyGraphPalette = (export const DiagramEditorPane = ({memo,+ notebooks,repository,readOnly,desktopFocusMode,@@ -1034,8 +1037,10 @@ export const DiagramEditorPane = ({const document = parseDiagramDocument(memo.contentMarkdown);const documentTheme = document?.theme ?? "brand";const [title, setTitle] = useState(memo.title ?? "");+ const [tagsText, setTagsText] = useState(memo.tags.join(", "));const [theme, setTheme] = useState<DiagramTheme>(documentTheme);const titleRef = useRef(title);+ const tagsRef = useRef(tagsText);const themeRef = useRef<DiagramTheme>(documentTheme);const appearanceRef = useRef<DiagramAppearance>(resolvedTheme);const savedSnapshotRef = useRef(document ? diagramEditorSnapshot(memo.title ?? "", document) : "");@@ -1046,6 +1051,7 @@ export const DiagramEditorPane = ({const [selectedEdgeLabel, setSelectedEdgeLabel] = useState("");const [hasSelection, setHasSelection] = useState(false);const [dirty, setDirty] = useState(false);+ const [tagsDirty, setTagsDirty] = useState(false);const [dirtyVersion, setDirtyVersion] = useState(0);const [saving, setSaving] = useState(false);const [editSessionReady, setEditSessionReady] = useState(false);@@ -1059,15 +1065,19 @@ export const DiagramEditorPane = ({const [searchOpen, setSearchOpen] = useState(false);const [searchQuery, setSearchQuery] = useState("");const [searchIndex, setSearchIndex] = useState(0);+ const [mobileNotebookSheetOpen, setMobileNotebookSheetOpen] = useState(false);+ const [notebookUpdatePending, setNotebookUpdatePending] = useState(false);const searchInputRef = useRef<HTMLInputElement | null>(null);const [zoomPercent, setZoomPercent] = useState(100);const [historyState, setHistoryState] = useState({ undo: false, redo: false });const [nodeEditor, setNodeEditor] = useState<NodeEditorState | null>(null);const [flowQuickCreate, setFlowQuickCreate] = useState<FlowQuickCreateState | null>(null);const [pendingArchitectureItem, setPendingArchitectureItem] = useState<ArchitectureLibraryItem | null>(null);+ const notebookOptions = useMemo(() => getNotebookMoveOptions(notebooks), [notebooks]);const flowQuickCreateRef = useRef<FlowQuickCreateState | null>(null);const flowPointerDragRef = useRef<FlowPointerDragState | null>(null);const nodeEditorRef = useRef<NodeEditorState | null>(null);+ const editorDirty = dirty || tagsDirty;useEffect(() => {setPendingArchitectureItem(null);@@ -1150,8 +1160,12 @@ export const DiagramEditorPane = ({memoRef.current = memo;setTitle(memo.title ?? "");titleRef.current = memo.title ?? "";+ setTagsText(memo.tags.join(", "));+ tagsRef.current = memo.tags.join(", ");savedSnapshotRef.current = document ? diagramEditorSnapshot(memo.title ?? "", document) : "";setDirty(false);+ setTagsDirty(false);+ setMobileNotebookSheetOpen(false);setSaveError(null);setSaveFailed(false);editSessionRef.current = null;@@ -1640,11 +1654,11 @@ export const DiagramEditorPane = ({}, [beginNodeEdit, dismissFlowQuickCreate, memo.contentHash, memo.id, readOnly]);useEffect(() => {- if (!dirty) return;+ if (!editorDirty) return;const warn = (event: BeforeUnloadEvent) => event.preventDefault();window.addEventListener("beforeunload", warn);return () => window.removeEventListener("beforeunload", warn);- }, [dirty]);+ }, [editorDirty]);useEffect(() => {if (readOnly) return;@@ -2033,10 +2047,13 @@ export const DiagramEditorPane = ({const graph = graphRef.current;const currentMemo = memoRef.current;const editSession = editSessionRef.current;- if (!graph || !document || !editSession || readOnly || saving) return;- if (savedSnapshotRef.current === diagramEditorSnapshot(titleRef.current, graphToDocument(graph, document.kind, themeRef.current))) {+ if (!graph || !document || !editSession || readOnly || saving) return false;+ if (+ savedSnapshotRef.current === diagramEditorSnapshot(titleRef.current, graphToDocument(graph, document.kind, themeRef.current))+ && !tagsDirty+ ) {setDirty(false);- return;+ return true;}setSaving(true);setSaveError(null);@@ -2045,6 +2062,7 @@ export const DiagramEditorPane = ({const nextDocument = graphToDocument(graph, document.kind, themeRef.current);const markdown = serializeDiagramDocument(nextDocument);const nextTitle = titleRef.current;+ const nextTags = parseTagsText(tagsRef.current);const nextSnapshot = diagramEditorSnapshot(nextTitle, nextDocument);const result = await repository.updateMemo(currentMemo, {expectedRevision: currentMemo.revision,@@ -2053,7 +2071,7 @@ export const DiagramEditorPane = ({title: nextTitle,contentJson: markdownToDoc(diagramFallbackMarkdown(nextDocument)),contentMarkdown: markdown,- tags: currentMemo.tags,+ tags: nextTags,});memoRef.current = result.memo;savedSnapshotRef.current = nextSnapshot;@@ -2062,15 +2080,24 @@ export const DiagramEditorPane = ({graphToDocument(graph, document.kind, themeRef.current),);const hasNewChanges = currentSnapshot !== nextSnapshot;+ const hasNewTagChanges = parseTagsText(tagsRef.current).join("\u0000") !== result.memo.tags.join("\u0000");setDirty(hasNewChanges);- if (!hasNewChanges) {+ setTagsDirty(hasNewTagChanges);+ if (!hasNewTagChanges) {+ const savedTagsText = result.memo.tags.join(", ");+ tagsRef.current = savedTagsText;+ setTagsText(savedTagsText);+ }+ if (!hasNewChanges && !hasNewTagChanges) {graph.cleanHistory();setHistoryState({ undo: false, redo: false });await onSaved(result.memo);}+ return true;} catch (error) {setSaveFailed(true);setSaveError(error instanceof Error ? error.message : t("diagram.saveError"));+ return false;} finally {setSaving(false);}@@ -2078,10 +2105,10 @@ export const DiagramEditorPane = ({saveRef.current = () => { void save(); };useEffect(() => {- if (readOnly || !dirty || nodeEditor !== null || saving || !editSessionReady || saveFailed) return;+ if (readOnly || !editorDirty || nodeEditor !== null || saving || !editSessionReady || saveFailed) return;const timer = window.setTimeout(() => saveRef.current(), EDITOR_LOCAL_SAVE_DELAY_MS);return () => window.clearTimeout(timer);- }, [dirty, dirtyVersion, editSessionReady, nodeEditor, readOnly, saveFailed, saving]);+ }, [dirtyVersion, editSessionReady, editorDirty, nodeEditor, readOnly, saveFailed, saving]);const handleCopyMemoId = async () => {if (isLocalMemoId(memo.id)) return;@@ -2110,6 +2137,32 @@ export const DiagramEditorPane = ({}, name.trim());};+ const handleNotebookChange = (notebookId: string) => {+ const currentMemo = memoRef.current;+ if (readOnly || notebookUpdatePending || notebookId === currentMemo.notebookId) {+ setMobileNotebookSheetOpen(false);+ return;+ }++ setNotebookUpdatePending(true);+ setSaveError(null);+ void (async () => {+ if (editorDirty && !(await save())) return;+ const sourceMemo = memoRef.current;+ await repository.moveMemos({ memoIds: [sourceMemo.id], notebookId });+ const { memo: movedMemo } = await repository.getMemo(sourceMemo.id);+ memoRef.current = movedMemo;+ await onSaved(movedMemo);+ })()+ .catch((error) => {+ setSaveError(error instanceof Error ? error.message : t("diagram.saveError"));+ })+ .finally(() => {+ setNotebookUpdatePending(false);+ setMobileNotebookSheetOpen(false);+ });+ };+const searchMatches = useMemo(() => {const query = searchQuery.trim().toLocaleLowerCase();if (!searchOpen || !query) return [];@@ -2157,7 +2210,7 @@ export const DiagramEditorPane = ({const currentMarkdown = historyOpen && dirty? serializeDiagramDocument(graphRef.current ? graphToDocument(graphRef.current, document.kind, themeRef.current) : document): memo.contentMarkdown;- const saveStatus = saveError ? "error" : saving ? "saving" : dirty ? "unsaved" : "saved";+ const saveStatus = saveError ? "error" : saving || notebookUpdatePending ? "saving" : editorDirty ? "unsaved" : "saved";const saveLabel = saveStatus === "error"? t("editor.saveState.error"): saveStatus === "saving"@@ -2176,28 +2229,21 @@ export const DiagramEditorPane = ({<div className="flex h-full min-h-0 flex-col bg-white"><header className="shrink-0 border-b border-slate-200 bg-white"><div className={MEMO_EDITOR_TOP_ROW_CLASS_NAME}>- <div className="flex min-w-0 items-center gap-2 text-sm">- <Tooltip>- <TooltipTrigger asChild>- <Button className="lg:hidden" size="icon" variant="ghost" aria-label={t("diagram.back")} onClick={() => dirty ? setConfirmDiscardOpen(true) : onBackToList()}>- <ChevronLeft className="h-4 w-4" />- </Button>- </TooltipTrigger>- <TooltipContent>{t("diagram.back")}</TooltipContent>- </Tooltip>- <div className="hidden items-center gap-1 lg:flex">+ <MemoEditorTopRowLeading+ desktopFocusMode={desktopFocusMode}+ updatedLabel={updatedLabel}+ onToggleDesktopFocusMode={onToggleDesktopFocusMode}+ mobileBackButton={(<Tooltip><TooltipTrigger asChild>- <Button size="sm" variant={desktopFocusMode ? "soft" : "ghost"} aria-label={t(desktopFocusMode ? "editor.exitFocusMode" : "editor.enterFocusMode")} aria-pressed={desktopFocusMode} onClick={onToggleDesktopFocusMode}>- {desktopFocusMode ? <Minimize2 className="h-4 w-4" /> : <Maximize2 className="h-4 w-4" />}- <span>{t(desktopFocusMode ? "editor.exitFocusMode" : "editor.focusMode")}</span>+ <Button className="lg:hidden" size="icon" variant="ghost" aria-label={t("diagram.back")} onClick={() => editorDirty ? setConfirmDiscardOpen(true) : onBackToList()}>+ <ChevronLeft className="h-4 w-4" /></Button></TooltipTrigger>- <TooltipContent>{t(desktopFocusMode ? "editor.exitFocusMode" : "editor.focusMode")}</TooltipContent>+ <TooltipContent>{t("diagram.back")}</TooltipContent></Tooltip>- </div>- <span className="hidden truncate text-xs text-slate-400 sm:inline">{updatedLabel}</span>- </div>+ )}+ /><div className="flex shrink-0 items-center gap-1"><m.span@@ -2301,23 +2347,44 @@ export const DiagramEditorPane = ({</div></div>- <div className={MEMO_EDITOR_TITLE_ROW_CLASS_NAME}>- <MemoTitleInput- value={title}- readOnly={readOnly}- placeholder={kindLabel}- ariaLabel={t("diagram.title")}- onValueChange={(nextTitle) => {- titleRef.current = nextTitle;- setTitle(nextTitle);+ <div className={MEMO_EDITOR_TITLE_REGION_CLASS_NAME}>+ <div className="min-w-0">+ <MemoTitleInput+ value={title}+ readOnly={readOnly}+ placeholder={kindLabel}+ ariaLabel={t("diagram.title")}+ onValueChange={(nextTitle) => {+ titleRef.current = nextTitle;+ setTitle(nextTitle);+ setDirtyVersion((current) => current + 1);+ const graph = graphRef.current;+ if (graph) {+ setDirty(savedSnapshotRef.current !== diagramEditorSnapshot(+ nextTitle,+ graphToDocument(graph, document.kind, themeRef.current),+ ));+ }+ }}+ />+ </div>+ <MemoEditorMetadataRow+ contentMarkdown={memo.contentMarkdown}+ disabled={readOnly}+ mobileNotebookPickerOpen={mobileNotebookSheetOpen}+ notebookOptions={notebookOptions}+ notebookUpdatePending={notebookUpdatePending || saving}+ repository={repository}+ selectedNotebookId={memoRef.current.notebookId}+ tagsText={tagsText}+ title={title}+ onMobileNotebookPickerOpenChange={setMobileNotebookSheetOpen}+ onNotebookChange={handleNotebookChange}+ onTagsChange={(nextTagsText) => {+ tagsRef.current = nextTagsText;+ setTagsText(nextTagsText);+ setTagsDirty(true);setDirtyVersion((current) => current + 1);- const graph = graphRef.current;- if (graph) {- setDirty(savedSnapshotRef.current !== diagramEditorSnapshot(- nextTitle,- graphToDocument(graph, document.kind, themeRef.current),- ));- }}}/></div>diff --git a/apps/web/src/components/EditorPane.tsx b/apps/web/src/components/EditorPane.tsxindex 5a356c08..db11fc46 100644--- a/apps/web/src/components/EditorPane.tsx+++ b/apps/web/src/components/EditorPane.tsx@@ -12,14 +12,11 @@ import * as m from "motion/react-m";import "katex/dist/katex.min.css";import {ChevronLeft,- ChevronDown,History,RotateCcw,Trash2,Tags,ReplaceAll,- Maximize2,- Minimize2,Paperclip,Pencil,Sparkles,@@ -40,8 +37,10 @@ import {import { Button } from "@/components/ui/button";import { ClipboardCopyNotice } from "@/components/ClipboardCopyNotice";import { MemoEditorHeaderActions } from "@/components/MemoEditorHeaderActions";+import { MemoEditorMetadataRow } from "@/components/MemoEditorMetadataRow";+import { MemoEditorTopRowLeading } from "@/components/MemoEditorTopRowLeading";import {- MEMO_EDITOR_TEXT_TITLE_REGION_CLASS_NAME,+ MEMO_EDITOR_TITLE_REGION_CLASS_NAME,MEMO_EDITOR_TOP_ROW_CLASS_NAME,} from "@/components/MemoEditorChromeDensity";import { MemoTitleInput } from "@/components/MemoTitleInput";@@ -51,11 +50,9 @@ import {DropdownMenuItem,DropdownMenuSeparator,} from "@/components/ui/dropdown-menu";-import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from "@/components/ui/select";import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";import { EditorToolbar } from "./EditorToolbar";import { EditorOutline } from "./EditorOutline";-import { EditorTagPicker } from "./EditorTagPicker";import { useAiBubbleMenu } from "./editor/useAiBubbleMenu";import {createEditorInstanceMemoIdentity,@@ -231,7 +228,6 @@ import { EditorSaveRecoveryBanner } from "./editor/EditorSaveRecoveryBanner";import {EmptyEditorHeader,IconTooltip,- MobileNotebookSelectSheet,NoteLinkInteractionHint,ResourceActionMenu,type NoteLinkHintPosition,@@ -3627,7 +3623,6 @@ const RichEditorPane = ({: saveStateClassName;const updatedLabel = formatDateTime(memo.updatedAt);- const currentNotebookLabel = notebookOptions.find((notebook) => notebook.id === memo.notebookId)?.name ?? t("editor.notebookFallback");const currentMarkdownForAi = getCurrentMarkdownForAi();const mobileDoneDisabled =@@ -3803,22 +3798,24 @@ const RichEditorPane = ({)}<header className="shrink-0 border-b border-slate-200 bg-white"><div className={MEMO_EDITOR_TOP_ROW_CLASS_NAME}>- <div className="flex min-w-0 items-center gap-2 text-sm">- <Button- className="lg:hidden"- size="icon"- variant="ghost"- title={hasUnsavedChanges && !readOnly ? t("editor.saveAndBack") : t("editor.backToList")}- aria-label={hasUnsavedChanges && !readOnly ? t("editor.saveAndBack") : t("editor.backToList")}- disabled={mobileDoneDisabled}- onClick={handleMobileBack}- >- <ChevronLeft className="h-4 w-4" />- </Button>- <span className="hidden truncate text-xs text-slate-400 sm:inline">- {updatedLabel}- </span>- </div>+ <MemoEditorTopRowLeading+ desktopFocusMode={desktopFocusMode}+ updatedLabel={updatedLabel}+ onToggleDesktopFocusMode={onToggleDesktopFocusMode}+ mobileBackButton={(+ <Button+ className="lg:hidden"+ size="icon"+ variant="ghost"+ title={hasUnsavedChanges && !readOnly ? t("editor.saveAndBack") : t("editor.backToList")}+ aria-label={hasUnsavedChanges && !readOnly ? t("editor.saveAndBack") : t("editor.backToList")}+ disabled={mobileDoneDisabled}+ onClick={handleMobileBack}+ >+ <ChevronLeft className="h-4 w-4" />+ </Button>+ )}+ /><div className="flex shrink-0 items-center gap-1">{isMemoShared && (@@ -4107,7 +4104,7 @@ const RichEditorPane = ({</div></div>- <div className={MEMO_EDITOR_TEXT_TITLE_REGION_CLASS_NAME}>+ <div className={MEMO_EDITOR_TITLE_REGION_CLASS_NAME}><div className="min-w-0"><MemoTitleInputvalue={title}@@ -4120,78 +4117,45 @@ const RichEditorPane = ({placeholder={t("common.untitledMemo")}/></div>- <div className="flex flex-wrap items-center gap-1.5 sm:gap-2">- <button- className="flex h-7 min-w-0 max-w-full items-center gap-1 rounded-md border border-transparent bg-transparent px-1.5 text-xs font-medium text-slate-600 outline-none transition hover:border-slate-200 hover:bg-slate-50 hover:text-slate-900 focus-visible:border-emerald-300 focus-visible:ring-2 focus-visible:ring-emerald-500/20 disabled:opacity-50 sm:hidden"- type="button"- disabled={effectiveReadOnly || notebookUpdatePending}- title={t("editor.currentNotebook")}- aria-label={t("editor.currentNotebookAria", { name: currentNotebookLabel })}- onClick={() => setMobileNotebookSheetOpen(true)}- >- <span className="min-w-0 truncate">{currentNotebookLabel}</span>- <ChevronDown className="h-3.5 w-3.5 shrink-0 text-slate-400" />- </button>- <div className="hidden min-w-[9rem] max-w-[18rem] sm:block">- <Select- value={memo.notebookId}- disabled={effectiveReadOnly || notebookUpdatePending}- onValueChange={(value) => handleNotebookChange(value)}- >- <SelectTrigger className="h-8 min-w-0 border-transparent bg-transparent px-2 text-sm font-medium text-slate-600 hover:border-slate-200 hover:bg-slate-50 hover:text-slate-900 whitespace-nowrap">- <SelectValue placeholder={t("editor.notebookPlaceholder")}>{currentNotebookLabel}</SelectValue>- </SelectTrigger>- <SelectContent className="max-h-60 bg-white border border-slate-200 rounded-md py-1 shadow-md">- {notebookOptions.map((notebook) => (- <SelectItem key={notebook.id} value={notebook.id}>- {notebook.selectLabel}- </SelectItem>- ))}- </SelectContent>- </Select>- </div>- <EditorTagPicker- contentMarkdown={currentMarkdownForAi}- disabled={effectiveReadOnly}- loadTags={() => repository.listTags()}- title={title}- value={tagsText}- onChange={(nextTagsText) => {- setTagsText(nextTagsText);- persistCurrentDraft(title, nextTagsText, getMobilePlainTextValue());- markDirty();- }}- />- {!readOnly && (- <IconTooltip label={`${t(desktopReadingProtection ? "editor.disableReadingProtection" : "editor.enableReadingProtection")} (${formatShortcutBinding(shortcutSettings.toggleReadingProtection)})`}>- <Button- className={cn(- "hidden shrink-0 sm:inline-flex",- desktopReadingProtection && "bg-slate-100 text-slate-700 ring-1 ring-inset ring-slate-300 hover:bg-slate-200 hover:text-slate-900"- )}- size="icon"- variant={desktopReadingProtection ? "soft" : "ghost"}- aria-label={`${t(desktopReadingProtection ? "editor.disableReadingProtection" : "editor.enableReadingProtection")} (${formatShortcutBinding(shortcutSettings.toggleReadingProtection)})`}- aria-pressed={desktopReadingProtection}- onClick={toggleDesktopReadingProtection}- >- {desktopReadingProtection ? <Lock className="h-4 w-4" /> : <LockOpen className="h-4 w-4" />}- </Button>- </IconTooltip>+ <MemoEditorMetadataRow+ contentMarkdown={currentMarkdownForAi}+ disabled={effectiveReadOnly}+ mobileNotebookPickerOpen={mobileNotebookSheetOpen}+ notebookOptions={notebookOptions}+ notebookUpdatePending={notebookUpdatePending || saveMutation.isPending}+ repository={repository}+ selectedNotebookId={memo.notebookId}+ tagsText={tagsText}+ title={title}+ onMobileNotebookPickerOpenChange={setMobileNotebookSheetOpen}+ onNotebookChange={handleNotebookChange}+ onTagsChange={(nextTagsText) => {+ setTagsText(nextTagsText);+ persistCurrentDraft(title, nextTagsText, getMobilePlainTextValue());+ markDirty();+ }}+ trailingActions={(+ <>+ {!readOnly && (+ <IconTooltip label={`${t(desktopReadingProtection ? "editor.disableReadingProtection" : "editor.enableReadingProtection")} (${formatShortcutBinding(shortcutSettings.toggleReadingProtection)})`}>+ <Button+ className={cn(+ "hidden shrink-0 sm:inline-flex",+ desktopReadingProtection && "bg-slate-100 text-slate-700 ring-1 ring-inset ring-slate-300 hover:bg-slate-200 hover:text-slate-900"+ )}+ size="icon"+ variant={desktopReadingProtection ? "soft" : "ghost"}+ aria-label={`${t(desktopReadingProtection ? "editor.disableReadingProtection" : "editor.enableReadingProtection")} (${formatShortcutBinding(shortcutSettings.toggleReadingProtection)})`}+ aria-pressed={desktopReadingProtection}+ onClick={toggleDesktopReadingProtection}+ >+ {desktopReadingProtection ? <Lock className="h-4 w-4" /> : <LockOpen className="h-4 w-4" />}+ </Button>+ </IconTooltip>+ )}+ </>)}- <Button- className="hidden shrink-0 lg:inline-flex"- size="sm"- variant={desktopFocusMode ? "soft" : "ghost"}- title={t(desktopFocusMode ? "editor.exitFocusMode" : "editor.enterFocusMode")}- aria-label={t(desktopFocusMode ? "editor.exitFocusMode" : "editor.enterFocusMode")}- aria-pressed={desktopFocusMode}- onClick={onToggleDesktopFocusMode}- >- {desktopFocusMode ? <Minimize2 className="h-4 w-4" /> : <Maximize2 className="h-4 w-4" />}- <span>{t(desktopFocusMode ? "editor.exitFocusMode" : "editor.focusMode")}</span>- </Button>- </div>+ /></div>{noteSearchOpen ? (<EditorNoteSearchBar@@ -4557,15 +4521,6 @@ const RichEditorPane = ({/>)}- {mobileNotebookSheetOpen && (- <MobileNotebookSelectSheet- isUpdating={notebookUpdatePending || saveMutation.isPending}- options={notebookOptions}- selectedNotebookId={memo.notebookId}- onClose={() => setMobileNotebookSheetOpen(false)}- onSelect={handleNotebookChange}- />- )}</div>);};diff --git a/apps/web/src/components/MemoEditorChromeDensity.ts b/apps/web/src/components/MemoEditorChromeDensity.tsindex fb415f6b..ca552167 100644--- a/apps/web/src/components/MemoEditorChromeDensity.ts+++ b/apps/web/src/components/MemoEditorChromeDensity.ts@@ -1,11 +1,8 @@export const MEMO_EDITOR_TOP_ROW_CLASS_NAME ="flex min-h-12 items-center justify-between gap-2 border-b border-slate-100 px-3 py-2 sm:min-h-9 sm:px-4 sm:py-0.5";-export const MEMO_EDITOR_TITLE_ROW_CLASS_NAME =- "flex min-h-12 items-center gap-3 px-4 py-2 sm:min-h-10 sm:px-4 sm:py-1";-export const MEMO_EDITOR_TOOLBAR_PADDING_CLASS_NAME ="px-3 py-2 sm:px-4 sm:py-0.5";-export const MEMO_EDITOR_TEXT_TITLE_REGION_CLASS_NAME =+export const MEMO_EDITOR_TITLE_REGION_CLASS_NAME ="space-y-1.5 px-4 pb-2.5 pt-2.5 sm:space-y-3 sm:px-4 sm:pb-4 sm:pt-4 lg:space-y-0 lg:py-0";diff --git a/apps/web/src/components/MemoEditorHeaderActions.test.mjs b/apps/web/src/components/MemoEditorHeaderActions.test.mjsindex 9ba0a59b..6e6be7a1 100644--- a/apps/web/src/components/MemoEditorHeaderActions.test.mjs+++ b/apps/web/src/components/MemoEditorHeaderActions.test.mjs@@ -8,6 +8,8 @@ const densitySource = readFileSync(new URL("./MemoEditorChromeDensity.ts", imporconst editorToolbarSource = readFileSync(new URL("./EditorToolbar.tsx", import.meta.url), "utf8");const diagramToolbarSource = readFileSync(new URL("./DiagramToolbar.tsx", import.meta.url), "utf8");const toolbarChromeSource = readFileSync(new URL("./MemoEditorToolbarChrome.tsx", import.meta.url), "utf8");+const metadataRowSource = readFileSync(new URL("./MemoEditorMetadataRow.tsx", import.meta.url), "utf8");+const topRowLeadingSource = readFileSync(new URL("./MemoEditorTopRowLeading.tsx", import.meta.url), "utf8");describe("shared memo editor header actions", () => {test("owns every action shared by text and diagram notes", () => {@@ -29,6 +31,23 @@ describe("shared memo editor header actions", () => {expect(diagramSource).not.toContain("<WeChatIcon");});+ test("shares notebook and tag metadata controls across text and diagram notes", () => {+ expect(editorSource).toContain("<MemoEditorMetadataRow");+ expect(diagramSource).toContain("<MemoEditorMetadataRow");+ expect(metadataRowSource).toContain("<EditorTagPicker");+ expect(metadataRowSource).toContain("<MobileNotebookSelectSheet");+ expect(metadataRowSource).toContain("<Select");+ expect(topRowLeadingSource).toContain("<Maximize2");+ expect(topRowLeadingSource).toContain("onToggleDesktopFocusMode");+ expect(editorSource).toContain("<MemoEditorTopRowLeading");+ expect(diagramSource).toContain("<MemoEditorTopRowLeading");+ expect(editorSource).not.toContain("<EditorTagPicker");+ expect(diagramSource).not.toContain("<EditorTagPicker");+ expect(editorSource).not.toContain("<Maximize2");+ expect(diagramSource).not.toContain("<Maximize2");+ expect(metadataRowSource).not.toContain("<Maximize2");+ });+test("leaves sequential note navigation to the memo list", () => {expect(editorSource).not.toContain("onOpenPreviousMemo");expect(editorSource).not.toContain("onOpenNextMemo");diff --git a/apps/web/src/components/MemoEditorMetadataRow.tsx b/apps/web/src/components/MemoEditorMetadataRow.tsxnew file mode 100644index 00000000..9471393e--- /dev/null+++ b/apps/web/src/components/MemoEditorMetadataRow.tsx@@ -0,0 +1,98 @@+import type { ReactNode } from "react";+import { ChevronDown } from "lucide-react";+import { useTranslation } from "react-i18next";+import type { NotebookMoveOption } from "@/lib/app-helpers";+import type { EdgeEverRepository } from "@/lib/repository";+import { EditorTagPicker } from "@/components/EditorTagPicker";+import { MobileNotebookSelectSheet } from "@/components/editor/EditorPaneChrome";+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";++type MemoEditorMetadataRowProps = {+ contentMarkdown: string;+ disabled: boolean;+ mobileNotebookPickerOpen: boolean;+ notebookOptions: NotebookMoveOption[];+ notebookUpdatePending: boolean;+ repository: Pick<EdgeEverRepository, "listTags">;+ selectedNotebookId: string;+ tagsText: string;+ title: string;+ trailingActions?: ReactNode;+ onMobileNotebookPickerOpenChange: (open: boolean) => void;+ onNotebookChange: (notebookId: string) => void;+ onTagsChange: (tagsText: string) => void;+};++export const MemoEditorMetadataRow = ({+ contentMarkdown,+ disabled,+ mobileNotebookPickerOpen,+ notebookOptions,+ notebookUpdatePending,+ repository,+ selectedNotebookId,+ tagsText,+ title,+ trailingActions,+ onMobileNotebookPickerOpenChange,+ onNotebookChange,+ onTagsChange,+}: MemoEditorMetadataRowProps) => {+ const { t } = useTranslation();+ const currentNotebookLabel = notebookOptions.find((notebook) => notebook.id === selectedNotebookId)?.name+ ?? t("editor.notebookFallback");++ return (+ <>+ <div className="flex flex-wrap items-center gap-1.5 sm:gap-2">+ <button+ className="flex h-7 min-w-0 max-w-full items-center gap-1 rounded-md border border-transparent bg-transparent px-1.5 text-xs font-medium text-slate-600 outline-none transition hover:border-slate-200 hover:bg-slate-50 hover:text-slate-900 focus-visible:border-emerald-300 focus-visible:ring-2 focus-visible:ring-emerald-500/20 disabled:opacity-50 sm:hidden"+ type="button"+ disabled={disabled || notebookUpdatePending}+ aria-label={t("editor.currentNotebookAria", { name: currentNotebookLabel })}+ onClick={() => onMobileNotebookPickerOpenChange(true)}+ >+ <span className="min-w-0 truncate">{currentNotebookLabel}</span>+ <ChevronDown className="h-3.5 w-3.5 shrink-0 text-slate-400" />+ </button>+ <div className="hidden min-w-[9rem] max-w-[18rem] sm:block">+ <Select+ value={selectedNotebookId}+ disabled={disabled || notebookUpdatePending}+ onValueChange={onNotebookChange}+ >+ <SelectTrigger className="h-8 min-w-0 whitespace-nowrap border-transparent bg-transparent px-2 text-sm font-medium text-slate-600 hover:border-slate-200 hover:bg-slate-50 hover:text-slate-900">+ <SelectValue placeholder={t("editor.notebookPlaceholder")}>{currentNotebookLabel}</SelectValue>+ </SelectTrigger>+ <SelectContent className="max-h-60 rounded-md border border-slate-200 bg-white py-1 shadow-md">+ {notebookOptions.map((notebook) => (+ <SelectItem key={notebook.id} value={notebook.id}>+ {notebook.selectLabel}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ </div>+ <EditorTagPicker+ contentMarkdown={contentMarkdown}+ disabled={disabled}+ loadTags={() => repository.listTags()}+ title={title}+ value={tagsText}+ onChange={onTagsChange}+ />+ {trailingActions}+ </div>++ {mobileNotebookPickerOpen ? (+ <MobileNotebookSelectSheet+ isUpdating={notebookUpdatePending}+ options={notebookOptions}+ selectedNotebookId={selectedNotebookId}+ onClose={() => onMobileNotebookPickerOpenChange(false)}+ onSelect={onNotebookChange}+ />+ ) : null}+ </>+ );+};diff --git a/apps/web/src/components/MemoEditorTopRowLeading.tsx b/apps/web/src/components/MemoEditorTopRowLeading.tsxnew file mode 100644index 00000000..1d375e8e--- /dev/null+++ b/apps/web/src/components/MemoEditorTopRowLeading.tsx@@ -0,0 +1,41 @@+import type { ReactNode } from "react";+import { Maximize2, Minimize2 } from "lucide-react";+import { useTranslation } from "react-i18next";+import { IconTooltip } from "@/components/editor/EditorPaneChrome";+import { Button } from "@/components/ui/button";++export const MemoEditorTopRowLeading = ({+ desktopFocusMode,+ mobileBackButton,+ updatedLabel,+ onToggleDesktopFocusMode,+}: {+ desktopFocusMode: boolean;+ mobileBackButton: ReactNode;+ updatedLabel: string;+ onToggleDesktopFocusMode: () => void;+}) => {+ const { t } = useTranslation();+ const focusModeLabel = t(desktopFocusMode ? "editor.exitFocusMode" : "editor.focusMode");++ return (+ <div className="flex min-w-0 items-center gap-2 text-sm">+ {mobileBackButton}+ <div className="hidden items-center lg:flex">+ <IconTooltip label={focusModeLabel}>+ <Button+ size="sm"+ variant={desktopFocusMode ? "soft" : "ghost"}+ aria-label={t(desktopFocusMode ? "editor.exitFocusMode" : "editor.enterFocusMode")}+ aria-pressed={desktopFocusMode}+ onClick={onToggleDesktopFocusMode}+ >+ {desktopFocusMode ? <Minimize2 className="h-4 w-4" /> : <Maximize2 className="h-4 w-4" />}+ <span>{focusModeLabel}</span>+ </Button>+ </IconTooltip>+ </div>+ <span className="hidden truncate text-xs text-slate-400 sm:inline">{updatedLabel}</span>+ </div>+ );+};diff --git a/apps/web/src/components/WorkspaceApp.tsx b/apps/web/src/components/WorkspaceApp.tsxindex 8cd283bc..b0eb2511 100644--- a/apps/web/src/components/WorkspaceApp.tsx+++ b/apps/web/src/components/WorkspaceApp.tsx@@ -3429,6 +3429,7 @@ export const WorkspaceApp = ({{selectedMemo && selectedDiagram ? (<DiagramEditorPanememo={selectedMemo}+ notebooks={notebooks}repository={repository}readOnly={memoView === "trash" || selectedMemo.isDeleted}desktopFocusMode={desktopFocusModeActive}