TextEditor

Annotations can be edited via a TextEditor instance instead of having to modify the annotation as a string value, which can be difficult as an annotation is in HTML format. A TextEditor for an annotation is provided via the GraphElem method annotationEditor.

Fields

Field

Type

Description

length

integer

Read only. Length of the β€œplain” text.

text

string

Read only. The styled text as an HTML document.

plainText

string

Read only. The plain text; i.e., the same as text above but with all HTML tags removed.

selection

string

Read only. The currently selected text as plain text.

selectionStart

integer

The start of the selection.

selectionEnd

integer

The end of the selection, always greater than selectionStart.

selectionAttributes

dictionary

Read only. The attributes of the text at selectionStart, as a dictionary of Text Editor Type.

Methods

flush( )

Saves all changes to the text, possibly creating an undo record.

replace( string, attributes )

Replaces the text between selectionStart and selectionEnd with string, assigning the given attributes dictionary to the new text, and sets selectionEnd to selectionStart plus the length of string (see the Text Editor Type in Application class for possible attributes keys and values).

insert( string, attributes )

Inserts string at selectionStart, assigning the given attributes dictionary to the new text, and sets selectionEnd to selectionStart plus the length of string (see the Text Editor Type in Application class for possible attributes keys and values).

remove( )

Deletes the text between selectionStart and selectionEnd and sets selectionEnd to selectionStart.

runStart( )

Searching backwards, finds the first character not matching the attributes at selectionStart starting at selectionStart and returns the index of the next character (as an integer) or zero if the start of the text is reached.

runStart( attributes )

Searching backwards, finds the first character not matching the given attributes starting at selectionStart and returns the index of the next character (as an integer) or zero if the start of the text is reached.

runLimit( )

Searching forward, finds the first character not matching the attributes at selectionStart starting at selectionStart, and returns the index of that character minus the result of calling runStart( ), as an integer.

runStart( attributes )

Searching backwards, finds the first character not matching the given attributes starting at selectionStart, and returns the index of that character minus the result of calling runStart( attributes), as an integer.

runOfSame()

Returns the number of characters with the same attributes beginning at start of string.

runOfSame(start)

Returns the number of characters with the same attributes beginning at start.

reset( string )

Replaces all the text in the editor with string, which must be an HTML document.

Last updated