mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-09-21 22:39:58 +08:00
fix(editor): 修复新增组件时,组件列表配置的数据丢失问题
This commit is contained in:
parent
31373500c2
commit
992ebbe3ce
@ -56,11 +56,11 @@ export default defineComponent({
|
||||
collapseValue,
|
||||
list,
|
||||
|
||||
appendComponent({ text, type, ...config }: ComponentItem): void {
|
||||
appendComponent({ text, type, data = {} }: ComponentItem): void {
|
||||
services?.editorService.add({
|
||||
name: text,
|
||||
type,
|
||||
...config,
|
||||
...data,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
@ -72,6 +72,7 @@ export default defineComponent({
|
||||
services?.editorService.add({
|
||||
name: config.text,
|
||||
type: config.type,
|
||||
...(config.data || {}),
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -229,7 +229,7 @@ class Editor extends BaseService {
|
||||
|
||||
const layout = await this.getLayout(parentNode);
|
||||
const newNode = initPosition(
|
||||
{ ...toRaw(await propsService.getPropsValue(type)), ...config },
|
||||
{ ...toRaw(await propsService.getPropsValue(type, config)) },
|
||||
layout,
|
||||
parentNode,
|
||||
this.get<StageCore>('stage'),
|
||||
|
@ -87,7 +87,7 @@ class Props extends BaseService {
|
||||
* @param type 组件类型
|
||||
* @returns 组件初始值
|
||||
*/
|
||||
public async getPropsValue(type: string) {
|
||||
public async getPropsValue(type: string, defaultValue = {}) {
|
||||
if (type === 'area') {
|
||||
const value = (await this.getPropsValue('button')) as MComponent;
|
||||
value.className = 'action-area';
|
||||
@ -100,6 +100,7 @@ class Props extends BaseService {
|
||||
|
||||
return cloneDeep({
|
||||
...getDefaultPropsValue(type),
|
||||
...defaultValue,
|
||||
...(this.state.propsValueMap[type] || {}),
|
||||
});
|
||||
}
|
||||
|
@ -220,7 +220,9 @@ export interface ComponentItem {
|
||||
type: string;
|
||||
/** element-plus icon class */
|
||||
icon?: string | Component;
|
||||
[key: string]: any;
|
||||
data?: {
|
||||
[key: string]: any;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ComponentGroup {
|
||||
|
Loading…
x
Reference in New Issue
Block a user