@inditextech/weave-sdk 5.1.5 → 5.2.1
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.js +65 -43
- package/dist/sdk.node.js +65 -43
- package/dist/sdk.node.stats.html +1 -1
- package/dist/sdk.stats.html +1 -1
- package/dist/types.d.ts +25 -23
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +65 -43
- package/dist/types.js.map +1 -1
- package/dist/types.stats.html +1 -1
- package/package.json +2 -2
package/dist/sdk.js
CHANGED
|
@@ -36,13 +36,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
36
36
|
}) : target, mod));
|
|
37
37
|
|
|
38
38
|
//#endregion
|
|
39
|
-
//#region
|
|
39
|
+
//#region node_modules/emittery/maps.js
|
|
40
40
|
const anyMap = new WeakMap();
|
|
41
41
|
const eventsMap = new WeakMap();
|
|
42
42
|
const producersMap = new WeakMap();
|
|
43
43
|
|
|
44
44
|
//#endregion
|
|
45
|
-
//#region
|
|
45
|
+
//#region node_modules/emittery/index.js
|
|
46
46
|
const anyProducer = Symbol("anyProducer");
|
|
47
47
|
const resolvedPromise = Promise.resolve();
|
|
48
48
|
const listenerAdded = Symbol("listenerAdded");
|
|
@@ -4432,23 +4432,12 @@ var TransformerController = class {
|
|
|
4432
4432
|
if (this.tr.nodes().length === 1 && this.tr.nodes()[0].getAttrs().isContainerPrincipal) {
|
|
4433
4433
|
const pos = stage.getPointerPosition();
|
|
4434
4434
|
if (!pos) return;
|
|
4435
|
+
const back = this.tr.findOne(".back");
|
|
4436
|
+
if (!back) return;
|
|
4435
4437
|
const shapeUnder = stage.getIntersection(pos);
|
|
4436
|
-
if (
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
}
|
|
4440
|
-
if (shapeUnder && this.tr.getChildren().includes(shapeUnder) && shapeUnder.name() === "back") {
|
|
4441
|
-
this.tr.setAttrs({ listening: false });
|
|
4442
|
-
this.tr.forceUpdate();
|
|
4443
|
-
}
|
|
4444
|
-
if (shapeUnder && this.tr.nodes()[0].getChildren().includes(shapeUnder)) {
|
|
4445
|
-
this.tr.setAttrs({ listening: false });
|
|
4446
|
-
this.tr.forceUpdate();
|
|
4447
|
-
}
|
|
4448
|
-
if (shapeUnder && !this.tr.getChildren().includes(shapeUnder) && this.tr.nodes()[0].getChildren().includes(shapeUnder)) {
|
|
4449
|
-
this.tr.setAttrs({ listening: true });
|
|
4450
|
-
this.tr.forceUpdate();
|
|
4451
|
-
}
|
|
4438
|
+
if (shapeUnder === back) back.listening(false);
|
|
4439
|
+
else back.listening(true);
|
|
4440
|
+
this.tr.forceUpdate();
|
|
4452
4441
|
}
|
|
4453
4442
|
};
|
|
4454
4443
|
stage.on("pointermove", (0, import_throttle.default)(handlePointerMoveInit, DEFAULT_THROTTLE_MS));
|
|
@@ -5029,7 +5018,7 @@ function handlePointerDown(ctx, e) {
|
|
|
5029
5018
|
const stage = ctx.getWeaveInstance().getStage();
|
|
5030
5019
|
if (stage.mode() !== WEAVE_STAGE_DEFAULT_MODE) return;
|
|
5031
5020
|
const selectedGroup = getTargetedNode(ctx.getWeaveInstance());
|
|
5032
|
-
if (selectedGroup?.getParent() instanceof Konva.Transformer) {
|
|
5021
|
+
if (selectedGroup?.getParent() instanceof Konva.Transformer && selectedGroup?.hasName("back")) {
|
|
5033
5022
|
ctx.setAreaSelecting(false);
|
|
5034
5023
|
ctx.getEdgePanning().stop();
|
|
5035
5024
|
ctx.getAreaSelector().hide();
|
|
@@ -8598,6 +8587,20 @@ var WeaveGroupsManager = class {
|
|
|
8598
8587
|
parentId
|
|
8599
8588
|
};
|
|
8600
8589
|
}
|
|
8590
|
+
selectRenderedNode(nodeId, triggerSelectionEvent = false) {
|
|
8591
|
+
this.instance.addOnceEventListener("onStateChange", () => {
|
|
8592
|
+
this.getNodesMultiSelectionFeedbackPlugin()?.cleanupSelectedHalos();
|
|
8593
|
+
const node = this.instance.getStage().findOne(`#${nodeId}`);
|
|
8594
|
+
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
8595
|
+
if (node && selectionPlugin) {
|
|
8596
|
+
const tr = selectionPlugin.getTransformer();
|
|
8597
|
+
selectionPlugin.setSelectedNodes([node]);
|
|
8598
|
+
tr.show();
|
|
8599
|
+
tr.forceUpdate();
|
|
8600
|
+
if (triggerSelectionEvent) selectionPlugin.triggerSelectedNodesEvent();
|
|
8601
|
+
}
|
|
8602
|
+
});
|
|
8603
|
+
}
|
|
8601
8604
|
group(nodes) {
|
|
8602
8605
|
this.instance.stateTransactional(() => {
|
|
8603
8606
|
this.logger.debug({ nodes }, "Grouping nodes");
|
|
@@ -8688,17 +8691,7 @@ var WeaveGroupsManager = class {
|
|
|
8688
8691
|
groupNode.y(0);
|
|
8689
8692
|
this.instance.updateNodeNT(groupHandler.serialize(groupNode));
|
|
8690
8693
|
}
|
|
8691
|
-
|
|
8692
|
-
this.getNodesMultiSelectionFeedbackPlugin()?.cleanupSelectedHalos();
|
|
8693
|
-
const groupNode$1 = stage.findOne(`#${groupId}`);
|
|
8694
|
-
const selectionPlugin$1 = this.instance.getPlugin("nodesSelection");
|
|
8695
|
-
if (groupNode$1 && selectionPlugin$1) {
|
|
8696
|
-
const tr = selectionPlugin$1.getTransformer();
|
|
8697
|
-
selectionPlugin$1.setSelectedNodes([groupNode$1]);
|
|
8698
|
-
tr.show();
|
|
8699
|
-
tr.forceUpdate();
|
|
8700
|
-
}
|
|
8701
|
-
}, 10);
|
|
8694
|
+
this.selectRenderedNode(groupId);
|
|
8702
8695
|
});
|
|
8703
8696
|
}
|
|
8704
8697
|
unGroup(group) {
|
|
@@ -8710,6 +8703,11 @@ var WeaveGroupsManager = class {
|
|
|
8710
8703
|
this.logger.debug({ group }, "Group instance doesn't exists, cannot un-group");
|
|
8711
8704
|
return;
|
|
8712
8705
|
}
|
|
8706
|
+
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
8707
|
+
if (selectionPlugin) {
|
|
8708
|
+
const tr = selectionPlugin.getTransformer();
|
|
8709
|
+
tr.hide();
|
|
8710
|
+
}
|
|
8713
8711
|
let nodeId = void 0;
|
|
8714
8712
|
let newLayer = this.instance.getMainLayer();
|
|
8715
8713
|
if (konvaGroup.getParent() && konvaGroup.getParent() instanceof Konva.Group && konvaGroup.getParent()?.getAttrs().nodeId) {
|
|
@@ -8762,6 +8760,7 @@ var WeaveGroupsManager = class {
|
|
|
8762
8760
|
node.key = newNodeId;
|
|
8763
8761
|
node.props.id = newNodeId;
|
|
8764
8762
|
for (const prop of Object.keys(node.props)) if (typeof node.props[prop] === "string") node.props[prop] = node.props[prop].replace(oldId, newNodeId);
|
|
8763
|
+
newChildId = newNodeId;
|
|
8765
8764
|
this.instance.addNodeNT(node, nodeId ?? newLayer.getAttrs().id);
|
|
8766
8765
|
}
|
|
8767
8766
|
child.destroy();
|
|
@@ -8771,12 +8770,7 @@ var WeaveGroupsManager = class {
|
|
|
8771
8770
|
const groupNode = groupHandler.serialize(konvaGroup);
|
|
8772
8771
|
this.instance.removeNodeNT(groupNode, { emitUserChangeEvent: false });
|
|
8773
8772
|
}
|
|
8774
|
-
|
|
8775
|
-
this.getNodesMultiSelectionFeedbackPlugin()?.cleanupSelectedHalos();
|
|
8776
|
-
const firstElement = newLayer.findOne(`#${newChildId}`);
|
|
8777
|
-
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
8778
|
-
if (firstElement && selectionPlugin) selectionPlugin.setSelectedNodes([firstElement]);
|
|
8779
|
-
}, 0);
|
|
8773
|
+
if (newChildId) this.selectRenderedNode(newChildId, true);
|
|
8780
8774
|
});
|
|
8781
8775
|
}
|
|
8782
8776
|
extractTransformFromMatrix(m) {
|
|
@@ -9782,7 +9776,7 @@ var WeaveRegisterManager = class {
|
|
|
9782
9776
|
|
|
9783
9777
|
//#endregion
|
|
9784
9778
|
//#region package.json
|
|
9785
|
-
var version = "5.1
|
|
9779
|
+
var version = "5.2.1";
|
|
9786
9780
|
|
|
9787
9781
|
//#endregion
|
|
9788
9782
|
//#region src/managers/setup.ts
|
|
@@ -15670,7 +15664,9 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
15670
15664
|
transformer.hide();
|
|
15671
15665
|
utilityLayer?.destroyChildren();
|
|
15672
15666
|
this.renderCropMode(utilityLayer, image);
|
|
15673
|
-
utilityLayer
|
|
15667
|
+
utilityLayer.show();
|
|
15668
|
+
utilityLayer.draw();
|
|
15669
|
+
this.updateCropCursorForCurrentPointer();
|
|
15674
15670
|
});
|
|
15675
15671
|
image.on("onCmdCtrlReleased", () => {
|
|
15676
15672
|
const utilityLayer = this.instance.getUtilityLayer();
|
|
@@ -15750,6 +15746,24 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
15750
15746
|
y: 1 / stageScale
|
|
15751
15747
|
});
|
|
15752
15748
|
}
|
|
15749
|
+
getCropAnchorCursor(position) {
|
|
15750
|
+
if (position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.BOTTOM_LEFT || position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.TOP_RIGHT) return "nesw-resize";
|
|
15751
|
+
if (position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.TOP_LEFT || position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.BOTTOM_RIGHT) return "nwse-resize";
|
|
15752
|
+
if (position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.MIDDLE_RIGHT || position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.MIDDLE_LEFT) return "ew-resize";
|
|
15753
|
+
if (position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.TOP_CENTER || position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.BOTTOM_CENTER) return "ns-resize";
|
|
15754
|
+
return void 0;
|
|
15755
|
+
}
|
|
15756
|
+
updateCropCursorForCurrentPointer() {
|
|
15757
|
+
const stage = this.instance.getStage();
|
|
15758
|
+
const pointerPosition = stage.getPointerPosition?.();
|
|
15759
|
+
if (!pointerPosition) return;
|
|
15760
|
+
const intersection = stage.getIntersection?.(pointerPosition);
|
|
15761
|
+
if (!intersection) return;
|
|
15762
|
+
const position = intersection.getAttr("cropAnchorPosition");
|
|
15763
|
+
if (!position) return;
|
|
15764
|
+
const cursor = this.getCropAnchorCursor(position);
|
|
15765
|
+
if (cursor) stage.container().style.cursor = cursor;
|
|
15766
|
+
}
|
|
15753
15767
|
renderCropAnchor(position, node, layer, onClick) {
|
|
15754
15768
|
const transform = node.getAbsoluteTransform().copy();
|
|
15755
15769
|
const stage = this.instance.getStage();
|
|
@@ -15801,6 +15815,7 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
15801
15815
|
name: "cropMode",
|
|
15802
15816
|
rotation: node.rotation()
|
|
15803
15817
|
});
|
|
15818
|
+
anchor.setAttr("cropAnchorPosition", position);
|
|
15804
15819
|
this.config.cropMode.selection.anchorStyleFunc(anchor, position);
|
|
15805
15820
|
layer.add(anchor);
|
|
15806
15821
|
anchor.scale({
|
|
@@ -15823,10 +15838,8 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
15823
15838
|
if (position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.MIDDLE_LEFT) anchor.setAbsolutePosition(absoluteCorners[6]);
|
|
15824
15839
|
if (position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.BOTTOM_CENTER) anchor.setAbsolutePosition(absoluteCorners[7]);
|
|
15825
15840
|
anchor.on("pointerover", () => {
|
|
15826
|
-
|
|
15827
|
-
if (
|
|
15828
|
-
if (position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.MIDDLE_RIGHT || position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.MIDDLE_LEFT) this.instance.getStage().container().style.cursor = "ew-resize";
|
|
15829
|
-
if (position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.TOP_CENTER || position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.BOTTOM_CENTER) this.instance.getStage().container().style.cursor = "ns-resize";
|
|
15841
|
+
const cursor = this.getCropAnchorCursor(position);
|
|
15842
|
+
if (cursor) this.instance.getStage().container().style.cursor = cursor;
|
|
15830
15843
|
});
|
|
15831
15844
|
anchor.on("pointerdown", () => {
|
|
15832
15845
|
onClick();
|
|
@@ -30885,6 +30898,7 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
|
|
|
30885
30898
|
triggerContextMenu(eventTarget, target) {
|
|
30886
30899
|
const stage = this.instance.getStage();
|
|
30887
30900
|
const selectionPlugin = this.getSelectionPlugin();
|
|
30901
|
+
const selectedNodes = selectionPlugin?.getSelectedNodes() ?? [];
|
|
30888
30902
|
let nodes = [];
|
|
30889
30903
|
if (target && target !== stage) {
|
|
30890
30904
|
const nodeHandler = this.instance.getNodeHandler(target.getAttrs().nodeType);
|
|
@@ -30901,6 +30915,14 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
|
|
|
30901
30915
|
node: nodeHandler?.serialize(node)
|
|
30902
30916
|
};
|
|
30903
30917
|
});
|
|
30918
|
+
const targetIsPartOfMultiSelection = target !== void 0 && selectedNodes.length > 1 && selectedNodes.some((selectedNode) => selectedNode.getAttrs().id === target.getAttrs().id);
|
|
30919
|
+
if (targetIsPartOfMultiSelection) nodes = selectedNodes.map((node) => {
|
|
30920
|
+
const nodeHandler = this.instance.getNodeHandler(node.getAttrs().nodeType);
|
|
30921
|
+
return {
|
|
30922
|
+
instance: node,
|
|
30923
|
+
node: nodeHandler?.serialize(node)
|
|
30924
|
+
};
|
|
30925
|
+
});
|
|
30904
30926
|
if (this.contextMenuVisible) this.closeContextMenu();
|
|
30905
30927
|
let allNodesMutexUnlocked = true;
|
|
30906
30928
|
let allNodesUnlocked = true;
|
|
@@ -30918,7 +30940,7 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
|
|
|
30918
30940
|
}
|
|
30919
30941
|
}
|
|
30920
30942
|
if (!allNodesMutexUnlocked || !allNodesUnlocked) return;
|
|
30921
|
-
if (selectionPlugin && !(eventTarget.getParent() instanceof Konva.Transformer &&
|
|
30943
|
+
if (selectionPlugin && !(eventTarget.getParent() instanceof Konva.Transformer && selectedNodes.length > 0) && !targetIsPartOfMultiSelection) {
|
|
30922
30944
|
selectionPlugin.setSelectedNodes([...nodes.map((node) => node.instance)]);
|
|
30923
30945
|
selectionPlugin.getHoverTransformer().nodes([]);
|
|
30924
30946
|
}
|
package/dist/sdk.node.js
CHANGED
|
@@ -36,13 +36,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
36
36
|
}) : target, mod));
|
|
37
37
|
|
|
38
38
|
//#endregion
|
|
39
|
-
//#region
|
|
39
|
+
//#region node_modules/emittery/maps.js
|
|
40
40
|
const anyMap = new WeakMap();
|
|
41
41
|
const eventsMap = new WeakMap();
|
|
42
42
|
const producersMap = new WeakMap();
|
|
43
43
|
|
|
44
44
|
//#endregion
|
|
45
|
-
//#region
|
|
45
|
+
//#region node_modules/emittery/index.js
|
|
46
46
|
const anyProducer = Symbol("anyProducer");
|
|
47
47
|
const resolvedPromise = Promise.resolve();
|
|
48
48
|
const listenerAdded = Symbol("listenerAdded");
|
|
@@ -4431,23 +4431,12 @@ var TransformerController = class {
|
|
|
4431
4431
|
if (this.tr.nodes().length === 1 && this.tr.nodes()[0].getAttrs().isContainerPrincipal) {
|
|
4432
4432
|
const pos = stage.getPointerPosition();
|
|
4433
4433
|
if (!pos) return;
|
|
4434
|
+
const back = this.tr.findOne(".back");
|
|
4435
|
+
if (!back) return;
|
|
4434
4436
|
const shapeUnder = stage.getIntersection(pos);
|
|
4435
|
-
if (
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
}
|
|
4439
|
-
if (shapeUnder && this.tr.getChildren().includes(shapeUnder) && shapeUnder.name() === "back") {
|
|
4440
|
-
this.tr.setAttrs({ listening: false });
|
|
4441
|
-
this.tr.forceUpdate();
|
|
4442
|
-
}
|
|
4443
|
-
if (shapeUnder && this.tr.nodes()[0].getChildren().includes(shapeUnder)) {
|
|
4444
|
-
this.tr.setAttrs({ listening: false });
|
|
4445
|
-
this.tr.forceUpdate();
|
|
4446
|
-
}
|
|
4447
|
-
if (shapeUnder && !this.tr.getChildren().includes(shapeUnder) && this.tr.nodes()[0].getChildren().includes(shapeUnder)) {
|
|
4448
|
-
this.tr.setAttrs({ listening: true });
|
|
4449
|
-
this.tr.forceUpdate();
|
|
4450
|
-
}
|
|
4437
|
+
if (shapeUnder === back) back.listening(false);
|
|
4438
|
+
else back.listening(true);
|
|
4439
|
+
this.tr.forceUpdate();
|
|
4451
4440
|
}
|
|
4452
4441
|
};
|
|
4453
4442
|
stage.on("pointermove", (0, import_throttle.default)(handlePointerMoveInit, DEFAULT_THROTTLE_MS));
|
|
@@ -5028,7 +5017,7 @@ function handlePointerDown(ctx, e) {
|
|
|
5028
5017
|
const stage = ctx.getWeaveInstance().getStage();
|
|
5029
5018
|
if (stage.mode() !== WEAVE_STAGE_DEFAULT_MODE) return;
|
|
5030
5019
|
const selectedGroup = getTargetedNode(ctx.getWeaveInstance());
|
|
5031
|
-
if (selectedGroup?.getParent() instanceof Konva.Transformer) {
|
|
5020
|
+
if (selectedGroup?.getParent() instanceof Konva.Transformer && selectedGroup?.hasName("back")) {
|
|
5032
5021
|
ctx.setAreaSelecting(false);
|
|
5033
5022
|
ctx.getEdgePanning().stop();
|
|
5034
5023
|
ctx.getAreaSelector().hide();
|
|
@@ -8597,6 +8586,20 @@ var WeaveGroupsManager = class {
|
|
|
8597
8586
|
parentId
|
|
8598
8587
|
};
|
|
8599
8588
|
}
|
|
8589
|
+
selectRenderedNode(nodeId, triggerSelectionEvent = false) {
|
|
8590
|
+
this.instance.addOnceEventListener("onStateChange", () => {
|
|
8591
|
+
this.getNodesMultiSelectionFeedbackPlugin()?.cleanupSelectedHalos();
|
|
8592
|
+
const node = this.instance.getStage().findOne(`#${nodeId}`);
|
|
8593
|
+
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
8594
|
+
if (node && selectionPlugin) {
|
|
8595
|
+
const tr = selectionPlugin.getTransformer();
|
|
8596
|
+
selectionPlugin.setSelectedNodes([node]);
|
|
8597
|
+
tr.show();
|
|
8598
|
+
tr.forceUpdate();
|
|
8599
|
+
if (triggerSelectionEvent) selectionPlugin.triggerSelectedNodesEvent();
|
|
8600
|
+
}
|
|
8601
|
+
});
|
|
8602
|
+
}
|
|
8600
8603
|
group(nodes) {
|
|
8601
8604
|
this.instance.stateTransactional(() => {
|
|
8602
8605
|
this.logger.debug({ nodes }, "Grouping nodes");
|
|
@@ -8687,17 +8690,7 @@ var WeaveGroupsManager = class {
|
|
|
8687
8690
|
groupNode.y(0);
|
|
8688
8691
|
this.instance.updateNodeNT(groupHandler.serialize(groupNode));
|
|
8689
8692
|
}
|
|
8690
|
-
|
|
8691
|
-
this.getNodesMultiSelectionFeedbackPlugin()?.cleanupSelectedHalos();
|
|
8692
|
-
const groupNode$1 = stage.findOne(`#${groupId}`);
|
|
8693
|
-
const selectionPlugin$1 = this.instance.getPlugin("nodesSelection");
|
|
8694
|
-
if (groupNode$1 && selectionPlugin$1) {
|
|
8695
|
-
const tr = selectionPlugin$1.getTransformer();
|
|
8696
|
-
selectionPlugin$1.setSelectedNodes([groupNode$1]);
|
|
8697
|
-
tr.show();
|
|
8698
|
-
tr.forceUpdate();
|
|
8699
|
-
}
|
|
8700
|
-
}, 10);
|
|
8693
|
+
this.selectRenderedNode(groupId);
|
|
8701
8694
|
});
|
|
8702
8695
|
}
|
|
8703
8696
|
unGroup(group) {
|
|
@@ -8709,6 +8702,11 @@ var WeaveGroupsManager = class {
|
|
|
8709
8702
|
this.logger.debug({ group }, "Group instance doesn't exists, cannot un-group");
|
|
8710
8703
|
return;
|
|
8711
8704
|
}
|
|
8705
|
+
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
8706
|
+
if (selectionPlugin) {
|
|
8707
|
+
const tr = selectionPlugin.getTransformer();
|
|
8708
|
+
tr.hide();
|
|
8709
|
+
}
|
|
8712
8710
|
let nodeId = void 0;
|
|
8713
8711
|
let newLayer = this.instance.getMainLayer();
|
|
8714
8712
|
if (konvaGroup.getParent() && konvaGroup.getParent() instanceof Konva.Group && konvaGroup.getParent()?.getAttrs().nodeId) {
|
|
@@ -8761,6 +8759,7 @@ var WeaveGroupsManager = class {
|
|
|
8761
8759
|
node.key = newNodeId;
|
|
8762
8760
|
node.props.id = newNodeId;
|
|
8763
8761
|
for (const prop of Object.keys(node.props)) if (typeof node.props[prop] === "string") node.props[prop] = node.props[prop].replace(oldId, newNodeId);
|
|
8762
|
+
newChildId = newNodeId;
|
|
8764
8763
|
this.instance.addNodeNT(node, nodeId ?? newLayer.getAttrs().id);
|
|
8765
8764
|
}
|
|
8766
8765
|
child.destroy();
|
|
@@ -8770,12 +8769,7 @@ var WeaveGroupsManager = class {
|
|
|
8770
8769
|
const groupNode = groupHandler.serialize(konvaGroup);
|
|
8771
8770
|
this.instance.removeNodeNT(groupNode, { emitUserChangeEvent: false });
|
|
8772
8771
|
}
|
|
8773
|
-
|
|
8774
|
-
this.getNodesMultiSelectionFeedbackPlugin()?.cleanupSelectedHalos();
|
|
8775
|
-
const firstElement = newLayer.findOne(`#${newChildId}`);
|
|
8776
|
-
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
8777
|
-
if (firstElement && selectionPlugin) selectionPlugin.setSelectedNodes([firstElement]);
|
|
8778
|
-
}, 0);
|
|
8772
|
+
if (newChildId) this.selectRenderedNode(newChildId, true);
|
|
8779
8773
|
});
|
|
8780
8774
|
}
|
|
8781
8775
|
extractTransformFromMatrix(m) {
|
|
@@ -9781,7 +9775,7 @@ var WeaveRegisterManager = class {
|
|
|
9781
9775
|
|
|
9782
9776
|
//#endregion
|
|
9783
9777
|
//#region package.json
|
|
9784
|
-
var version = "5.1
|
|
9778
|
+
var version = "5.2.1";
|
|
9785
9779
|
|
|
9786
9780
|
//#endregion
|
|
9787
9781
|
//#region src/managers/setup.ts
|
|
@@ -15669,7 +15663,9 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
15669
15663
|
transformer.hide();
|
|
15670
15664
|
utilityLayer?.destroyChildren();
|
|
15671
15665
|
this.renderCropMode(utilityLayer, image);
|
|
15672
|
-
utilityLayer
|
|
15666
|
+
utilityLayer.show();
|
|
15667
|
+
utilityLayer.draw();
|
|
15668
|
+
this.updateCropCursorForCurrentPointer();
|
|
15673
15669
|
});
|
|
15674
15670
|
image.on("onCmdCtrlReleased", () => {
|
|
15675
15671
|
const utilityLayer = this.instance.getUtilityLayer();
|
|
@@ -15749,6 +15745,24 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
15749
15745
|
y: 1 / stageScale
|
|
15750
15746
|
});
|
|
15751
15747
|
}
|
|
15748
|
+
getCropAnchorCursor(position) {
|
|
15749
|
+
if (position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.BOTTOM_LEFT || position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.TOP_RIGHT) return "nesw-resize";
|
|
15750
|
+
if (position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.TOP_LEFT || position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.BOTTOM_RIGHT) return "nwse-resize";
|
|
15751
|
+
if (position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.MIDDLE_RIGHT || position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.MIDDLE_LEFT) return "ew-resize";
|
|
15752
|
+
if (position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.TOP_CENTER || position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.BOTTOM_CENTER) return "ns-resize";
|
|
15753
|
+
return void 0;
|
|
15754
|
+
}
|
|
15755
|
+
updateCropCursorForCurrentPointer() {
|
|
15756
|
+
const stage = this.instance.getStage();
|
|
15757
|
+
const pointerPosition = stage.getPointerPosition?.();
|
|
15758
|
+
if (!pointerPosition) return;
|
|
15759
|
+
const intersection = stage.getIntersection?.(pointerPosition);
|
|
15760
|
+
if (!intersection) return;
|
|
15761
|
+
const position = intersection.getAttr("cropAnchorPosition");
|
|
15762
|
+
if (!position) return;
|
|
15763
|
+
const cursor = this.getCropAnchorCursor(position);
|
|
15764
|
+
if (cursor) stage.container().style.cursor = cursor;
|
|
15765
|
+
}
|
|
15752
15766
|
renderCropAnchor(position, node, layer, onClick) {
|
|
15753
15767
|
const transform = node.getAbsoluteTransform().copy();
|
|
15754
15768
|
const stage = this.instance.getStage();
|
|
@@ -15800,6 +15814,7 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
15800
15814
|
name: "cropMode",
|
|
15801
15815
|
rotation: node.rotation()
|
|
15802
15816
|
});
|
|
15817
|
+
anchor.setAttr("cropAnchorPosition", position);
|
|
15803
15818
|
this.config.cropMode.selection.anchorStyleFunc(anchor, position);
|
|
15804
15819
|
layer.add(anchor);
|
|
15805
15820
|
anchor.scale({
|
|
@@ -15822,10 +15837,8 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
15822
15837
|
if (position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.MIDDLE_LEFT) anchor.setAbsolutePosition(absoluteCorners[6]);
|
|
15823
15838
|
if (position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.BOTTOM_CENTER) anchor.setAbsolutePosition(absoluteCorners[7]);
|
|
15824
15839
|
anchor.on("pointerover", () => {
|
|
15825
|
-
|
|
15826
|
-
if (
|
|
15827
|
-
if (position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.MIDDLE_RIGHT || position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.MIDDLE_LEFT) this.instance.getStage().container().style.cursor = "ew-resize";
|
|
15828
|
-
if (position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.TOP_CENTER || position === WEAVE_IMAGE_CROP_ANCHOR_POSITION.BOTTOM_CENTER) this.instance.getStage().container().style.cursor = "ns-resize";
|
|
15840
|
+
const cursor = this.getCropAnchorCursor(position);
|
|
15841
|
+
if (cursor) this.instance.getStage().container().style.cursor = cursor;
|
|
15829
15842
|
});
|
|
15830
15843
|
anchor.on("pointerdown", () => {
|
|
15831
15844
|
onClick();
|
|
@@ -30905,6 +30918,7 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
|
|
|
30905
30918
|
triggerContextMenu(eventTarget, target) {
|
|
30906
30919
|
const stage = this.instance.getStage();
|
|
30907
30920
|
const selectionPlugin = this.getSelectionPlugin();
|
|
30921
|
+
const selectedNodes = selectionPlugin?.getSelectedNodes() ?? [];
|
|
30908
30922
|
let nodes = [];
|
|
30909
30923
|
if (target && target !== stage) {
|
|
30910
30924
|
const nodeHandler = this.instance.getNodeHandler(target.getAttrs().nodeType);
|
|
@@ -30921,6 +30935,14 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
|
|
|
30921
30935
|
node: nodeHandler?.serialize(node)
|
|
30922
30936
|
};
|
|
30923
30937
|
});
|
|
30938
|
+
const targetIsPartOfMultiSelection = target !== void 0 && selectedNodes.length > 1 && selectedNodes.some((selectedNode) => selectedNode.getAttrs().id === target.getAttrs().id);
|
|
30939
|
+
if (targetIsPartOfMultiSelection) nodes = selectedNodes.map((node) => {
|
|
30940
|
+
const nodeHandler = this.instance.getNodeHandler(node.getAttrs().nodeType);
|
|
30941
|
+
return {
|
|
30942
|
+
instance: node,
|
|
30943
|
+
node: nodeHandler?.serialize(node)
|
|
30944
|
+
};
|
|
30945
|
+
});
|
|
30924
30946
|
if (this.contextMenuVisible) this.closeContextMenu();
|
|
30925
30947
|
let allNodesMutexUnlocked = true;
|
|
30926
30948
|
let allNodesUnlocked = true;
|
|
@@ -30938,7 +30960,7 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
|
|
|
30938
30960
|
}
|
|
30939
30961
|
}
|
|
30940
30962
|
if (!allNodesMutexUnlocked || !allNodesUnlocked) return;
|
|
30941
|
-
if (selectionPlugin && !(eventTarget.getParent() instanceof Konva.Transformer &&
|
|
30963
|
+
if (selectionPlugin && !(eventTarget.getParent() instanceof Konva.Transformer && selectedNodes.length > 0) && !targetIsPartOfMultiSelection) {
|
|
30942
30964
|
selectionPlugin.setSelectedNodes([...nodes.map((node) => node.instance)]);
|
|
30943
30965
|
selectionPlugin.getHoverTransformer().nodes([]);
|
|
30944
30966
|
}
|