Open johanneswilm opened 7 years ago
@reinmar I believe you were talking about something similar a while back anbd this is why we changed the definition of the formatting commands to also apply in these cases where there is no actual change to the DOM, right?
Hey, as I was editing the spec with the comments from the TAG review, it hit me that for some formatting, we let the user epxress intentions to add formatting to content that does not yet exist. For example, take the following example:
1 The user hits a "bold" button while the selection is collapsed. The DOM does not yet change.
2a The user types the first letter. The default action would be to encapsulate that first letter an element that adds the bold styling, for example "
<b>A</b>
", or2b The user gets a different idea and changes the selection. There should be no change to the DOM at all.
2c The user gets a different idea, but does not want to change the selection, so he hits the "bold" button a second time to undo the initiation of bold executed in 1.
So the two questions are:
If we do it as part of 1, then surely the beforeinput and input events won't be paired perfectly.
If we do it as part of 2, do we then differentiate between a beforeinput event for formatBold and one for insertText for the "A"? What if the the selection in 2b is changed not due to the user but due to the JS moving the selection around (the JS can't really know it shouldn't do that)?