Constructor
new ve.dm.ModelFromDomConverter(modelRegistry, nodeFactory, annotationFactory)
#
Provides VisualEditor linear data to HTML DOM conversion
functionality to ve.dm.Converter.
Parameters:
| Name | Type | Description |
|---|---|---|
modelRegistry |
ve.dm.ModelRegistry | |
nodeFactory |
ve.dm.NodeFactory | |
annotationFactory |
ve.dm.AnnotationFactory |
Provides VisualEditor linear data to HTML DOM conversion
functionality to ve.dm.Converter.
Methods
canCloseWrapper() → {boolean|null}
#
null}
#
Whether the active wrapper can be closed. Note that this is specific to the current recursion level. If there is no active wrapper, this returns false.
Returns:
Boolean indicating whether the wrapper can be closed, or null if not converting
- Type
-
boolean
|
null
createDataElements(modelClass, domElements) → {ve.dm.LinearData.Element|Array.<ve.dm.LinearData.Item>|null}private
#
null}private
#
Create a data element from a DOM element.
Parameters:
| Name | Type | Description |
|---|---|---|
modelClass |
ve.dm.Model | Model class to use for conversion |
domElements |
Array.<Node> | DOM elements to convert |
Returns:
Data element or array of linear model data, or null to alienate
- Type
-
ve.dm.LinearData.Element
|
Array.<ve.dm.LinearData.Item>
|
null
getCurrentContext() → {Object|null}
#
null}
#
Get the current conversion context. This is the recursion state of getDataFromDomSubtree().
Returns:
Context object, or null if not converting
- Type
-
Object
|
null
getDataFromDomClean(domElement, [wrapperElement], [annotationSet]) → {Array.<ve.dm.LinearData.Item>}
#
Wrapper for getDataFromDom which resets contextStack before the call and then set it back after the call.
TODO: This is kind of a hack, better implementation would be more appropriate in near future.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
domElement |
HTMLElement | HTML element to convert |
|
wrapperElement |
Object |
optional |
Data element to wrap the returned data in |
annotationSet |
ve.dm.AnnotationSet |
optional |
Override the set of annotations to use |
Returns:
Linear model data
- Type
- Array.<ve.dm.LinearData.Item>
Wrapper for getDataFromDom which resets contextStack before the call and then set it back after the call.
getDataFromDomSubtree(domElement, [wrapperElement], [annotationSet]) → {Array.<ve.dm.LinearData.Item>}
#
Get linear model data from a DOM node. Called recursively. For internal use
and ve.dm.Model.static.toDataElement() implementations.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
domElement |
HTMLElement | HTML element to convert |
|
wrapperElement |
Object |
optional |
Data element to wrap the returned data in |
annotationSet |
ve.dm.AnnotationSet |
optional |
Override the set of annotations to use |
Returns:
Linear model data
- Type
- Array.<ve.dm.LinearData.Item>
getHtmlDocument() → {HTMLDocument|null}
#
null}
#
Get the HTML document currently being converted
Returns:
HTML document being converted, or null if not converting
- Type
-
HTMLDocument
|
null
getInnerWhitespace(data) → {Array.<(string|undefined)>}private
#
Get inner whitespace from linear data
Parameters:
| Name | Type | Description |
|---|---|---|
data |
ve.dm.LinearData | Linear model data |
Returns:
Sparse array of whitespace strings: [ innerLeft, innerRight ]
- Type
- Array.<(string|undefined)>
getModelFromDom(doc, [options], [store]) → {ve.dm.Document}
#
Convert an HTML document to a document model.
Parameters:
| Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
doc |
HTMLDocument | HTML document to convert |
|||||||||||||||||||||||||||
options |
Object |
optional |
Conversion options Properties:
|
||||||||||||||||||||||||||
store |
ve.dm.HashValueStore |
optional |
new ve.dm.HashValueStore() | Hash value store |
Returns:
Document model
- Type
- ve.dm.Document
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
getTargetHtmlDocument() → {HTMLDocument|null}
#
null}
#
Get the HTML document we are converting data for
Returns:
HTML document being converted for, or null if not converting
- Type
-
HTMLDocument
|
null
isExpectingContent() → {boolean|null}
#
null}
#
Whether the converter is currently expecting content. Note that this is specific to the current recursion level.
Returns:
Boolean indicating whether content is expected, or null if not converting
- Type
-
boolean
|
null
isFromClipboard() → {boolean|null}
#
null}
#
Is the current conversion from the clipboard
Returns:
The conversion is from the clipboard, or null if not converting
- Type
-
boolean
|
null
isInWrapper() → {boolean|null}
#
null}
#
Whether the conversion is currently inside a wrapper paragraph generated by the converter. Note that this is specific to the current recursion level.
Returns:
Boolean indicating whether we're wrapping, or null if not converting
- Type
-
boolean
|
null
isValidChildNodeType(nodeType) → {boolean|null}
#
null}
#
Whether the converter can currently accept a child node with the given type.
Parameters:
| Name | Type | Description |
|---|---|---|
nodeType |
string |
Returns:
Whether the node type is valid, or null if not converting
- Type
-
boolean
|
null
getDataContentFromText(text, [annotations]) → {Array.<ve.dm.LinearData.Item>}privatestatic
#
Get linear model data from a string optionally applying annotations
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
text |
string | Plain text to convert |
|
annotations |
ve.dm.AnnotationSet |
optional |
Annotations to apply |
Returns:
Linear model data, one element per character
- Type
- Array.<ve.dm.LinearData.Item>
moveInlineMetaItems(data)privatestatic
#
Modify linear model data in-place to move inline meta items out of content context
All branch node start items must have item.internal.metaItems = [] All inline meta items must have item.internal.isInlineMeta set to true
After the method completes, each inline meta item will be moved downward to the nearest legal block position (i.e. just after the close meta parent item), and has these properties: item.internal.loadMetaParentHash - corresponding meta parent's item.originalDomElementsHash item.internal.loadMetaParentOffset - offset at load time within the meta parent (0 for start). Each meta item is appended to the corresponding meta parent's item.internal.metaItems .
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Array.<ve.dm.LinearData.Item> | Linear model data to modify in place |
Modify linear model data in-place to move inline meta items out of content context
All branch node start items must have item.internal.metaItems = [] All inline meta items must have item.internal.isInlineMeta set to true
After the method completes, each inline meta item will be moved downward to the nearest legal block position (i.e.