Extends
Constructor
new ve.dm.Annotation(element, store)
#
Hierarchy
Children
Generic DataModel annotation.
This is an abstract class, annotations should extend this and call this constructor from their constructor. You should not instantiate this class directly.
Annotations in the linear model are instances of subclasses of this class. Subclasses should only override static properties and functions.
Parameters:
Name | Type | Description |
---|---|---|
element |
Object | Linear model annotation |
store |
ve.dm.HashValueStore | Store used by annotation |
- Source:
Properties
applyToAppendedContentstatic
#
Automatically apply annotation to content inserted after it.
Properties:
Type | Description |
---|---|
boolean |
applyToInsertedContentstatic
#
Automatically apply annotation to content inserted within it.
This includes content inserted after the annotation (appended content).
Properties:
Type | Description |
---|---|
boolean |
enableAboutGroupingstatic
#
About grouping is not supported for annotations; setting this to true has no effect.
Properties:
Type | Description |
---|---|
boolean |
- Source:
inferFromViewstatic
#
Accept this annotation when the browser spontaneously adds it to view's DOM.
Properties:
Type | Description |
---|---|
boolean |
- Source:
removesstatic
#
Annotations which are removed when this one is applied
Properties:
Type | Description |
---|---|
Array.<string> |
- Source:
trimWhitespacestatic
#
Move whitespace at the edge of the transaction outside of it when converting
e.g. "foo bar baz" -> "foo bar baz"
Properties:
Type | Description |
---|---|
boolean |
- Source:
Move whitespace at the edge of the transaction outside of it when converting
e.g.
Methods
compareTo(annotation) → {boolean}
#
Compare two annotations using #getComparableObject
Parameters:
Name | Type | Description |
---|---|---|
annotation |
ve.dm.Annotation | Other annotation to compare against |
- Source:
Returns:
Annotation is comparable
- Type
- boolean
compareToForSerialization(annotation) → {boolean}
#
FIXME T126039: Compare to another annotation for serialization
Compares two annotations using #getComparableObjectForSerialization, unless they are both generated annotations, in which case they must be identical.
Parameters:
Name | Type | Description |
---|---|---|
annotation |
ve.dm.Annotation | Annotation to compare to |
- Source:
Returns:
The other annotation is similar to this one
- Type
- boolean
FIXME T126039: Compare to another annotation for serialization
Compares two annotations using #getComparableObjectForSerialization, unless they are both generated annotations, in which case they must be identical.
describeAdded() → {Array}
#
Describe the addition of this annotation to some text
- Source:
Returns:
Descriptions, list of strings or Node arrays
- Type
- Array
describeRemoved() → {Array}
#
Describe the removal of this annotation from some text
- Source:
Returns:
Descriptions, list of strings or Node arrays
- Type
- Array
getAttribute(key) → {any}
#
Get the value of an attribute.
Return value is by reference if array or object.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | Name of attribute to get |
- Inherited from:
- Source:
Returns:
Value of attribute, or undefined if no such attribute exists
- Type
- any
getAttributes([prefix]) → {Object}
#
Get a copy of all attributes.
Values are by reference if array or object, similar to using the getAttribute method.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
prefix |
string |
optional |
Only return attributes with this prefix, and remove the prefix from them |
- Inherited from:
- Source:
Returns:
Attributes
- Type
- Object
getClonedElement() → {Object}
#
Get a clone of the model's linear model element.
The attributes object will be deep-copied.
- Inherited from:
- Source:
Returns:
Cloned element object
- Type
- Object
getComparableHtmlAttributes() → {Object}
#
getComparableObject() → {Object}
#
Get an object containing comparable annotation properties.
This is used by the converter to merge adjacent annotations.
- Source:
Returns:
An object containing a subset of the annotation's properties
- Type
- Object
getComparableObjectForSerialization() → {Object}
#
FIXME T126038: This method adds in HTML attributes so comparable objects aren't serialized together if they have different HTML attributes.
This method needs to be different from #getComparableObject which is still used for editing annotations.
- Source:
Returns:
An object containing a subset of the annotation's properties and HTML attributes
- Type
- Object
FIXME T126038: This method adds in HTML attributes so comparable objects aren't serialized together if they have different HTML attributes.
getElement() → {Object}
#
Get a reference to the linear model element.
- Inherited from:
- Source:
Returns:
Linear model element passed to the constructor, by reference
- Type
- Object
getHashObject() → {Object}
#
getOriginalDomElements(store) → {Array.<HTMLElement>}
#
Get the DOM element(s) this model was originally converted from, if any.
Parameters:
Name | Type | Description |
---|---|---|
store |
ve.dm.HashValueStore | Hash value store where the DOM elements are stored |
- Inherited from:
- Source:
Returns:
DOM elements this model was converted from, empty if not applicable
- Type
- Array.<HTMLElement>
getOriginalDomElementsHash() → {string|undefined
}
#
undefined
}
#
Get the DOM element(s) this model was originally converted from, if any.
- Inherited from:
- Source:
Returns:
Store hash of DOM elements this model was converted from
- Type
-
string
|
undefined
getStore() → {ve.dm.HashValueStore}
#
Get a reference to the hash-value store used by the element.
- Inherited from:
- Source:
Returns:
Hash-value store
- Type
- ve.dm.HashValueStore
getType() → {string}
#
Get the symbolic name of this model's type.
- Inherited from:
- Source:
Returns:
Type name
- Type
- string
isDiffComparable(other) → {boolean}
#
Check if this element is of the same type as another element for the purposes of diffing.
Elements which aren't of the same type will always be shown as removal and an insertion, whereas comarable elements will be shown as an attribute change.
Parameters:
Name | Type | Description |
---|---|---|
other |
Object | Another element |
- Inherited from:
- Source:
Returns:
Elements are of a comparable type
- Type
- boolean
isEditable() → {boolean}
#
Check whether this node can be edited by a context item
The default implementation always returns true. If your node type is uneditable in certain cases, you should override this function.
- Inherited from:
- Source:
Returns:
Whether this node is editable
- Type
- boolean
Check whether this node can be edited by a context item
The default implementation always returns true.
isGenerated() → {boolean}
#
Check if the annotation was generated by the converter
Used by compareToForSerialization to avoid merging generated annotations.
- Source:
Returns:
The annotation was generated
- Type
- boolean
Check if the annotation was generated by the converter
Used by compareToForSerialization to avoid merging generated annotations.
isInspectable() → {boolean}
#
Check whether this node can be inspected by a context item.
The default implementation always returns true. If your node type is uninspectable in certain cases, you should override this function.
- Inherited from:
- Source:
Returns:
Whether this node is inspectable
- Type
- boolean
toDomElements(dataElement, doc, converter, childDomElements) → {Array.<HTMLElement>}abstractstatic
#
Static function to convert a linear model data element for this annotation type back to a DOM element.
As special facilities for annotations, the annotated content that the returned element will wrap around is passed in as childDomElements, and this function may return an empty array to indicate that the annotation should produce no output. In that case, the child DOM elements will not be wrapped in anything and will be inserted directly into this annotation's parent.
Parameters:
Name | Type | Description |
---|---|---|
dataElement |
Object | Array | Linear model element or array of linear model data |
doc |
HTMLDocument | HTML document for creating elements |
converter |
ve.dm.Converter | Converter object to optionally call .getDomSubtreeFromData() on |
childDomElements |
Array.<Node> | Children that will be appended to the returned element |
- Source:
Returns:
Array of DOM elements; only the first element is used; may be empty
- Type
- Array.<HTMLElement>
Static function to convert a linear model data element for this annotation type back to a DOM element.