X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/20c36d58a64f7400bd07eba760bcdb8a54fccf65..444a23a419539b9236a3cf04cf5c76c2d216c49e:/resources/assets/js/components/wysiwyg-editor.js diff --git a/resources/assets/js/components/wysiwyg-editor.js b/resources/assets/js/components/wysiwyg-editor.js index a356c6a9e..c03c0d2aa 100644 --- a/resources/assets/js/components/wysiwyg-editor.js +++ b/resources/assets/js/components/wysiwyg-editor.js @@ -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();