]> BookStack Code Mirror - bookstack/blobdiff - resources/js/wysiwyg/drop-paste-handling.js
Tweaked code editor sidebar side to be smaller
[bookstack] / resources / js / wysiwyg / drop-paste-handling.js
index 1da13c88835dcd0a4d1f24e644289ddb9c019792..0529f6b6cdd110f00335b3a5c2785df608e7fe71 100644 (file)
@@ -43,7 +43,6 @@ function paste(editor, options, event) {
                 editor.dom.replace(newEl, id);
             }).catch(err => {
                 editor.dom.remove(id);
-                // TODO - Check we have this translation
                 window.$events.emit('error', options.translations.imageUploadErrorText);
                 console.log(err);
             });
@@ -61,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);