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.
To repro:
Expect: nothing happens
Actual, "ab" reappears
The root cause is demo site will always update content model by calling getContentModelCopy() which will update model cache before our formatContentModel() API write cache back, it is triggered when backspace. So the result is cached model in DOM tree is updated by demo site, but cached model in editor is updated by formatContentModel(), so the two models don't match. Later when we keep editing, it will edit on a staled cache.
To fix it, we should not update cache when create model from demo site. Furthermore, we should not update cache at all from API
getContentModelCopy
. It should be a "readonly" operation, to create model only, but not touch cache at all.In this change I explicitly specified if a API call should reuse cache, and as long as any option is passed in, we should not update cache. For more detailed summary:
I added test cases to ensure the result of this table.
Also fix another recent regression in Editor.getContentModelCopy() with parameter "clean", we need to clone the content model to avoid removing entity DOM element when write back to DOM. Related test cases added.