Skip to content

fix: preserve node identity during type updates#1201

Closed
appflowy wants to merge 1 commit into
chore/optimize-mobile-gesturefrom
fix/preserve-block-type-identity
Closed

fix: preserve node identity during type updates#1201
appflowy wants to merge 1 commit into
chore/optimize-mobile-gesturefrom
fix/preserve-block-type-identity

Conversation

@appflowy

@appflowy appflowy commented May 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Preserve editor node identity during safe block type conversions.

Changes:

  • Add UpdateNodeTypeOperation for same-node type/data updates.
  • Add Transaction.updateNodeType and Document.updateNodeType.
  • Preserve ids through Node.copyWith when explicitly requested.
  • Use in-place type updates for markdown shortcut conversions when descendant shape/content is unchanged.
  • Emit same-id type diffs from diffDocuments and apply them in EditorState.

Why

The previous markdown conversion path replaced a block with insert+delete. That regenerated block ids and related child/text references even when only the block type changed. Desktop and web now rely on same-id type updates to avoid shared block reference corruption.

Verification

  • dart format --output=none --set-exit-if-changed ...
  • Attempted flutter test test/core/transform/operation_test.dart test/core/document/diff_test.dart test/core/document/node_test.dart, but this machine has Flutter 3.27.4 while this package requires Flutter >=3.32.0.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@appflowy appflowy closed this May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants