Developer provides a number of extension points that allow you to extend the editor’s functionality, providing a better user experience and deeper integration into a Content Management System/Application. Extensions are registered with a JavaScript call before the instance of the editor is rendered. You can perform this by calling:
ditaStorm.registerExtension(...)
method and providing the necessary parameters. Depending on the type of extension parameters, this could be different. See the descriptions of particular extension points for parameter details.
Extend Developer by defining custom actions that are executed when a user edits the href/conref attributes and clicks the related browse button.
This can be achived by registering ‘ditastorm.conref’ extension
A JavaScript method must be provided to call when the corresponding button is clicked. This method accepts one parameter - a reference to a property form control, in which the value is set as a result (HRef on the picture above). Sample code:
<SCRIPT>
function onBrowse(control) {
var hrefValue = ...; // lookup the value
control.value = hrefValue; // assign value back to the form
}
</SCRIPT>
...
<SCRIPT>
ditaStorm.registerExtension('ditastorm.conref',onBrowse);
ditaStorm.render(...);
</SCRIPT>
Please remember, as with all extensions, your function will be executed in the context of the Developer frame, not in the page context. To refer to external resources (such as when opening a popup window or loading data from a server), you need to either provide a URL related to the Developer location or use the utility method to automatically calculate an absolute URL:
ditaStorm.getAbsoluteUrl(<base_url>,<relative_url>)
For example:
ditaStorm.getAbsoluteUrl(window.location.href,'../../editMyConref.php');
To create a custom XML element, Developer must be installed and working.
Create new
Register with other elements
Specify how the new element will be rendered.
Compile your changes.
When all necessary steps are performed you will be able to insert the newly created element into XML, edit its attributes and store it along with the XML document.
With Developer’s XML customization options, entire new XML structures can be built.
Developer is preconfigured to work with DITA XML, but is also capable of operating with any user-defined XML structure. It can be configured for customized DITA XML or something completely unrelated, such as XML for invoice handling.
Currently, Developer does not support the direct use of a DTD or Schema file to control the structure of edited XML documents. This is related to the performance and size restrictions of browser-based applications. Instead, Developer uses an XML configuration file similar to a Schema, but it contains both the XML structure description and additional information, such as user-defined actions and presentation details.
For your reference file DITAStorm/config/model.dtd contains a DTD definition of the structure of model.xml.
Root element for the entire Developer XML structure definition.
<!ELEMENT model (element*,editor*)>
<model> <element.../> ... <editor.../> ... </model>
Describes a single element in the set of all elements supported by the editor.
<!ELEMENT element (group*,action*,default?)>
| Type | Attribute Name | Description |
|---|---|---|
| string | name | Name of the element. (E.g. ‘section’ or ‘p’) |
| string | title | Full name of the element (E.g. ‘section’ or ‘Topic’) |
| true/false | addToNewButton | Adds the element to the ‘New’ button in the editor allowing it to be the root element of the edited content. (E.g. for Topic) |
| string | attributeeditor | Name of the attribute that the editor associated with this element. See ‘editor’ element. (E.g. ‘topic’ or ‘univ-atts’). |
| true/false | confirmDelete | Enables confirmation on deleting this element. Used primarily on high-level elements such as Section or Topic. |
| string | doctypePublicId | Will be used to generate a public ID for the element if it gets exported on the top level. (E.g. ‘-//OASIS//DTD DITA Topic//EN’ for Topic). |
| string | doctypeFile | Used to generate a path to the file in the DOCTYPE section of the output XML document. This element should only contain a file name without the path. (E.g. ‘topic.dtd’ for DITA Topic). |
| true/false | toolbarOnly | Indication to only show the element on the Developer toolbar (E.g. for Bold or Italic). |
| string | toolbarHTML | Snippet to be used on the toolbar to render the element. Element will not be added to the toolbar if this attribute is not defined. (E.g. ‘B’ for bold). |
| true/false | applyToSelection | Indication to allow the element to be ‘applied’ to the selection. (E.g. set to true for Bold or Note). |
| character | ctrlShortcut | If defined, specifies keyboard key used with Control (Ctrl) key to insert element into the content. (E.g. by default set to ‘b’ on Bold and to ‘i’ on Italic element). |
| true/false | enableUnwrap | Enables ‘unwrap’ functionality when an element can be replaced by its content. (E.g. by default enabled for Note, Paragraph and Bold). |
| true/false | inline | A hint to the editor on how to better format the XML output. Inline elements flow with the text other (block) elements always represent rectangle. (E.g. inline elements are Bold and Quotes, block elements are Notes and Long Quotes). |
| true/false | showPropsOnInsert | Forces the editor to show the property dialog when an element is inserted (E.g. for XRef and Image DITA Elements). |
| true/false | gnericRenderer | Forces the editor to use ‘generic’ element rendered similar to the one in Outline mode. Setting this attribute to ’true’ disables XSL styles defined for this element. |
| string | helpUrl | Location (URL) of the help page for this XML element. |
| true/false | hidden | Removes the element from the editor’s Insert menus, but does not prohibit it from creating or handling an element from an XML source or original XML document. |
| string | lock | Attribute defining editor-wide lock (or readonly) behavior for all elements of this type. See this section for more information and available values. |
<element name='topic' title='Topic' addToNewButton='true' attributeeditor='topic' doctypePublicId='-//OASIS//DTD DITA Topic//EN' doctypeFile='topic.dtd' confirmDelete='true'>
<group allows='title' card='1'/>
<group allows='shortdesc'/>
<group allows='prolog'/>
<group allows='body'/>
<group allows='related-links'/>
<group allows='topic,task,concept,reference' card='0..n'/>
<default>
<![CDATA[
<topic>
<title/>
<shortdesc/>
<body>
<p/>
</body>
</topic>
]]>
</default>
</element>
Defines a fragment of XML that will be used to populate a newly created element. For example, for convenience UL should be created with inner LI.
<!ELEMENT default (#PCDATA)>
<element ...>
...
<default>
<![CDATA[
<topic>
<title/>
<shortdesc/>
<body>
<p/>
</body>
</topic>
]]>
</default>
</element>
Describes element attributes and provides the editor with the necessary information to organize the editing process. Developer can reuse fields defined in other editors by using <fields.../> element.
<!ELEMENT editor (fields|field)*>
| Type | Attribute Name | Description |
|---|---|---|
| string | name | Name of the attribute editor. |
<editor name="created"> <field attribute="date" title="Creation Date" type="date"/> ... </editor>
Imports fields defined in a different editor element with a specified name. This can be useful to organize commonly used attributes in groups for later reuse.
<!ELEMENT fields EMPTY>
| Type | Attribute Name | Description |
|---|---|---|
| string | name | Name of the attribute editor to be included at this position. |
<editor name="xref"> <field attribute="href" title="Hyperlink URL" type="conref"/> ... <fields name="univ-atts"/> </editor>
Defines a single attribute editing control. If the field is of the type ‘choice’ then ‘option’ child elements are available to define a list of possible attribute values.
<!ELEMENT field (option*)>
| Type | Attribute Name | Description |
|---|---|---|
| string | attribute | Name of the attribute. (E.g: ‘href’) |
| string | title | Title of the attribute (E.g. ‘Navigation Title’ for ‘navtitle’ attribute). |
| ‘string’/conref/choice/date/separator | type | Type of the attribute |
| number | size | Size of the attribute editing field (applicable for ‘string’ type) |
<editor...> <field attribute="href" title="Image URL" type="conref"/> <field attribute="alt" title="Alt Text" type="string"/> ... </editor>
Describes one of the possible values of the attributes/fields defined with type ‘choice’.
<!ELEMENT option EMPTY>
| Type | Attribute Name | Description |
|---|---|---|
| string | title | Title of the dropdown value. |
| string | attribute | Actual attribute stored in the field. |
<field attribute="align" title="Alignment" type="choice"> <option title="" value=""/> <option title="Left" value="left"/> <option title="Right" value="right"/> <option title="Center" value="center"/> </field>
This section describes the actions necessary to disable the editing of certain XML elements and attributes within Developer.
There are three scenarios when an XML editor may need to prevent users from modifying certain elements of XML:
All three scenarios could be enforced for a certain class of elements, (see lock attribute in model.xml) as well as for specific elements within the provided XML.
To enforce one of these rules on specific elements within XML, the developer uses the special _lock attribute. Its value will identify how the element should be handled. List of available values:
| _lock attribute value | Description |
|---|---|
| attribute:<attribute_name> |
Prohibits editing of the specified attribute. For example: <section product="UV Scanner" _lock="attribute:product"> ... </section> |
| content |
Prohibits editing of an element along with attributes and child nodes. For example: <section _lock="content"> ... </section> |
| inparent |
Prevents any action that could remove the element from its parent. For example: <section _lock="inparent"> ... </section> |
| any combination of values above |
Combines the effect of multiple settings. Values should be coma or space separated. For example: <section _lock="inparent,attribute:product"> ... </section> |
To indicate that a certain element and all of its child nodes can not be edited, Developer uses CSS style called readonly. In the initial configuration the background is light gray and letters are dark gray and italic:
.readonly { background-color: #F5F5F5; color: #A0A0A0; font-style: italic; }
User can customize styling by updating the definition in the CSS file styles.css located in the Developer directory.