Class

TextProxy (engine/view)

@ckeditor/ckeditor5-engine/src/view/textproxy

class

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.

  • document : Document | null

    readonly

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

  • offsetInText : Number

    readonly

    Offset in the textNode where this TextProxy 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.

  • textNode : Text

    readonly

    Reference to the Text element which TextProxy is a substring.

Methods

  • constructor( textNode, offsetInText, length )

    protected

    Creates a text proxy.

    Parameters

    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.

    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 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.

    Parameters

    type : String

    Returns

    Boolean