@inditextech/weave-sdk 0.34.0 → 0.36.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 +162 -23
- package/dist/sdk.d.cts +24 -3
- package/dist/sdk.d.cts.map +1 -1
- package/dist/sdk.d.ts +24 -3
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +179 -39
- package/dist/sdk.js.map +1 -1
- package/package.json +2 -2
package/dist/sdk.js
CHANGED
|
@@ -15493,6 +15493,7 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
|
|
|
15493
15493
|
} else root._ = _;
|
|
15494
15494
|
}).call(exports);
|
|
15495
15495
|
} });
|
|
15496
|
+
var import_lodash$1 = __toESM(require_lodash());
|
|
15496
15497
|
var import_lodash = __toESM(require_lodash(), 1);
|
|
15497
15498
|
|
|
15498
15499
|
//#endregion
|
|
@@ -15586,12 +15587,12 @@ var WeaveStore = class {
|
|
|
15586
15587
|
node: JSON.parse(JSON.stringify(nodeInfo.node))
|
|
15587
15588
|
});
|
|
15588
15589
|
}
|
|
15589
|
-
if (!this.isRoomLoaded && !(0, import_lodash.isEmpty)(this.state.weave)) {
|
|
15590
|
+
if (!this.isRoomLoaded && !(0, import_lodash$1.isEmpty)(this.state.weave)) {
|
|
15590
15591
|
this.instance.setupRenderer();
|
|
15591
15592
|
this.isRoomLoaded = true;
|
|
15592
15593
|
this.instance.emitEvent("onRoomLoaded", this.isRoomLoaded);
|
|
15593
15594
|
}
|
|
15594
|
-
if (this.isRoomLoaded && !(0, import_lodash.isEmpty)(this.state.weave)) this.instance.render();
|
|
15595
|
+
if (this.isRoomLoaded && !(0, import_lodash$1.isEmpty)(this.state.weave)) this.instance.render();
|
|
15595
15596
|
});
|
|
15596
15597
|
}
|
|
15597
15598
|
canUndoStateStep() {
|
|
@@ -15729,19 +15730,34 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
|
|
|
15729
15730
|
}
|
|
15730
15731
|
initEvents() {
|
|
15731
15732
|
const stage = this.instance.getStage();
|
|
15733
|
+
this.instance.addEventListener("onDrag", (node) => {
|
|
15734
|
+
if (node) this.dragging = true;
|
|
15735
|
+
else this.dragging = false;
|
|
15736
|
+
});
|
|
15737
|
+
this.instance.addEventListener("onTransform", (node) => {
|
|
15738
|
+
if (node) this.transforming = true;
|
|
15739
|
+
else this.transforming = false;
|
|
15740
|
+
});
|
|
15732
15741
|
stage.on("pointerdown", (e) => {
|
|
15733
15742
|
this.pointers[e.evt.pointerId] = e.evt;
|
|
15743
|
+
if (e.evt.pointerType === "mouse") return;
|
|
15734
15744
|
if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length > 1) return;
|
|
15735
15745
|
this.touchTimer = setTimeout(() => {
|
|
15736
15746
|
this.tapHold = true;
|
|
15747
|
+
if (this.touchTimer && (this.dragging || this.transforming)) {
|
|
15748
|
+
clearTimeout(this.touchTimer);
|
|
15749
|
+
return;
|
|
15750
|
+
}
|
|
15737
15751
|
this.triggerContextMenu(e.target);
|
|
15738
15752
|
}, this.tapHoldTimeout);
|
|
15739
15753
|
});
|
|
15740
|
-
stage.on("pointermove", () => {
|
|
15754
|
+
stage.on("pointermove", (e) => {
|
|
15755
|
+
if (e.evt.pointerType === "mouse") return;
|
|
15741
15756
|
if (this.touchTimer) clearTimeout(this.touchTimer);
|
|
15742
15757
|
});
|
|
15743
15758
|
stage.on("pointerup", (e) => {
|
|
15744
15759
|
delete this.pointers[e.evt.pointerId];
|
|
15760
|
+
if (e.evt.pointerType === "mouse") return;
|
|
15745
15761
|
if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length + 1 > 1) return;
|
|
15746
15762
|
if (this.touchTimer) {
|
|
15747
15763
|
clearTimeout(this.touchTimer);
|
|
@@ -16023,7 +16039,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
16023
16039
|
const handleTransform = () => {
|
|
16024
16040
|
this.triggerSelectedNodesEvent();
|
|
16025
16041
|
};
|
|
16026
|
-
tr.on("transform", (0, import_lodash.throttle)(handleTransform, 50));
|
|
16042
|
+
tr.on("transform", (0, import_lodash$1.throttle)(handleTransform, 50));
|
|
16027
16043
|
tr.on("transformend", () => {
|
|
16028
16044
|
this.triggerSelectedNodesEvent();
|
|
16029
16045
|
});
|
|
@@ -16063,7 +16079,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
16063
16079
|
}
|
|
16064
16080
|
tr.forceUpdate();
|
|
16065
16081
|
};
|
|
16066
|
-
tr.on("dragmove", (0, import_lodash.throttle)(handleDragMove, 50));
|
|
16082
|
+
tr.on("dragmove", (0, import_lodash$1.throttle)(handleDragMove, 50));
|
|
16067
16083
|
tr.on("dragend", (e) => {
|
|
16068
16084
|
this.dragging = false;
|
|
16069
16085
|
e.cancelBubble = true;
|
|
@@ -16213,7 +16229,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
16213
16229
|
height: Math.abs(y2 - y1)
|
|
16214
16230
|
});
|
|
16215
16231
|
};
|
|
16216
|
-
stage.on("pointermove", (0, import_lodash.throttle)(handleMouseMove, 50));
|
|
16232
|
+
stage.on("pointermove", (0, import_lodash$1.throttle)(handleMouseMove, 50));
|
|
16217
16233
|
stage.on("pointerup", (e) => {
|
|
16218
16234
|
delete this.pointers[e.evt.pointerId];
|
|
16219
16235
|
if (!this.initialized) return;
|
|
@@ -16250,13 +16266,15 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
16250
16266
|
return false;
|
|
16251
16267
|
});
|
|
16252
16268
|
const selectedNodes = new Set();
|
|
16253
|
-
const framesNodes = selected.
|
|
16269
|
+
const framesNodes = selected.filter((shape) => {
|
|
16270
|
+
return shape.getAttrs().nodeType === "frame";
|
|
16271
|
+
});
|
|
16272
|
+
const framesNodesIds = framesNodes.map((shape) => {
|
|
16254
16273
|
if (shape.getAttrs().nodeType === "frame" && shape.getAttrs().nodeId) return stage.findOne(`#${shape.getAttrs().nodeId}`);
|
|
16255
16274
|
return shape;
|
|
16256
16275
|
}).filter((shape) => {
|
|
16257
16276
|
return shape.getAttrs().nodeType === "frame";
|
|
16258
|
-
})
|
|
16259
|
-
const framesNodesIds = framesNodes.map((shape) => {
|
|
16277
|
+
}).map((shape) => {
|
|
16260
16278
|
return shape.getAttrs().id;
|
|
16261
16279
|
});
|
|
16262
16280
|
const otherNodes = selected.filter((shape) => shape.getAttrs().nodeType !== "frame");
|
|
@@ -16701,8 +16719,9 @@ var WeaveNode = class {
|
|
|
16701
16719
|
node.off("pointerleave");
|
|
16702
16720
|
} else {
|
|
16703
16721
|
let transforming = false;
|
|
16704
|
-
node.on("transformstart", () => {
|
|
16722
|
+
node.on("transformstart", (e) => {
|
|
16705
16723
|
transforming = true;
|
|
16724
|
+
this.instance.emitEvent("onTransform", e.target);
|
|
16706
16725
|
});
|
|
16707
16726
|
const handleTransform = (e) => {
|
|
16708
16727
|
const node$1 = e.target;
|
|
@@ -16716,9 +16735,10 @@ var WeaveNode = class {
|
|
|
16716
16735
|
if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(node$1));
|
|
16717
16736
|
}
|
|
16718
16737
|
};
|
|
16719
|
-
node.on("transform", (0, import_lodash.throttle)(handleTransform, 100));
|
|
16738
|
+
node.on("transform", (0, import_lodash$1.throttle)(handleTransform, 100));
|
|
16720
16739
|
node.on("transformend", (e) => {
|
|
16721
16740
|
const node$1 = e.target;
|
|
16741
|
+
this.instance.emitEvent("onTransform", null);
|
|
16722
16742
|
transforming = false;
|
|
16723
16743
|
const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
16724
16744
|
const nodesSnappingPlugin = this.instance.getPlugin("nodesSnapping");
|
|
@@ -16729,6 +16749,7 @@ var WeaveNode = class {
|
|
|
16729
16749
|
});
|
|
16730
16750
|
node.on("dragstart", (e) => {
|
|
16731
16751
|
const stage = this.instance.getStage();
|
|
16752
|
+
this.instance.emitEvent("onDrag", e.target);
|
|
16732
16753
|
if (stage.isMouseWheelPressed()) {
|
|
16733
16754
|
e.cancelBubble = true;
|
|
16734
16755
|
e.target.stopDrag();
|
|
@@ -16749,8 +16770,9 @@ var WeaveNode = class {
|
|
|
16749
16770
|
if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(node));
|
|
16750
16771
|
}
|
|
16751
16772
|
};
|
|
16752
|
-
node.on("dragmove", (0, import_lodash.throttle)(handleDragMove, 100));
|
|
16773
|
+
node.on("dragmove", (0, import_lodash$1.throttle)(handleDragMove, 100));
|
|
16753
16774
|
node.on("dragend", (e) => {
|
|
16775
|
+
this.instance.emitEvent("onDrag", null);
|
|
16754
16776
|
if (this.isSelecting() && this.isNodeSelected(node)) {
|
|
16755
16777
|
clearContainerTargets(this.instance);
|
|
16756
16778
|
const nodesSnappingPlugin = this.instance.getPlugin("nodesSnapping");
|
|
@@ -16807,6 +16829,35 @@ var WeaveNode = class {
|
|
|
16807
16829
|
}
|
|
16808
16830
|
};
|
|
16809
16831
|
}
|
|
16832
|
+
show(instance) {
|
|
16833
|
+
if (instance.getAttrs().nodeType !== this.getNodeType()) return;
|
|
16834
|
+
instance.setAttrs({ visible: true });
|
|
16835
|
+
this.instance.updateNode(this.serialize(instance));
|
|
16836
|
+
this.setupDefaultNodeEvents(instance);
|
|
16837
|
+
const stage = this.instance.getStage();
|
|
16838
|
+
stage.container().style.cursor = "default";
|
|
16839
|
+
}
|
|
16840
|
+
hide(instance) {
|
|
16841
|
+
if (instance.getAttrs().nodeType !== this.getNodeType()) return;
|
|
16842
|
+
instance.setAttrs({ visible: false });
|
|
16843
|
+
const selectionPlugin = this.getSelectionPlugin();
|
|
16844
|
+
if (selectionPlugin) {
|
|
16845
|
+
const ids = [instance.getAttrs().id];
|
|
16846
|
+
if (instance.getAttrs().nodeType === "frame") ids.push(`${instance.getAttrs().id}-selector-area`);
|
|
16847
|
+
const selectedNodes = selectionPlugin.getSelectedNodes();
|
|
16848
|
+
const newSelectedNodes = selectedNodes.filter((node) => !ids.includes(node.getAttrs().id));
|
|
16849
|
+
selectionPlugin.setSelectedNodes(newSelectedNodes);
|
|
16850
|
+
selectionPlugin.getTransformer().forceUpdate();
|
|
16851
|
+
}
|
|
16852
|
+
this.instance.updateNode(this.serialize(instance));
|
|
16853
|
+
this.setupDefaultNodeEvents(instance);
|
|
16854
|
+
const stage = this.instance.getStage();
|
|
16855
|
+
stage.container().style.cursor = "default";
|
|
16856
|
+
}
|
|
16857
|
+
isVisible(instance) {
|
|
16858
|
+
if (typeof instance.getAttrs().visible === "undefined") return true;
|
|
16859
|
+
return instance.getAttrs().visible ?? false;
|
|
16860
|
+
}
|
|
16810
16861
|
lock(instance) {
|
|
16811
16862
|
if (instance.getAttrs().nodeType !== this.getNodeType()) return;
|
|
16812
16863
|
instance.setAttrs({ locked: true });
|
|
@@ -18267,7 +18318,7 @@ var WeaveRegisterManager = class {
|
|
|
18267
18318
|
|
|
18268
18319
|
//#endregion
|
|
18269
18320
|
//#region package.json
|
|
18270
|
-
var version = "0.
|
|
18321
|
+
var version = "0.36.0";
|
|
18271
18322
|
|
|
18272
18323
|
//#endregion
|
|
18273
18324
|
//#region src/managers/setup.ts
|
|
@@ -18945,6 +18996,48 @@ var Weave = class {
|
|
|
18945
18996
|
nodeHandler.unlock(node);
|
|
18946
18997
|
}
|
|
18947
18998
|
}
|
|
18999
|
+
allNodesVisible(nodes) {
|
|
19000
|
+
let allNodesVisible = true;
|
|
19001
|
+
for (const node of nodes) {
|
|
19002
|
+
const nodeHandler = this.getNodeHandler(node.getAttrs().nodeType);
|
|
19003
|
+
if (!nodeHandler) continue;
|
|
19004
|
+
allNodesVisible = allNodesVisible && nodeHandler.isVisible(node);
|
|
19005
|
+
}
|
|
19006
|
+
return allNodesVisible;
|
|
19007
|
+
}
|
|
19008
|
+
allNodesHidden(nodes) {
|
|
19009
|
+
let allNodesHidden = true;
|
|
19010
|
+
for (const node of nodes) {
|
|
19011
|
+
const nodeHandler = this.getNodeHandler(node.getAttrs().nodeType);
|
|
19012
|
+
if (!nodeHandler) continue;
|
|
19013
|
+
allNodesHidden = allNodesHidden && !nodeHandler.isVisible(node);
|
|
19014
|
+
}
|
|
19015
|
+
return allNodesHidden;
|
|
19016
|
+
}
|
|
19017
|
+
hideNode(node) {
|
|
19018
|
+
const nodeHandler = this.getNodeHandler(node.getAttrs().nodeType);
|
|
19019
|
+
if (!nodeHandler) return;
|
|
19020
|
+
nodeHandler.hide(node);
|
|
19021
|
+
}
|
|
19022
|
+
hideNodes(nodes) {
|
|
19023
|
+
for (const node of nodes) {
|
|
19024
|
+
const nodeHandler = this.getNodeHandler(node.getAttrs().nodeType);
|
|
19025
|
+
if (!nodeHandler) continue;
|
|
19026
|
+
nodeHandler.hide(node);
|
|
19027
|
+
}
|
|
19028
|
+
}
|
|
19029
|
+
showNode(node) {
|
|
19030
|
+
const nodeHandler = this.getNodeHandler(node.getAttrs().nodeType);
|
|
19031
|
+
if (!nodeHandler) return;
|
|
19032
|
+
nodeHandler.show(node);
|
|
19033
|
+
}
|
|
19034
|
+
showNodes(nodes) {
|
|
19035
|
+
for (const node of nodes) {
|
|
19036
|
+
const nodeHandler = this.getNodeHandler(node.getAttrs().nodeType);
|
|
19037
|
+
if (!nodeHandler) continue;
|
|
19038
|
+
nodeHandler.show(node);
|
|
19039
|
+
}
|
|
19040
|
+
}
|
|
18948
19041
|
};
|
|
18949
19042
|
|
|
18950
19043
|
//#endregion
|
|
@@ -18970,8 +19063,24 @@ var WeaveStageNode = class extends WeaveNode {
|
|
|
18970
19063
|
stage.container().addEventListener("blur", () => {
|
|
18971
19064
|
this.stageFocused = false;
|
|
18972
19065
|
});
|
|
19066
|
+
Konva.Stage.prototype.allowActions = function(actions) {
|
|
19067
|
+
if (typeof actions !== "undefined") this._allowActions = actions;
|
|
19068
|
+
return this._allowActions;
|
|
19069
|
+
};
|
|
19070
|
+
Konva.Stage.prototype.allowSelectNodes = function(nodeTypes) {
|
|
19071
|
+
if (typeof nodeTypes !== "undefined") this._allowSelectNodeTypes = nodeTypes;
|
|
19072
|
+
return this._allowSelectNodeTypes;
|
|
19073
|
+
};
|
|
19074
|
+
Konva.Stage.prototype.allowSelection = function(allowSelection) {
|
|
19075
|
+
if (typeof allowSelection !== "undefined") this._allowSelection = allowSelection;
|
|
19076
|
+
return this._allowSelection;
|
|
19077
|
+
};
|
|
18973
19078
|
stage.on("pointermove", (e) => {
|
|
18974
|
-
if (e.target
|
|
19079
|
+
if (stage.allowSelection() && !stage.allowActions().includes(this.instance.getActiveAction() ?? "") && !stage.allowSelectNodes().includes(e.target.getAttrs()?.nodeType ?? "")) {
|
|
19080
|
+
const stage$1 = this.instance.getStage();
|
|
19081
|
+
stage$1.container().style.cursor = "default";
|
|
19082
|
+
}
|
|
19083
|
+
if (e.target === stage && this.instance.getActiveAction() === "selectionTool") {
|
|
18975
19084
|
const stage$1 = this.instance.getStage();
|
|
18976
19085
|
stage$1.container().style.cursor = "default";
|
|
18977
19086
|
}
|
|
@@ -19305,7 +19414,13 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
19305
19414
|
const node = e.target;
|
|
19306
19415
|
if (this.isSelecting() && this.isNodeSelected(node)) e.cancelBubble = true;
|
|
19307
19416
|
};
|
|
19308
|
-
text.on("
|
|
19417
|
+
text.on("transformstart", (e) => {
|
|
19418
|
+
this.instance.emitEvent("onTransform", e.target);
|
|
19419
|
+
});
|
|
19420
|
+
text.on("transform", (0, import_lodash$1.throttle)(handleTextTransform, 50));
|
|
19421
|
+
text.on("transformend", () => {
|
|
19422
|
+
this.instance.emitEvent("onTransform", null);
|
|
19423
|
+
});
|
|
19309
19424
|
window.addEventListener("keypress", (e) => {
|
|
19310
19425
|
if (e.key === "Enter" && this.instance.getActiveAction() === SELECTION_TOOL_ACTION_NAME && !this.editing && e.target !== this.textArea) {
|
|
19311
19426
|
e.preventDefault();
|
|
@@ -19776,13 +19891,18 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
19776
19891
|
setState(state) {
|
|
19777
19892
|
this.state = state;
|
|
19778
19893
|
}
|
|
19779
|
-
loadImage(imageURL, position) {
|
|
19894
|
+
loadImage(imageURL, options, position) {
|
|
19780
19895
|
const stage = this.instance.getStage();
|
|
19896
|
+
const imageOptions = {
|
|
19897
|
+
crossOrigin: "anonymous",
|
|
19898
|
+
...options
|
|
19899
|
+
};
|
|
19781
19900
|
stage.container().style.cursor = "crosshair";
|
|
19782
19901
|
stage.container().focus();
|
|
19783
19902
|
this.imageId = v4_default();
|
|
19784
19903
|
this.imageURL = imageURL;
|
|
19785
19904
|
this.preloadImgs[this.imageId] = new Image();
|
|
19905
|
+
this.preloadImgs[this.imageId].crossOrigin = imageOptions.crossOrigin;
|
|
19786
19906
|
this.preloadImgs[this.imageId].onerror = () => {
|
|
19787
19907
|
this.instance.emitEvent("onImageLoadEnd", new Error("Error loading image"));
|
|
19788
19908
|
this.cancelAction();
|
|
@@ -19880,7 +20000,7 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
19880
20000
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
19881
20001
|
if (selectionPlugin) selectionPlugin.setSelectedNodes([]);
|
|
19882
20002
|
if (params?.imageURL) {
|
|
19883
|
-
this.loadImage(params.imageURL, params?.position ?? void 0);
|
|
20003
|
+
this.loadImage(params.imageURL, params?.options ?? void 0, params?.position ?? void 0);
|
|
19884
20004
|
return;
|
|
19885
20005
|
}
|
|
19886
20006
|
this.props = this.initProps();
|
|
@@ -20044,19 +20164,26 @@ var WeaveImageCrop = class WeaveImageCrop {
|
|
|
20044
20164
|
skipStroke: true
|
|
20045
20165
|
});
|
|
20046
20166
|
this.drawGridLines(0, 0, cropRect.width, cropRect.height);
|
|
20047
|
-
|
|
20167
|
+
const handleGridLines = () => {
|
|
20048
20168
|
const cropRect$1 = this.cropRect.getClientRect({
|
|
20049
20169
|
relativeTo: this.cropGroup,
|
|
20050
20170
|
skipStroke: true
|
|
20051
20171
|
});
|
|
20052
20172
|
this.drawGridLines(cropRect$1.x, cropRect$1.y, cropRect$1.width, cropRect$1.height);
|
|
20173
|
+
};
|
|
20174
|
+
this.cropRect.on("dragstart", (e) => {
|
|
20175
|
+
this.instance.emitEvent("onDrag", e.target);
|
|
20053
20176
|
});
|
|
20054
|
-
this.cropRect.on("
|
|
20055
|
-
|
|
20056
|
-
|
|
20057
|
-
|
|
20058
|
-
|
|
20059
|
-
this.
|
|
20177
|
+
this.cropRect.on("dragmove", handleGridLines);
|
|
20178
|
+
this.cropRect.on("dragend", () => {
|
|
20179
|
+
this.instance.emitEvent("onDrag", null);
|
|
20180
|
+
});
|
|
20181
|
+
this.cropRect.on("transformstart", (e) => {
|
|
20182
|
+
this.instance.emitEvent("onTransform", e.target);
|
|
20183
|
+
});
|
|
20184
|
+
this.cropRect.on("transform", handleGridLines);
|
|
20185
|
+
this.cropRect.on("transformend", () => {
|
|
20186
|
+
this.instance.emitEvent("onTransform", null);
|
|
20060
20187
|
});
|
|
20061
20188
|
this.transformer.nodes([this.cropRect]);
|
|
20062
20189
|
this.cropGroup.add(this.cropImage);
|
|
@@ -20250,10 +20377,13 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
20250
20377
|
constructor(params) {
|
|
20251
20378
|
super();
|
|
20252
20379
|
const { config } = params ?? {};
|
|
20253
|
-
this.config = {
|
|
20254
|
-
|
|
20255
|
-
|
|
20256
|
-
|
|
20380
|
+
this.config = {
|
|
20381
|
+
crossOrigin: config?.crossOrigin ?? "anonymous",
|
|
20382
|
+
transform: {
|
|
20383
|
+
...WEAVE_DEFAULT_TRANSFORM_PROPERTIES,
|
|
20384
|
+
...config?.transform
|
|
20385
|
+
}
|
|
20386
|
+
};
|
|
20257
20387
|
this.imageCrop = null;
|
|
20258
20388
|
this.cachedCropInfo = {};
|
|
20259
20389
|
this.imageLoaded = false;
|
|
@@ -20483,7 +20613,9 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
20483
20613
|
const imageProps = params;
|
|
20484
20614
|
const imagePlaceholder = image.findOne(`#${imageProps.id}-placeholder`);
|
|
20485
20615
|
const internalImage = image.findOne(`#${imageProps.id}-image`);
|
|
20616
|
+
console.log("crossOrigin", this.config.crossOrigin);
|
|
20486
20617
|
const imageObj = new Image();
|
|
20618
|
+
imageObj.crossOrigin = this.config.crossOrigin;
|
|
20487
20619
|
imageObj.onerror = (error) => {
|
|
20488
20620
|
console.error("Error loading image", imageProps.imageURL, error);
|
|
20489
20621
|
imagePlaceholder?.setAttrs({ visible: true });
|
|
@@ -20538,7 +20670,7 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
20538
20670
|
const stage = this.instance.getStage();
|
|
20539
20671
|
const image = stage.findOne(`#${imageAttrs.id}`);
|
|
20540
20672
|
const internalImage = image?.findOne(`#${imageAttrs.id}-image`);
|
|
20541
|
-
if (image && internalImage && !imageAttrs.adding && imageAttrs.cropInfo && !(0, import_lodash.isEqual)(imageAttrs.cropInfo, this.cachedCropInfo[imageAttrs.id ?? ""])) {
|
|
20673
|
+
if (image && internalImage && !imageAttrs.adding && imageAttrs.cropInfo && !(0, import_lodash$1.isEqual)(imageAttrs.cropInfo, this.cachedCropInfo[imageAttrs.id ?? ""])) {
|
|
20542
20674
|
const actualScale = imageAttrs.uncroppedImage.width / imageAttrs.imageInfo.width;
|
|
20543
20675
|
internalImage.width(imageAttrs.uncroppedImage.width);
|
|
20544
20676
|
internalImage.height(imageAttrs.uncroppedImage.height);
|
|
@@ -20555,7 +20687,7 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
20555
20687
|
internalImage.height(imageAttrs.cropSize.height);
|
|
20556
20688
|
this.cachedCropInfo[imageAttrs.id ?? ""] = imageAttrs.cropInfo;
|
|
20557
20689
|
}
|
|
20558
|
-
if (image && internalImage && !imageAttrs.adding && !imageAttrs.cropInfo && !(0, import_lodash.isEqual)(imageAttrs.cropInfo, this.cachedCropInfo[imageAttrs.id ?? ""])) {
|
|
20690
|
+
if (image && internalImage && !imageAttrs.adding && !imageAttrs.cropInfo && !(0, import_lodash$1.isEqual)(imageAttrs.cropInfo, this.cachedCropInfo[imageAttrs.id ?? ""])) {
|
|
20559
20691
|
internalImage.width(imageAttrs.uncroppedImage.width);
|
|
20560
20692
|
internalImage.height(imageAttrs.uncroppedImage.height);
|
|
20561
20693
|
internalImage.rotation(0);
|
|
@@ -20970,8 +21102,12 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
20970
21102
|
clonedSA.scaleY(1);
|
|
20971
21103
|
e.cancelBubble = true;
|
|
20972
21104
|
};
|
|
20973
|
-
selectorArea.on("transform", (0, import_lodash.throttle)(handleSelectorAreaTransform, 50));
|
|
20974
21105
|
selectorArea.on("transformend", (e) => {
|
|
21106
|
+
this.instance.emitEvent("onTransform", e.target);
|
|
21107
|
+
});
|
|
21108
|
+
selectorArea.on("transform", (0, import_lodash$1.throttle)(handleSelectorAreaTransform, 50));
|
|
21109
|
+
selectorArea.on("transformend", (e) => {
|
|
21110
|
+
this.instance.emitEvent("onTransform", null);
|
|
20975
21111
|
const nodesSnappingPlugin = this.instance.getPlugin("nodesSnapping");
|
|
20976
21112
|
if (nodesSnappingPlugin) nodesSnappingPlugin.cleanupEvaluateGuidelines();
|
|
20977
21113
|
const scaleX = selectorArea.scaleX();
|
|
@@ -22812,7 +22948,7 @@ var require_hammer = __commonJS({ "../../node_modules/hammerjs/hammer.js"(export
|
|
|
22812
22948
|
else window$1[exportName] = Hammer;
|
|
22813
22949
|
})(window, document, "Hammer");
|
|
22814
22950
|
} });
|
|
22815
|
-
var import_hammer = __toESM(require_hammer()
|
|
22951
|
+
var import_hammer = __toESM(require_hammer());
|
|
22816
22952
|
|
|
22817
22953
|
//#endregion
|
|
22818
22954
|
//#region src/plugins/stage-zoom/stage-zoom.ts
|
|
@@ -22852,7 +22988,7 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
|
|
|
22852
22988
|
this.config.zoomSteps = [minimumZoom, ...this.config.zoomSteps];
|
|
22853
22989
|
}
|
|
22854
22990
|
};
|
|
22855
|
-
mainLayer?.on("draw", (0, import_lodash.throttle)(handleDraw, 50));
|
|
22991
|
+
mainLayer?.on("draw", (0, import_lodash$1.throttle)(handleDraw, 50));
|
|
22856
22992
|
this.setZoom(this.config.zoomSteps[this.actualStep]);
|
|
22857
22993
|
}
|
|
22858
22994
|
setZoom(scale, centered = true, pointer) {
|
|
@@ -22983,7 +23119,9 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
|
|
|
22983
23119
|
x: 0,
|
|
22984
23120
|
y: 0
|
|
22985
23121
|
});
|
|
22986
|
-
|
|
23122
|
+
let realNodes = mainLayer.getChildren();
|
|
23123
|
+
realNodes = realNodes.filter((node) => typeof node.getAttrs().visible === "undefined" || node.getAttrs().visible);
|
|
23124
|
+
const bounds = getBoundingBox(stage, realNodes);
|
|
22987
23125
|
const stageWidth = stage.width();
|
|
22988
23126
|
const stageHeight = stage.height();
|
|
22989
23127
|
const scaleX = (stageWidth - this.config.fitToScreen.padding * 2) / bounds.width;
|
|
@@ -23293,12 +23431,14 @@ var WeaveMoveToolAction = class extends WeaveAction {
|
|
|
23293
23431
|
stage.container().focus();
|
|
23294
23432
|
this.setState(MOVE_TOOL_STATE.MOVING);
|
|
23295
23433
|
}
|
|
23296
|
-
trigger(cancelAction) {
|
|
23434
|
+
trigger(cancelAction, params) {
|
|
23297
23435
|
if (!this.instance) throw new Error("Instance not defined");
|
|
23298
23436
|
if (!this.initialized) this.setupEvents();
|
|
23299
23437
|
const stage = this.instance.getStage();
|
|
23300
23438
|
stage.container().tabIndex = 1;
|
|
23301
23439
|
stage.container().focus();
|
|
23440
|
+
const { triggerSelectionTool = true } = params ?? {};
|
|
23441
|
+
this.triggerSelectionTool = triggerSelectionTool;
|
|
23302
23442
|
this.cancelAction = cancelAction;
|
|
23303
23443
|
this.setMoving();
|
|
23304
23444
|
}
|
|
@@ -23306,7 +23446,7 @@ var WeaveMoveToolAction = class extends WeaveAction {
|
|
|
23306
23446
|
const stage = this.instance.getStage();
|
|
23307
23447
|
stage.container().style.cursor = "default";
|
|
23308
23448
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
23309
|
-
if (selectionPlugin) this.instance.triggerAction(SELECTION_TOOL_ACTION_NAME);
|
|
23449
|
+
if (selectionPlugin && this.triggerSelectionTool) this.instance.triggerAction(SELECTION_TOOL_ACTION_NAME);
|
|
23310
23450
|
this.setState(MOVE_TOOL_STATE.IDLE);
|
|
23311
23451
|
}
|
|
23312
23452
|
};
|
|
@@ -25453,7 +25593,7 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
|
|
|
25453
25593
|
if (!this.enabled || !(this.isSpaceKeyPressed || this.isMouseMiddleButtonPressed || this.moveToolActive)) return;
|
|
25454
25594
|
this.onRender();
|
|
25455
25595
|
};
|
|
25456
|
-
stage.on("pointermove", (0, import_lodash.throttle)(handleMouseMove, 50));
|
|
25596
|
+
stage.on("pointermove", (0, import_lodash$1.throttle)(handleMouseMove, 50));
|
|
25457
25597
|
stage.on("pointermove", () => {
|
|
25458
25598
|
if (!this.enabled) return;
|
|
25459
25599
|
this.onRender();
|
|
@@ -25748,7 +25888,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
25748
25888
|
stage.y(stage.y() - deltaY);
|
|
25749
25889
|
this.instance.emitEvent("onStageMove");
|
|
25750
25890
|
};
|
|
25751
|
-
stage.on("pointermove", (0, import_lodash.throttle)(handleMouseMove, 50));
|
|
25891
|
+
stage.on("pointermove", (0, import_lodash$1.throttle)(handleMouseMove, 50));
|
|
25752
25892
|
stage.on("pointerdown", () => {
|
|
25753
25893
|
const mousePos = stage.getPointerPosition();
|
|
25754
25894
|
previousMouseX = mousePos?.x ?? 0;
|
|
@@ -25864,7 +26004,7 @@ var WeaveConnectedUsersPlugin = class extends WeavePlugin {
|
|
|
25864
26004
|
newConnectedUsers[userInformation.name] = userInformation;
|
|
25865
26005
|
}
|
|
25866
26006
|
}
|
|
25867
|
-
if (!(0, import_lodash.isEqual)(this.connectedUsers, newConnectedUsers)) this.instance.emitEvent("onConnectedUsersChange", newConnectedUsers);
|
|
26007
|
+
if (!(0, import_lodash$1.isEqual)(this.connectedUsers, newConnectedUsers)) this.instance.emitEvent("onConnectedUsersChange", newConnectedUsers);
|
|
25868
26008
|
this.connectedUsers = newConnectedUsers;
|
|
25869
26009
|
});
|
|
25870
26010
|
}
|