Skip to content

Commit

Permalink
drag n drop support #199
Browse files Browse the repository at this point in the history
  • Loading branch information
DJ2LS committed Sep 17, 2024
1 parent e0b34bd commit 9766abd
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions freedata_gui/src/components/chat_new_message.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,21 @@ function triggerFileInput() {
// Handle file selection and preview
function handleFileSelection(event) {
handleFiles(event.target.files);
}
// Handle drag and drop files
function handleDrop(event) {
event.preventDefault();
event.stopPropagation();
handleFiles(event.dataTransfer.files);
}
// Handle files from file input or drag-and-drop
function handleFiles(files) {
selectedFiles.value = [];
for (let file of event.target.files) {
for (let file of files) {
const reader = new FileReader();
reader.onload = () => {
const base64Content = btoa(reader.result);
Expand Down Expand Up @@ -113,13 +125,16 @@ function applyMarkdown(formatType) {
</script>

<template>
<nav class="navbar sticky-bottom bg-body-tertiary border-top">
<nav class="navbar sticky-bottom bg-body-tertiary border-top" @dragover.prevent @drop="handleDrop">
<div class="container-fluid p-0">
<!-- Hidden file input -->
<input type="file" multiple ref="fileInput" @change="handleFileSelection" style="display: none;" />

<!-- File Attachment Preview Area -->
<div class="container-fluid">
<!-- File Attachment Preview Area with Drag-and-Drop -->
<div
class="container-fluid"

>
<div class="d-flex flex-row overflow-auto bg-light">
<div v-for="(file, index) in selectedFiles" :key="index" class="p-2">
<div class="card" style="min-width: 10rem; max-width: 10rem;">
Expand Down Expand Up @@ -168,8 +183,6 @@ function applyMarkdown(formatType) {
<button class="btn btn-outline-secondary border-0 rounded-pill" @click="applyMarkdown('italic')"><i>I</i></button>
<button class="btn btn-outline-secondary border-0 rounded-pill" @click="applyMarkdown('underline')"><u>U</u></button>



<textarea
class="form-control border rounded-pill"
rows="1"
Expand Down

0 comments on commit 9766abd

Please sign in to comment.