Commit Graph
15 Commits
Author SHA1 Message Date
DarkSky f7dc193f9d feat(editor): unify ToolbarChrome, tooltips, page block toolbars, and table hover controls
Extract shared ToolbarChrome, Tooltip, and HoverController (500ms enter / 250ms leave with hover bridge) under blocksuite-editor overlays.

Align FormatToolbar (Turn into current-block icon and selected row, Align dropdown, score-ordered inline actions, dual-section vertical Highlight list, Create Table, More), Image inner top-right hover/selected toolbar with all four corner resize handles, Bookmark/LinkedDoc/SyncedDoc/ExternalEmbed/Callout toolbars (single-click select, double-click open), Link/Reference hover popup above inline anchor with bridge and dropdowns, and desktop Simple Table hover add-bars (a press counts as a drag only after 4 px of travel along the bar's axis, a forward drag adds at least one row or column, and a drag back to the press point or away from the table adds nothing), three-dot axis pills, and 5px column resize handles.

Unify Page and canvas media downloads onto ImageStore's single set_on_blob_download host channel (with Web anchor fallback), and show the canvas Image and Attachment Download button only when ImageStore::can_deliver_downloads() is true and non-empty blob bytes are cached for that source_id.

Compute document math presence once per page and document revision (snapshot_has_math, memoized on BlockFlow) instead of walking the whole page on every layout, and include database titles, row titles, and rich-text cells in both the math check and the per-block preview fingerprint.

Route /pdf through the media slash path so that a host without a file picker keeps the typed /pdf text, the same as /attachment.
2026-12-01 19:26:55 +09:00
DarkSky 2144304032 perf(preview): keep PDF documents open in the worker by docId
The preview workers now use a linear-memory ABI with four exports:
`memory`, `prepare(len)`, `invoke()` and `output_ptr()`. The host writes
each request into worker memory in one copy and copies each response out in
one copy. The old ABI called an export for every 4 bytes in each direction.

Rust gives out only the addresses of its own buffers, so the crate keeps
`forbid(unsafe_code)`. Buffers larger than 1 MiB go back to the allocator
after each request.

The PDF worker keeps each parsed document under a `docId` that the host
assigns. The frames are `PDF_OPEN`, `PDF_RENDER` and `PDF_CLOSE`.

The bytes of a document go to the worker once per open, not once per page.
Page pixels come back as a compact RGBA buffer that the worker transfers.

The playground bridge has one session table in `wasm_pdf_state.rs`. It
opens at most 8 documents or 256 MiB of source bytes.

To make room, the table closes least recently used idle documents, but only
when that makes the new document fit. Empty documents and documents larger
than 256 MiB never go to the worker.

The table closes a document when the view clears the last scope that used
it, also when no page request claimed it yet. A reopen that fails after a
worker restart keeps the known page count.

The table restarts the worker before the IDs run out.

The bridge no longer keeps 16 copies of PDF bytes.

Each worker event listener ignores events from a replaced worker, so a late
error of an old worker cannot stop the new one. A crash answers each sent
request once, so the count of unanswered requests stays exact.

`pdf-client.js` uses the same protocol and keeps its public methods. It
keeps the same open budget and waits for room before it sends an open.

New bytes for a known `docKey` now open a new document and drop the old
page count and pages. Before, the client returned the old page count.

Four snapshot IDs of the PDF viewer and the attachment toolbar use
`format_args!`, so the production bundle has no copy of their prefixes. The
prefix gate now checks 14 prefixes.
2026-12-01 18:55:10 +09:00
DarkSky 88343a5303 test(web,ci): verify legacy workspace readiness and guard wasm snapshot prefixes
Replace the interactive control check in the dual-shell verifier with a legacy workspace readiness check for @affine/mobile 0.27.5.

The verifier requires a valid workspace document route and a visible editor container with a mounted editor host.
It also requires the legacy shell cookie and no synthetic legacy shell object.
One page check covers these conditions, and it uses the same route parser as Node.
The verifier runs this page check again after each IndexedDB read and before it returns.
A shell that leaves the document route or unmounts the editor before it stores data fails.

The verifier loads yjs on demand so Node tests run without installed packages.
It reads only target document records from local IndexedDB and verifies root catalog and page block state.
Rows must agree with the nbstore schema, and the updates store must have its docId index.
When a fresh profile stops at the workspace home route, it reads one document ID from the catalog.
It then locks that workspace and document and navigates once to the document route.
A redirect to a different document fails the check.

The legacy CLI path now reopens the mounted document in a new tab of the same Chromium profile.
That tab blocks the welcome template, so the shell must load the workspace from IndexedDB.
The local workspace database count must stay the same.
A server that cannot serve the document route directly fails the check.
Limit Chromium browser test file concurrency to two in CI so three browser suites do not overload four runner CPUs during SwiftShader startup.

Add a zero-dependency Node script that scans WebAssembly Section 11 data segments for eleven harness snapshot ID prefixes.
The script also scans Rust sources under blocksuite/crates to confirm that every watched prefix stays active.
The source scan ignores test modules and their child modules.
Wire the source check into packages/frontend/scripts/check-invariants.sh.
Wire the binary check into .github/workflows/native-playground.yml after wasm-opt.
2026-12-01 14:42:28 +09:00
DarkSky 6f193694ba fix(web): serialize legacy document saves and share Chromium cleanup
Save the page and its catalog in one IndexedDB transaction.
Use the Chromium harness in four browser checks.
Use one 45-second DevTools handshake for the SwiftShader smoke tests.
Open each new page with one DevTools request.
Stop the process group if the browser exits before the handshake.
Use a short temporary directory if the socket path exceeds the limit.

Check the legacy control on two consecutive frames.
Report startup errors for --legacy-dir.
Wait for the OAuth configuration and provider render on /sign-in.
Run the browser regression tests in CI.
2026-12-01 11:11:27 +09:00
DarkSky 2b94d66b97 perf(editor): skip snapshot markers and reuse static icon strings 2026-12-01 08:22:39 +09:00
DarkSky c02056c82d feat(blocksuite): add inline popovers, block toolbars, and overlay polish
Add inline link and linked-doc 500ms hover popovers, dual-field text+link editing, and Inline/Card/Embed view conversion.

Extend the desktop format toolbar with inline equation, linked-doc creation, More submenu, and block-selection mounting.

Add block-level controls for code blocks (searchable language picker, line numbers, 8-line collapse), block/note LaTeX 2-step editing, image double-click lightbox, bookmark style toolbar, and callout 44px layout with emoji and 9-color toolbar.

Include targeted fixes:
- Flatten H4-H6 in touch Slash menus and hide scrolled-out desktop Slash preview cards.
- Allow Slash Copy in page_readonly mode.
- Preserve nested Y.Map background and readonly guard in Edgeless note slicer, guard locked mindmap descendants on delete, and skip dangling mindmap children.
- Consume click when dismissing active Calendar inline edit and restrict selected-day '+' visibility to touch form factors.
- Expand Page block_selection highlight to cover visible nested subtrees (skipping collapsed children) and align Move Up / Move Down icons in the block menu.
2026-11-30 18:18:41 +09:00
DarkSky 646d638354 fix(editor,hosts,web): resolve cold-start touch keyboard, link hit-testing, and collaborative unlink
- Track actual presented system keyboard inside MetalHostView.inputView, restore software keyboard on repeat prose taps after dismissal, honor iPadOS hardware Command shortcuts in Modifiers::secondary, and sync UITextInteraction mode synchronously across readonly/mode/form-factor transitions.

- Make mobile KeyboardToolbar visibility declarative on active selection so narrow-to-wide resize, selection clear, and Android cold start never leave a ghost bottom toolbar; deduct docked toolbar height in popover_viewport and forward iOS touches immediately when floating overlays are open.

- Re-validate LinkPopup against live document revisions and sub-ranges so concurrent partial title/text link edits survive Unlink, align full-width and adjacent-link hit-testing, update web-smoke link button geometry for the 11-item format toolbar, and harden preview-workers/sign-in redirect handling.
2026-11-29 07:35:58 +09:00
DarkSky 03736fe260 fix(editor,playground,ui): unify IME recomposition, ContentScope, touch gestures, and table navigation 2026-11-28 07:30:44 +09:00
DarkSky 4e66722b44 feat(mobile): mount native GPU BlockSuite editor in iOS and Android hosts
- Add orthogonal PointerKind, FormFactor, and EditorCapabilities matrix in blocksuite-editor, decoupling database_readonly from edgeless_readonly and enforcing page_readonly across command/toolbar paths
- Attach cross-platform CJK and emoji FontFallbacks to blocksuite-editor text runs so iOS CoreText and Android CosmicTextSystem render CJK and emoji glyphs cleanly
- Wire real WgpuRenderer and CosmicTextSystem into Android ANativeWindow via SwappableAtlas, deterministic ui::clock_now() dispatch_after timer draining, single-JNI UTF-16 reads, surrogate-pair composing alignment, requestCursorUpdates + Matrix CursorAnchorInfo, historical ACTION_MOVE samples, hardware keyboard/scroll forwarding, and zero shadow-buffer pollution
- Frame iOS MetalHostView and SelectionOverlayView inside safeAreaInsets, gate software keyboard responder on PlaygroundView::wants_software_keyboard and pan-slop tap detection, avoid double safe_bottom subtraction on KeyboardToolbar insets, prevent spurious UITextInputDelegate textWillChange/textDidChange echo during IME composition, yield hardware pressesBegan during marked text, and guard UIEditMenuInteraction with explicit actions
- Enable wgpu/cosmic-text for target_os = "android" in packages/ui/ui and add Linux fontconfig/freetype packages to np-mobile CI workflow
2026-11-28 06:11:09 +09:00
DarkSky f7150b2191 feat(blocksuite): add affine:database CRDT codec and Table/Kanban/Calendar views 2026-11-28 00:33:36 +09:00
DarkSky 3d7c480933 perf(preview,playground): drop unused wasm exports and serve validated web fonts statically
Gate wasm-bindgen worker exports per preview target, externalize the four bundled UI/script fonts from the web playground Wasm bundle into static web assets, and validate fetched font bytes through the text system's fontdb loader so empty or HTML fallback responses fail closed with usable-face checks.
2026-11-28 00:31:40 +09:00
DarkSky 8e0b345036 feat(editor): extract ui-tokens, ui-kit, and blocksuite-editor crates
Add the zero-dependency ui-tokens crate to export generated theme tokens,
icon definitions, and bundled font bytes without cross-tree include_bytes!
paths.

Add the domain-neutral ui-kit crate with logical geometry helpers, SafeArea,
VirtualList, SwipeDialog, and SwipeMenu state machines backed by scheduler
time and four-rate replay invariance tests.

Extract blocksuite-editor from playground with the WorkspaceDocDirectory
host port, exact substring UTF-16 highlight matching, and LTR/RTL logical
start/end block flow layout. Slim playground to the demo and harness host.
Update workspace manifests, static invariant guards, CI workflows, and
AGENTS.md files.
2026-11-27 06:55:47 +09:00
DarkSky d619bfbcda feat(preview): add pure-Rust offline preview kernel crate 2026-11-27 06:55:47 +09:00
DarkSky 0c9e634d08 feat(ui): add L0 mobile logical layout, bidi shaping, gestures, motion, web safe-area and iOS foundation
- Add logical geometry helpers on Edges, Corners, Svg, and scroll offsets, and propagate inherited LayoutDirection through Taffy and fast splice rebuilds with a zero-clone LTR fast path.
- Propagate explicit BaseDirection through LineLayoutCache and all platform shapers (Apple CoreText, CosmicText, and Web), sort visual clusters by x_start, add UAX #9 multi-line soft-wrap bidi reordering, preserve contextual Arabic joining across same-font runs, and align text truncation on shaped glyph-cluster boundaries (`UI_LOC_CEILING = 95200`).
- Add scheduler-clock TouchGestureRecognizer with tap, long-press timer wakeup, pan cancellation, pinch re-anchoring, and closed-form MotionCurve presets including SwipeMenu InOutSine and SwipeDialog cubic-bezier/outQuad.
- Replace Web four-element safe-area probing with a single hidden probe and exact per-edge float comparison, preserving non-double-subtracted IME insets.
- Align the iOS platform stub traits and PlatformInfo, update packages/ui/AGENTS.md, and add aarch64-apple-ios and aarch64-apple-ios-sim compile guards to native-playground CI.
2026-11-27 06:55:47 +09:00
DarkSky 6f9f1cace5 refactor(workspace): dissolve native-playground into domain directories 2026-11-27 06:55:47 +09:00