ViewStringify (engine/dev-utils)
@ckeditor/ckeditor5-engine/src/dev-utils/view
Private helper class used for converting the view tree to a string.
Filtering
Methods
-
constructor( root, selection, options = { [options.showType], [options.showPriority], [options.ignoreRoot], [options.sameSelectionCharacters], [options.renderUIElements], [options.renderRawElements], [options.domConverter] } )module:engine/dev-utils/view~ViewStringify#constructorCreates a view stringify instance.
Parameters
rootselection : DocumentSelectionA selection whose ranges should also be converted to a string.
options : ObjectAn options object.
Properties[ options.showType ] : BooleanWhen set to
true, the type of elements will be printed (<container:p>instead of<p>,<attribute:b>instead of<b>and<empty:img>instead of<img>).Defaults to
false[ options.showPriority ] : BooleanWhen set to
true, the attribute element's priority will be printed.Defaults to
false[ options.ignoreRoot ] : BooleanWhen set to
true, the root's element opening and closing tag will not be outputted.Defaults to
false[ options.sameSelectionCharacters ] : BooleanWhen set to
true, the selection inside the text is marked as{and}and the selection outside the text as[and]. When set tofalse, both are marked as[and].Defaults to
false[ options.renderUIElements ] : BooleanWhen set to
true, the inner content of eachUIElementwill be printed.Defaults to
false[ options.renderRawElements ] : BooleanWhen set to
true, the inner content of eachDefaults to
false[ options.domConverter ] : ObjectWhen set to an actual DomConverter instance, it lets the conversion go through exactly the same flow the editing view is going through, i.e. with view data filtering. Otherwise the simple stub is used.
RawElementwill be printed.Defaults to
{}
-
stringify() → Stringmodule:engine/dev-utils/view~ViewStringify#stringify -
private
_stringifyElementAttributes( element ) → Stringmodule:engine/dev-utils/view~ViewStringify#_stringifyElementAttributes -
private
_stringifyElementClose( element ) → Stringmodule:engine/dev-utils/view~ViewStringify#_stringifyElementClose -
private
_stringifyElementId( element ) → Stringmodule:engine/dev-utils/view~ViewStringify#_stringifyElementIdConverts the passed element to its id representation.
The id string representation will be returned when the passed element is an instance of attribute element, the element has an id and the current configuration allows to show the id. Otherwise returns an empty string.
Parameters
element : Element
Returns
String
-
private
_stringifyElementOpen( element ) → Stringmodule:engine/dev-utils/view~ViewStringify#_stringifyElementOpenConverts the passed element to an opening tag.
Depending on the current configuration, the opening tag can be simple (
<a>), contain a type prefix (<container:p>,<attribute:a>or<empty:img>), contain priority information (<attribute:a view-priority="20">), or contain element id (<attribute:span view-id="foo">). Element attributes will also be included (<a href="https://ckeditor.com" name="foobar">).Parameters
element : Element
Returns
String
-
private
_stringifyElementPriority( element ) → Stringmodule:engine/dev-utils/view~ViewStringify#_stringifyElementPriorityConverts the passed element to its priority representation.
The priority string representation will be returned when the passed element is an instance of attribute element and the current configuration allows to show the priority. Otherwise returns an empty string.
Parameters
element : Element
Returns
String
-
private
_stringifyElementRanges( element, offset )module:engine/dev-utils/view~ViewStringify#_stringifyElementRangesChecks if a given element has a range start or a range end placed at a given offset and returns its string representation.
Parameters
element : Elementoffset : Number
-
private
_stringifyElementType( element ) → Stringmodule:engine/dev-utils/view~ViewStringify#_stringifyElementTypeConverts the passed element's type to its string representation
Returns:
- 'attribute' for attribute elements,
- 'container' for container elements,
- 'empty' for empty elements,
- 'ui' for UI elements,
- 'raw' for raw elements,
- an empty string when the current configuration is preventing showing elements' types.
Parameters
element : Element
Returns
String
-
Checks if a given Text node has a range start or a range end placed somewhere inside. Returns a string representation of text with range delimiters placed inside.
Parameters
node : Text
-
Executes a simple walker that iterates over all elements in the view tree starting from the root element. Calls the
callbackwith parsed chunks of string data.Parameters
root : DocumentFragment | Element | Textcallback : function
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.