Here one child editor mutate the data, which is covered by the replacement decoration (atomic). However, it causes each time dispatch, that destroys everything and creates again.
I was wondering, if there is a way to mutate the text underneath without redrawing, but just reassigning the widget range to a new one (if a new text is larger or shorter).
Yes. I added it to return true to the widget class, but looking back to console log output, it has no effect.
PS: I guess the reason why is that eq method return false, since the inner content was changed, right? Yeah, since there is no unique identifier for this widget anymore, CM cannot decide if it is the same widget or not.
Thanks! Did not know you can easily code via Try CM page.
I think I got the idea, so update method works great if we keep the same length. Here is an example
If one replaces just one character inside the nested editor : updateDOM
if one writes or deletes characters - the length is different : toDOM
I do not know, if it is actually possible in CM6 system to handle the second case as if it was the 1st one. Looks like I need to perform some low-level dispatch and manually perform all transitions to prevent constructor of a widget to be called.
Ok. I have a feeling I am very close to the solution.
If I turn eq(other) method to return always true, then the editor does not update the DOM element.
Now I am trying to update the field, which eq method compares to the others. However the line 19 seems not able to mutate the widgets properties like
this.str = value //not working ;(
where
eq: (other) => {other.str === this.str} //remains the same