Expand all

ve.dm.LinkAnnotation

Extends

Constructor

new ve.dm.LinkAnnotation(element) #

DataModel link annotation.

Represents <a> tags that don't have a specific type.

Parameters:

Name Type Description
element Object
Source:
DataModel link annotation.

Methods

compareTo(annotation) → {boolean} #

Compare two annotations using #getComparableObject

Parameters:

Name Type Description
annotation ve.dm.Annotation

Other annotation to compare against

Inherited from:
Source:

Returns:

Annotation is comparable

Type
boolean
Compare two annotations using #getComparableObject

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

Inherited from:
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

Overrides:
Source:

Returns:

Descriptions, list of strings or Node arrays

Type
Array
Describe the addition of this annotation to some text

describeRemoved() → {Array} #

Describe the removal of this annotation from some text

Overrides:
Source:

Returns:

Descriptions, list of strings or Node arrays

Type
Array
Describe the removal of this annotation from some text

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
Get the value of an attribute.

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
Get a copy of all attributes.

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
Get a clone of the model's linear model element.

getComparableHtmlAttributes() → {Object} #

FIXME T126037: This method strips data-parsoid & RESTBase IDs from HTML attributes for comparisons.

This should be removed once similar annotation merging is handled correctly by Parsoid.

Overrides:
Source:

Returns:

An object all HTML attributes except data-parsoid & RESTBase IDs

Type
Object
FIXME T126037: This method strips data-parsoid & RESTBase IDs from HTML attributes for comparisons.

getComparableObject() → {Object} #

Get an object containing comparable annotation properties.

This is used by the converter to merge adjacent annotations.

Overrides:
Source:

Returns:

An object containing a subset of the annotation's properties

Type
Object
Get an object containing comparable annotation properties.

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.

Inherited from:
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.

getDisplayTitle() → {string} #

Get the display title for this link

Can be overridden by special link types.

Source:

Returns:

Display title

Type
string

Get the display title for this link

Can be overridden by special link types.

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
Get a reference to the linear model element.

getFragment() → {string|null} #

Get the fragment / hash for the current href

Source:

Returns:

The fragment, or null if none is present

Type
string | null
Get the fragment / hash for the current href

getHashObject() → {Object} #

Get the hash object of the linear model element.

The actual logic is in a static function as this needs to be accessible from ve.dm.Converter

This is a custom hash function for OO#getHash.

Inherited from:
Source:

Returns:

Hash object

Type
Object
Get the hash object of the linear model element.

getHref() → {string} #

Convenience wrapper for .getHref() on the current element.

Source:
See:

Returns:

Link href

Type
string
Convenience wrapper for .getHref() on the current element.

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>
Get the DOM element(s) this model was originally converted from, if any.

getOriginalDomElementsHash() → {string|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
Get the DOM element(s) this model was originally converted from, if any.

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
Get a reference to the hash-value store used by the element.

getType() → {string} #

Get the symbolic name of this model's type.

Inherited from:
Source:

Returns:

Type name

Type
string
Get the symbolic name of this model's type.

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
Check if this element is of the same type as another element for the purposes of diffing.

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.

Inherited from:
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
Check whether this node can be inspected by a context item.

getHref(dataElement) → {string}static #

Get the link href from linear data. Helper function for toDomElements.

Subclasses can override this if they provide complex href computation.

Parameters:

Name Type Description
dataElement Object

Linear model element

Source:

Returns:

Link href

Type
string
Get the link href from linear data.