Custom CSS Pseudo-classes
You can set your custom CSS pseudo-classes on the nodes from the AuthorDocument model. These are similar to the normal XML attributes, with the important difference that they are not serialized, and by changing them, the document does not create undo and redo edits (the document is considered unmodified). You can use custom pseudo-classes for changing the style of an element (and its children) without altering the document.
In Oxygen XML Editor they are used to hide/show the colspec
elements
from CALS tables. To take a look at the implementation, see:
- [OXYGEN_INSTALL_DIR]/frameworks/docbook/css/cals_table.css (Search for
-oxy-visible-colspecs
) - The definition of action
table.toggle.colspec
from the DocBook framework makes use of the pre-defined TogglePseudoClassOperation Author mode operation.
Here are some examples:
Example: Controlling the visibility of a section using a pseudo-class
access-control-user
, like the one below:
section {
display:none;
}
section:access-control-user {
display:block;
}
By setting the pseudo-class access-control-user
, the element section will
become visible by matching the second CSS selector.
Example: Coloring the elements at the current cursor location
caret-visited
pseudo-class to the element at the cursor location. The
effect will be that all the elements traversed by the cursor become
red.*:caret-visited {
color:red;
}
The API that you can use from the CaretListener: