|
@@ -24,12 +24,20 @@ export const editActions = EditorModule.action({
|
|
|
// 通过点击添加组件到画布
|
|
|
async clickCompToDesign(compKey: ICompKeys, cb?: (comp: DesignComp) => void) {
|
|
|
|
|
|
+ //点击默认都创建一个容器
|
|
|
+ //创建容器
|
|
|
+ const isCreatCard = compKey != "Text"
|
|
|
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);
|
|
@@ -39,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);
|