behavior: plaintext

behavior: plaintext

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

Elements

that have this behavior applied by default:

  • <plaintext>...</plaintext> display:block editor;

Attributes

that this behavior knows about:

  • readonly –  declares that element is read only.

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:

  • EDIT_VALUE_CHANGED event – value of the element was changed due to user actions. Posted (asynchronous) event.
  • EDIT_VALUE_CHANGING event – sent when value of the element is about to change. Synchronous event.

Value

string, reflects current status of internal editing buffer.

Special key combinations

  • LEFT, CTRL+LEFT, SHIFT+LEFT, CTRL+SHIFT+LEFT
  • RIGHT, CTRL+RIGHT, SHIFT+RIGHT, CTRL+SHIFT+RIGHT
  • HOME, SHIFT+HOME
  • END, SHIFT+END
  • BACKSPACE, ALT+BACKSPACE, CTRL+BACKSPACE
  • CTRL+A
  • DELETE, SHIFT+DELETE, CTRL+DELETE
  • INSERT, SHIFT+INSERT, CTRL+INSERT
  • CTRL+X
  • CTRL+V
  • CTRL+Z
  • CTRL+(LEFT)SHIFT and CTRL+(RIGHT)SHIFT – in forms having the dir attribute these key combinations switches between dir="ltr" and dir="rtl".

Commands

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

  • "edit:cut" – cut selection – copy selection to the clipboard and remove it;
  • "edit:copy" – copy selection to the clipboard;
  • "edit:paste" – paste content of the clipboard;
  • "edit:selectall" – select whole content of the element;
  • "edit:undo" – undo last editing operation;
  • "edit:redo" – redo last operation that was undone;
  • "edit:delete-next" – if there is a selection – delete selected content, otherwise delete next character;
  • "edit:delete-prev" – if there is a selection – delete selected content, otherwise delete previous character;
  • "edit:delete-word-next" – if there is a selection – delete selected content, otherwise delete next word;
  • "edit:delete-word-prev" – if there is a selection – delete selected content, otherwise delete previous word;

Methods

loadDocument
(url:string): true|false

loads file from URL into the editor;

saveDocument
(url:string): true|false

saves content to file;

setContent
(text:string): true|false

sets content from the string;

setContent
(text:string, selStart:integer, selEnd:integer): true|false

sets content from the text and selection from given selStart and selEnd;

getContent
() : [string, integer, integer]

returns content and selection as an array of three elements;