Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2880 optimize() causes segment cache to be wrong when merging <A> #2889

Merged
merged 2 commits into from
Nov 22, 2024

Conversation

JiuqingSong
Copy link
Collaborator

The problem is, when create DOM tree, content model index is added to not only leaf nodes (#text, image, br, ...) but also their wrapper if any (e.g. <A>). And optimize() can merge some elements without updating their index info. When reconcile content model from user's input, we may see an incorrect index to be updated.

To repro:

  1. use the snapshot below
  2. type something
  3. press enter

After enter, the text order is wrong. This is because the cached model is incorrectly updated.

<a href="#"><img src="null">test</a><!--{"type":"range","start":[1],"end":[1],"isReverted":false,"isDarkMode":false}-->

To fix it:

  1. No need to add model index to wrapper element (A, CODE, ...)
  2. When reconcile, find index from leaf node only.

@JiuqingSong JiuqingSong merged commit 24f5af0 into master Nov 22, 2024
7 checks passed
@JiuqingSong JiuqingSong deleted the u/jisong/2880 branch November 22, 2024 19:05
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