Writer Quick Start
To expedite your integration we provide templates to implement your own TextWriter. Follow the instructions below:
- Choose the correct template and copy the full code into a JavaScript file.
- Implement the essential methods and optionally the extra methods.
- Set up the writer via the Invox Dictation API.
- Test functionality.
Choose a template
If you are unsure about the type of editor you are using, check the editor's documentation to determine if its write/read operations return Promises.
Choose a template and implement its methods:
Implement methods
To create your TextWriter, implement the following essential methods:
| Function | Purpose | Mandatory |
|---|---|---|
writer.setEditor() | Handle one or several editor instances. | ✅ |
writer.getEditor() | Obtain the current editor instance. | ✅ |
writer.getText() | Obtain the full text from the editor. | ✅ |
writer.write() | Enable write operations in the editor. | ✅ |
writer.getSelection() | Obtain selections and the current caret position. | ✅ |
writer.setSelection() | Enable navigation commands through the text. | ✅ |
writer.getTextContext() | Enable write text with format. | Optional |
You can also implement extra methods:
| Function | Purpose | Mandatory |
|---|---|---|
writer.undo() | Enable undo operation. | Optional |
writer.redo() | Enable redo operation. | Optional |
writer.updateRedoUndoStack() | Enable redo/undo operations management. | Optional |
writer.writeNewLine() | Specify the editor new line format. | Optional |
writer.writeNewParagraph() | Specify the editor new paragraph format. | Optional |
Set up the Writer
The following API functions must be used after the user has logged in.
| API Function | Description |
|---|---|
INVOX.SetTextWriter(writer) | Sets the specific TextWriter for the editor. |
INVOX.SetWriterTarget(editorInstance) | Sets the target editor by its instance. |
// Get editor instance
const yourEditorInstance = /* ... */
// Import your Writer
const yourWriterImplementation = /* ... */
// Set the Writer
INVOX.SetTextWriter(yourWriterImplementation);
// Set the editor instance
INVOX.SetWriterTarget(yourEditorInstance);
Table of Contents