|
@@ -792,7 +792,7 @@ export default {
|
|
|
let textNode = this.$store.state.currentEditTextNode;
|
|
|
x = mode == "new" ? this.stage.width() * 0.1 + Math.floor(Math.random() * 200) : textNode.attrs.x;
|
|
|
y = mode == "new" ? this.stage.height() * 0.2 + Math.floor(Math.random() * 200) : textNode.attrs.y;
|
|
|
-
|
|
|
+ let uuid=this.$jsFn.getUUID()
|
|
|
let pastText = new Konva.Label({
|
|
|
x: x,
|
|
|
y: y,
|
|
@@ -812,6 +812,7 @@ export default {
|
|
|
name: "pastTextContent",
|
|
|
draggable: false,
|
|
|
listening: true,
|
|
|
+ uuid:uuid
|
|
|
})
|
|
|
);
|
|
|
pastText.add(
|
|
@@ -826,6 +827,7 @@ export default {
|
|
|
name: "pastTextContent",
|
|
|
draggable: false,
|
|
|
listening: true,
|
|
|
+ uuid:uuid
|
|
|
})
|
|
|
);
|
|
|
|
|
@@ -842,6 +844,8 @@ export default {
|
|
|
name: "default",
|
|
|
});
|
|
|
this.layer.add(pastText);
|
|
|
+ this.$toolbox.saveUndoHistory('add',pastText)//儲存undo記錄
|
|
|
+
|
|
|
if (mode == "edit") {
|
|
|
//殺掉原本的文字物件
|
|
|
textNode.destroy();
|
|
@@ -871,6 +875,7 @@ export default {
|
|
|
width: 300,
|
|
|
height: "auto",
|
|
|
name: "text",
|
|
|
+ uuid:this.$jsFn.getUUID()
|
|
|
});
|
|
|
|
|
|
let tr = new Konva.Transformer({
|
|
@@ -886,6 +891,8 @@ export default {
|
|
|
name: "default",
|
|
|
});
|
|
|
this.layer.add(textNode);
|
|
|
+ this.$toolbox.saveUndoHistory('add',textNode)//儲存undo記錄
|
|
|
+
|
|
|
if (mode == "edit") {
|
|
|
pastText.destroy();
|
|
|
//殺掉原本的Transformer
|
|
@@ -1111,6 +1118,7 @@ export default {
|
|
|
let text = item.seat + "\t\t\t" + (this.$store.state.hideStudentName == false ? item.name : "");
|
|
|
|
|
|
let that = this;
|
|
|
+ let uuid = this.$jsFn.getUUID()
|
|
|
|
|
|
Konva.Image.fromURL(item.url, function (image) {
|
|
|
// image is Konva.Image instance
|
|
@@ -1126,6 +1134,7 @@ export default {
|
|
|
draggable: false,
|
|
|
listenning: false,
|
|
|
name: "pastImgContent",
|
|
|
+ uuid:uuid
|
|
|
});
|
|
|
var circle = new Konva.Circle({
|
|
|
radius: 16,
|
|
@@ -1135,6 +1144,7 @@ export default {
|
|
|
draggable: false,
|
|
|
listening: false,
|
|
|
name: "pastImgContent",
|
|
|
+ uuid:uuid
|
|
|
});
|
|
|
var rect = new Konva.Rect({
|
|
|
radius: 20,
|
|
@@ -1147,14 +1157,16 @@ export default {
|
|
|
draggable: false,
|
|
|
listening: false,
|
|
|
name: "pastImgContent",
|
|
|
+ uuid:uuid
|
|
|
});
|
|
|
- console.log(layer.children);
|
|
|
+
|
|
|
var group = new Konva.Group({
|
|
|
x: image.attrs.image.naturalWidth * scaleY * (index % 3) + 40 * ((index % 3) + 1),
|
|
|
y: index + 1 > 3 ? image.attrs.image.naturalHeight * scaleY + 110 : 60,
|
|
|
text: text,
|
|
|
draggable: true,
|
|
|
listening: true,
|
|
|
+ uuid:uuid
|
|
|
});
|
|
|
|
|
|
group.add(image);
|
|
@@ -1181,6 +1193,7 @@ export default {
|
|
|
draggable: false,
|
|
|
listenning: false,
|
|
|
name: "pastImgContent",
|
|
|
+ uuid:uuid
|
|
|
})
|
|
|
);
|
|
|
group.on("mouseover", function () {
|
|
@@ -1191,22 +1204,9 @@ export default {
|
|
|
});
|
|
|
|
|
|
layer.add(group);
|
|
|
-
|
|
|
- // stage.find('Transformer').destroy()
|
|
|
+ that.$toolbox.saveUndoHistory('add',group)//儲存undo記錄
|
|
|
+
|
|
|
let tr = new Konva.Transformer({
|
|
|
- // boundBoxFunc: function (oldBoundBox, newBoundBox) {
|
|
|
- // // "boundBox" is an object with
|
|
|
- // // x, y, width, height and rotation properties
|
|
|
- // // transformer tool will try to fit nodes into that box
|
|
|
-
|
|
|
- // // the logic is simple, if new width is too big
|
|
|
- // // we will return previous state
|
|
|
- // if (Math.abs(newBoundBox.width) > 600) {
|
|
|
- // return oldBoundBox;
|
|
|
- // }
|
|
|
-
|
|
|
- // return newBoundBox;
|
|
|
- // },
|
|
|
anchorStroke: "#00a6ff",
|
|
|
anchorFill: "#fff",
|
|
|
anchorSize: 12,
|
|
@@ -2600,7 +2600,7 @@ export default {
|
|
|
}
|
|
|
|
|
|
// console.log(target.parent.className == 'Transformer', '拖动的元素')
|
|
|
- if (target.className != "text" && target.attrs.name != "pastTextContent" && target.attrs.name != "pastImgContent") {
|
|
|
+ if (target.className != "text" && target.attrs.name != "pastTextContent" && target.attrs.name != "pastImgContent"&&target.attrs.name != "pastTextPickName") {
|
|
|
target.draggable(true);
|
|
|
}
|
|
|
|
|
@@ -2684,14 +2684,7 @@ export default {
|
|
|
tr.nodes([this]);
|
|
|
that.addMenuBtnToTr(tr, this);
|
|
|
layer.draw();
|
|
|
- } else if (target.attrs.name == "pastImgContent" && target.className != "text") {
|
|
|
- target.draggable(false);
|
|
|
- target.parent.draggable(true);
|
|
|
- layer.add(tr);
|
|
|
- tr.nodes([this.parent]);
|
|
|
- that.addMenuBtnToTr(tr, this.parent);
|
|
|
- layer.draw();
|
|
|
- } else if ((target.attrs.name == "pastTextContent" && target.className != "text") || (target.attrs.name == "pastTextPickName" && target.className != "text")) {
|
|
|
+ } else if (target.attrs.name == "pastImgContent" && target.className != "text"||target.attrs.name == "pastTextPickName"||target.attrs.name == "pastTextContent" && target.className != "text") {
|
|
|
target.draggable(false);
|
|
|
target.parent.draggable(true);
|
|
|
layer.add(tr);
|