Possible to use CSS Class Applier functionality purely with inline-CSS only?

28 views
Skip to first unread message

Uwe Keim

unread,
Nov 3, 2013, 5:18:52 PM11/3/13
to ra...@googlegroups.com
What works

Currently I'm successfully using this definition:

cssApplier = rangy.createCssClassApplier(
        "someClass", 
        {
            normalize: true, 
            elementProperties: {
                style: {
                    fontFamily: "courier"
                }
            }
        });

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?

Reply all
Reply to author
Forward
0 new messages