TextProxy (engine/view)



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.



  • readonly

    data : String

    Text data represented by this text proxy.

  • readonly

    document : Document | null

    View document that owns this text proxy, or null if the text proxy is inside document fragment.

  • readonly

    isPartial : Boolean

    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 equals 0) and text proxy sizes is equal to text node size.

  • readonly

    offsetInText : Number

    Offset in the textNode where this TextProxy instance starts.

  • readonly

    offsetSize : Number

    Offset size of this node.

  • readonly

    parent : Element | DocumentFragment | null

    Parent of this text proxy, which is same as parent of text node represented by this text proxy.

  • readonly

    root : Node | DocumentFragment

    Root of this text proxy, which is same as root of text node represented by this text proxy.

  • readonly

    textNode : Text

    Reference to the Text element which TextProxy is a substring.


  • protected

    constructor( textNode, offsetInText, length )

    Creates a text proxy.


    textNode : Text

    Text node which part is represented by this text proxy.

    offsetInText : Number

    Offset in text node from which the text proxy starts.

    length : Number

    Text proxy length, that is how many text node's characters, starting from offsetInText it represents.

  • getAncestors( options = { [options.includeSelf], [options.parentFirst] } ) → Array

    Returns ancestors array of this text proxy.


    options : Object

    Options object.

    [ 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



    Array with ancestors.

  • is( type ) → Boolean

    Checks whether this object is of the given type. '$textProxy' ); // -> true 'view:$textProxy' ); // -> true 'model:$textProxy' ); // -> false 'element' ); // -> false '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.


    type : String

    Type to check.