diff --git a/packages/form/docs/customize.en-US.md b/packages/form/docs/customize.en-US.md index eb04040d42..c864a75238 100644 --- a/packages/form/docs/customize.en-US.md +++ b/packages/form/docs/customize.en-US.md @@ -31,21 +31,44 @@ export function withTestWidget(): SFWidgetProvideConfig { } @Component({ - selector: 'test', + selector: 'sf-tinymce', template: ` - - test widget, {{ data }} - - `, + + + + + + `, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [DelonFormModule] }) class TestWidget extends ControlWidget implements OnInit { - data?: string; + /* KEY value for registering widgets */ + static readonly KEY = 'test'; + + // It is recommended to use `ngOnInit` to obtain the parameters required by the component. + config: any; + loadingTip: string; + ngOnInit(): void { - console.warn('init test widget'); + this.loadingTip = this.ui.loadingTip || 'Loading……'; + this.config = this.ui.config || {}; + } + + // reset can better solve the problem of new data required during the form reset process + reset(value: string) { + + } + + change(value: string) { + if (this.ui.change) this.ui.change(value); + this.setValue(value); } } ``` diff --git a/packages/form/docs/customize.zh-CN.md b/packages/form/docs/customize.zh-CN.md index 3f63fa6c5d..e36c38586c 100644 --- a/packages/form/docs/customize.zh-CN.md +++ b/packages/form/docs/customize.zh-CN.md @@ -31,21 +31,44 @@ export function withTestWidget(): SFWidgetProvideConfig { } @Component({ - selector: 'test', + selector: 'sf-tinymce', template: ` - - test widget, {{ data }} - - `, + + + + + + `, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [DelonFormModule] }) class TestWidget extends ControlWidget implements OnInit { - data?: string; + /* 用于注册小部件 KEY 值 */ + static readonly KEY = 'test'; + + // 组件所需要的参数,建议使用 `ngOnInit` 获取 + config: any; + loadingTip: string; + ngOnInit(): void { - console.warn('init test widget'); + this.loadingTip = this.ui.loadingTip || '加载中……'; + this.config = this.ui.config || {}; + } + + // reset 可以更好的解决表单重置过程中所需要的新数据问题 + reset(value: string) { + + } + + change(value: string) { + if (this.ui.change) this.ui.change(value); + this.setValue(value); } } ```