mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
921131f999
- Split everything into specific plugin/concern files to make things more managable. Means original component file is now simple and much of the core config is focused in one place.
32 lines
836 B
JavaScript
32 lines
836 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', () => {
|
|
editor.focus();
|
|
});
|
|
} |