Allow for the indention and outdention of multiple selected headings at once in the structured headings plugin #422
Conversation
…gs at once now works.
…ion and outdention.
…utdention, and reformatted the functions for multiple indention and outdention into one function.
…esn't perform the action of nodes are selected outside of one list.
Indenting or outdenting multiple headings in a selection at once now works as expected. When applying an indent or outdent to multiple headings at once, the plugin will loop through each heading in the selection and apply the specified action to the heading if it does not create an invalid heading structure. As part of adding this functionality to the structured headings plugin, I also had to fix how indent and outdent tools work when applied to normal lists. I made it so that the indent and outdent actions will only be applied to a list if every node in the selection is within the same list. This is tested by the Also, as part of this ticket, I added a large amount of tests for both indenting and outdenting with multiple headings to try to cover all of the various cases where those actions could take place. |
if (parentList.length === 0 || parentList[0] !== rootList) { | ||
return null; | ||
haveCommonParent = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before this ticket, the getCommonParentList
function was trying to return null
from within an internal function, so it wasn't actually ever able to return null
and would always return a parent list whether all of the nodes were in it or not. I'm surprised this wasn't causing other issues elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch. It looks like this would have broken lots of things if a user had an odd selection when trying to indent a list.
…d lists with content between them.
…s properly in converting list types.
I went back and added some more tests specifically for ensuring that the |
headingManager = this, | ||
shouldRaise = (upOrDown === 'up'), | ||
i, | ||
i_start = (shouldRaise ? selection.rangeCount - 1 : 0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be camelCase'd
I love the tests on this. There are definitely lots of cases to consider and you did a great job covering them. After the small camelCase change, this will be ready to merge in. |
I fixed the camel case issue you pointed out. |
Fixes #422 Allow for the indention and outdention of multiple selected headings at once in the structured headings plugin
In the structured headings plugin currently, if a user selects multiple headings at once and uses the indent or outdent tool, the tool will only be applied to the last heading in the selection. Fix this so that the tool applies to every heading in the selection if allowable.