@inditextech/weave-sdk 2.3.0 → 2.3.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.d.ts +31 -20
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +108 -40
- package/dist/sdk.js.map +1 -1
- package/dist/sdk.node.d.ts +17 -6
- package/dist/sdk.node.d.ts.map +1 -1
- package/dist/sdk.node.js +108 -40
- package/dist/sdk.node.js.map +1 -1
- package/package.json +2 -2
package/dist/sdk.js
CHANGED
|
@@ -15290,7 +15290,8 @@ const WEAVE_NODES_SELECTION_DEFAULT_CONFIG = {
|
|
|
15290
15290
|
]
|
|
15291
15291
|
};
|
|
15292
15292
|
}
|
|
15293
|
-
}
|
|
15293
|
+
},
|
|
15294
|
+
style: { dragOpacity: .75 }
|
|
15294
15295
|
};
|
|
15295
15296
|
|
|
15296
15297
|
//#endregion
|
|
@@ -18732,11 +18733,16 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
18732
18733
|
};
|
|
18733
18734
|
tr.on("transform", (0, import_throttle.default)(handleTransform, 50));
|
|
18734
18735
|
tr.on("transformend", () => {
|
|
18736
|
+
if (tr.nodes().length > 1) {
|
|
18737
|
+
const nodes = tr.nodes();
|
|
18738
|
+
for (const node of nodes) {
|
|
18739
|
+
this.getNodesSelectionFeedbackPlugin()?.showSelectionHalo(node);
|
|
18740
|
+
this.getNodesSelectionFeedbackPlugin()?.updateSelectionHalo(node);
|
|
18741
|
+
}
|
|
18742
|
+
}
|
|
18735
18743
|
this.triggerSelectedNodesEvent();
|
|
18736
18744
|
});
|
|
18737
18745
|
let initialPos = null;
|
|
18738
|
-
const originalNodeOpacity = {};
|
|
18739
|
-
const DRAG_OPACITY = .75;
|
|
18740
18746
|
tr.on("dragstart", (e) => {
|
|
18741
18747
|
initialPos = {
|
|
18742
18748
|
x: e.target.x(),
|
|
@@ -18751,8 +18757,9 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
18751
18757
|
}
|
|
18752
18758
|
const nodes = tr.nodes();
|
|
18753
18759
|
if (nodes.length > 1) for (const node of nodes) {
|
|
18754
|
-
originalNodeOpacity
|
|
18755
|
-
node.
|
|
18760
|
+
const originalNodeOpacity = node.getAttrs().opacity ?? 1;
|
|
18761
|
+
node.setAttr("dragStartOpacity", originalNodeOpacity);
|
|
18762
|
+
node.opacity(this.getDragOpacity());
|
|
18756
18763
|
}
|
|
18757
18764
|
e.cancelBubble = true;
|
|
18758
18765
|
tr.forceUpdate();
|
|
@@ -18792,6 +18799,13 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
18792
18799
|
tr.on("dragend", (e) => {
|
|
18793
18800
|
if (!this.didMove) return;
|
|
18794
18801
|
e.cancelBubble = true;
|
|
18802
|
+
if (tr.nodes().length > 1) {
|
|
18803
|
+
const nodes$1 = tr.nodes();
|
|
18804
|
+
for (const node of nodes$1) {
|
|
18805
|
+
this.getNodesSelectionFeedbackPlugin()?.showSelectionHalo(node);
|
|
18806
|
+
this.getNodesSelectionFeedbackPlugin()?.updateSelectionHalo(node);
|
|
18807
|
+
}
|
|
18808
|
+
}
|
|
18795
18809
|
this.instance.getCloningManager().cleanupClones();
|
|
18796
18810
|
this.getStagePanningPlugin()?.cleanupEdgeMoveIntervals();
|
|
18797
18811
|
const selectedNodes = tr.nodes();
|
|
@@ -18803,8 +18817,9 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
18803
18817
|
}
|
|
18804
18818
|
const nodes = tr.nodes();
|
|
18805
18819
|
if (nodes.length > 1) for (const node of nodes) {
|
|
18806
|
-
node.
|
|
18807
|
-
|
|
18820
|
+
const dragStartOpacity = node.getAttr("dragStartOpacity") ?? 1;
|
|
18821
|
+
node.opacity(dragStartOpacity);
|
|
18822
|
+
node.setAttr("dragStartOpacity", void 0);
|
|
18808
18823
|
}
|
|
18809
18824
|
if (this.isSelecting() && tr.nodes().length > 1) {
|
|
18810
18825
|
const actualCursor = stage.container().style.cursor;
|
|
@@ -18816,18 +18831,29 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
18816
18831
|
const nodeUpdatePromise = (node) => {
|
|
18817
18832
|
return new Promise((resolve) => {
|
|
18818
18833
|
setTimeout(() => {
|
|
18819
|
-
|
|
18820
|
-
|
|
18821
|
-
|
|
18822
|
-
|
|
18823
|
-
|
|
18824
|
-
|
|
18825
|
-
|
|
18826
|
-
|
|
18827
|
-
|
|
18828
|
-
|
|
18829
|
-
|
|
18830
|
-
|
|
18834
|
+
const isLockedToContainer = node.getAttrs().lockToContainer;
|
|
18835
|
+
if (!isLockedToContainer) {
|
|
18836
|
+
clearContainerTargets(this.instance);
|
|
18837
|
+
const nodeHandler = this.instance.getNodeHandler(node.getAttrs().nodeType);
|
|
18838
|
+
if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(node));
|
|
18839
|
+
let containerToMove = this.instance.getMainLayer();
|
|
18840
|
+
if (layerToMove) containerToMove = layerToMove;
|
|
18841
|
+
let moved = false;
|
|
18842
|
+
if (containerToMove && !selectionContainsFrames) moved = moveNodeToContainer(this.instance, node, containerToMove);
|
|
18843
|
+
if (containerToMove) containerToMove.fire(WEAVE_NODE_CUSTOM_EVENTS.onTargetLeave, { node: void 0 });
|
|
18844
|
+
if (!nodeHandler) return resolve();
|
|
18845
|
+
toSelect.push(node.getAttrs().id ?? "");
|
|
18846
|
+
if (!moved) toUpdate.push(nodeHandler.serialize(node));
|
|
18847
|
+
}
|
|
18848
|
+
if (isLockedToContainer) {
|
|
18849
|
+
clearContainerTargets(this.instance);
|
|
18850
|
+
toSelect.push(node.getAttrs().id ?? "");
|
|
18851
|
+
const nodeHandler = this.instance.getNodeHandler(node.getAttrs().nodeType);
|
|
18852
|
+
if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(node));
|
|
18853
|
+
if (!nodeHandler) return resolve();
|
|
18854
|
+
toSelect.push(node.getAttrs().id ?? "");
|
|
18855
|
+
toUpdate.push(nodeHandler.serialize(node));
|
|
18856
|
+
}
|
|
18831
18857
|
resolve();
|
|
18832
18858
|
}, 0);
|
|
18833
18859
|
});
|
|
@@ -18841,16 +18867,16 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
18841
18867
|
Promise.allSettled(promises).then((results) => {
|
|
18842
18868
|
if (results.length > 0) this.instance.updateNodes(toUpdate);
|
|
18843
18869
|
stage.container().style.cursor = actualCursor;
|
|
18870
|
+
setTimeout(() => {
|
|
18871
|
+
const finalSelectedNodes = [];
|
|
18872
|
+
toSelect.forEach((nodeId) => {
|
|
18873
|
+
const actNode = this.instance.getStage().findOne(`#${nodeId}`);
|
|
18874
|
+
if (actNode) finalSelectedNodes.push(actNode);
|
|
18875
|
+
});
|
|
18876
|
+
tr.nodes(finalSelectedNodes);
|
|
18877
|
+
tr.forceUpdate();
|
|
18878
|
+
}, 0);
|
|
18844
18879
|
});
|
|
18845
|
-
setTimeout(() => {
|
|
18846
|
-
const finalSelectedNodes = [];
|
|
18847
|
-
toSelect.forEach((nodeId) => {
|
|
18848
|
-
const actNode = this.instance.getStage().findOne(`#${nodeId}`);
|
|
18849
|
-
if (actNode) finalSelectedNodes.push(actNode);
|
|
18850
|
-
});
|
|
18851
|
-
tr.nodes(finalSelectedNodes);
|
|
18852
|
-
tr.forceUpdate();
|
|
18853
|
-
}, 0);
|
|
18854
18880
|
}
|
|
18855
18881
|
for (const node of selectedNodes) node.setAttrs({ isCloned: void 0 });
|
|
18856
18882
|
tr.forceUpdate();
|
|
@@ -19453,6 +19479,9 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19453
19479
|
getSelectorConfig() {
|
|
19454
19480
|
return this.config.selection;
|
|
19455
19481
|
}
|
|
19482
|
+
getDragOpacity() {
|
|
19483
|
+
return this.config.style.dragOpacity;
|
|
19484
|
+
}
|
|
19456
19485
|
};
|
|
19457
19486
|
|
|
19458
19487
|
//#endregion
|
|
@@ -20027,7 +20056,10 @@ var WeaveNode = class {
|
|
|
20027
20056
|
if (nodesSnappingPlugin) nodesSnappingPlugin.cleanupGuidelines();
|
|
20028
20057
|
if (nodesSelectionPlugin) nodesSelectionPlugin.getTransformer().forceUpdate();
|
|
20029
20058
|
this.scaleReset(node$1);
|
|
20030
|
-
this.
|
|
20059
|
+
if (this.getSelectionPlugin()?.getSelectedNodes().length === 1) {
|
|
20060
|
+
this.getNodesSelectionFeedbackPlugin()?.showSelectionHalo(node$1);
|
|
20061
|
+
this.getNodesSelectionFeedbackPlugin()?.updateSelectionHalo(node$1);
|
|
20062
|
+
}
|
|
20031
20063
|
const nodeHandler = this.instance.getNodeHandler(node$1.getAttrs().nodeType);
|
|
20032
20064
|
if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(node$1));
|
|
20033
20065
|
this.getNodesSelectionPlugin()?.getHoverTransformer().forceUpdate();
|
|
@@ -20043,8 +20075,6 @@ var WeaveNode = class {
|
|
|
20043
20075
|
const nodeTarget = e.target;
|
|
20044
20076
|
originalPosition = nodeTarget.getAbsolutePosition();
|
|
20045
20077
|
});
|
|
20046
|
-
let originalOpacity = void 0;
|
|
20047
|
-
const DRAG_OPACITY = .75;
|
|
20048
20078
|
node.on("dragstart", (e) => {
|
|
20049
20079
|
const nodeTarget = e.target;
|
|
20050
20080
|
this.getNodesSelectionFeedbackPlugin()?.hideSelectionHalo(nodeTarget);
|
|
@@ -20065,8 +20095,10 @@ var WeaveNode = class {
|
|
|
20065
20095
|
}
|
|
20066
20096
|
const realNodeTarget = this.getRealSelectedNode(nodeTarget);
|
|
20067
20097
|
if (realNodeTarget.getAttrs().isCloned) return;
|
|
20068
|
-
|
|
20069
|
-
|
|
20098
|
+
if (this.getNodesSelectionPlugin()?.getSelectedNodes().length === 1) {
|
|
20099
|
+
realNodeTarget.setAttr("dragStartOpacity", realNodeTarget.opacity());
|
|
20100
|
+
realNodeTarget.opacity(this.getNodesSelectionPlugin()?.getDragOpacity());
|
|
20101
|
+
}
|
|
20070
20102
|
if (e.evt?.altKey) {
|
|
20071
20103
|
nodeTarget.setAttrs({ isCloneOrigin: true });
|
|
20072
20104
|
nodeTarget.setAttrs({ isCloned: false });
|
|
@@ -20116,7 +20148,10 @@ var WeaveNode = class {
|
|
|
20116
20148
|
node.on("dragmove", (0, import_lodash.throttle)(handleDragMove, 100));
|
|
20117
20149
|
node.on("dragend", (e) => {
|
|
20118
20150
|
const nodeTarget = e.target;
|
|
20119
|
-
this.
|
|
20151
|
+
if (this.getSelectionPlugin()?.getSelectedNodes().length === 1) {
|
|
20152
|
+
this.getNodesSelectionFeedbackPlugin()?.showSelectionHalo(nodeTarget);
|
|
20153
|
+
this.getNodesSelectionFeedbackPlugin()?.updateSelectionHalo(nodeTarget);
|
|
20154
|
+
}
|
|
20120
20155
|
e.cancelBubble = true;
|
|
20121
20156
|
if (nodeTarget.getAttrs().isCloneOrigin && originalPosition) {
|
|
20122
20157
|
nodeTarget.setAbsolutePosition(originalPosition);
|
|
@@ -20133,8 +20168,11 @@ var WeaveNode = class {
|
|
|
20133
20168
|
}
|
|
20134
20169
|
this.instance.emitEvent("onDrag", null);
|
|
20135
20170
|
const realNodeTarget = this.getRealSelectedNode(nodeTarget);
|
|
20136
|
-
|
|
20137
|
-
|
|
20171
|
+
if (this.getNodesSelectionPlugin()?.getSelectedNodes().length === 1) {
|
|
20172
|
+
const originalNodeOpacity = realNodeTarget.getAttr("dragStartOpacity") ?? 1;
|
|
20173
|
+
realNodeTarget.setAttrs({ opacity: originalNodeOpacity });
|
|
20174
|
+
realNodeTarget.setAttr("dragStartOpacity", void 0);
|
|
20175
|
+
}
|
|
20138
20176
|
if (this.isSelecting() && this.getSelectionPlugin()?.getSelectedNodes().length === 1 && (realNodeTarget.getAttrs().lockToContainer === void 0 || !realNodeTarget.getAttrs().lockToContainer)) {
|
|
20139
20177
|
clearContainerTargets(this.instance);
|
|
20140
20178
|
const nodesEdgeSnappingPlugin = this.getNodesEdgeSnappingPlugin();
|
|
@@ -29035,9 +29073,7 @@ var WeaveNodesMultiSelectionFeedbackPlugin = class extends WeavePlugin {
|
|
|
29035
29073
|
rotation: clone.rotation()
|
|
29036
29074
|
};
|
|
29037
29075
|
}
|
|
29038
|
-
|
|
29039
|
-
const nodeId = node.getAttrs().id ?? "";
|
|
29040
|
-
if (this.selectedHalos[nodeId]) return;
|
|
29076
|
+
getNodeInfo(node) {
|
|
29041
29077
|
const info = this.getNodeRectInfo(node);
|
|
29042
29078
|
if (info) {
|
|
29043
29079
|
const parent = node.getParent();
|
|
@@ -29055,6 +29091,14 @@ var WeaveNodesMultiSelectionFeedbackPlugin = class extends WeavePlugin {
|
|
|
29055
29091
|
info.y += realParent.y();
|
|
29056
29092
|
}
|
|
29057
29093
|
}
|
|
29094
|
+
}
|
|
29095
|
+
return info;
|
|
29096
|
+
}
|
|
29097
|
+
createSelectionHalo(node) {
|
|
29098
|
+
const nodeId = node.getAttrs().id ?? "";
|
|
29099
|
+
if (this.selectedHalos[nodeId]) return;
|
|
29100
|
+
const info = this.getNodeInfo(node);
|
|
29101
|
+
if (info) {
|
|
29058
29102
|
this.selectedHalos[nodeId] = new Konva.Rect({
|
|
29059
29103
|
id: `${nodeId}-selection-halo`,
|
|
29060
29104
|
name: "selection-halo",
|
|
@@ -29079,6 +29123,30 @@ var WeaveNodesMultiSelectionFeedbackPlugin = class extends WeavePlugin {
|
|
|
29079
29123
|
delete this.selectedHalos[nodeId];
|
|
29080
29124
|
}
|
|
29081
29125
|
}
|
|
29126
|
+
updateSelectionHalo(node) {
|
|
29127
|
+
const nodeId = node.getAttrs().id ?? "";
|
|
29128
|
+
if (!this.selectedHalos[nodeId]) return;
|
|
29129
|
+
const info = this.getNodeInfo(node);
|
|
29130
|
+
if (info) {
|
|
29131
|
+
const selectionLayer = this.instance.getSelectionLayer();
|
|
29132
|
+
if (!selectionLayer) return;
|
|
29133
|
+
const groupHalo = selectionLayer.findOne(`#${node.getAttrs().id}-selection-halo`);
|
|
29134
|
+
groupHalo?.setAttrs({
|
|
29135
|
+
x: info.x,
|
|
29136
|
+
y: info.y,
|
|
29137
|
+
width: info.width,
|
|
29138
|
+
height: info.height,
|
|
29139
|
+
rotation: info.rotation
|
|
29140
|
+
});
|
|
29141
|
+
}
|
|
29142
|
+
}
|
|
29143
|
+
showSelectionHalo(node) {
|
|
29144
|
+
const selectionLayer = this.instance.getSelectionLayer();
|
|
29145
|
+
if (selectionLayer) {
|
|
29146
|
+
const groupHalo = selectionLayer.findOne(`#${node.getAttrs().id}-selection-halo`);
|
|
29147
|
+
if (groupHalo) groupHalo.show();
|
|
29148
|
+
}
|
|
29149
|
+
}
|
|
29082
29150
|
hideSelectionHalo(node) {
|
|
29083
29151
|
const selectionLayer = this.instance.getSelectionLayer();
|
|
29084
29152
|
if (selectionLayer) {
|
|
@@ -31665,7 +31733,7 @@ var WeaveRegisterManager = class {
|
|
|
31665
31733
|
|
|
31666
31734
|
//#endregion
|
|
31667
31735
|
//#region package.json
|
|
31668
|
-
var version = "2.3.
|
|
31736
|
+
var version = "2.3.1";
|
|
31669
31737
|
|
|
31670
31738
|
//#endregion
|
|
31671
31739
|
//#region src/managers/setup.ts
|