Skip to content

insertText

insertText(editor, text, start?, end?, newCursorStart?, newCursorEnd?): void

Defined in: utils/index.ts:108

Inserts text into the editor (unless it’s read-only) while keeping undo/redo history. Focuses the textarea if it isn’t already.

PrismEditor

Target editor.

string

Text to insert.

Position to start the insertion. Defaults to selectionStart.

number | null

Position to end the insertion. Defaults to start if specified, else selectionEnd.

number | null

New starting position for the cursor. Defaults to the end of the inserted text.

number | null

New ending position for the cursor. Defaults to newCursorStart.

number | null

void