I am trying Step.merge. It is quite a common case during editing:
- input some text, say
it is a test
- locates the cursor back and modify the text just inputed, resulting in
it is another test
- select some text just inputed and delete it, resulting in
it is test
All those steps are ReplaceStep instances, and I find they are not merged:
[{"stepType":"replace","from":10,"to":10,
"slice":{"content":[{"type":"text","text":"This is a test"}]}},
{"stepType":"replace","from":19,"to":19,
"slice":{"content":[{"type":"text","text":"nother"}]}},
{"stepType":"replace","from":18,"to":26}]
IMHO, from step 1, it is known that it covers the range from 10 to 24 (from + "This is a test".length
). Step 2 just takes place in this range. So they should be mergable, resulting in some new step like {"stepType":"replace","from":10,"to":10,"slice":{"content":[{"type":"text","text":"This is another test"}]}}
.
And step 3 should also merge into the new step for the same reason.