feat(toolbar): list the document's fonts with a support status#3673
feat(toolbar): list the document's fonts with a support status#3673caio-pizzol wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d54bd43cea
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const signature = this.#fontOptionsSignature(); | ||
| if (signature !== this._lastFontOptionsSignature) { | ||
| this._lastFontOptionsSignature = signature; | ||
| this.#rebuildToolbarItems(); // the document's fonts/statuses changed -> rebuild the dropdown options |
There was a problem hiding this comment.
Notify Vue after rebuilding font items
When fonts-changed fires after the toolbar is mounted, this rebuilds this.toolbarItems but does not update any reactive state that Toolbar.vue tracks; the mounted component only forces a re-render by incrementing toolbarKey in its resize path, so the rendered ButtonGroup keeps the old font dropdown until an unrelated resize/remount happens. In the normal async font-resolution path, the new document fonts and support labels therefore never appear in the visible toolbar even though the backing array was replaced.
Useful? React with 👍 / 👎.
| export type { FontFaceConfig } from '@superdoc/super-editor'; | ||
| export type { FontFamilyConfig } from '@superdoc/super-editor'; | ||
| export type { FontResolutionRecord } from '@superdoc/super-editor'; | ||
| export type { DocumentFontOption, FontSupportStatus } from '@superdoc/super-editor'; |
There was a problem hiding this comment.
Add classification rows for new root types
This adds two new superdoc root exports, but the required tests/consumer-typecheck/snapshots/superdoc-root-classification.json update is missing; packages/superdoc/AGENTS.md says every root-surface change must update that snapshot, and I searched it for both DocumentFontOption and FontSupportStatus and found neither. As a result the public-surface checks/audits treat these symbols as unclassified (unknown-root-export/skipped), so the root contract has no bucket or rationale for the new API.
Useful? React with 👍 / 👎.
Rebuilt toolbarItems/overflowItems are plain instance fields, not a Vue reactive source, so swapping them on fonts-changed or active-editor change did not reach the mounted Toolbar.vue; the toolbar stayed on the initial disabled items until a resize bumped the render key. SuperToolbar now emits toolbar-items-changed on rebuild and Toolbar.vue bumps toolbarKey to re-read.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
The font dropdown now shows every font the open document actually uses, not just the five bundled defaults, so you can pick a font the document already references. Each non-default font carries a short support status (Fallback, Pending font, Needs font, Preserve only) so a font SuperDoc cannot render faithfully never reads as a clean default; a faithfully-rendered font shows no status at all.
fontsconfig is left untouched.New public read API:
superdoc.fonts.getDocumentFontOptions().Must stay the same: consumer
fontsconfig returned unchanged; dropdownlabel/keystay the pure logical family (active-state matching + the stored and exported value).Review: the status mapping in document-font-options.ts (runtime reason + evidence kind to user-facing status). The snapshot diff is mechanical (the two new public type exports).
Verified: pnpm check:types -> 0; pnpm check:public:superdoc -> PASS 14 stages; snapshot --check -> 0