API Reference
Complete reference for the EditorAPI object returned by createEditor().
Method Summary
| Signature | Returns | Description |
|---|---|---|
getValue() | string | Return the full document text. |
setValue(value: string) | void | Replace all content. |
insertText(text: string) | void | Insert text at the cursor. |
getCursor() | CursorPosition | Return { line, column } (zero-based). |
setCursor(pos: CursorPosition) | void | Move cursor to position. |
getSelection() | Selection | null | Return selection or null. |
setSelection(sel: Selection) | void | Programmatically set the selection range. |
undo() | void | Undo the last change. |
redo() | void | Redo the undone change. |
executeCommand(name: string) | void | Run a built-in editor command. |
setTheme(id: string) | void | Switch the active theme. |
getThemes() | string[] | List all registered theme IDs. |
registerTheme(def: ThemeDefinition) | void | Register a custom theme globally. |
updateConfig(patch: Partial<EditorConfig>) | void | Apply a partial config update. |
destroy() | void | Tear down the editor and free all resources. |
Creating an Editor
Content
Cursor & Selection
History (Undo / Redo)
Commands
Execute any built-in command by name via executeCommand(). All commands are also bound to keyboard shortcuts (see Keyboard Shortcuts).
| Command | Description |
|---|---|
undo | Undo last change. |
redo | Redo undone change. |
selectAll | Select all content. |
copy | Copy selection to clipboard. |
cut | Cut selection to clipboard. |
paste | Paste from clipboard. |
toggleComment | Toggle line comment (Ctrl+/). |
duplicateLine | Duplicate the current line. |
deleteLine | Delete the current line. |
indentLine | Indent current line / selection by one level. |
outdentLine | Outdent current line / selection by one level. |
toggleWordWrap | Toggle soft word-wrap (Alt+Z). |
find | Open find bar (Ctrl+F). |
findReplace | Open find-and-replace (Ctrl+H). |
Theme API
Config Updates
Destroy
Call destroy() when unmounting — it removes all DOM nodes, cancels animation frames, and frees web worker resources:
© 2026 Syncline Editor. All rights reserved.