Skip to content

Commit

Permalink
cleanup drag/drop images
Browse files Browse the repository at this point in the history
  • Loading branch information
thooyork committed Jun 14, 2024
1 parent 8343810 commit 0f7b859
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 8 deletions.
46 changes: 42 additions & 4 deletions client/src/components/ImagePreview.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<div class="preview-container">
<div class="erase" @click="$emit('delete')" :title="t('app.base.delete_image')"></div>
<div class="img-container">
<img :src="dataUrl" v-on:dragstart="onDragStart($event)" :draggable="showPaste" />
</div>
Expand All @@ -12,21 +13,58 @@
type="button"
v-if="showPaste"
@click="$emit('paste', getMarkdownString())"
:title="t('app.base.insert')"
:title="t('app.base.insert_image')"
>
<fa-icon :icon="faFileImport"></fa-icon>
</button>
<button class="btn btn-softdelete mx-1" type="button" v-if="showDelete" @click="$emit('softdelete')" :title="t('app.base.remove')">
<fa-icon :icon="faEraser"></fa-icon>
</button>
<button class="btn btn-delete mx-1" type="button" v-if="showDelete" @click="$emit('delete')" :title="t('app.base.delete_image')">
<!-- <button class="btn btn-delete mx-1" type="button" v-if="showDelete" @click="$emit('delete')"
:title="t('app.base.delete_image')">
<fa-icon :icon="faTrash"></fa-icon>
</button>
</button> -->
</div>
</div>
</div>
</template>
<style scoped lang="scss">
.erase {
width: 16px;
height: 16px;
right: -7px;
top: -7px;
display: block;
position: absolute;
z-index: 999;
background-color: #333;
border: 1px solid #555;
border-radius: 50%;
cursor: pointer;
transition-duration: 0.4s;
&:hover {
transition-duration: 0.4s;
background-color: #a00;
}
&:before {
position: absolute;
top: 0;
left: calc(50% - 3px);
z-index: 1000;
content: "\d7";
line-height: 12px;
font-size: 12px;
padding: 0;
margin: 0;
transform: scale(1.25);
color: #fff;
text-align: center;
}
}
.preview-container {
width: 150px;
margin: 0;
Expand Down Expand Up @@ -69,7 +107,7 @@
}
&:not(:last-child) {
margin-right: 10px;
margin-right: 15px;
}
.img-container {
Expand Down
5 changes: 3 additions & 2 deletions client/src/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"save": "Speichern",
"cancel": "Abbrechen",
"edit": "Bearbeiten",
"insert": "Einfügen",
"insert_image": "Bild einfügen",
"delete": "Löschen",
"delete_image": "Bild löschen",
"remove": "Bildrefernz aus Text entfernen",
Expand Down Expand Up @@ -62,7 +62,8 @@
"tags": "Schlagworte",
"enter": "Geben Sie Schlagworte ein..."
},
"imageupload": "keine angehängten Bilder | ein angehängtes Bild | {count} angehängte Bilder"
"imageupload": "keine angehängten Bilder | ein angehängtes Bild | {count} angehängte Bilder",
"imageupload_hint": "(Bild per Drag & Drop in den Text ziehen)"
},
"confirm": {
"title": "Löschen bestätigen",
Expand Down
3 changes: 2 additions & 1 deletion client/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"save": "Save",
"cancel": "Cancel",
"edit": "Edit",
"insert": "Insert",
"insert_image": "Insert image",
"delete_image": "Delete image",
"remove": "Remove image reference from text",
"read": "Read",
Expand Down Expand Up @@ -58,6 +58,7 @@
"title": "Preview"
},
"imageupload": "Upload image",
"imageupload_hint": "(drag onto textarea to insert)",
"tags": "Tags"
},
"confirm": {
Expand Down
9 changes: 8 additions & 1 deletion client/src/views/PostFormView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
<small class="text-body-secondary f-4" v-if="Object.keys(files).length > 0">
({{ convertToHumanReadableFileSize(totalBytesInFiles) }})
</small>

<span class="tiny">{{ t("posts.form.imageupload_hint") }}</span>
</h4>
<!-- Hidden file input, used to open the file dialog, when the dropzone is clicked -->
<input
Expand Down Expand Up @@ -141,6 +143,10 @@
</template>

<style lang="scss">
.tiny {
font-size: 0.75rem;
color: #6c757d;
}
.post-bg {
background-image: url("@client/assets/images/post-bg.jpg");
background-repeat: no-repeat;
Expand Down Expand Up @@ -171,7 +177,8 @@
padding: 0;
overflow-x: auto;
height: auto;
min-height: 270px;
min-height: 280px;
padding-top: 10px;
}
.inner {
Expand Down

0 comments on commit 0f7b859

Please sign in to comment.