Skip to content

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

fix(web): separate note header status from action icons

tianma-if75b792348c15
diff --git a/apps/web/src/components/DiagramEditorPane.tsx b/apps/web/src/components/DiagramEditorPane.tsx
index 35867ad7..b7e3f3e3 100644
--- a/apps/web/src/components/DiagramEditorPane.tsx
+++ b/apps/web/src/components/DiagramEditorPane.tsx
@@ -151,7 +151,8 @@ 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 { MemoEditorFocusModeButton, MemoEditorTopRowLeading, MemoEditorUpdatedLabel } from "@/components/MemoEditorTopRowLeading";
+import { MemoEditorToolbarDivider } from "@/components/MemoEditorToolbarChrome";
import {
MEMO_EDITOR_TITLE_REGION_CLASS_NAME,
MEMO_EDITOR_TOP_ROW_CLASS_NAME,
@@ -3049,9 +3050,6 @@ export const DiagramEditorPane = ({
<header className="shrink-0 border-b border-slate-200 bg-card">
<div className={MEMO_EDITOR_TOP_ROW_CLASS_NAME}>
<MemoEditorTopRowLeading
- desktopFocusMode={desktopFocusMode}
- updatedLabel={updatedLabel}
- onToggleDesktopFocusMode={onToggleDesktopFocusMode}
mobileBackButton={(
<Tooltip>
<TooltipTrigger asChild>
@@ -3085,6 +3083,8 @@ export const DiagramEditorPane = ({
/>
<div className="flex shrink-0 items-center gap-1">
+ <div className="flex min-w-0 items-center gap-1.5">
+ <MemoEditorUpdatedLabel updatedLabel={updatedLabel} />
<m.span
key={`mobile-${saveStatus}`}
className={cn(
@@ -3120,6 +3120,13 @@ export const DiagramEditorPane = ({
)}
{saveLabel}
</m.span>
+ </div>
+ <MemoEditorToolbarDivider className="mx-0.5 hidden h-4 sm:block" />
+ <div className="flex items-center gap-0.5">
+ <MemoEditorFocusModeButton
+ desktopFocusMode={desktopFocusMode}
+ onToggleDesktopFocusMode={onToggleDesktopFocusMode}
+ />
{!readOnly && saveFailed && (
<Button variant="soft" size="sm" disabled={saving || !editSessionReady} onClick={() => void save()}>
<RefreshCw className="h-4 w-4" />
@@ -3182,6 +3189,7 @@ export const DiagramEditorPane = ({
</>
)}
/>
+ </div>
</div>
</div>
diff --git a/apps/web/src/components/EditorPane.tsx b/apps/web/src/components/EditorPane.tsx
index 27be766d..7c2fe43f 100644
--- a/apps/web/src/components/EditorPane.tsx
+++ b/apps/web/src/components/EditorPane.tsx
@@ -34,7 +34,8 @@ 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 { MemoEditorFocusModeButton, MemoEditorTopRowLeading, MemoEditorUpdatedLabel } from "@/components/MemoEditorTopRowLeading";
+import { MemoEditorToolbarDivider } from "@/components/MemoEditorToolbarChrome";
import {
MEMO_EDITOR_TITLE_REGION_CLASS_NAME,
MEMO_EDITOR_TOP_ROW_CLASS_NAME,
@@ -3535,9 +3536,6 @@ const RichEditorPane = ({
<header className="shrink-0 border-b border-slate-200 bg-card">
<div className={MEMO_EDITOR_TOP_ROW_CLASS_NAME}>
<MemoEditorTopRowLeading
- desktopFocusMode={desktopFocusMode}
- updatedLabel={updatedLabel}
- onToggleDesktopFocusMode={onToggleDesktopFocusMode}
mobileBackButton={(
<Button
className="lg:hidden"
@@ -3566,34 +3564,8 @@ const RichEditorPane = ({
/>
<div className="flex shrink-0 items-center gap-1">
- {isMemoShared && !readOnly && (
- <Button
- className="h-7 gap-1 rounded-full bg-emerald-50 px-2 text-[11px] font-medium text-emerald-700 ring-1 ring-inset ring-emerald-200 hover:bg-emerald-100 hover:text-emerald-800 focus-visible:ring-emerald-500"
- size="sm"
- variant="ghost"
- type="button"
- title={t("sharing.manage")}
- aria-label={t("sharing.manage")}
- onClick={() => setShareOpen(true)}
- >
- <Share2 className="h-3 w-3" aria-hidden="true" />
- <span className="hidden sm:inline">{t("sharing.active")}</span>
- </Button>
- )}
- {!readOnly && !isMemoShared && !mobileEditingActive && (
- <Button
- className="h-8 w-8 text-slate-500 sm:hidden"
- size="icon"
- variant="ghost"
- type="button"
- title={t(isLocalMemoId(memo.id) ? "sharing.afterSync" : "sharing.action")}
- aria-label={t(isLocalMemoId(memo.id) ? "sharing.afterSync" : "sharing.action")}
- disabled={isLocalMemoId(memo.id)}
- onClick={() => setShareOpen(true)}
- >
- <Share2 className="h-4 w-4" aria-hidden="true" />
- </Button>
- )}
+ <div className="flex min-w-0 items-center gap-1.5">
+ <MemoEditorUpdatedLabel updatedLabel={updatedLabel} />
<span
className="hidden whitespace-nowrap px-1.5 text-xs tabular-nums text-slate-400 sm:inline-flex"
title={t("editor.characterCount", { count: characterCount })}
@@ -3647,6 +3619,40 @@ const RichEditorPane = ({
>
{mobileStatusLabel}
</m.span>
+ </div>
+ <MemoEditorToolbarDivider className="mx-0.5 hidden h-4 sm:block" />
+ <div className="flex items-center gap-0.5">
+ <MemoEditorFocusModeButton
+ desktopFocusMode={desktopFocusMode}
+ onToggleDesktopFocusMode={onToggleDesktopFocusMode}
+ />
+ {isMemoShared && !readOnly && (
+ <Button
+ className="h-8 w-8 rounded-full bg-emerald-50 text-emerald-700 ring-1 ring-inset ring-emerald-200 hover:bg-emerald-100 hover:text-emerald-800 focus-visible:ring-emerald-500"
+ size="icon"
+ variant="ghost"
+ type="button"
+ title={t("sharing.manage")}
+ aria-label={t("sharing.manage")}
+ onClick={() => setShareOpen(true)}
+ >
+ <Share2 className="h-4 w-4" aria-hidden="true" />
+ </Button>
+ )}
+ {!readOnly && !isMemoShared && !mobileEditingActive && (
+ <Button
+ className="h-8 w-8 text-slate-500 sm:hidden"
+ size="icon"
+ variant="ghost"
+ type="button"
+ title={t(isLocalMemoId(memo.id) ? "sharing.afterSync" : "sharing.action")}
+ aria-label={t(isLocalMemoId(memo.id) ? "sharing.afterSync" : "sharing.action")}
+ disabled={isLocalMemoId(memo.id)}
+ onClick={() => setShareOpen(true)}
+ >
+ <Share2 className="h-4 w-4" aria-hidden="true" />
+ </Button>
+ )}
{mobileEditingActive && !readOnly && (
<button
className="inline-flex h-8 items-center justify-center rounded-full bg-slate-950 px-3 text-xs font-semibold text-white transition hover:bg-slate-800 disabled:bg-slate-200 disabled:text-slate-500 sm:hidden"
@@ -3887,6 +3893,7 @@ const RichEditorPane = ({
</>
)}
/>
+ </div>
</div>
</div>
diff --git a/apps/web/src/components/FocusModeEntry.test.mjs b/apps/web/src/components/FocusModeEntry.test.mjs
index 65b7df66..b3d1f1a0 100644
--- a/apps/web/src/components/FocusModeEntry.test.mjs
+++ b/apps/web/src/components/FocusModeEntry.test.mjs
@@ -5,16 +5,18 @@ const editorPaneSource = readFileSync(new URL("./EditorPane.tsx", import.meta.ur
const diagramEditorPaneSource = readFileSync(new URL("./DiagramEditorPane.tsx", import.meta.url), "utf8");
const topRowLeadingSource = readFileSync(new URL("./MemoEditorTopRowLeading.tsx", import.meta.url), "utf8");
-const expectDiscoverableFocusModeEntry = (source) => {
+const expectIconOnlyFocusModeEntry = (source) => {
const normalizedSource = source.replace(/\s+/g, " ");
- expect(normalizedSource).toContain('size="sm" variant={desktopFocusMode ? "soft" : "ghost"}');
- expect(normalizedSource).toContain('<span>{focusModeLabel}</span>');
+ expect(normalizedSource).toContain('size="icon"');
+ expect(normalizedSource).toContain('variant={desktopFocusMode ? "soft" : "ghost"}');
+ expect(normalizedSource).toContain("<IconTooltip label={focusModeLabel}>");
+ expect(normalizedSource).not.toContain("<span>{focusModeLabel}</span>");
expect(source).not.toContain('size="sm"\n variant="solid"');
};
describe("focus mode entry", () => {
- test("labels a restrained action in every desktop note editor instead of relying on an ambiguous icon", () => {
- expectDiscoverableFocusModeEntry(topRowLeadingSource);
+ test("keeps an icon-only focus action with a tooltip in every desktop note editor", () => {
+ expectIconOnlyFocusModeEntry(topRowLeadingSource);
for (const source of [editorPaneSource, diagramEditorPaneSource]) {
expect(source).toContain("<MemoEditorTopRowLeading");
expect(source).toContain("desktopFocusMode={desktopFocusMode}");
@@ -22,12 +24,15 @@ describe("focus mode entry", () => {
}
});
- test("keeps the focus mode entry in the shared editor header instead of top-level navigation", () => {
+ test("keeps status copy ahead of the action icons in the shared editor header", () => {
for (const source of [editorPaneSource, diagramEditorPaneSource]) {
- const focusModeEntryIndex = source.indexOf("<MemoEditorTopRowLeading");
+ const statusIndex = source.indexOf("<MemoEditorUpdatedLabel");
+ const focusIndex = source.indexOf("<MemoEditorFocusModeButton");
const headerActionsIndex = source.indexOf("<MemoEditorHeaderActions");
- expect(focusModeEntryIndex).toBeGreaterThan(-1);
- expect(headerActionsIndex).toBeGreaterThan(focusModeEntryIndex);
+ expect(statusIndex).toBeGreaterThan(-1);
+ expect(focusIndex).toBeGreaterThan(statusIndex);
+ expect(headerActionsIndex).toBeGreaterThan(focusIndex);
+ expect(source.indexOf("<MemoEditorTopRowLeading")).toBeGreaterThan(-1);
}
});
});
diff --git a/apps/web/src/components/MemoEditorTopRowLeading.tsx b/apps/web/src/components/MemoEditorTopRowLeading.tsx
index 2e2315d4..f46bc2c2 100644
--- a/apps/web/src/components/MemoEditorTopRowLeading.tsx
+++ b/apps/web/src/components/MemoEditorTopRowLeading.tsx
@@ -4,41 +4,47 @@ import { useTranslation } from "react-i18next";
import { IconTooltip } from "@/components/editor/EditorPaneChrome";
import { Button } from "@/components/ui/button";
-export const MemoEditorTopRowLeading = ({
+export const MemoEditorUpdatedLabel = ({ updatedLabel }: { updatedLabel: string }) => (
+ <span className="hidden truncate text-xs text-slate-400 sm:inline">{updatedLabel}</span>
+);
+
+export const MemoEditorFocusModeButton = ({
desktopFocusMode,
- mobileBackButton,
- updatedLabel,
onToggleDesktopFocusMode,
- titleInput,
}: {
desktopFocusMode: boolean;
- mobileBackButton?: ReactNode;
- updatedLabel: string;
onToggleDesktopFocusMode: () => void;
- titleInput?: ReactNode;
}) => {
const { t } = useTranslation();
- const focusModeLabel = t(desktopFocusMode ? "editor.exitFocusMode" : "editor.focusMode");
+ const focusModeLabel = t(desktopFocusMode ? "editor.exitFocusMode" : "editor.enterFocusMode");
return (
- <div className="flex min-w-0 flex-1 items-center gap-2 text-sm">
- {mobileBackButton}
- {titleInput && <div className="min-w-0 flex-1">{titleInput}</div>}
- <div className="hidden shrink-0 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 className="hidden shrink-0 items-center lg:flex">
+ <IconTooltip label={focusModeLabel}>
+ <Button
+ className="h-8 w-8 text-slate-500"
+ size="icon"
+ variant={desktopFocusMode ? "soft" : "ghost"}
+ aria-label={focusModeLabel}
+ aria-pressed={desktopFocusMode}
+ onClick={onToggleDesktopFocusMode}
+ >
+ {desktopFocusMode ? <Minimize2 className="h-4 w-4" /> : <Maximize2 className="h-4 w-4" />}
+ </Button>
+ </IconTooltip>
</div>
);
};
+
+export const MemoEditorTopRowLeading = ({
+ mobileBackButton,
+ titleInput,
+}: {
+ mobileBackButton?: ReactNode;
+ titleInput?: ReactNode;
+}) => (
+ <div className="flex min-w-0 flex-1 items-center gap-2 text-sm">
+ {mobileBackButton}
+ {titleInput && <div className="min-w-0 flex-1">{titleInput}</div>}
+ </div>
+);