feat:image preview component add download feature

This commit is contained in:
Hufe921
2022-06-23 20:49:04 +08:00
parent 01081ebda1
commit 08676abf05
4 changed files with 19 additions and 0 deletions
@@ -1,6 +1,7 @@
import { IImageParticleCreateResult } from '../../../interface/Draw'
import { IEditorOption } from '../../../interface/Editor'
import { IElement, IElementPosition } from '../../../interface/Element'
import { downloadFile } from '../../../utils'
import { Draw } from '../Draw'
export class ImageParticle {
@@ -228,6 +229,12 @@ export class ImageParticle {
this._setPreviewerTransform(scaleSize, rotateSize, x, y)
}
menuContainer.append(originalSize)
const imageDownload = document.createElement('i')
imageDownload.classList.add('image-download')
imageDownload.onclick = () => {
downloadFile(img.src, `${this.curElement?.id}.png`)
}
menuContainer.append(imageDownload)
previewerContainer.append(menuContainer)
this.previewerContainer = previewerContainer
document.body.append(previewerContainer)