ViewDomConverter
ViewDomConverter is a set of tools to do transformations between DOM nodes and view nodes. It also handles bindings between these nodes.
An instance of the DOM converter is available under editor.editing.view.domConverter.
The DOM converter does not check which nodes should be rendered (use ViewRenderer), does not keep the state of a tree nor keeps the synchronization between the tree view and the DOM tree (use ViewDocument).
The DOM converter keeps DOM elements to view element bindings, so when the converter gets destroyed, the bindings are lost. Two converters will keep separate binding maps, so one tree view can be bound with two DOM trees.
Properties
blockElements : Array<string>readonlymodule:engine/view/domconverter~ViewDomConverter#blockElementsElements which are considered block elements (and hence should be filled with a block filler).
Whether an element is considered a block element also affects handling of trailing whitespaces.
You can extend this array if you introduce support for block elements which are not yet recognized here.
module:engine/view/domconverter~ViewDomConverter#blockFillerModeThe mode of a block filler used by the DOM converter.
document : ViewDocumentreadonlymodule:engine/view/domconverter~ViewDomConverter#documentdomDocument : Documentreadonlymodule:engine/view/domconverter~ViewDomConverter#domDocumentThe DOM Document used by
ViewDomConverterto create DOM nodes.inlineObjectElements : Array<string>readonlymodule:engine/view/domconverter~ViewDomConverter#inlineObjectElementsA list of elements that exist inline (in text) but their inner structure cannot be edited because of the way they are rendered by the browser. They are mostly HTML form elements but there are other elements such as
<img>or<iframe>that also have non-editable children or no children whatsoever.Whether an element is considered an inline object has an impact on white space rendering (trimming) around (and inside of it). In short, white spaces in text nodes next to inline objects are not trimmed.
You can extend this array if you introduce support for inline object elements which are not yet recognized here.
preElements : Array<string>readonlymodule:engine/view/domconverter~ViewDomConverter#preElementsElements which are considered pre-formatted elements.
renderingMode : 'data' | 'editing'readonlymodule:engine/view/domconverter~ViewDomConverter#renderingModeWhether to leave the View-to-DOM conversion result unchanged or improve editing experience by filtering out interactive data.
unsafeElements : Array<string>readonlymodule:engine/view/domconverter~ViewDomConverter#unsafeElementsA list of elements which may affect the editing experience. To avoid this, those elements are replaced with
<span data-ck-unsafe-element="[element name]"></span>while rendering in the editing mode._domDocument : Documentprivatereadonlymodule:engine/view/domconverter~ViewDomConverter#_domDocumentThe DOM Document used by
ViewDomConverterto create DOM nodes._domToViewMapping : WeakMap<HTMLElement | DocumentFragment, ViewElement | ViewDocumentFragment>privatereadonlymodule:engine/view/domconverter~ViewDomConverter#_domToViewMappingThe DOM-to-view mapping.
_elementsWithTemporaryCustomProperties : Set<ViewElement | ViewDocumentFragment>privatereadonlymodule:engine/view/domconverter~ViewDomConverter#_elementsWithTemporaryCustomPropertiesSet of elements with temporary custom properties that require clearing after render.
_fakeSelectionMapping : WeakMap<HTMLElement, ViewSelection>privatereadonlymodule:engine/view/domconverter~ViewDomConverter#_fakeSelectionMappingHolds the mapping between fake selection containers and corresponding view selections.
_inlineObjectElementMatcher : Matcherprivatereadonlymodule:engine/view/domconverter~ViewDomConverter#_inlineObjectElementMatcherMatcher for inline object view elements. This is an extension of a simple
inlineObjectElementsarray of element names._rawContentElementMatcher : Matcherprivatereadonlymodule:engine/view/domconverter~ViewDomConverter#_rawContentElementMatcherMatcher for view elements whose content should be treated as raw data and not processed during the conversion from DOM nodes to view elements.
_viewToDomMapping : WeakMap<ViewElement | ViewDocumentFragment, HTMLElement | DocumentFragment>privatereadonlymodule:engine/view/domconverter~ViewDomConverter#_viewToDomMappingThe view-to-DOM mapping.
Methods
constructor( document, options = { [options.blockFillerMode], [options.renderingMode] } )module:engine/view/domconverter~ViewDomConverter#constructorCreates a DOM converter.
Parameters
document : ViewDocumentThe view document instance.
options : objectAn object with configuration options.
Properties[ options.blockFillerMode ] : ViewBlockFillerModeThe type of the block filler to use. Default value depends on the options.renderingMode: 'nbsp' when options.renderingMode == 'data', 'br' when options.renderingMode == 'editing'.
[ options.renderingMode ] : 'data' | 'editing'Whether to leave the View-to-DOM conversion result unchanged or improve editing experience by filtering out interactive data.
Defaults to
'editing'
Defaults to
{}
bindDocumentFragments( domFragment, viewFragment ) → voidmodule:engine/view/domconverter~ViewDomConverter#bindDocumentFragmentsBinds DOM and view document fragments, so it will be possible to get corresponding document fragments using
mapDomToViewandmapViewToDom.Parameters
domFragment : DocumentFragmentThe DOM document fragment to bind.
viewFragment : ViewDocumentFragmentThe view document fragment to bind.
Returns
void
bindElements( domElement, viewElement ) → voidmodule:engine/view/domconverter~ViewDomConverter#bindElementsBinds DOM and view elements, so it will be possible to get corresponding elements using
mapDomToViewandmapViewToDom.Parameters
domElement : HTMLElementThe DOM element to bind.
viewElement : ViewElementThe view element to bind.
Returns
void
bindFakeSelection( domElement, viewDocumentSelection ) → voidmodule:engine/view/domconverter~ViewDomConverter#bindFakeSelectionBinds a given DOM element that represents fake selection to a position of a document selection. Document selection copy is stored and can be retrieved by the
fakeSelectionToViewmethod.Parameters
domElement : HTMLElementviewDocumentSelection : ViewDocumentSelection
Returns
void
domChildrenToView( domElement, options = { [options.bind], [options.keepOriginalCase], [options.skipComments], [options.withChildren] }, inlineNodes ) → IterableIterator<ViewNode>module:engine/view/domconverter~ViewDomConverter#domChildrenToViewConverts children of the DOM element to view nodes using the
domToViewmethod. Additionally this method omits block filler, if it exists in the DOM parent.Parameters
domElement : HTMLElementParent DOM element.
options : undefined | objectSee
domToViewoptions parameter.Properties[ options.bind ] : boolean[ options.keepOriginalCase ] : boolean[ options.skipComments ] : boolean[ options.withChildren ] : boolean
Defaults to
{}inlineNodes : Array<ViewNode>An array that will be populated with inline nodes. It's used internally for whitespace processing.
Defaults to
[]
Returns
IterableIterator<ViewNode>View nodes.
domPositionToView( domParent, domOffset ) → null | ViewPositionmodule:engine/view/domconverter~ViewDomConverter#domPositionToViewConverts DOM parent and offset to view
ViewPosition.If the position is inside a filler which has no corresponding view node, position of the filler will be converted and returned.
If the position is inside DOM element rendered by
ViewUIElementthat position will be converted to view position before that UIElement.If structures are too different and it is not possible to find corresponding position then
nullwill be returned.Parameters
domParent : NodeDOM position parent.
domOffset : numberDOM position offset. You can skip it when converting the inline filler node.
Defaults to
0
Returns
null | ViewPositionView position.
domRangeToView( domRange ) → null | ViewRangemodule:engine/view/domconverter~ViewDomConverter#domRangeToViewdomSelectionToView( domSelection ) → ViewSelectionmodule:engine/view/domconverter~ViewDomConverter#domSelectionToViewConverts DOM selection to view
ViewSelection. Ranges which cannot be converted will be omitted.Parameters
domSelection : SelectionDOM selection.
Returns
ViewSelectionView selection.
domToView( domNode, options = { [options.bind], [options.keepOriginalCase], [options.skipComments], [options.withChildren] } ) → null | ViewNode | ViewDocumentFragmentmodule:engine/view/domconverter~ViewDomConverter#domToViewConverts DOM to view. For all text nodes, not bound elements and document fragments new items will be created. For bound elements and document fragments function will return corresponding items. For fillers
nullwill be returned. For all DOM elements rendered byViewUIElementthat UIElement will be returned.Parameters
domNode : NodeDOM node or document fragment to transform.
options : objectConversion options.
Properties[ options.bind ] : booleanDetermines whether new elements will be bound. False by default.
[ options.keepOriginalCase ] : booleanIf
false, node's tag name will be converted to lower case. False by default.[ options.skipComments ] : booleanIf
false, comment nodes will be converted to$commentview UI elements. False by default.[ options.withChildren ] : booleanIf
true, node's and document fragment's children will be converted too. True by default.
Defaults to
{}
Returns
null | ViewNode | ViewDocumentFragmentConverted node or document fragment or
nullif DOM node is a filler or the given node is an empty text node.
fakeSelectionToView( domElement ) → undefined | ViewSelectionmodule:engine/view/domconverter~ViewDomConverter#fakeSelectionToViewReturns a view selection instance corresponding to a given DOM element that represents fake selection. Returns
undefinedif binding to the given DOM element does not exist.Parameters
domElement : HTMLElement
Returns
undefined | ViewSelection
findCorrespondingDomText( viewText ) → null | Textmodule:engine/view/domconverter~ViewDomConverter#findCorrespondingDomTextFinds corresponding text node. Text nodes are not bound, corresponding text node is returned based on the sibling or parent.
If the directly previous sibling is a bound element, it is used to find the corresponding text node.
If this is a first child in the parent and the parent is a bound element, it is used to find the corresponding text node.
Otherwise
nullis returned.Parameters
viewText : ViewTextView text node.
Returns
null | TextCorresponding DOM text node or
null, if it was not possible to find a corresponding node.
findCorrespondingViewText( domText ) → null | ViewText | ViewRawElement | ViewUIElementmodule:engine/view/domconverter~ViewDomConverter#findCorrespondingViewTextFinds corresponding text node. Text nodes are not bound, corresponding text node is returned based on the sibling or parent.
If the directly previous sibling is a bound element, it is used to find the corresponding text node.
If this is a first child in the parent and the parent is a bound element, it is used to find the corresponding text node.
For all text nodes rendered by a
ViewUIElementor aViewRawElement, the parentUIElementorRawElementwill be returned.Otherwise
nullis returned.Note that for the block or inline filler this method returns
null.Parameters
domText : TextDOM text node.
Returns
null | ViewText | ViewRawElement | ViewUIElementCorresponding view text node or
null, if it was not possible to find a corresponding node.
focus( viewEditable ) → voidmodule:engine/view/domconverter~ViewDomConverter#focusFocuses DOM editable that is corresponding to provided
ViewEditableElement.Parameters
viewEditable : ViewEditableElement
Returns
void
getHostViewElement( domNode ) → null | ViewRawElement | ViewUIElementmodule:engine/view/domconverter~ViewDomConverter#getHostViewElementReturns a parent
ViewUIElementorViewRawElementthat hosts the provided DOM node. Returnsnullif there is no such parent.Parameters
domNode : Node
Returns
null | ViewRawElement | ViewUIElement
isBlockFiller( domNode ) → booleanmodule:engine/view/domconverter~ViewDomConverter#isBlockFillerChecks if the node is an instance of the block filler for this DOM converter.
const converter = new ViewDomConverter( viewDocument, { blockFillerMode: 'br' } ); converter.isBlockFiller( BR_FILLER( document ) ); // true converter.isBlockFiller( NBSP_FILLER( document ) ); // falseCopy codeNote:: For the
'nbsp'mode the method also checks context of a node so it cannot be a detached node.Note: A special case in the
'nbsp'mode exists where the<br>in<p><br></p>is treated as a block filler.Parameters
domNode : NodeDOM node to check.
Returns
booleanTrue if a node is considered a block filler for given mode.
isDocumentFragment( node ) → node is DocumentFragmentmodule:engine/view/domconverter~ViewDomConverter#isDocumentFragmentReturns
truewhennode.nodeTypeequalsNode.DOCUMENT_FRAGMENT_NODE.Parameters
node : NodeNode to check.
Returns
node is DocumentFragment
isDomSelectionBackward( selection ) → booleanmodule:engine/view/domconverter~ViewDomConverter#isDomSelectionBackwardReturns
trueif given selection is a backward selection, that is, if it'sfocusis beforeanchor.Parameters
selection : SelectionSelection instance to check.
Returns
boolean
isDomSelectionCorrect( domSelection ) → booleanmodule:engine/view/domconverter~ViewDomConverter#isDomSelectionCorrectChecks if the given selection's boundaries are at correct places.
The following places are considered as incorrect for selection boundaries:
- before or in the middle of an inline filler sequence,
- inside a DOM element which represents a view UI element,
- inside a DOM element which represents a view raw element.
Parameters
domSelection : SelectionThe DOM selection object to be checked.
Returns
booleantrueif the given selection is at a correct place,falseotherwise.
isElement( node ) → node is HTMLElementmodule:engine/view/domconverter~ViewDomConverter#isElementReturns
truewhennode.nodeTypeequalsNode.ELEMENT_NODE.Parameters
node : NodeNode to check.
Returns
node is HTMLElement
mapDomToView( domElementOrDocumentFragment ) → undefined | ViewElement | ViewDocumentFragmentmodule:engine/view/domconverter~ViewDomConverter#mapDomToViewReturns corresponding view Element or
ViewDocumentFragmentfor provided DOM element or document fragment. If there is no view item bound to the given DOM -undefinedis returned.For all DOM elements rendered by a
ViewUIElementor aViewRawElement, the parentUIElementorRawElementwill be returned.Parameters
domElementOrDocumentFragment : HTMLElement | DocumentFragmentDOM element or document fragment.
Returns
undefined | ViewElement | ViewDocumentFragmentCorresponding view element, document fragment or
undefinedif no element was bound.
mapViewToDom( documentFragment ) → undefined | DocumentFragmentmodule:engine/view/domconverter~ViewDomConverter#mapViewToDom:DOCUMENT_FRAGMENTReturns corresponding DOM item for provided Element or DocumentFragment. To find a corresponding text for view Text instance use
findCorrespondingDomText.Parameters
documentFragment : ViewDocumentFragmentView element or document fragment.
Returns
undefined | DocumentFragmentCorresponding DOM node or document fragment.
mapViewToDom( documentFragmentOrElement ) → undefined | HTMLElement | DocumentFragmentmodule:engine/view/domconverter~ViewDomConverter#mapViewToDom:DOCUMENT_FRAGMENT_OR_ELEMENTReturns corresponding DOM item for provided Element or DocumentFragment. To find a corresponding text for view Text instance use
findCorrespondingDomText.Parameters
documentFragmentOrElement : ViewElement | ViewDocumentFragmentView element or document fragment.
Returns
undefined | HTMLElement | DocumentFragmentCorresponding DOM node or document fragment.
mapViewToDom( element ) → undefined | HTMLElementmodule:engine/view/domconverter~ViewDomConverter#mapViewToDom:ELEMENTReturns corresponding DOM item for provided Element or DocumentFragment. To find a corresponding text for view Text instance use
findCorrespondingDomText.Parameters
element : ViewElementView element or document fragment.
Returns
undefined | HTMLElementCorresponding DOM node or document fragment.
registerInlineObjectMatcher( pattern ) → voidmodule:engine/view/domconverter~ViewDomConverter#registerInlineObjectMatcherRegisters a
MatcherPatternfor inline object view elements.This is affecting how
domToViewanddomChildrenToViewprocess DOM nodes.This is an extension of a simple
inlineObjectElementsarray of element names.Parameters
pattern : MatcherPatternPattern matching a view element which should be treated as an inline object.
Returns
void
registerRawContentMatcher( pattern ) → voidmodule:engine/view/domconverter~ViewDomConverter#registerRawContentMatcherRegisters a
MatcherPatternfor view elements whose content should be treated as raw data and not processed during the conversion from DOM nodes to view elements.This is affecting how
domToViewanddomChildrenToViewprocess DOM nodes.The raw data can be later accessed by a custom property of a view element called
"$rawContent".Parameters
pattern : MatcherPatternPattern matching a view element whose content should be treated as raw data.
Returns
void
removeDomElementAttribute( domElement, key ) → voidmodule:engine/view/domconverter~ViewDomConverter#removeDomElementAttributeRemoves an attribute from a DOM element.
Note: To set the attribute, use
setDomElementAttribute.Parameters
domElement : HTMLElementThe DOM element the attribute should be removed from.
key : stringThe name of the attribute.
Returns
void
setContentOf( domElement, html ) → voidmodule:engine/view/domconverter~ViewDomConverter#setContentOfSet
domElement's content using providedhtmlargument. Apply necessary filtering for the editing pipeline.Parameters
domElement : HTMLElementDOM element that should have
htmlset as its content.html : stringTextual representation of the HTML that will be set on
domElement.
Returns
void
setDomElementAttribute( domElement, key, value, [ relatedViewElement ] ) → voidmodule:engine/view/domconverter~ViewDomConverter#setDomElementAttributeSets the attribute on a DOM element.
Note: To remove the attribute, use
removeDomElementAttribute.Parameters
domElement : HTMLElementThe DOM element the attribute should be set on.
key : stringThe name of the attribute.
value : stringThe value of the attribute.
[ relatedViewElement ] : ViewElementThe view element related to the
domElement(if there is any). It helps decide whether the attribute set is unsafe. For instance, view elements created via theViewDowncastWritermethods can allow certain attributes that would normally be filtered out.
Returns
void
shouldRenderAttribute( attributeKey, attributeValue, elementName ) → booleanmodule:engine/view/domconverter~ViewDomConverter#shouldRenderAttributeDecides whether a given pair of attribute key and value should be passed further down the pipeline.
Parameters
attributeKey : stringattributeValue : stringelementName : stringElement name in lower case.
Returns
boolean
unbindDomElement( domElement ) → voidmodule:engine/view/domconverter~ViewDomConverter#unbindDomElementUnbinds a given DOM element from the view element it was bound to. Unbinding is deep, meaning that all children of the DOM element will be unbound too.
Parameters
domElement : HTMLElementThe DOM element to unbind.
Returns
void
viewChildrenToDom( viewElement, options = { [options.bind], [options.withChildren] } ) → IterableIterator<Node>module:engine/view/domconverter~ViewDomConverter#viewChildrenToDomConverts children of the view element to DOM using the
viewToDommethod. Additionally, this method adds block filler to the list of children, if needed.Parameters
viewElement : ViewElement | ViewDocumentFragmentParent view element.
options : objectSee
viewToDomoptions parameter.Properties[ options.bind ] : boolean[ options.withChildren ] : boolean
Defaults to
{}
Returns
IterableIterator<Node>DOM nodes.
viewPositionToDom( viewPosition ) → null | objectmodule:engine/view/domconverter~ViewDomConverter#viewPositionToDomConverts view
ViewPositionto DOM parent and offset.Inline and block fillers are handled during the conversion. If the converted position is directly before inline filler it is moved inside the filler.
Parameters
viewPosition : ViewPositionView position.
Returns
null | objectDOM position or
nullif view position could not be converted to DOM. DOM position has two properties:parent- DOM position parent.offset- DOM position offset.
viewRangeToDom( viewRange ) → Rangemodule:engine/view/domconverter~ViewDomConverter#viewRangeToDomviewToDom( viewNode, [ options ] = { [options.bind], [options.withChildren] } ) → HTMLElementmodule:engine/view/domconverter~ViewDomConverter#viewToDomParameters
viewNode : ViewElement[ options ] : object- Properties
[ options.bind ] : boolean[ options.withChildren ] : boolean
Returns
HTMLElement
viewToDom( viewNode, [ options ] = { [options.bind], [options.withChildren] } ) → DocumentFragmentmodule:engine/view/domconverter~ViewDomConverter#viewToDomParameters
viewNode : ViewDocumentFragment[ options ] : object- Properties
[ options.bind ] : boolean[ options.withChildren ] : boolean
Returns
DocumentFragment
viewToDom( viewNode, [ options ] = { [options.bind], [options.withChildren] } ) → Nodemodule:engine/view/domconverter~ViewDomConverter#viewToDomParameters
viewNode : ViewNode[ options ] : object- Properties
[ options.bind ] : boolean[ options.withChildren ] : boolean
Returns
Node
viewToDom( viewNode, [ options ] = { [options.bind], [options.withChildren] } ) → Textmodule:engine/view/domconverter~ViewDomConverter#viewToDomParameters
viewNode : ViewText[ options ] : object- Properties
[ options.bind ] : boolean[ options.withChildren ] : boolean
Returns
Text
_clearDomSelection() → voidinternalmodule:engine/view/domconverter~ViewDomConverter#_clearDomSelectionRemove DOM selection from blurred editable, so it won't interfere with clicking on dropdowns (especially on iOS).
Returns
void
_clearTemporaryCustomProperties() → voidinternalmodule:engine/view/domconverter~ViewDomConverter#_clearTemporaryCustomProperties_createReplacementDomElement( elementName, [ originalDomElement ] ) → HTMLElementprivatemodule:engine/view/domconverter~ViewDomConverter#_createReplacementDomElementReturn a element with a special attribute holding the name of the original element. Optionally, copy all the attributes of the original element if that element is provided.
Parameters
elementName : stringThe name of view element.
[ originalDomElement ] : HTMLElementThe original DOM element to copy attributes and content from.
Returns
HTMLElement
_createViewElement( node, options = { [options.keepOriginalCase] } ) → ViewElementprivatemodule:engine/view/domconverter~ViewDomConverter#_createViewElementCreates view element basing on the node type.
Parameters
node : NodeDOM node to check.
options : objectConversion options. See
domToViewoptions parameter.Properties[ options.keepOriginalCase ] : boolean
Returns
_domToView( domNode, options = { [options.bind], [options.keepOriginalCase], [options.skipComments], [options.withChildren] }, inlineNodes ) → IterableIterator<null | ViewNode | ViewDocumentFragment>privatemodule:engine/view/domconverter~ViewDomConverter#_domToViewInternal generator for
domToView. Also used bydomChildrenToView. Separates DOM nodes conversion from whitespaces processing.Parameters
domNode : NodeDOM node or document fragment to transform.
options : object- Properties
[ options.bind ] : boolean[ options.keepOriginalCase ] : boolean[ options.skipComments ] : boolean[ options.withChildren ] : boolean
inlineNodes : Array<ViewNode>An array of recently encountered inline nodes truncated to the block element boundaries. Used later to process whitespaces.
Returns
IterableIterator<null | ViewNode | ViewDocumentFragment>
_getBlockFiller() → Nodeprivatemodule:engine/view/domconverter~ViewDomConverter#_getBlockFiller_getTouchingInlineViewNode( node, getNext ) → null | ViewElement | ViewTextProxyprivatemodule:engine/view/domconverter~ViewDomConverter#_getTouchingInlineViewNodeHelper function. For given view text node, it finds previous or next sibling that is contained in the same container element. If there is no such sibling,
nullis returned.Parameters
node : ViewTextReference node.
getNext : boolean
Returns
null | ViewElement | ViewTextProxyTouching text node, an inline object or
nullif there is no next or previous touching text node.
_isBlockDomElement( node ) → booleanprivatemodule:engine/view/domconverter~ViewDomConverter#_isBlockDomElementReturns
trueif a DOM node belongs toblockElements.falseotherwise.Parameters
node : Node
Returns
boolean
_isBlockViewElement( node ) → booleanprivatemodule:engine/view/domconverter~ViewDomConverter#_isBlockViewElementReturns
trueif a view node belongs toblockElements.falseotherwise.Parameters
node : ViewNode
Returns
boolean
_isDomSelectionPositionCorrect( domParent, offset ) → booleanprivatemodule:engine/view/domconverter~ViewDomConverter#_isDomSelectionPositionCorrectChecks if the given DOM position is a correct place for selection boundary. See
isDomSelectionCorrect.Parameters
domParent : NodePosition parent.
offset : numberPosition offset.
Returns
booleantrueif given position is at a correct place for selection boundary,falseotherwise.
_isInlineObjectElement( node ) → node is ViewElementprivatemodule:engine/view/domconverter~ViewDomConverter#_isInlineObjectElementReturns
trueif a DOM node belongs toinlineObjectElements.falseotherwise.Parameters
node : ViewNode | ViewDocumentFragment | ViewTextProxy
Returns
node is ViewElement
_isPreFormatted( node ) → booleanprivatemodule:engine/view/domconverter~ViewDomConverter#_isPreFormattedChecks whether given text contains preformatted white space. This is the case if
- any of node ancestors has a name which is in
preElementsarray, or - the closest ancestor that has the
white-spaceCSS property sets it to a value that preserves spaces
Parameters
node : ViewText | ViewTextProxyNode to check
Returns
booleantrueif given node contains preformatted white space,falseotherwise.
- any of node ancestors has a name which is in
_isViewElementWithRawContent( viewElement, options = { [options.withChildren] } ) → booleanprivatemodule:engine/view/domconverter~ViewDomConverter#_isViewElementWithRawContentChecks if view element's content should be treated as a raw data.
Parameters
viewElement : ViewElement | ViewDocumentFragmentView element to check.
options : objectConversion options. See
domToViewoptions parameter.Properties[ options.withChildren ] : boolean
Returns
boolean
_nodeEndsWithSpace( node ) → booleanprivatemodule:engine/view/domconverter~ViewDomConverter#_nodeEndsWithSpaceChecks whether given node ends with a space character after changing appropriate space characters to
s.Parameters
node : ViewTextProxyNode to check.
Returns
booleantrueif givennodeends with space,falseotherwise.
_processDataFromViewText( node ) → stringprivatemodule:engine/view/domconverter~ViewDomConverter#_processDataFromViewTextTakes text data from a given
dataand processes it so it is correctly displayed in the DOM.Following changes are done:
- a space at the beginning is changed to
if this is the first text node in its container element or if a previous text node ends with a space character, - space at the end of the text node is changed to
if there are two spaces at the end of a node or if next node starts with a space or if it is the last text node in its container, - remaining spaces are replaced to a chain of spaces and
(e.g.'x x'becomes'x x').
Content of
preElementsis not processed.Parameters
node : ViewText | ViewTextProxyView text node to process.
Returns
stringProcessed text data.
- a space at the beginning is changed to
_processDomInlineNodes( domParent, inlineNodes, options = { [options.withChildren] } ) → voidprivatemodule:engine/view/domconverter~ViewDomConverter#_processDomInlineNodesInternal helper that walks the list of inline view nodes already generated from DOM nodes and handles whitespaces and NBSPs.
Parameters
domParent : null | HTMLElementThe DOM parent of the given inline nodes. This should be a document fragment or a block element to whitespace processing start cleaning.
inlineNodes : Array<ViewNode>An array of recently encountered inline nodes truncated to the block element boundaries.
options : object- Properties
[ options.withChildren ] : boolean
Returns
void
_shouldRenameElement( elementName ) → booleanprivatemodule:engine/view/domconverter~ViewDomConverter#_shouldRenameElementChecks whether a given element name should be renamed in a current rendering mode.
Parameters
elementName : stringThe name of view element.
Returns
boolean