]> BookStack Code Mirror - bookstack/blobdiff - resources/assets/js/components/wysiwyg-editor.js
Fixed issue causing text overlap in sort select box
[bookstack] / resources / assets / js / components / wysiwyg-editor.js
index a356c6a9e2a0a4fcfa75028caa78a21ddf94c560..c03c0d2aa4e8bba75b8206e7060d50bb4dc26f06 100644 (file)
@@ -557,7 +557,6 @@ class WysiwygEditor {
                 });
 
                 function editorChange() {
-                    console.log('CHANGE');
                     let content = editor.getContent();
                     window.$events.emit('editor-html-change', content);
                 }
@@ -609,6 +608,18 @@ class WysiwygEditor {
                     let dom = editor.dom,
                         rng = tinymce.dom.RangeUtils.getCaretRangeFromPoint(event.clientX, event.clientY, editor.getDoc());
 
+                    // Template insertion
+                    const templateId = event.dataTransfer.getData('bookstack/template');
+                    if (templateId) {
+                        event.preventDefault();
+                        window.$http.get(`/templates/${templateId}`).then(resp => {
+                            editor.selection.setRng(rng);
+                            editor.undoManager.transact(function () {
+                                editor.execCommand('mceInsertContent', false, resp.data.html);
+                            });
+                        });
+                    }
+
                     // Don't allow anything to be dropped in a captioned image.
                     if (dom.getParent(rng.startContainer, '.mceTemp')) {
                         event.preventDefault();