@inditextech/weave-sdk 2.3.0 → 2.3.2
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 +39 -20
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +123 -45
- package/dist/sdk.js.map +1 -1
- package/dist/sdk.node.d.ts +20 -1
- package/dist/sdk.node.d.ts.map +1 -1
- package/dist/sdk.node.js +123 -45
- 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();
|
|
@@ -20239,6 +20277,7 @@ var WeaveNode = class {
|
|
|
20239
20277
|
onDestroy(nodeInstance) {
|
|
20240
20278
|
nodeInstance.destroy();
|
|
20241
20279
|
}
|
|
20280
|
+
onDestroyInstance() {}
|
|
20242
20281
|
serialize(instance) {
|
|
20243
20282
|
const attrs = instance.getAttrs();
|
|
20244
20283
|
const cleanedAttrs = { ...attrs };
|
|
@@ -21199,11 +21238,6 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
21199
21238
|
if (!this.instance.isServerSide() && !this.keyPressHandler) {
|
|
21200
21239
|
this.keyPressHandler = this.handleKeyPress.bind(this);
|
|
21201
21240
|
window.addEventListener("keypress", this.keyPressHandler);
|
|
21202
|
-
this.instance.addEventListener("onStoreConnectionStatusChange", (status) => {
|
|
21203
|
-
if (!this.keyPressHandler) return;
|
|
21204
|
-
if (status !== "connected" && this.keyPressHandler) window.removeEventListener("keypress", this.keyPressHandler);
|
|
21205
|
-
else if (status === "connected" && this.keyPressHandler) window.addEventListener("keypress", this.keyPressHandler);
|
|
21206
|
-
});
|
|
21207
21241
|
}
|
|
21208
21242
|
}
|
|
21209
21243
|
onRender(props) {
|
|
@@ -21625,6 +21659,7 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
21625
21659
|
stage.container().tabIndex = 1;
|
|
21626
21660
|
stage.container().click();
|
|
21627
21661
|
stage.container().focus();
|
|
21662
|
+
this.instance.emitEvent("onExitTextNodeEditMode", { node: textNode });
|
|
21628
21663
|
}
|
|
21629
21664
|
triggerEditMode(textNode) {
|
|
21630
21665
|
const stage = this.instance.getStage();
|
|
@@ -21644,6 +21679,14 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
21644
21679
|
y: stageRect.y + stageContainer.offsetTop + textPosition.y
|
|
21645
21680
|
};
|
|
21646
21681
|
this.createTextAreaDOM(textNode, areaPosition);
|
|
21682
|
+
this.instance.emitEvent("onEnterTextNodeEditMode", { node: textNode });
|
|
21683
|
+
}
|
|
21684
|
+
onDestroyInstance() {
|
|
21685
|
+
super.onDestroyInstance();
|
|
21686
|
+
if (!this.instance.isServerSide() && this.keyPressHandler) {
|
|
21687
|
+
window.removeEventListener("keypress", this.keyPressHandler);
|
|
21688
|
+
this.keyPressHandler = void 0;
|
|
21689
|
+
}
|
|
21647
21690
|
}
|
|
21648
21691
|
};
|
|
21649
21692
|
|
|
@@ -29035,9 +29078,7 @@ var WeaveNodesMultiSelectionFeedbackPlugin = class extends WeavePlugin {
|
|
|
29035
29078
|
rotation: clone.rotation()
|
|
29036
29079
|
};
|
|
29037
29080
|
}
|
|
29038
|
-
|
|
29039
|
-
const nodeId = node.getAttrs().id ?? "";
|
|
29040
|
-
if (this.selectedHalos[nodeId]) return;
|
|
29081
|
+
getNodeInfo(node) {
|
|
29041
29082
|
const info = this.getNodeRectInfo(node);
|
|
29042
29083
|
if (info) {
|
|
29043
29084
|
const parent = node.getParent();
|
|
@@ -29055,6 +29096,14 @@ var WeaveNodesMultiSelectionFeedbackPlugin = class extends WeavePlugin {
|
|
|
29055
29096
|
info.y += realParent.y();
|
|
29056
29097
|
}
|
|
29057
29098
|
}
|
|
29099
|
+
}
|
|
29100
|
+
return info;
|
|
29101
|
+
}
|
|
29102
|
+
createSelectionHalo(node) {
|
|
29103
|
+
const nodeId = node.getAttrs().id ?? "";
|
|
29104
|
+
if (this.selectedHalos[nodeId]) return;
|
|
29105
|
+
const info = this.getNodeInfo(node);
|
|
29106
|
+
if (info) {
|
|
29058
29107
|
this.selectedHalos[nodeId] = new Konva.Rect({
|
|
29059
29108
|
id: `${nodeId}-selection-halo`,
|
|
29060
29109
|
name: "selection-halo",
|
|
@@ -29079,6 +29128,30 @@ var WeaveNodesMultiSelectionFeedbackPlugin = class extends WeavePlugin {
|
|
|
29079
29128
|
delete this.selectedHalos[nodeId];
|
|
29080
29129
|
}
|
|
29081
29130
|
}
|
|
29131
|
+
updateSelectionHalo(node) {
|
|
29132
|
+
const nodeId = node.getAttrs().id ?? "";
|
|
29133
|
+
if (!this.selectedHalos[nodeId]) return;
|
|
29134
|
+
const info = this.getNodeInfo(node);
|
|
29135
|
+
if (info) {
|
|
29136
|
+
const selectionLayer = this.instance.getSelectionLayer();
|
|
29137
|
+
if (!selectionLayer) return;
|
|
29138
|
+
const groupHalo = selectionLayer.findOne(`#${node.getAttrs().id}-selection-halo`);
|
|
29139
|
+
groupHalo?.setAttrs({
|
|
29140
|
+
x: info.x,
|
|
29141
|
+
y: info.y,
|
|
29142
|
+
width: info.width,
|
|
29143
|
+
height: info.height,
|
|
29144
|
+
rotation: info.rotation
|
|
29145
|
+
});
|
|
29146
|
+
}
|
|
29147
|
+
}
|
|
29148
|
+
showSelectionHalo(node) {
|
|
29149
|
+
const selectionLayer = this.instance.getSelectionLayer();
|
|
29150
|
+
if (selectionLayer) {
|
|
29151
|
+
const groupHalo = selectionLayer.findOne(`#${node.getAttrs().id}-selection-halo`);
|
|
29152
|
+
if (groupHalo) groupHalo.show();
|
|
29153
|
+
}
|
|
29154
|
+
}
|
|
29082
29155
|
hideSelectionHalo(node) {
|
|
29083
29156
|
const selectionLayer = this.instance.getSelectionLayer();
|
|
29084
29157
|
if (selectionLayer) {
|
|
@@ -31665,7 +31738,7 @@ var WeaveRegisterManager = class {
|
|
|
31665
31738
|
|
|
31666
31739
|
//#endregion
|
|
31667
31740
|
//#region package.json
|
|
31668
|
-
var version = "2.3.
|
|
31741
|
+
var version = "2.3.2";
|
|
31669
31742
|
|
|
31670
31743
|
//#endregion
|
|
31671
31744
|
//#region src/managers/setup.ts
|
|
@@ -32283,6 +32356,11 @@ var Weave = class {
|
|
|
32283
32356
|
this.emitEvent("onInstanceStatus", this.status);
|
|
32284
32357
|
const store = this.storeManager.getStore();
|
|
32285
32358
|
store.disconnect();
|
|
32359
|
+
const nodeHandlers = this.registerManager.getNodesHandlers();
|
|
32360
|
+
for (const nodeHandlerKey of Object.keys(nodeHandlers)) {
|
|
32361
|
+
const nodeHandler = nodeHandlers[nodeHandlerKey];
|
|
32362
|
+
nodeHandler?.onDestroyInstance();
|
|
32363
|
+
}
|
|
32286
32364
|
const stage = this.getStage();
|
|
32287
32365
|
if (stage) stage.destroy();
|
|
32288
32366
|
globalThis.Konva = void 0;
|