API Documentation - slugcat-dev/mark-ed GitHub Wiki

Editor

Property Description
config -
content The content of the editor.
focused Get if the editor is currently focused.
lines The lines that the editor content consists of.
If you modify this value, you need to call editor.updateDOM() manually.
markdown The MarkdownParser instance the editor uses.
readonly -
root -
Method Description
convertIndentation(text: string) Convert the indentation of the lines in a text to spaces or tabs, depending on how the editor is configured.
destroy() Unregister all event listeners and clean up the editor.
getNodeOffset(target: Node) Get the character offset of a node in the editor.
getSelection() Get the current text selection within the editor.
Returns an object with the start and end positions of the selection, as character offset from the start of the content.
insertAtSelection(text: string) Insert the given text at the cursor position, or replace the currently selected text.
line(num: number) Get a line by number.
Returns an object holding the positions and text of the line.
lineAt(pos: number) Get the line around a specific position in the content.
Returns an object holding the positions and text of the line.
setSelection(selection: Partial<EditorSelection>, collapse?: boolean)
setSelection(selection: number)
Set the text selection within the editor.

Param selection - An object specifying the new start or end position.
Param collapse - If true, collapses the selection to the specified start or end position, otherwise extends the selection.
⚠️ **GitHub.com Fallback** ⚠️