2.0.0
Kontent.ai Rich Text Resolver 2.0.0
New version of the primary tool for Kontent.ai rich text resolution in JS/TS-based frameworks, including more accurate typing, reworked transformation logic with focus on streamlining migration of external rich text and HTML and performance improvements.
Changes
Since the deprecation of rich text resolution built into the JS SDK, this package has become the primary solution for resolving rich text. To align with familiar naming conventions, a large number of types, properties and functions have been renamed. Some methods were removed altogether, while others have updated signatures. See changes below.
Note
Changes marked with 
Changes marked with ℹ️ are non-breaking
Functions
- ⚠️ - transformToPortableText– updated signature. previously accepted a- ParseResultobject from either- nodeParseor- browserParsefunctions. Now accepts- stringrepresentation of the rich text HTML. Parsing happens internally and is environment-aware (Node.js vs browser).
- ⚠️ - nodeParse,- browserParse– removed in favor of- parseHTML, which picks a correct parser based on the environment it's called from. The result is now directly- DomNode[]rather than- ParseResult, which contained the resulting- DomNodearray in a nested- childrenproperty.
- ⚠️ - transformToJson– removed. See reworked transformation entry below.
Types
- 
⚠️ PortableTextComponentrenamed →PortableTextComponentOrItem- ⚠️ - _typeliteral changed to- componentOrItem
- ⚠️ - componentproperty renamed to- componentOrItem
 
- 
⚠️ PortableTextInternalLinkrenamed →PortableTextItemLink- ⚠️ - referenceproperty renamed to- contentItemLink
 
- 
PortableTextTable- ⚠️ - numColumnsproperty removed
 
- 
PortableTextTableCell- ⚠️ - childBlocksCountproperty removed
 
- 
Reference,AssetReference- ℹ️ added a referenceTypeproperty, informing whether the value referencescodename,idorexternal-id
 
- ℹ️ added a 
- 
⚠️ ParseResult– removed,parseHTMLfunction now returns directlyDomNode[]
- 
⚠️ ResolveDomTextNodeType,ResolveDomHtmlNodeType,TransformDomNodeType– removed
Features
Reworked HTML parsing and transformation (formerly JSON)
Parsing has been unified under a new, environment-aware (Node.js and browser) parseHTML function. The result is now directly a DomNode array, which can be transformed and composed back to HTML using new nodesToHTML and nodesToHTMLAsync functions.
The revamped logic is specifically tailored for transforming external rich text and HTML in order to make it compatible with Kontent.ai rich text format. See dedicated transformer documentation for details.
More accurate resolution types
Resolution to React and HTML has been improved by addition of modified types from the respective external packages. The new types (PortableTextReactResolvers and PortableTextHtmlResolvers respectively) now natively support custom Kontent.ai portable text objects without the need for explicit typing.
Default resolution improvements for HTML and React
<PortableText> component and toHTML functions from respective external packages have been modified and re-exported from the module itself. They now provide default fallback for resolution of tables, images, URL links and previously unsupported sub and sup tags, without the need to specify transformations for them explicitly. Existing helper functions (such as resolveImage and resolveTable) remain unchanged, but no longer have to be used, as the process will supply them automatically, if no custom resolution was provided.
Reworked internal portable text transformation logic
The transformation logic from DomNode[] to Portable Text has been simplified and optimized, removing some redundancy and lowering the number of recursive traversals, which may result in slight performance gain with large HTML inputs.
Pull requests
Full Changelog: 1.2.2...2.0.0