VisualEditor/API/Data Model/Annotations

Register an annotation in VisualEditor.

Has to be globally unique for all annotations, tag names etc. No hierarchy is enforced although naming conventions encourage usage of the slash character to group related annotations (for readability only) such as.

Describes the annotation. Requires the following three properties:
 * : This object is used to determine whether a given HTMLElement should be represented by this annotation (for more detail on annotation matching, see matchElement). Must have one or more of the following:
 * : A lowercase HTMLElement node name. Omit this property if it can match multiple kinds of elements (including if it may match all html elements), in that case at least one of the next two properties must be included.
 * : Filters by one of the (space-separated) values in txhe RDFa attributes of the HTMLElement (usually the rel attributes @TODO: Which else, when? See Parsoid/RDFa vocabulary.)
 * Should return Boolean true or false.
 * [optional]: Object (or function returning an object) with annotation data to be kept about this annotation in the linear model. Any information that is needed to understand or manipulate the annotation must be extracted at this point as no access to the HTML element will be given during the editing process.
 * : When converting the linear model back to HTML, this object (or the object returned by this function) is used to create an HTML element from the annotation. If the annotation was originally created from an HTML element, the attributes will be based on the original element's attributes, and any attributes specified in 'attributes' below will override these. To explicitly remove an attribute, set it to undefined.
 * : Lowercase HTML element node name.
 * [optional]: Object with attributes and their values.
 * [optional] If the HTML rendering in the editor should be different from the HTML output, this property can be used to override it. This object (or object returned by this function) has the same behavior and properties as 'html' above. If it's omitted, the rules in 'html' will be used.