]> BookStack Code Mirror - bookstack/blob - resources/js/markdown/common-events.js
Merge pull request #5626 from BookStackApp/rubentalstra-development
[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     window.$events.listen('editor::replace', eventContent => {
10         const markdown = getContentToInsert(eventContent);
11         editor.actions.replaceContent(markdown);
12     });
13
14     window.$events.listen('editor::append', eventContent => {
15         const markdown = getContentToInsert(eventContent);
16         editor.actions.appendContent(markdown);
17     });
18
19     window.$events.listen('editor::prepend', eventContent => {
20         const markdown = getContentToInsert(eventContent);
21         editor.actions.prependContent(markdown);
22     });
23
24     window.$events.listen('editor::insert', eventContent => {
25         const markdown = getContentToInsert(eventContent);
26         editor.actions.insertContent(markdown);
27     });
28
29     window.$events.listen('editor::focus', () => {
30         editor.actions.focus();
31     });
32 }
Morty Proxy This is a proxified and sanitized view of the page, visit original site.