DomConverter (engine/view)
@ckeditor/ckeditor5-engine/src/view/domconverter
DomConverter
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 Renderer
), does not keep the
state of a tree nor keeps the synchronization between the tree view and the DOM tree (use Document
).
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.
Filtering
Properties
-
Elements 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.
-
blockFillerMode : BlockFillerMode
module:engine/view/domconverter~DomConverter#blockFillerMode
The mode of a block filler used by the DOM converter.
-
readonly
inlineObjectElements : Array<string>
module:engine/view/domconverter~DomConverter#inlineObjectElements
A 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.
-
Elements which are considered pre-formatted elements.
-
readonly
renderingMode : 'data' | 'editing'
module:engine/view/domconverter~DomConverter#renderingMode
Whether to leave the View-to-DOM conversion result unchanged or improve editing experience by filtering out interactive data.
-
A 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. -
The DOM Document used to create DOM nodes.
-
private readonly
_domToViewMapping : WeakMap<HTMLElement | DocumentFragment, Element | DocumentFragment>
module:engine/view/domconverter~DomConverter#_domToViewMapping
The DOM-to-view mapping.
-
private readonly
_elementsWithTemporaryCustomProperties : Set<Element | DocumentFragment>
module:engine/view/domconverter~DomConverter#_elementsWithTemporaryCustomProperties
Set of elements with temporary custom properties that require clearing after render.
-
private readonly
_fakeSelectionMapping : WeakMap<HTMLElement, Selection>
module:engine/view/domconverter~DomConverter#_fakeSelectionMapping
Holds the mapping between fake selection containers and corresponding view selections.
-
private readonly
_inlineObjectElementMatcher : Matcher
module:engine/view/domconverter~DomConverter#_inlineObjectElementMatcher
Matcher for inline object view elements. This is an extension of a simple
inlineObjectElements
array of element names. -
private readonly
_rawContentElementMatcher : Matcher
module:engine/view/domconverter~DomConverter#_rawContentElementMatcher
Matcher for view elements whose content should be treated as raw data and not processed during the conversion from DOM nodes to view elements.
-
private readonly
_viewToDomMapping : WeakMap<Element | DocumentFragment, HTMLElement | DocumentFragment>
module:engine/view/domconverter~DomConverter#_viewToDomMapping
The view-to-DOM mapping.
Methods
-
constructor( document, options = { [options.blockFillerMode], [options.renderingMode] } )
module:engine/view/domconverter~DomConverter#constructor
Creates a DOM converter.
Parameters
document : Document
The view document instance.
options : object
An object with configuration options.
Properties[ options.blockFillerMode ] : BlockFillerMode
The 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
{}
-
bindDocumentFragments( domFragment, viewFragment ) → void
module:engine/view/domconverter~DomConverter#bindDocumentFragments
Binds DOM and view document fragments, so it will be possible to get corresponding document fragments using
mapDomToView
andmapViewToDom
.Parameters
domFragment : DocumentFragment
The DOM document fragment to bind.
viewFragment : DocumentFragment
The view document fragment to bind.
Returns
void
-
bindElements( domElement, viewElement ) → void
module:engine/view/domconverter~DomConverter#bindElements
Binds DOM and view elements, so it will be possible to get corresponding elements using
mapDomToView
andmapViewToDom
.Parameters
domElement : HTMLElement
The DOM element to bind.
viewElement : Element
The view element to bind.
Returns
void
-
bindFakeSelection( domElement, viewDocumentSelection ) → void
module:engine/view/domconverter~DomConverter#bindFakeSelection
Binds 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
fakeSelectionToView
method.Parameters
domElement : HTMLElement
viewDocumentSelection : DocumentSelection
Returns
void
-
domChildrenToView( domElement, options = { [options.bind], [options.keepOriginalCase], [options.skipComments], [options.withChildren] }, inlineNodes ) → IterableIterator<Node>
module:engine/view/domconverter~DomConverter#domChildrenToView
Converts children of the DOM element to view nodes using the
domToView
method. Additionally this method omits block filler, if it exists in the DOM parent.Parameters
domElement : HTMLElement
Parent DOM element.
options : undefined | object
See
domToView
options parameter.Properties[ options.bind ] : boolean
[ options.keepOriginalCase ] : boolean
[ options.skipComments ] : boolean
[ options.withChildren ] : boolean
Defaults to
{}
inlineNodes : Array<Node>
An array that will be populated with inline nodes. It's used internally for whitespace processing.
Defaults to
[]
Returns
IterableIterator<Node>
View nodes.
-
domPositionToView( domParent, domOffset ) → null | Position
module:engine/view/domconverter~DomConverter#domPositionToView
Converts DOM parent and offset to view
Position
.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
UIElement
that 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
null
will be returned.Parameters
domParent : Node
DOM position parent.
domOffset : number
DOM position offset. You can skip it when converting the inline filler node.
Defaults to
0
Returns
null | Position
View position.
-
domRangeToView( domRange ) → null | Range
module:engine/view/domconverter~DomConverter#domRangeToView
-
domSelectionToView( domSelection ) → Selection
module:engine/view/domconverter~DomConverter#domSelectionToView
-
domToView( domNode, options = { [options.bind], [options.keepOriginalCase], [options.skipComments], [options.withChildren] } ) → null | Node | DocumentFragment
module:engine/view/domconverter~DomConverter#domToView
Converts 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
null
will be returned. For all DOM elements rendered byUIElement
that UIElement will be returned.Parameters
domNode : Node
DOM node or document fragment to transform.
options : object
Conversion options.
Properties[ options.bind ] : boolean
Determines whether new elements will be bound. False by default.
[ options.keepOriginalCase ] : boolean
If
false
, node's tag name will be converted to lower case. False by default.[ options.skipComments ] : boolean
If
false
, comment nodes will be converted to$comment
view UI elements. False by default.[ options.withChildren ] : boolean
If
true
, node's and document fragment's children will be converted too. True by default.
Defaults to
{}
Returns
null | Node | DocumentFragment
Converted node or document fragment or
null
if DOM node is a filler or the given node is an empty text node.
-
fakeSelectionToView( domElement ) → undefined | Selection
module:engine/view/domconverter~DomConverter#fakeSelectionToView
Returns a view selection instance corresponding to a given DOM element that represents fake selection. Returns
undefined
if binding to the given DOM element does not exist.Parameters
domElement : HTMLElement
Returns
undefined | Selection
-
findCorrespondingDomText( viewText ) → null | Text
module:engine/view/domconverter~DomConverter#findCorrespondingDomText
Finds 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
null
is returned.Parameters
viewText : Text
View text node.
Returns
null | Text
Corresponding DOM text node or
null
, if it was not possible to find a corresponding node.
-
findCorrespondingViewText( domText ) → null | Text | RawElement | UIElement
module:engine/view/domconverter~DomConverter#findCorrespondingViewText
Finds 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
UIElement
or aRawElement
, the parentUIElement
orRawElement
will be returned.Otherwise
null
is returned.Note that for the block or inline filler this method returns
null
.Parameters
domText : Text
DOM text node.
Returns
null | Text | RawElement | UIElement
Corresponding view text node or
null
, if it was not possible to find a corresponding node.
-
focus( viewEditable ) → void
module:engine/view/domconverter~DomConverter#focus
Focuses DOM editable that is corresponding to provided
EditableElement
.Parameters
viewEditable : EditableElement
Returns
void
-
getHostViewElement( domNode ) → null | RawElement | UIElement
module:engine/view/domconverter~DomConverter#getHostViewElement
Returns a parent
UIElement
orRawElement
that hosts the provided DOM node. Returnsnull
if there is no such parent.Parameters
domNode : Node
Returns
null | RawElement | UIElement
-
isBlockFiller( domNode ) → boolean
module:engine/view/domconverter~DomConverter#isBlockFiller
Checks if the node is an instance of the block filler for this DOM converter.
const converter = new DomConverter( viewDocument, { blockFillerMode: 'br' } ); converter.isBlockFiller( BR_FILLER( document ) ); // true converter.isBlockFiller( NBSP_FILLER( document ) ); // false
Note:: 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 : Node
DOM node to check.
Returns
boolean
True if a node is considered a block filler for given mode.
-
isDocumentFragment( node ) → node is DocumentFragment
module:engine/view/domconverter~DomConverter#isDocumentFragment
Returns
true
whennode.nodeType
equalsNode.DOCUMENT_FRAGMENT_NODE
.Parameters
node : Node
Node to check.
Returns
node is DocumentFragment
-
isDomSelectionBackward( selection ) → boolean
module:engine/view/domconverter~DomConverter#isDomSelectionBackward
Returns
true
if given selection is a backward selection, that is, if it'sfocus
is beforeanchor
.Parameters
selection : Selection
Returns
boolean
-
isDomSelectionCorrect( domSelection ) → boolean
module:engine/view/domconverter~DomConverter#isDomSelectionCorrect
Checks 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 : Selection
The DOM selection object to be checked.
Returns
boolean
true
if the given selection is at a correct place,false
otherwise.
-
isElement( node ) → node is HTMLElement
module:engine/view/domconverter~DomConverter#isElement
Returns
true
whennode.nodeType
equalsNode.ELEMENT_NODE
.Parameters
node : Node
Node to check.
Returns
node is HTMLElement
-
mapDomToView( domElementOrDocumentFragment ) → undefined | Element | DocumentFragment
module:engine/view/domconverter~DomConverter#mapDomToView
Returns corresponding view Element or
DocumentFragment
for provided DOM element or document fragment. If there is no view item bound to the given DOM -undefined
is returned.For all DOM elements rendered by a
UIElement
or aRawElement
, the parentUIElement
orRawElement
will be returned.Parameters
domElementOrDocumentFragment : HTMLElement | DocumentFragment
DOM element or document fragment.
Returns
undefined | Element | DocumentFragment
Corresponding view element, document fragment or
undefined
if no element was bound.
-
mapViewToDom( documentFragment ) → undefined | DocumentFragment
module:engine/view/domconverter~DomConverter#mapViewToDom:DOCUMENT_FRAGMENT
Returns corresponding DOM item for provided Element or DocumentFragment. To find a corresponding text for view Text instance use
findCorrespondingDomText
.Parameters
documentFragment : DocumentFragment
View element or document fragment.
Returns
undefined | DocumentFragment
Corresponding DOM node or document fragment.
-
mapViewToDom( documentFragmentOrElement ) → undefined | HTMLElement | DocumentFragment
module:engine/view/domconverter~DomConverter#mapViewToDom:DOCUMENT_FRAGMENT_OR_ELEMENT
Returns corresponding DOM item for provided Element or DocumentFragment. To find a corresponding text for view Text instance use
findCorrespondingDomText
.Parameters
documentFragmentOrElement : Element | DocumentFragment
View element or document fragment.
Returns
undefined | HTMLElement | DocumentFragment
Corresponding DOM node or document fragment.
-
mapViewToDom( element ) → undefined | HTMLElement
module:engine/view/domconverter~DomConverter#mapViewToDom:ELEMENT
Returns corresponding DOM item for provided Element or DocumentFragment. To find a corresponding text for view Text instance use
findCorrespondingDomText
.Parameters
element : Element
View element or document fragment.
Returns
undefined | HTMLElement
Corresponding DOM node or document fragment.
-
registerInlineObjectMatcher( pattern ) → void
module:engine/view/domconverter~DomConverter#registerInlineObjectMatcher
Registers a
MatcherPattern
for inline object view elements.This is affecting how
domToView
anddomChildrenToView
process DOM nodes.This is an extension of a simple
inlineObjectElements
array of element names.Parameters
pattern : MatcherPattern
Pattern matching a view element which should be treated as an inline object.
Returns
void
-
registerRawContentMatcher( pattern ) → void
module:engine/view/domconverter~DomConverter#registerRawContentMatcher
Registers a
MatcherPattern
for 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
domToView
anddomChildrenToView
process DOM nodes.The raw data can be later accessed by a custom property of a view element called
"$rawContent"
.Parameters
pattern : MatcherPattern
Pattern matching a view element whose content should be treated as raw data.
Returns
void
-
removeDomElementAttribute( domElement, key ) → void
module:engine/view/domconverter~DomConverter#removeDomElementAttribute
Removes an attribute from a DOM element.
Note: To set the attribute, use
setDomElementAttribute
.Parameters
domElement : HTMLElement
The DOM element the attribute should be removed from.
key : string
The name of the attribute.
Returns
void
-
setContentOf( domElement, html ) → void
module:engine/view/domconverter~DomConverter#setContentOf
Set
domElement
's content using providedhtml
argument. Apply necessary filtering for the editing pipeline.Parameters
domElement : HTMLElement
DOM element that should have
html
set as its content.html : string
Textual representation of the HTML that will be set on
domElement
.
Returns
void
-
setDomElementAttribute( domElement, key, value, [ relatedViewElement ] ) → void
module:engine/view/domconverter~DomConverter#setDomElementAttribute
Sets the attribute on a DOM element.
Note: To remove the attribute, use
removeDomElementAttribute
.Parameters
domElement : HTMLElement
The DOM element the attribute should be set on.
key : string
The name of the attribute.
value : string
The value of the attribute.
[ relatedViewElement ] : Element
The 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 theDowncastWriter
methods can allow certain attributes that would normally be filtered out.
Returns
void
-
shouldRenderAttribute( attributeKey, attributeValue, elementName ) → boolean
module:engine/view/domconverter~DomConverter#shouldRenderAttribute
Decides whether a given pair of attribute key and value should be passed further down the pipeline.
Parameters
attributeKey : string
attributeValue : string
elementName : string
Element name in lower case.
Returns
boolean
-
unbindDomElement( domElement ) → void
module:engine/view/domconverter~DomConverter#unbindDomElement
Unbinds 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 : HTMLElement
The DOM element to unbind.
Returns
void
-
viewChildrenToDom( viewElement, options = { [options.bind], [options.withChildren] } ) → IterableIterator<Node>
module:engine/view/domconverter~DomConverter#viewChildrenToDom
Converts children of the view element to DOM using the
viewToDom
method. Additionally, this method adds block filler to the list of children, if needed.Parameters
viewElement : Element | DocumentFragment
Parent view element.
options : object
See
viewToDom
options parameter.Properties[ options.bind ] : boolean
[ options.withChildren ] : boolean
Defaults to
{}
Returns
IterableIterator<Node>
DOM nodes.
-
viewPositionToDom( viewPosition ) → null | object
module:engine/view/domconverter~DomConverter#viewPositionToDom
Converts view
Position
to 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 : Position
View position.
Returns
null | object
DOM position or
null
if view position could not be converted to DOM. DOM position has two properties:parent
- DOM position parent.offset
- DOM position offset.
-
viewRangeToDom( viewRange ) → Range
module:engine/view/domconverter~DomConverter#viewRangeToDom
-
viewToDom( viewNode, [ options ] = { [options.bind], [options.withChildren] } ) → HTMLElement
module:engine/view/domconverter~DomConverter#viewToDom
Converts the view to the DOM. For all text nodes, not bound elements and document fragments new items will be created. For bound elements and document fragments the method will return corresponding items.
Parameters
viewNode : Element
View node or document fragment to transform.
[ options ] : object
Conversion options.
Properties[ options.bind ] : boolean
Determines whether new elements will be bound.
[ options.withChildren ] : boolean
If
false
, node's and document fragment's children will not be converted.
Returns
HTMLElement
Converted node or DocumentFragment.
-
viewToDom( viewNode, [ options ] = { [options.bind], [options.withChildren] } ) → DocumentFragment
module:engine/view/domconverter~DomConverter#viewToDom
Converts the view to the DOM. For all text nodes, not bound elements and document fragments new items will be created. For bound elements and document fragments the method will return corresponding items.
Parameters
viewNode : DocumentFragment
View node or document fragment to transform.
[ options ] : object
Conversion options.
Properties[ options.bind ] : boolean
Determines whether new elements will be bound.
[ options.withChildren ] : boolean
If
false
, node's and document fragment's children will not be converted.
Returns
DocumentFragment
Converted node or DocumentFragment.
-
viewToDom( viewNode, [ options ] = { [options.bind], [options.withChildren] } ) → Node
module:engine/view/domconverter~DomConverter#viewToDom
Converts the view to the DOM. For all text nodes, not bound elements and document fragments new items will be created. For bound elements and document fragments the method will return corresponding items.
Parameters
viewNode : Node
View node or document fragment to transform.
[ options ] : object
Conversion options.
Properties[ options.bind ] : boolean
Determines whether new elements will be bound.
[ options.withChildren ] : boolean
If
false
, node's and document fragment's children will not be converted.
Returns
Node
Converted node or DocumentFragment.
-
viewToDom( viewNode, [ options ] = { [options.bind], [options.withChildren] } ) → Text
module:engine/view/domconverter~DomConverter#viewToDom
Converts the view to the DOM. For all text nodes, not bound elements and document fragments new items will be created. For bound elements and document fragments the method will return corresponding items.
Parameters
viewNode : Text
View node or document fragment to transform.
[ options ] : object
Conversion options.
Properties[ options.bind ] : boolean
Determines whether new elements will be bound.
[ options.withChildren ] : boolean
If
false
, node's and document fragment's children will not be converted.
Returns
Text
Converted node or DocumentFragment.
-
Remove DOM selection from blurred editable, so it won't interfere with clicking on dropdowns (especially on iOS).
Returns
void
-
internal
_clearTemporaryCustomProperties() → void
module:engine/view/domconverter~DomConverter#_clearTemporaryCustomProperties
-
private
_createReplacementDomElement( elementName, [ originalDomElement ] ) → HTMLElement
module:engine/view/domconverter~DomConverter#_createReplacementDomElement
Return 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 : string
The name of view element.
[ originalDomElement ] : HTMLElement
The original DOM element to copy attributes and content from.
Returns
HTMLElement
-
private
_createViewElement( node, options = { [options.keepOriginalCase] } ) → Element
module:engine/view/domconverter~DomConverter#_createViewElement
Creates view element basing on the node type.
Parameters
node : Node
DOM node to check.
options : object
Conversion options. See
domToView
options parameter.Properties[ options.keepOriginalCase ] : boolean
Returns
-
private
_domToView( domNode, options = { [options.bind], [options.keepOriginalCase], [options.skipComments], [options.withChildren] }, inlineNodes ) → IterableIterator<null | Node | DocumentFragment>
module:engine/view/domconverter~DomConverter#_domToView
Internal generator for
domToView
. Also used bydomChildrenToView
. Separates DOM nodes conversion from whitespaces processing.Parameters
domNode : Node
DOM node or document fragment to transform.
options : object
-
Properties
[ options.bind ] : boolean
[ options.keepOriginalCase ] : boolean
[ options.skipComments ] : boolean
[ options.withChildren ] : boolean
inlineNodes : Array<Node>
An array of recently encountered inline nodes truncated to the block element boundaries. Used later to process whitespaces.
Returns
IterableIterator<null | Node | DocumentFragment>
-
-
private
_getTouchingInlineViewNode( node, getNext ) → null | Element | TextProxy
module:engine/view/domconverter~DomConverter#_getTouchingInlineViewNode
Helper 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,
null
is returned.Parameters
node : Text
Reference node.
getNext : boolean
Returns
-
private
_isBlockDomElement( node ) → boolean
module:engine/view/domconverter~DomConverter#_isBlockDomElement
Returns
true
if a DOM node belongs toblockElements
.false
otherwise.Parameters
node : Node
Returns
boolean
-
private
_isBlockViewElement( node ) → boolean
module:engine/view/domconverter~DomConverter#_isBlockViewElement
Returns
true
if a view node belongs toblockElements
.false
otherwise.Parameters
node : Node
Returns
boolean
-
private
_isDomSelectionPositionCorrect( domParent, offset ) → boolean
module:engine/view/domconverter~DomConverter#_isDomSelectionPositionCorrect
Checks if the given DOM position is a correct place for selection boundary. See
isDomSelectionCorrect
.Parameters
domParent : Node
Position parent.
offset : number
Position offset.
Returns
boolean
true
if given position is at a correct place for selection boundary,false
otherwise.
-
private
_isInlineObjectElement( node ) → node is Element
module:engine/view/domconverter~DomConverter#_isInlineObjectElement
Returns
true
if a DOM node belongs toinlineObjectElements
.false
otherwise.Parameters
node : Node | DocumentFragment | TextProxy
Returns
node is Element
-
private
_isPreFormatted( node ) → boolean
module:engine/view/domconverter~DomConverter#_isPreFormatted
Checks whether given text contains preformatted white space. This is the case if
- any of node ancestors has a name which is in
preElements
array, or - the closest ancestor that has the
white-space
CSS property sets it to a value that preserves spaces
Parameters
Returns
boolean
true
if given node contains preformatted white space,false
otherwise.
- any of node ancestors has a name which is in
-
private
_isViewElementWithRawContent( viewElement, options = { [options.withChildren] } ) → boolean
module:engine/view/domconverter~DomConverter#_isViewElementWithRawContent
Checks if view element's content should be treated as a raw data.
Parameters
viewElement : Element | DocumentFragment
View element to check.
options : object
Conversion options. See
domToView
options parameter.Properties[ options.withChildren ] : boolean
Returns
boolean
-
private
_nodeEndsWithSpace( node ) → boolean
module:engine/view/domconverter~DomConverter#_nodeEndsWithSpace
Checks whether given node ends with a space character after changing appropriate space characters to
s.Parameters
node : TextProxy
Node to check.
Returns
boolean
true
if givennode
ends with space,false
otherwise.
-
private
_processDataFromViewText( node ) → string
module:engine/view/domconverter~DomConverter#_processDataFromViewText
Takes text data from a given
data
and 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
preElements
is not processed.Parameters
Returns
string
Processed text data.
- a space at the beginning is changed to
-
private
_processDomInlineNodes( domParent, inlineNodes, options = { [options.withChildren] } ) → void
module:engine/view/domconverter~DomConverter#_processDomInlineNodes
Internal helper that walks the list of inline view nodes already generated from DOM nodes and handles whitespaces and NBSPs.
Parameters
domParent : null | HTMLElement
The DOM parent of the given inline nodes. This should be a document fragment or a block element to whitespace processing start cleaning.
inlineNodes : Array<Node>
An array of recently encountered inline nodes truncated to the block element boundaries.
options : object
-
Properties
[ options.withChildren ] : boolean
Returns
void
-
private
_shouldRenameElement( elementName ) → boolean
module:engine/view/domconverter~DomConverter#_shouldRenameElement
Checks whether a given element name should be renamed in a current rendering mode.
Parameters
elementName : string
The name of view element.
Returns
boolean
Every day, we work hard to keep our documentation complete. Have you spotted outdated information? Is something missing? Please report it via our issue tracker.
With the release of version 42.0.0, we have rewritten much of our documentation to reflect the new import paths and features. We appreciate your feedback to help us ensure its accuracy and completeness.