]> BookStack Code Mirror - bookstack/blob - resources/js/wysiwyg/common-events.js
MFA: Tweaked backup code wording
[bookstack] / resources / js / wysiwyg / common-events.js
1 /**
2  * @param {Editor} editor
3  */
4 export function listen(editor) {
5     // Replace editor content
6     window.$events.listen('editor::replace', ({html}) => {
7         editor.setContent(html);
8     });
9
10     // Append editor content
11     window.$events.listen('editor::append', ({html}) => {
12         const content = editor.getContent() + html;
13         editor.setContent(content);
14     });
15
16     // Prepend editor content
17     window.$events.listen('editor::prepend', ({html}) => {
18         const content = html + editor.getContent();
19         editor.setContent(content);
20     });
21
22     // Insert editor content at the current location
23     window.$events.listen('editor::insert', ({html}) => {
24         editor.insertContent(html);
25     });
26
27     // Focus on the editor
28     window.$events.listen('editor::focus', () => {
29         if (editor.initialized) {
30             editor.focus();
31         }
32     });
33 }