refactor: TextContent 与 Textbox 重新实现

This commit is contained in:
AncTe committed 2026-11-23 20:26:29 +08:00
1 parent 13758114c2
commit 56ae1b757b
3 files changed
+193 -402

No files matched your search

+5 -2
View File
@@ -28,7 +28,7 @@ export class RenderText
constructor() {
super();
this.eventNames.add('onSetText');
this.eventNames.add('onSetText').add('onUpdateSize');
}
protected getDefaultCache(): boolean {
@@ -121,7 +121,10 @@ export class RenderText
this.descent = actualBoundingBoxAscent;
const height = actualBoundingBoxAscent + actualBoundingBoxDescent;
const stroke = this.strokeWidth * 2;
this.size(width + stroke, height + stroke + SAFE_PAD * 2);
const tw = width + stroke;
const th = height + stroke + SAFE_PAD * 2;
this.size(tw, th);
this.forEachHook(hook => hook.onUpdateSize?.(tw, th));
}
protected handleProps(
+7
View File
@@ -656,6 +656,13 @@ export interface IRenderTextHooks extends IRenderItemBaseHooks {
* @param text 设置的文字内容
*/
onSetText?(text: string): void;
/**
* 当更新文字的尺寸时触发
* @param width 文字的宽度
* @param height 文字的高度
*/
onUpdateSize?(width: number, height: number): void;
}
export interface IRenderText extends IRenderItem<IRenderTextHooks> {