Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
ab27506
feat(edgeless): build a mind map with no editor, text measurement inj…
Nov 10, 2026
bb75335
fix(edgeless): bound a built mind map's text and wrap long words in l…
Nov 10, 2026
65767d7
chore(edgeless): regenerate the architecture map for the mind map bui…
Nov 10, 2026
b9b1c58
test(edgeless): read node boxes through the surface in the mind map p…
Nov 10, 2026
14cdacd
fix(edgeless): draw the canvas viewer under a strict content security…
Nov 10, 2026
78416b6
fix(edgeless): settle synced docs of named pages and follow only the …
Nov 10, 2026
13357b1
fix(blocks): keep emotion's rules out of a style element a strict pol…
Nov 10, 2026
70e5257
feat(edgeless): make the canvas viewer the editor itself, derived fro…
Nov 10, 2026
b3d0470
test(edgeless): paint the canvas viewer in a browser under a strict p…
Nov 10, 2026
aa0d642
fix(edgeless): viewer guard reads the mounted list, keys and clicks a…
Nov 10, 2026
50664cd
Merge remote-tracking branch 'origin/blocksuite-labre-main' into feat…
Nov 12, 2026
e97977c
chore(edgeless): regenerate the architecture map after the merge
Nov 12, 2026
d7f2d34
fix(database): read a malformed cell as its property default
Nov 12, 2026
a66a21c
fix(blocks): keep a fractional index key before its next neighbour
Nov 12, 2026
6d1f01e
feat(blocks): open the icon picker outside an editor from a public entry
Nov 12, 2026
6503e18
fix(blocks): keep the canvas selection when a table selects or clears
Nov 12, 2026
86eda11
fix(blocks): keep the start number of a numbered list on export
Nov 12, 2026
02a15cb
fix(edgeless): wrap a built mind map's text exactly as the editor does
Nov 12, 2026
730ca5b
test(edgeless): guard the mind map style colour past the palette
Nov 12, 2026
5247d70
feat(playground): build a mind map with no editor from the debug menu
Nov 12, 2026
918df2c
chore(playground): regenerate the architecture map for the mind map r…
Nov 12, 2026
ec83bf3
fix(edgeless): show a focused frame's title badge in the canvas viewer
Nov 12, 2026
b7952a6
test(edgeless): paint the canvas viewer under the site's own policy
Nov 12, 2026
4cb4426
docs: tell a host what a strict policy needs from the canvas viewer
Nov 12, 2026
9cb0812
feat(playground): open the document in the canvas viewer
Nov 12, 2026
f30fdd1
fix(blocks): flip the code toolbar wrap and line-number switches once
Nov 12, 2026
de965d5
fix(database): draw a blank select option as untitled
Nov 12, 2026
cfd83e2
test(edgeless): report the stage a framed canvas viewer stalls at
Nov 12, 2026
15c1284
fix(playground): keep the canvas viewer page's status off window.status
Nov 12, 2026
1020225
chore: refresh the architecture map for the canvas viewer
Nov 12, 2026
27ad2e4
fix(database): open a document row from a read-only desktop view
Nov 12, 2026
0256ac4
chore(database): refresh the architecture map for the tag label
Nov 12, 2026
4508572
fix(edgeless): ignore a pinch step whose fingers started on one point
Nov 12, 2026
73d8e84
fix(edgeless): name a frozen canvas view and repaint it when page fon…
Nov 12, 2026
d7d63f7
docs: say the canvas viewer repaints when the page's fonts load
Nov 12, 2026
56549a5
fix(blocks): keep a native modal dialog open when escape closes the i…
Nov 12, 2026
93d6697
fix(blocks): flip a menu toggle row once per click
Nov 12, 2026
ade058f
fix(blocks): bound the steps moving a fractional index key towards b
Nov 12, 2026
7d642d1
fix(blocks): write no list start past nine digits
Nov 12, 2026
c959280
fix(database): open a read-only kanban card from its cells
Nov 12, 2026
40f98a9
test(blocks): leave the column select-and-clear case to the unit spec
Nov 12, 2026
a1455f1
test(blocks): drop the words path from the code toggle unit spec
Nov 12, 2026
7e6fb0e
docs(edgeless): say why the export options menu rebuilds its rows
Nov 12, 2026
bab59d4
refactor(edgeless): carry the palette values in the library's theme
Nov 12, 2026
de28885
fix(blocks): keep the random postfix past the fractional index step b…
Nov 12, 2026
8004e3b
test(edgeless): drop a duplicate type check and a repeated comment
Nov 12, 2026
54a9907
fix(blocks): give a menu toggle row's focus back after a switch click
Nov 12, 2026
0069e9d
fix(blocks): give the library an emotion instance of its own
Nov 12, 2026
a140c46
fix(edgeless): deny the pages a canvas viewer is not given, free its …
Nov 12, 2026
c327fd2
docs: canvas viewer pages, host seams and emotion instance
Nov 12, 2026
4c08e54
fix(database): decide a kanban card's read-only open at the click
Nov 12, 2026
8c1aafa
fix(blocks): bound the last list number, not the start, on export
Nov 12, 2026
3e69def
chore: refresh the architecture map for the viewer's styles module
Nov 12, 2026
0179f24
docs(blocks): say why the fractional index fallback guard is required
Nov 12, 2026
3213bdc
fix(database): keep a read-only kanban card from opening a row twice
Nov 12, 2026
e6998e3
fix(edgeless): read the host's translation in the canvas viewer's own…
Nov 12, 2026
fe62de7
chore: refresh the architecture map after the viewer translation fix
Nov 12, 2026
aa5c39c
fix(playground): show the interactive canvas viewer across the whole …
Nov 12, 2026
54bf8cd
fix(page): store the outline type-icon switch's own value
Nov 12, 2026
c89de83
docs: record the unpushed host-session work and the browser-start fal…
Nov 12, 2026
bbb78fc
fix(database): read a malformed data-view cell as its column default
Nov 12, 2026
7385047
fix(blocks): refuse an oversized fractional index key with a named error
Nov 12, 2026
83af34d
fix(blocks): keep a shadow-held portal open on a click inside it
Nov 12, 2026
1982460
fix(blocks): count only list items when importing an html start number
Nov 12, 2026
33d8b68
fix(edgeless): cache a canvas character's width by the whole character
Nov 12, 2026
44335e0
docs(database): record the virtual table's missing row open button
Nov 12, 2026
09c9e1c
test(blocks): take every deep shadow query from the shared helper
Nov 12, 2026
b1c6ce3
feat(blocks): unify the emoji picker on the callout's emoji-mart picker
Nov 12, 2026
549b801
fix(blocks): write list markers in plain text
Nov 12, 2026
eb08a8e
fix(blocks): keep frequently used for every emoji picker after one wi…
Nov 12, 2026
945e2b0
fix(database): give a duplicated column its own option ids
Nov 12, 2026
1bc03d0
fix(edgeless): follow a middle click in the canvas viewer through its…
Nov 12, 2026
a49fc3f
fix(blocks): open no emoji picker on a read-only callout
Nov 12, 2026
e37de3f
fix(database): keep a rich-text cell stored as a string in a data-view
Nov 12, 2026
1367140
fix(database): keep a rich-text cell stored as a string
Nov 12, 2026
9d7d485
fix(blocks): name the fractional index stack overflow instead of boun…
Nov 12, 2026
47901a7
fix(blocks): separate copied blocks by a newline in plain text
Nov 12, 2026
d000e2c
fix(database): drag-to-fill a rich-text cell stored as a string
Nov 12, 2026
5e4f935
fix(blocks): name the fractional index overflow on firefox too
Nov 12, 2026
9b1226e
fix(edgeless): drop the canvas viewer's auxclick branch for other but…
Nov 12, 2026
de75035
refactor(blocks): move the list start number rule to affine-shared
Nov 12, 2026
66f812d
fix(blocks): copy the text alone from inside one list item
Nov 12, 2026
0de5685
Merge branch 'fix/fractional-index-between' into recette/2026-11-12
Nov 12, 2026
e5fcb33
Merge branch 'fix/list-export-start' into recette/2026-11-12
Nov 12, 2026
d1cb264
Merge branch 'fix/database-cell-default' into recette/2026-11-12
Nov 12, 2026
4163d80
Merge branch 'fix/select-tag-blank-name' into recette/2026-11-12
Nov 12, 2026
7fb6da6
Merge branch 'fix/database-readonly-row-open' into recette/2026-11-12
Nov 12, 2026
9d43478
Merge branch 'fix/table-selection-keeps-canvas' into recette/2026-11-12
Nov 12, 2026
2a56c1c
Merge branch 'fix/code-toggle-double' into recette/2026-11-12
Nov 12, 2026
1d2f5d2
Merge branch 'fix/menu-toggle-row' into recette/2026-11-12
Nov 12, 2026
91f4f67
Merge branch 'feat/icon-picker-standalone' into recette/2026-11-12
Nov 12, 2026
e4a9135
Merge branch 'feat/unified-emoji-picker' into recette/2026-11-12
Nov 12, 2026
08aa090
Merge branch 'feat/mindmap-headless-builder' into recette/2026-11-12
Nov 12, 2026
babac7d
Merge branch 'feat/canvas-viewer-editor' into recette/2026-11-12
Nov 12, 2026
3235c76
Merge branch 'fix/data-view-cell-default' into recette/2026-11-12
Nov 12, 2026
5bb7118
Merge branch 'fix/database-duplicate-property-options' into recette/2…
Nov 12, 2026
3586ae2
Merge branch 'fix/outline-setting-toggle' into recette/2026-11-12
Nov 12, 2026
4f5d947
Merge branch 'fix/portal-click-away-composed' into recette/2026-11-12
Nov 12, 2026
bff0877
Merge branch 'fix/text-char-width-codepoint' into recette/2026-11-12
Nov 12, 2026
e2c578e
Merge branch 'fix/list-html-import-order' into recette/2026-11-12
Nov 12, 2026
406824a
Merge branch 'fix/plain-text-list-markers' into recette/2026-11-12
Nov 12, 2026
d1d7c97
Merge branch 'fix/plain-text-block-separator' into recette/2026-11-12
Nov 12, 2026
a94136b
Merge branch 'docs/lessons-3-5-0' into recette/2026-11-12
Nov 12, 2026
bbbfb00
chore: refresh the architecture map for the recette merge
Nov 12, 2026
7cb87b5
chore(blocks): drop the switch click stop the toggle fix made redundant
Nov 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor(edgeless): carry the palette values in the library's theme
The editor-free entries now load zod only. The model's theme read
@toeverything/theme/v2 at run time for getColorByKey, pureBlack and
pureWhite, which put the package in every headless graph once the mind map
styles joined @labre/affine-model/headless. The product owner chose not to
allow it.

