Update web image editor (#588)

* Update web image editor

* Delete type-assertions.ts

* Re-add getKeys

* Uncomment rotation code

* Revert "Uncomment rotation code"

This reverts commit 6269f3b928c2e5cacaf5d0ff5323fe975ee48eab.

* Shuffle dependencies and update mobile resolution

* Update ImageEditor modal layout for mobile

* Avoid accidental closes of the EditImage modal

---------

Co-authored-by: Paul Frazee <pfrazee@gmail.com>
This commit is contained in:
Ollie H 2023-05-09 12:55:44 -07:00 committed by GitHub
parent 8f6b5d3df9
commit b0ebb6c9d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 642 additions and 16 deletions

View file

@ -5,6 +5,7 @@ import {Image as RNImage} from 'react-native-image-crop-picker'
import {openPicker} from 'lib/media/picker'
import {getImageDim} from 'lib/media/manip'
import {getDataUriSize} from 'lib/media/util'
import {isNative} from 'platform/detection'
export class GalleryModel {
images: ImageModel[] = []
@ -37,7 +38,12 @@ export class GalleryModel {
// Temporarily enforce uniqueness but can eventually also use index
if (!this.images.some(i => i.path === image_.path)) {
const image = new ImageModel(this.rootStore, image_)
await image.compress()
if (!isNative) {
await image.manipulate({})
} else {
await image.compress()
}
runInAction(() => {
this.images.push(image)
@ -45,6 +51,20 @@ export class GalleryModel {
}
}
async edit(image: ImageModel) {
if (!isNative) {
this.rootStore.shell.openModal({
name: 'edit-image',
image,
gallery: this,
})
return
} else {
this.crop(image)
}
}
async paste(uri: string) {
if (this.size >= 4) {
return
@ -65,8 +85,8 @@ export class GalleryModel {
})
}
setAltText(image: ImageModel) {
image.setAltText()
setAltText(image: ImageModel, altText: string) {
image.setAltText(altText)
}
crop(image: ImageModel) {
@ -78,6 +98,10 @@ export class GalleryModel {
this.images.splice(index, 1)
}
async previous(image: ImageModel) {
image.previous()
}
async pick() {
const images = await openPicker(this.rootStore, {
multiple: true,