Description
Assume editor data with a marker, for example:
<p>
A
<comment id="e64dce95ad23165bb6aca6c5efb543636" type="start"></comment>
bcd
<comment id="e64dce95ad23165bb6aca6c5efb543636" type="end"></comment>
ef
</p>
Calling editor.setData( editor.getData() )
with throw an error. Why?
The whole data is removed, but the marker isn't removed it is actually moved to the graveyard. Then .setData()
adds the marker with the same name second time which throws an error.
It feels incorrect that under any circumstances editor.setData( editor.getData() )
fails. Also, I think that it feels natural, that if the specified marker already exists in the editor, it should be moved to a new place. OTOH, we rather discourage using editor.setData()
as it is rarely correct to do so.
What exactly happens is that DataController#set()
uses model.Writer#insert()
and the writer handles the markers insertions. We need to think about two things:
-
Maybe a marker should be automatically removed when it is moved to the graveyard. I already thought about it earlier and now @Reinmar also suggested that. As I think of it, it makes sense for all marker usages I can think of. We already need to write post-fixers which removes those markers after they end up in the graveyard! Mind, that auto-removing will not break undo.
-
If not, we should think whether this issue should be fixed in
model.Writer#insert()
or inDataController#set()
. We need to think if the writer, on inserting, should handle existing markers or if it is strictlyDataController#set()
scenario and responsibility.