Skip to content

Commit 4b905b3

Browse files
committed
reduce complexity of the 'onPasteImage' function
1 parent 2ecf86e commit 4b905b3

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

src/lib/Room/Room.vue

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -944,23 +944,16 @@ export default {
944944
this.$refs.file.value = ''
945945
this.$refs.file.click()
946946
},
947-
onPasteImage(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])
947+
onPasteImage(pasteEvent) {
948+
const items = pasteEvent.clipboardData?.items
949+
950+
if (items) {
951+
items.forEach(item => {
952+
if (item.type.indexOf('image') !== -1) {
953+
const blob = item.getAsFile()
954+
this.onFileChange([blob])
955+
}
956+
})
964957
}
965958
},
966959
async onFileChange(files) {

0 commit comments

Comments
 (0)