Mecha CMS

Mecha CMS blog and documentation.

Main Text Editor API

Accessing the main text editor’s text selection range API.

Requires text editor extension.

This would maps to the main text editor’s text selection range API in the page manager that is created by the text editor extension:

// `$form_id = 'form.c.' . $id`
// `PANEL.__form__.TE.{$form_id}.{$textarea_name}`
PANEL.__form__.TE['form.c.page'].content;

Using that reference, you can execute the available API as described in this documentation page. Example:

// Show a prompt modal
var editor = PANEL.__form__.TE['form.c.page'].content;
editor.ui.prompt('What is your name?', "", false, function(e, $, v) {
    $.insert('Your name is: ' + v);
});