|
@@ -69,10 +69,12 @@ export const store = EditorModule.store({
|
|
this.store.compPids[compId] = pid;
|
|
this.store.compPids[compId] = pid;
|
|
},
|
|
},
|
|
async insertDesignContent(compKey: ICompKeys, index?: number) {
|
|
async insertDesignContent(compKey: ICompKeys, index?: number) {
|
|
- const { pageCompIds } = this.store;
|
|
|
|
- index === undefined && (index = pageCompIds.length);
|
|
|
|
const compId = await this.controls.compUICtrl.createCompId(compKey);
|
|
const compId = await this.controls.compUICtrl.createCompId(compKey);
|
|
- pageCompIds.splice(index, 0, compId);
|
|
|
|
|
|
+ const childIds = [...this.store.pageCompIds];
|
|
|
|
+
|
|
|
|
+ index === undefined && (index = childIds.length);
|
|
|
|
+ childIds.splice(index, 0, compId);
|
|
|
|
+ this.store.designData.compMap.root.children.default = childIds;
|
|
return compId;
|
|
return compId;
|
|
},
|
|
},
|
|
async insertCompContainer(compKey: ICompKeys, container: DesignComp) {
|
|
async insertCompContainer(compKey: ICompKeys, container: DesignComp) {
|
|
@@ -84,7 +86,6 @@ export const store = EditorModule.store({
|
|
},
|
|
},
|
|
setCurrComp(compId: string) {
|
|
setCurrComp(compId: string) {
|
|
this.store.currCompId = compId;
|
|
this.store.currCompId = compId;
|
|
-
|
|
|
|
const comps = this.helper.getCompTrees(compId);
|
|
const comps = this.helper.getCompTrees(compId);
|
|
|
|
|
|
if (compId == "root") {
|
|
if (compId == "root") {
|
|
@@ -98,7 +99,7 @@ export const store = EditorModule.store({
|
|
const parentComp = this.helper.findParentComp(compId);
|
|
const parentComp = this.helper.findParentComp(compId);
|
|
let deleteOK = false;
|
|
let deleteOK = false;
|
|
if (parentComp) {
|
|
if (parentComp) {
|
|
- const ids = [...parentComp.children.default || []];
|
|
|
|
|
|
+ const ids = [...(parentComp.children.default || [])];
|
|
// 只能删除children.default中的组件
|
|
// 只能删除children.default中的组件
|
|
if (ids?.includes(compId)) {
|
|
if (ids?.includes(compId)) {
|
|
const index = ids.findIndex((id) => id === compId);
|
|
const index = ids.findIndex((id) => id === compId);
|
|
@@ -120,9 +121,10 @@ export const store = EditorModule.store({
|
|
}
|
|
}
|
|
},
|
|
},
|
|
moveComp(selIndex: number, targetIndex: number) {
|
|
moveComp(selIndex: number, targetIndex: number) {
|
|
- const { pageCompIds } = this.store;
|
|
|
|
|
|
+ const pageCompIds = [...this.store.pageCompIds]
|
|
const [selComp] = pageCompIds.splice(selIndex, 1);
|
|
const [selComp] = pageCompIds.splice(selIndex, 1);
|
|
pageCompIds.splice(targetIndex, 0, selComp);
|
|
pageCompIds.splice(targetIndex, 0, selComp);
|
|
|
|
+ this.store.designData.compMap.root.children.default = pageCompIds;
|
|
},
|
|
},
|
|
setTextEditingState(state: boolean) {
|
|
setTextEditingState(state: boolean) {
|
|
this.store.textEditingState = state;
|
|
this.store.textEditingState = state;
|