Skip to content

Commit a4cd55a

Browse files
committed
Paste image into textarea
1 parent 1bcb9f1 commit a4cd55a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/lib/Room/Room.vue

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@
250250
@input="onChangeInput"
251251
@keydown.esc="escapeTextarea"
252252
@keydown.enter.exact.prevent=""
253+
@paste="pasteImage"
253254
/>
254255

255256
<div class="vac-icon-textarea">
@@ -943,6 +944,25 @@ export default {
943944
this.$refs.file.value = ''
944945
this.$refs.file.click()
945946
},
947+
pasteImage(pasteEvent, callback) {
948+
if (pasteEvent.clipboardData === false) {
949+
if (typeof (callback) === 'function') {
950+
callback(undefined)
951+
}
952+
}
953+
this.clipboardData = pasteEvent.clipboardData.items
954+
var items = pasteEvent.clipboardData.items
955+
if (items === undefined) {
956+
if (typeof (callback) === 'function') {
957+
callback(undefined)
958+
}
959+
}
960+
for (var i = 0; i < items.length; i++) {
961+
if (items[i].type.indexOf('image') === -1) continue
962+
var blob = items[i].getAsFile()
963+
this.onFileChange([blob])
964+
}
965+
},
946966
async onFileChange(files) {
947967
this.fileDialog = true
948968
this.resetMediaFile()

0 commit comments

Comments
 (0)