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 |
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:
- Array.<string>
Methods
doesModeNeedRendering() → {boolean}
#
Checks if the current mode needs a full view rendering in the HTML
Returns:
Mode needs a rendering
- Type
- boolean
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) |
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.
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 |
Returns:
Document containing the resulting HTML
- Type
- HTMLDocument
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 |
Returns:
Document containing the resulting HTML
- Type
- HTMLDocument
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 |
Throws:
Unbalanced data: looking for closing /type
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 |
getMode() → {number}
#
Get the converter mode, one of PARSER_MODE, CLIPBOARD_MODE or PREVIEW_MODE
Returns:
Converter mode
- Type
- number
getStore() → {ve.dm.HashValueStore|null}
#
null}
#
Get the HashValueStore used for the current conversion.
Returns:
Current store, or null if not converting
- Type
-
ve.dm.HashValueStore
|
null
isForClipboard() → {boolean}
#
Is the current conversion for the clipboard
Returns:
The conversion is for the clipboard
- Type
- boolean
isForParser() → {boolean}
#
Is the current conversion for the parser
Returns:
The conversion is for the paser
- Type
- boolean
isForPreview() → {boolean}
#
Is the current conversion for the preview
Returns:
The conversion is for the preview
- Type
- boolean
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 |
||
close |
function | Callback called when an annotation is closed. Passed a |
||
forSerialization |
boolean |
optional |
true | Compare annotations for serialization |
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 |