Documentation

Overview

To access the Article's API from external scripts, you need to get an instance of the running editor.

This can be done by defining a variable at startup or after starting the editor by accessing the element by ID:

var app = ArticleEditor('#entry');
app.editor.content.insert('<p>Hello world!</p>');

Plugins API

Inside the plugins, you can access to the editor modules API by using this.app.

(function() {
    ArticleEditor.add('plugin', 'myplugin', {
        start: function() {
            this.app.toolbar.add('mybutton', {
                title: 'My Button',
                icon: '<i class="far fa-file-alt"></i>',
                command: 'myplugin.insert'
            });
        },
        insert: function() {
            this.app.editor.content.insert('<p>Hello world!</p>');
        }
    });
})(ArticleEditor);

Define services

To access the services API (they are indicated in the API description in a separate way), you must first define a service.

(function() {
    ArticleEditor.add('plugin', 'myplugin', {
        init: function() {
            // define service
            this.insertion = this.app.create('insertion');
        },
        mymethod: function() {
            // insert html char at caret
            var inserted = this.insertion.insertChar('&nbsp;');
        }
    });
})(ArticleEditor);