feat(openapi): type rich text field value — spec, aliases, naming - #710
Conversation
Expands richtext-field-value.yaml from a loose type: object into a fully discriminated schema with $defs for all 17 node types and 12 mark types, mirroring richtext-attrs.ts. - overlay.openapi.yaml: add RichTextNode and RichTextMark as top-level schema refs so they are emitted as named types - aliases.ts: register RichtextDoc, RichTextNode, RichTextMark aliases - index.ts: fix copyWrapperTemplates to skip writing the empty types/_sources.ts when no wrapper templates are requested - richtext-field-value.yaml: BlokNode body items reference block-content.yaml instead of an inline duplicate schema Fixes DX-487
Expands richtext-field-value.yaml from a loose type: object into a fully discriminated schema with $defs for all 17 node types and 12 mark types, mirroring richtext-attrs.ts. - overlay.openapi.yaml: add RichTextNode and RichTextMark as top-level schema refs so they are emitted as named types - aliases.ts: register RichTextDoc, RichTextNode, RichTextMark aliases - index.ts: fix copyWrapperTemplates to skip writing the empty types/_sources.ts when no wrapper templates are requested - richtext-field-value.yaml: BlockNode body items reference block-content.yaml instead of an inline duplicate schema Naming: use RichText (not Richtext) for all type names and Block (not Blok) for the embedded component node type. Wire values (enum: richtext, enum: blok) are unchanged as they are API contract values. Fixes DX-487
Type names keep RichText (PascalCase). In description strings, use 'Rich text' at sentence start and 'rich text' mid-sentence. Wire values (enum: richtext, toggle-richtext) are unchanged. Fixes DX-487
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 848fae8. Configure here.
…TextNode to known types
@storyblok/angular
@storyblok/astro
@storyblok/api-client
storyblok
@storyblok/eslint-config
@storyblok/experiments
@storyblok/js
storyblok-js-client
@storyblok/live-preview
@storyblok/management-api-client
@storyblok/migrations
@storyblok/nuxt
@storyblok/react
@storyblok/region-helper
@storyblok/richtext
@storyblok/schema
@storyblok/svelte
@storyblok/vue
commit: |
…compat RichtextFieldValue is renamed to RichTextFieldValue in this PR. To avoid breaking consumer packages that already import the old name, export a deprecated type alias from the field template so each package can migrate at its own pace. - templates/field.ts: export `RichtextFieldValue = RichTextFieldValue` with @deprecated JSDoc - src/templates.ts: register RichtextFieldValue in the field template's provides list Fixes DX-487
…r correct casing Fixes RichtextFieldValue* type prefix to RichTextFieldValue* (PascalCase). Fixes DX-487
An empty paragraph emitted by the editor is just {"type": "paragraph"}
with no attrs or content. Requiring attrs caused schema validation to
fail for that case.
Fixes DX-487
|
- Add optional dir (ltr | rtl | null) to paragraph, heading, blockquote, list_item, and code_block nodes - Make meta_data properties optional and allow custom additionalProperties (string | null) - Make HighlightMark color nullable - Make ImageNode src nullable Fixes DX-487
Should we do this in this PR? |
…rd-compat aliases - Regenerate src/generated with RichTextFieldValue (new canonical name) - scripts/generate.ts: update include list entry to RichTextFieldValue - helpers/define-field.ts: re-export RichTextFieldValue alongside deprecated RichtextFieldValue - src/index.ts: export RichTextFieldValue (new) alongside kept RichtextFieldValue - validators/internal-schemas.ts: import zRichTextFieldValue; export deprecated zRichtextFieldValue alias - validators/validate-story.ts: use zRichTextFieldValue internally - validators/validate-story.test.ts: add _uid to richtext embedded blok fixtures (required by tightened zBlockContentRoot) Fixes DX-487
- Regenerate src/generated with RichTextFieldValue (new canonical name) - resources/stories.ts: update internal import to RichTextFieldValue Fixes DX-487
…ackward-compat alias - Regenerate src/generated with RichTextFieldValue (new canonical name) - src/index.ts: export RichTextFieldValue (new) alongside kept deprecated RichtextFieldValue Fixes DX-487
…textFieldValue Fixes DX-487
|
Yes, absolutely! |
… make link custom attr nullable - BlockNode.body items now reference block-content-input.yaml so _uid is optional when writing richtext content with embedded bloks - LinkMark attrs.custom changed to type [object, 'null'] to correctly reflect that the field may be null

Summary
Extracts the
tools/openapi-codegenchanges from #684 into a standalone PR so the spec work can be reviewed and merged independently.Changes
tools/openapi-codegenSpec (
specs/)richtext-field-value.yaml— expanded from a loosetype: objectinto a fully discriminated schema with$defsfor all 17 node types and 12 mark typesBlockNode.attrs.bodyitems reference../block-content.yaml(canonical definition) instead of an inline duplicateoverlay.openapi.yaml— addedRichTextNodeandRichTextMarkas top-level schema refs so they are emitted as named types; renamedRichtextFieldValue→RichTextFieldValuemapi/components/field-types/richtext-field.yaml— description updated to follow naming conventionsSource (
src/)aliases.ts— registeredRichTextDoc,RichTextNode,RichTextMark; updatedRichtextFieldValue→RichTextFieldValueindex.ts— fixedcopyWrapperTemplatesto skip writing the emptytypes/_sources.tswhen no wrapper templates are requestedknown-types.ts,templates.ts— updatedRichtextFieldValue→RichTextFieldValue; registeredRichtextFieldValueinprovidesfor backward compatTemplates (
templates/)field.ts— updated import/export/map entry forRichTextFieldValue; added deprecatedRichtextFieldValuealiasBackward compatibility
RichtextFieldValuehas been renamed toRichTextFieldValue. To avoid breaking consumer packages all at once, the generatedfield.tsnow also exports:This means packages that currently import
RichtextFieldValue(mapi-client,schema,capi-client,migrations, etc.) will continue to compile after regeneration — TypeScript/editors will surface the@deprecatedwarning so each package can migrate at its own pace.Naming conventions applied
RichText(PascalCase)RichTextFieldValue,RichTextDocRich textRich text field type …rich text… rich text document …enum: [richtext],toggle-richtextBlocknotBlokBlockNodeFixes DX-487