Plugins and commands
Bundle buttons, commands, shortcuts and paste rules.
A plugin is a { name, init(editor) } object. Add buttons, commands and listeners in init; return a function if something needs cleaning up when the editor is destroyed.
const stamp = {
name: 'stamp',
init(editor) {
editor.addCommand('stamp', (ed) => ed.insertHTML('<p><mark>Approved</mark></p>'));
editor.addButton('stamp', { icon: 'OK', title: 'Approval stamp', onAction: (ed) => ed.exec('stamp') });
},
};
createEditor('#editor', {
plugins: [stamp],
toolbar: 'board | stamp',
shortcuts: [{ keys: 'Mod+Shift+S', run: (ed) => ed.exec('stamp') }],
});