]> BookStack Code Mirror - bookstack/blobdiff - resources/js/components/markdown-editor.js
Fix build:js:watch not building at first launch in Docker
[bookstack] / resources / js / components / markdown-editor.js
index 6e646c72bbf32af50378697782c73c96f6ee5164..c371a983991dfa333429b824122d0758628a4599 100644 (file)
@@ -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();