themes/palette-values.ts holds the 33 palette entries the theme reads, valued
as getColorByKey valued them, and imports types only. palette-values.unit.spec.ts
holds each entry to the package and the key list to default.ts, so a theme
bump that would move a stored colour fails there. DefaultTheme and Themes are
deep-equal before and after: no stored colour changes.

The interchange-headless guard drops the package from its allow-list and
refuses it by name. ADR 0045: the 2026-11-10 amendment no longer widens the
list; a 2026-11-12 amendment records the copy (red zone, stored format
unchanged).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • Loading branch information
r and claude committed Nov 12, 2026
commit bab59d4b13fafe4cb217fb0557b1fcd8a8024210
4 changes: 2 additions & 2 deletions architecture/code.c4
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ model {
link https://github.com/formicoidea/blocksuite-labre/tree/blocksuite-labre-main/packages/affine/model
metadata {
path 'packages/affine/model'
files '152'
files '153'
}
blocks = folder 'blocks/' {
link https://github.com/formicoidea/blocksuite-labre/tree/blocksuite-labre-main/packages/affine/model/src/blocks
Expand Down Expand Up @@ -332,7 +332,7 @@ model {
link https://github.com/formicoidea/blocksuite-labre/tree/blocksuite-labre-main/packages/affine/model/src/themes
metadata {
path 'packages/affine/model/src/themes'
files '5'
files '6'
}
}
utils = folder 'utils/' {
Expand Down
45 changes: 39 additions & 6 deletions docs/adr/0045-headless-toolbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ and Event Storming follow on the same entry.
## Amended 2026-11-10 — the mind map: a builder with the measure injected

**Not a red zone for the stored format** (no schema, no stored field, no enum
value: the builder writes the props the toolbar's mind map already writes), but
it **widens the allow-list** of `interchange-headless.unit.spec.ts`, which
asks for the maintainer's approval like the amendment above. Issue #662.
value: the builder writes the props the toolbar's mind map already writes). The
allow-list of `interchange-headless.unit.spec.ts` stays `zod` (amendment of
2026-11-12 below). Issue #662.

The mind map was left out above because its layout needs text measurement. It
is the last canvas tool a host with no editor cannot place (the Labre
Expand Down Expand Up @@ -182,9 +182,9 @@ options)`. It returns one `shape` per node, in tree order, with the style
editor's `MindmapNode` satisfies; its algorithm is unchanged.
4. `style.ts` loads no lodash (`applyNodeStyle` moves to `apply-style.ts`,
still on the model index), and joins `@labre/affine-model/headless`. Its
colours come from the theme tokens, so `@toeverything/theme` (data only,
aliased by a host to its own theme) joins `zod` in the allow-list: a
builder must store the colours the toolbar stores.
colours come from the model's theme, so a builder stores the colours the
toolbar stores; that theme carries its own palette values (amendment of
2026-11-12 below).
5. `materializeInterchangeImport` rewrites a `mindmap`'s `children` keys and
their `parent` onto the minted ids, as it rewrites a group's `children`.
6. Two copies, each held to its original: `wrapMindmapText` is `wrapText`
Expand All @@ -201,3 +201,36 @@ options)`. It returns one `shape` per node, in tree order, with the style
Not done: the branches are local connectors the view draws from the tree, so a
host that previews a built map draws them itself; collapsed nodes; reading
`.mm` or `.opml` with no editor (a reader could sit on this builder).

## Amended 2026-11-12 — the library's theme carries its palette values

**Touches `packages/affine/model` (red zone) without changing the stored
format**: `DefaultTheme` is deep-equal before and after, so every colour the
editor writes into a document is the colour it wrote before.

With the mind map styles in `@labre/affine-model/headless`, the editor-free
graph reached `themes/utils.ts`, which read `@toeverything/theme/v2` at run
time for `getColorByKey` and `pureBlack` / `pureWhite`: the only third-party
package besides `zod` in that graph. The product owner chose not to widen the
allow-list for it.

Decided:

1. `model/src/themes/palette-values.ts` holds the palette entries the theme
reads (the keys `default.ts` passes to `getColorByKey`, plus the black and
white `pureBlack` and `pureWhite` read), valued as `getColorByKey` valued
them: one colour when the dark and light themes agree, `{ dark, light }`
when they do not. It imports types only. `getColorByKey`, `pureBlack` and
`pureWhite` read it, and nothing in `model/src` imports the package at run
time any more.
2. A deliberate copy, held by a parity: `palette-values.unit.spec.ts` checks
every entry against `@toeverything/theme/v2` (a test may import it), and
the key list against `default.ts`. A bump of the package that would change
a stored colour fails there; moving the colour becomes an edit of the copy,
that is a decision.
3. The editor-free entries load `zod` and the workspace sources only;
`interchange-headless.unit.spec.ts` refuses `@toeverything/theme` by name.

Consequences: `@toeverything/theme` stays a dependency of the model (its
parity spec) and of the editor packages that read its CSS variables; nothing
changes for a host.
4 changes: 4 additions & 0 deletions docs/integrate/06-build-tooling.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,8 @@ const elements = buildMindmap(
The branches are drawn by the editor from the tree, never stored: a host that
previews a built map draws them itself.

Like the framework entries, this one loads `zod` and nothing else from outside
the library: the mind map styles' colours come from the library's theme, which
carries its own copy of the palette (ADR 0045, amendment of 2026-11-12).

Next: [07-upgrade.md](07-upgrade.md).
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ const ALLOWED_WORKSPACE = [
*/
const ALLOWED_THIRD_PARTY = new Set([
'zod',
// The theme tokens, data only: the mind map styles' colours are read from
// them, and a builder must store the colours the toolbar stores (ADR 0045
// amendment of 2026-11-10). A host may alias it to its own theme.
'@toeverything/theme',
// Not `@toeverything/theme`: the model's theme reads its palette from its
// own copy (`themes/palette-values.ts`, held to the package by
// `palette-values.unit.spec.ts`), so the mind map styles, which a builder
// must store as the toolbar does, bring no theme package in (ADR 0045,
// amendment of 2026-11-12).
]);

/** DOM globals a reader must not touch: a server has none of them. */
Expand Down Expand Up @@ -219,6 +220,12 @@ describe('the headless interchange entries', () => {
/packages\/framework\/(?:std|store|sync)\//.test(path)
)
).toEqual([]);
// Nor the AFFiNE theme package, which the model's theme once loaded for
// its palette (ADR 0045, amendment of 2026-11-12): matches
// `node_modules/@toeverything/theme/dist/v2/index.js`, not `zod`.
expect(
modules.filter(path => /node_modules\/@toeverything\//.test(path))
).toEqual([]);
// And no DOM by name, in any module that made it in: the readers are
// pure in ADR 0012's amended sense, with no DOM and no editor.
expect(DOM_GLOBALS.exec(code)?.[0]).toBeUndefined();
Expand Down
79 changes: 79 additions & 0 deletions packages/affine/model/src/__tests__/palette-values.unit.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/// <reference types="vite/client" />
import {
type AffineThemeKeyV2,
darkThemeV2,
lightThemeV2,
} from '@toeverything/theme/v2';
import { describe, expect, test } from 'vitest';

import { DefaultTheme } from '../themes/default.js';
import { PALETTE_VALUES } from '../themes/palette-values.js';
import { getColorByKey, pureBlack, pureWhite } from '../themes/utils.js';

/**
* PARITY — the library's copy of the AFFiNE palette is the palette
* `@toeverything/theme/v2` ships (ADR 0045, amendment of 2026-11-12).
*
* Why the copy exists: `themes/default.ts` is in the graph of every
* editor-free entry (`@labre/affine-model/headless`, the `./interchange`
* builders, the mind map's among them), and those entries load `zod` and
* `@labre/global` only (`interchange-headless.unit.spec.ts`). So the theme
* reads its colours from `palette-values.ts`, not from the package.
*
* What this spec catches: a bump of `@toeverything/theme` that changes one of
* these colours. They are written into documents (a shape's fill, a note's
* background, a mind map node's stroke), so a silent change would make the
* editor write a colour the copy no longer agrees with. Decide then whether
* the stored colour moves (update the copy) or stays (keep it); either way,
* this spec makes it a decision. It also catches a key `default.ts` starts
* reading without a value here, and a value nobody reads any more.
*/
const fromPackage = (key: AffineThemeKeyV2) => {
const dark = darkThemeV2[key];
const light = lightThemeV2[key];
return dark === light ? dark : { dark, light };
};

const keys = Object.keys(PALETTE_VALUES) as (keyof typeof PALETTE_VALUES)[];

describe('the palette copy', () => {
test.each(keys)('%s is the package’s value', key => {
expect(PALETTE_VALUES[key]).toEqual(fromPackage(key));
expect(getColorByKey(key)).toEqual(fromPackage(key));
});

test('pure black and white are the light palette’s', () => {
expect(pureBlack).toBe(lightThemeV2['edgeless/palette/black']);
expect(pureWhite).toBe(lightThemeV2['edgeless/palette/white']);
});

test('holds exactly the keys the theme reads', () => {
// Read as text (table-writing-width.unit.spec.ts does the same).
const source =
Object.values(
import.meta.glob<string>('../themes/default.ts', {
query: '?raw',
import: 'default',
eager: true,
})
)[0] ?? '';
expect(source).not.toBe('');
// A literal key passed to getColorByKey: matches
// `getColorByKey('edgeless/note/red')`, not `getColorByKey(key)`.
const read = new Set(
[...source.matchAll(/getColorByKey\('([^']+)'\)/g)].map(m => m[1])
);
// `pureBlack` and `pureWhite` read these two (`utils.ts`).
read.add('edgeless/palette/black');
read.add('edgeless/palette/white');
expect([...read].sort()).toEqual([...keys].sort());
});

test('the default theme reads its colours from the copy', () => {
expect(DefaultTheme.black).toEqual(fromPackage('edgeless/palette/black'));
expect(DefaultTheme.white).toEqual(fromPackage('edgeless/palette/white'));
expect(DefaultTheme.NoteBackgroundColorMap.Yellow).toEqual(
fromPackage('edgeless/note/yellow')
);
});
});
5 changes: 3 additions & 2 deletions packages/affine/model/src/headless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
* the drag-and-drop adapter): the headless `./interchange` entries of the
* framework bundles. Held by `interchange-headless.unit.spec.ts` in
* `packages/affine/all`. Add only from files that import nothing but
* `@labre/global`, `zod`, the theme tokens (`@toeverything/theme`, data only)
* and types.
* `@labre/global`, `zod` and types. Not `@toeverything/theme`: the theme reads
* its palette from its own copy, `themes/palette-values.ts` (ADR 0045,
* amendment of 2026-11-12).
*/
export * from './consts/index.js';
export * from './elements/bpmn/consts.js';
Expand Down
55 changes: 55 additions & 0 deletions packages/affine/model/src/themes/palette-values.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import type { Color } from './color';

/**
* The palette the library's theme is built from (`default.ts`), by AFFiNE
* theme key, valued as `@toeverything/theme/v2` values them: one colour when
* the dark and light themes agree, `{ dark, light }` when they do not.
*
* A copy, on purpose (ADR 0045, amendment of 2026-11-12): `default.ts` is in
* the graph of every editor-free entry (`@labre/affine-model/headless`, the
* `./interchange` builders), and those entries load `zod` and
* `@labre/global` only. These values are written into documents (a shape's
* fill, a note's background), so they must not move when the theme package
* does: `palette-values.unit.spec.ts` holds every entry to the package, and a
* bump that changes one fails there before it changes a stored colour.
*
* Only the keys the theme reads; add one here, and its value, when
* `default.ts` starts reading it (the spec checks both lists agree).
*/
export const PALETTE_VALUES = {
'edgeless/palette/white': { dark: '#000000', light: '#ffffff' },
'edgeless/palette/black': { dark: '#ffffff', light: '#000000' },
'edgeless/palette/light/redLight': '#fce5e6',
'edgeless/palette/light/orangeLight': '#ffebd5',
'edgeless/palette/light/yellowLight': '#fffbd5',
'edgeless/palette/light/greenLight': '#f1fdf4',
'edgeless/palette/light/blueLight': '#e6f5ff',
'edgeless/palette/light/purpleLight': { dark: '#d7cdff', light: '#ede9ff' },
'edgeless/palette/light/magentaLight': '#ffecf6',
'edgeless/palette/light/greyLight': '#e6e6e6',
'edgeless/palette/medium/redMedium': '#fb7081',
'edgeless/palette/medium/orangeMedium': '#ff8c38',
'edgeless/palette/medium/yellowMedium': '#fcd34d',
'edgeless/palette/medium/greenMedium': '#3cbc36',
'edgeless/palette/medium/blueMedium': '#84cfff',
'edgeless/palette/medium/purpleMedium': '#6e52df',
'edgeless/palette/medium/magentaMedium': '#e96cab',
'edgeless/palette/medium/greyMedium': '#929292',
'edgeless/palette/heavy/red': '#761717',
'edgeless/palette/heavy/orange': '#b55309',
'edgeless/palette/heavy/yellow': '#ac7400',
'edgeless/palette/heavy/green': '#447756',
'edgeless/palette/heavy/blue': '#1c70a5',
'edgeless/palette/heavy/purple': '#5a21b6',
'edgeless/palette/heavy/magenta': '#941555',
'edgeless/note/red': { dark: '#460606', light: '#fbb7b7' },
'edgeless/note/orange': { dark: '#843b06', light: '#ffc58f' },
'edgeless/note/yellow': { dark: '#704200', light: '#fde68a' },
'edgeless/note/green': { dark: '#3b5315', light: '#c9f8c1' },
'edgeless/note/blue': { dark: '#004b7b', light: '#ceecff' },
'edgeless/note/purple': { dark: '#312e81', light: '#ddd6fe' },
'edgeless/note/magenta': { dark: '#5f0a35', light: '#ffdaed' },
'edgeless/note/white': { dark: '#252525', light: '#ffffff' },
} as const satisfies Record<string, Color>;

export type PaletteKey = keyof typeof PALETTE_VALUES;
22 changes: 9 additions & 13 deletions packages/affine/model/src/themes/utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import {
type AffineThemeKeyV2,
darkThemeV2,
lightThemeV2,
} from '@toeverything/theme/v2';

import type { Color } from './color';
import { PALETTE_VALUES, type PaletteKey } from './palette-values';
import type { Palette } from './types';

// Converts a color map to color list.
Expand All @@ -18,12 +13,13 @@ export function buildPalettes(
}));
}

export function getColorByKey(key: AffineThemeKeyV2): Color {
const dark = darkThemeV2[key];
const light = lightThemeV2[key];
if (dark === light) return dark;
return { dark, light };
// Read from the library's own copy of the palette, not from
// `@toeverything/theme`: this file is in every editor-free graph (ADR 0045,
// amendment of 2026-11-12). A fresh object per call, as before the copy.
export function getColorByKey(key: PaletteKey): Color {
const value: Color = PALETTE_VALUES[key];
return typeof value === 'string' ? value : { ...value };
}

export const pureBlack = lightThemeV2['edgeless/palette/black'];
export const pureWhite = lightThemeV2['edgeless/palette/white'];
export const pureBlack = PALETTE_VALUES['edgeless/palette/black'].light;
export const pureWhite = PALETTE_VALUES['edgeless/palette/white'].light;