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
module:engine/view/textproxy~TextProxy#data
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
module:engine/view/textproxy~TextProxy#isPartial
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
module:engine/view/textproxy~TextProxy#offsetInText
readonly
Offset in the
textNode
where thisTextProxy
instance starts. -
offsetSize : Number
module:engine/view/textproxy~TextProxy#offsetSize
readonly
Offset size of this node.
-
parent : Element | DocumentFragment | null
module:engine/view/textproxy~TextProxy#parent
readonly
Parent of this text proxy, which is same as parent of text node represented by this text proxy.
-
root : Node | DocumentFragment
module:engine/view/textproxy~TextProxy#root
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 )
module:engine/view/textproxy~TextProxy#constructor
protected
Creates a text proxy.
-
getAncestors( options = { [options.includeSelf], [options.parentFirst] } ) → Array
module:engine/view/textproxy~TextProxy#getAncestors
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
module:engine/view/textproxy~TextProxy#is
Checks whether this object is of the given type.
textProxy.is( '$textProxy' ); // -> true textProxy.is( 'view:$textProxy' ); // -> true textProxy.is( 'model:$textProxy' ); // -> false textProxy.is( 'element' ); // -> false textProxy.is( 'range' ); // -> false
Check the entire list of view objects which implement the
is()
method.Note: Until version 20.0.0 this method wasn't accepting
'$textProxy'
type. The legacy'textProxy'
type is still accepted for backward compatibility.Parameters
type : String
Type to check.
Returns
Boolean
Every day, we work hard to keep our documentation complete. Have you spotted an outdated information? Is something missing? Please report it via our issue tracker.