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
feat(edgeless): make the canvas viewer the editor itself, derived fro…
…m the registry

The PO's principle for the viewer: a mirror of the interactive editor,
generated by the library so that changing the editor changes it, with no
maintenance of its own (ADR 0051, superseding in part ADR 0050).

`mountCanvasViewer` now mounts the `edgeless` scope of the view registry
(every flag on) plus the host's providers (`viewExtensions`: each
framework bundle, which the published core leaves to the bundles), minus
`READ_ONLY_EXCLUDED_VIEW_EXTENSIONS` and `READ_ONLY_EXCLUDED_EXTENSIONS`,
the one list of tooling, kept beside the registry in `extensions/view.ts`
with `getReadOnlyViewProviders`. On the read-only store the editor takes
the pan tool, so the viewer's own pan, wheel and pinch handlers are gone,
and with them the shared wheel module ADR 0050 asked for: the edgeless
root is back to the default branch, unchanged.

The viewer keeps only the host's integration (links resolved under a
note's mask, the frozen view of a frame, framing, the light theme) and
the strict-policy measures.

`read-only-view.unit.spec.ts` compares what the editor and the viewer
register in a real DI container: no excluded entry may paint content (a
block view, a canvas element's view or renderer), nothing may be missing
unless excluded, no exclusion may be stale. Excluding the paragraph
provider makes it fail on `BlockView|affine:paragraph`.

Checked in a browser under the viewer pages' policy: the editor root
mounts, no report, the drag pans, a click on a page reference reaches
`onOpenDoc`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • Loading branch information
2 people authored and r committed Nov 12, 2026
commit 70e5257c13232f2cf8a309fd946882ce22a0b37c
5 changes: 4 additions & 1 deletion .changeset/canvas-viewer.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
---
'@labre/affine': minor
'@labre/std': minor
'@labre/affine-shared': minor
'@labre/affine-block-code': minor
---

New entry `@labre/affine/canvas-viewer` (ADR 0050): `mountCanvasViewer(host, state, options)` mounts a read-only canvas from a stored Y.Doc state, with no editor around it, for a host's public page. It pans (drag, wheel, two fingers), zooms (ctrl+wheel, trackpad pinch, two fingers) and follows links: a page link goes to `onOpenDoc(docId)`, an external one to `onLinkClick(url)` after `isSafeLinkUrl`; `getBlob` feeds images. It returns `{ zoomIn, zoomOut, fit, dispose }` and fits once at mount. `focus: { kind: 'frame' | 'group', id }` shows one element the way a surface reference shows it in a page (its proportions, its bounds, a frame without its border); with it the view is frozen by default (`interactive`), lets the page scroll, and calls `onExpand` on a click or Enter so the host can open the same `focus` with `interactive: true`. It imports the whole view graph (3.65 MB gzipped, browser ESM): load it with a dynamic `import()`. The wheel and pinch maths of the edgeless root moved to `zoomAtPointer`, `panByWheel` and `pinchStep` (`@labre/affine-block-root`), shared by both; the editor's behaviour does not change. `docTitles` names the other pages for page references and linked doc cards. The viewer holds under a strict Content-Security-Policy (no `'unsafe-inline'` styles, no `'wasm-unsafe-eval'`): new `adoptShadowlessStyles()` in `@labre/std` moves light-DOM styles to adopted style sheets (the editor keeps `<style>` elements unless a host calls it), new `CodeBlockConfig.engine: 'oniguruma' | 'javascript'` (default `oniguruma`) highlights code without WebAssembly, and the paragraph block's in-template `<style>` moved to its static styles.
New entry `@labre/affine/canvas-viewer` (ADR 0050, ADR 0051): `mountCanvasViewer(host, state, options)` shows a stored canvas, read-only, on a host's public page. It is the edgeless editor itself on a read-only store, built from the view registry plus the host's own providers (`viewExtensions`: each framework bundle's view extensions, which the published core leaves to the bundles) minus the tooling listed in `READ_ONLY_EXCLUDED_VIEW_EXTENSIONS` and `READ_ONLY_EXCLUDED_EXTENSIONS` (exported from `@labre/affine/extensions/view` with `getReadOnlyViewProviders`); a guard spec proves no excluded entry paints content. The editor pans and zooms as it does for a read-only document. A page link goes to `onOpenDoc(docId)`, an external one to `onLinkClick(url)` after `isSafeLinkUrl`; `getBlob` feeds images; `docTitles` names the other pages. `focus: { kind: 'frame' | 'group', id }` shows one element the way a surface reference shows it in a page, frozen by default (`interactive`) with `onExpand` on a click or Enter. It returns `{ zoomIn, zoomOut, fit, dispose }` and imports the whole view graph (3.65 MB gzipped): load it with a dynamic `import()`.

It holds under a strict Content-Security-Policy (no `'unsafe-inline'` style, no `'wasm-unsafe-eval'`): new `adoptShadowlessStyles()` (`@labre/std`) moves light-DOM styles to adopted style sheets, new `adoptEmotionStyles()` (`@labre/affine-shared/styles`, the library's one emotion instance, which the table and database blocks now import) does the same for emotion, new `CodeBlockConfig.engine: 'oniguruma' | 'javascript'` (default `oniguruma`) highlights code without WebAssembly, and the paragraph block's in-template `<style>` moved to its static styles. The editor keeps `<style>` elements unless a host calls the two functions.
31 changes: 16 additions & 15 deletions architecture/code.c4
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ model {
link https://github.com/formicoidea/blocksuite-labre/tree/blocksuite-labre-main/packages/affine/blocks/root
metadata {
path 'packages/affine/blocks/root'
files '55'
files '54'
}
adapters = folder 'adapters/' {
link https://github.com/formicoidea/blocksuite-labre/tree/blocksuite-labre-main/packages/affine/blocks/root/src/adapters
Expand Down Expand Up @@ -977,7 +977,7 @@ model {
link https://github.com/formicoidea/blocksuite-labre/tree/blocksuite-labre-main/packages/affine/blocks/root/src/edgeless
metadata {
path 'packages/affine/blocks/root/src/edgeless'
files '28'
files '27'
}
}
keyboard = folder 'keyboard/' {
Expand Down Expand Up @@ -3464,7 +3464,7 @@ model {
assembly.all -[uses]-> features.blocks.list '5 imports'
assembly.all -[uses]-> features.blocks.note '6 imports'
assembly.all -[uses]-> features.blocks.paragraph '6 imports'
assembly.all -[uses]-> features.blocks.root '9 imports, 1 type-only'
assembly.all -[uses]-> features.blocks.root '8 imports, 1 type-only'
assembly.all -[uses]-> features.blocks.surface '11 imports'
assembly.all -[uses]-> features.blocks.surface-ref '6 imports'
assembly.all -[uses]-> features.blocks.table '6 imports'
Expand All @@ -3473,7 +3473,7 @@ model {
assembly.all -[uses]-> features.database.editor '2 imports'
assembly.all -[uses]-> features.database.engine '3 imports'
assembly.all -[uses]-> features.database.view-block '6 imports'
assembly.all -[uses]-> features.ext-loader '4 imports'
assembly.all -[uses]-> features.ext-loader '5 imports, 1 type-only'
assembly.all -[uses]-> features.foundation '5 imports'
assembly.all -[uses]-> features.fragments.adapter-panel '4 imports'
assembly.all -[uses]-> features.fragments.doc-title '5 imports'
Expand Down Expand Up @@ -3528,7 +3528,7 @@ model {
assembly.all -[uses]-> features.widgets.viewport-overlay '3 imports'
assembly.all -[uses]-> framework.global_ '11 imports'
assembly.all -[uses]-> framework.std '16 imports, 2 type-only'
assembly.all -[uses]-> framework.store '6 imports, 3 type-only'
assembly.all -[uses]-> framework.store '7 imports, 4 type-only'
assembly.all -[uses]-> framework.sync '2 imports, 1 type-only'
assembly.all -[uses]-> model_.model_ '5 imports, 1 type-only'
features.blocks.attachment -[uses]-> features.blocks.image '3 imports'
Expand Down Expand Up @@ -3688,7 +3688,7 @@ model {
features.blocks.root -[uses]-> features.blocks.image '2 imports'
features.blocks.root -[uses]-> features.blocks.note '2 imports'
features.blocks.root -[uses]-> features.blocks.paragraph '2 imports'
features.blocks.root -[uses]-> features.blocks.surface '19 imports, 1 type-only'
features.blocks.root -[uses]-> features.blocks.surface '18 imports, 1 type-only'
features.blocks.root -[uses]-> features.components '5 imports, 1 type-only'
features.blocks.root -[uses]-> features.database.block '1 import'
features.blocks.root -[uses]-> features.database.engine '1 import'
Expand All @@ -3707,8 +3707,8 @@ model {
features.blocks.root -[uses]-> features.shared '50 imports, 1 type-only'
features.blocks.root -[uses]-> features.widgets.edgeless-toolbar '2 imports'
features.blocks.root -[uses]-> features.widgets.linked-doc '1 import'
features.blocks.root -[uses]-> framework.global_ '25 imports'
features.blocks.root -[uses]-> framework.std '56 imports, 21 type-only'
features.blocks.root -[uses]-> framework.global_ '24 imports'
features.blocks.root -[uses]-> framework.std '55 imports, 20 type-only'
features.blocks.root -[uses]-> framework.store '15 imports, 10 type-only'
features.blocks.root -[uses]-> model_.model_ '24 imports, 6 type-only'
features.blocks.surface -[uses]-> features.components '5 imports, 1 type-only'
Expand Down Expand Up @@ -4360,10 +4360,11 @@ model {
assembly.all.extensions -[imports]-> features.blocks.surface-ref.src '2 imports'
assembly.all.extensions -[imports]-> features.blocks.surface.src '2 imports'
assembly.all.extensions -[imports]-> features.blocks.table.src '2 imports'
assembly.all.extensions -[imports]-> features.components.drop-indicator '1 import'
assembly.all.extensions -[imports]-> features.database.block.src '2 imports'
assembly.all.extensions -[imports]-> features.database.editor.src '1 import'
assembly.all.extensions -[imports]-> features.database.view-block.src '2 imports'
assembly.all.extensions -[imports]-> features.ext-loader.src '2 imports'
assembly.all.extensions -[imports]-> features.ext-loader.src '3 imports, 1 type-only'
assembly.all.extensions -[imports]-> features.foundation.src '2 imports'
assembly.all.extensions -[imports]-> features.fragments.adapter-panel.src '1 import'
assembly.all.extensions -[imports]-> features.fragments.doc-title.src '1 import'
Expand Down Expand Up @@ -4415,7 +4416,7 @@ model {
assembly.all.extensions -[imports]-> features.widgets.toolbar.src '1 import'
assembly.all.extensions -[imports]-> features.widgets.viewport-overlay.src '1 import'
assembly.all.extensions -[imports]-> framework.std.src '2 imports'
assembly.all.extensions -[imports]-> framework.store.src '2 imports, 2 type-only'
assembly.all.extensions -[imports]-> framework.store.src '3 imports, 3 type-only'
assembly.all.foundation -[imports]-> features.foundation.src '3 imports'
assembly.all.fragments -[imports]-> features.fragments.adapter-panel.src '2 imports'
assembly.all.fragments -[imports]-> features.fragments.doc-title.src '2 imports'
Expand Down Expand Up @@ -4472,15 +4473,15 @@ model {
assembly.all.src -[imports]-> features.blocks.latex.src '1 import'
assembly.all.src -[imports]-> features.blocks.note.src '1 import'
assembly.all.src -[imports]-> features.blocks.paragraph.src '1 import'
assembly.all.src -[imports]-> features.blocks.root.src '4 imports, 1 type-only'
assembly.all.src -[imports]-> features.blocks.root.src '3 imports, 1 type-only'
assembly.all.src -[imports]-> features.blocks.surface-ref.src '1 import'
assembly.all.src -[imports]-> features.blocks.surface.src '6 imports'
assembly.all.src -[imports]-> features.blocks.table.src '1 import'
assembly.all.src -[imports]-> features.components.caption '1 import, 1 type-only'
assembly.all.src -[imports]-> features.components.color-picker '1 import, 1 type-only'
assembly.all.src -[imports]-> features.components.context-menu '1 import, 1 type-only'
assembly.all.src -[imports]-> features.components.date-picker '1 import, 1 type-only'
assembly.all.src -[imports]-> features.components.drop-indicator '2 imports, 1 type-only'
assembly.all.src -[imports]-> features.components.drop-indicator '1 import, 1 type-only'
assembly.all.src -[imports]-> features.components.embed-card-modal '1 import, 1 type-only'
assembly.all.src -[imports]-> features.components.highlight-dropdown-menu '1 import, 1 type-only'
assembly.all.src -[imports]-> features.components.link-preview '1 import, 1 type-only'
Expand Down Expand Up @@ -5334,7 +5335,7 @@ model {
features.blocks.root.edgeless -[imports]-> features.blocks.root.clipboard '1 import'
features.blocks.root.edgeless -[imports]-> features.blocks.root.keyboard '1 import'
features.blocks.root.edgeless -[imports]-> features.blocks.root.src '4 imports'
features.blocks.root.edgeless -[imports]-> features.blocks.surface.src '16 imports, 1 type-only'
features.blocks.root.edgeless -[imports]-> features.blocks.surface.src '15 imports, 1 type-only'
features.blocks.root.edgeless -[imports]-> features.components.toast '1 import'
features.blocks.root.edgeless -[imports]-> features.components.toolbar '1 import'
features.blocks.root.edgeless -[imports]-> features.gfx.brush.src '1 import'
Expand All @@ -5353,10 +5354,10 @@ model {
features.blocks.root.edgeless -[imports]-> framework.global_.disposable '1 import'
features.blocks.root.edgeless -[imports]-> framework.global_.env '2 imports'
features.blocks.root.edgeless -[imports]-> framework.global_.exceptions '2 imports'
features.blocks.root.edgeless -[imports]-> framework.global_.gfx '12 imports'
features.blocks.root.edgeless -[imports]-> framework.global_.gfx '11 imports'
features.blocks.root.edgeless -[imports]-> framework.global_.lit '1 import'
features.blocks.root.edgeless -[imports]-> framework.global_.utils '1 import'
features.blocks.root.edgeless -[imports]-> framework.std.gfx '19 imports, 6 type-only'
features.blocks.root.edgeless -[imports]-> framework.std.gfx '18 imports, 5 type-only'
features.blocks.root.edgeless -[imports]-> framework.std.src '15 imports, 10 type-only'
features.blocks.root.edgeless -[imports]-> framework.store.src '8 imports, 5 type-only'
features.blocks.root.edgeless -[imports]-> model_.model_.src '13 imports, 4 type-only'
Expand Down
2 changes: 1 addition & 1 deletion architecture/domain.c4
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ model {
extend features.blocks.root {
metadata {
domain ['canvas', 'file']
domain_canvas '0.51'
domain_canvas '0.50'
domain_file '0.15'
}
}
Expand Down
8 changes: 5 additions & 3 deletions docs/adr/0050-read-only-canvas-viewer.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# ADR 0050 — A read-only canvas viewer a host mounts from a Y.Doc state

- Status: accepted (2026-11-08, built as amended below)
- Status: accepted (2026-11-08, built as amended below); superseded in part
by [0051](0051-read-only-viewer-is-the-editor.md) (2026-11-10): the viewer
mounts the edgeless editor on a read-only store, not the preview scope
- Date: 2026-11-05
- Deciders: Mathieu Jolly
- Host side, never restated here: Labre Sites (labre ADR-0069), public pages
Expand Down Expand Up @@ -135,8 +137,8 @@ export function mountCanvasViewer(
sheet carries. A click resolves its link from the elements under the
pointer, since a note's mask covers its content.
- The light theme is set as custom properties on the viewer's container only.
- §4 shipped as `utils/wheel-gesture.ts` in `blocks/root` (`zoomAtPointer`,
`panByWheel`, `pinchStep`), called by the edgeless root and the viewer.
- §4 shipped as `utils/wheel-gesture.ts`, then was dropped by ADR 0051: the
viewer now runs the editor's own handlers and has none to share.
- Events: one-finger or mouse drag pans, two fingers pinch, ctrl+wheel and a
trackpad pinch zoom, a plain wheel pans; every pointer, wheel and click
event stops on the viewer's container in capture, so no block reacts.
Expand Down
95 changes: 95 additions & 0 deletions docs/adr/0051-read-only-viewer-is-the-editor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# ADR 0051 — The read-only viewer is the editor, mounted read-only, derived from the registry

- Status: **accepted** (2026-11-10)
- Deciders: Mathieu Jolly (PO principle, Labre Sites acceptance of 2026-11-10)
- Supersedes in part: [0050](0050-read-only-canvas-viewer.md), its decision to
mount the `preview-edgeless` scope and to add pan, zoom and links by a runtime
extension. 0050's entry point, sub-path and host contract stand.
- Related ADRs: [0009](0009-reversed-flag-contract.md) (a flag never gates
content), [0035](0035-core-database-bundle-and-panel-seams.md) (the database chrome
ships apart).

## Context

The PO's principle, verbatim: « Cet éditeur doit être un miroir de l'éditeur
interactif, c'est presque un fork quelque part. D'ailleurs ce serait bien qu'il
soit autogénéré par la lib elle-même pour qu'on n'ait pas à penser sa
maintenance alors que l'éditeur interactif est modifié. »

ADR 0050 mounted the `preview-edgeless` scope, a picture, and gave it back
pan, zoom and link clicks with its own handlers. That is a second interaction
layer that drifts from the editor's (the editor's wheel and pinch maths had to
be extracted to be shared), and the preview scope only shows what each
provider chose to register for previews. 0050 rejected the full `edgeless`
scope because "the clipboard, the toolbars and the widgets would each have to
be proven inert on a public page".

What the code says since:

- On a read-only store the edgeless root takes the pan tool
(`edgeless-root-block.ts`, `this.store.readonly`): a drag, the wheel, two
fingers and the pinch move the canvas with the editor's own handlers.
- Every write goes through the store, which refuses it when read-only.
- What a public page must not show is a short, nameable set of providers:
editing widgets, panels, collaboration, telemetry.

## Decision

`mountCanvasViewer` mounts the `edgeless` scope of:

```
getInternalViewExtensions() // the registry, every flag on
+ host providers // what the host adds for its editor
− READ_ONLY_EXCLUDED_VIEW_EXTENSIONS
```

then drops the single extensions in `READ_ONLY_EXCLUDED_EXTENSIONS`, on a
store opened `readonly`. Both lists live in `extensions/view.ts`, beside the
registry, and nowhere else:

- telemetry and the AI audit: `CommandTelemetry`, `CommandUsage`, `Audit`;
- editing widgets: drag handle, auto-connect, dragging areas, selected rect,
edgeless toolbar, zoom toolbar, keyboard toolbar, linked-doc menu, note
slicer, scroll anchoring, slash menu, toolbar;
- collaboration: remote selection, thread marks;
- panels: adapter panel, doc title, frame panel, outline;
- one extension inside a kept provider: the file drop, whose indicator lives
in `<body>`.

A provider added to the registry reaches the viewer without touching it. The
viewer keeps only the host's integration: links (a note's mask covers its
content, so a click is resolved from the elements under the pointer), the
frozen view of an inserted frame, framing, the light theme, and holding under
a strict Content-Security-Policy (`adoptShadowlessStyles`,
`adoptEmotionStyles`, shiki's JavaScript engine).

**The host's providers.** The published core leaves each framework to its own
bundle (`scripts/build-bundles.mjs` strips them from core's `view.ts`), so the
viewer takes `viewExtensions`: the same providers the host gives its editor
(each `descriptor.extensions[].viewExtension`, the database chrome). Without
them a framework's notation is not painted.

**The guard.** `read-only-view.unit.spec.ts` reads, in a real DI container,
what the editor and the viewer register, by identifier. It fails when an
excluded provider or extension registers content (a block view, a canvas
element's view or renderer), when the editor registers something the viewer
lacks without it being excluded, and when an exclusion is stale.

## Consequences

- The wheel and pinch extraction 0050 §4 asked for is dropped: the viewer has
no handler of its own to share them with. The editor's root is unchanged.
- The viewer is as heavy as the editor (3.65 MB gzipped, browser ESM); a host
loads it with a dynamic `import()`. 0050's measure stands.
- A frozen view locks the viewport and makes the editor host `inert`; the
wheel and touch then scroll the page.
- The library keeps no per-line deviation log ([0001](0001-assumed-divergence-from-upstream.md)
records the divergence as a whole): this ADR is the record.

## Open questions

- A widget that registers with a kept block provider (the code block's
toolbar, a framework's validation widgets) is part of the viewer. It is read
only on a read-only store; if one shows editing chrome on a public page, it
joins `READ_ONLY_EXCLUDED_EXTENSIONS` and the guard proves it paints no
content.
Loading