mirror of
https://github.com/motajs/template.git
synced 2026-12-01 03:04:30 +08:00
refactor: TextContent 与 Textbox 重新实现
This commit is contained in:
1 parent
13758114c2
commit
56ae1b757b
3 files changed
+193
-402
No files matched your search
@@ -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(
|
||||
|
||||
@@ -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> {
|
||||
|
||||
Reference in new issue
Block a user