|
@@ -4,6 +4,7 @@ import { EditorModule } from "..";
|
|
|
import { ScreenshotCtrl } from "../../controllers/ScreenshotCtrl";
|
|
|
import { DesignComp } from "../../objects/DesignTemp/DesignComp";
|
|
|
import { ICompKeys, Layout } from "../../typings";
|
|
|
+import { CompObject } from "../../controllers/SelectCtrl/compObj";
|
|
|
|
|
|
export const editActions = EditorModule.action({
|
|
|
// 通过拖拽添加组件到画布
|
|
@@ -21,14 +22,24 @@ export const editActions = EditorModule.action({
|
|
|
},
|
|
|
// 通过点击添加组件到画布
|
|
|
async clickCompToDesign(compKey: ICompKeys) {
|
|
|
+
|
|
|
+ const bound = this.helper.getCardCompBound(this.store.currCompId);
|
|
|
+
|
|
|
await this.actions.addCompToDesign(compKey);
|
|
|
- const { currStreamCard, currComp } = this.store;
|
|
|
+ const { currComp } = this.store;
|
|
|
|
|
|
- const y = currStreamCard.getH();
|
|
|
- currStreamCard.setH(y + currComp.getH());
|
|
|
- currComp.translate(0, y);
|
|
|
+ //添加组件到当前选中的组件下面
|
|
|
+ const obj = new CompObject(currComp);
|
|
|
+ const selectCtrl = this.controls.selectCtrl;
|
|
|
+ selectCtrl.selecteObjs([obj]);
|
|
|
+ selectCtrl.translate(0, bound.y + bound.h);
|
|
|
+
|
|
|
+ //扩展
|
|
|
+ this.helper.extendStreamCard(this.store.currStreamCardId);
|
|
|
},
|
|
|
|
|
|
+
|
|
|
+
|
|
|
// 添加组件到画布
|
|
|
async addCompToDesign(compKey: ICompKeys, index?: number) {
|
|
|
if (!this.store.currStreamCardId) {
|
|
@@ -42,23 +53,13 @@ export const editActions = EditorModule.action({
|
|
|
this.actions.pickComp(compId);
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- // if (
|
|
|
- // index === undefined &&
|
|
|
- // this.store.currComp?.compKey === "Container"
|
|
|
- // // this.store.pageCompIds.includes(this.store.currComp.id)
|
|
|
- // ) {
|
|
|
-
|
|
|
const compId = await this.store.insertCompContainer(
|
|
|
compKey,
|
|
|
this.store.currStreamCard
|
|
|
);
|
|
|
this.actions.pickComp(compId);
|
|
|
- this.actions.setCompPosition(this.store.currComp);
|
|
|
- // } else {
|
|
|
- // compId = await this.store.insertDesignContent(compKey, index);
|
|
|
- // this.actions.pickComp(compId);
|
|
|
- // }
|
|
|
+ this.actions.setCompPositionFloat(this.store.currComp);
|
|
|
+
|
|
|
},
|
|
|
// 切换当前组件
|
|
|
pickComp(compId: string) {
|
|
@@ -233,6 +234,11 @@ export const editActions = EditorModule.action({
|
|
|
set(comp, path, value);
|
|
|
},
|
|
|
|
|
|
+ // 设置组件浮动
|
|
|
+ setCompPositionFloat(comp: DesignComp) {
|
|
|
+ comp.layout.position = "absolute"
|
|
|
+ },
|
|
|
+
|
|
|
// 设置组件浮动
|
|
|
setCompPosition(comp: DesignComp) {
|
|
|
comp.layout.position =
|