mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
feat(editor): propsService添加fillConfig方法,支持扩展
This commit is contained in:
parent
3cdcca3b0b
commit
31029bc8f1
@ -24,7 +24,7 @@ import type { MComponent, MNode } from '@tmagic/schema';
|
||||
import { toLine } from '@tmagic/utils';
|
||||
|
||||
import type { PropsState } from '../type';
|
||||
import { DEFAULT_CONFIG, fillConfig } from '../utils/props';
|
||||
import { fillConfig } from '../utils/props';
|
||||
|
||||
import BaseService from './BaseService';
|
||||
|
||||
@ -42,6 +42,7 @@ class Props extends BaseService {
|
||||
'getPropsValue',
|
||||
'createId',
|
||||
'setNewItemId',
|
||||
'fillConfig',
|
||||
'getDefaultPropsValue',
|
||||
]);
|
||||
}
|
||||
@ -53,13 +54,17 @@ class Props extends BaseService {
|
||||
this.emit('props-configs-change');
|
||||
}
|
||||
|
||||
public async fillConfig(config: FormConfig) {
|
||||
return fillConfig(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为指定类型组件设置组件属性表单配置
|
||||
* @param type 组件类型
|
||||
* @param config 组件属性表单配置
|
||||
*/
|
||||
public setPropsConfig(type: string, config: FormConfig) {
|
||||
this.state.propsConfigMap[type] = fillConfig(Array.isArray(config) ? config : [config]);
|
||||
public async setPropsConfig(type: string, config: FormConfig) {
|
||||
this.state.propsConfigMap[type] = await this.fillConfig(Array.isArray(config) ? config : [config]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,7 +77,7 @@ class Props extends BaseService {
|
||||
return await this.getPropsConfig('button');
|
||||
}
|
||||
|
||||
return cloneDeep(this.state.propsConfigMap[type] || DEFAULT_CONFIG);
|
||||
return cloneDeep(this.state.propsConfigMap[type] || this.fillConfig([]));
|
||||
}
|
||||
|
||||
public setPropsValues(values: Record<string, MNode>) {
|
||||
|
@ -234,6 +234,3 @@ export const fillConfig = (config: FormConfig = []) => [
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
// 默认组件属性表单配置
|
||||
export const DEFAULT_CONFIG: FormConfig = fillConfig([]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user