X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/2f6ff0734773c4ac009de699a2661971fd585b22..refs/pull/2298/head:/resources/js/components/markdown-editor.js diff --git a/resources/js/components/markdown-editor.js b/resources/js/components/markdown-editor.js index 6e646c72b..c371a9839 100644 --- a/resources/js/components/markdown-editor.js +++ b/resources/js/components/markdown-editor.js @@ -256,7 +256,7 @@ class MarkdownEditor { } const clipboard = new Clipboard(event.dataTransfer); - if (clipboard.hasItems()) { + if (clipboard.hasItems() && clipboard.getImages().length > 0) { const cursorPos = cm.coordsChar({left: event.pageX, top: event.pageY}); cm.setCursor(cursorPos); event.stopPropagation(); @@ -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();