fix: preserve node identity during type updates#1203
Merged
LucasXu0 merged 5 commits intoJun 12, 2026
Conversation
|
|
Collaborator
Author
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
Small editor-only change to preserve node identity during safe block type conversions.
Scope is intentionally limited to
appflowy-editor:UpdateNodeTypeOperationfor same-node type/data updates.Transaction.updateNodeTypeandDocument.updateNodeType.Node.copyWithto preserve ids only when explicitly requested.diffDocuments/EditorState.Related GitHub Issues
Failed to apply update: block parent ... Type: 8.Type: 8document-open failure on Linux.Why
The old markdown conversion path replaced a block with insert+delete even when only the block type changed. That regenerated node ids and made downstream clients treat a type conversion as a structural replacement. Desktop/web integration can use this operation to preserve block identity instead.
The user-reported historical context from AppFlowy PR #6516 was also checked before adding coverage. That earlier fix showed two important constraints:
Test Coverage
Core operation/document coverage:
UpdateNodeTypeOperationserialization, inversion, copy, equality, and hash consistency.Document.updateNodeType/Transaction.updateNodeTypepreserve node id, children, external values, and metadata.diffDocumentsemitsUpdateNodeTypeOperationfor same-id type changes.UpdateNodeTypeOperation.nodeIdinstead of mutating the wrong path.nodeIdtargets are skipped instead of applying to a stale path.UpdateNodeTypeOperationpreserves parent and child ids.Markdown conversion coverage:
paragraph -> headingpreserves node id through undo/redo.todo_list -> numbered_listpreserves parent and child ids through undo/redo.numbered_list -> headingflattens children into siblings.bulleted_list -> headingflattening behavior remains covered.Diff Size
Verification
dart format --output=none --set-exit-if-changed ...git diff --checkflutter test test/core/transform/operation_test.dart test/core/transform/transaction_test.dart test/new/block_component/heading_block_component/heading_character_shortcut_test.dart test/new/block_component/numbered_list_block_component/numbered_list_character_shortcut_test.dart