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
fix(edgeless): name a frozen canvas view and repaint it when page fon…
…ts load

A frozen view is a button; with no title it had no accessible name. It is
now named by com.labre.canvas-viewer.open-titled ("Open canvas: {{title}}")
or com.labre.canvas-viewer.open ("Open canvas"), English when the host has
no translation.

The viewer loads no face: a public page declares its own, which may land
after the canvas painted its text. The viewer now repaints the surface on
each document.fonts loadingdone, as the editor does once FontLoaderService's
faces are in, and stops listening when disposed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • Loading branch information
r and claude committed Nov 12, 2026
commit 73d8e84c2008189dccc93f6cda8afce253161920
55 changes: 54 additions & 1 deletion packages/affine/all/src/__tests__/canvas-viewer.unit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
* page with a canvas;
* - a mount, a zoom or a click that writes anything into the document shown
* (its Y.Doc's state vector moves);
* - text left in a fallback face when the page's own fonts arrive late, or a
* listener on `document.fonts` left behind by `dispose`;
* - a frozen view whose button has no accessible name (a frame with no
* title);
* - zoom buttons, ctrl+wheel or a drag that move nothing;
* - an inline page reference that does not reach `onOpenDoc`, or a refused
* scheme that navigates;
Expand Down Expand Up @@ -249,6 +253,35 @@ describe('the canvas viewer', () => {
expect(Y.encodeStateVector(spaceDoc)).toEqual(Y.encodeStateVector(shown));
});

test("paints again when the page's fonts finish loading, until disposed", async () => {
// happy-dom has no font set to fire: a stand-in for `document.fonts`.
const fonts = new EventTarget();
Object.defineProperty(document, 'fonts', {
value: fonts,
configurable: true,
});
try {
const { viewer, editorHost } = await mount();
const { getSurfaceComponent } = await import(
'@labre/affine-block-surface'
);
const surface = getSurfaceComponent(
editorHost.std as unknown as Parameters<typeof getSurfaceComponent>[0]
);
if (!surface) throw new Error('no surface mounted');
const refresh = vi.spyOn(surface, 'refresh');

fonts.dispatchEvent(new Event('loadingdone'));
expect(refresh).toHaveBeenCalledTimes(1);

viewer.dispose();
fonts.dispatchEvent(new Event('loadingdone'));
expect(refresh).toHaveBeenCalledTimes(1);
} finally {
delete (document as unknown as { fonts?: unknown }).fonts;
}
});

test('refuses a state with no page', () => {
const host = document.createElement('div');
expect(() => mountCanvasViewer(host, new Uint8Array([0, 0]))).toThrow();
Expand Down Expand Up @@ -448,11 +481,31 @@ describe('the canvas viewer on one frame', () => {
const clickThenEnter = 2;
expect(onExpand).toHaveBeenCalledTimes(clickThenEnter);
expect(container.getAttribute('role')).toBe('button');
expect(container.getAttribute('aria-label')).toBe('The map');
expect(container.getAttribute('aria-label')).toBe('Open canvas: The map');
// One button: nothing inside it takes focus or keys.
expect((editorHost as HTMLElement & { inert: boolean }).inert).toBe(true);
});

test('a frozen frame with no title still names its button', async () => {
const { store, doc } = openHeadless(null);
store.transact(() => {
const page = store.addBlock('affine:page', { title: new Text('A page') });
const surface = store.addBlock('affine:surface', {}, page);
store.addBlock(
'affine:frame',
{ id: 'untitled', title: new Text(''), xywh: FRAME },
surface
);
});
const { container } = await mount(
{ focus: { kind: 'frame', id: 'untitled' }, onExpand: () => {} },
Y.encodeStateAsUpdate(doc)
);
// No host translation: the English fallback of its `com.labre.*` key.
expect(container.getAttribute('role')).toBe('button');
expect(container.getAttribute('aria-label')).toBe('Open canvas');
});

test('interactive on demand: it fills the host and zooms', async () => {
const { viewer, container, editorHost } = await mount(
{ focus: frame, interactive: true },
Expand Down
39 changes: 36 additions & 3 deletions packages/affine/all/src/canvas-viewer.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { CodeBlockConfigExtension } from '@labre/affine-block-code';
import { FrameBlockComponent } from '@labre/affine-block-frame';
import { getSurfaceBlock } from '@labre/affine-block-surface';
import {
getSurfaceBlock,
getSurfaceComponent,
} from '@labre/affine-block-surface';
import {
StoreExtensionManager,
type ViewExtensionProvider,
} from '@labre/affine-ext-loader';
import { FrameBlockModel, GroupElementModel } from '@labre/affine-model';
import { ViewportElementExtension } from '@labre/affine-shared/services';
import {
translateKey,
ViewportElementExtension,
} from '@labre/affine-shared/services';
import { adoptEmotionStyles } from '@labre/affine-shared/styles';
import { isSafeLinkUrl, normalizeUrl } from '@labre/affine-shared/utils';
import { frameTitleStyleVars } from '@labre/affine-widget-frame-title';
Expand Down Expand Up @@ -335,7 +341,6 @@ export function mountCanvasViewer(
box.cursor = 'pointer';
container.tabIndex = 0;
container.setAttribute('role', 'button');
if (focused?.title) container.setAttribute('aria-label', focused.title);
}
// The light theme, on this container only: the page around keeps its own.
// Built from names already in the theme contract (`theme-imports.unit.spec`):
Expand Down Expand Up @@ -371,6 +376,18 @@ export function mountCanvasViewer(
})
);
}
// The viewer loads no face: a public page declares its own, which may
// arrive after the canvas painted its text with a fallback. Paint
// again each time the page's faces finish loading, as the editor does
// once `FontLoaderService`'s are in.
const fonts = document.fonts as FontFaceSet | undefined;
if (fonts) {
const repaint = () => getSurfaceComponent(this.std)?.refresh();
fonts.addEventListener('loadingdone', repaint);
this._disposables.add(() =>
fonts.removeEventListener('loadingdone', repaint)
);
}
if (focus?.kind !== 'frame') return;
// The frame is the picture's edge: no border, as in the surface reference.
const hideBorder = (view: unknown) => {
Expand Down Expand Up @@ -401,6 +418,22 @@ export function mountCanvasViewer(
];
try {
std = new BlockStdScope({ store, extensions });
if (!interactive && options.onExpand) {
// A button needs a name, the element's title or none: a host with no
// translation reads the English fallback.
const title = focused?.title.trim();
container.setAttribute(
'aria-label',
title
? translateKey(
std,
'com.labre.canvas-viewer.open-titled',
'Open canvas: {{title}}',
{ title }
)
: translateKey(std, 'com.labre.canvas-viewer.open', 'Open canvas')
);
}
const editorHost = std.render();
// A frozen view is one button: nothing inside it takes focus, keys or
// pointers (the editor host would otherwise be a second tab stop, and
Expand Down
3 changes: 3 additions & 0 deletions packages/affine/all/src/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ const CHROME_KEYS: readonly [key: string, fallback: string][] = [
'com.labre.catalogue.open.description',
'This framework offers more than the menu can show.',
],
// Read-only canvas viewer: the name of a frozen view, a button
['com.labre.canvas-viewer.open', 'Open canvas'],
['com.labre.canvas-viewer.open-titled', 'Open canvas: {{title}}'],
// Artefact catalogue sidepanel
['com.labre.catalogue.title', 'Artefacts'],
['com.labre.catalogue.close', 'Close'],
Expand Down