Skip to content

feat(toolbar): list the document's fonts with a support status#3673

Draft
caio-pizzol wants to merge 3 commits into
mainfrom
caio-pizzol/document-font-options
Draft

feat(toolbar): list the document's fonts with a support status#3673
caio-pizzol wants to merge 3 commits into
mainfrom
caio-pizzol/document-font-options

Conversation

@caio-pizzol
Copy link
Copy Markdown
Contributor

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.

  • The status is derived per font by combining the runtime face report (does the document render this with a real, embedded, or clone face?) with the published substitution evidence (is an open substitute pending an asset, customer-supplied, or preserve-only?). It is a user-facing summary, deliberately not the evidence internals.
  • A family's status is the worst across the faces the document uses, so a family with a faithful Regular but an unsubstitutable Bold is not advertised as fully available.
  • The dropdown rebuilds on fonts-changed and on active-editor change, since fonts resolve asynchronously after a document opens. A signature guard skips the rebuild when the options did not actually change.
  • A consumer-provided fonts config is left untouched.

New public read API: superdoc.fonts.getDocumentFontOptions().

Must stay the same: consumer fonts config returned unchanged; dropdown label/key stay 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

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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';
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@caio-pizzol caio-pizzol marked this pull request as draft June 6, 2026 02:25
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-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

2 participants