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(settings): reorganize preference cards into dedicated tabs
tianma-if36872660e200
diff --git a/apps/web/src/components/SettingsPane.tsx b/apps/web/src/components/SettingsPane.tsxindex 12802c2e..0035a84f 100644--- a/apps/web/src/components/SettingsPane.tsx+++ b/apps/web/src/components/SettingsPane.tsx@@ -3,6 +3,8 @@ import {ChevronRight,Database,Info,+ Keyboard,+ KeyRound,LayoutTemplate,Shield,SlidersHorizontal,@@ -28,6 +30,7 @@ import { EvernoteImportGuideCard } from "./settings/EvernoteImportGuideCard";import { FeedbackLink } from "./settings/FeedbackLink";import { McpConfigCard } from "./settings/McpConfigCard";import { PreferenceCard } from "./settings/PreferenceCard";+import { ShortcutSettingsItem } from "./settings/ShortcutSettingsItem";import { PasswordCard } from "./settings/PasswordCard";import { UserManagementCard } from "./settings/UserManagementCard";import { ObjectStorageCard } from "./settings/ObjectStorageCard";@@ -65,7 +68,7 @@ const SettingsGroup = ({ children }: { children: ReactNode }) => (</div>);-type TabKey = "general" | "users" | "data" | "ai" | "advanced" | "account";+type TabKey = "general" | "shortcuts" | "users" | "data" | "ai" | "mcp" | "advanced" | "account";interface TabItem {key: TabKey;@@ -106,11 +109,21 @@ export const SettingsPane = ({label: t("settings.tabs.general"),icon: SlidersHorizontal,},+ {+ key: "shortcuts",+ label: t("settings.tabs.shortcuts"),+ icon: Keyboard,+ },{key: "ai",label: t("settings.tabs.ai"),icon: Sparkles,},+ {+ key: "mcp",+ label: t("settings.tabs.mcp"),+ icon: KeyRound,+ },{key: "data",label: t("settings.tabs.data"),@@ -141,6 +154,8 @@ export const SettingsPane = ({},];+ const mobileTabItems = tabItems.filter((item) => item.key !== "shortcuts");+const handleBack = () => {if (activeMobileTab !== null) {setActiveMobileTab(null);@@ -169,17 +184,24 @@ export const SettingsPane = ({switch (key) {case "general":return (- <SettingsGroup>+ <div className="grid gap-6"><PreferenceCardimageCompressionEnabled={imageCompressionEnabled}onImageCompressionChange={onImageCompressionChange}- shortcutSettings={shortcutSettings}- onShortcutSettingsChange={onShortcutSettingsChange}editorContentAlignment={editorContentAlignment}onEditorContentAlignmentChange={onEditorContentAlignmentChange}/>- <FeedbackLink className="hidden lg:flex" />- </SettingsGroup>+ <div className="hidden overflow-hidden rounded-xl border border-slate-200 bg-card lg:block">+ <FeedbackLink />+ </div>+ </div>+ );+ case "shortcuts":+ return (+ <ShortcutSettingsItem+ shortcutSettings={shortcutSettings}+ onShortcutSettingsChange={onShortcutSettingsChange}+ />);case "users":return isOwner ? (@@ -198,6 +220,11 @@ export const SettingsPane = ({return (<SettingsGroup><AiModelCard />+ </SettingsGroup>+ );+ case "mcp":+ return (+ <SettingsGroup><McpConfigCard /></SettingsGroup>);@@ -335,7 +362,7 @@ export const SettingsPane = ({</button></div><div className="divide-y divide-slate-100 overflow-hidden rounded-2xl border border-slate-200 bg-card">- {tabItems.map((item) => {+ {mobileTabItems.map((item) => {const Icon = item.icon;return (<buttondiff --git a/apps/web/src/components/settings/PreferenceCard.test.mjs b/apps/web/src/components/settings/PreferenceCard.test.mjsindex 54d5fdc0..1876ed2e 100644--- a/apps/web/src/components/settings/PreferenceCard.test.mjs+++ b/apps/web/src/components/settings/PreferenceCard.test.mjs@@ -73,6 +73,24 @@ describe("paper editor themes", () => {});});+describe("settings information architecture", () => {+ test("groups general preferences and gives shortcuts and MCP their own navigation", () => {+ const preferenceCard = readFileSync(new URL("./PreferenceCard.tsx", import.meta.url), "utf8");+ const settingsPane = readFileSync(new URL("../SettingsPane.tsx", import.meta.url), "utf8");+ const shortcuts = readFileSync(new URL("./ShortcutSettingsItem.tsx", import.meta.url), "utf8");++ expect(preferenceCard).toContain('t("settings.groups.interface")');+ expect(preferenceCard).toContain('t("settings.groups.reading")');+ expect(preferenceCard).toContain('t("settings.groups.editing")');+ expect(preferenceCard).not.toContain("ShortcutSettingsItem");+ expect(settingsPane).toContain('t("settings.tabs.shortcuts")');+ expect(settingsPane).toContain('t("settings.tabs.mcp")');+ expect(settingsPane).toContain('item.key !== "shortcuts"');+ expect(shortcuts).not.toContain("Dialog");+ expect(shortcuts).toContain('t("shortcuts.reset")');+ });+});+describe("custom editor theme portability", () => {test("offers import and export while keeping contrast as a warning", () => {const dialog = readFileSync(new URL("./CustomEditorThemeDialog.tsx", import.meta.url), "utf8");diff --git a/apps/web/src/components/settings/PreferenceCard.tsx b/apps/web/src/components/settings/PreferenceCard.tsxindex 67587e66..7f7ecba5 100644--- a/apps/web/src/components/settings/PreferenceCard.tsx+++ b/apps/web/src/components/settings/PreferenceCard.tsx@@ -1,7 +1,7 @@import { AlignHorizontalJustifyCenter, AppWindow, BookOpenText, ChartNoAxesCombined, Image, Keyboard, Languages, MousePointerClick, Palette, Sparkles, SunMoon } from "lucide-react";-import { useState, useEffect } from "react";+import { useState, useEffect, type ReactNode } from "react";import { useTranslation } from "react-i18next";-import type { EditorContentAlignment, ShortcutSettings } from "@/lib/app-helpers";+import type { EditorContentAlignment } from "@/lib/app-helpers";import {EDITOR_LINK_OPEN_MODE_CHANGED_EVENT,getStoredEditorLinkOpenMode,@@ -20,13 +20,7 @@ import {} from "@/lib/ai-space-shortcut-preference";import { Button } from "@/components/ui/button";import { Input } from "@/components/ui/input";-import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";-import {- SETTINGS_CARD_HEADER_CLASSNAME,- SETTINGS_CARD_ICON_CLASSNAME,- SETTINGS_CARD_TITLE_CLASSNAME,- SETTINGS_ITEM_TITLE_CLASSNAME,-} from "./settings-ui";+import { SETTINGS_ITEM_TITLE_CLASSNAME } from "./settings-ui";import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";import { Switch } from "@/components/ui/switch";import {@@ -46,8 +40,16 @@ import {} from "@/lib/editor-body-font";import { applyUiFontPreference, readUiFontPreference, writeUiFontPreference } from "@/lib/ui-font";import { syncPublishedNoteBodyFont } from "@/lib/published-note-body-font";-import { ShortcutSettingsItem } from "./ShortcutSettingsItem";import { CustomEditorThemeDialog } from "./CustomEditorThemeDialog";++const PreferenceSection = ({ title, children }: { title: string; children: ReactNode }) => (+ <section className="grid gap-2">+ <h2 className="px-1 text-xs font-medium leading-5 text-slate-500">{title}</h2>+ <div className="divide-y divide-slate-100 overflow-hidden rounded-xl border border-slate-200 bg-card">+ {children}+ </div>+ </section>+);import {MERMAID_THEME_PREFERENCES,useAppearanceTheme,@@ -179,8 +181,6 @@ const FontChoiceFields = ({interface PreferenceCardProps {imageCompressionEnabled: boolean;onImageCompressionChange: (enabled: boolean) => void;- shortcutSettings: ShortcutSettings;- onShortcutSettingsChange: (settings: ShortcutSettings) => void;editorContentAlignment: EditorContentAlignment;onEditorContentAlignmentChange: (alignment: EditorContentAlignment) => void;}@@ -188,8 +188,6 @@ interface PreferenceCardProps {export const PreferenceCard = ({imageCompressionEnabled,onImageCompressionChange,- shortcutSettings,- onShortcutSettingsChange,editorContentAlignment,onEditorContentAlignmentChange,}: PreferenceCardProps) => {@@ -336,14 +334,8 @@ export const PreferenceCard = ({};return (- <Card className="w-full min-w-0 overflow-hidden shadow-none">- <CardHeader className={SETTINGS_CARD_HEADER_CLASSNAME}>- <CardTitle className={SETTINGS_CARD_TITLE_CLASSNAME}>- <Image className={SETTINGS_CARD_ICON_CLASSNAME} />- {t("settings.preferences")}- </CardTitle>- </CardHeader>- <CardContent className="divide-y divide-slate-100 p-0">+ <div className="grid gap-6">+ <PreferenceSection title={t("settings.groups.interface")}><div className="flex min-h-16 flex-col items-start gap-3 px-4 py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4"><div className="flex min-w-0 items-center gap-3"><Languages className="h-4 w-4 shrink-0 text-slate-500" />@@ -408,7 +400,9 @@ export const PreferenceCard = ({onChange={updateUiFont}/></div>+ </PreferenceSection>+ <PreferenceSection title={t("settings.groups.reading")}><div className="hidden min-h-16 flex-col items-start gap-3 px-4 py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4 lg:flex"><div className="flex min-w-0 items-center gap-3"><AlignHorizontalJustifyCenter className="h-4 w-4 shrink-0 text-slate-500" />@@ -486,7 +480,9 @@ export const PreferenceCard = ({</Select></div></div>+ </PreferenceSection>+ <PreferenceSection title={t("settings.groups.editing")}><div className="flex min-h-16 flex-col items-start gap-3 px-4 py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4"><div className="flex min-w-0 items-center gap-3"><Image className="h-4 w-4 shrink-0 text-slate-500" />@@ -561,14 +557,7 @@ export const PreferenceCard = ({/></div></div>-- <div className="hidden lg:block">- <ShortcutSettingsItem- shortcutSettings={shortcutSettings}- onShortcutSettingsChange={onShortcutSettingsChange}- />- </div>- </CardContent>+ </PreferenceSection>{!isMobile && editingTheme && (<CustomEditorThemeDialogopen={customThemeDialogOpen}@@ -579,6 +568,6 @@ export const PreferenceCard = ({isDefaultTheme={editingTheme.id === "custom-default"}/>)}- </Card>+ </div>);};diff --git a/apps/web/src/components/settings/ShortcutSettingsItem.tsx b/apps/web/src/components/settings/ShortcutSettingsItem.tsxindex b5ea038b..aaa2f05e 100644--- a/apps/web/src/components/settings/ShortcutSettingsItem.tsx+++ b/apps/web/src/components/settings/ShortcutSettingsItem.tsx@@ -1,5 +1,5 @@import { useEffect, useMemo, useRef, useState } from "react";-import { Keyboard, RotateCcw } from "lucide-react";+import { RotateCcw } from "lucide-react";import { useTranslation } from "react-i18next";import type { ShortcutAction, ShortcutBinding, ShortcutSettings } from "@/lib/app-helpers";import {@@ -10,18 +10,9 @@ import {shortcutBindingsEqual,} from "@/lib/app-helpers";import { Button } from "@/components/ui/button";-import {- Dialog,- DialogContent,- DialogDescription,- DialogFooter,- DialogHeader,- DialogTitle,-} from "@/components/ui/dialog";import { cn } from "@/lib/utils";import {SETTINGS_ITEM_DESCRIPTION_CLASSNAME,- SETTINGS_ITEM_ICON_CLASSNAME,SETTINGS_ITEM_TITLE_CLASSNAME,} from "./settings-ui";@@ -39,20 +30,11 @@ const getConflictAction = (export const ShortcutSettingsItem = ({ shortcutSettings, onShortcutSettingsChange }: ShortcutSettingsItemProps) => {const { t } = useTranslation();- const [shortcutsOpen, setShortcutsOpen] = useState(false);const [recordingAction, setRecordingAction] = useState<ShortcutAction | null>(null);const [captureMessage, setCaptureMessage] = useState("");const captureButtonRef = useRef<HTMLButtonElement | null>(null);const shortcutActionOptions = useMemo(() => getShortcutActionOptions(t), [t]);- const shortcutSummary = useMemo(- () =>- shortcutActionOptions.map((item) => formatShortcutBinding(shortcutSettings[item.value]))- .slice(0, 3)- .join(" / "),- [shortcutActionOptions, shortcutSettings]- );-useEffect(() => {if (!recordingAction) {return;@@ -107,80 +89,47 @@ export const ShortcutSettingsItem = ({ shortcutSettings, onShortcutSettingsChang};return (- <>- <div className="flex min-h-16 flex-col items-start gap-3 px-4 py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4">- <div className="flex min-w-0 items-start gap-3">- <Keyboard className={SETTINGS_ITEM_ICON_CLASSNAME} />- <div className="min-w-0">- <div className={SETTINGS_ITEM_TITLE_CLASSNAME}>{t("shortcuts.title")}</div>- <div className={cn(SETTINGS_ITEM_DESCRIPTION_CLASSNAME, "truncate")}>{shortcutSummary}</div>- </div>+ <div className="overflow-hidden rounded-xl border border-slate-200 bg-card">+ <div className="divide-y divide-slate-100">+ {shortcutActionOptions.map((item) => {+ const recording = recordingAction === item.value;++ return (+ <div+ key={item.value}+ className="flex min-h-16 flex-col items-start gap-3 px-4 py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4"+ >+ <div className="min-w-0">+ <div className={SETTINGS_ITEM_TITLE_CLASSNAME}>{item.label}</div>+ <div className={SETTINGS_ITEM_DESCRIPTION_CLASSNAME}>{item.description}</div>+ </div>+ <Button+ ref={recording ? captureButtonRef : null}+ type="button"+ variant={recording ? "solid" : "outline"}+ className={cn("h-9 w-full min-w-32 px-3 font-mono text-xs sm:w-auto", !recording && "bg-card")}+ onClick={() => {+ setRecordingAction(item.value);+ setCaptureMessage("");+ }}+ >+ {recording ? t("shortcuts.recording") : formatShortcutBinding(shortcutSettings[item.value])}+ </Button>+ </div>+ );+ })}+ </div>+ {captureMessage ? (+ <div className="border-t border-amber-200 bg-amber-50 px-4 py-2 text-xs font-medium text-amber-700">+ {captureMessage}</div>- <Button- size="sm"- variant="outline"- className="h-8 w-full bg-card px-3 text-xs sm:w-auto"- type="button"- onClick={() => setShortcutsOpen(true)}- >- {t("shortcuts.manage")}+ ) : null}+ <div className="flex justify-end border-t border-slate-100 px-4 py-3">+ <Button type="button" variant="outline" className="h-9 px-3 text-xs" onClick={handleResetShortcuts}>+ <RotateCcw className="h-4 w-4" />+ {t("shortcuts.reset")}</Button></div>-- <Dialog open={shortcutsOpen} onOpenChange={setShortcutsOpen}>- <DialogContent className="max-h-[min(640px,calc(100vh-2rem))] max-w-xl overflow-y-auto">- <DialogHeader>- <DialogTitle className="flex items-center gap-2">- <Keyboard className="h-5 w-5 text-slate-900" />- {t("shortcuts.title")}- </DialogTitle>- <DialogDescription>{t("shortcuts.description")}</DialogDescription>- </DialogHeader>-- <div className="grid gap-3">- {shortcutActionOptions.map((item) => {- const recording = recordingAction === item.value;-- return (- <div- key={item.value}- className="flex min-w-0 flex-col gap-3 rounded-lg border border-slate-200 bg-slate-50/60 p-3 sm:flex-row sm:items-center sm:justify-between"- >- <div className="min-w-0">- <div className={SETTINGS_ITEM_TITLE_CLASSNAME}>{item.label}</div>- <div className={SETTINGS_ITEM_DESCRIPTION_CLASSNAME}>{item.description}</div>- </div>- <Button- ref={recording ? captureButtonRef : null}- type="button"- variant={recording ? "solid" : "outline"}- className={cn("h-9 min-w-32 px-3 font-mono text-xs", !recording && "bg-card")}- onClick={() => {- setRecordingAction(item.value);- setCaptureMessage("");- }}- >- {recording ? t("shortcuts.recording") : formatShortcutBinding(shortcutSettings[item.value])}- </Button>- </div>- );- })}- </div>-- {captureMessage ? (- <div className="rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs font-medium text-amber-700">- {captureMessage}- </div>- ) : null}-- <DialogFooter>- <Button type="button" variant="outline" onClick={handleResetShortcuts}>- <RotateCcw className="h-4 w-4" />- {t("shortcuts.reset")}- </Button>- </DialogFooter>- </DialogContent>- </Dialog>- </>+ </div>);};diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.tsindex 0a05c491..2b128058 100644--- a/packages/shared/src/i18n/en-US.ts+++ b/packages/shared/src/i18n/en-US.ts@@ -741,8 +741,11 @@ export const enUS = {settings: {title: "Me",subtitle: "Preferences, system info, MCP tokens, and sign-in session",- preferences: "Preferences",- preferencesDescription: "Customize interface appearance, editor typography, and shortcut preferences.",+ groups: {+ interface: "Interface",+ reading: "Reading",+ editing: "Editing",+ },languageTitle: "Interface language",systemLanguage: "Follow system",imageCompressionTitle: "Compress note images",@@ -878,7 +881,9 @@ export const enUS = {themeToggleToLight: "Switch to light mode",tabs: {general: "General",+ shortcuts: "Shortcuts",ai: "AI Integrations",+ mcp: "MCP",data: "Import & Export",advanced: "Advanced",account: "Login Settings",diff --git a/packages/shared/src/i18n/ja.ts b/packages/shared/src/i18n/ja.tsindex 26515616..d8173068 100644--- a/packages/shared/src/i18n/ja.ts+++ b/packages/shared/src/i18n/ja.ts@@ -741,8 +741,11 @@ export const ja = {settings: {title: "マイ",subtitle: "設定、システム情報、MCP トークン、サインインセッション",- preferences: "設定",- preferencesDescription: "画面の見た目、エディタの書体、ショートカットの好みを調整します。",+ groups: {+ interface: "画面",+ reading: "閲覧",+ editing: "編集",+ },languageTitle: "表示言語",systemLanguage: "システムに合わせる",imageCompressionTitle: "ノート内の画像を圧縮",@@ -878,7 +881,9 @@ export const ja = {themeToggleToLight: "ライトモードに切り替え",tabs: {general: "一般",+ shortcuts: "ショートカット",ai: "AI 連携",+ mcp: "MCP",data: "インポートとエクスポート",advanced: "詳細",account: "ログイン設定",diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.tsindex 10cd6a00..2dba44cb 100644--- a/packages/shared/src/i18n/zh-CN.ts+++ b/packages/shared/src/i18n/zh-CN.ts@@ -741,8 +741,11 @@ export const zhCN = {settings: {title: "我的",subtitle: "个人偏好、系统信息、MCP Token 与登录会话",- preferences: "偏好设置",- preferencesDescription: "自定义界面显示、编辑器排版与快捷键操作偏好。",+ groups: {+ interface: "界面",+ reading: "阅读",+ editing: "编辑",+ },languageTitle: "界面语言",systemLanguage: "跟随系统",imageCompressionTitle: "压缩笔记内图片",@@ -878,7 +881,9 @@ export const zhCN = {themeToggleToLight: "切换到浅色模式",tabs: {general: "常规设置",+ shortcuts: "快捷键",ai: "AI集成",+ mcp: "MCP",data: "导入导出",advanced: "高级设置",account: "登录设置",