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
feat(diagram): offer ten flowchart color schemes
tianma-ifb55e81713b05
diff --git a/apps/web/src/components/DiagramEditorPane.test.mjs b/apps/web/src/components/DiagramEditorPane.test.mjsindex df728039..be88b6e2 100644--- a/apps/web/src/components/DiagramEditorPane.test.mjs+++ b/apps/web/src/components/DiagramEditorPane.test.mjs@@ -175,7 +175,7 @@ describe("diagram editor canvas surface", () => {expect(source).toContain('themeCatalog={document.kind === "flowchart" ? "flowchart" : "mind-map"}');expect(toolbarSource).toContain("showTheme = true");expect(toolbarSource).toContain("themeCatalog = \"mind-map\"");- expect(toolbarSource).toContain("FLOWCHART_SELECTABLE_THEMES");+ expect(toolbarSource).toContain("FLOWCHART_THEME_GROUPS");expect(toolbarSource).toContain("flowchartThemeSwatches");expect(source).toContain("maxScale: policy.maxScale");expect(source).not.toContain("minScale: policy.minScale");diff --git a/apps/web/src/components/DiagramToolbar.tsx b/apps/web/src/components/DiagramToolbar.tsxindex 928d33dd..143407dc 100644--- a/apps/web/src/components/DiagramToolbar.tsx+++ b/apps/web/src/components/DiagramToolbar.tsx@@ -19,7 +19,7 @@ import {DIAGRAM_SELECTABLE_STRUCTURES,DIAGRAM_STRUCTURE_GROUPS,DIAGRAM_THEME_GROUPS,- FLOWCHART_SELECTABLE_THEMES,+ FLOWCHART_THEME_GROUPS,diagramThemeSwatches,flowchartThemeSwatches,resolveDiagramTheme,@@ -286,36 +286,24 @@ export const DiagramToolbar = ({</TooltipTrigger><TooltipContent>{t("diagram.theme")}</TooltipContent></Tooltip>- <DropdownMenuContent align="start" className="w-[18.5rem] p-3">- {themeCatalog === "flowchart" ? (- <div className="grid grid-cols-1 gap-1.5">- {FLOWCHART_SELECTABLE_THEMES.map((value) => (- <DropdownMenuItem- key={value}- className={cn("h-auto items-center gap-3 rounded-lg border px-2 py-1.5", resolveFlowchartTheme(theme) === value ? "border-slate-900 bg-slate-50" : "border-transparent")}- onSelect={() => onThemeChange(value)}- >- <span className="flex h-5 flex-1 overflow-hidden rounded-md border border-black/10">- {flowchartThemeSwatches(value).map((color) => (- <span key={`${value}-${color}`} className="h-full flex-1" style={{ background: color }} />- ))}- </span>- <span className="w-10 shrink-0 text-xs text-slate-600">{t(`diagram.theme${value.charAt(0).toUpperCase()}${value.slice(1)}` as "diagram.themeBrand")}</span>- </DropdownMenuItem>- ))}- </div>- ) : (["vivid", "classic"] as const).map((group) => (+ <DropdownMenuContent align="start" className="max-h-[min(36rem,70vh)] w-[18.5rem] overflow-y-auto p-3">+ {(["vivid", "classic"] as const).map((group) => (<div key={group} className="mb-3 last:mb-0"><div className="mb-1.5 text-xs font-medium text-slate-500">{t(group === "vivid" ? "diagram.themeGroupVivid" : "diagram.themeGroupClassic")}</div><div className="grid grid-cols-1 gap-1.5">- {DIAGRAM_THEME_GROUPS[group].map((value) => (+ {(themeCatalog === "flowchart" ? FLOWCHART_THEME_GROUPS[group] : DIAGRAM_THEME_GROUPS[group]).map((value) => (<DropdownMenuItemkey={value}- className={cn("h-auto items-center gap-3 rounded-lg border px-2 py-1.5", theme === value ? "border-slate-900 bg-slate-50" : "border-transparent")}+ className={cn(+ "h-auto items-center gap-3 rounded-lg border px-2 py-1.5",+ (themeCatalog === "flowchart" ? resolveFlowchartTheme(theme) === value : theme === value)+ ? "border-slate-900 bg-slate-50"+ : "border-transparent",+ )}onSelect={() => onThemeChange(value)}><span className="flex h-5 flex-1 overflow-hidden rounded-md border border-black/10">- {diagramThemeSwatches(value).map((color) => (+ {(themeCatalog === "flowchart" ? flowchartThemeSwatches(value) : diagramThemeSwatches(value)).map((color) => (<span key={`${value}-${color}`} className="h-full flex-1" style={{ background: color }} />))}</span>diff --git a/packages/shared/src/diagram-flowchart-style.test.mjs b/packages/shared/src/diagram-flowchart-style.test.mjsindex 63d5d4a4..4871cb10 100644--- a/packages/shared/src/diagram-flowchart-style.test.mjs+++ b/packages/shared/src/diagram-flowchart-style.test.mjs@@ -4,6 +4,7 @@ import {FLOWCHART_READABLE_MIN_SCALE,FLOWCHART_SELECTABLE_THEMES,FLOWCHART_SURFACES,+ FLOWCHART_THEME_GROUPS,flowchartEdgeIsStraight,flowchartEdgePorts,flowchartFitsReadableViewport,@@ -29,7 +30,7 @@ const contrast = (foreground, background) => {describe("flowchart semantic paint", () => {test("keeps process, decision, and terminator visually distinct", () => {- for (const theme of ["brand", "ink", "paper"]) {+ for (const theme of FLOWCHART_SELECTABLE_THEMES) {for (const appearance of ["light", "dark"]) {const surface = resolveFlowchartSurface(appearance, theme);expect(surface.process.fill).not.toBe(surface.decision.fill);@@ -41,7 +42,7 @@ describe("flowchart semantic paint", () => {});test("keeps node labels readable on their fills", () => {- for (const theme of ["brand", "ink", "paper"]) {+ for (const theme of FLOWCHART_SELECTABLE_THEMES) {for (const appearance of ["light", "dark"]) {const surface = FLOWCHART_SURFACES[theme][appearance];for (const paint of [surface.process, surface.decision, surface.terminator]) {@@ -58,18 +59,17 @@ describe("flowchart semantic paint", () => {expect(visual.label.fontFamily).toContain("Inter");});- test("offers three quiet surfaces and maps unknown themes to forest", () => {- expect(FLOWCHART_SELECTABLE_THEMES).toEqual(["brand", "ink", "paper"]);- expect(resolveFlowchartTheme("mint")).toBe("brand");- expect(resolveFlowchartTheme("classic")).toBe("brand");+ test("offers ten flowchart surfaces and maps leftover ids onto them", () => {+ expect(FLOWCHART_SELECTABLE_THEMES).toHaveLength(10);+ expect([...FLOWCHART_THEME_GROUPS.classic, ...FLOWCHART_THEME_GROUPS.vivid]).toEqual([...FLOWCHART_SELECTABLE_THEMES]);+ expect(resolveFlowchartTheme("mint")).toBe("mint");+ expect(resolveFlowchartTheme("classic")).toBe("paper");+ expect(resolveFlowchartTheme("naive")).toBe("brand");expect(FLOWCHART_SURFACES.brand.light.terminator.stroke).toBe("#16A06E");- expect(resolveFlowchartSurface("light", "mint")).toEqual(FLOWCHART_SURFACES.brand.light);+ expect(new Set(FLOWCHART_SELECTABLE_THEMES.map((theme) => FLOWCHART_SURFACES[theme].light.terminator.stroke)).size).toBe(10);expect(resolveFlowchartSurface("light", "ink").terminator.stroke).toBe("#3A4656");expect(resolveFlowchartSurface("light", "paper").canvas).toBe("#F6F1E8");- expect(resolveFlowchartSurface("light", "ink").decision.fill)- .not.toBe(resolveFlowchartSurface("light", "brand").decision.fill);- expect(resolveFlowchartSurface("light", "paper").terminator.stroke)- .not.toBe(resolveFlowchartSurface("light", "brand").terminator.stroke);+ expect(resolveFlowchartSurface("light", "mint").terminator.stroke).toBe("#1A7A70");});});diff --git a/packages/shared/src/diagram-flowchart-style.ts b/packages/shared/src/diagram-flowchart-style.tsindex 2fc00ab1..843315ae 100644--- a/packages/shared/src/diagram-flowchart-style.ts+++ b/packages/shared/src/diagram-flowchart-style.ts@@ -63,8 +63,14 @@ export const flowchartFitsReadableViewport = (};export type FlowchartAppearance = "light" | "dark";-export const FLOWCHART_SELECTABLE_THEMES = ["brand", "ink", "paper"] as const;+export const FLOWCHART_SELECTABLE_THEMES = [+ "brand", "ink", "paper", "island", "tea", "cosmos", "sun", "wa", "rose", "mint",+] as const;export type FlowchartTheme = (typeof FLOWCHART_SELECTABLE_THEMES)[number];+export const FLOWCHART_THEME_GROUPS = {+ classic: ["brand", "ink", "paper", "island", "tea", "cosmos"],+ vivid: ["sun", "wa", "rose", "mint"],+} as const;export type FlowchartShapePaint = {fill: string;@@ -82,8 +88,14 @@ export type FlowchartSurface = {const FLOWCHART_THEME_ALIASES: Partial<Record<DiagramTheme, FlowchartTheme>> = {ocean: "brand",- ink: "ink",- paper: "paper",+ slate: "ink",+ mono: "ink",+ classic: "paper",+ sand: "island",+ sky: "cosmos",+ sunset: "sun",+ violet: "rose",+ aurora: "mint",};export const resolveFlowchartTheme = (theme?: DiagramTheme): FlowchartTheme => {@@ -140,6 +152,118 @@ export const FLOWCHART_SURFACES: Record<FlowchartTheme, Record<FlowchartAppearanterminator: { fill: "#2A2118", stroke: "#C4A07A", text: "#F0E4D4" },},},+ island: {+ light: {+ canvas: "#F6EEE8",+ edge: "#8A6550",+ process: { fill: "#FFF8F3", stroke: "#C4A090", text: "#3A2A22" },+ decision: { fill: "#F3D8C8", stroke: "#C46A48", text: "#6A3220" },+ terminator: { fill: "#EBD0C0", stroke: "#8B4A32", text: "#3F2418" },+ },+ dark: {+ canvas: "#161210",+ edge: "#C4A082",+ process: { fill: "#231C18", stroke: "#8A6A56", text: "#F3E8E0" },+ decision: { fill: "#2C2018", stroke: "#D49070", text: "#F6D8C4" },+ terminator: { fill: "#281A16", stroke: "#C48868", text: "#F0D8CC" },+ },+ },+ tea: {+ light: {+ canvas: "#F4F6EE",+ edge: "#6A7A52",+ process: { fill: "#FFFFFF", stroke: "#8A9A72", text: "#2A3420" },+ decision: { fill: "#E8EED4", stroke: "#8A9A48", text: "#3F4A18" },+ terminator: { fill: "#DCE6C8", stroke: "#4F6A32", text: "#243018" },+ },+ dark: {+ canvas: "#121410",+ edge: "#A0B07A",+ process: { fill: "#1C2018", stroke: "#6A7A56", text: "#E8F0DC" },+ decision: { fill: "#222618", stroke: "#B8C46A", text: "#E8F0C4" },+ terminator: { fill: "#1A2418", stroke: "#8AAA5A", text: "#D8E8C4" },+ },+ },+ cosmos: {+ light: {+ canvas: "#F2F5F8",+ edge: "#4D6F8A",+ process: { fill: "#FFFFFF", stroke: "#7A94A8", text: "#1C2A38" },+ decision: { fill: "#E4EEF5", stroke: "#5A82A0", text: "#1E3A52" },+ terminator: { fill: "#D8E6F0", stroke: "#2A5470", text: "#163044" },+ },+ dark: {+ canvas: "#101218",+ edge: "#7AA0C0",+ process: { fill: "#181E26", stroke: "#5A7088", text: "#E0E8F0" },+ decision: { fill: "#1C2834", stroke: "#7AA0C0", text: "#D0E4F4" },+ terminator: { fill: "#162028", stroke: "#8AB4D0", text: "#D8E8F4" },+ },+ },+ sun: {+ light: {+ canvas: "#F8F6EC",+ edge: "#C4A030",+ process: { fill: "#FFFEF6", stroke: "#D4C47A", text: "#3A3418" },+ decision: { fill: "#FFF0C4", stroke: "#E0B040", text: "#6A4A08" },+ terminator: { fill: "#F8E8B0", stroke: "#C09020", text: "#4A3808" },+ },+ dark: {+ canvas: "#16140C",+ edge: "#E0C060",+ process: { fill: "#242018", stroke: "#8A7A48", text: "#F6F0D8" },+ decision: { fill: "#2C2410", stroke: "#E0B848", text: "#F8E8B8" },+ terminator: { fill: "#28240C", stroke: "#D4B040", text: "#F4E8C0" },+ },+ },+ wa: {+ light: {+ canvas: "#F4F7F9",+ edge: "#4A7AA0",+ process: { fill: "#FFFFFF", stroke: "#8AA8C0", text: "#1C2C3A" },+ decision: { fill: "#FCE8DC", stroke: "#E09070", text: "#7A3A24" },+ terminator: { fill: "#DCE8F4", stroke: "#2A5A88", text: "#1A3858" },+ },+ dark: {+ canvas: "#101418",+ edge: "#7AA8C8",+ process: { fill: "#182028", stroke: "#5A7088", text: "#E0E8F0" },+ decision: { fill: "#2C2018", stroke: "#E0A080", text: "#F8DCC8" },+ terminator: { fill: "#162030", stroke: "#6A98C0", text: "#D4E4F4" },+ },+ },+ rose: {+ light: {+ canvas: "#F8F3F5",+ edge: "#A06078",+ process: { fill: "#FFFFFF", stroke: "#C49AAC", text: "#3A2430" },+ decision: { fill: "#F8E4EC", stroke: "#D0809A", text: "#7A3048" },+ terminator: { fill: "#F0D8E2", stroke: "#A04060", text: "#4A2030" },+ },+ dark: {+ canvas: "#161014",+ edge: "#D0809A",+ process: { fill: "#24181C", stroke: "#8A5A6A", text: "#F4E4EA" },+ decision: { fill: "#2C1A22", stroke: "#E090A8", text: "#F8D8E4" },+ terminator: { fill: "#28141C", stroke: "#E07090", text: "#F4D0DC" },+ },+ },+ mint: {+ light: {+ canvas: "#F2F8F7",+ edge: "#3A8A82",+ process: { fill: "#FFFFFF", stroke: "#7AB0A8", text: "#1C3A38" },+ decision: { fill: "#E4F4F0", stroke: "#4AA89A", text: "#1A5A52" },+ terminator: { fill: "#D4EEE8", stroke: "#1A7A70", text: "#145048" },+ },+ dark: {+ canvas: "#101614",+ edge: "#6AB8AC",+ process: { fill: "#182422", stroke: "#4A786E", text: "#DCF0EC" },+ decision: { fill: "#1A2C28", stroke: "#6AC4B4", text: "#D0F0E8" },+ terminator: { fill: "#162824", stroke: "#5AB8A8", text: "#D0EEE6" },+ },+ },};export const resolveFlowchartSurface = (diff --git a/packages/shared/src/diagram.test.mjs b/packages/shared/src/diagram.test.mjsindex 2944842c..09d190ed 100644--- a/packages/shared/src/diagram.test.mjs+++ b/packages/shared/src/diagram.test.mjs@@ -79,7 +79,10 @@ describe("diagram document", () => {expect(diagramDocumentToMermaid(paper)).toContain("classDef flowTerminator fill:#F0E4D0,stroke:#7A5230");const mint = createDefaultDiagramDocument("flowchart");mint.theme = "mint";- expect(diagramDocumentToMermaid(mint)).toContain("classDef flowProcess fill:#FFFFFF,stroke:#6F9B88");+ expect(diagramDocumentToMermaid(mint)).toContain("classDef flowTerminator fill:#D4EEE8,stroke:#1A7A70");+ const naive = createDefaultDiagramDocument("flowchart");+ naive.theme = "naive";+ expect(diagramDocumentToMermaid(naive)).toContain("classDef flowProcess fill:#FFFFFF,stroke:#6F9B88");const doc = markdownToDoc(markdown);expect(doc.content?.some((node) => node.type === "codeBlock" && node.attrs?.language === "mermaid")).toBe(true);