Skip to content

1.0.0

Compare
Choose a tag to compare
@pokornyd pokornyd released this 12 Jan 13:35
· 37 commits to main since this release

Rich Text Resolver v1.0.0 release

No longer in beta, v1 release brings several new features as well as a number of breaking changes that need to be addressed for a successful upgrade.

Breaking changes

Types and interfaces

  • all types are now pulled from @portabletext/types package
    • IPortableTextBaseItem removed, all custom block types extend from ArbitraryTypedObject instead
    • IPortableTextParagraph removed, replaced with PortableTextStrictBlock
    • IPortableTextListBlock removed, replaced with PortableTextStrictListItemBlock
  • IOutputResult is now ParseResult
  • IPortableTextItem is now called PortableTextItem, a union of two types:
    • PortableTextObject represents all top-level block types returned from the transform method
    • PortableTextInternalObject represents nested portable text objects (references, marks etc.)
  • all interfaces and types with capital I prefix were renamed without it

Methods

  • transformToPortableText method now returns PortableTextObject
  • resolveTable now has two implementations, one for HTML and one for Vue, each in a corresponding util file

New features

Extending/modifying portable text blocks

A new traversePortableText method goes through the whole subtree of a portable text object and applies a user-defined callback function on each node, allowing you to modify its properties or extend it with new ones. Readme

Default resolution

  • resolveImage method added for HTML and Vue, allowing you to resolve custom image _type blocks with your own resolution method or a default one (toHTMLImageDefault and toVueImageDefault respectively)
  • resolveTable method reimplemented for HTML and Vue separately

Misc

  • added missing type definitions, updated readme with properly typed examples
  • added JSDoc comments to a large number of methods and types
  • updated suggested Vue resolution package, added an example and related tests
  • updated most of the dependencies
  • TS: Module and ModuleResolution set to NodeNext
  • minor changes to transformation logic

What's Changed

Full Changelog: 0.0.5...1.0.0