X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/c6ad16dba657c82512ae495a4a38b99b8cfa9eeb..refs/heads/ldap_host_failover:/resources/js/wysiwyg/drop-paste-handling.js diff --git a/resources/js/wysiwyg/drop-paste-handling.js b/resources/js/wysiwyg/drop-paste-handling.js index ace74dd33..866d25a24 100644 --- a/resources/js/wysiwyg/drop-paste-handling.js +++ b/resources/js/wysiwyg/drop-paste-handling.js @@ -60,13 +60,7 @@ async function uploadImageFile(file, pageId) { throw new Error(`Not an image file`); } - let ext = 'png'; - if (file.name) { - let fileNameMatches = file.name.match(/\.(.+)$/); - if (fileNameMatches.length > 1) ext = fileNameMatches[1]; - } - - const remoteFilename = "image-" + Date.now() + "." + ext; + const remoteFilename = file.name || `image-${Date.now()}.png`; const formData = new FormData(); formData.append('file', file, remoteFilename); formData.append('uploaded_to', pageId); @@ -138,9 +132,9 @@ function drop(editor, options, event) { const range = editor.selection.getRng(); const selectedNodeRoot = selectedNode.closest('body > *'); if (range.startOffset > (range.startContainer.length / 2)) { - editor.$(selectedNodeRoot).after(draggedContentEditable); + selectedNodeRoot.after(draggedContentEditable); } else { - editor.$(selectedNodeRoot).before(draggedContentEditable); + selectedNodeRoot.before(draggedContentEditable); } }); }