From 5272c85bbe9a723886506363e3ff4f51c2c6a941 Mon Sep 17 00:00:00 2001 From: Hufe921 Date: Thu, 11 Jan 2024 22:45:14 +0800 Subject: [PATCH] fix: control minimum width rendering boundary error #401 --- src/editor/core/draw/Draw.ts | 4 ++++ src/editor/core/draw/control/Control.ts | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/editor/core/draw/Draw.ts b/src/editor/core/draw/Draw.ts index f49f979..66a935b 100644 --- a/src/editor/core/draw/Draw.ts +++ b/src/editor/core/draw/Draw.ts @@ -1645,6 +1645,10 @@ export class Draw { this._drawRichText(ctx) this.blockParticle.render(pageNo, element, x, y) } else { + // 如果当前元素设置左偏移,则上一元素立即绘制 + if (element.left) { + this.textParticle.complete() + } this.textParticle.record(ctx, element, x, y + offsetY) // 如果设置字宽、字间距需单独绘制 if (element.width || element.letterSpacing) { diff --git a/src/editor/core/draw/control/Control.ts b/src/editor/core/draw/control/Control.ts index 2cae2a7..ec406fb 100644 --- a/src/editor/core/draw/control/Control.ts +++ b/src/editor/core/draw/control/Control.ts @@ -97,8 +97,15 @@ export class Control { } } } - if (!element.controlId || element.control?.minWidth) { - return true + if (!element.controlId) return true + if (element.control?.minWidth) { + if ( + element.controlComponent === ControlComponent.PREFIX || + element.controlComponent === ControlComponent.POSTFIX + ) { + element.value = '' + return true + } } return ( element.controlComponent !== ControlComponent.PREFIX &&