Skip to content

fix: preserve node identity during type updates#1202

Closed
appflowy wants to merge 2 commits into
mainfrom
fix/preserve-node-type-identity-main
Closed

fix: preserve node identity during type updates#1202
appflowy wants to merge 2 commits into
mainfrom
fix/preserve-node-type-identity-main

Conversation

@appflowy

@appflowy appflowy commented May 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Small editor-only change to preserve node identity during safe block type conversions.

Scope is intentionally limited to appflowy-editor:

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

Related GitHub Issues

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.

Diff Size

  • 10 files changed
  • 299 insertions
  • 13 deletions
  • No desktop, Rust, web, vendored dependency, generated, or lockfile changes

Verification

  • dart format --output=none --set-exit-if-changed ...
  • git diff --check origin/main...HEAD

Could not run targeted Flutter tests locally because this machine uses Flutter 3.27.4 while current main requires Flutter >=3.32.0 / .fvmrc specifies 3.38.5:

Because appflowy_editor requires Flutter SDK version >=3.32.0, version solving failed.

@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.

@codecov

codecov Bot commented May 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.17857% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.44%. Comparing base (6fbe7ba) to head (94c2b97).

Files with missing lines Patch % Lines
lib/src/core/transform/operation.dart 85.41% 7 Missing ⚠️
lib/src/core/document/node.dart 50.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1202      +/-   ##
==========================================
+ Coverage   72.33%   72.44%   +0.11%     
==========================================
  Files         324      324              
  Lines       15900    16003     +103     
==========================================
+ Hits        11501    11594      +93     
- Misses       4399     4409      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@appflowy appflowy closed this May 10, 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