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
fix(web): keep the note title and metadata on one header row
tianma-if71517861cfb4
diff --git a/apps/web/src/components/EditorPane.tsx b/apps/web/src/components/EditorPane.tsxindex 2a76f0ca..e6b16527 100644--- a/apps/web/src/components/EditorPane.tsx+++ b/apps/web/src/components/EditorPane.tsx@@ -26,6 +26,7 @@ import {Printer,Image as ImageIcon,Share2,+ Search,Copy,Lock,LockOpen,@@ -38,8 +39,8 @@ import { MemoEditorFocusModeButton, MemoEditorTopRowLeading, MemoEditorUpdatedLaimport { MemoEditorToolbarDivider } from "@/components/MemoEditorToolbarChrome";import {MEMO_EDITOR_READING_GUTTER_CLASS_NAME,- MEMO_EDITOR_TITLE_REGION_CLASS_NAME,MEMO_EDITOR_TOP_ROW_CLASS_NAME,+ nextTitleStatusClearance,} from "@/components/MemoEditorChromeDensity";import { MemoTitleInput } from "@/components/MemoTitleInput";import { Input } from "@/components/ui/input";@@ -525,6 +526,9 @@ const RichEditorPane = ({});const [editorScrollContainer, setEditorScrollContainer] = useState<HTMLDivElement | null>(null);const [editorScrollbarGutter, setEditorScrollbarGutter] = useState(0);+ const [headerTitleSlot, setHeaderTitleSlot] = useState<HTMLDivElement | null>(null);+ const [headerStatusCluster, setHeaderStatusCluster] = useState<HTMLDivElement | null>(null);+ const [titleStatusClearancePx, setTitleStatusClearancePx] = useState(0);useLayoutEffect(() => {const element = editorScrollContainer;if (!element) return;@@ -3306,6 +3310,32 @@ const RichEditorPane = ({title,});+ useLayoutEffect(() => {+ const title = headerTitleSlot;+ const status = headerStatusCluster;+ if (!title || !status) return;+ let frame = 0;+ const measure = () => {+ const titleRect = title.getBoundingClientRect();+ const statusRect = status.getBoundingClientRect();+ if (titleRect.width < 1 || statusRect.width < 1) return;+ const paddingRight = Number.parseFloat(getComputedStyle(title).paddingRight) || 0;+ const inputRight = titleRect.right - paddingRight;+ setTitleStatusClearancePx((current) => nextTitleStatusClearance(current, inputRight, statusRect.left));+ };+ measure();+ const observer = new ResizeObserver(() => {+ cancelAnimationFrame(frame);+ frame = requestAnimationFrame(measure);+ });+ observer.observe(title);+ observer.observe(status);+ return () => {+ cancelAnimationFrame(frame);+ observer.disconnect();+ };+ }, [characterCount, hasUnsavedChanges, headerStatusCluster, headerTitleSlot, saveState]);+if (isSelectionMode) {return (<div className="flex h-full min-w-0 flex-col bg-card">@@ -3590,14 +3620,20 @@ const RichEditorPane = ({<divclassName={cn("min-w-0 w-full",- editorColumnMatchesArticle ? MEMO_EDITOR_READING_GUTTER_CLASS_NAME : "px-3 sm:px-4",- "pr-36 sm:!pr-44",(desktopFocusMode || editorColumnStyle) && "mx-auto",desktopFocusMode && "max-w-[960px]",)}- style={editorColumnStyle}+ style={{+ ...editorColumnStyle,+ ...(titleStatusClearancePx > 0 ? { paddingRight: titleStatusClearancePx } : {}),+ }}+ >+ <div+ ref={setHeaderTitleSlot}+ className="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 px-4 sm:flex-nowrap"><MemoEditorTopRowLeading+ className="min-w-0 flex-1"mobileBackButton={(<ButtonclassName="lg:hidden"@@ -3613,7 +3649,7 @@ const RichEditorPane = ({)}titleInput={(<MemoTitleInput- className="px-0"+ className="w-full min-w-0 px-2"value={title}readOnly={effectiveReadOnly}onValueChange={(nextTitle) => {@@ -3625,15 +3661,59 @@ const RichEditorPane = ({/>)}/>+ <MemoEditorMetadataRow+ rowClassName="shrink-0 flex-nowrap"+ 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 h-7 w-7 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-3.5 w-3.5" /> : <LockOpen className="h-3.5 w-3.5" />}+ </Button>+ </IconTooltip>+ )}+ </>+ )}+ />+ </div></div>{editorColumnMatchesArticle && editorContentAlignment === "center" && !desktopFocusMode && !editorOutlineCollapsed ? (<div aria-hidden="true" className="hidden shrink-0 lg:block" style={{ width: `calc(${EDITOR_OUTLINE_WIDTH} + 2rem)` }} />) : null}</div>- <div className="absolute right-1 top-0 flex h-full shrink-0 items-center gap-1 sm:right-2">+ <div ref={setHeaderStatusCluster} className="absolute right-1 top-0 flex h-full shrink-0 items-center gap-1 sm:right-2"><div className="flex min-w-0 items-center gap-1.5"><MemoEditorUpdatedLabel updatedLabel={updatedLabel} />+ <span className="hidden shrink-0 whitespace-nowrap text-xs tabular-nums text-slate-400 sm:inline">+ {t("editor.characterCount", { count: characterCount })}+ </span>{imageUploadState !== "idle" && (<spanclassName={cn(@@ -3692,33 +3772,33 @@ const RichEditorPane = ({desktopFocusMode={desktopFocusMode}onToggleDesktopFocusMode={onToggleDesktopFocusMode}/>- {isMemoShared && !readOnly && (- <Button- className="h-8 w-8 text-slate-700"- 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 && (!mobileEditingActive || isMemoShared) && (+ <IconTooltip label={t(isLocalMemoId(memo.id) ? "sharing.afterSync" : isMemoShared ? "sharing.manage" : "sharing.action")}>+ <Button+ className={cn("h-8 w-8", isMemoShared ? "text-slate-700" : "text-slate-500")}+ size="icon"+ variant="ghost"+ type="button"+ aria-label={t(isLocalMemoId(memo.id) ? "sharing.afterSync" : isMemoShared ? "sharing.manage" : "sharing.action")}+ disabled={isLocalMemoId(memo.id)}+ onClick={() => setShareOpen(true)}+ >+ <Share2 className="h-4 w-4" aria-hidden="true" />+ </Button>+ </IconTooltip>)}- {!readOnly && !isMemoShared && !mobileEditingActive && (+ <IconTooltip label={t("editor.searchCurrentMemo")}><Button- className="h-8 w-8 text-slate-500 sm:hidden"+ className="hidden h-8 w-8 text-slate-500 sm:inline-flex"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)}+ aria-label={t("editor.searchCurrentMemo")}+ onClick={() => openNoteSearch()}>- <Share2 className="h-4 w-4" aria-hidden="true" />+ <Search className="h-4 w-4" aria-hidden="true" /></Button>- )}+ </IconTooltip>{mobileEditingActive && !readOnly && (<buttonclassName="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"@@ -3936,55 +4016,6 @@ const RichEditorPane = ({</div></div>- <div- className={cn(desktopFocusMode && "mx-auto w-full max-w-[1400px]", editorColumnMatchesArticle && editorContentAlignment === "center" && "flex justify-center")}- style={editorColumnMatchesArticle ? { paddingLeft: editorScrollbarGutter, paddingRight: editorScrollbarGutter } : undefined}- >- <div className={cn(MEMO_EDITOR_TITLE_REGION_CLASS_NAME, useMarkdownSourceEditor && "lg:px-4", "min-w-0 w-full", (desktopFocusMode || editorColumnStyle) && "mx-auto", desktopFocusMode && "max-w-[960px]")} style={editorColumnStyle}>- <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 h-7 w-7 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-3.5 w-3.5" /> : <LockOpen className="h-3.5 w-3.5" />}- </Button>- </IconTooltip>- )}- </>- )}- />- </div>- {editorColumnMatchesArticle && editorContentAlignment === "center" && !desktopFocusMode && !editorOutlineCollapsed ? (- <div aria-hidden="true" className="hidden shrink-0 lg:block" style={{ width: `calc(${EDITOR_OUTLINE_WIDTH} + 2rem)` }} />- ) : null}- </div>{noteSearchOpen ? (<EditorNoteSearchBarinputRef={noteSearchInputRef}diff --git a/apps/web/src/components/MemoEditorChromeDensity.test.mjs b/apps/web/src/components/MemoEditorChromeDensity.test.mjsnew file mode 100644index 00000000..939f7c9b--- /dev/null+++ b/apps/web/src/components/MemoEditorChromeDensity.test.mjs@@ -0,0 +1,18 @@+import { describe, expect, test } from "bun:test";+import { nextTitleStatusClearance } from "./MemoEditorChromeDensity.ts";++describe("title status clearance", () => {+ test("pads the title until it clears the status cluster", () => {+ expect(nextTitleStatusClearance(0, 1750, 1680)).toBe(78);+ expect(nextTitleStatusClearance(78, 1672, 1680)).toBe(78);+ });++ test("drops clearance once the title already sits clear of the status", () => {+ expect(nextTitleStatusClearance(40, 1500, 1700)).toBe(0);+ expect(nextTitleStatusClearance(0, 1500, 1700)).toBe(0);+ });++ test("stops growing once the inset reaches the header cap", () => {+ expect(nextTitleStatusClearance(480, 2000, 1000)).toBe(480);+ });+});diff --git a/apps/web/src/components/MemoEditorChromeDensity.ts b/apps/web/src/components/MemoEditorChromeDensity.tsindex f76cc37c..18c4ce0b 100644--- a/apps/web/src/components/MemoEditorChromeDensity.ts+++ b/apps/web/src/components/MemoEditorChromeDensity.ts@@ -12,3 +12,14 @@ export const MEMO_EDITOR_TOOLBAR_COLLAPSED_CLASS_NAME =export const MEMO_EDITOR_TITLE_REGION_CLASS_NAME =`space-y-1 pb-2 pt-1 sm:pb-2 sm:pt-1 ${MEMO_EDITOR_READING_GUTTER_CLASS_NAME}`;++/** Extra right inset so the title field stops before the header status cluster. */+export const nextTitleStatusClearance = (+ current: number,+ inputRight: number,+ statusLeft: number,+ gap = 8,+) => {+ const next = Math.min(480, Math.max(0, Math.ceil(current + inputRight - (statusLeft - gap))));+ return Math.abs(next - current) <= 1 ? current : next;+};diff --git a/apps/web/src/components/MemoEditorMetadataRow.tsx b/apps/web/src/components/MemoEditorMetadataRow.tsxindex d424cd05..9eb14371 100644--- a/apps/web/src/components/MemoEditorMetadataRow.tsx+++ b/apps/web/src/components/MemoEditorMetadataRow.tsx@@ -5,6 +5,7 @@ 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 { cn } from "@/lib/utils";import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";type MemoEditorMetadataRowProps = {@@ -18,6 +19,8 @@ type MemoEditorMetadataRowProps = {tagsText: string;title: string;trailingActions?: ReactNode;+ rowClassName?: string;+ includeMobileSheet?: boolean;onMobileNotebookPickerOpenChange: (open: boolean) => void;onNotebookChange: (notebookId: string) => void;onTagsChange: (tagsText: string) => void;@@ -34,6 +37,8 @@ export const MemoEditorMetadataRow = ({tagsText,title,trailingActions,+ rowClassName,+ includeMobileSheet = true,onMobileNotebookPickerOpenChange,onNotebookChange,onTagsChange,@@ -44,7 +49,7 @@ export const MemoEditorMetadataRow = ({return (<>- <div className="flex flex-wrap items-center gap-1.5 sm:gap-2">+ <div className={cn("flex flex-wrap items-center gap-1.5 sm:gap-2", rowClassName)}><buttonclassName="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"@@ -84,7 +89,7 @@ export const MemoEditorMetadataRow = ({{trailingActions}</div>- {mobileNotebookPickerOpen ? (+ {includeMobileSheet && mobileNotebookPickerOpen ? (<MobileNotebookSelectSheetisUpdating={notebookUpdatePending}options={notebookOptions}diff --git a/apps/web/src/components/MemoEditorTopRowLeading.tsx b/apps/web/src/components/MemoEditorTopRowLeading.tsxindex f46bc2c2..afd7cd8f 100644--- a/apps/web/src/components/MemoEditorTopRowLeading.tsx+++ b/apps/web/src/components/MemoEditorTopRowLeading.tsx@@ -3,6 +3,7 @@ import { Maximize2, Minimize2 } from "lucide-react";import { useTranslation } from "react-i18next";import { IconTooltip } from "@/components/editor/EditorPaneChrome";import { Button } from "@/components/ui/button";+import { cn } from "@/lib/utils";export const MemoEditorUpdatedLabel = ({ updatedLabel }: { updatedLabel: string }) => (<span className="hidden truncate text-xs text-slate-400 sm:inline">{updatedLabel}</span>@@ -37,13 +38,15 @@ export const MemoEditorFocusModeButton = ({};export const MemoEditorTopRowLeading = ({+ className,mobileBackButton,titleInput,}: {+ className?: string;mobileBackButton?: ReactNode;titleInput?: ReactNode;}) => (- <div className="flex min-w-0 flex-1 items-center gap-2 text-sm">+ <div className={cn("flex min-w-0 flex-1 items-center gap-2 text-sm", className)}>{mobileBackButton}{titleInput && <div className="min-w-0 flex-1">{titleInput}</div>}</div>