Fix toggleMark bug for selections with depth zero #14
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix-toggle-mark-top-node-edge-case"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When a selection range starts at depth zero, allow toggleMark commands
to succeed only if the top node both allows the mark and has inline
content. These restrictions align with the restrictions for the command
to succeed on other selections, fixing an edge case that
5692407did notcatch.
I think it's also possible that this could be implemented maybe simply by using the
parentargument to the traversal function, making it unnecessary to handle the top node in any special way.The way it is already may be better, because it can avoid a level of recursion that the other approach might take.
There may also be a related bug here, where
$to.depthis zero but$from.depthis not. I don't know if that's realistic for a document with a top node that has inline content or not.In that vein, I pushed an additional commit that I think avoids some other unnecessary recursion. If that's wrong, or you'd prefer it as a separate PR, please let me know.
I've merged the first patch as
9a187ec. The second doesn't seem worthwhile.Thanks for the quick response!
If it isn't too much trouble and there's no other planned work that you'd want to do here beforehand, would it be possible to make a release with this change? I'm shipping a local copy of
toggleMarkto work around this currently.No, definitely no trouble. I've tagged 1.3.1
🙏🏻 Thank you!
Pull request closed