|
@@ -1,4 +1,4 @@
|
|
|
-import { cloneDeep, pick } from "lodash";
|
|
|
+import { cloneDeep, curry, pick } from "lodash";
|
|
|
import { Exception, queenApi } from "queenjs";
|
|
|
import { EditorModule } from "..";
|
|
|
import { ScreenshotCtrl } from "../../controllers/ScreenshotCtrl";
|
|
@@ -10,9 +10,16 @@ import { ObjsContainer } from "../../controllers/SelectCtrl/ObjsContainer";
|
|
|
import { getKeyThenIncreaseKey } from "ant-design-vue/lib/message";
|
|
|
import { Matrix } from "../../controllers/SelectCtrl/matrix";
|
|
|
import { nanoid } from "nanoid";
|
|
|
-import { string } from "vue-types";
|
|
|
|
|
|
-let ctrlcselected: string[] = [];
|
|
|
+
|
|
|
+const ctrlState = {
|
|
|
+ selected: [] as string[],
|
|
|
+ type: 0, // 1 ctrlc 2 ctrlx
|
|
|
+ cardId: "", //当前的卡片Id
|
|
|
+ selWidth: 0,
|
|
|
+ selX: 0,
|
|
|
+ selY: 0
|
|
|
+}
|
|
|
|
|
|
export const editActions = EditorModule.action({
|
|
|
pickComp(compId: string, selected = true) {
|
|
@@ -259,7 +266,7 @@ export const editActions = EditorModule.action({
|
|
|
this.helper.extendStreamCard(compId);
|
|
|
|
|
|
this.actions.selectObjs([]);
|
|
|
-
|
|
|
+
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -320,11 +327,23 @@ export const editActions = EditorModule.action({
|
|
|
|
|
|
ctrlc() {
|
|
|
// console.log("contrc ", this.store.selected);
|
|
|
- ctrlcselected = this.store.selected.slice(0);
|
|
|
+ ctrlState.selected = this.store.selected.slice(0);
|
|
|
+ ctrlState.cardId = this.store.currStreamCardId;
|
|
|
+ ctrlState.type = 1;
|
|
|
+ const objc = this.controls.selectCtrl.objContainer as ObjsContainer;
|
|
|
+ ctrlState.selWidth = this.helper.pxToDesignSize(objc.width);
|
|
|
+ objc.setPivot(0);
|
|
|
+ const currX = objc.parent.x, currY = objc.parent.y;
|
|
|
+ ctrlState.selX = currX;
|
|
|
+ ctrlState.selY = currY;
|
|
|
+ objc.setPivot(4);
|
|
|
},
|
|
|
+
|
|
|
copyLastSelected() {
|
|
|
if (this.store.currCompId && this.store.currCompId != "root") {
|
|
|
- ctrlcselected = [this.store.currCompId];
|
|
|
+ ctrlState.selected = [this.store.currCompId];
|
|
|
+ ctrlState.cardId = this.store.currStreamCardId;
|
|
|
+ ctrlState.type = 1;
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -368,10 +387,24 @@ export const editActions = EditorModule.action({
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+ ctrlx() {
|
|
|
+ //console.log("ctrlv ", this.store.selected);
|
|
|
+ //console.log("ctrlv ", this.store.selected);
|
|
|
+ ctrlState.selected = this.store.selected.slice(0);
|
|
|
+ ctrlState.cardId = this.store.currStreamCardId;
|
|
|
+ ctrlState.type = 2;
|
|
|
+
|
|
|
+ const objc = this.controls.selectCtrl.objContainer as ObjsContainer;
|
|
|
+ ctrlState.selWidth = this.helper.pxToDesignSize(objc.width);
|
|
|
+ objc.setPivot(0);
|
|
|
+ const currX = objc.parent.x, currY = objc.parent.y;
|
|
|
+ ctrlState.selX = currX;
|
|
|
+ ctrlState.selY = currY;
|
|
|
+ objc.setPivot(4);
|
|
|
+ },
|
|
|
|
|
|
ctrlv() {
|
|
|
- console.log("ctrlv ", this.store.selected);
|
|
|
- if (ctrlcselected.length < 1) return;
|
|
|
+ if (ctrlState.selected.length < 1) return;
|
|
|
|
|
|
const news: string[] = [];
|
|
|
|
|
@@ -391,12 +424,12 @@ export const editActions = EditorModule.action({
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- ctrlcselected.forEach((c) => {
|
|
|
+
|
|
|
+ ctrlState.selected.forEach((c) => {
|
|
|
const cp = this.helper.findComp(c) as DesignComp;
|
|
|
const cp1 = cloneDeep(cp);
|
|
|
cp1.id = nanoid();
|
|
|
news.push(cp1.id);
|
|
|
-
|
|
|
this.store.compMap[cp1.id] = cp1;
|
|
|
this.store.setCompPid(cp1.id, this.store.currStreamCardId);
|
|
|
|
|
@@ -404,10 +437,29 @@ export const editActions = EditorModule.action({
|
|
|
});
|
|
|
|
|
|
this.actions.addComps(news);
|
|
|
-
|
|
|
this.actions.selectObjs(news);
|
|
|
|
|
|
setTimeout(() => {
|
|
|
+ if (ctrlState.type == 2) {//剪辑删除原来的组件
|
|
|
+ const card = this.helper.findComp(ctrlState.cardId) as DesignComp;
|
|
|
+ const childs = card.children.default?.slice(0) || [];
|
|
|
+ ctrlState.selected.forEach(s=>{
|
|
|
+ let i = childs.indexOf(s);
|
|
|
+ if (i != -1) {
|
|
|
+ childs.splice(i, 1);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ card.children.default = childs;
|
|
|
+ this.helper.extendStreamCard(ctrlState.cardId);
|
|
|
+ ctrlState.selected = [];
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取当前选中的内容
|
|
|
+ if ( ctrlState.cardId != this.store.currStreamCardId) {//跨卡片拷贝
|
|
|
+ let pox = this.helper.getCardNextPosY(this.store.currStreamCardId, ctrlState.selWidth);
|
|
|
+ this.controls.selectCtrl.translate(0, pox.y - ctrlState.selY);
|
|
|
+ return;
|
|
|
+ }
|
|
|
this.controls.selectCtrl.translate(20, 20);
|
|
|
}, 100);
|
|
|
},
|