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,
|
collapseValue,
|
||||||
list,
|
list,
|
||||||
|
|
||||||
appendComponent({ text, type, ...config }: ComponentItem): void {
|
appendComponent({ text, type, data = {} }: ComponentItem): void {
|
||||||
services?.editorService.add({
|
services?.editorService.add({
|
||||||
name: text,
|
name: text,
|
||||||
type,
|
type,
|
||||||
...config,
|
...data,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -72,6 +72,7 @@ export default defineComponent({
|
|||||||
services?.editorService.add({
|
services?.editorService.add({
|
||||||
name: config.text,
|
name: config.text,
|
||||||
type: config.type,
|
type: config.type,
|
||||||
|
...(config.data || {}),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ class Editor extends BaseService {
|
|||||||
|
|
||||||
const layout = await this.getLayout(parentNode);
|
const layout = await this.getLayout(parentNode);
|
||||||
const newNode = initPosition(
|
const newNode = initPosition(
|
||||||
{ ...toRaw(await propsService.getPropsValue(type)), ...config },
|
{ ...toRaw(await propsService.getPropsValue(type, config)) },
|
||||||
layout,
|
layout,
|
||||||
parentNode,
|
parentNode,
|
||||||
this.get<StageCore>('stage'),
|
this.get<StageCore>('stage'),
|
||||||
|
@ -87,7 +87,7 @@ class Props extends BaseService {
|
|||||||
* @param type 组件类型
|
* @param type 组件类型
|
||||||
* @returns 组件初始值
|
* @returns 组件初始值
|
||||||
*/
|
*/
|
||||||
public async getPropsValue(type: string) {
|
public async getPropsValue(type: string, defaultValue = {}) {
|
||||||
if (type === 'area') {
|
if (type === 'area') {
|
||||||
const value = (await this.getPropsValue('button')) as MComponent;
|
const value = (await this.getPropsValue('button')) as MComponent;
|
||||||
value.className = 'action-area';
|
value.className = 'action-area';
|
||||||
@ -100,6 +100,7 @@ class Props extends BaseService {
|
|||||||
|
|
||||||
return cloneDeep({
|
return cloneDeep({
|
||||||
...getDefaultPropsValue(type),
|
...getDefaultPropsValue(type),
|
||||||
|
...defaultValue,
|
||||||
...(this.state.propsValueMap[type] || {}),
|
...(this.state.propsValueMap[type] || {}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,9 @@ export interface ComponentItem {
|
|||||||
type: string;
|
type: string;
|
||||||
/** element-plus icon class */
|
/** element-plus icon class */
|
||||||
icon?: string | Component;
|
icon?: string | Component;
|
||||||
[key: string]: any;
|
data?: {
|
||||||
|
[key: string]: any;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ComponentGroup {
|
export interface ComponentGroup {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user