Documentation Center

Elements in a contextualmenuitems section in BehaviorConfig.xml

A contextualmenuitems section specifies custom context menu items.

contextualmenuitems
Use this element to add menu items to the context menu of any element matching the XPath expression specified in the required xpath attribute.
If you define a contextualmenuitems element with no contextualmenuitem entries, the matching elements will not show a context menu. Here is an example of a contextualmenuitems element that suppresses the context menu of the p element:
<contextualmenuitems xpath="self::p"/>
You can add contextualmenuitems as a child element to the following behavior elements:
  • definitiontable (and rows in definitiontable)
  • items in list
  • image
  • block
  • title
  • sheetbody
contextualmenuitem
The element that defines an additional menu item in the context menu. It can contain the following child elements:
  • a required label child element
  • either an inserttemplate or a toggletemplate child element
Here is an example of a contextualmenuitem element that adds a context menu item labeled "Insert block of code" to the context menu for a p element:
<contextualmenuitems xpath="self::p"/>
  <contextualmenuitem>
    <label>Insert block of code</label>
    <inserttemplate>
      <codeblock/>
    </inserttemplate>
  <contextualmenuitem>
</contextualmenuitems>
label
The label of the menu item.
inserttemplate
Use this element to specify a certain XML structure, which will be inserted either below the current element or below the ancestor element that is specified in the xpath attribute of the menuitem element.
An optional specialbehavior attribute with value repositoryimageselector can be used to specify that you want to pick an image using a Repository browse dialog.
Typically, you would use insert templates for all elements that allow a menuitems child element, except for the inline and highlighting elements.
Here is an example of an inserttemplate element that inserts a definition list:
<inserttemplate>
  <dl>
    <dlhead>
      <dthd/>
      <ddhd/>
    </dlhead>
    <dlentry>
      <dt/>
      <dd/>
    </dlentry>
  </dl>
</inserttemplate>
And here is an example of an inserttemplate element that inserts an image, to be selected by the author:
<inserttemplate specialbehavior="showrepositoryimageselector">
  <image placement="break" href="{{reference}}"/>
</inserttemplate>
toggletemplate
Use toggletemplate to either insert/wrap or remove/unwrap a specified XML element. If text is selected when you use toggletemplate, then the text gets wrapped with the specified element; otherwise, the element is simply inserted. If text is already wrapped within the XML element, using toggletemplate unwraps/removes the element from the text while leaving the text itself intact. Typically, you would use a toggle template for inline or highlighting elements.
The toggletemplate element includes the following:
  • elementname (required) — This attribute defines which XML element will be inserted or removed.
  • attributes (optional) — This section defines additional attribute values for the XML element specified in elementname. If used, this section must include at least one attribute element and each element requires a name to identify the attribute.
Here is an example of using a toggletemplate element to insert a <ph> element around text that should not be translated:
<toggletemplate elementname="ph">
  <attributes>
    <attribute name="outputclass">ph-class</>
    <attribute name="translate">no</>
  </attributes>
<toggletemplate/>