mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-22 22:59:58 +08:00
@ -33,6 +33,15 @@ class Attachments {
|
||||
this.container.addEventListener('event-emit-select-edit-back', event => {
|
||||
this.stopEdit();
|
||||
});
|
||||
|
||||
this.container.addEventListener('event-emit-select-insert', event => {
|
||||
const insertContent = event.target.closest('[data-drag-content]').getAttribute('data-drag-content');
|
||||
const contentTypes = JSON.parse(insertContent);
|
||||
window.$events.emit('editor::insert', {
|
||||
html: contentTypes['text/html'],
|
||||
markdown: contentTypes['text/plain'],
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
reloadList() {
|
||||
|
@ -563,6 +563,12 @@ class MarkdownEditor {
|
||||
this.cm.setCursor(cursorPos.line + prependLineCount, cursorPos.ch);
|
||||
});
|
||||
|
||||
// Insert editor content at the current location
|
||||
window.$events.listen('editor::insert', (eventContent) => {
|
||||
const markdown = getContentToInsert(eventContent);
|
||||
this.cm.replaceSelection(markdown);
|
||||
});
|
||||
|
||||
// Focus on editor
|
||||
window.$events.listen('editor::focus', () => {
|
||||
this.cm.focus();
|
||||
|
@ -401,6 +401,11 @@ function listenForBookStackEditorEvents(editor) {
|
||||
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();
|
||||
|
Reference in New Issue
Block a user