Content Model: Improve the behavior of deleting general element#1680
Merged
Conversation
JiuqingSong
requested review from
Andres-CT98,
BryanValverdeU,
flyingbee2012,
ianeli1 and
juliaroldi
March 29, 2023 22:06
JiuqingSong
marked this pull request as ready for review
March 29, 2023 22:06
BryanValverdeU
approved these changes
Apr 4, 2023
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.
#1662
When the deleting content is related to general element, for example:
here "button" is not supported as a special element in Content Model so we will use
ContentModelGeneralBlockorContentModelGeneralSegmentto represent it, depends on its CSS display state.When we hit a general element, we need to check if the whole element is selected, or there is potentially selected element under it. So we need to modify the API
iterateSelections()to allow return the selected element or its child nodes.In order to let it also work for existing code (mostly, format segments API), we need to introduce a new option named
contentUnderSelectedGeneralElement, it has 3 values:When we hit a general model, either segment or block, first check if it is selected, then do different handling according to this new option value:
contentUnderSelectedGeneralElementset tocontentOnlyorboth), recursively iterate its child nodes. This is used for format segments and blockscontentUnderSelectedGeneralElementset togeneralElementOnlyorboth), invoke the callback to let caller handle this element. This is used for deletegeneralElementOnlyWith this design, we can make sure
deleteSelection()API will always get the selected general element and delete it correctly.