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): settle synced docs of named pages and follow only the …
…clicked block

Found by a fresh review of the strict-CSP round:

- a page listed in `docTitles` became an empty doc with no root, so a
  synced-doc card of it waited forever for content; it now gets an empty
  page with its title and settles;
- the click read every element under the pointer, so a card hidden under
  another note could be followed; the lookup stops at the first block
  under the pointer, and reads the container's root node, so it also
  works inside a shadow root;
- in a shadow root, a class leaving removed every copy of a shared sheet;
  it now removes one occurrence per sheet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • Loading branch information
2 people authored and r committed Nov 12, 2026
commit 78416b6779ef3124cd6b87e4579ce0a361613b0d
40 changes: 40 additions & 0 deletions packages/affine/all/src/__tests__/canvas-viewer.unit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,46 @@ describe('the canvas viewer', () => {
);
});

test('a synced doc of a named page settles instead of loading forever', async () => {
const { store, doc } = openHeadless(null);
store.transact(() => {
const page = store.addBlock('affine:page', { title: new Text('A map') });
store.addBlock('affine:surface', {}, page);
store.addBlock(
'affine:embed-synced-doc',
{ id: 'synced', pageId: 'p-2', xywh: '[0,0,400,200]' },
page
);
});
const { container } = await mount(
{ docTitles: { 'p-2': 'Next page' } },
Y.encodeStateAsUpdate(doc)
);
const card = container.querySelector('affine-embed-synced-doc-block') as
| (HTMLElement & { syncedDoc?: { root?: unknown } | null })
| null;
expect(card).not.toBeNull();
// A root to render, so the card is not waiting for one that never comes.
expect(card?.syncedDoc?.root).toBeTruthy();
});

test('a click on a note covering a card follows nothing', async () => {
// The elements under the pointer run from the note's own text down to a
// bookmark the note hides: only the top block counts.
const onLinkClick = vi.fn();
const { container } = await mount({ onLinkClick });
const card = container.querySelector('[data-block-id="bm-1"]')!;
const text = container.querySelector('affine-paragraph')!;
// happy-dom has no hit testing: the stack a browser would return.
Object.defineProperty(document, 'elementsFromPoint', {
configurable: true,
value: () => [text, card],
});
container.dispatchEvent(new MouseEvent('click', { bubbles: true }));
expect(onLinkClick).not.toHaveBeenCalled();
Reflect.deleteProperty(document, 'elementsFromPoint');
});

test('refuses a state with no page', () => {
const host = document.createElement('div');
expect(() => mountCanvasViewer(host, new Uint8Array([0, 0]))).toThrow();
Expand Down
35 changes: 27 additions & 8 deletions packages/affine/all/src/canvas-viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ import {
import { DisposableGroup } from '@labre/global/disposable';
import { Bound } from '@labre/global/gfx';
import { GfxControllerIdentifier } from '@labre/std/gfx';
import { type ExtensionType, type Store, WorkspaceImpl } from '@labre/store';
import {
type ExtensionType,
type Store,
Text,
WorkspaceImpl,
} from '@labre/store';
import type { BlobSource } from '@labre/sync';
import { combinedLightCssVariables } from '@toeverything/theme';
import {
Expand Down Expand Up @@ -274,9 +279,16 @@ export function mountCanvasViewer(
getInternalStoreExtensions()
).get('store');
workspace.meta.initialize();
Object.entries(options.docTitles ?? {}).forEach(([id, title]) =>
workspace.meta.addDocMeta({ id, title, tags: [], createDate: 0 })
);
Object.entries(options.docTitles ?? {}).forEach(([id, title]) => {
workspace.meta.addDocMeta({ id, title, tags: [], createDate: 0 });
// The viewer knows a listed page by its title only. Without a root, a
// synced-doc card of it waits forever for a page block that never comes;
// an empty page with the title lets it settle.
const page = workspace.getDoc(id)?.getStore();
page?.load(() => {
page.addBlock('affine:page', { title: new Text(title) });
});
});
const doc = workspace.createDoc('canvas-viewer');
Y.applyUpdate(doc.spaceDoc, state);
const store = doc.getStore({ readonly: true });
Expand Down Expand Up @@ -463,10 +475,17 @@ export function mountCanvasViewer(
if (travelled > CLICK_SLOP_PX) return;
// A note on the canvas lies under its mask (`.affine-note-mask`), so the
// click's own path never holds the link: the elements under the pointer do.
const under = document
.elementsFromPoint?.(e.clientX, e.clientY)
.filter(element => container.contains(element));
const link = linkOf([...e.composedPath(), ...(under ?? [])], id => {
// Only down to the first block under the pointer: a card hidden under
// another note is not what the reader clicked.
const root = container.getRootNode() as Document | ShadowRoot;
const stack = (root.elementsFromPoint?.(e.clientX, e.clientY) ?? []).filter(
element => container.contains(element)
);
const hit = stack.findIndex(
element => element instanceof HTMLElement && element.dataset.blockId
);
const under = hit < 0 ? stack : stack.slice(0, hit + 1);
const link = linkOf([...e.composedPath(), ...under], id => {
const model = store.getBlock(id)?.model;
return model ? { flavour: model.flavour, props: model.props } : undefined;
});
Expand Down
11 changes: 8 additions & 3 deletions packages/framework/std/src/view/element/shadowless-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,14 @@ export class ShadowlessElement extends LitElement {
SE.onDisconnectedMap.set(SE, new WeakMap());
}
SE.onDisconnectedMap.get(SE)?.set(parentRoot, () => {
parentRoot.adoptedStyleSheets = parentRoot.adoptedStyleSheets.filter(
sheet => !sheets.includes(sheet)
);
// One occurrence per sheet: a class sharing a `css` result with this
// one adopted its own copy, and keeps it.
const adopted = [...parentRoot.adoptedStyleSheets];
sheets.forEach(sheet => {
const at = adopted.indexOf(sheet);
if (at >= 0) adopted.splice(at, 1);
});
parentRoot.adoptedStyleSheets = adopted;
});
} else if (styleInjectedCount === 0 && insideShadowRoot) {
const elementStyles = SE.elementStyles;
Expand Down