Skip to content

feat(editor): default-on toolbar + controlled typography + fidelity fixes (wiki-v2 #135) - #9

Merged
PMQ9 merged 4 commits into
wiki-v2from
feat/editor-ux-wysiwyg-135
Sep 2, 2026
Merged

PMQ9 merged 4 commits into
wiki-v2from
feat/editor-ux-wysiwyg-135

Conversation

@PMQ9

@PMQ9 PMQ9 commented Sep 2, 2026

Copy link
Copy Markdown

Fork half of wiki-v2 issue docmost#135 (editor WYSIWYG UX). Parent PR bumps the submodule to this branch.

Keeps the stock Docmost fixed toolbar and polishes it in place — no parallel toolbar. All genuinely-new code lives in three new boundary-excluded fork dirs (apps/client/src/features/editor-ux/, packages/editor-ext/src/lib/ccc/, apps/server/src/editor-compat/); every upstream edit is minimal and documented in the parent's UPSTREAM_MODIFICATIONS.md (#51–#63).

Highlights

  • Toolbar ON by default (shared resolveEditorToolbarPref helper; explicit opt-out honored; no migration).
  • Controlled font size (14/16/18/20) + font family (Default/Serif/Monospace) as allowlist-gated attributes on the existing textStyle mark — registered on both client and server schemas in lockstep (closes the "server strips unknown textStyle attrs" trap).
  • Toolbar Link button (missing before), strikethrough surfaced, highlight relabeled, roving-tabindex a11y, 44px touch targets, brand active state, print + responsive fixes.
  • Internal copy/paste preserves formatting; blank-page placeholder fixed; link-panel open-timing bug fixed.

Tests

  • Server apps/server/src/editor-compat/ (9): schema + ydoc round-trip, render-path allowlist gate, text_content invariance, Markdown degradation, legacy fixture.
  • Client Vitest +29 (129 total): pref truth-table, real-Editor font commands + gate, allowlist, paste sanitizer, link word-selection.
  • tsc --noEmit clean; editor-ext + server build clean.

Browser-validated (desktop + phone × light/dark). Fidelity policy in parent ADR 0012.

🤖 Generated with Claude Code

PMQ9 and others added 4 commits September 2, 2026 15:51
…eholder fixes (docmost#135)

Keep the stock Docmost fixed toolbar and polish it in place (no new toolbar):
turn it ON by default, add a Link button, controlled font size (14/16/18/20)
and a Default/Serif/Monospace family selector, surface strikethrough, improve
highlight discoverability, add roving-tabindex a11y, 44px touch targets, brand
active state, print + responsive fixes.

Typography is allowlist-gated attributes on the existing textStyle mark
(CccFontSize/CccFontFamily), registered on BOTH the client and server schemas
so the schema-bound server paths no longer strip them. Internal ProseMirror
copy/paste now preserves formatting; a fork placeholder shows on empty
unfocused pages. All genuinely-new code lives in fork-owned excluded dirs
(features/editor-ux/, packages/editor-ext/src/lib/ccc/, editor-compat/);
upstream edits are minimal seams documented as UPSTREAM_MODIFICATIONS #51-#62.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ocmost#135)

Sync EditorLinkMenu's showLinkMenu ref during render so the panel's shouldShow
sees the correct value on first evaluation (was racy / never opened from a
programmatic trigger). Extract the toolbar Link word-selection into a tested
fork helper. Browser-validated end-to-end.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…, roving stability, tests (docmost#135)

Round-justifying (Priority Level 3+) findings from the 7-lens review of
PR docmost#146 / docmost#9:

- Frontend + Correctness (L3): the toolbar Link button on an empty caret
  inserted a literal "link" word that stayed behind if the panel was
  dismissed without a URL. `ensureLinkableSelection` now returns the
  placeholder range; `LinkGroup` removes it on a cancelled panel (no link
  mark applied), keeping applied-link behavior unchanged.
- Architecture (L3): `scale.ts` hand-duplicated the size scale in
  `PX_BY_SIZE`; derive it from the single-source `ALLOWED_FONT_SIZES` +
  the Normal (16px) anchor, sorted ascending to preserve the tested
  round-toward-smaller tie-break.
- Testing (L3 x3): added tests for `collectTextStyleAttr` (incl. the
  "mixed" multi-value branch), `ensureLinkableSelection`'s link-active
  branch (with a real Link mark), and a raw-attr render-gate bypass for
  fontFamily — symmetric with the existing fontSize gate test, on both
  client and server.

Opportunistic (converged L2, same files): stabilize `useRovingToolbar`'s
`onExit` via a ref so the effect no longer tears down listeners and resets
the roving tab stop on every toolbar re-render; correct a stale "Mixed"
docstring in `FontSizeGroup`.

Client vitest 33/33, server editor-compat jest 10/10, client tsc clean.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ocmost#135 review r2)

Round-2 re-review surfaced two Priority Level 3 findings, both from the
round-1 cancel-cleanup path:

- Correctness (L3): `LinkGroup` stored the placeholder's absolute
  `{from,to}` at panel-open and fed them UNMAPPED into `deleteRange` at
  panel-close. Safe single-user, but in the Yjs/Hocuspocus collaborative
  editor a concurrent remote edit before the placeholder could make the
  range stale → delete the wrong content, miss the placeholder, or throw
  a Position-out-of-range RangeError. Now the range is mapped through
  every transaction (local + remote) via `editor.on("transaction")`, and
  the delete is gated by a new pure `shouldRemovePlaceholder(editor,
  range)` helper that only approves an in-bounds range still holding
  exactly the placeholder text with no link mark — so a stale/rewritten
  range is left untouched instead of mis-deleting.

- Testing (L3): the `placeholder: null` return invariant (which guards
  that destructive delete) was asserted on only 2 of 4 branches. Added
  assertions on the word-at-caret and keep-selection branches, plus four
  `shouldRemovePlaceholder` unit tests (intact / linked / rewritten /
  out-of-range) — which also gives the previously-untested cleanup
  decision direct coverage.

Extracting the decision into `shouldRemovePlaceholder` also resolves the
round-2 Architecture L2 (helper extraction) and Testing L2 (untested
cleanup logic).

Client vitest 37/37, client tsc clean.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@PMQ9
PMQ9 merged commit a821c11 into wiki-v2 Sep 2, 2026
@PMQ9
PMQ9 deleted the feat/editor-ux-wysiwyg-135 branch September 2, 2026 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant