Skip to content

Releases: datocms/structured-text

datocms-structured-text-utils@5.1.3

20 Sep 13:56

Choose a tag to compare

Added

  • Tree Visualization with Inspector: Added powerful tree visualization utility that renders structured text documents as ASCII trees for debugging and development:
    • inspect function renders documents or nodes as ASCII trees with clear hierarchical structure
    • Support for custom block formatting to display rich information about embedded content
    • Configurable output with options for block and inline block formatters
    • Perfect for debugging document structure during development
    • Visual representation shows node types, attributes, marks, and content in an easy-to-read format

datocms-structured-text-utils@5.1.0

05 Sep 11:32

Choose a tag to compare

Added

  • New Tree Manipulation Utilities: Added comprehensive tree manipulation utilities with support for:
    • forEachNode and forEachNodeAsync - Visit all nodes in the structured text tree
    • mapNodes and mapNodesAsync - Transform nodes while preserving tree structure
    • collectNodes and collectNodesAsync - Collect all nodes matching a predicate
    • findFirstNode and findFirstNodeAsync - Find the first node matching a predicate
    • filterNodes and filterNodesAsync - Remove nodes that don't match a predicate
    • reduceNodes and reduceNodesAsync - Reduce tree to single value
    • someNode and someNodeAsync - Check if any node matches predicate
    • everyNode and everyNodeAsync - Check if all nodes match predicate
    • All functions support both synchronous and asynchronous operation
    • Full TypeScript support with proper type narrowing for type guards
    • Comprehensive test coverage in packages/utils/__tests__/manipulation.test.ts

Changed

  • Type System Improvements: Enhanced type definitions:

    • Added generic BlockItemType parameter to node types (defaults to BlockId = string)
    • All node type guards now support generic block item types
    • Added isCdaStructuredTextValue function as replacement for isStructuredText
  • API Deprecations and Migrations:

    • StructuredText type is now deprecated in favor of CdaStructuredTextValue
    • isStructuredText function is now deprecated in favor of isCdaStructuredTextValue
    • TypesafeStructuredText type is now deprecated in favor of TypesafeCdaStructuredTextValue