Author Mode Default Operations

The default operations for the Author mode, along with their arguments are as follows:
The following example is a script that retrieves the current value of the type attribute on the current element, allows the end user to edit its new value and sets the new value in the document:
function doOperation(){ 
  //The current node is either entirely selected...
 currentNode = authorAccess.getEditorAccess().getFullySelectedNode();
 if(currentNode == null){
  //or the cursor is placed in it
  caretOffset = authorAccess.getEditorAccess().getCaretOffset(); 
  currentNode = authorAccess.getDocumentController().getNodeAtOffset(caretOffset);
 }
 //Get current value of the @type attribute
  currentTypeValue = "";
  currentTypeValueAttr = currentNode.getAttribute("type");
  if(currentTypeValueAttr != null){
    currentTypeValue = currentTypeValueAttr.getValue();
  }
 //Ask user for new value for attribute.
 newTypeValue = javax.swing.JOptionPane.showInputDialog("Input @type value", currentTypeValue);
 if(newTypeValue != null){
   //Create and set the new attribute value for the @type attribute.
   attrValue = new Packages.ro.sync.ecss.extensions.api.node.AttrValue(newTypeValue);
   authorAccess.getDocumentController().setAttribute("type", attrValue, currentNode);
 }
} 
Note: If you have a script called commons.js in the framework directory, you can call functions defined inside it from your custom script content so that you can use that external script file as a library of functions.
The following example makes use of the selection variable to convert selected paragraphs into a list:
declare namespace oxyxq = "http://www.oxygenxml.com/ns/xqu";
(: This variable will be linked to the selected nodes assuming that there are 
actually fully selected nodes. For example this selection will return null: 
<p>{SEL_START}text{SEL_END} in para</p>
but this will give two "p" elements:
{SEL_END}<p>text</p><p>text2</p>{SEL_END}

If a multiple selection exists it will also be processed and forwarded. 
Again, only fully selected nodes will be passed.
:)
declare variable $oxyxq:selection external;

(: We will process either the selection or the context node :)
let $toProcess := if (empty($oxyxq:selection)) then
    (.)
else
    ($oxyxq:selection)

return
    if (not(empty($toProcess))) then
        (
        (: Create the list :)
        let $ul :=
        <ul>
            {
                for $sel in $toProcess
                return
                    <li>{$sel}</li>
            }
        </ul>
        
        return
            (
            (: Delete the processed nodes :)
            for $sel in $toProcess
            return
                delete node $sel,
            (: Inserts the constructed list :)
            insert node $ul
                before $toProcess[1]
            )
        )
    else
        ()

Let's consider that there is a pseudo-class called myClass on the element paragraph and there are CSS styles matching the pseudo-class.

paragraph:myClass{
  font-size:2em;
  color:red;
}
paragraph{
  color:blue;
}

In the previous example, by removing the pseudo-class, the layout of the paragraph is rebuilt by matching the other rules (in this case, the foreground color of the paragraph element will become blue.

paragraph:myClass{
  color:red;
}
paragraph{
  color:blue;
}

By default, the paragraph content is rendered in blue. Suppose that we have a TogglePseudoClassOperation configured for the myClass pseudo-class. Invoking it the first time will set the myClass pseudo-class and the paragraph will be rendered in red. Invoking the operation again, will remove the pseudo-class and the visible result will be a blue rendered paragraph element.

Author mode operations can include parameters that contain the following editor variables:
Related information
The Arguments of InsertFragmentOperation Operation
The Arguments of SurroundWithFragmentOperation