Skip to content

feat(examples): vanilla custom UI comments example (SD-2929)#3130

Closed
caio-pizzol wants to merge 1 commit intocaio/sd-2929-vanilla-custom-ui-toolbarfrom
caio/sd-2929-vanilla-custom-ui-comments
Closed

feat(examples): vanilla custom UI comments example (SD-2929)#3130
caio-pizzol wants to merge 1 commit intocaio/sd-2929-vanilla-custom-ui-toolbarfrom
caio/sd-2929-vanilla-custom-ui-comments

Conversation

@caio-pizzol
Copy link
Copy Markdown
Contributor

Second focused minimal example under `examples/editor/custom-ui/`. Single file (~125 lines) demonstrating the comments composer pattern that the controller surfaces specifically solve.

The load-bearing piece is `ui.selection.capture()`: the user clicks "Add comment", the textarea takes focus, the editor's live selection visually clears. A composer that read the live selection at submit time would refuse the create. `capture()` returns a frozen snapshot at composer-open time, and `ui.comments.createFromCapture(capture, { text })` anchors against that snapshot regardless of where focus has moved.

The list renders from `ui.comments.observe(snapshot => ...)`: one subscription, plain DOM. Resolve / reopen / reply route through `ui.comments.*` and end up in the same Document API that powers DOCX import/export, so changes here round-trip through Word.

Verified: `pnpm --filter superdoc build` clean; `tsc --noEmit` clean in the new example.

@linear
Copy link
Copy Markdown

linear Bot commented May 4, 2026

@caio-pizzol caio-pizzol force-pushed the caio/sd-2929-vanilla-custom-ui-comments branch from 77021d4 to 6af174a Compare May 4, 2026 23:38
@caio-pizzol caio-pizzol force-pushed the caio/sd-2929-vanilla-custom-ui-toolbar branch from 8267653 to 567d5db Compare May 4, 2026 23:42
Second focused minimal example under examples/editor/custom-ui/.
Single file (~125 lines) demonstrating the comments composer pattern
that the controller surfaces specifically solve:

- ui.selection.capture() freezes the selection at the moment the
  composer opens. The textarea then takes focus and the editor's
  live selection visually clears, but the captured snapshot still
  has the original anchor.
- ui.comments.createFromCapture(capture, { text }) anchors the new
  comment against that snapshot, not the live (now empty)
  selection. A composer that read the live selection at submit
  time would refuse the create.
- ui.comments.observe(snapshot => ...) renders the sidebar list
  from a single subscription.
- ui.comments.resolve / .reopen / .reply route through the same
  Document API that powers DOCX import / export, so changes here
  round-trip through Word.
- ui.createScope() collects every subscription so the whole surface
  tears down cleanly on ui.destroy().

Wired into examples/manifest.json and the custom-ui CI smoke matrix.
Stacked on caio/sd-2929-vanilla-custom-ui-toolbar.
@caio-pizzol caio-pizzol force-pushed the caio/sd-2929-vanilla-custom-ui-comments branch from 6af174a to a448478 Compare May 4, 2026 23:42
@caio-pizzol caio-pizzol closed this May 4, 2026
@caio-pizzol
Copy link
Copy Markdown
Contributor Author

Closing this for now after the Custom UI examples audit. We're going to keep examples docs-driven and concept-shaped, not surface-shaped. The next Custom UI examples should be focused vanilla examples linked from specific docs pages: selection-capture/vanilla first, then possibly configurable-toolbar/vanilla. Track changes stays inline / demo-only for now. Keeping the branch around for cherry-picking if useful.

The PublicToolbarItemId re-export fix that lived on this stack has been split out as #3135 so it can land independent of the examples conversation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant