insertText EDITOR
¶
insertText API can be used to insert or replace text from any content block in the INK editor.
Syntax¶
insertText(text: String, path: Array<Number>, offset: Number, length?: Number)
Example¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | import INKAPI from './inkapi.js'
INKAPI.ready(() => {
const EDITOR = INKAPI.editor;
//Add `Some Text` on block [2,1] after 10 character offset
EDITOR.insertText("Some Text", [2, 1], 10);
//for replacing some text, provide length parameter too
EDITOR.insertText("Some Text", [2, 1], 10, 6);
//above line will replace the next 6 characters with the provided text
});
|