mirror of
https://github.com/thomiceli/opengist.git
synced 2025-06-13 05:47:12 +02:00
Add drag and drop filename support
This commit is contained in:
9
public/editor.js
vendored
9
public/editor.js
vendored
@ -19,9 +19,12 @@ const newEditor = (dom, value = '') => {
|
||||
})
|
||||
}
|
||||
|
||||
const eventOnDrop = (e) => {
|
||||
e.preventDefault(); // prevent the browser from opening the dropped file
|
||||
e.target.closest('.editor').querySelector('input.form-filename').value = e.dataTransfer.files[0].name
|
||||
}
|
||||
|
||||
document.onsubmit = () => {
|
||||
console.log('onsubmit');
|
||||
window.onbeforeunload = null;
|
||||
}
|
||||
|
||||
@ -40,6 +43,8 @@ arr.forEach(el => {
|
||||
}
|
||||
});
|
||||
|
||||
currEditor.dom.addEventListener("drop", eventOnDrop);
|
||||
|
||||
// remove editor on delete
|
||||
let deleteBtns = el.querySelector('button.delete-file')
|
||||
if (deleteBtns !== null) {
|
||||
@ -65,6 +70,8 @@ document.getElementById('add-file').onclick = () => {
|
||||
// creating the new codemirror editor and append it in the editor div
|
||||
editorsjs.push(newEditor(newEditorDom))
|
||||
editorsParentdom.append(newEditorDom)
|
||||
editorsParentdom.addEventListener("drop", eventOnDrop);
|
||||
|
||||
}
|
||||
|
||||
document.querySelector('form#create').onsubmit = () => {
|
||||
|
Reference in New Issue
Block a user