JavaScript API

Feature origin: Tint

The public interface of a <tint-editor> element.

Editor properties

PropertyDescription
value, defaultValueCurrent Markdown and reset value, respectively.
toolbarReads the current commands and separators. Assign a string, array, or null.
selectionStart, selectionEnd, selectionDirectionRead selection offsets and direction from the textarea.
name, readOnly, required, disabled, placeholder, rowsReflected field settings.
form, labels, validity, validationMessage, willValidateNative form association and validation state.

Editor methods

MethodDescription
getMarkdown(), setMarkdown(text)Read or set the current Markdown.
exec(name, url?)Run a command. A link or image opens a dialog when called without a URL.
insertText(text), insertImage(url, alt?)Replace the current selection with text or an image reference.
focus(), getSelectedText(), setSelectionRange(start, end, direction?)Focus the textarea and work with its selection.
isActive(name, options?)Check formatting around the selection. For a heading level, use isActive("heading", { level: 2 }).
checkValidity(), reportValidity()Check constraints or report them through the browser.

Events

Listen for input and change as described in Events.

Package export

The module registers the tag when imported and exports TintEditor.