]> BookStack Code Mirror - bookstack/blob - resources/js/markdown/common-events.js
Changed the way settings are loaded
[bookstack] / resources / js / markdown / common-events.js
1 function getContentToInsert({html, markdown}) {
2     return markdown || html;
3 }
4
5 /**
6  * @param {MarkdownEditor} editor
7  */
8 export function listen(editor) {
9
10     window.$events.listen('editor::replace', (eventContent) => {
11         const markdown = getContentToInsert(eventContent);
12         editor.actions.replaceContent(markdown);
13     });
14
15     window.$events.listen('editor::append', (eventContent) => {
16         const markdown = getContentToInsert(eventContent);
17         editor.actions.appendContent(markdown);
18     });
19
20     window.$events.listen('editor::prepend', (eventContent) => {
21         const markdown = getContentToInsert(eventContent);
22         editor.actions.prependContent(markdown);
23     });
24
25     window.$events.listen('editor::insert', (eventContent) => {
26         const markdown = getContentToInsert(eventContent);
27         editor.actions.insertContent(markdown);
28     });
29
30     window.$events.listen('editor::focus', () => {
31         editor.actions.focus();
32     });
33 }