kopia lustrzana https://github.com/nextcloud/social
PoC: Upload images in Composer
Signed-off-by: Cyrille Bollu <cyrpub@bollu.be>pull/657/head
rodzic
36fb838476
commit
26e8755438
|
@ -81,11 +81,12 @@
|
||||||
|
|
||||||
<masonry>
|
<masonry>
|
||||||
<div v-for="(item, index) in postAttachments" :key="index">
|
<div v-for="(item, index) in postAttachments" :key="index">
|
||||||
<img src="">
|
<img :src="item">
|
||||||
</div>
|
</div>
|
||||||
</masonry>
|
</masonry>
|
||||||
|
|
||||||
<div class="options">
|
<div class="options">
|
||||||
|
<input ref="addAttach" class="emoji-invoker" type="file" @change="uploadImages" />
|
||||||
<input :value="currentVisibilityPostLabel" :disabled="post.length < 1" class="submit primary"
|
<input :value="currentVisibilityPostLabel" :disabled="post.length < 1" class="submit primary"
|
||||||
type="submit" title="" data-original-title="Post">
|
type="submit" title="" data-original-title="Post">
|
||||||
<div v-click-outside="hidePopoverMenu">
|
<div v-click-outside="hidePopoverMenu">
|
||||||
|
@ -239,6 +240,12 @@
|
||||||
.popovermenu {
|
.popovermenu {
|
||||||
top: 55px;
|
top: 55px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.attachment-picker-wrapper {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
top: 2;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<style>
|
<style>
|
||||||
/* Tribute-specific styles TODO: properly scope component css */
|
/* Tribute-specific styles TODO: properly scope component css */
|
||||||
|
@ -559,6 +566,37 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
uploadImages() {
|
||||||
|
var self = this
|
||||||
|
let file = this.$refs.addAttach.files[0];
|
||||||
|
let reader = new FileReader()
|
||||||
|
reader.onload = function(e) {
|
||||||
|
var canvas = document.createElement('canvas')
|
||||||
|
var ctx = canvas.getContext('2d');
|
||||||
|
var width = 300
|
||||||
|
var height = 200
|
||||||
|
var img = new Image()
|
||||||
|
img.onload = function() {
|
||||||
|
var imgWidth = img.width
|
||||||
|
var imgHeight = img.height
|
||||||
|
if (imgWidth > window.innerWidth) {
|
||||||
|
imgHeight = imgHeight * (width / imgWidth)
|
||||||
|
imgWidth = width
|
||||||
|
}
|
||||||
|
if (imgHeight > height) {
|
||||||
|
imgWidth = imgWidth * (height / imgHeight)
|
||||||
|
imgHeight = height
|
||||||
|
}
|
||||||
|
canvas.width = imgWidth
|
||||||
|
canvas.height = imgHeight
|
||||||
|
ctx.drawImage(img, 0, 0, imgWidth, imgHeight)
|
||||||
|
var resizedImg = canvas.toDataURL()
|
||||||
|
self.postAttachments.push(resizedImg)
|
||||||
|
}
|
||||||
|
img.src = e.target.result
|
||||||
|
}
|
||||||
|
reader.readAsDataURL(file)
|
||||||
|
},
|
||||||
insert(emoji) {
|
insert(emoji) {
|
||||||
if (typeof emoji === 'object') {
|
if (typeof emoji === 'object') {
|
||||||
let category = Object.keys(emoji)[0]
|
let category = Object.keys(emoji)[0]
|
||||||
|
|
Ładowanie…
Reference in New Issue