Would like to know what should be the suitable way to achieve the task for removing the mark if the range of the node that has the mark is modified in terms of the mark’s attribute or the text has been modified.
For example, if the following sentence, this is bolded, is edited into this is bolded!. Then I would like to remove the bold mark.
How can I detect the range has been modified? Seem there are different cases that I need to handle.
Use a single tracking target as an example, If I want to track the change of this is the sentence I want to check.
Before:
this is a line
this is the sentence I want to check
Change Case 1: Edit is before the tracked range
this is a modified line
this is the sentence I want to check
Change Case 2: Edit is within the target range
this is a line
this is the modified sentence I want to check
Change Case 3: Edit by breaking into 2 paragraph
this is a line
this is the sentence
I want to check
Change Case 4: Edit is after the target range
this is a line
this is the sentence I want to check
this is a new line
I think I need to compute the target contents that I want to observe from the oldState.
Then I don’t think I can simply detect these contents has been changed by looking at the newState.
Do I need to look through each transaction and each transaction step in order to detect the tracked content in the oldState has been modified? And I think things will be more complicated if the content has multiple contents that need to be tracked at the same time.
Yes, iterate through the transaction’s steps, and then through the changed ranges in each step’s step map. Make sure you map the affected ranges forward if a step isn’t the last step in the transaction.
Would like some guidelines on the map the affected ranges forward. I’m not too familiar with the mapping concept. And under what situation will there be multiple tr and multiple steps in each tr?