Expand all

ve.dm.DomFromModelConverter

Constructor

new ve.dm.DomFromModelConverter(modelRegistry, nodeFactory) #

Provides HTML DOM to VisualEditor linear data conversion functionality to ve.dm.Converter.

Parameters:

Name Type Description
modelRegistry ve.dm.ModelRegistry
nodeFactory ve.dm.NodeFactory
Source:

Provides HTML DOM to VisualEditor linear data conversion functionality to ve.dm.Converter.

Properties

computedAttributes :Array.<string>static #

List of HTML attribute names that {#renderHtmlAttributeList} should use computed values for.

Type:

Source:
List of HTML attribute names that {#renderHtmlAttributeList} should use computed values for.

Methods

doesModeNeedRendering() → {boolean} #

Checks if the current mode needs a full view rendering in the HTML

Source:

Returns:

Mode needs a rendering

Type
boolean
Checks if the current mode needs a full view rendering in the HTML

getDomElementsFromDataElement(dataElements, doc, [childDomElements]) → {Array.<Node>|boolean}private #

Get the DOM element for a given linear model element.

This invokes the toDomElements function registered for the element type.

Parameters:

Name Type Attributes Description
dataElements ve.dm.LinearData.Element | Array.<ve.dm.LinearData.Item>

Linear model element or data slice

doc HTMLDocument

Document to create DOM elements in

childDomElements Array.<Node> optional

Array of child DOM elements to pass in (annotations only)

Source:

Returns:

DOM elements, or false if the element cannot be converted. If the first DOMelement has a 'handledOwnChildren' property set, the converter treats it as if it were a handlesOwnChildren node.

Type
Array.<Node> | boolean
Get the DOM element for a given linear model element.

getDomFromModel(model, [mode]) → {HTMLDocument} #

Convert document model to an HTML DOM

Parameters:

Name Type Attributes Default Description
model ve.dm.Document

Document model

mode number optional
PARSER_MODE

Conversion mode, defaults to PARSER_MODE

Source:

Returns:

Document containing the resulting HTML

Type
HTMLDocument
Convert document model to an HTML DOM

getDomFromNode(node, [mode]) → {HTMLDocument} #

Convert model node to an HTML DOM

Parameters:

Name Type Attributes Default Description
node ve.dm.Node

Model node

mode number optional
PARSER_MODE

Conversion mode, defaults to PARSER_MODE

Source:

Returns:

Document containing the resulting HTML

Type
HTMLDocument
Convert model node to an HTML DOM

getDomSubtreeFromData(data, container, [innerWhitespace]) #

Convert linear model data to an HTML DOM subtree and add it to a container element.

Parameters:

Name Type Attributes Description
data Array.<ve.dm.LinearData.Item>

Linear model data

container HTMLElement

DOM element to add the generated elements to. Should be empty.

innerWhitespace Array.<(string|undefined)> optional

Inner whitespace if the container is the body

Source:

Throws:

Unbalanced data: looking for closing /type

Convert linear model data to an HTML DOM subtree and add it to a container element.

getDomSubtreeFromModel(model, container, [mode]) #

Convert document model to an HTML DOM subtree and add it to a container element.

Parameters:

Name Type Attributes Default Description
model ve.dm.Document

Document model

container HTMLElement

DOM element to add the generated elements to. Should be empty.

mode number optional
PARSER_MODE

Conversion mode, defaults to PARSER_MODE

Source:
Convert document model to an HTML DOM subtree and add it to a container element.

getMode() → {number} #

Get the converter mode, one of PARSER_MODE, CLIPBOARD_MODE or PREVIEW_MODE

Source:

Returns:

Converter mode

Type
number
Get the converter mode, one of PARSER_MODE, CLIPBOARD_MODE or PREVIEW_MODE

getStore() → {ve.dm.HashValueStore|null} #

Get the HashValueStore used for the current conversion.

Source:

Returns:

Current store, or null if not converting

Type
ve.dm.HashValueStore | null
Get the HashValueStore used for the current conversion.

isForClipboard() → {boolean} #

Is the current conversion for the clipboard

Source:

Returns:

The conversion is for the clipboard

Type
boolean
Is the current conversion for the clipboard

isForParser() → {boolean} #

Is the current conversion for the parser

Source:

Returns:

The conversion is for the paser

Type
boolean
Is the current conversion for the parser

isForPreview() → {boolean} #

Is the current conversion for the preview

Source:

Returns:

The conversion is for the preview

Type
boolean
Is the current conversion for the preview

openAndCloseAnnotations(currentSet, targetSet, open, close, [forSerialization])static #

Utility function for annotation rendering. Transforms one set of annotations into another by opening and closing annotations. Each time an annotation is opened or closed, the associated callback is called with the annotation passed as a parameter.

Note that currentSet will be modified, and will be equal to targetSet once this function returns.

Parameters:

Name Type Attributes Default Description
currentSet ve.dm.AnnotationSet

The set of annotations currently opened. Will be modified.

targetSet ve.dm.AnnotationSet

The set of annotations we want to have.

open function

Callback called when an annotation is opened. Passed a ve.dm.Annotation.

close function

Callback called when an annotation is closed. Passed a ve.dm.Annotation.

forSerialization boolean optional
true

Compare annotations for serialization

Source:
Utility function for annotation rendering.

renderHtmlAttributeList(originalDomElements, targetDomElements, [filter], [computed], [deep])static #

Copy attributes from one set of DOM elements to another.

Parameters:

Name Type Attributes Default Description
originalDomElements Array.<HTMLElement>

Array of DOM elements to render from

targetDomElements Array.<HTMLElement>

Array of DOM elements to render onto

filter boolean | function optional
true

Attribute filter

computed boolean optional
false

If true, use the computed values of attributes where available

deep boolean optional
false

Recurse into child nodes

Source:
Copy attributes from one set of DOM elements to another.