BookStackApp_BookStack/resources/js/wysiwyg-tinymce/common-events.js
Dan Brown 5a4f595341
Editors: Added lexical editor for testing
Started basic playground for testing lexical as a new WYSIWYG editor.
Moved out tinymce to be under wysiwyg-tinymce instead so lexical is the
default, but TinyMce code remains.
2024-05-27 15:39:41 +01:00

34 lines
884 B
JavaScript

/**
* @param {Editor} editor
*/
export function listen(editor) {
// Replace editor content
window.$events.listen('editor::replace', ({html}) => {
editor.setContent(html);
});
// Append editor content
window.$events.listen('editor::append', ({html}) => {
const content = editor.getContent() + html;
editor.setContent(content);
});
// Prepend editor content
window.$events.listen('editor::prepend', ({html}) => {
const content = html + editor.getContent();
editor.setContent(content);
});
// Insert editor content at the current location
window.$events.listen('editor::insert', ({html}) => {
editor.insertContent(html);
});
// Focus on the editor
window.$events.listen('editor::focus', () => {
if (editor.initialized) {
editor.focus();
}
});
}