Retain segments with undeletable links during model pruning#3380
Merged
Conversation
Keep segments that have link.format.undeletable set to true in pruneUnselectedModel, even when they are not selected. This prevents undeletable link segments from being lost during selection-based pruning. Add unit tests covering the new behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates pruneUnselectedModel to preserve segments that belong to undeletable links while pruning away unselected content, ensuring links marked link.format.undeletable = true survive selection-based model pruning.
Changes:
- Extend paragraph segment retention logic to keep segments with
link.format.undeletableeven when the segment itself is not selected. - Add unit tests validating undeletable-link retention (and non-retention when the link is deletable).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/roosterjs-content-model-dom/lib/domUtils/selection/pruneUnselectedModel.ts | Adjusts segment filtering logic during pruning to retain undeletable-link content. |
| packages/roosterjs-content-model-dom/test/domUtils/selection/pruneUnselectedModelTest.ts | Adds test coverage for undeletable-link retention behavior during pruning. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
juliaroldi
approved these changes
Jun 24, 2026
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
pruneUnselectedModelpreviously dropped any unselected segment, which would remove links marked asundeletable. This updates the segment-retention logic inpruneUnselectedModel.tsso a segment is also kept when itslink.format.undeletableistrue, even if the segment itself is not selected. This preserves undeletable links (e.g. inserted by features that require the link to survive) when pruning unselected content.How to test
yarn test:fast --testPathPattern=pruneUnselectedModellink.format.undeletable = trueplus other unselected segments, then callpruneUnselectedModel.