Conversation
Added COMPONENT_ARRAY field type to handle structural changes in modular component arrays. This enables real-time preview updates when components are reordered, added, or deleted. Changes: - Added COMPONENT_ARRAY field type to FieldType union - Implemented updateComponentArrayField method in ContentUpdater - Uses morphdom for efficient DOM diffing when available - Preserves data attributes during array updates - Added comprehensive test coverage (8 new tests) Test coverage includes: - Component reordering detection - Component deletion detection - Component addition detection - Empty array handling - Component chain filtering - Data attribute preservation Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…andling **Component Array Updates:** - Add reorderComponentArray() method to handle drag-and-drop reordering - Support transformedValue field for flattened component data from Studio - Add COMPONENT_ARRAY field type to TypeScript types - Preserve React-rendered HTML structure during reordering **RichText Improvements:** - Support multi-format RichText objects (html, markdown, text, ast) - Add isRichTextFormats() helper to detect multi-format objects - Use HTML format for rendering in formatComponentValue() - Backwards compatible with legacy string formats **Framework Integration:** - Add logging for Next.js App Router vs Pages Router detection - Improve refresh() fallback handling - Add onRefresh config option for custom refresh handlers **Testing:** - Add comprehensive tests for component array operations - Test reordering, deletion, addition scenarios - Test component chain filtering This enables live preview updates for: - Component array reordering without full page refresh - RichText field edits within components - Component additions/deletions Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Wrap COMPONENT_ARRAY case block in curly braces to fix no-case-declarations - Replace 'any' types with proper TypeScript interfaces in FrameworkIntegration
- Fix tests to properly test DOM reordering (not rendering) - Pre-populate DOM elements with data-hygraph-component-chain attributes - Test actual reordering behavior (moving existing elements) - Handle empty arrays correctly (clear container) - Test deletion/addition scenarios realistically - All tests now passing
…nents When editing a newly created (unsaved) component in a union list, the Studio sends a synthetic instanceId that doesn't match the real CMS IDs in the DOM. Previously, findElements would fall back to updating ALL matching elements, corrupting every component in the list. Now the SDK distinguishes between: - Elements without chain attrs (backward compat → fall back to all) - Elements with chain attrs but no match (mismatch → skip update) Also removes the onRefresh call for new components in reorderComponentArray since the API doesn't have unsaved data anyway. Bumps version from 1.1.0 to 1.0.7. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The env.d.ts file was missing from git, causing tsc --noEmit to fail in CI while working locally (Vite injects the constant at build time). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for component array reordering and RichText multi-format handling to enable live preview updates without full page refresh.
Component Array Updates
reorderComponentArray()method for drag-and-drop reorderingtransformedValuefield for flattened component data from StudioCOMPONENT_ARRAYfield type to TypeScript typesdata-hygraph-component-chainattributesRichText Improvements
isRichTextFormats()helper to detect multi-format objectsformatComponentValue()Framework Integration
refresh()fallback handlingonRefreshconfig option for custom refresh handlersTesting
Breaking Changes
None - all changes are backwards compatible:
transformedValuefield is optional (falls back tonewValue)Enables
This enables live preview updates for:
Version
Bumped to v1.1.0 (minor) for new features.
Related PRs
🤖 Generated with Claude Code