@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.js
CHANGED
|
@@ -15494,7 +15494,6 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
|
|
|
15494
15494
|
} else root._ = _;
|
|
15495
15495
|
}).call(exports);
|
|
15496
15496
|
} });
|
|
15497
|
-
var import_lodash$1 = __toESM(require_lodash());
|
|
15498
15497
|
var import_lodash = __toESM(require_lodash(), 1);
|
|
15499
15498
|
|
|
15500
15499
|
//#endregion
|
|
@@ -15589,12 +15588,12 @@ var WeaveStore = class {
|
|
|
15589
15588
|
node: JSON.parse(JSON.stringify(nodeInfo.node))
|
|
15590
15589
|
});
|
|
15591
15590
|
}
|
|
15592
|
-
if (!this.isRoomLoaded && !(0, import_lodash
|
|
15591
|
+
if (!this.isRoomLoaded && !(0, import_lodash.isEmpty)(this.state.weave)) {
|
|
15593
15592
|
this.instance.setupRenderer();
|
|
15594
15593
|
this.isRoomLoaded = true;
|
|
15595
15594
|
this.instance.emitEvent("onRoomLoaded", this.isRoomLoaded);
|
|
15596
15595
|
}
|
|
15597
|
-
if (this.isRoomLoaded && !(0, import_lodash
|
|
15596
|
+
if (this.isRoomLoaded && !(0, import_lodash.isEmpty)(this.state.weave)) this.instance.render();
|
|
15598
15597
|
});
|
|
15599
15598
|
}
|
|
15600
15599
|
canUndoStateStep() {
|
|
@@ -16092,7 +16091,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
16092
16091
|
if (moved) this.getContextMenuPlugin()?.cancelLongPressTimer();
|
|
16093
16092
|
this.triggerSelectedNodesEvent();
|
|
16094
16093
|
};
|
|
16095
|
-
tr.on("transform", (0, import_lodash
|
|
16094
|
+
tr.on("transform", (0, import_lodash.throttle)(handleTransform, 50));
|
|
16096
16095
|
tr.on("transformend", () => {
|
|
16097
16096
|
this.triggerSelectedNodesEvent();
|
|
16098
16097
|
});
|
|
@@ -16964,7 +16963,7 @@ var WeaveNode = class {
|
|
|
16964
16963
|
if (nodesSnappingPlugin && transforming && this.isSelecting() && this.isNodeSelected(node$1)) nodesSnappingPlugin.evaluateGuidelines(e);
|
|
16965
16964
|
if (this.isSelecting() && this.isNodeSelected(node$1)) this.scaleReset(node$1);
|
|
16966
16965
|
};
|
|
16967
|
-
node.on("transform", (0, import_lodash
|
|
16966
|
+
node.on("transform", (0, import_lodash.throttle)(handleTransform, 100));
|
|
16968
16967
|
node.on("transformend", (e) => {
|
|
16969
16968
|
const node$1 = e.target;
|
|
16970
16969
|
this.instance.emitEvent("onTransform", null);
|
|
@@ -17017,7 +17016,7 @@ var WeaveNode = class {
|
|
|
17017
17016
|
if (layerToMove) layerToMove.fire(WEAVE_NODE_CUSTOM_EVENTS.onTargetEnter, { bubbles: true });
|
|
17018
17017
|
}
|
|
17019
17018
|
};
|
|
17020
|
-
node.on("dragmove", (0, import_lodash
|
|
17019
|
+
node.on("dragmove", (0, import_lodash.throttle)(handleDragMove, 100));
|
|
17021
17020
|
node.on("dragend", (e) => {
|
|
17022
17021
|
if (!this.didMove) return;
|
|
17023
17022
|
const isErasing = this.instance.getActiveAction() === "eraseTool";
|
|
@@ -18451,6 +18450,7 @@ var WeaveStateManager = class {
|
|
|
18451
18450
|
return;
|
|
18452
18451
|
}
|
|
18453
18452
|
const doc = getYjsDoc(state);
|
|
18453
|
+
const userId = this.instance.getStore().getUser().id;
|
|
18454
18454
|
doc.transact(() => {
|
|
18455
18455
|
if (!parent.props.children) parent.props.children = [];
|
|
18456
18456
|
if (index) {
|
|
@@ -18469,7 +18469,7 @@ var WeaveStateManager = class {
|
|
|
18469
18469
|
parent.props.children.push(nodeToAdd);
|
|
18470
18470
|
}
|
|
18471
18471
|
this.instance.emitEvent("onNodeAdded", node);
|
|
18472
|
-
});
|
|
18472
|
+
}, userId);
|
|
18473
18473
|
}
|
|
18474
18474
|
deepSyncSyncedStore(target, source) {
|
|
18475
18475
|
for (const key in target) if (!(key in source)) delete target[key];
|
|
@@ -18513,9 +18513,10 @@ var WeaveStateManager = class {
|
|
|
18513
18513
|
return;
|
|
18514
18514
|
}
|
|
18515
18515
|
const doc = getYjsDoc(state);
|
|
18516
|
+
const userId = this.instance.getStore().getUser().id;
|
|
18516
18517
|
doc.transact(() => {
|
|
18517
18518
|
this.deepSyncSyncedStore(nodeState.props, node.props);
|
|
18518
|
-
});
|
|
18519
|
+
}, userId);
|
|
18519
18520
|
this.instance.emitEvent("onNodeUpdated", node);
|
|
18520
18521
|
}
|
|
18521
18522
|
removeNode(node) {
|
|
@@ -18537,6 +18538,7 @@ var WeaveStateManager = class {
|
|
|
18537
18538
|
return;
|
|
18538
18539
|
}
|
|
18539
18540
|
const doc = getYjsDoc(state);
|
|
18541
|
+
const userId = this.instance.getStore().getUser().id;
|
|
18540
18542
|
doc.transact(() => {
|
|
18541
18543
|
if (parent.props.children) {
|
|
18542
18544
|
for (let i = parent.props.children.length - 1; i >= 0; i--) if (parent.props.children[i].key === node.key) {
|
|
@@ -18546,7 +18548,7 @@ var WeaveStateManager = class {
|
|
|
18546
18548
|
for (let i = 0; i < parent.props.children.length; i++) parent.props.children[i].props.zIndex = i;
|
|
18547
18549
|
this.instance.emitEvent("onNodeRemoved", node);
|
|
18548
18550
|
}
|
|
18549
|
-
});
|
|
18551
|
+
}, userId);
|
|
18550
18552
|
}
|
|
18551
18553
|
removeNodes(nodes) {
|
|
18552
18554
|
for (const node of nodes) this.removeNode(node);
|
|
@@ -18578,6 +18580,7 @@ var WeaveStateManager = class {
|
|
|
18578
18580
|
return;
|
|
18579
18581
|
}
|
|
18580
18582
|
const doc = getYjsDoc(state);
|
|
18583
|
+
const userId = this.instance.getStore().getUser().id;
|
|
18581
18584
|
doc.transact(() => {
|
|
18582
18585
|
if (parent.props.children) {
|
|
18583
18586
|
const item = JSON.parse(JSON.stringify(parent.props.children[nodeIndex]));
|
|
@@ -18588,7 +18591,7 @@ var WeaveStateManager = class {
|
|
|
18588
18591
|
if (item && position === WEAVE_NODE_POSITION.BACK) parent.props.children.splice(0, 0, item);
|
|
18589
18592
|
for (let i = 0; i < parent.props.children.length; i++) parent.props.children[i].props.zIndex = i;
|
|
18590
18593
|
}
|
|
18591
|
-
});
|
|
18594
|
+
}, userId);
|
|
18592
18595
|
}
|
|
18593
18596
|
}
|
|
18594
18597
|
getElementsTree() {
|
|
@@ -18674,7 +18677,7 @@ var WeaveRegisterManager = class {
|
|
|
18674
18677
|
|
|
18675
18678
|
//#endregion
|
|
18676
18679
|
//#region package.json
|
|
18677
|
-
var version = "0.
|
|
18680
|
+
var version = "0.43.0";
|
|
18678
18681
|
|
|
18679
18682
|
//#endregion
|
|
18680
18683
|
//#region src/managers/setup.ts
|
|
@@ -19788,7 +19791,7 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
19788
19791
|
text.on("transformstart", (e) => {
|
|
19789
19792
|
this.instance.emitEvent("onTransform", e.target);
|
|
19790
19793
|
});
|
|
19791
|
-
text.on("transform", (0, import_lodash
|
|
19794
|
+
text.on("transform", (0, import_lodash.throttle)(handleTextTransform, 50));
|
|
19792
19795
|
text.on("transformend", () => {
|
|
19793
19796
|
this.instance.emitEvent("onTransform", null);
|
|
19794
19797
|
});
|
|
@@ -21076,7 +21079,7 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
21076
21079
|
const stage = this.instance.getStage();
|
|
21077
21080
|
const image = stage.findOne(`#${imageAttrs.id}`);
|
|
21078
21081
|
const internalImage = image?.findOne(`#${imageAttrs.id}-image`);
|
|
21079
|
-
if (image && internalImage && !imageAttrs.adding && imageAttrs.cropInfo && !(0, import_lodash
|
|
21082
|
+
if (image && internalImage && !imageAttrs.adding && imageAttrs.cropInfo && !(0, import_lodash.isEqual)(imageAttrs.cropInfo, this.cachedCropInfo[imageAttrs.id ?? ""])) {
|
|
21080
21083
|
const actualScale = imageAttrs.uncroppedImage.width / imageAttrs.imageInfo.width;
|
|
21081
21084
|
internalImage.width(imageAttrs.uncroppedImage.width);
|
|
21082
21085
|
internalImage.height(imageAttrs.uncroppedImage.height);
|
|
@@ -21093,7 +21096,7 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
21093
21096
|
internalImage.height(imageAttrs.cropSize.height);
|
|
21094
21097
|
this.cachedCropInfo[imageAttrs.id ?? ""] = imageAttrs.cropInfo;
|
|
21095
21098
|
}
|
|
21096
|
-
if (image && internalImage && !imageAttrs.adding && !imageAttrs.cropInfo && !(0, import_lodash
|
|
21099
|
+
if (image && internalImage && !imageAttrs.adding && !imageAttrs.cropInfo && !(0, import_lodash.isEqual)(imageAttrs.cropInfo, this.cachedCropInfo[imageAttrs.id ?? ""])) {
|
|
21097
21100
|
internalImage.width(imageAttrs.uncroppedImage.width);
|
|
21098
21101
|
internalImage.height(imageAttrs.uncroppedImage.height);
|
|
21099
21102
|
internalImage.rotation(0);
|
|
@@ -23392,7 +23395,7 @@ var require_hammer = __commonJS({ "../../node_modules/hammerjs/hammer.js"(export
|
|
|
23392
23395
|
else window$1[exportName] = Hammer;
|
|
23393
23396
|
})(window, document, "Hammer");
|
|
23394
23397
|
} });
|
|
23395
|
-
var import_hammer = __toESM(require_hammer());
|
|
23398
|
+
var import_hammer = __toESM(require_hammer(), 1);
|
|
23396
23399
|
|
|
23397
23400
|
//#endregion
|
|
23398
23401
|
//#region src/plugins/stage-zoom/stage-zoom.ts
|
|
@@ -23414,7 +23417,7 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
|
|
|
23414
23417
|
constructor(params) {
|
|
23415
23418
|
super();
|
|
23416
23419
|
const { config } = params ?? {};
|
|
23417
|
-
this.config = (0, import_lodash
|
|
23420
|
+
this.config = (0, import_lodash.merge)(WEAVE_STAGE_ZOOM_DEFAULT_CONFIG, config);
|
|
23418
23421
|
if (!this.config.zoomSteps.includes(this.config.defaultZoom)) throw new Error(`Default zoom ${this.config.defaultZoom} is not in zoom steps`);
|
|
23419
23422
|
this.threshold = .2;
|
|
23420
23423
|
this.pinching = false;
|
|
@@ -23443,7 +23446,7 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
|
|
|
23443
23446
|
this.config.zoomSteps = [minimumZoom, ...this.config.zoomSteps];
|
|
23444
23447
|
}
|
|
23445
23448
|
};
|
|
23446
|
-
mainLayer?.on("draw", (0, import_lodash
|
|
23449
|
+
mainLayer?.on("draw", (0, import_lodash.throttle)(handleDraw, 50));
|
|
23447
23450
|
this.setZoom(this.config.zoomSteps[this.actualStep]);
|
|
23448
23451
|
}
|
|
23449
23452
|
setZoom(scale, centered = true, pointer) {
|
|
@@ -24138,9 +24141,10 @@ var WeaveRectangleToolAction = class extends WeaveAction {
|
|
|
24138
24141
|
this.initialized = false;
|
|
24139
24142
|
this.state = RECTANGLE_TOOL_STATE.IDLE;
|
|
24140
24143
|
this.rectId = null;
|
|
24141
|
-
this.
|
|
24144
|
+
this.tempRectNode = null;
|
|
24142
24145
|
this.moved = false;
|
|
24143
24146
|
this.container = void 0;
|
|
24147
|
+
this.measureContainer = void 0;
|
|
24144
24148
|
this.clickPoint = null;
|
|
24145
24149
|
this.props = this.initProps();
|
|
24146
24150
|
}
|
|
@@ -24179,10 +24183,7 @@ var WeaveRectangleToolAction = class extends WeaveAction {
|
|
|
24179
24183
|
this.state = RECTANGLE_TOOL_STATE.ADDING;
|
|
24180
24184
|
return;
|
|
24181
24185
|
}
|
|
24182
|
-
if (this.state === RECTANGLE_TOOL_STATE.ADDING)
|
|
24183
|
-
this.creating = true;
|
|
24184
|
-
this.handleAdding();
|
|
24185
|
-
}
|
|
24186
|
+
if (this.state === RECTANGLE_TOOL_STATE.ADDING) this.handleAdding();
|
|
24186
24187
|
});
|
|
24187
24188
|
stage.on("pointermove", (e) => {
|
|
24188
24189
|
if (!this.isPressed(e)) return;
|
|
@@ -24191,19 +24192,13 @@ var WeaveRectangleToolAction = class extends WeaveAction {
|
|
|
24191
24192
|
this.state = RECTANGLE_TOOL_STATE.ADDING;
|
|
24192
24193
|
return;
|
|
24193
24194
|
}
|
|
24194
|
-
if (this.state === RECTANGLE_TOOL_STATE.DEFINING_SIZE)
|
|
24195
|
-
this.moved = true;
|
|
24196
|
-
this.handleMovement();
|
|
24197
|
-
}
|
|
24195
|
+
if (this.state === RECTANGLE_TOOL_STATE.DEFINING_SIZE) this.handleMovement();
|
|
24198
24196
|
});
|
|
24199
24197
|
stage.on("pointerup", (e) => {
|
|
24200
24198
|
this.pointers.delete(e.evt.pointerId);
|
|
24201
24199
|
const isTap = this.isTap(e);
|
|
24202
24200
|
if (isTap) this.moved = false;
|
|
24203
|
-
if (this.state === RECTANGLE_TOOL_STATE.DEFINING_SIZE)
|
|
24204
|
-
this.creating = false;
|
|
24205
|
-
this.handleSettingSize();
|
|
24206
|
-
}
|
|
24201
|
+
if (this.state === RECTANGLE_TOOL_STATE.DEFINING_SIZE) this.handleSettingSize();
|
|
24207
24202
|
});
|
|
24208
24203
|
this.initialized = true;
|
|
24209
24204
|
}
|
|
@@ -24219,29 +24214,28 @@ var WeaveRectangleToolAction = class extends WeaveAction {
|
|
|
24219
24214
|
this.setState(RECTANGLE_TOOL_STATE.ADDING);
|
|
24220
24215
|
}
|
|
24221
24216
|
handleAdding() {
|
|
24222
|
-
const { mousePoint, container } = this.instance.getMousePointer();
|
|
24217
|
+
const { mousePoint, container, measureContainer } = this.instance.getMousePointer();
|
|
24223
24218
|
this.clickPoint = mousePoint;
|
|
24224
24219
|
this.container = container;
|
|
24220
|
+
this.measureContainer = measureContainer;
|
|
24225
24221
|
this.rectId = v4_default();
|
|
24226
|
-
|
|
24227
|
-
|
|
24228
|
-
const node = nodeHandler.create(this.rectId, {
|
|
24222
|
+
if (!this.tempRectNode) {
|
|
24223
|
+
this.tempRectNode = new Konva.Rect({
|
|
24229
24224
|
...this.props,
|
|
24225
|
+
id: this.rectId,
|
|
24230
24226
|
strokeScaleEnabled: true,
|
|
24231
24227
|
x: this.clickPoint?.x ?? 0,
|
|
24232
24228
|
y: this.clickPoint?.y ?? 0,
|
|
24233
24229
|
width: 0,
|
|
24234
24230
|
height: 0
|
|
24235
24231
|
});
|
|
24236
|
-
this.
|
|
24232
|
+
this.measureContainer?.add(this.tempRectNode);
|
|
24237
24233
|
}
|
|
24238
24234
|
this.setState(RECTANGLE_TOOL_STATE.DEFINING_SIZE);
|
|
24239
24235
|
}
|
|
24240
24236
|
handleSettingSize() {
|
|
24241
|
-
|
|
24242
|
-
if (this.rectId && this.clickPoint && this.container && rectangle) {
|
|
24237
|
+
if (this.rectId && this.tempRectNode && this.clickPoint && this.container) {
|
|
24243
24238
|
const { mousePoint } = this.instance.getMousePointerRelativeToContainer(this.container);
|
|
24244
|
-
const nodeHandler = this.instance.getNodeHandler("rectangle");
|
|
24245
24239
|
const rectPos = {
|
|
24246
24240
|
x: this.clickPoint.x,
|
|
24247
24241
|
y: this.clickPoint.y
|
|
@@ -24254,31 +24248,38 @@ var WeaveRectangleToolAction = class extends WeaveAction {
|
|
|
24254
24248
|
rectWidth = Math.abs(this.clickPoint.x - mousePoint.x);
|
|
24255
24249
|
rectHeight = Math.abs(this.clickPoint.y - mousePoint.y);
|
|
24256
24250
|
}
|
|
24257
|
-
|
|
24251
|
+
this.tempRectNode.setAttrs({
|
|
24258
24252
|
...this.props,
|
|
24259
24253
|
x: rectPos.x,
|
|
24260
24254
|
y: rectPos.y,
|
|
24261
24255
|
width: rectWidth,
|
|
24262
24256
|
height: rectHeight
|
|
24263
24257
|
});
|
|
24264
|
-
|
|
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
|
+
}
|
|
24265
24268
|
this.instance.emitEvent("onAddedRectangle");
|
|
24266
24269
|
}
|
|
24267
24270
|
this.cancelAction();
|
|
24268
24271
|
}
|
|
24269
24272
|
handleMovement() {
|
|
24270
24273
|
if (this.state !== RECTANGLE_TOOL_STATE.DEFINING_SIZE) return;
|
|
24271
|
-
|
|
24272
|
-
|
|
24273
|
-
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);
|
|
24274
24277
|
const deltaX = mousePoint.x - this.clickPoint?.x;
|
|
24275
24278
|
const deltaY = mousePoint.y - this.clickPoint?.y;
|
|
24276
|
-
|
|
24277
|
-
rectangle.setAttrs({
|
|
24279
|
+
this.tempRectNode.setAttrs({
|
|
24278
24280
|
width: deltaX,
|
|
24279
24281
|
height: deltaY
|
|
24280
24282
|
});
|
|
24281
|
-
if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(rectangle));
|
|
24282
24283
|
}
|
|
24283
24284
|
}
|
|
24284
24285
|
trigger(cancelAction) {
|
|
@@ -24303,9 +24304,10 @@ var WeaveRectangleToolAction = class extends WeaveAction {
|
|
|
24303
24304
|
this.instance.triggerAction(SELECTION_TOOL_ACTION_NAME);
|
|
24304
24305
|
}
|
|
24305
24306
|
this.rectId = null;
|
|
24306
|
-
this.
|
|
24307
|
+
this.tempRectNode = null;
|
|
24307
24308
|
this.moved = false;
|
|
24308
24309
|
this.container = void 0;
|
|
24310
|
+
this.measureContainer = void 0;
|
|
24309
24311
|
this.clickPoint = null;
|
|
24310
24312
|
this.setState(RECTANGLE_TOOL_STATE.IDLE);
|
|
24311
24313
|
}
|
|
@@ -24541,6 +24543,8 @@ var WeavePenToolAction = class extends WeaveAction {
|
|
|
24541
24543
|
this.state = PEN_TOOL_STATE.IDLE;
|
|
24542
24544
|
this.lineId = null;
|
|
24543
24545
|
this.tempLineId = null;
|
|
24546
|
+
this.tempMainLineNode = null;
|
|
24547
|
+
this.tempLineNode = null;
|
|
24544
24548
|
this.container = void 0;
|
|
24545
24549
|
this.measureContainer = void 0;
|
|
24546
24550
|
this.clickPoint = null;
|
|
@@ -24580,11 +24584,10 @@ var WeavePenToolAction = class extends WeaveAction {
|
|
|
24580
24584
|
this.state = PEN_TOOL_STATE.ADDING;
|
|
24581
24585
|
return;
|
|
24582
24586
|
}
|
|
24583
|
-
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;
|
|
24584
24589
|
});
|
|
24585
|
-
stage.on("pointermove", (
|
|
24586
|
-
if (!this.isPressed(e)) return;
|
|
24587
|
-
if (!this.pointers.has(e.evt.pointerId)) return;
|
|
24590
|
+
stage.on("pointermove", () => {
|
|
24588
24591
|
if (this.pointers.size === 2 && this.instance.getActiveAction() === PEN_TOOL_ACTION_NAME) {
|
|
24589
24592
|
this.state = PEN_TOOL_STATE.ADDING;
|
|
24590
24593
|
return;
|
|
@@ -24603,6 +24606,8 @@ var WeavePenToolAction = class extends WeaveAction {
|
|
|
24603
24606
|
addLine() {
|
|
24604
24607
|
const stage = this.instance.getStage();
|
|
24605
24608
|
stage.container().style.cursor = "crosshair";
|
|
24609
|
+
stage.container().focus();
|
|
24610
|
+
this.instance.emitEvent("onAddingPen");
|
|
24606
24611
|
this.tempPoint = void 0;
|
|
24607
24612
|
this.tempNextPoint = void 0;
|
|
24608
24613
|
this.clickPoint = null;
|
|
@@ -24616,63 +24621,58 @@ var WeavePenToolAction = class extends WeaveAction {
|
|
|
24616
24621
|
this.measureContainer = measureContainer;
|
|
24617
24622
|
this.lineId = v4_default();
|
|
24618
24623
|
this.tempLineId = v4_default();
|
|
24619
|
-
|
|
24620
|
-
|
|
24621
|
-
const node = nodeHandler.create(this.lineId, {
|
|
24624
|
+
if (!this.tempLineNode) {
|
|
24625
|
+
this.tempMainLineNode = new Konva.Line({
|
|
24622
24626
|
...this.props,
|
|
24627
|
+
id: this.lineId,
|
|
24623
24628
|
strokeScaleEnabled: true,
|
|
24624
24629
|
x: this.clickPoint?.x ?? 0,
|
|
24625
24630
|
y: this.clickPoint?.y ?? 0,
|
|
24626
24631
|
points: [0, 0]
|
|
24627
24632
|
});
|
|
24628
|
-
this.
|
|
24629
|
-
|
|
24630
|
-
|
|
24631
|
-
|
|
24632
|
-
|
|
24633
|
-
|
|
24634
|
-
|
|
24635
|
-
|
|
24636
|
-
|
|
24637
|
-
|
|
24638
|
-
|
|
24639
|
-
|
|
24640
|
-
if (nodeHandler) {
|
|
24641
|
-
const tempLine = nodeHandler.create(this.tempLineId, {
|
|
24633
|
+
this.measureContainer?.add(this.tempMainLineNode);
|
|
24634
|
+
this.tempPoint = new Konva.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.Line({
|
|
24642
24645
|
...this.props,
|
|
24646
|
+
id: this.tempLineId,
|
|
24643
24647
|
x: this.clickPoint?.x ?? 0,
|
|
24644
24648
|
y: this.clickPoint?.y ?? 0,
|
|
24645
24649
|
strokeScaleEnabled: true,
|
|
24646
24650
|
points: [0, 0]
|
|
24647
24651
|
});
|
|
24648
|
-
this.
|
|
24652
|
+
this.measureContainer?.add(this.tempLineNode);
|
|
24653
|
+
this.tempNextPoint = new Konva.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);
|
|
24649
24664
|
}
|
|
24650
|
-
this.tempNextPoint = new Konva.Circle({
|
|
24651
|
-
x: this.clickPoint?.x ?? 0,
|
|
24652
|
-
y: this.clickPoint?.y ?? 0,
|
|
24653
|
-
radius: 5 / stage.scaleX(),
|
|
24654
|
-
strokeScaleEnabled: true,
|
|
24655
|
-
stroke: "#cccccc",
|
|
24656
|
-
strokeWidth: 0,
|
|
24657
|
-
fill: "#cccccc"
|
|
24658
|
-
});
|
|
24659
|
-
this.measureContainer?.add(this.tempNextPoint);
|
|
24660
|
-
this.setState(PEN_TOOL_STATE.DEFINING_SIZE);
|
|
24661
24665
|
}
|
|
24662
24666
|
handleSettingSize() {
|
|
24663
|
-
|
|
24664
|
-
const tempMainLine = this.instance.getStage().findOne(`#${this.lineId}`);
|
|
24665
|
-
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) {
|
|
24666
24668
|
const { mousePoint } = this.instance.getMousePointerRelativeToContainer(this.measureContainer);
|
|
24667
|
-
const newPoints = [...
|
|
24668
|
-
newPoints.push(mousePoint.x -
|
|
24669
|
-
newPoints.push(mousePoint.y -
|
|
24670
|
-
|
|
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({
|
|
24671
24673
|
...this.props,
|
|
24672
24674
|
points: newPoints
|
|
24673
24675
|
});
|
|
24674
|
-
const nodeHandler = this.instance.getNodeHandler("line");
|
|
24675
|
-
if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(tempMainLine));
|
|
24676
24676
|
this.tempPoint.setAttrs({
|
|
24677
24677
|
x: mousePoint.x,
|
|
24678
24678
|
y: mousePoint.y
|
|
@@ -24681,32 +24681,28 @@ var WeavePenToolAction = class extends WeaveAction {
|
|
|
24681
24681
|
x: mousePoint.x,
|
|
24682
24682
|
y: mousePoint.y
|
|
24683
24683
|
});
|
|
24684
|
-
|
|
24684
|
+
this.tempLineNode.setAttrs({
|
|
24685
24685
|
...this.props,
|
|
24686
24686
|
x: mousePoint.x,
|
|
24687
24687
|
y: mousePoint.y,
|
|
24688
24688
|
points: [0, 0]
|
|
24689
24689
|
});
|
|
24690
|
-
|
|
24690
|
+
this.setState(PEN_TOOL_STATE.DEFINING_SIZE);
|
|
24691
24691
|
}
|
|
24692
|
-
this.setState(PEN_TOOL_STATE.DEFINING_SIZE);
|
|
24693
24692
|
}
|
|
24694
24693
|
handleMovement() {
|
|
24695
24694
|
if (this.state !== PEN_TOOL_STATE.DEFINING_SIZE) return;
|
|
24696
|
-
|
|
24697
|
-
if (this.lineId && this.measureContainer && this.tempNextPoint && tempLine) {
|
|
24695
|
+
if (this.tempLineNode && this.measureContainer && this.tempNextPoint) {
|
|
24698
24696
|
const { mousePoint } = this.instance.getMousePointerRelativeToContainer(this.measureContainer);
|
|
24699
|
-
|
|
24697
|
+
this.tempLineNode.setAttrs({
|
|
24700
24698
|
...this.props,
|
|
24701
24699
|
points: [
|
|
24702
|
-
|
|
24703
|
-
|
|
24704
|
-
mousePoint.x -
|
|
24705
|
-
mousePoint.y -
|
|
24700
|
+
this.tempLineNode.points()[0],
|
|
24701
|
+
this.tempLineNode.points()[1],
|
|
24702
|
+
mousePoint.x - this.tempLineNode.x(),
|
|
24703
|
+
mousePoint.y - this.tempLineNode.y()
|
|
24706
24704
|
]
|
|
24707
24705
|
});
|
|
24708
|
-
const nodeHandler = this.instance.getNodeHandler("line");
|
|
24709
|
-
if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(tempLine));
|
|
24710
24706
|
this.tempNextPoint.setAttrs({
|
|
24711
24707
|
x: mousePoint.x,
|
|
24712
24708
|
y: mousePoint.y
|
|
@@ -24729,24 +24725,20 @@ var WeavePenToolAction = class extends WeaveAction {
|
|
|
24729
24725
|
const stage = this.instance.getStage();
|
|
24730
24726
|
this.tempPoint?.destroy();
|
|
24731
24727
|
this.tempNextPoint?.destroy();
|
|
24732
|
-
|
|
24733
|
-
|
|
24734
|
-
if (tempLine) {
|
|
24728
|
+
this.tempLineNode?.destroy();
|
|
24729
|
+
if (this.lineId && this.tempMainLineNode && this.tempMainLineNode.points().length >= 4) {
|
|
24735
24730
|
const nodeHandler = this.instance.getNodeHandler("line");
|
|
24736
|
-
if (nodeHandler)
|
|
24737
|
-
|
|
24738
|
-
|
|
24739
|
-
|
|
24740
|
-
|
|
24741
|
-
|
|
24742
|
-
|
|
24743
|
-
|
|
24744
|
-
|
|
24745
|
-
|
|
24746
|
-
|
|
24747
|
-
hitStrokeWidth: 16
|
|
24748
|
-
});
|
|
24749
|
-
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
|
+
}
|
|
24750
24742
|
}
|
|
24751
24743
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
24752
24744
|
if (selectionPlugin) {
|
|
@@ -24759,8 +24751,11 @@ var WeavePenToolAction = class extends WeaveAction {
|
|
|
24759
24751
|
this.tempPoint = void 0;
|
|
24760
24752
|
this.tempNextPoint = void 0;
|
|
24761
24753
|
this.lineId = null;
|
|
24754
|
+
this.tempMainLineNode = null;
|
|
24762
24755
|
this.tempLineId = null;
|
|
24756
|
+
this.tempLineNode = null;
|
|
24763
24757
|
this.container = void 0;
|
|
24758
|
+
this.measureContainer = void 0;
|
|
24764
24759
|
this.clickPoint = null;
|
|
24765
24760
|
this.setState(PEN_TOOL_STATE.IDLE);
|
|
24766
24761
|
}
|
|
@@ -24963,11 +24958,13 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
24963
24958
|
if (selectionPlugin) selectionPlugin.setSelectedNodes([]);
|
|
24964
24959
|
this.props = this.initProps();
|
|
24965
24960
|
this.setState(BRUSH_TOOL_STATE.IDLE);
|
|
24961
|
+
this.instance.emitEvent("onAddingBrush");
|
|
24966
24962
|
stage.container().style.cursor = "crosshair";
|
|
24967
24963
|
}
|
|
24968
24964
|
cleanup() {
|
|
24969
24965
|
const stage = this.instance.getStage();
|
|
24970
24966
|
stage.container().style.cursor = "default";
|
|
24967
|
+
this.instance.emitEvent("onAddedBrush");
|
|
24971
24968
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
24972
24969
|
if (selectionPlugin) {
|
|
24973
24970
|
const node = stage.findOne(`#${this.strokeId}`);
|
|
@@ -25038,6 +25035,8 @@ var WeaveTextToolAction = class extends WeaveAction {
|
|
|
25038
25035
|
tr.hide();
|
|
25039
25036
|
}
|
|
25040
25037
|
stage.container().style.cursor = "crosshair";
|
|
25038
|
+
stage.container().focus();
|
|
25039
|
+
this.instance.emitEvent("onAddingText");
|
|
25041
25040
|
this.clickPoint = null;
|
|
25042
25041
|
this.setState(TEXT_TOOL_STATE.ADDING);
|
|
25043
25042
|
}
|
|
@@ -25055,6 +25054,7 @@ var WeaveTextToolAction = class extends WeaveAction {
|
|
|
25055
25054
|
draggable: true
|
|
25056
25055
|
});
|
|
25057
25056
|
this.instance.addNode(node, this.container?.getAttrs().id);
|
|
25057
|
+
this.instance.emitEvent("onAddedArrow");
|
|
25058
25058
|
}
|
|
25059
25059
|
this.setState(TEXT_TOOL_STATE.FINISHED);
|
|
25060
25060
|
this.cancelAction();
|
|
@@ -25314,10 +25314,13 @@ var WeaveArrowToolAction = class extends WeaveAction {
|
|
|
25314
25314
|
onInit = void 0;
|
|
25315
25315
|
constructor() {
|
|
25316
25316
|
super();
|
|
25317
|
+
this.pointers = new Map();
|
|
25317
25318
|
this.initialized = false;
|
|
25318
25319
|
this.state = ARROW_TOOL_STATE.IDLE;
|
|
25319
25320
|
this.arrowId = null;
|
|
25320
25321
|
this.tempArrowId = null;
|
|
25322
|
+
this.tempMainArrowNode = null;
|
|
25323
|
+
this.tempArrowNode = null;
|
|
25321
25324
|
this.container = void 0;
|
|
25322
25325
|
this.measureContainer = void 0;
|
|
25323
25326
|
this.clickPoint = null;
|
|
@@ -25352,22 +25355,29 @@ var WeaveArrowToolAction = class extends WeaveAction {
|
|
|
25352
25355
|
return;
|
|
25353
25356
|
}
|
|
25354
25357
|
});
|
|
25355
|
-
stage.on("
|
|
25356
|
-
this.
|
|
25357
|
-
|
|
25358
|
-
|
|
25359
|
-
|
|
25360
|
-
|
|
25361
|
-
|
|
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;
|
|
25362
25366
|
return;
|
|
25363
25367
|
}
|
|
25364
|
-
if (this.state === ARROW_TOOL_STATE.
|
|
25365
|
-
|
|
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;
|
|
25366
25374
|
return;
|
|
25367
25375
|
}
|
|
25376
|
+
if (this.state === ARROW_TOOL_STATE.DEFINING_SIZE) this.handleMovement();
|
|
25368
25377
|
});
|
|
25369
|
-
stage.on("
|
|
25370
|
-
this.
|
|
25378
|
+
stage.on("pointerup", (e) => {
|
|
25379
|
+
this.pointers.delete(e.evt.pointerId);
|
|
25380
|
+
if (this.state === ARROW_TOOL_STATE.DEFINING_SIZE) this.handleSettingSize();
|
|
25371
25381
|
});
|
|
25372
25382
|
this.initialized = true;
|
|
25373
25383
|
}
|
|
@@ -25377,6 +25387,8 @@ var WeaveArrowToolAction = class extends WeaveAction {
|
|
|
25377
25387
|
addArrow() {
|
|
25378
25388
|
const stage = this.instance.getStage();
|
|
25379
25389
|
stage.container().style.cursor = "crosshair";
|
|
25390
|
+
stage.container().focus();
|
|
25391
|
+
this.instance.emitEvent("onAddingArrow");
|
|
25380
25392
|
this.tempPoint = void 0;
|
|
25381
25393
|
this.tempNextPoint = void 0;
|
|
25382
25394
|
this.clickPoint = null;
|
|
@@ -25390,65 +25402,58 @@ var WeaveArrowToolAction = class extends WeaveAction {
|
|
|
25390
25402
|
this.measureContainer = measureContainer;
|
|
25391
25403
|
this.arrowId = v4_default();
|
|
25392
25404
|
this.tempArrowId = v4_default();
|
|
25393
|
-
|
|
25394
|
-
|
|
25395
|
-
if (lineNodeHandler) {
|
|
25396
|
-
const node = lineNodeHandler.create(this.arrowId, {
|
|
25405
|
+
if (!this.tempMainArrowNode) {
|
|
25406
|
+
this.tempMainArrowNode = new Konva.Line({
|
|
25397
25407
|
...this.props,
|
|
25408
|
+
id: this.arrowId,
|
|
25398
25409
|
strokeScaleEnabled: true,
|
|
25399
25410
|
x: this.clickPoint?.x ?? 0,
|
|
25400
25411
|
y: this.clickPoint?.y ?? 0,
|
|
25401
25412
|
points: [0, 0]
|
|
25402
25413
|
});
|
|
25403
|
-
this.
|
|
25404
|
-
|
|
25405
|
-
this.tempPoint = new Konva.Circle({
|
|
25406
|
-
x: this.clickPoint?.x ?? 0,
|
|
25407
|
-
y: this.clickPoint?.y ?? 0,
|
|
25408
|
-
radius: 5 / stage.scaleX(),
|
|
25409
|
-
strokeScaleEnabled: true,
|
|
25410
|
-
stroke: "#cccccc",
|
|
25411
|
-
strokeWidth: 0,
|
|
25412
|
-
fill: "#cccccc"
|
|
25413
|
-
});
|
|
25414
|
-
this.measureContainer?.add(this.tempPoint);
|
|
25415
|
-
if (nodeHandler) {
|
|
25416
|
-
const tempArrow = nodeHandler.create(this.tempArrowId, {
|
|
25417
|
-
...this.props,
|
|
25414
|
+
this.measureContainer?.add(this.tempMainArrowNode);
|
|
25415
|
+
this.tempPoint = new Konva.Circle({
|
|
25418
25416
|
x: this.clickPoint?.x ?? 0,
|
|
25419
25417
|
y: this.clickPoint?.y ?? 0,
|
|
25418
|
+
radius: 5 / stage.scaleX(),
|
|
25420
25419
|
strokeScaleEnabled: true,
|
|
25420
|
+
stroke: "#cccccc",
|
|
25421
|
+
strokeWidth: 0,
|
|
25422
|
+
fill: "#cccccc"
|
|
25423
|
+
});
|
|
25424
|
+
this.measureContainer?.add(this.tempPoint);
|
|
25425
|
+
this.tempArrowNode = new Konva.Arrow({
|
|
25426
|
+
...this.props,
|
|
25427
|
+
id: this.tempArrowId,
|
|
25428
|
+
strokeScaleEnabled: true,
|
|
25429
|
+
x: this.clickPoint?.x ?? 0,
|
|
25430
|
+
y: this.clickPoint?.y ?? 0,
|
|
25421
25431
|
points: [0, 0]
|
|
25422
25432
|
});
|
|
25423
|
-
this.
|
|
25433
|
+
this.measureContainer?.add(this.tempArrowNode);
|
|
25434
|
+
this.tempNextPoint = new Konva.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);
|
|
25424
25445
|
}
|
|
25425
|
-
this.tempNextPoint = new Konva.Circle({
|
|
25426
|
-
x: this.clickPoint?.x ?? 0,
|
|
25427
|
-
y: this.clickPoint?.y ?? 0,
|
|
25428
|
-
radius: 5 / stage.scaleX(),
|
|
25429
|
-
strokeScaleEnabled: true,
|
|
25430
|
-
stroke: "#cccccc",
|
|
25431
|
-
strokeWidth: 0,
|
|
25432
|
-
fill: "#cccccc"
|
|
25433
|
-
});
|
|
25434
|
-
this.measureContainer?.add(this.tempNextPoint);
|
|
25435
|
-
this.setState(ARROW_TOOL_STATE.DEFINING_SIZE);
|
|
25436
25446
|
}
|
|
25437
25447
|
handleSettingSize() {
|
|
25438
|
-
|
|
25439
|
-
const tempMainArrow = this.instance.getStage().findOne(`#${this.arrowId}`);
|
|
25440
|
-
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) {
|
|
25441
25449
|
const { mousePoint } = this.instance.getMousePointerRelativeToContainer(this.measureContainer);
|
|
25442
|
-
const newPoints = [...
|
|
25443
|
-
newPoints.push(mousePoint.x -
|
|
25444
|
-
newPoints.push(mousePoint.y -
|
|
25445
|
-
|
|
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({
|
|
25446
25454
|
...this.props,
|
|
25447
25455
|
points: newPoints
|
|
25448
25456
|
});
|
|
25449
|
-
const nodeHandler = this.instance.getNodeHandler("arrow");
|
|
25450
|
-
const lineNodeHandler = this.instance.getNodeHandler("line");
|
|
25451
|
-
if (lineNodeHandler) this.instance.updateNode(lineNodeHandler.serialize(tempMainArrow));
|
|
25452
25457
|
this.tempPoint.setAttrs({
|
|
25453
25458
|
x: mousePoint.x,
|
|
25454
25459
|
y: mousePoint.y
|
|
@@ -25457,32 +25462,28 @@ var WeaveArrowToolAction = class extends WeaveAction {
|
|
|
25457
25462
|
x: mousePoint.x,
|
|
25458
25463
|
y: mousePoint.y
|
|
25459
25464
|
});
|
|
25460
|
-
|
|
25465
|
+
this.tempArrowNode.setAttrs({
|
|
25461
25466
|
...this.props,
|
|
25462
25467
|
x: mousePoint.x,
|
|
25463
25468
|
y: mousePoint.y,
|
|
25464
25469
|
points: [0, 0]
|
|
25465
25470
|
});
|
|
25466
|
-
|
|
25471
|
+
this.setState(ARROW_TOOL_STATE.DEFINING_SIZE);
|
|
25467
25472
|
}
|
|
25468
|
-
this.setState(ARROW_TOOL_STATE.DEFINING_SIZE);
|
|
25469
25473
|
}
|
|
25470
25474
|
handleMovement() {
|
|
25471
25475
|
if (this.state !== ARROW_TOOL_STATE.DEFINING_SIZE) return;
|
|
25472
|
-
|
|
25473
|
-
if (this.arrowId && this.measureContainer && this.tempNextPoint && tempArrow) {
|
|
25476
|
+
if (this.arrowId && this.tempArrowNode && this.measureContainer && this.tempNextPoint) {
|
|
25474
25477
|
const { mousePoint } = this.instance.getMousePointerRelativeToContainer(this.measureContainer);
|
|
25475
|
-
|
|
25478
|
+
this.tempArrowNode.setAttrs({
|
|
25476
25479
|
...this.props,
|
|
25477
25480
|
points: [
|
|
25478
|
-
|
|
25479
|
-
|
|
25480
|
-
mousePoint.x -
|
|
25481
|
-
mousePoint.y -
|
|
25481
|
+
this.tempArrowNode.points()[0],
|
|
25482
|
+
this.tempArrowNode.points()[1],
|
|
25483
|
+
mousePoint.x - this.tempArrowNode.x(),
|
|
25484
|
+
mousePoint.y - this.tempArrowNode.y()
|
|
25482
25485
|
]
|
|
25483
25486
|
});
|
|
25484
|
-
const nodeHandler = this.instance.getNodeHandler("arrow");
|
|
25485
|
-
if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(tempArrow));
|
|
25486
25487
|
this.tempNextPoint.setAttrs({
|
|
25487
25488
|
x: mousePoint.x,
|
|
25488
25489
|
y: mousePoint.y
|
|
@@ -25505,29 +25506,19 @@ var WeaveArrowToolAction = class extends WeaveAction {
|
|
|
25505
25506
|
const stage = this.instance.getStage();
|
|
25506
25507
|
this.tempPoint?.destroy();
|
|
25507
25508
|
this.tempNextPoint?.destroy();
|
|
25508
|
-
|
|
25509
|
-
|
|
25510
|
-
if (tempArrow) {
|
|
25509
|
+
this.tempArrowNode?.destroy();
|
|
25510
|
+
if (this.arrowId && this.tempMainArrowNode && this.tempMainArrowNode.points().length >= 4) {
|
|
25511
25511
|
const nodeHandler = this.instance.getNodeHandler("arrow");
|
|
25512
|
-
if (nodeHandler)
|
|
25513
|
-
|
|
25514
|
-
|
|
25515
|
-
const nodeHandler = this.instance.getNodeHandler("line");
|
|
25516
|
-
if (nodeHandler) this.instance.removeNode(nodeHandler.serialize(tempMainArrow));
|
|
25517
|
-
}
|
|
25518
|
-
if (this.arrowId && tempMainArrow && tempMainArrow.points().length >= 4) {
|
|
25519
|
-
const nodeHandler = this.instance.getNodeHandler("arrow");
|
|
25520
|
-
const lineNodeHandler = this.instance.getNodeHandler("line");
|
|
25521
|
-
if (nodeHandler && lineNodeHandler) {
|
|
25512
|
+
if (nodeHandler) {
|
|
25513
|
+
const clonedLine = this.tempMainArrowNode.clone();
|
|
25514
|
+
this.tempMainArrowNode.destroy();
|
|
25522
25515
|
const finalArrow = nodeHandler.create(this.arrowId, {
|
|
25523
|
-
...tempMainArrow.getAttrs(),
|
|
25524
25516
|
...this.props,
|
|
25525
|
-
|
|
25526
|
-
strokeWidth: 1,
|
|
25517
|
+
...clonedLine.getAttrs(),
|
|
25527
25518
|
hitStrokeWidth: 16
|
|
25528
25519
|
});
|
|
25529
|
-
this.instance.removeNode(lineNodeHandler.serialize(tempMainArrow));
|
|
25530
25520
|
this.instance.addNode(finalArrow, this.container?.getAttrs().id);
|
|
25521
|
+
this.instance.emitEvent("onAddedArrow");
|
|
25531
25522
|
}
|
|
25532
25523
|
}
|
|
25533
25524
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
@@ -25542,7 +25533,10 @@ var WeaveArrowToolAction = class extends WeaveAction {
|
|
|
25542
25533
|
this.tempNextPoint = void 0;
|
|
25543
25534
|
this.arrowId = null;
|
|
25544
25535
|
this.tempArrowId = null;
|
|
25536
|
+
this.tempMainArrowNode = null;
|
|
25537
|
+
this.tempArrowNode = null;
|
|
25545
25538
|
this.container = void 0;
|
|
25539
|
+
this.measureContainer = void 0;
|
|
25546
25540
|
this.clickPoint = null;
|
|
25547
25541
|
this.setState(ARROW_TOOL_STATE.IDLE);
|
|
25548
25542
|
}
|
|
@@ -25804,6 +25798,7 @@ var WeaveFrameToolAction = class extends WeaveAction {
|
|
|
25804
25798
|
const stage = this.instance.getStage();
|
|
25805
25799
|
stage.container().style.cursor = "crosshair";
|
|
25806
25800
|
stage.container().focus();
|
|
25801
|
+
this.instance.emitEvent("onAddingFrame");
|
|
25807
25802
|
this.frameId = null;
|
|
25808
25803
|
this.clickPoint = null;
|
|
25809
25804
|
this.setState(FRAME_TOOL_STATE.ADDING);
|
|
@@ -25825,6 +25820,7 @@ var WeaveFrameToolAction = class extends WeaveAction {
|
|
|
25825
25820
|
y: this.clickPoint.y
|
|
25826
25821
|
});
|
|
25827
25822
|
this.instance.addNode(node, this.container?.getAttrs().id);
|
|
25823
|
+
this.instance.emitEvent("onAddedFrame");
|
|
25828
25824
|
}
|
|
25829
25825
|
this.cancelAction?.();
|
|
25830
25826
|
}
|
|
@@ -26284,7 +26280,7 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
|
|
|
26284
26280
|
if (!this.enabled || !(this.isSpaceKeyPressed || this.isMouseMiddleButtonPressed || this.moveToolActive)) return;
|
|
26285
26281
|
this.onRender();
|
|
26286
26282
|
};
|
|
26287
|
-
stage.on("pointermove", (0, import_lodash
|
|
26283
|
+
stage.on("pointermove", (0, import_lodash.throttle)(handleMouseMove, 50));
|
|
26288
26284
|
stage.on("pointermove", () => {
|
|
26289
26285
|
if (this.enabled) this.onRender();
|
|
26290
26286
|
});
|
|
@@ -26856,7 +26852,7 @@ var WeaveConnectedUsersPlugin = class extends WeavePlugin {
|
|
|
26856
26852
|
newConnectedUsers[userInformation.id] = userInformation;
|
|
26857
26853
|
}
|
|
26858
26854
|
}
|
|
26859
|
-
if (!(0, import_lodash
|
|
26855
|
+
if (!(0, import_lodash.isEqual)(this.connectedUsers, newConnectedUsers)) this.instance.emitEvent("onConnectedUsersChange", newConnectedUsers);
|
|
26860
26856
|
this.connectedUsers = newConnectedUsers;
|
|
26861
26857
|
});
|
|
26862
26858
|
}
|