Files
roundcubemail/plugins/markdown_editor/javascript/toolbar-plugin.js
Pablo Zmdl e34a813355 New plugin "markdown_editor": compose in markdown, send as HTML
This adds a markdown editor that sends HTML to the server.

It uses codemirror and some custom code to show a syntax highlighted
textarea and some buttons to help editing
(including a preview).

Drafts get marked via an internal email header that causes the markdown
editor to automatically start if a message composition is
continued that was started using the markdown editor.
2025-10-27 15:34:19 +01:00

25 lines
764 B
JavaScript

export default class ToolbarPlugin {
destroy() {
this.element.remove();
}
constructor(view, buttons) {
this.view = view;
buttons.forEach((button) => {
if (typeof button.command === 'function') {
button.addEventListener('click', (ev) => {
ev.preventDefault();
if (!button.disabled) {
button.command(this.view);
}
});
button.classList.add('clickable');
}
});
this.element = document.createElement('div');
this.element.classList.add('codemirror-toolbar');
this.element.append(...buttons);
this.view.dom.prepend(this.element);
}
}