What works
Currently I'm successfully using this definition:
cssApplier = rangy.createCssClassApplier(
To create a CSS Applier and then call it with
cssApplier.applyToSelection();
and
cssApplier.undoToSelection();
To both set/remove a CSS class as well as an inline CSS style.
Goal
What I want to achieve is to (mis-)use the functionality to purely work on inline CSS and not setting any CSS class values.
I've successfully modified the code above:
cssApplier = rangy.createCssClassApplier(
null, // Now null.
{
normalize: true,
elementProperties: {
style: {
fontFamily: "courier"
}
}
});
To create a CSS Applier without a CSS class and then call it with
cssApplier.applyToSelection();
This succeeds as it only sets the inline CSS in the style attribute and completely omits the class attribute.
Where it fails
What not works is the call to:
cssApplier.undoToSelection();
This simply does nothing. My assumption is that if it does not find the correct CSS class, it also cannot work on the inline CSS styles.
My question
Would it be possible to somehow make the call to cssApplier.undoToSelection() work, even with a null CSS class?