Can toggleMark be changed so that if attrs is given, the mark with the same attributes is toggled ?
Consider for example a mark that sets classes like in How do I restrict the types of tags and classes allowed? and consider menu buttons for toggling the different attributes of the mark (r/g/b), you want toogleMark for the ‘r’ mark to remove marks for ‘g’ and ‘b’ but add the mark with the attributes for ‘r’.
This should work both for selection or the current set.
You’ll have to implement your own version. In general, don’t treat the bundle of comments that are part of the core libraries as the whole story – these are just some common ones, but in order to do specialized things, you’ll have to write specialized commands.