TextProxy (engine/view)
@ckeditor/ckeditor5-engine/src/view/textproxy
TextProxy is a wrapper for substring of Text
. Instance of this class is created by
TreeWalker
when only a part of Text
needs to be returned.
TextProxy
has an API similar to Text and allows to do most of the common tasks performed
on view nodes.
Note: Some TextProxy
instances may represent whole text node, not just a part of it.
See isPartial
.
Note: TextProxy
is a readonly interface.
Note: TextProxy
instances are created on the fly basing on the current state of parent Text
.
Because of this it is highly unrecommended to store references to `TextProxy instances because they might get
invalidated due to operations on Document. Also TextProxy is not a Node
so it can not be
inserted as a child of Element
.
TextProxy
instances are created by view tree walker. You should not need to create
an instance of this class by your own.
Filtering
Properties
-
data : String
readonly
Text data represented by this text proxy.
-
View document that owns this text proxy, or
null
if the text proxy is inside document fragment. -
isPartial : Boolean
readonly
Flag indicating whether
TextProxy
instance covers only part of the original text node (true
) or the whole text node (false
).This is
false
when text proxy starts at the very beginning of textNode (offsetInText equals0
) and text proxy sizes is equal to text node size. -
offsetInText : Number
readonly
Offset in the
textNode
where thisTextProxy
instance starts. -
offsetSize : Number
readonly
Offset size of this node.
-
parent : Element | DocumentFragment | null
readonly
Parent of this text proxy, which is same as parent of text node represented by this text proxy.
-
root : Node | DocumentFragment
readonly
Root of this text proxy, which is same as root of text node represented by this text proxy.
-
Reference to the
Text
element which TextProxy is a substring.
Methods
-
constructor( textNode, offsetInText, length )
protected
Creates a text proxy.
-
getAncestors( options = { [options.includeSelf], [options.parentFirst] } ) → Array
Returns ancestors array of this text proxy.
Parameters
options : Object
Options object.
Properties[ options.includeSelf ] : Boolean
When set to
true
{#textNode} will be also included in parent's array.Defaults to
false
[ options.parentFirst ] : Boolean
When set to
true
, array will be sorted from text proxy parent to root element, otherwise root element will be the first item in the array.Defaults to
false
Returns
Array
Array with ancestors.
-
is( type ) → Boolean
Checks whether given view tree object is of given type.