diff --git a/src/editor/core/draw/Draw.ts b/src/editor/core/draw/Draw.ts index a47352b..17f68f2 100644 --- a/src/editor/core/draw/Draw.ts +++ b/src/editor/core/draw/Draw.ts @@ -711,7 +711,9 @@ export class Draw { metrics.boundingBoxDescent = 0 metrics.boundingBoxAscent = metrics.height } else if (element.type === ElementType.BLOCK) { - metrics.width = element.width! * scale + metrics.width = element.width + ? element.width * scale + : this.getInnerWidth() metrics.height = element.height! * scale metrics.boundingBoxDescent = metrics.height metrics.boundingBoxAscent = 0 diff --git a/src/editor/core/draw/particle/block/modules/BaseBlock.ts b/src/editor/core/draw/particle/block/modules/BaseBlock.ts index cfa70d7..20952cc 100644 --- a/src/editor/core/draw/particle/block/modules/BaseBlock.ts +++ b/src/editor/core/draw/particle/block/modules/BaseBlock.ts @@ -44,13 +44,13 @@ export class BaseBlock { } public setClientRects(pageNo: number, x: number, y: number) { - const scale = this.draw.getOptions().scale const height = this.draw.getHeight() const pageGap = this.draw.getPageGap() const preY = pageNo * (height + pageGap) // 尺寸 - this.blockItem.style.width = `${this.element.width! * scale}px` - this.blockItem.style.height = `${this.element.height! * scale}px` + const { metrics } = this.element + this.blockItem.style.width = `${metrics.width}px` + this.blockItem.style.height = `${metrics.height}px` // 位置 this.blockItem.style.left = `${x}px` this.blockItem.style.top = `${preY + y}px` diff --git a/src/editor/utils/element.ts b/src/editor/utils/element.ts index 7352aab..c171035 100644 --- a/src/editor/utils/element.ts +++ b/src/editor/utils/element.ts @@ -237,16 +237,9 @@ export function formatElementList(elementList: IElement[], options: IFormatEleme if (el.value === '\n') { el.value = ZERO } - if (el.type === ElementType.IMAGE) { + if (el.type === ElementType.IMAGE || el.type === ElementType.BLOCK) { el.id = getUUID() } - if (el.type === ElementType.BLOCK) { - el.id = getUUID() - if (!el.width) { - const { editorOptions: { width, margins } } = options - el.width = width - margins[1] - margins[3] - } - } if (el.type === ElementType.LATEX) { const { svg, width, height } = LaTexParticle.convertLaTextToSVG(el.value) el.width = el.width || width