diff --git a/src/editor/core/command/CommandAdapt.ts b/src/editor/core/command/CommandAdapt.ts index e9137469..76a8eb89 100644 --- a/src/editor/core/command/CommandAdapt.ts +++ b/src/editor/core/command/CommandAdapt.ts @@ -1406,8 +1406,6 @@ export class CommandAdapt { const elementList = this.draw.getElementList() const element = elementList[startIndex] if (!element || element.type !== ElementType.IMAGE) return - // 替换图片 - element.id = getUUID() element.value = payload this.draw.render({ isSetCursor: false diff --git a/src/editor/core/draw/particle/ImageParticle.ts b/src/editor/core/draw/particle/ImageParticle.ts index 436a363c..8a380961 100644 --- a/src/editor/core/draw/particle/ImageParticle.ts +++ b/src/editor/core/draw/particle/ImageParticle.ts @@ -102,8 +102,8 @@ export class ImageParticle { const { scale } = this.options const width = element.width! * scale const height = element.height! * scale - if (this.imageCache.has(element.id!)) { - const img = this.imageCache.get(element.id!)! + if (this.imageCache.has(element.value)) { + const img = this.imageCache.get(element.value)! ctx.drawImage(img, x, y, width, height) } else { const imageLoadPromise = new Promise((resolve, reject) => { @@ -111,7 +111,7 @@ export class ImageParticle { img.setAttribute('crossOrigin', 'Anonymous') img.src = element.value img.onload = () => { - this.imageCache.set(element.id!, img) + this.imageCache.set(element.value, img) resolve(element) // 衬于文字下方图片需要重新首先绘制 if (element.imgDisplay === ImageDisplay.FLOAT_BOTTOM) { @@ -128,7 +128,7 @@ export class ImageParticle { const fallbackImage = this.getFallbackImage(width, height) fallbackImage.onload = () => { ctx.drawImage(fallbackImage, x, y, width, height) - this.imageCache.set(element.id!, fallbackImage) + this.imageCache.set(element.value, fallbackImage) } reject(error) }