feat(examples): vanilla custom UI toolbar example (SD-2929)#3128
Closed
caio-pizzol wants to merge 2 commits intomainfrom
Closed
feat(examples): vanilla custom UI toolbar example (SD-2929)#3128caio-pizzol wants to merge 2 commits intomainfrom
caio-pizzol wants to merge 2 commits intomainfrom
Conversation
This was referenced May 4, 2026
First focused minimal example under examples/editor/custom-ui/.
Single file (~99 lines) demonstrating the cleaned-up controller
surface from SD-2917 / SD-2918 / SD-2919 / SD-2920:
- createSuperDocUI({ superdoc }) accepts the SuperDoc instance
directly. No cast.
- ui.createScope() collects every subscription, custom command
registration, and DOM listener; ui.destroy() cascades into every
scope so consumers tear everything down with one call.
- Per-command observe(state => ...) so each button only re-renders
when its own command flips, matching the React useSuperDocCommand
pattern.
- BUILT_IN_COMMAND_IDS, ui.commands.has(id), and ui.commands.require(id)
validate a config-driven button list at startup so a typo cannot
ship silently.
- One custom command via scope.register(...), auto-unregistered on
scope teardown.
Also surfaced and fixed: PublicToolbarItemId was added to the runtime
exports of superdoc/ui (SD-2920) but never re-exported as a type from
the public sub-entry. This commit threads it through
super-editor/src/ui/index.ts and superdoc/src/ui.d.ts so consumers
can type their config arrays without dipping into the
headless-toolbar entry.
Wired into examples/manifest.json and a new custom-ui CI smoke job.
Stacked on caio/sd-2928-examples-demos-reorg until #3127 merges.
…d pnpm-setup to custom-ui CI
The earlier change in this PR added `type PublicToolbarItemId` to
the consumer-facing `superdoc/ui` re-export list (packages/superdoc/
src/ui.d.ts) but never landed the corresponding source export in the
inner barrel at packages/super-editor/src/ui/index.ts. With
`skipLibCheck: true`, TypeScript silently masked the broken
re-export; consumers writing `import type { PublicToolbarItemId }
from 'superdoc/ui'` would still pass typecheck against the dist but
would fail without skipLibCheck (and would not actually resolve to
the typed union when chased through). Add the missing source export
so the chain is real.
The new custom-ui CI matrix job restores the workspace cache and
invokes the smoke test, but does not run pnpm/action-setup. The
example's package.json predev hook calls `pnpm --filter superdoc
build`, and the playwright config falls back to `pnpm --dir <example>
run dev` when the example has no local node_modules (pnpm-hoisted
layout). Both require pnpm on PATH. Add pnpm setup so the smoke test
can launch its dev server.
8267653 to
567d5db
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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: The |
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.
First focused minimal example under `examples/editor/custom-ui/`. Single file, ~99 lines, demonstrates the cleaned-up controller surface from SD-2917 / SD-2918 / SD-2919 / SD-2920:
Also threads `PublicToolbarItemId` through the public `superdoc/ui` sub-entry. SD-2920 exposed `BUILT_IN_COMMAND_IDS` at runtime but missed the derived type, so consumers had to dip into `superdoc/headless-toolbar` to type a config array. Fixed.
Verified: `pnpm --filter superdoc build` clean; `tsc --noEmit` clean in the new example.