The class dropdown menulist is now looking exactly how I wanted it to be but it does not do exactly what I want...

  • if a class is to be added
    • if the selection is collapsed, get the block-level container of the selection; if it's not the body, apply the class to that block; if it's the body, set TypeInState to create a span of the given class when the next char is entered at same location
    • if the selection is not collapsed, traverse it and encapsulate adjacent inlines into a span carrying the class
  • if a class is to be removed
    • if the selection is collapsed, get the block-level container of the selection having that class (there must be one since we know we remove the class...); remove the class from that block
    • if the selection is not collapsed, traverse the selection and remove all occurences of the given class