Repository navigation
feat(blocks): canvas viewer, headless mind map, icon picker and fixes for 3.5.0 - #664
Merged
Merged
Conversation
…ected buildMindmap on @labre/affine-gfx-mindmap/interchange (core: gfx/mindmap/interchange) returns the elements the toolbar's mind map writes: one styled shape per node, sized as fitContent sizes it from the caller's MindmapTextMeasure, placed by the view's layout, then the mindmap element naming them by local id. materializeInterchangeImport rewrites a mind map's children and their parent onto the minted ids. layout.ts is typed against a structural LayoutNode; style.ts loads no lodash (applyNodeStyle moves to apply-style.ts) and joins model ./headless; the headless guard allows @toeverything/theme (data only). ADR 0045, amendment of 2026-11-10. Refs #662. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…inear time A server builds what a model sent: a node holds at most 2,000 characters, a word wider than the line is cut searching forward (a line costs its own width), the widest line is a reduce rather than a spread, and the materializer passes a mind map entry that is not a record through instead of throwing after the nodes are written. Refs #662. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lder Refs #662. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…arity spec Refs #662. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… policy Labre's site serves the viewer with `style-src 'self'` and no `'wasm-unsafe-eval'`. The 3.5.0-rc.0 viewer mounted there and drew nothing. Reproduced in a browser against that policy (203 reports), then fixed: - every light-DOM component appended its styles as a `<style>` in `<head>`: `adoptShadowlessStyles()` (std) moves the registered ones, and every later one, to `document.adoptedStyleSheets`, which a CSP does not block; the viewer calls it, the editor keeps `<style>`; - the viewer's own rule was a `<style>`: it is an adopted sheet now, and it carries the two declarations `@blocksuite/icons` binds as a `style` attribute; - the code block highlighter compiled Oniguruma to WebAssembly at mount: `CodeBlockConfig.engine` picks shiki's JavaScript engine, which the viewer asks for (the editor keeps Oniguruma); - emotion's one `<style>` (tables, databases) has a null sheet under the policy: its registered and later rules go to an adopted sheet too; - the paragraph block rendered a `<style>` in its template: the rule moved to its static styles, a higher specificity than the heading icon's own rule, so the editor's cascade is unchanged; - the file drop is not mounted by the viewer (its indicator in `<body>`). Two reports remain and change nothing on screen: emotion's `<style>`, created at import, and the icons' `style` attribute. Found on the way, also fixed: a click on a note's content never reached its link in a browser, because the note's mask covers it; the link is now resolved from the elements under the pointer. And `docTitles` names the other pages, which page references showed as deleted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…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>
…icy blocks Emotion (the table and database blocks) created its `<style>` at import, before any canvas viewer existed: one report under the published site's `style-src`, whose criterion is none. Every `css` now comes from `@labre/affine-shared/styles`, the library's one emotion instance, whose rules wait for the next microtask before reaching emotion's `<style>`. The editor gets them there as before, before its first render. The canvas viewer calls `adoptEmotionStyles()` (with `adoptShadowlessStyles()`) at import, while the modules are still evaluating, so the rules go to an adopted sheet and no `<style>` is ever created. The replay from `cache.registered` in the viewer is gone. `@emotion/css` moves from the table and database packages to `@labre/affine-shared`, the one place that imports it now. Checked in a browser under the viewer pages' policy (`script-src 'self' 'wasm-unsafe-eval'; style-src 'self'; style-src-attr 'unsafe-inline'`): no report, no `<style>` in `<head>`, the table styled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…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>
…olicy The 3.5.0-rc.0 viewer mounted on Labre's site and drew nothing under the page's Content-Security-Policy. This spec mounts the viewer in a frame whose policy is stricter than the site's (`script-src 'self'`, no `'wasm-unsafe-eval'`; `style-src 'self'`; `style-src-attr 'unsafe-inline'`), on a page whose frame holds a filled shape, and counts the shape's pixels on the canvases: a whole canvas and one frame frozen in a page. It also fails on any `<style>` element or any policy report whose source is the library rather than Vite's own dev CSS injection. With `adoptShadowlessStyles()` switched off, it fails as the site did: 0 pixels on the whole canvas. A shim module defines `__vitest_browser_runner__.wrapDynamicImport`, which Vitest's browser mode writes into every dynamic `import()` it serves and which only its own frame defines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fter a drag - getReadOnlyViewExtensions is the one list mountCanvasViewer mounts; the guard reads it instead of recomposing it, and counts AffineInlineSpec as content - a key typed while the pointer rests on an interactive canvas reaches the page: the editor's dispatcher pauses for that key, then resumes - a keyboard click (detail 0) never counts as the end of a drag - the spec names its constants and no longer leaves an unused variable Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…/mindmap-headless-builder
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DatabaseBlockDataSource.getCellValue returned undefined when the stored value failed the property's rawValue.schema (a type change, an import, a peer on another version). It now returns rawValue.default(), at the read boundary only: the stored value is kept as is and nothing is written. Port of toeverything/AFFiNE#15809 (1433ac7). Closes #656. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the subkeys of a and b share a prefix, generateFractionalIndexingKeyBetween(a, b) appended '0' and a random postfix to generateKeyBetween(a, b). If b itself continues with that key plus '0', the postfix decided the order and the new key could sort after b: inserting a table row or column right after the first one reordered it within about twenty inserts. The key now moves towards b until b no longer continues with key + '0' (upstream toeverything/AFFiNE#15709). Only newly generated keys change; stored keys are read and compared as before. Closes #655 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`@labre/affine/components/icon-picker` re-exports the icon picker so a host importing only public entries can reuse it (issue 636: the Labre shell's workspace icon). `openIconPicker(anchor, options)` opens `affine-icon-picker` in a portal anchored to the element and resolves with the picked `IconData` (plain JSON), `null` for Remove, or `undefined` on Escape, a click outside, the host's `signal`, the anchor leaving or a second opening; the popup closes in every case and Escape stops before a host dialog. The three elements take an optional `translation` (the host's `TranslationService`) so the picker reads in the host's language without `std`, English otherwise. `effects()` is now idempotent; nothing is defined at import. The playground debug bar gains an "Icon Picker (host demo)" button that goes through the public entry only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The table selection controller wrote its selection with `set` and cleared it with `clear()`, both of which replace every selection group. In edgeless that dropped the `gfx` group: the note being edited left edit mode when the caret entered a cell, and selecting then clearing a column wiped an unrelated canvas selection. `setSelected` now writes only the `TableSelection` group through `setGroup` (issue #659, upstream toeverything/AFFiNE#15791). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A numbered list that does not start at 1 keeps its start number in the order prop of its first list block, and the Markdown and HTML imports already read it from the list start. Both exports dropped it, so the exported list restarted at 1 and an export then import round trip lost the numbering. The markdown and html list adapters now write start on a new numbered list when the first item's order is an integer above 1 (upstream toeverything/AFFiNE#15726). A list at 1 or without an order exports unchanged. The clipboard's text/html copy uses the same adapter. Closes #658 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The builder's own wrap dropped the trailing space wrapText keeps on a line broken before a word, ignored hyphens and cut long words one character later, so a node long enough to break was stored 4 to 9 px narrower than the editor lays it out. wrapMindmapText is now wrapText line for line with the injected width, held to the real function on a corpus by mindmap-headless.spec.ts. A measure answering NaN, a negative or an infinite size throws MindmapMeasureError instead of looping. The parity spec now covers the four styles and three layouts, a wrapping node, and a toolbar-made map read prop for prop; the unit spec tests both caps at their bound, a refusal that quotes no text, the measure as the only source of size, and the child index against generateKeyBetween up to the node cap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Dropping lodash last from the style getters must leave a node deeper than style two's palette on its last colour. Checked once against the getters before the change on 12 000 paths of the four styles; this keeps the branch that changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Build Mind Map (headless) calls buildMindmap with the browser's measure, writes the result with the materializer at the top-left of the view, and reports how many nodes the editor's own layout moved on landing (zero is the expected answer). Each click takes the next of the four styles. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ecette Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A frozen frame was framed edge to edge, so the badge the editor draws above the frame's top edge was clipped. The view now keeps a strip of the badge's height (28px) above a titled frame: its aspect-ratio adds that strip for the current width and is read again on each resize, and fit() frames the frame under it. The viewer's adopted sheet also carries vertical-align: middle for a page reference's icon, which @blocksuite/icons asks for in a style attribute that a strict policy refuses. CommunityCanvasTextFonts is re-exported from the canvas-viewer entry for a public page that serves the faces itself. Guards: the read-only view spec names the frame-title widget among the viewer's and the editing toolbars outside it (excluding the widget made the four other cases pass and this one fail); the viewer spec asserts that mount, zoom and a click leave the shown Y.Doc's state vector unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The spec ran with style-src-attr 'unsafe-inline', so it could not see an attribute report. It now runs under default-src 'none'; script-src 'self'; style-src 'self'; font-src 'self', waits until the shape is painted instead of a fixed delay (180s deadline, cold dev-server imports took over 60s here), and its page holds a linked-doc card, a formatted note and a page-only note. Both cases assert painted pixels, no style element, the frame badge shown inside the view and no editing chrome. The two known reports are named and let through: one style-src-attr per icon whose declarations the viewer's sheet carries, and the data: drag image pragmatic-drag-and-drop preloads. Any other report fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The static HTML guide says what importing the viewer already calls (adoptShadowlessStyles, adoptEmotionStyles, the JavaScript regex engine), what the policy still needs from the host, which reports remain and why the viewer belongs on a page without the editor. ADR 0051 gains an amendment with the measurements under the site's policy and the frame badge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The debug menu's "Open in Canvas Viewer" serializes the document and posts it to examples/canvas-viewer, a page of its own (importing the viewer moves the page's styles to adopted sheets). A selected frame or group opens frozen; a click expands it. The strict variant loads under Labre Sites' policy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In the code block's "more" menu, a click on the Wrap or Line number switch flipped the switch and bubbled up to its `editor-menu-action` row, which flipped the setting a second time; the switch was bound through the `checked` attribute, so its drawn state drifted from the model (issue #660, upstream toeverything/AFFiNE#15782). `ToggleSwitch` now stops the click at its label, reads the new value from the checkbox and binds `.checked` as a property. Each code toolbar row hands its switch an `onChange` that shares the row's write, so a click on the switch or on the row flips the setting once, and both refuse a readonly store before writing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A select or multi-select option whose name is empty or blank drew an empty pill: invisible in cells and in the tag menu, and as a kanban group title a zero-height strip that could not be clicked to rename it. The pill, the cell tag, the mobile picker and the group title now draw TAG_UNTITLED (com.labre.data-view.tag.untitled, "Untitled") through one tagLabel helper, the tag menu finds blank options by that label, the rename fields take it as placeholder, and the group title keeps a min-height. Display only: the stored option name is never rewritten. The manifest's chrome dedupe keeps the word apart from the page's DOC_UNTITLED (a name, not a title). Port of toeverything/AFFiNE#15807 (a2d1584). Closes #657. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A shell edit had left the deadline's Error without its message, and the stage it reads unused (TS6133 in yarn build). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The page is a script with no top-level import, so a top-level status clashed with the global (TS2451 in yarn build). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The viewer imports the frame-title widget's style constants; the playground gains its examples/canvas-viewer page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # architecture/code.c4
# Conflicts: # architecture/code.c4 # packages/playground/apps/_common/components/starter-debug-menu.ts
# Conflicts: # architecture/code.c4 # packages/playground/apps/_common/components/starter-debug-menu.ts
Both toggle fixes are in this branch: <toggle-switch> stops its own click at its label, so the menu row's extra stop on the switch's host is redundant, as its ponytail line said. The icon picker's comment no longer says the portal reads event.target. Land-Verified: 2026-11-12T22:30:00+01:00 rounds=4 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 13, 2026
Closed
Owner
Author
Résumé de session
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intention — The PO asked to finish everything started on the library side so that 3.5.0 can be published, even where hosts had only taken part of it, then to clear the debt that the reviews turned up. One consolidated PR, which the PO chose over 21 single-topic PRs: each topic was developed, reviewed and accepted on its own branch, and those branches are merged here as they are. Four groups of work:
Test —
usine check(format, build, unit, architecture map, couplings) is green on 7cb87b5, and so are the integration specs this branch touches. Details below.Risque
packages/affine/model(mind map styles; the library's palette values now live in its theme). No stored field is added or changed: a parity spec against@toeverything/themeand a deep equality ofDefaultThemehold the stored colours.@emotion/cssintoaffine-shared,emoji-martintoaffine-components.@labre/affine/canvas-viewerand@labre/affine/components/icon-picker,buildMindmap, andlistStartNumber/listPlainTextPrefix/storedShapeIsReadable. Plain-text exports now carry list markers. Five newcom.labre.*keys and elevencom.labre.emoji-picker.*keys.Revert — Squash revert of this PR. Nothing is migrated and no stored format changes, so documents written in between stay readable by 3.4.0.
What is in it
docTitlesshow "Access denied". It repaints when the page's fonts load, its frozen view has an accessible name, and a middle click goes through the link checks.feat/canvas-viewer-editorfeat/mindmap-headless-builderopenIconPicker(anchor, options)returnsIconData,nullfor Remove, orundefinedwhen cancelled.feat/icon-picker-standalonefeat/unified-emoji-pickerb. A forged key cannot freeze the tab, and a stack overflow becomes a named error.fix/fractional-index-betweenfix/database-cell-defaultfix/select-tag-blank-namefix/list-export-startfix/table-selection-keeps-canvasfix/code-toggle-doublefix/database-readonly-row-openfix/menu-toggle-rowfix/data-view-cell-defaultfix/database-duplicate-property-optionsfix/outline-setting-togglefix/portal-click-away-composedfix/text-char-width-codepoint<ol start>imports with the right numbers.fix/list-html-import-orderfix/plain-text-list-markerstext/plain.fix/plain-text-block-separatordocs/lessons-3-5-0How it was verified
yarn build.usine checkis green on 7cb87b5, with Vitest held to 4 workers (VITEST_MAX_FORKS=4,VITEST_MAX_THREADS=4). The same tests ran with the same limits. Four earlier runs at full parallelism on this 8-core workstation each failed on a different load-bound test: timeouts of 0.5 s, 1 s or 10 s, and the two Wardley validation benches. No assertion failed. Every one of those tests passes when run alone, the viewer spec 25/25 andsvg-importin 18 ms.Host follow-ups
These are information for the host sessions only; nothing here changes the host.
@formicoidea/*package to 3.5.0;viewExtensions, which carries the framework providers and the link-preview and image-proxy seams;onLinkClick, and takeCommunityCanvasTextFontsfrom@labre/affine/canvas-viewer;img-src blob:to the CSP (PO accepted);buildMindmapwith Poppins/Kalam width tables.openIconPickerfor the workspace icon.🤖 Generated with Claude Code