@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.node.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 };
|
|
@@ -21803,7 +21842,7 @@ var WeaveRegisterManager = class {
|
|
|
21803
21842
|
|
|
21804
21843
|
//#endregion
|
|
21805
21844
|
//#region package.json
|
|
21806
|
-
var version = "2.3.
|
|
21845
|
+
var version = "2.3.2";
|
|
21807
21846
|
|
|
21808
21847
|
//#endregion
|
|
21809
21848
|
//#region src/managers/setup.ts
|
|
@@ -22426,6 +22465,11 @@ var Weave = class {
|
|
|
22426
22465
|
this.emitEvent("onInstanceStatus", this.status);
|
|
22427
22466
|
const store = this.storeManager.getStore();
|
|
22428
22467
|
store.disconnect();
|
|
22468
|
+
const nodeHandlers = this.registerManager.getNodesHandlers();
|
|
22469
|
+
for (const nodeHandlerKey of Object.keys(nodeHandlers)) {
|
|
22470
|
+
const nodeHandler = nodeHandlers[nodeHandlerKey];
|
|
22471
|
+
nodeHandler?.onDestroyInstance();
|
|
22472
|
+
}
|
|
22429
22473
|
const stage = this.getStage();
|
|
22430
22474
|
if (stage) stage.destroy();
|
|
22431
22475
|
globalThis.Konva = void 0;
|
|
@@ -23300,11 +23344,6 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
23300
23344
|
if (!this.instance.isServerSide() && !this.keyPressHandler) {
|
|
23301
23345
|
this.keyPressHandler = this.handleKeyPress.bind(this);
|
|
23302
23346
|
window.addEventListener("keypress", this.keyPressHandler);
|
|
23303
|
-
this.instance.addEventListener("onStoreConnectionStatusChange", (status) => {
|
|
23304
|
-
if (!this.keyPressHandler) return;
|
|
23305
|
-
if (status !== "connected" && this.keyPressHandler) window.removeEventListener("keypress", this.keyPressHandler);
|
|
23306
|
-
else if (status === "connected" && this.keyPressHandler) window.addEventListener("keypress", this.keyPressHandler);
|
|
23307
|
-
});
|
|
23308
23347
|
}
|
|
23309
23348
|
}
|
|
23310
23349
|
onRender(props) {
|
|
@@ -23726,6 +23765,7 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
23726
23765
|
stage.container().tabIndex = 1;
|
|
23727
23766
|
stage.container().click();
|
|
23728
23767
|
stage.container().focus();
|
|
23768
|
+
this.instance.emitEvent("onExitTextNodeEditMode", { node: textNode });
|
|
23729
23769
|
}
|
|
23730
23770
|
triggerEditMode(textNode) {
|
|
23731
23771
|
const stage = this.instance.getStage();
|
|
@@ -23745,6 +23785,14 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
23745
23785
|
y: stageRect.y + stageContainer.offsetTop + textPosition.y
|
|
23746
23786
|
};
|
|
23747
23787
|
this.createTextAreaDOM(textNode, areaPosition);
|
|
23788
|
+
this.instance.emitEvent("onEnterTextNodeEditMode", { node: textNode });
|
|
23789
|
+
}
|
|
23790
|
+
onDestroyInstance() {
|
|
23791
|
+
super.onDestroyInstance();
|
|
23792
|
+
if (!this.instance.isServerSide() && this.keyPressHandler) {
|
|
23793
|
+
window.removeEventListener("keypress", this.keyPressHandler);
|
|
23794
|
+
this.keyPressHandler = void 0;
|
|
23795
|
+
}
|
|
23748
23796
|
}
|
|
23749
23797
|
};
|
|
23750
23798
|
|
|
@@ -31131,9 +31179,7 @@ var WeaveNodesMultiSelectionFeedbackPlugin = class extends WeavePlugin {
|
|
|
31131
31179
|
rotation: clone.rotation()
|
|
31132
31180
|
};
|
|
31133
31181
|
}
|
|
31134
|
-
|
|
31135
|
-
const nodeId = node.getAttrs().id ?? "";
|
|
31136
|
-
if (this.selectedHalos[nodeId]) return;
|
|
31182
|
+
getNodeInfo(node) {
|
|
31137
31183
|
const info = this.getNodeRectInfo(node);
|
|
31138
31184
|
if (info) {
|
|
31139
31185
|
const parent = node.getParent();
|
|
@@ -31151,6 +31197,14 @@ var WeaveNodesMultiSelectionFeedbackPlugin = class extends WeavePlugin {
|
|
|
31151
31197
|
info.y += realParent.y();
|
|
31152
31198
|
}
|
|
31153
31199
|
}
|
|
31200
|
+
}
|
|
31201
|
+
return info;
|
|
31202
|
+
}
|
|
31203
|
+
createSelectionHalo(node) {
|
|
31204
|
+
const nodeId = node.getAttrs().id ?? "";
|
|
31205
|
+
if (this.selectedHalos[nodeId]) return;
|
|
31206
|
+
const info = this.getNodeInfo(node);
|
|
31207
|
+
if (info) {
|
|
31154
31208
|
this.selectedHalos[nodeId] = new Konva.Rect({
|
|
31155
31209
|
id: `${nodeId}-selection-halo`,
|
|
31156
31210
|
name: "selection-halo",
|
|
@@ -31175,6 +31229,30 @@ var WeaveNodesMultiSelectionFeedbackPlugin = class extends WeavePlugin {
|
|
|
31175
31229
|
delete this.selectedHalos[nodeId];
|
|
31176
31230
|
}
|
|
31177
31231
|
}
|
|
31232
|
+
updateSelectionHalo(node) {
|
|
31233
|
+
const nodeId = node.getAttrs().id ?? "";
|
|
31234
|
+
if (!this.selectedHalos[nodeId]) return;
|
|
31235
|
+
const info = this.getNodeInfo(node);
|
|
31236
|
+
if (info) {
|
|
31237
|
+
const selectionLayer = this.instance.getSelectionLayer();
|
|
31238
|
+
if (!selectionLayer) return;
|
|
31239
|
+
const groupHalo = selectionLayer.findOne(`#${node.getAttrs().id}-selection-halo`);
|
|
31240
|
+
groupHalo?.setAttrs({
|
|
31241
|
+
x: info.x,
|
|
31242
|
+
y: info.y,
|
|
31243
|
+
width: info.width,
|
|
31244
|
+
height: info.height,
|
|
31245
|
+
rotation: info.rotation
|
|
31246
|
+
});
|
|
31247
|
+
}
|
|
31248
|
+
}
|
|
31249
|
+
showSelectionHalo(node) {
|
|
31250
|
+
const selectionLayer = this.instance.getSelectionLayer();
|
|
31251
|
+
if (selectionLayer) {
|
|
31252
|
+
const groupHalo = selectionLayer.findOne(`#${node.getAttrs().id}-selection-halo`);
|
|
31253
|
+
if (groupHalo) groupHalo.show();
|
|
31254
|
+
}
|
|
31255
|
+
}
|
|
31178
31256
|
hideSelectionHalo(node) {
|
|
31179
31257
|
const selectionLayer = this.instance.getSelectionLayer();
|
|
31180
31258
|
if (selectionLayer) {
|