@inditextech/weave-sdk 0.42.2 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/sdk.cjs +184 -187
- package/dist/sdk.d.cts +18 -2
- package/dist/sdk.d.cts.map +1 -1
- package/dist/sdk.d.ts +18 -2
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +197 -201
- package/dist/sdk.js.map +1 -1
- package/package.json +2 -2
package/dist/sdk.cjs
CHANGED
|
@@ -18450,6 +18450,7 @@ var WeaveStateManager = class {
|
|
|
18450
18450
|
return;
|
|
18451
18451
|
}
|
|
18452
18452
|
const doc = (0, __syncedstore_core.getYjsDoc)(state);
|
|
18453
|
+
const userId = this.instance.getStore().getUser().id;
|
|
18453
18454
|
doc.transact(() => {
|
|
18454
18455
|
if (!parent.props.children) parent.props.children = [];
|
|
18455
18456
|
if (index) {
|
|
@@ -18468,7 +18469,7 @@ var WeaveStateManager = class {
|
|
|
18468
18469
|
parent.props.children.push(nodeToAdd);
|
|
18469
18470
|
}
|
|
18470
18471
|
this.instance.emitEvent("onNodeAdded", node);
|
|
18471
|
-
});
|
|
18472
|
+
}, userId);
|
|
18472
18473
|
}
|
|
18473
18474
|
deepSyncSyncedStore(target, source) {
|
|
18474
18475
|
for (const key in target) if (!(key in source)) delete target[key];
|
|
@@ -18512,9 +18513,10 @@ var WeaveStateManager = class {
|
|
|
18512
18513
|
return;
|
|
18513
18514
|
}
|
|
18514
18515
|
const doc = (0, __syncedstore_core.getYjsDoc)(state);
|
|
18516
|
+
const userId = this.instance.getStore().getUser().id;
|
|
18515
18517
|
doc.transact(() => {
|
|
18516
18518
|
this.deepSyncSyncedStore(nodeState.props, node.props);
|
|
18517
|
-
});
|
|
18519
|
+
}, userId);
|
|
18518
18520
|
this.instance.emitEvent("onNodeUpdated", node);
|
|
18519
18521
|
}
|
|
18520
18522
|
removeNode(node) {
|
|
@@ -18536,6 +18538,7 @@ var WeaveStateManager = class {
|
|
|
18536
18538
|
return;
|
|
18537
18539
|
}
|
|
18538
18540
|
const doc = (0, __syncedstore_core.getYjsDoc)(state);
|
|
18541
|
+
const userId = this.instance.getStore().getUser().id;
|
|
18539
18542
|
doc.transact(() => {
|
|
18540
18543
|
if (parent.props.children) {
|
|
18541
18544
|
for (let i = parent.props.children.length - 1; i >= 0; i--) if (parent.props.children[i].key === node.key) {
|
|
@@ -18545,7 +18548,7 @@ var WeaveStateManager = class {
|
|
|
18545
18548
|
for (let i = 0; i < parent.props.children.length; i++) parent.props.children[i].props.zIndex = i;
|
|
18546
18549
|
this.instance.emitEvent("onNodeRemoved", node);
|
|
18547
18550
|
}
|
|
18548
|
-
});
|
|
18551
|
+
}, userId);
|
|
18549
18552
|
}
|
|
18550
18553
|
removeNodes(nodes) {
|
|
18551
18554
|
for (const node of nodes) this.removeNode(node);
|
|
@@ -18577,6 +18580,7 @@ var WeaveStateManager = class {
|
|
|
18577
18580
|
return;
|
|
18578
18581
|
}
|
|
18579
18582
|
const doc = (0, __syncedstore_core.getYjsDoc)(state);
|
|
18583
|
+
const userId = this.instance.getStore().getUser().id;
|
|
18580
18584
|
doc.transact(() => {
|
|
18581
18585
|
if (parent.props.children) {
|
|
18582
18586
|
const item = JSON.parse(JSON.stringify(parent.props.children[nodeIndex]));
|
|
@@ -18587,7 +18591,7 @@ var WeaveStateManager = class {
|
|
|
18587
18591
|
if (item && position === __inditextech_weave_types.WEAVE_NODE_POSITION.BACK) parent.props.children.splice(0, 0, item);
|
|
18588
18592
|
for (let i = 0; i < parent.props.children.length; i++) parent.props.children[i].props.zIndex = i;
|
|
18589
18593
|
}
|
|
18590
|
-
});
|
|
18594
|
+
}, userId);
|
|
18591
18595
|
}
|
|
18592
18596
|
}
|
|
18593
18597
|
getElementsTree() {
|
|
@@ -18673,7 +18677,7 @@ var WeaveRegisterManager = class {
|
|
|
18673
18677
|
|
|
18674
18678
|
//#endregion
|
|
18675
18679
|
//#region package.json
|
|
18676
|
-
var version = "0.
|
|
18680
|
+
var version = "0.43.0";
|
|
18677
18681
|
|
|
18678
18682
|
//#endregion
|
|
18679
18683
|
//#region src/managers/setup.ts
|
|
@@ -24137,9 +24141,10 @@ var WeaveRectangleToolAction = class extends WeaveAction {
|
|
|
24137
24141
|
this.initialized = false;
|
|
24138
24142
|
this.state = RECTANGLE_TOOL_STATE.IDLE;
|
|
24139
24143
|
this.rectId = null;
|
|
24140
|
-
this.
|
|
24144
|
+
this.tempRectNode = null;
|
|
24141
24145
|
this.moved = false;
|
|
24142
24146
|
this.container = void 0;
|
|
24147
|
+
this.measureContainer = void 0;
|
|
24143
24148
|
this.clickPoint = null;
|
|
24144
24149
|
this.props = this.initProps();
|
|
24145
24150
|
}
|
|
@@ -24178,10 +24183,7 @@ var WeaveRectangleToolAction = class extends WeaveAction {
|
|
|
24178
24183
|
this.state = RECTANGLE_TOOL_STATE.ADDING;
|
|
24179
24184
|
return;
|
|
24180
24185
|
}
|
|
24181
|
-
if (this.state === RECTANGLE_TOOL_STATE.ADDING)
|
|
24182
|
-
this.creating = true;
|
|
24183
|
-
this.handleAdding();
|
|
24184
|
-
}
|
|
24186
|
+
if (this.state === RECTANGLE_TOOL_STATE.ADDING) this.handleAdding();
|
|
24185
24187
|
});
|
|
24186
24188
|
stage.on("pointermove", (e) => {
|
|
24187
24189
|
if (!this.isPressed(e)) return;
|
|
@@ -24190,19 +24192,13 @@ var WeaveRectangleToolAction = class extends WeaveAction {
|
|
|
24190
24192
|
this.state = RECTANGLE_TOOL_STATE.ADDING;
|
|
24191
24193
|
return;
|
|
24192
24194
|
}
|
|
24193
|
-
if (this.state === RECTANGLE_TOOL_STATE.DEFINING_SIZE)
|
|
24194
|
-
this.moved = true;
|
|
24195
|
-
this.handleMovement();
|
|
24196
|
-
}
|
|
24195
|
+
if (this.state === RECTANGLE_TOOL_STATE.DEFINING_SIZE) this.handleMovement();
|
|
24197
24196
|
});
|
|
24198
24197
|
stage.on("pointerup", (e) => {
|
|
24199
24198
|
this.pointers.delete(e.evt.pointerId);
|
|
24200
24199
|
const isTap = this.isTap(e);
|
|
24201
24200
|
if (isTap) this.moved = false;
|
|
24202
|
-
if (this.state === RECTANGLE_TOOL_STATE.DEFINING_SIZE)
|
|
24203
|
-
this.creating = false;
|
|
24204
|
-
this.handleSettingSize();
|
|
24205
|
-
}
|
|
24201
|
+
if (this.state === RECTANGLE_TOOL_STATE.DEFINING_SIZE) this.handleSettingSize();
|
|
24206
24202
|
});
|
|
24207
24203
|
this.initialized = true;
|
|
24208
24204
|
}
|
|
@@ -24218,29 +24214,28 @@ var WeaveRectangleToolAction = class extends WeaveAction {
|
|
|
24218
24214
|
this.setState(RECTANGLE_TOOL_STATE.ADDING);
|
|
24219
24215
|
}
|
|
24220
24216
|
handleAdding() {
|
|
24221
|
-
const { mousePoint, container } = this.instance.getMousePointer();
|
|
24217
|
+
const { mousePoint, container, measureContainer } = this.instance.getMousePointer();
|
|
24222
24218
|
this.clickPoint = mousePoint;
|
|
24223
24219
|
this.container = container;
|
|
24220
|
+
this.measureContainer = measureContainer;
|
|
24224
24221
|
this.rectId = v4_default();
|
|
24225
|
-
|
|
24226
|
-
|
|
24227
|
-
const node = nodeHandler.create(this.rectId, {
|
|
24222
|
+
if (!this.tempRectNode) {
|
|
24223
|
+
this.tempRectNode = new konva.default.Rect({
|
|
24228
24224
|
...this.props,
|
|
24225
|
+
id: this.rectId,
|
|
24229
24226
|
strokeScaleEnabled: true,
|
|
24230
24227
|
x: this.clickPoint?.x ?? 0,
|
|
24231
24228
|
y: this.clickPoint?.y ?? 0,
|
|
24232
24229
|
width: 0,
|
|
24233
24230
|
height: 0
|
|
24234
24231
|
});
|
|
24235
|
-
this.
|
|
24232
|
+
this.measureContainer?.add(this.tempRectNode);
|
|
24236
24233
|
}
|
|
24237
24234
|
this.setState(RECTANGLE_TOOL_STATE.DEFINING_SIZE);
|
|
24238
24235
|
}
|
|
24239
24236
|
handleSettingSize() {
|
|
24240
|
-
|
|
24241
|
-
if (this.rectId && this.clickPoint && this.container && rectangle) {
|
|
24237
|
+
if (this.rectId && this.tempRectNode && this.clickPoint && this.container) {
|
|
24242
24238
|
const { mousePoint } = this.instance.getMousePointerRelativeToContainer(this.container);
|
|
24243
|
-
const nodeHandler = this.instance.getNodeHandler("rectangle");
|
|
24244
24239
|
const rectPos = {
|
|
24245
24240
|
x: this.clickPoint.x,
|
|
24246
24241
|
y: this.clickPoint.y
|
|
@@ -24253,31 +24248,38 @@ var WeaveRectangleToolAction = class extends WeaveAction {
|
|
|
24253
24248
|
rectWidth = Math.abs(this.clickPoint.x - mousePoint.x);
|
|
24254
24249
|
rectHeight = Math.abs(this.clickPoint.y - mousePoint.y);
|
|
24255
24250
|
}
|
|
24256
|
-
|
|
24251
|
+
this.tempRectNode.setAttrs({
|
|
24257
24252
|
...this.props,
|
|
24258
24253
|
x: rectPos.x,
|
|
24259
24254
|
y: rectPos.y,
|
|
24260
24255
|
width: rectWidth,
|
|
24261
24256
|
height: rectHeight
|
|
24262
24257
|
});
|
|
24263
|
-
|
|
24258
|
+
const nodeHandler = this.instance.getNodeHandler("rectangle");
|
|
24259
|
+
if (nodeHandler) {
|
|
24260
|
+
const clonedRectNode = this.tempRectNode.clone();
|
|
24261
|
+
this.tempRectNode.destroy();
|
|
24262
|
+
const node = nodeHandler.create(this.rectId, {
|
|
24263
|
+
...this.props,
|
|
24264
|
+
...clonedRectNode.getAttrs()
|
|
24265
|
+
});
|
|
24266
|
+
this.instance.addNode(node, this.container?.getAttrs().id);
|
|
24267
|
+
}
|
|
24264
24268
|
this.instance.emitEvent("onAddedRectangle");
|
|
24265
24269
|
}
|
|
24266
24270
|
this.cancelAction();
|
|
24267
24271
|
}
|
|
24268
24272
|
handleMovement() {
|
|
24269
24273
|
if (this.state !== RECTANGLE_TOOL_STATE.DEFINING_SIZE) return;
|
|
24270
|
-
|
|
24271
|
-
|
|
24272
|
-
const { mousePoint } = this.instance.getMousePointerRelativeToContainer(this.
|
|
24274
|
+
if (this.rectId && this.tempRectNode && this.measureContainer && this.clickPoint) {
|
|
24275
|
+
this.moved = true;
|
|
24276
|
+
const { mousePoint } = this.instance.getMousePointerRelativeToContainer(this.measureContainer);
|
|
24273
24277
|
const deltaX = mousePoint.x - this.clickPoint?.x;
|
|
24274
24278
|
const deltaY = mousePoint.y - this.clickPoint?.y;
|
|
24275
|
-
|
|
24276
|
-
rectangle.setAttrs({
|
|
24279
|
+
this.tempRectNode.setAttrs({
|
|
24277
24280
|
width: deltaX,
|
|
24278
24281
|
height: deltaY
|
|
24279
24282
|
});
|
|
24280
|
-
if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(rectangle));
|
|
24281
24283
|
}
|
|
24282
24284
|
}
|
|
24283
24285
|
trigger(cancelAction) {
|
|
@@ -24302,9 +24304,10 @@ var WeaveRectangleToolAction = class extends WeaveAction {
|
|
|
24302
24304
|
this.instance.triggerAction(SELECTION_TOOL_ACTION_NAME);
|
|
24303
24305
|
}
|
|
24304
24306
|
this.rectId = null;
|
|
24305
|
-
this.
|
|
24307
|
+
this.tempRectNode = null;
|
|
24306
24308
|
this.moved = false;
|
|
24307
24309
|
this.container = void 0;
|
|
24310
|
+
this.measureContainer = void 0;
|
|
24308
24311
|
this.clickPoint = null;
|
|
24309
24312
|
this.setState(RECTANGLE_TOOL_STATE.IDLE);
|
|
24310
24313
|
}
|
|
@@ -24540,6 +24543,8 @@ var WeavePenToolAction = class extends WeaveAction {
|
|
|
24540
24543
|
this.state = PEN_TOOL_STATE.IDLE;
|
|
24541
24544
|
this.lineId = null;
|
|
24542
24545
|
this.tempLineId = null;
|
|
24546
|
+
this.tempMainLineNode = null;
|
|
24547
|
+
this.tempLineNode = null;
|
|
24543
24548
|
this.container = void 0;
|
|
24544
24549
|
this.measureContainer = void 0;
|
|
24545
24550
|
this.clickPoint = null;
|
|
@@ -24579,11 +24584,10 @@ var WeavePenToolAction = class extends WeaveAction {
|
|
|
24579
24584
|
this.state = PEN_TOOL_STATE.ADDING;
|
|
24580
24585
|
return;
|
|
24581
24586
|
}
|
|
24582
|
-
if (this.state === PEN_TOOL_STATE.ADDING) this.handleAdding();
|
|
24587
|
+
if (!this.tempMainLineNode && this.state === PEN_TOOL_STATE.ADDING) this.handleAdding();
|
|
24588
|
+
if (this.tempMainLineNode && this.state === PEN_TOOL_STATE.ADDING) this.state = PEN_TOOL_STATE.DEFINING_SIZE;
|
|
24583
24589
|
});
|
|
24584
|
-
stage.on("pointermove", (
|
|
24585
|
-
if (!this.isPressed(e)) return;
|
|
24586
|
-
if (!this.pointers.has(e.evt.pointerId)) return;
|
|
24590
|
+
stage.on("pointermove", () => {
|
|
24587
24591
|
if (this.pointers.size === 2 && this.instance.getActiveAction() === PEN_TOOL_ACTION_NAME) {
|
|
24588
24592
|
this.state = PEN_TOOL_STATE.ADDING;
|
|
24589
24593
|
return;
|
|
@@ -24602,6 +24606,8 @@ var WeavePenToolAction = class extends WeaveAction {
|
|
|
24602
24606
|
addLine() {
|
|
24603
24607
|
const stage = this.instance.getStage();
|
|
24604
24608
|
stage.container().style.cursor = "crosshair";
|
|
24609
|
+
stage.container().focus();
|
|
24610
|
+
this.instance.emitEvent("onAddingPen");
|
|
24605
24611
|
this.tempPoint = void 0;
|
|
24606
24612
|
this.tempNextPoint = void 0;
|
|
24607
24613
|
this.clickPoint = null;
|
|
@@ -24615,63 +24621,58 @@ var WeavePenToolAction = class extends WeaveAction {
|
|
|
24615
24621
|
this.measureContainer = measureContainer;
|
|
24616
24622
|
this.lineId = v4_default();
|
|
24617
24623
|
this.tempLineId = v4_default();
|
|
24618
|
-
|
|
24619
|
-
|
|
24620
|
-
const node = nodeHandler.create(this.lineId, {
|
|
24624
|
+
if (!this.tempLineNode) {
|
|
24625
|
+
this.tempMainLineNode = new konva.default.Line({
|
|
24621
24626
|
...this.props,
|
|
24627
|
+
id: this.lineId,
|
|
24622
24628
|
strokeScaleEnabled: true,
|
|
24623
24629
|
x: this.clickPoint?.x ?? 0,
|
|
24624
24630
|
y: this.clickPoint?.y ?? 0,
|
|
24625
24631
|
points: [0, 0]
|
|
24626
24632
|
});
|
|
24627
|
-
this.
|
|
24628
|
-
|
|
24629
|
-
|
|
24630
|
-
|
|
24631
|
-
|
|
24632
|
-
|
|
24633
|
-
|
|
24634
|
-
|
|
24635
|
-
|
|
24636
|
-
|
|
24637
|
-
|
|
24638
|
-
|
|
24639
|
-
if (nodeHandler) {
|
|
24640
|
-
const tempLine = nodeHandler.create(this.tempLineId, {
|
|
24633
|
+
this.measureContainer?.add(this.tempMainLineNode);
|
|
24634
|
+
this.tempPoint = new konva.default.Circle({
|
|
24635
|
+
x: this.clickPoint?.x ?? 0,
|
|
24636
|
+
y: this.clickPoint?.y ?? 0,
|
|
24637
|
+
radius: 5 / stage.scaleX(),
|
|
24638
|
+
strokeScaleEnabled: true,
|
|
24639
|
+
stroke: "#cccccc",
|
|
24640
|
+
strokeWidth: 0,
|
|
24641
|
+
fill: "#cccccc"
|
|
24642
|
+
});
|
|
24643
|
+
this.measureContainer?.add(this.tempPoint);
|
|
24644
|
+
this.tempLineNode = new konva.default.Line({
|
|
24641
24645
|
...this.props,
|
|
24646
|
+
id: this.tempLineId,
|
|
24642
24647
|
x: this.clickPoint?.x ?? 0,
|
|
24643
24648
|
y: this.clickPoint?.y ?? 0,
|
|
24644
24649
|
strokeScaleEnabled: true,
|
|
24645
24650
|
points: [0, 0]
|
|
24646
24651
|
});
|
|
24647
|
-
this.
|
|
24652
|
+
this.measureContainer?.add(this.tempLineNode);
|
|
24653
|
+
this.tempNextPoint = new konva.default.Circle({
|
|
24654
|
+
x: this.clickPoint?.x ?? 0,
|
|
24655
|
+
y: this.clickPoint?.y ?? 0,
|
|
24656
|
+
radius: 5 / stage.scaleX(),
|
|
24657
|
+
strokeScaleEnabled: true,
|
|
24658
|
+
stroke: "#cccccc",
|
|
24659
|
+
strokeWidth: 0,
|
|
24660
|
+
fill: "#cccccc"
|
|
24661
|
+
});
|
|
24662
|
+
this.measureContainer?.add(this.tempNextPoint);
|
|
24663
|
+
this.setState(PEN_TOOL_STATE.DEFINING_SIZE);
|
|
24648
24664
|
}
|
|
24649
|
-
this.tempNextPoint = new konva.default.Circle({
|
|
24650
|
-
x: this.clickPoint?.x ?? 0,
|
|
24651
|
-
y: this.clickPoint?.y ?? 0,
|
|
24652
|
-
radius: 5 / stage.scaleX(),
|
|
24653
|
-
strokeScaleEnabled: true,
|
|
24654
|
-
stroke: "#cccccc",
|
|
24655
|
-
strokeWidth: 0,
|
|
24656
|
-
fill: "#cccccc"
|
|
24657
|
-
});
|
|
24658
|
-
this.measureContainer?.add(this.tempNextPoint);
|
|
24659
|
-
this.setState(PEN_TOOL_STATE.DEFINING_SIZE);
|
|
24660
24665
|
}
|
|
24661
24666
|
handleSettingSize() {
|
|
24662
|
-
|
|
24663
|
-
const tempMainLine = this.instance.getStage().findOne(`#${this.lineId}`);
|
|
24664
|
-
if (this.lineId && this.tempPoint && this.tempNextPoint && this.measureContainer && tempMainLine && tempLine) {
|
|
24667
|
+
if (this.lineId && this.tempLineNode && this.tempMainLineNode && this.tempPoint && this.tempNextPoint && this.measureContainer) {
|
|
24665
24668
|
const { mousePoint } = this.instance.getMousePointerRelativeToContainer(this.measureContainer);
|
|
24666
|
-
const newPoints = [...
|
|
24667
|
-
newPoints.push(mousePoint.x -
|
|
24668
|
-
newPoints.push(mousePoint.y -
|
|
24669
|
-
|
|
24669
|
+
const newPoints = [...this.tempMainLineNode.points()];
|
|
24670
|
+
newPoints.push(mousePoint.x - this.tempMainLineNode.x());
|
|
24671
|
+
newPoints.push(mousePoint.y - this.tempMainLineNode.y());
|
|
24672
|
+
this.tempMainLineNode.setAttrs({
|
|
24670
24673
|
...this.props,
|
|
24671
24674
|
points: newPoints
|
|
24672
24675
|
});
|
|
24673
|
-
const nodeHandler = this.instance.getNodeHandler("line");
|
|
24674
|
-
if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(tempMainLine));
|
|
24675
24676
|
this.tempPoint.setAttrs({
|
|
24676
24677
|
x: mousePoint.x,
|
|
24677
24678
|
y: mousePoint.y
|
|
@@ -24680,32 +24681,28 @@ var WeavePenToolAction = class extends WeaveAction {
|
|
|
24680
24681
|
x: mousePoint.x,
|
|
24681
24682
|
y: mousePoint.y
|
|
24682
24683
|
});
|
|
24683
|
-
|
|
24684
|
+
this.tempLineNode.setAttrs({
|
|
24684
24685
|
...this.props,
|
|
24685
24686
|
x: mousePoint.x,
|
|
24686
24687
|
y: mousePoint.y,
|
|
24687
24688
|
points: [0, 0]
|
|
24688
24689
|
});
|
|
24689
|
-
|
|
24690
|
+
this.setState(PEN_TOOL_STATE.DEFINING_SIZE);
|
|
24690
24691
|
}
|
|
24691
|
-
this.setState(PEN_TOOL_STATE.DEFINING_SIZE);
|
|
24692
24692
|
}
|
|
24693
24693
|
handleMovement() {
|
|
24694
24694
|
if (this.state !== PEN_TOOL_STATE.DEFINING_SIZE) return;
|
|
24695
|
-
|
|
24696
|
-
if (this.lineId && this.measureContainer && this.tempNextPoint && tempLine) {
|
|
24695
|
+
if (this.tempLineNode && this.measureContainer && this.tempNextPoint) {
|
|
24697
24696
|
const { mousePoint } = this.instance.getMousePointerRelativeToContainer(this.measureContainer);
|
|
24698
|
-
|
|
24697
|
+
this.tempLineNode.setAttrs({
|
|
24699
24698
|
...this.props,
|
|
24700
24699
|
points: [
|
|
24701
|
-
|
|
24702
|
-
|
|
24703
|
-
mousePoint.x -
|
|
24704
|
-
mousePoint.y -
|
|
24700
|
+
this.tempLineNode.points()[0],
|
|
24701
|
+
this.tempLineNode.points()[1],
|
|
24702
|
+
mousePoint.x - this.tempLineNode.x(),
|
|
24703
|
+
mousePoint.y - this.tempLineNode.y()
|
|
24705
24704
|
]
|
|
24706
24705
|
});
|
|
24707
|
-
const nodeHandler = this.instance.getNodeHandler("line");
|
|
24708
|
-
if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(tempLine));
|
|
24709
24706
|
this.tempNextPoint.setAttrs({
|
|
24710
24707
|
x: mousePoint.x,
|
|
24711
24708
|
y: mousePoint.y
|
|
@@ -24728,24 +24725,20 @@ var WeavePenToolAction = class extends WeaveAction {
|
|
|
24728
24725
|
const stage = this.instance.getStage();
|
|
24729
24726
|
this.tempPoint?.destroy();
|
|
24730
24727
|
this.tempNextPoint?.destroy();
|
|
24731
|
-
|
|
24732
|
-
|
|
24733
|
-
if (tempLine) {
|
|
24728
|
+
this.tempLineNode?.destroy();
|
|
24729
|
+
if (this.lineId && this.tempMainLineNode && this.tempMainLineNode.points().length >= 4) {
|
|
24734
24730
|
const nodeHandler = this.instance.getNodeHandler("line");
|
|
24735
|
-
if (nodeHandler)
|
|
24736
|
-
|
|
24737
|
-
|
|
24738
|
-
|
|
24739
|
-
|
|
24740
|
-
|
|
24741
|
-
|
|
24742
|
-
|
|
24743
|
-
|
|
24744
|
-
|
|
24745
|
-
|
|
24746
|
-
hitStrokeWidth: 16
|
|
24747
|
-
});
|
|
24748
|
-
if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(tempMainLine));
|
|
24731
|
+
if (nodeHandler) {
|
|
24732
|
+
const clonedLine = this.tempMainLineNode.clone();
|
|
24733
|
+
this.tempMainLineNode.destroy();
|
|
24734
|
+
const node = nodeHandler.create(this.lineId, {
|
|
24735
|
+
...this.props,
|
|
24736
|
+
...clonedLine.getAttrs(),
|
|
24737
|
+
hitStrokeWidth: 16
|
|
24738
|
+
});
|
|
24739
|
+
this.instance.addNode(node, this.container?.getAttrs().id);
|
|
24740
|
+
this.instance.emitEvent("onAddedPen");
|
|
24741
|
+
}
|
|
24749
24742
|
}
|
|
24750
24743
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
24751
24744
|
if (selectionPlugin) {
|
|
@@ -24758,8 +24751,11 @@ var WeavePenToolAction = class extends WeaveAction {
|
|
|
24758
24751
|
this.tempPoint = void 0;
|
|
24759
24752
|
this.tempNextPoint = void 0;
|
|
24760
24753
|
this.lineId = null;
|
|
24754
|
+
this.tempMainLineNode = null;
|
|
24761
24755
|
this.tempLineId = null;
|
|
24756
|
+
this.tempLineNode = null;
|
|
24762
24757
|
this.container = void 0;
|
|
24758
|
+
this.measureContainer = void 0;
|
|
24763
24759
|
this.clickPoint = null;
|
|
24764
24760
|
this.setState(PEN_TOOL_STATE.IDLE);
|
|
24765
24761
|
}
|
|
@@ -24962,11 +24958,13 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
24962
24958
|
if (selectionPlugin) selectionPlugin.setSelectedNodes([]);
|
|
24963
24959
|
this.props = this.initProps();
|
|
24964
24960
|
this.setState(BRUSH_TOOL_STATE.IDLE);
|
|
24961
|
+
this.instance.emitEvent("onAddingBrush");
|
|
24965
24962
|
stage.container().style.cursor = "crosshair";
|
|
24966
24963
|
}
|
|
24967
24964
|
cleanup() {
|
|
24968
24965
|
const stage = this.instance.getStage();
|
|
24969
24966
|
stage.container().style.cursor = "default";
|
|
24967
|
+
this.instance.emitEvent("onAddedBrush");
|
|
24970
24968
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
24971
24969
|
if (selectionPlugin) {
|
|
24972
24970
|
const node = stage.findOne(`#${this.strokeId}`);
|
|
@@ -25037,6 +25035,8 @@ var WeaveTextToolAction = class extends WeaveAction {
|
|
|
25037
25035
|
tr.hide();
|
|
25038
25036
|
}
|
|
25039
25037
|
stage.container().style.cursor = "crosshair";
|
|
25038
|
+
stage.container().focus();
|
|
25039
|
+
this.instance.emitEvent("onAddingText");
|
|
25040
25040
|
this.clickPoint = null;
|
|
25041
25041
|
this.setState(TEXT_TOOL_STATE.ADDING);
|
|
25042
25042
|
}
|
|
@@ -25054,6 +25054,7 @@ var WeaveTextToolAction = class extends WeaveAction {
|
|
|
25054
25054
|
draggable: true
|
|
25055
25055
|
});
|
|
25056
25056
|
this.instance.addNode(node, this.container?.getAttrs().id);
|
|
25057
|
+
this.instance.emitEvent("onAddedArrow");
|
|
25057
25058
|
}
|
|
25058
25059
|
this.setState(TEXT_TOOL_STATE.FINISHED);
|
|
25059
25060
|
this.cancelAction();
|
|
@@ -25313,10 +25314,13 @@ var WeaveArrowToolAction = class extends WeaveAction {
|
|
|
25313
25314
|
onInit = void 0;
|
|
25314
25315
|
constructor() {
|
|
25315
25316
|
super();
|
|
25317
|
+
this.pointers = new Map();
|
|
25316
25318
|
this.initialized = false;
|
|
25317
25319
|
this.state = ARROW_TOOL_STATE.IDLE;
|
|
25318
25320
|
this.arrowId = null;
|
|
25319
25321
|
this.tempArrowId = null;
|
|
25322
|
+
this.tempMainArrowNode = null;
|
|
25323
|
+
this.tempArrowNode = null;
|
|
25320
25324
|
this.container = void 0;
|
|
25321
25325
|
this.measureContainer = void 0;
|
|
25322
25326
|
this.clickPoint = null;
|
|
@@ -25351,22 +25355,29 @@ var WeaveArrowToolAction = class extends WeaveAction {
|
|
|
25351
25355
|
return;
|
|
25352
25356
|
}
|
|
25353
25357
|
});
|
|
25354
|
-
stage.on("
|
|
25355
|
-
this.
|
|
25356
|
-
|
|
25357
|
-
|
|
25358
|
-
|
|
25359
|
-
|
|
25360
|
-
|
|
25358
|
+
stage.on("pointerdown", (e) => {
|
|
25359
|
+
this.setTapStart(e);
|
|
25360
|
+
this.pointers.set(e.evt.pointerId, {
|
|
25361
|
+
x: e.evt.clientX,
|
|
25362
|
+
y: e.evt.clientY
|
|
25363
|
+
});
|
|
25364
|
+
if (this.pointers.size === 2 && this.instance.getActiveAction() === ARROW_TOOL_ACTION_NAME) {
|
|
25365
|
+
this.state = ARROW_TOOL_STATE.ADDING;
|
|
25361
25366
|
return;
|
|
25362
25367
|
}
|
|
25363
|
-
if (this.state === ARROW_TOOL_STATE.
|
|
25364
|
-
|
|
25368
|
+
if (!this.tempMainArrowNode && this.state === ARROW_TOOL_STATE.ADDING) this.handleAdding();
|
|
25369
|
+
if (this.tempMainArrowNode && this.state === ARROW_TOOL_STATE.ADDING) this.state = ARROW_TOOL_STATE.DEFINING_SIZE;
|
|
25370
|
+
});
|
|
25371
|
+
stage.on("pointermove", () => {
|
|
25372
|
+
if (this.pointers.size === 2 && this.instance.getActiveAction() === ARROW_TOOL_ACTION_NAME) {
|
|
25373
|
+
this.state = ARROW_TOOL_STATE.ADDING;
|
|
25365
25374
|
return;
|
|
25366
25375
|
}
|
|
25376
|
+
if (this.state === ARROW_TOOL_STATE.DEFINING_SIZE) this.handleMovement();
|
|
25367
25377
|
});
|
|
25368
|
-
stage.on("
|
|
25369
|
-
this.
|
|
25378
|
+
stage.on("pointerup", (e) => {
|
|
25379
|
+
this.pointers.delete(e.evt.pointerId);
|
|
25380
|
+
if (this.state === ARROW_TOOL_STATE.DEFINING_SIZE) this.handleSettingSize();
|
|
25370
25381
|
});
|
|
25371
25382
|
this.initialized = true;
|
|
25372
25383
|
}
|
|
@@ -25376,6 +25387,8 @@ var WeaveArrowToolAction = class extends WeaveAction {
|
|
|
25376
25387
|
addArrow() {
|
|
25377
25388
|
const stage = this.instance.getStage();
|
|
25378
25389
|
stage.container().style.cursor = "crosshair";
|
|
25390
|
+
stage.container().focus();
|
|
25391
|
+
this.instance.emitEvent("onAddingArrow");
|
|
25379
25392
|
this.tempPoint = void 0;
|
|
25380
25393
|
this.tempNextPoint = void 0;
|
|
25381
25394
|
this.clickPoint = null;
|
|
@@ -25389,65 +25402,58 @@ var WeaveArrowToolAction = class extends WeaveAction {
|
|
|
25389
25402
|
this.measureContainer = measureContainer;
|
|
25390
25403
|
this.arrowId = v4_default();
|
|
25391
25404
|
this.tempArrowId = v4_default();
|
|
25392
|
-
|
|
25393
|
-
|
|
25394
|
-
if (lineNodeHandler) {
|
|
25395
|
-
const node = lineNodeHandler.create(this.arrowId, {
|
|
25405
|
+
if (!this.tempMainArrowNode) {
|
|
25406
|
+
this.tempMainArrowNode = new konva.default.Line({
|
|
25396
25407
|
...this.props,
|
|
25408
|
+
id: this.arrowId,
|
|
25397
25409
|
strokeScaleEnabled: true,
|
|
25398
25410
|
x: this.clickPoint?.x ?? 0,
|
|
25399
25411
|
y: this.clickPoint?.y ?? 0,
|
|
25400
25412
|
points: [0, 0]
|
|
25401
25413
|
});
|
|
25402
|
-
this.
|
|
25403
|
-
|
|
25404
|
-
this.tempPoint = new konva.default.Circle({
|
|
25405
|
-
x: this.clickPoint?.x ?? 0,
|
|
25406
|
-
y: this.clickPoint?.y ?? 0,
|
|
25407
|
-
radius: 5 / stage.scaleX(),
|
|
25408
|
-
strokeScaleEnabled: true,
|
|
25409
|
-
stroke: "#cccccc",
|
|
25410
|
-
strokeWidth: 0,
|
|
25411
|
-
fill: "#cccccc"
|
|
25412
|
-
});
|
|
25413
|
-
this.measureContainer?.add(this.tempPoint);
|
|
25414
|
-
if (nodeHandler) {
|
|
25415
|
-
const tempArrow = nodeHandler.create(this.tempArrowId, {
|
|
25416
|
-
...this.props,
|
|
25414
|
+
this.measureContainer?.add(this.tempMainArrowNode);
|
|
25415
|
+
this.tempPoint = new konva.default.Circle({
|
|
25417
25416
|
x: this.clickPoint?.x ?? 0,
|
|
25418
25417
|
y: this.clickPoint?.y ?? 0,
|
|
25418
|
+
radius: 5 / stage.scaleX(),
|
|
25419
25419
|
strokeScaleEnabled: true,
|
|
25420
|
+
stroke: "#cccccc",
|
|
25421
|
+
strokeWidth: 0,
|
|
25422
|
+
fill: "#cccccc"
|
|
25423
|
+
});
|
|
25424
|
+
this.measureContainer?.add(this.tempPoint);
|
|
25425
|
+
this.tempArrowNode = new konva.default.Arrow({
|
|
25426
|
+
...this.props,
|
|
25427
|
+
id: this.tempArrowId,
|
|
25428
|
+
strokeScaleEnabled: true,
|
|
25429
|
+
x: this.clickPoint?.x ?? 0,
|
|
25430
|
+
y: this.clickPoint?.y ?? 0,
|
|
25420
25431
|
points: [0, 0]
|
|
25421
25432
|
});
|
|
25422
|
-
this.
|
|
25433
|
+
this.measureContainer?.add(this.tempArrowNode);
|
|
25434
|
+
this.tempNextPoint = new konva.default.Circle({
|
|
25435
|
+
x: this.clickPoint?.x ?? 0,
|
|
25436
|
+
y: this.clickPoint?.y ?? 0,
|
|
25437
|
+
radius: 5 / stage.scaleX(),
|
|
25438
|
+
strokeScaleEnabled: true,
|
|
25439
|
+
stroke: "#cccccc",
|
|
25440
|
+
strokeWidth: 0,
|
|
25441
|
+
fill: "#cccccc"
|
|
25442
|
+
});
|
|
25443
|
+
this.measureContainer?.add(this.tempNextPoint);
|
|
25444
|
+
this.setState(ARROW_TOOL_STATE.DEFINING_SIZE);
|
|
25423
25445
|
}
|
|
25424
|
-
this.tempNextPoint = new konva.default.Circle({
|
|
25425
|
-
x: this.clickPoint?.x ?? 0,
|
|
25426
|
-
y: this.clickPoint?.y ?? 0,
|
|
25427
|
-
radius: 5 / stage.scaleX(),
|
|
25428
|
-
strokeScaleEnabled: true,
|
|
25429
|
-
stroke: "#cccccc",
|
|
25430
|
-
strokeWidth: 0,
|
|
25431
|
-
fill: "#cccccc"
|
|
25432
|
-
});
|
|
25433
|
-
this.measureContainer?.add(this.tempNextPoint);
|
|
25434
|
-
this.setState(ARROW_TOOL_STATE.DEFINING_SIZE);
|
|
25435
25446
|
}
|
|
25436
25447
|
handleSettingSize() {
|
|
25437
|
-
|
|
25438
|
-
const tempMainArrow = this.instance.getStage().findOne(`#${this.arrowId}`);
|
|
25439
|
-
if (this.arrowId && this.tempPoint && this.tempNextPoint && this.measureContainer && tempMainArrow && tempArrow) {
|
|
25448
|
+
if (this.arrowId && this.tempMainArrowNode && this.tempArrowNode && this.tempPoint && this.tempNextPoint && this.measureContainer) {
|
|
25440
25449
|
const { mousePoint } = this.instance.getMousePointerRelativeToContainer(this.measureContainer);
|
|
25441
|
-
const newPoints = [...
|
|
25442
|
-
newPoints.push(mousePoint.x -
|
|
25443
|
-
newPoints.push(mousePoint.y -
|
|
25444
|
-
|
|
25450
|
+
const newPoints = [...this.tempMainArrowNode.points()];
|
|
25451
|
+
newPoints.push(mousePoint.x - this.tempMainArrowNode.x());
|
|
25452
|
+
newPoints.push(mousePoint.y - this.tempMainArrowNode.y());
|
|
25453
|
+
this.tempMainArrowNode.setAttrs({
|
|
25445
25454
|
...this.props,
|
|
25446
25455
|
points: newPoints
|
|
25447
25456
|
});
|
|
25448
|
-
const nodeHandler = this.instance.getNodeHandler("arrow");
|
|
25449
|
-
const lineNodeHandler = this.instance.getNodeHandler("line");
|
|
25450
|
-
if (lineNodeHandler) this.instance.updateNode(lineNodeHandler.serialize(tempMainArrow));
|
|
25451
25457
|
this.tempPoint.setAttrs({
|
|
25452
25458
|
x: mousePoint.x,
|
|
25453
25459
|
y: mousePoint.y
|
|
@@ -25456,32 +25462,28 @@ var WeaveArrowToolAction = class extends WeaveAction {
|
|
|
25456
25462
|
x: mousePoint.x,
|
|
25457
25463
|
y: mousePoint.y
|
|
25458
25464
|
});
|
|
25459
|
-
|
|
25465
|
+
this.tempArrowNode.setAttrs({
|
|
25460
25466
|
...this.props,
|
|
25461
25467
|
x: mousePoint.x,
|
|
25462
25468
|
y: mousePoint.y,
|
|
25463
25469
|
points: [0, 0]
|
|
25464
25470
|
});
|
|
25465
|
-
|
|
25471
|
+
this.setState(ARROW_TOOL_STATE.DEFINING_SIZE);
|
|
25466
25472
|
}
|
|
25467
|
-
this.setState(ARROW_TOOL_STATE.DEFINING_SIZE);
|
|
25468
25473
|
}
|
|
25469
25474
|
handleMovement() {
|
|
25470
25475
|
if (this.state !== ARROW_TOOL_STATE.DEFINING_SIZE) return;
|
|
25471
|
-
|
|
25472
|
-
if (this.arrowId && this.measureContainer && this.tempNextPoint && tempArrow) {
|
|
25476
|
+
if (this.arrowId && this.tempArrowNode && this.measureContainer && this.tempNextPoint) {
|
|
25473
25477
|
const { mousePoint } = this.instance.getMousePointerRelativeToContainer(this.measureContainer);
|
|
25474
|
-
|
|
25478
|
+
this.tempArrowNode.setAttrs({
|
|
25475
25479
|
...this.props,
|
|
25476
25480
|
points: [
|
|
25477
|
-
|
|
25478
|
-
|
|
25479
|
-
mousePoint.x -
|
|
25480
|
-
mousePoint.y -
|
|
25481
|
+
this.tempArrowNode.points()[0],
|
|
25482
|
+
this.tempArrowNode.points()[1],
|
|
25483
|
+
mousePoint.x - this.tempArrowNode.x(),
|
|
25484
|
+
mousePoint.y - this.tempArrowNode.y()
|
|
25481
25485
|
]
|
|
25482
25486
|
});
|
|
25483
|
-
const nodeHandler = this.instance.getNodeHandler("arrow");
|
|
25484
|
-
if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(tempArrow));
|
|
25485
25487
|
this.tempNextPoint.setAttrs({
|
|
25486
25488
|
x: mousePoint.x,
|
|
25487
25489
|
y: mousePoint.y
|
|
@@ -25504,29 +25506,19 @@ var WeaveArrowToolAction = class extends WeaveAction {
|
|
|
25504
25506
|
const stage = this.instance.getStage();
|
|
25505
25507
|
this.tempPoint?.destroy();
|
|
25506
25508
|
this.tempNextPoint?.destroy();
|
|
25507
|
-
|
|
25508
|
-
|
|
25509
|
-
if (tempArrow) {
|
|
25509
|
+
this.tempArrowNode?.destroy();
|
|
25510
|
+
if (this.arrowId && this.tempMainArrowNode && this.tempMainArrowNode.points().length >= 4) {
|
|
25510
25511
|
const nodeHandler = this.instance.getNodeHandler("arrow");
|
|
25511
|
-
if (nodeHandler)
|
|
25512
|
-
|
|
25513
|
-
|
|
25514
|
-
const nodeHandler = this.instance.getNodeHandler("line");
|
|
25515
|
-
if (nodeHandler) this.instance.removeNode(nodeHandler.serialize(tempMainArrow));
|
|
25516
|
-
}
|
|
25517
|
-
if (this.arrowId && tempMainArrow && tempMainArrow.points().length >= 4) {
|
|
25518
|
-
const nodeHandler = this.instance.getNodeHandler("arrow");
|
|
25519
|
-
const lineNodeHandler = this.instance.getNodeHandler("line");
|
|
25520
|
-
if (nodeHandler && lineNodeHandler) {
|
|
25512
|
+
if (nodeHandler) {
|
|
25513
|
+
const clonedLine = this.tempMainArrowNode.clone();
|
|
25514
|
+
this.tempMainArrowNode.destroy();
|
|
25521
25515
|
const finalArrow = nodeHandler.create(this.arrowId, {
|
|
25522
|
-
...tempMainArrow.getAttrs(),
|
|
25523
25516
|
...this.props,
|
|
25524
|
-
|
|
25525
|
-
strokeWidth: 1,
|
|
25517
|
+
...clonedLine.getAttrs(),
|
|
25526
25518
|
hitStrokeWidth: 16
|
|
25527
25519
|
});
|
|
25528
|
-
this.instance.removeNode(lineNodeHandler.serialize(tempMainArrow));
|
|
25529
25520
|
this.instance.addNode(finalArrow, this.container?.getAttrs().id);
|
|
25521
|
+
this.instance.emitEvent("onAddedArrow");
|
|
25530
25522
|
}
|
|
25531
25523
|
}
|
|
25532
25524
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
@@ -25541,7 +25533,10 @@ var WeaveArrowToolAction = class extends WeaveAction {
|
|
|
25541
25533
|
this.tempNextPoint = void 0;
|
|
25542
25534
|
this.arrowId = null;
|
|
25543
25535
|
this.tempArrowId = null;
|
|
25536
|
+
this.tempMainArrowNode = null;
|
|
25537
|
+
this.tempArrowNode = null;
|
|
25544
25538
|
this.container = void 0;
|
|
25539
|
+
this.measureContainer = void 0;
|
|
25545
25540
|
this.clickPoint = null;
|
|
25546
25541
|
this.setState(ARROW_TOOL_STATE.IDLE);
|
|
25547
25542
|
}
|
|
@@ -25803,6 +25798,7 @@ var WeaveFrameToolAction = class extends WeaveAction {
|
|
|
25803
25798
|
const stage = this.instance.getStage();
|
|
25804
25799
|
stage.container().style.cursor = "crosshair";
|
|
25805
25800
|
stage.container().focus();
|
|
25801
|
+
this.instance.emitEvent("onAddingFrame");
|
|
25806
25802
|
this.frameId = null;
|
|
25807
25803
|
this.clickPoint = null;
|
|
25808
25804
|
this.setState(FRAME_TOOL_STATE.ADDING);
|
|
@@ -25824,6 +25820,7 @@ var WeaveFrameToolAction = class extends WeaveAction {
|
|
|
25824
25820
|
y: this.clickPoint.y
|
|
25825
25821
|
});
|
|
25826
25822
|
this.instance.addNode(node, this.container?.getAttrs().id);
|
|
25823
|
+
this.instance.emitEvent("onAddedFrame");
|
|
25827
25824
|
}
|
|
25828
25825
|
this.cancelAction?.();
|
|
25829
25826
|
}
|