Writer Methods
Essential methods
setEditor()
| Function | Description | Parameters | Returns (sync) | Returns (async) |
|---|---|---|---|---|
| setEditor(editorInstance) | Specify the current editor instance. | Object | void | Promise<void> |
Allows you to set the editor instance that you use in your web application.
Tests: INVOX.SetWriterTarget() — sets the current editor instance.
getEditor()
| Function | Description | Parameters | Returns (sync) | Returns (async) |
|---|---|---|---|---|
| getEditor() | Get the current editor instance. | — | Object | Promise<Object> |
Tests: INVOX.GetWriterTarget() — get the current editor instance.
getText()
| Function | Description | Parameters | Returns (sync) | Returns (async) |
|---|---|---|---|---|
| getText() | Get the editor text content. | — | String | Promise<String> |
Tests: INVOX.GetText() — returns the full plain text from the editor content.
write()
| Function | Description | Parameters | Returns (sync) | Returns (async) |
|---|---|---|---|---|
| write(text) | Write in the editor where the caret is. | String | void | Promise<void> |
Tests: INVOX.Write(), INVOX.AppendText(), INVOX.PrependText(), INVOX.ClearText()
getSelection()
| Function | Description | Parameters | Returns (sync) | Returns (async) |
|---|---|---|---|---|
| getSelection() | Get the range of the current selection. | — | INVOX.Range | Promise<INVOX.Range> |
Returns an INVOX.Range object. If there is no selection, returns the current caret position.
e.g: Consider ^ as the caret position, and [ ] the selection.
EDITOR CONTENT: "this [is all text] in the editor"
CALL: getSelection()
OUTPUT: new INVOX.Range(5, 16)
Tests: INVOX.Write() — writes the text at the position of the current selection.
setSelection()
| Function | Description | Parameters | Returns (sync) | Returns (async) |
|---|---|---|---|---|
| setSelection(range) | Select text in the current editor. | INVOX.Range | void | Promise<void> |
If the values of start and end are the same, you are setting the position of the caret.
e.g:
EDITOR CONTENT: "this is all text in the editor^"
CALL: setSelection(new INVOX.Range(5, 16))
EDITOR CONTENT: "this [is all text] in the editor"
Tests: INVOX.SetSelection() — select the range of text passed as a parameter.
getTextContext()
| Function | Description | Parameters | Returns (sync) | Returns (async) |
|---|---|---|---|---|
| getTextContext() | Get the context around the caret position. | — | Array<String> | Promise<Array<String>> |
getSelection() and getText() implemented, you can skip this method — it is automatically derived from them.Returns [leftText, rightText] — the text before and after the caret. Used by Invox Dictation to decide whether to include spaces or capital letters when typing.
Extra methods
undo()
| Function | Description | Parameters | Returns (sync) | Returns (async) |
|---|---|---|---|---|
| undo() | Apply undo in the editor. | — | void | Promise<void> |
redo()
| Function | Description | Parameters | Returns (sync) | Returns (async) |
|---|---|---|---|---|
| redo() | Apply redo in the editor. | — | void | Promise<void> |
updateRedoUndoStack()
| Function | Description | Parameters | Returns (sync) | Returns (async) |
|---|---|---|---|---|
| updateRedoUndoStack() | Manage the redo/undo operations stack. | — | void | Promise<void> |
writeNewLine()
| Function | Description | Parameters | Returns (sync) | Returns (async) |
|---|---|---|---|---|
| writeNewLine() | Specify the line break format for the editor. | — | void | Promise<void> |
By default, Invox Dictation writes \n. Override this if your editor uses a different format (e.g. <br>):
myWriter.writeNewLine = function() {
this.write("<br>");
}
writeNewParagraph()
| Function | Description | Parameters | Returns (sync) | Returns (async) |
|---|---|---|---|---|
| writeNewParagraph() | Specify the paragraph break format for the editor. | — | void | Promise<void> |
By default, Invox Dictation writes \n\n. Override this if your editor uses a different format.