image cropper cleanup

This commit is contained in:
Henry Jameson 2025-08-05 17:00:21 +03:00
commit ee01395071

View file

@ -10,19 +10,12 @@ library.add(
const ImageCropper = { const ImageCropper = {
props: { props: {
// Mime-types to accept, i.e. which filetypes to accept (.gif, .png, etc.)
mimes: { mimes: {
type: String, type: String,
default: 'image/png, image/gif, image/jpeg, image/bmp, image/x-icon' default: 'image/png, image/gif, image/jpeg, image/bmp, image/x-icon'
}, },
saveButtonLabel: { // Fixed aspect-ratio for selection box
type: String
},
saveWithoutCroppingButtonlabel: {
type: String
},
cancelButtonLabel: {
type: String
},
aspectRatio: { aspectRatio: {
type: Number type: Number
} }
@ -30,11 +23,13 @@ const ImageCropper = {
data () { data () {
return { return {
dataUrl: undefined, dataUrl: undefined,
filename: undefined, filename: undefined
submitting: false
} }
}, },
emits: ['submit'], emits: [
'submit', // cropping complete or uncropped image returned
'close', // cropper is closed
],
methods: { methods: {
destroy () { destroy () {
this.$refs.input.value = '' this.$refs.input.value = ''
@ -42,8 +37,6 @@ const ImageCropper = {
this.$emit('close') this.$emit('close')
}, },
submit (cropping = true) { submit (cropping = true) {
this.submitting = true
let cropperPromise let cropperPromise
if (cropping) { if (cropping) {
cropperPromise = this.$refs.cropperSelection.$toCanvas() cropperPromise = this.$refs.cropperSelection.$toCanvas()
@ -53,7 +46,6 @@ const ImageCropper = {
cropperPromise.then(canvas => { cropperPromise.then(canvas => {
this.$emit('submit', { canvas, file: this.file }) this.$emit('submit', { canvas, file: this.file })
this.submitting = false
}) })
}, },
pickImage () { pickImage () {