Expand all

ve.dm.FakeCommentNode

Extends

Constructor

new ve.dm.FakeCommentNode(element) #

Fake comments generated by the converter for the clipboard

<span rel="ve:Comment"> is used to to preserve comments in the clipboard

Parameters:

Name Type Description
element Object

Reference to element in meta-linmod

Source:

Fake comments generated by the converter for the clipboard

<span rel="ve:Comment"> is used to to preserve comments in the clipboard

Methods

adjustLength(adjustment) #

Adjust the length.

This should only be called after a relevant change to the document data. Calling this method will not change the document data.

Parameters:

Name Type Description
adjustment number

Amount to adjust length by

Inherited from:
Source:

Throws:

Invalid adjustment error if resulting length is less than 0

Type
Error
Adjust the length.

canBeMergedWith(node) → {boolean} #

Check if the node can be merged with another.

For two nodes to be mergeable, the two nodes must either be the same node or:

  • Are comparable according to #compareForMerging (by default, have the same type)
  • Have the same depth
  • Have similar ancestry (each node upstream must have the same type)

Parameters:

Name Type Description
node ve.dm.Node

Node to consider merging with

Inherited from:
Source:

Returns:

Nodes can be merged

Type
boolean
Check if the node can be merged with another.

canContainContent() #

canHaveChildren() #

canHaveChildrenNotContent() #

canHaveSlugAfter() → {boolean} #

Check if the node can have a slug after it.

Inherited from:
Source:

Returns:

Whether the node can have a slug after it

Type
boolean
Check if the node can have a slug after it.

canHaveSlugBefore() → {boolean} #

Check if the node can have a slug before it.

Inherited from:
Source:

Returns:

Whether the node can have a slug before it

Type
boolean
Check if the node can have a slug before it.

compareAttributes(attributes) → {boolean} #

Check if specific attributes match those in the node

Parameters:

Name Type Description
attributes Object

Node attributes to match

Inherited from:
Source:

Returns:

Attributes sepcified match those in the node

Type
boolean
Check if specific attributes match those in the node

compareForMerging(otherNode) → {boolean} #

Compare with another node for merging (see #canBeMergedWidth)

The default implementation just compares node types.

Parameters:

Name Type Description
otherNode ve.dm.Node

Other node to compare with

Inherited from:
Source:

Returns:

Nodes are comparable

Type
boolean

Compare with another node for merging (see #canBeMergedWidth)

The default implementation just compares node types.

findMatchingAncestor(type, [attributes]) → {ve.dm.Node|null} #

Find the first ancestor with matching type and attribute values.

Parameters:

Name Type Attributes Description
type string

Node type to match

attributes Object optional

Node attributes to match

Inherited from:
Source:

Returns:

Ancestor with matching type and attribute values

Type
ve.dm.Node | null
Find the first ancestor with matching type and attribute values.

getAnnotations() → {Array.<number>} #

Get the annotations that apply to the node.

Annotations are grabbed directly from the linear model, so they are updated live. If the linear model element doesn't have a .annotations property, an empty array is returned.

Inherited from:
Source:

Returns:

Annotation set indexes in the index-value store

Type
Array.<number>
Get the annotations that apply to the node.

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.

getChildNodeTypes() #

getClonedElement(preserveGenerated, resetAttributes) → {Object} #

Parameters:

Name Type Description
preserveGenerated boolean

Preserve internal.generated property of element

resetAttributes boolean

Reset attributes for an empty clone, as defined in #static-resetForClone

Inherited from:
Source:
See:

Returns:

Cloned element object

Type
Object

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.

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.

getLength() #

getOffset() #

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.

getParentNodeTypes() #

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.

getSuggestedParentNodeTypes() #

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.

handlesOwnChildren() #

hasMatchingAncestor(type, [attributes]) → {boolean} #

Check if the node has an ancestor with matching type and attribute values.

Parameters:

Name Type Attributes Description
type string

Node type to match

attributes Object optional

Node attributes to match

Inherited from:
Source:

Returns:

Node has an ancestor with matching type and attribute values

Type
boolean
Check if the node has an ancestor with matching type and attribute values.

hasSignificantWhitespace() #

isAlignable() #

isCellEditable() #

isCellable() #

isContent() #

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.

isDiffedAsDocument() #

isDiffedAsLeaf() #

isDiffedAsList() #

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.

isFocusable() #

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.

isInternal() #

isMetaData() #

isSurfaceable() → {boolean} #

Check if the node can be the root of a branch exposed in a ve.ce.Surface

Inherited from:
Source:

Returns:

Node can be the root of a surfaced branch

Type
boolean
Check if the node can be the root of a branch exposed in a ve.ce.Surface

isUnwrappable() #

isWrapped() #

matches(type, [attributes]) → {boolean} #

Check if the node matches type and attribute values.

Parameters:

Name Type Attributes Description
type string

Node type to match

attributes Object optional

Node attributes to match

Inherited from:
Source:

Returns:

Node matches type and attribute values

Type
boolean
Check if the node matches type and attribute values.

setLength(length) #

Set the inner length of the node.

This should only be called after a relevant change to the document data. Calling this method will not change the document data.

Parameters:

Name Type Description
length number

Length of content

Inherited from:
Source:

Fires:

Throws:

Invalid content length error if length is less than 0

Type
Error
Set the inner length of the node.

shouldIgnoreChildren() #

suppressSlugType() → {string|null} #

A string identifier used to suppress slugs

If sequential nodes have the same non-null suppressSlugType, then no slug is shown, e.g. two floated images can return 'float' to suppress the slug between them.

Inherited from:
Source:

Returns:

Type

Type
string | null

A string identifier used to suppress slugs

If sequential nodes have the same non-null suppressSlugType, then no slug is shown, e.g.

Events

attributeChange(key, oldValue, newValue) #

Parameters:

Name Type Description
key string
oldValue any
newValue any
Inherited from:
Source:

lengthChange(diff) #

Parameters:

Name Type Description
diff number
Inherited from:
Source:

update() #