|
@@ -24,12 +24,21 @@ export const editActions = EditorModule.action({
|
|
|
// 通过点击添加组件到画布
|
|
|
async clickCompToDesign(compKey: ICompKeys, cb?: (comp: DesignComp) => void) {
|
|
|
|
|
|
+ //点击默认都创建一个容器
|
|
|
+ //创建容器
|
|
|
+ const isCreatCard = compKey != "Text" && compKey != "Image" && compKey != "Video" && compKey != "Web3D";
|
|
|
+
|
|
|
let yOffset = 0;
|
|
|
- if (this.store.currCompId != this.store.currStreamCardId) {
|
|
|
+ if (this.store.currCompId != this.store.currStreamCardId && !isCreatCard) {
|
|
|
const bound = this.helper.getCardCompBound(this.store.currCompId);
|
|
|
yOffset = bound.y + bound.h
|
|
|
}
|
|
|
|
|
|
+ if (isCreatCard) { //先创建卡片
|
|
|
+ const index = this.store.streamCardIds.indexOf(this.store.currStreamCardId) + 1;
|
|
|
+ const compId = await this.store.insertDesignContent("Container", index);
|
|
|
+ this.actions.pickComp(compId);
|
|
|
+ }
|
|
|
await this.actions.addCompToDesign(compKey);
|
|
|
const { currComp } = this.store;
|
|
|
cb?.(currComp);
|
|
@@ -38,6 +47,7 @@ export const editActions = EditorModule.action({
|
|
|
const selectCtrl = this.controls.selectCtrl;
|
|
|
let xOffset = this.helper.designSizeToPx(375 - (currComp.layout.size?.[0] || 750) / 2);
|
|
|
selectCtrl.translate(xOffset, yOffset);
|
|
|
+ selectCtrl.selecteObjs([]);
|
|
|
|
|
|
//扩展
|
|
|
this.helper.extendStreamCard(this.store.currStreamCardId);
|
|
@@ -115,10 +125,10 @@ export const editActions = EditorModule.action({
|
|
|
removeComp(compId: string) {
|
|
|
|
|
|
if (this.helper.isCompCanDelete(compId)) {
|
|
|
- if (compId === this.store.currCompId) {
|
|
|
- this.controls.selectCtrl.selecteObjs([]);
|
|
|
+ if (compId === this.store.currCompId) {
|
|
|
this.store.setCurrComp("root");
|
|
|
}
|
|
|
+ this.controls.selectCtrl.selecteObjs([]);
|
|
|
this.store.deleteComp(compId);
|
|
|
}
|
|
|
},
|
|
@@ -126,9 +136,10 @@ export const editActions = EditorModule.action({
|
|
|
async removeStreamCard(compId: string) {
|
|
|
await queenApi.showConfirm({ title: "删除", content: "确认删除当前内容?" });
|
|
|
|
|
|
- if (this.store.streamCardIds.length < 2) {
|
|
|
- return;
|
|
|
- }
|
|
|
+ // if (this.store.streamCardIds.length < 2) {
|
|
|
+ // queenApi.messageError("")
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
let nextCard = this.store.currStreamCardId;
|
|
|
if (compId == this.store.currStreamCardId) {
|
|
|
const i = this.store.streamCardIds.indexOf(compId);
|
|
@@ -137,7 +148,10 @@ export const editActions = EditorModule.action({
|
|
|
nextCard = this.store.streamCardIds[i - 1];
|
|
|
}
|
|
|
}
|
|
|
+ this.controls.selectCtrl.selecteObjs([])
|
|
|
+
|
|
|
this.store.deleteComp(compId);
|
|
|
+
|
|
|
this.store.setCurrComp(nextCard);
|
|
|
},
|
|
|
// 移动组件顺序
|