This commit is contained in:
2020-04-23 23:27:02 +00:00
parent 11076698e5
commit d9611763f1
2 changed files with 59 additions and 13 deletions

View File

@@ -299,6 +299,9 @@
>
<div :style="editStyle()">
<v-textarea
v-cloak
@drop.prevent="onDrop"
@dragover.prevent
solo
no-resize
:height="editAreaHeight"
@@ -382,7 +385,8 @@ export default {
imageTab: null,
imageUrl: "",
imageText: "",
selectedImageAttachment: null
selectedImageAttachment: null,
dropTest: null
};
},
props: {
@@ -806,7 +810,54 @@ export default {
{ id: 1, name: "Stub attachment two" },
{ id: 2, name: "Stub attachment three" }
];
},
onDrop(ev) {
//Drop image file
var files = Array.from(ev.dataTransfer.files);
if (files.length > 0) {
//handle file drop
console.log("DROP:Possible files", files);
//if an image then put it directly in viewable, if not an image then make a link and keep as an attach
} else {
//maybe an url?
let url = ev.dataTransfer.getData("text");
if (url) {
//Attachment?
if (url.includes("Attachment/download/")) {
//it's an attachment url so fixup accordingly
//DROP:Possible url http://localhost:7575/api/v8.0/Attachment/download/4?t=CYs1xUgjdyaWmcq8rXlPpNNSaKpiMt8Xhi7mKRGeg8o wiki-control.vue:826
//cow(.*)milk
let m = url.match(/Attachment\/download\/(.*)\?t=/);
if (m.length > 1) {
url = "[ATTACH:" + m[1] + "]";
} else {
url = null;
}
if (url != null) {
//insert into textarea
let txt = this.getSelectedText();
if (txt) {
this.replaceSelectedText(
"![" + txt + "](" + url + ' "' + txt + '") \n' + txt //keep original selected text otherwise it will vanish
);
} else {
this.replaceSelectedText("![](" + url + ")");
}
}
console.log("processed url:", url);
} else {
//External url
//todo: this
console.log("STUB: Handle external url drop");
}
//handle accordingly
}
}
}
//----------end methods----------
}
};
</script>