behavior: plaintext

Multiline editting behavior that is optimized to handle relatively large (thousands of lines) texts.

Elements

that have this behavior applied by default:

Attributes

that this behavior knows about:

Model

Plaintext parses each line of text into separate <text> element:

<plaintext>
   <text>Line 1</text>
   <text>Line 2</text>
   <text>Line 3</text>
</plaintext>

Events

Together with the standard set of events (mouse, keyboard, focus) behavior: button generates:

Value

string, reflects current status of internal editing buffer.

Special key combinations

Commands

Commands supported by the behavior through Element.execCommand() and Element.queryMethods()

Script API

Note: API of plaintext is accessible on element by using .plaintext. interface modifier:

const editor = $(plaintext#editor);
editor.plaintext.load("file://users/documents/readme.txt");

Index accessor and enumeration

plaintext[index:integer]
string, get/set text line at given position. Use it as: var firstLine = el.plaintext[0];
for(var line in el.plaintext) 
string, allows to enumerate text lines one by one. 

Properties

plaintext.content
plaintext.lines
read-only, integer, reports number of lines;
plaintext.selectionStart
plaintext.selectionEnd
read-only, [lineNumber, linePosition], returns array that contains two elements: line number and position inside the line;
plaintext.selectionText
read-only, selected text or empty sting if there is no selection or selection is collapsed.

Methods

plaintext.load
(url:string): true|false

loads file from URL into the editor;

plaintext.save
(url:string): true|false

saves content to file defined by the file url;

plaintext.selectRange
(startLine:integer, startPosition:integer, endLine:integer, endPosition:integer)

selects text range;

plaintext.appendLine
(text:string | lines: array): true|false

appends line at the end of the text;

plaintext.insertLine
(at: integer, text:string | lines: array): true|false

inserts line at position n;

plaintext.removeLine
(at : integer [, count: integer) : true|false

removes line[s] at position;