@inditextech/weave-sdk 0.14.2 → 0.15.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 +107 -44
- package/dist/sdk.d.cts +8 -16
- package/dist/sdk.d.ts +8 -16
- package/dist/sdk.js +107 -44
- package/package.json +2 -2
package/dist/sdk.cjs
CHANGED
|
@@ -15506,6 +15506,7 @@ var WeaveStore = class {
|
|
|
15506
15506
|
this.instance = instance;
|
|
15507
15507
|
this.logger = this.instance.getChildLogger(this.getName());
|
|
15508
15508
|
this.instance.getMainLogger().info(`Store with name [${this.getName()}] registered`);
|
|
15509
|
+
this.instance.emitEvent("onRoomLoaded", this.isRoomLoaded);
|
|
15509
15510
|
return this;
|
|
15510
15511
|
}
|
|
15511
15512
|
getUser() {
|
|
@@ -15530,8 +15531,7 @@ var WeaveStore = class {
|
|
|
15530
15531
|
return JSON.parse(JSON.stringify(this.state, void 0, 2));
|
|
15531
15532
|
}
|
|
15532
15533
|
setup() {
|
|
15533
|
-
|
|
15534
|
-
config.callbacks?.onRoomLoaded?.(this.isRoomLoaded);
|
|
15534
|
+
this.isRoomLoaded = false;
|
|
15535
15535
|
this.instance.emitEvent("onRoomLoaded", this.isRoomLoaded);
|
|
15536
15536
|
if (this.supportsUndoManager) {
|
|
15537
15537
|
const weaveStateValues = (0, __syncedstore_core.getYjsValue)(
|
|
@@ -15552,7 +15552,6 @@ var WeaveStore = class {
|
|
|
15552
15552
|
redoStackLength: this.undoManager.redoStack.length,
|
|
15553
15553
|
undoStackLength: this.undoManager.undoStack.length
|
|
15554
15554
|
};
|
|
15555
|
-
config.callbacks?.onUndoManagerStatusChange?.(change);
|
|
15556
15555
|
this.instance.emitEvent("onUndoManagerStatusChange", change);
|
|
15557
15556
|
});
|
|
15558
15557
|
this.undoManager.on("stack-item-popped", () => {
|
|
@@ -15562,14 +15561,12 @@ var WeaveStore = class {
|
|
|
15562
15561
|
redoStackLength: this.undoManager.redoStack.length,
|
|
15563
15562
|
undoStackLength: this.undoManager.undoStack.length
|
|
15564
15563
|
};
|
|
15565
|
-
config.callbacks?.onUndoManagerStatusChange?.(change);
|
|
15566
15564
|
this.instance.emitEvent("onUndoManagerStatusChange", change);
|
|
15567
15565
|
});
|
|
15568
15566
|
}
|
|
15569
15567
|
}
|
|
15570
15568
|
(0, __syncedstore_core.observeDeep)(this.getState(), () => {
|
|
15571
15569
|
const newState = JSON.parse(JSON.stringify(this.getState()));
|
|
15572
|
-
config.callbacks?.onStateChange?.(newState);
|
|
15573
15570
|
this.instance.emitEvent("onStateChange", newState);
|
|
15574
15571
|
const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
15575
15572
|
if (this.isRoomLoaded && nodesSelectionPlugin && nodesSelectionPlugin.getSelectedNodes().length === 1) {
|
|
@@ -15583,7 +15580,6 @@ var WeaveStore = class {
|
|
|
15583
15580
|
if (!this.isRoomLoaded && !(0, import_lodash.isEmpty)(this.state.weave)) {
|
|
15584
15581
|
this.instance.setupRenderer();
|
|
15585
15582
|
this.isRoomLoaded = true;
|
|
15586
|
-
config.callbacks?.onRoomLoaded?.(this.isRoomLoaded);
|
|
15587
15583
|
this.instance.emitEvent("onRoomLoaded", this.isRoomLoaded);
|
|
15588
15584
|
}
|
|
15589
15585
|
if (this.isRoomLoaded && !(0, import_lodash.isEmpty)(this.state.weave)) this.instance.render();
|
|
@@ -15790,7 +15786,7 @@ function moveNodeToContainer(instance, node) {
|
|
|
15790
15786
|
const nodeHandler = instance.getNodeHandler(node.getAttrs().nodeType);
|
|
15791
15787
|
const actualNode = nodeHandler.serialize(node);
|
|
15792
15788
|
instance.removeNode(actualNode);
|
|
15793
|
-
instance.addNode(actualNode, layerToMove
|
|
15789
|
+
instance.addNode(actualNode, layerToMove.getAttrs().id);
|
|
15794
15790
|
}
|
|
15795
15791
|
return layerToMove;
|
|
15796
15792
|
}
|
|
@@ -16459,14 +16455,14 @@ var WeaveNode = class {
|
|
|
16459
16455
|
clearContainerTargets(this.instance);
|
|
16460
16456
|
const layerToMove = checkIfOverContainer(this.instance, e.target);
|
|
16461
16457
|
if (layerToMove) layerToMove.fire(__inditextech_weave_types.WEAVE_NODE_CUSTOM_EVENTS.onTargetEnter, { bubbles: true });
|
|
16462
|
-
this.instance.updateNode(this.serialize(
|
|
16458
|
+
this.instance.updateNode(this.serialize(e.target));
|
|
16463
16459
|
}
|
|
16464
16460
|
});
|
|
16465
16461
|
node.on("dragend", (e) => {
|
|
16466
16462
|
if (this.isSelecting() && this.isNodeSelected(node)) {
|
|
16467
16463
|
clearContainerTargets(this.instance);
|
|
16468
|
-
const
|
|
16469
|
-
if (
|
|
16464
|
+
const containerToMove = moveNodeToContainer(this.instance, e.target);
|
|
16465
|
+
if (containerToMove) return;
|
|
16470
16466
|
this.instance.updateNode(this.serialize(node));
|
|
16471
16467
|
}
|
|
16472
16468
|
});
|
|
@@ -17166,6 +17162,8 @@ var WeaveTargetingManager = class {
|
|
|
17166
17162
|
};
|
|
17167
17163
|
let measureContainer = mainLayer;
|
|
17168
17164
|
let container = mainLayer;
|
|
17165
|
+
const nodesSelection = this.instance.getPlugin("nodesSelection");
|
|
17166
|
+
if (nodesSelection) nodesSelection.disable();
|
|
17169
17167
|
const intersectedNode = stage.getIntersection(relativeMousePointer);
|
|
17170
17168
|
if (intersectedNode) {
|
|
17171
17169
|
const node = this.instance.getInstanceRecursive(intersectedNode, ["group"]);
|
|
@@ -17185,6 +17183,7 @@ var WeaveTargetingManager = class {
|
|
|
17185
17183
|
x: 0,
|
|
17186
17184
|
y: 0
|
|
17187
17185
|
};
|
|
17186
|
+
if (nodesSelection) nodesSelection.enable();
|
|
17188
17187
|
return {
|
|
17189
17188
|
mousePoint: relativeMousePointer,
|
|
17190
17189
|
container,
|
|
@@ -17913,7 +17912,7 @@ var WeaveRegisterManager = class {
|
|
|
17913
17912
|
|
|
17914
17913
|
//#endregion
|
|
17915
17914
|
//#region package.json
|
|
17916
|
-
var version = "0.
|
|
17915
|
+
var version = "0.15.0";
|
|
17917
17916
|
|
|
17918
17917
|
//#endregion
|
|
17919
17918
|
//#region src/managers/setup.ts
|
|
@@ -18032,7 +18031,6 @@ var WeaveActionsManager = class {
|
|
|
18032
18031
|
return this.activeAction;
|
|
18033
18032
|
}
|
|
18034
18033
|
triggerAction(actionName, params) {
|
|
18035
|
-
const config = this.instance.getConfiguration();
|
|
18036
18034
|
const actionsHandlers = this.instance.getActionsHandlers();
|
|
18037
18035
|
if (!actionsHandlers[actionName]) {
|
|
18038
18036
|
const msg = `Action handler with name [${actionName}] not registered`;
|
|
@@ -18042,7 +18040,6 @@ var WeaveActionsManager = class {
|
|
|
18042
18040
|
if (typeof this.activeAction !== "undefined") this.cancelAction(this.activeAction);
|
|
18043
18041
|
this.activeAction = actionName;
|
|
18044
18042
|
const payload = actionsHandlers[actionName].trigger(this.cancelActionCallback(actionName), params);
|
|
18045
|
-
config.callbacks?.onActiveActionChange?.(this.activeAction);
|
|
18046
18043
|
this.instance.emitEvent("onActiveActionChange", this.activeAction);
|
|
18047
18044
|
return payload;
|
|
18048
18045
|
}
|
|
@@ -18077,7 +18074,6 @@ var WeaveActionsManager = class {
|
|
|
18077
18074
|
return actionsHandlers[actionName].getProps?.();
|
|
18078
18075
|
}
|
|
18079
18076
|
cancelAction(actionName) {
|
|
18080
|
-
const config = this.instance.getConfiguration();
|
|
18081
18077
|
const actionsHandlers = this.instance.getActionsHandlers();
|
|
18082
18078
|
if (!actionsHandlers[actionName]) {
|
|
18083
18079
|
const msg = `Action handler with name [${actionName}] not registered`;
|
|
@@ -18086,7 +18082,6 @@ var WeaveActionsManager = class {
|
|
|
18086
18082
|
}
|
|
18087
18083
|
this.activeAction = void 0;
|
|
18088
18084
|
actionsHandlers[actionName].cleanup?.();
|
|
18089
|
-
config.callbacks?.onActiveActionChange?.(this.activeAction);
|
|
18090
18085
|
this.instance.emitEvent("onActiveActionChange", this.activeAction);
|
|
18091
18086
|
}
|
|
18092
18087
|
cancelActionCallback(actionName) {
|
|
@@ -18310,7 +18305,6 @@ var Weave = class extends Emittery {
|
|
|
18310
18305
|
this.setupManager.setupActions();
|
|
18311
18306
|
this.moduleLogger.info("Instance started");
|
|
18312
18307
|
this.status = __inditextech_weave_types.WEAVE_INSTANCE_STATUS.RUNNING;
|
|
18313
|
-
this.getConfiguration().callbacks?.onInstanceStatus?.(this.status);
|
|
18314
18308
|
this.emitEvent("onInstanceStatus", this.status);
|
|
18315
18309
|
});
|
|
18316
18310
|
}
|
|
@@ -18325,15 +18319,14 @@ var Weave = class extends Emittery {
|
|
|
18325
18319
|
}
|
|
18326
18320
|
async start() {
|
|
18327
18321
|
this.moduleLogger.info("Start instance");
|
|
18322
|
+
this.emitEvent("onRoomLoaded", false);
|
|
18328
18323
|
this.status = __inditextech_weave_types.WEAVE_INSTANCE_STATUS.STARTING;
|
|
18329
|
-
this.getConfiguration().callbacks?.onInstanceStatus?.(this.status);
|
|
18330
18324
|
this.emitEvent("onInstanceStatus", this.status);
|
|
18331
18325
|
this.registerManager.registerNodesHandlers();
|
|
18332
18326
|
this.registerManager.registerPlugins();
|
|
18333
18327
|
this.registerManager.registerActionsHandlers();
|
|
18334
18328
|
this.storeManager.registerStore(this.config.store);
|
|
18335
18329
|
this.status = __inditextech_weave_types.WEAVE_INSTANCE_STATUS.LOADING_FONTS;
|
|
18336
|
-
this.getConfiguration().callbacks?.onInstanceStatus?.(this.status);
|
|
18337
18330
|
this.emitEvent("onInstanceStatus", this.status);
|
|
18338
18331
|
await this.fontsManager.loadFonts();
|
|
18339
18332
|
this.setupManager.setupLog();
|
|
@@ -18342,6 +18335,17 @@ var Weave = class extends Emittery {
|
|
|
18342
18335
|
store.setup();
|
|
18343
18336
|
store.connect();
|
|
18344
18337
|
}
|
|
18338
|
+
destroy() {
|
|
18339
|
+
this.moduleLogger.info(`Destroying the instance`);
|
|
18340
|
+
this.clearListeners();
|
|
18341
|
+
this.status = __inditextech_weave_types.WEAVE_INSTANCE_STATUS.IDLE;
|
|
18342
|
+
this.emitEvent("onInstanceStatus", this.status);
|
|
18343
|
+
const store = this.storeManager.getStore();
|
|
18344
|
+
store.disconnect();
|
|
18345
|
+
const stage = this.getStage();
|
|
18346
|
+
if (stage) stage.destroy();
|
|
18347
|
+
this.moduleLogger.info(`Instance destroyed`);
|
|
18348
|
+
}
|
|
18345
18349
|
getId() {
|
|
18346
18350
|
return this.id;
|
|
18347
18351
|
}
|
|
@@ -18456,13 +18460,11 @@ var Weave = class extends Emittery {
|
|
|
18456
18460
|
update(newState) {
|
|
18457
18461
|
this.getStore().setState(newState);
|
|
18458
18462
|
this.renderer.render(() => {
|
|
18459
|
-
this.config.callbacks?.onRender?.();
|
|
18460
18463
|
this.emitEvent("onRender", {});
|
|
18461
18464
|
});
|
|
18462
18465
|
}
|
|
18463
18466
|
render() {
|
|
18464
18467
|
this.renderer.render(() => {
|
|
18465
|
-
this.config.callbacks?.onRender?.();
|
|
18466
18468
|
this.emitEvent("onRender", {});
|
|
18467
18469
|
});
|
|
18468
18470
|
}
|
|
@@ -19648,7 +19650,7 @@ const WEAVE_FRAME_NODE_DEFAULT_CONFIG = {
|
|
|
19648
19650
|
},
|
|
19649
19651
|
onTargetEnter: {
|
|
19650
19652
|
borderColor: "#ff6863ff",
|
|
19651
|
-
fill: "#
|
|
19653
|
+
fill: "#ffffffff"
|
|
19652
19654
|
}
|
|
19653
19655
|
};
|
|
19654
19656
|
const WEAVE_FRAME_NODE_DEFAULT_PROPS = {
|
|
@@ -19699,21 +19701,21 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
19699
19701
|
id,
|
|
19700
19702
|
containerId: `${id}-group-internal`,
|
|
19701
19703
|
containerOffsetX: 0,
|
|
19702
|
-
containerOffsetY: titleHeight
|
|
19703
|
-
width: props.frameWidth
|
|
19704
|
-
height: props.frameHeight + titleHeight
|
|
19704
|
+
containerOffsetY: titleHeight,
|
|
19705
|
+
width: props.frameWidth,
|
|
19706
|
+
height: props.frameHeight + titleHeight,
|
|
19705
19707
|
fill: "#ffffffff",
|
|
19706
19708
|
clipX: 0,
|
|
19707
19709
|
clipY: 0,
|
|
19708
|
-
clipWidth: props.frameWidth
|
|
19709
|
-
clipHeight: props.frameHeight + titleHeight
|
|
19710
|
+
clipWidth: props.frameWidth,
|
|
19711
|
+
clipHeight: props.frameHeight + titleHeight,
|
|
19710
19712
|
name: "node"
|
|
19711
19713
|
});
|
|
19712
19714
|
const background = new konva.default.Rect({
|
|
19713
19715
|
id: `${id}-bg`,
|
|
19714
19716
|
nodeId: id,
|
|
19715
|
-
x:
|
|
19716
|
-
y: titleHeight
|
|
19717
|
+
x: 0,
|
|
19718
|
+
y: titleHeight,
|
|
19717
19719
|
width: props.frameWidth,
|
|
19718
19720
|
stroke: borderColor,
|
|
19719
19721
|
strokeWidth: borderWidth,
|
|
@@ -19744,18 +19746,18 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
19744
19746
|
const frameInternal = new konva.default.Group({
|
|
19745
19747
|
id: `${id}-group-internal`,
|
|
19746
19748
|
nodeId: id,
|
|
19747
|
-
x:
|
|
19748
|
-
y: titleHeight
|
|
19749
|
+
x: 0,
|
|
19750
|
+
y: titleHeight,
|
|
19749
19751
|
width: props.frameWidth,
|
|
19750
19752
|
height: props.frameHeight,
|
|
19751
19753
|
draggable: false,
|
|
19752
19754
|
stroke: "transparent",
|
|
19753
19755
|
strokeScaleEnabled: false,
|
|
19754
|
-
borderWidth,
|
|
19756
|
+
borderWidth: 0,
|
|
19755
19757
|
clipX: 0,
|
|
19756
19758
|
clipY: 0,
|
|
19757
|
-
clipWidth: props.frameWidth
|
|
19758
|
-
clipHeight: props.frameHeight
|
|
19759
|
+
clipWidth: props.frameWidth,
|
|
19760
|
+
clipHeight: props.frameHeight
|
|
19759
19761
|
});
|
|
19760
19762
|
frame.add(frameInternal);
|
|
19761
19763
|
this.setupDefaultNodeEvents(frame);
|
|
@@ -21386,6 +21388,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
21386
21388
|
this.isMouseMiddleButtonPressed = false;
|
|
21387
21389
|
this.isCtrlOrMetaPressed = false;
|
|
21388
21390
|
this.isSpaceKeyPressed = false;
|
|
21391
|
+
this.overStage = false;
|
|
21389
21392
|
this.previousPointer = null;
|
|
21390
21393
|
}
|
|
21391
21394
|
getName() {
|
|
@@ -21426,6 +21429,12 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
21426
21429
|
this.disableMove();
|
|
21427
21430
|
}
|
|
21428
21431
|
});
|
|
21432
|
+
stage.on("mouseenter", () => {
|
|
21433
|
+
this.overStage = true;
|
|
21434
|
+
});
|
|
21435
|
+
stage.on("mouseleave", () => {
|
|
21436
|
+
this.overStage = false;
|
|
21437
|
+
});
|
|
21429
21438
|
stage.on("mousedown", (e) => {
|
|
21430
21439
|
const activeAction = this.instance.getActiveAction();
|
|
21431
21440
|
let enableMove = false;
|
|
@@ -21495,7 +21504,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
21495
21504
|
this.instance.emit("onStageMove", void 0);
|
|
21496
21505
|
});
|
|
21497
21506
|
window.addEventListener("wheel", (e) => {
|
|
21498
|
-
if (!this.enabled || this.isCtrlOrMetaPressed || this.isSpaceKeyPressed || this.isMouseMiddleButtonPressed) return;
|
|
21507
|
+
if (!this.enabled || !this.overStage || this.isCtrlOrMetaPressed || this.isSpaceKeyPressed || this.isMouseMiddleButtonPressed) return;
|
|
21499
21508
|
stage.x(stage.x() - e.deltaX);
|
|
21500
21509
|
stage.y(stage.y() - e.deltaY);
|
|
21501
21510
|
this.instance.emit("stageMove", void 0);
|
|
@@ -21901,24 +21910,60 @@ var WeaveNodesSnappingPlugin = class extends WeavePlugin {
|
|
|
21901
21910
|
setEnabled(enabled) {
|
|
21902
21911
|
this.enabled = enabled;
|
|
21903
21912
|
}
|
|
21913
|
+
getSelectedNodesMetadata(transformer) {
|
|
21914
|
+
const firstNode = transformer.getNodes()[0];
|
|
21915
|
+
const firstNodeClientRect = firstNode.getClientRect();
|
|
21916
|
+
const rectCoordsMin = {
|
|
21917
|
+
x: firstNodeClientRect.x,
|
|
21918
|
+
y: firstNodeClientRect.y
|
|
21919
|
+
};
|
|
21920
|
+
const rectCoordsMax = {
|
|
21921
|
+
x: firstNodeClientRect.x + firstNodeClientRect.width,
|
|
21922
|
+
y: firstNodeClientRect.y + firstNodeClientRect.height
|
|
21923
|
+
};
|
|
21924
|
+
const nodes = [];
|
|
21925
|
+
for (const node of transformer.getNodes()) {
|
|
21926
|
+
const clientRect = node.getClientRect();
|
|
21927
|
+
if (clientRect.x < rectCoordsMin.x) rectCoordsMin.x = clientRect.x;
|
|
21928
|
+
if (clientRect.y < rectCoordsMin.y) rectCoordsMin.y = clientRect.y;
|
|
21929
|
+
if (clientRect.x + clientRect.width > rectCoordsMax.x) rectCoordsMax.x = clientRect.x + clientRect.width;
|
|
21930
|
+
if (clientRect.y + clientRect.height > rectCoordsMax.y) rectCoordsMax.y = clientRect.y + clientRect.height;
|
|
21931
|
+
nodes.push(node.getAttrs().id);
|
|
21932
|
+
}
|
|
21933
|
+
return {
|
|
21934
|
+
width: rectCoordsMax.x - rectCoordsMin.x,
|
|
21935
|
+
height: rectCoordsMax.y - rectCoordsMin.y,
|
|
21936
|
+
nodes
|
|
21937
|
+
};
|
|
21938
|
+
}
|
|
21904
21939
|
evaluateGuidelines(e) {
|
|
21905
21940
|
const utilityLayer = this.instance.getUtilityLayer();
|
|
21906
21941
|
if (!this.enabled) return;
|
|
21907
21942
|
if (!utilityLayer) return;
|
|
21943
|
+
const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
21944
|
+
let skipNodes = [];
|
|
21908
21945
|
let node = void 0;
|
|
21909
|
-
if (e.type === "dragmove" && e.target instanceof konva.default.Transformer) {
|
|
21946
|
+
if (e.type === "dragmove" && nodesSelectionPlugin && e.target instanceof konva.default.Transformer && e.target.getNodes().length === 1) {
|
|
21910
21947
|
const actualTarget = e.target;
|
|
21911
21948
|
node = actualTarget.getNodes()[0];
|
|
21949
|
+
skipNodes.push(node.getAttrs().id ?? "");
|
|
21950
|
+
}
|
|
21951
|
+
if (e.type === "dragmove" && nodesSelectionPlugin && e.target instanceof konva.default.Transformer && e.target.getNodes().length > 1) {
|
|
21952
|
+
const { nodes } = this.getSelectedNodesMetadata(e.target);
|
|
21953
|
+
node = e.target;
|
|
21954
|
+
skipNodes = [...nodes];
|
|
21912
21955
|
}
|
|
21913
21956
|
if (e.type === "transform") node = e.target;
|
|
21914
21957
|
if (typeof node === "undefined") return;
|
|
21915
|
-
const lineGuideStops = this.getLineGuideStops(
|
|
21958
|
+
const lineGuideStops = this.getLineGuideStops(skipNodes);
|
|
21916
21959
|
const itemBounds = this.getObjectSnappingEdges(node);
|
|
21917
21960
|
const guides = this.getGuides(lineGuideStops, itemBounds, e.type);
|
|
21961
|
+
utilityLayer.destroyChildren();
|
|
21918
21962
|
if (!guides.length) return;
|
|
21919
21963
|
utilityLayer.find(`.${GUIDE_LINE_NAME}`).forEach((l) => l.destroy());
|
|
21920
21964
|
this.drawGuides(guides);
|
|
21921
21965
|
if (e.type === "dragmove") {
|
|
21966
|
+
const orgAbsPos = node.absolutePosition();
|
|
21922
21967
|
const absPos = node.absolutePosition();
|
|
21923
21968
|
guides.forEach((lg) => {
|
|
21924
21969
|
switch (lg.orientation) {
|
|
@@ -21932,12 +21977,24 @@ var WeaveNodesSnappingPlugin = class extends WeavePlugin {
|
|
|
21932
21977
|
}
|
|
21933
21978
|
}
|
|
21934
21979
|
});
|
|
21935
|
-
|
|
21980
|
+
const vecDiff = {
|
|
21981
|
+
x: orgAbsPos.x - absPos.x,
|
|
21982
|
+
y: orgAbsPos.y - absPos.y
|
|
21983
|
+
};
|
|
21984
|
+
if (node instanceof konva.default.Transformer) node.getNodes().forEach((n) => {
|
|
21985
|
+
const nodeAbsPos = n.getAbsolutePosition();
|
|
21986
|
+
const newPos = {
|
|
21987
|
+
x: nodeAbsPos.x - vecDiff.x,
|
|
21988
|
+
y: nodeAbsPos.y - vecDiff.y
|
|
21989
|
+
};
|
|
21990
|
+
n.setAbsolutePosition(newPos);
|
|
21991
|
+
});
|
|
21992
|
+
else node.absolutePosition(absPos);
|
|
21936
21993
|
}
|
|
21937
21994
|
if (e.type === "transform") {
|
|
21938
|
-
const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
21939
|
-
if (nodesSelectionPlugin) {
|
|
21940
|
-
const transformer = nodesSelectionPlugin.getTransformer();
|
|
21995
|
+
const nodesSelectionPlugin$1 = this.instance.getPlugin("nodesSelection");
|
|
21996
|
+
if (nodesSelectionPlugin$1) {
|
|
21997
|
+
const transformer = nodesSelectionPlugin$1.getTransformer();
|
|
21941
21998
|
transformer.anchorDragBoundFunc((_, newAbsPos) => {
|
|
21942
21999
|
const finalPos = { ...newAbsPos };
|
|
21943
22000
|
for (const lg of guides) switch (lg.orientation) {
|
|
@@ -21961,7 +22018,7 @@ var WeaveNodesSnappingPlugin = class extends WeavePlugin {
|
|
|
21961
22018
|
const utilityLayer = this.instance.getUtilityLayer();
|
|
21962
22019
|
if (!this.enabled) return;
|
|
21963
22020
|
if (!utilityLayer) return;
|
|
21964
|
-
utilityLayer.
|
|
22021
|
+
utilityLayer.destroyChildren();
|
|
21965
22022
|
}
|
|
21966
22023
|
initEvents() {
|
|
21967
22024
|
const stage = this.instance.getStage();
|
|
@@ -21971,7 +22028,7 @@ var WeaveNodesSnappingPlugin = class extends WeavePlugin {
|
|
|
21971
22028
|
stage.on("dragend", this.cleanupEvaluateGuidelines.bind(this));
|
|
21972
22029
|
}
|
|
21973
22030
|
}
|
|
21974
|
-
getLineGuideStops(
|
|
22031
|
+
getLineGuideStops(skipNodes) {
|
|
21975
22032
|
const stage = this.instance.getStage();
|
|
21976
22033
|
const nodesSelection = this.instance.getPlugin("nodesSelection");
|
|
21977
22034
|
if (nodesSelection) nodesSelection.getTransformer().hide();
|
|
@@ -21986,7 +22043,7 @@ var WeaveNodesSnappingPlugin = class extends WeavePlugin {
|
|
|
21986
22043
|
stage.height()
|
|
21987
22044
|
];
|
|
21988
22045
|
stage.find(".node").forEach((guideItem) => {
|
|
21989
|
-
if (guideItem
|
|
22046
|
+
if (skipNodes.includes(guideItem.getAttrs().id ?? "")) return;
|
|
21990
22047
|
const box = guideItem.getClientRect({ skipStroke: true });
|
|
21991
22048
|
vertical.push([
|
|
21992
22049
|
box.x,
|
|
@@ -22006,7 +22063,13 @@ var WeaveNodesSnappingPlugin = class extends WeavePlugin {
|
|
|
22006
22063
|
};
|
|
22007
22064
|
}
|
|
22008
22065
|
getObjectSnappingEdges(node) {
|
|
22009
|
-
|
|
22066
|
+
let box = node.getClientRect({ skipStroke: true });
|
|
22067
|
+
if (node instanceof konva.default.Transformer) {
|
|
22068
|
+
const transformerRect = node.getChildren((node$1) => {
|
|
22069
|
+
return node$1.getAttrs().name === "back";
|
|
22070
|
+
})[0];
|
|
22071
|
+
box = transformerRect.getClientRect({ skipStroke: true });
|
|
22072
|
+
}
|
|
22010
22073
|
const absPos = node.absolutePosition();
|
|
22011
22074
|
const snappingEdges = {
|
|
22012
22075
|
vertical: [
|
package/dist/sdk.d.cts
CHANGED
|
@@ -63,7 +63,6 @@ type WeaveConfig = {
|
|
|
63
63
|
actions?: WeaveActionBase[];
|
|
64
64
|
plugins?: WeavePluginBase[];
|
|
65
65
|
fonts?: WeaveFont[];
|
|
66
|
-
callbacks?: WeaveCallbacks;
|
|
67
66
|
logger?: WeaveLoggerConfig;
|
|
68
67
|
};
|
|
69
68
|
type WeaveStatusKeys = keyof typeof WEAVE_INSTANCE_STATUS;
|
|
@@ -141,20 +140,6 @@ type WeaveUndoManagerOptions = {
|
|
|
141
140
|
captureTimeout?: number;
|
|
142
141
|
trackedOrigins?: Set<any>;
|
|
143
142
|
};
|
|
144
|
-
type WeaveUndoRedoChange = {
|
|
145
|
-
canRedo: boolean;
|
|
146
|
-
canUndo: boolean;
|
|
147
|
-
redoStackLength: number;
|
|
148
|
-
undoStackLength: number;
|
|
149
|
-
};
|
|
150
|
-
type WeaveCallbacks = {
|
|
151
|
-
onRender?: () => void;
|
|
152
|
-
onRoomLoaded?: (loaded: boolean) => void;
|
|
153
|
-
onInstanceStatus?: (status: WeaveStatus) => void;
|
|
154
|
-
onActiveActionChange?: (actionName: string | undefined) => void;
|
|
155
|
-
onStateChange?: (state: WeaveState) => void;
|
|
156
|
-
onUndoManagerStatusChange?: (undoManagerStatus: WeaveUndoRedoChange) => void;
|
|
157
|
-
};
|
|
158
143
|
declare type docElementTypeDescription = "xml" | "text" | Array<any> | object;
|
|
159
144
|
declare type DocTypeDescription = {
|
|
160
145
|
[key: string]: docElementTypeDescription;
|
|
@@ -393,6 +378,7 @@ declare class Weave extends Emittery {
|
|
|
393
378
|
getStatus(): WeaveStatus;
|
|
394
379
|
setStore(store: WeaveStore): void;
|
|
395
380
|
start(): Promise<void>;
|
|
381
|
+
destroy(): void;
|
|
396
382
|
getId(): string;
|
|
397
383
|
getConfiguration(): WeaveConfig;
|
|
398
384
|
emitEvent<T>(event: string, payload?: T): void;
|
|
@@ -1177,6 +1163,7 @@ declare class WeaveStagePanningPlugin extends WeavePlugin {
|
|
|
1177
1163
|
private isMouseMiddleButtonPressed;
|
|
1178
1164
|
private isCtrlOrMetaPressed;
|
|
1179
1165
|
private isSpaceKeyPressed;
|
|
1166
|
+
private overStage;
|
|
1180
1167
|
protected previousPointer: string | null;
|
|
1181
1168
|
getLayerName: undefined;
|
|
1182
1169
|
initLayer: undefined;
|
|
@@ -1510,10 +1497,15 @@ declare class WeaveNodesSnappingPlugin extends WeavePlugin {
|
|
|
1510
1497
|
getName(): string;
|
|
1511
1498
|
onInit(): void;
|
|
1512
1499
|
setEnabled(enabled: boolean): void;
|
|
1500
|
+
getSelectedNodesMetadata(transformer: Konva.Transformer): {
|
|
1501
|
+
width: number;
|
|
1502
|
+
height: number;
|
|
1503
|
+
nodes: string[];
|
|
1504
|
+
};
|
|
1513
1505
|
evaluateGuidelines(e: KonvaEventObject<any>): void;
|
|
1514
1506
|
cleanupEvaluateGuidelines(): void;
|
|
1515
1507
|
private initEvents;
|
|
1516
|
-
getLineGuideStops(
|
|
1508
|
+
getLineGuideStops(skipNodes: string[]): LineGuideStop;
|
|
1517
1509
|
getObjectSnappingEdges(node: Konva.Node): NodeSnappingEdges;
|
|
1518
1510
|
getGuides(lineGuideStops: LineGuideStop, itemBounds: NodeSnappingEdges, type: string): Guide[];
|
|
1519
1511
|
drawGuides(guides: Guide[]): void;
|
package/dist/sdk.d.ts
CHANGED
|
@@ -63,7 +63,6 @@ type WeaveConfig = {
|
|
|
63
63
|
actions?: WeaveActionBase[];
|
|
64
64
|
plugins?: WeavePluginBase[];
|
|
65
65
|
fonts?: WeaveFont[];
|
|
66
|
-
callbacks?: WeaveCallbacks;
|
|
67
66
|
logger?: WeaveLoggerConfig;
|
|
68
67
|
};
|
|
69
68
|
type WeaveStatusKeys = keyof typeof WEAVE_INSTANCE_STATUS;
|
|
@@ -141,20 +140,6 @@ type WeaveUndoManagerOptions = {
|
|
|
141
140
|
captureTimeout?: number;
|
|
142
141
|
trackedOrigins?: Set<any>;
|
|
143
142
|
};
|
|
144
|
-
type WeaveUndoRedoChange = {
|
|
145
|
-
canRedo: boolean;
|
|
146
|
-
canUndo: boolean;
|
|
147
|
-
redoStackLength: number;
|
|
148
|
-
undoStackLength: number;
|
|
149
|
-
};
|
|
150
|
-
type WeaveCallbacks = {
|
|
151
|
-
onRender?: () => void;
|
|
152
|
-
onRoomLoaded?: (loaded: boolean) => void;
|
|
153
|
-
onInstanceStatus?: (status: WeaveStatus) => void;
|
|
154
|
-
onActiveActionChange?: (actionName: string | undefined) => void;
|
|
155
|
-
onStateChange?: (state: WeaveState) => void;
|
|
156
|
-
onUndoManagerStatusChange?: (undoManagerStatus: WeaveUndoRedoChange) => void;
|
|
157
|
-
};
|
|
158
143
|
declare type docElementTypeDescription = "xml" | "text" | Array<any> | object;
|
|
159
144
|
declare type DocTypeDescription = {
|
|
160
145
|
[key: string]: docElementTypeDescription;
|
|
@@ -393,6 +378,7 @@ declare class Weave extends Emittery {
|
|
|
393
378
|
getStatus(): WeaveStatus;
|
|
394
379
|
setStore(store: WeaveStore): void;
|
|
395
380
|
start(): Promise<void>;
|
|
381
|
+
destroy(): void;
|
|
396
382
|
getId(): string;
|
|
397
383
|
getConfiguration(): WeaveConfig;
|
|
398
384
|
emitEvent<T>(event: string, payload?: T): void;
|
|
@@ -1177,6 +1163,7 @@ declare class WeaveStagePanningPlugin extends WeavePlugin {
|
|
|
1177
1163
|
private isMouseMiddleButtonPressed;
|
|
1178
1164
|
private isCtrlOrMetaPressed;
|
|
1179
1165
|
private isSpaceKeyPressed;
|
|
1166
|
+
private overStage;
|
|
1180
1167
|
protected previousPointer: string | null;
|
|
1181
1168
|
getLayerName: undefined;
|
|
1182
1169
|
initLayer: undefined;
|
|
@@ -1510,10 +1497,15 @@ declare class WeaveNodesSnappingPlugin extends WeavePlugin {
|
|
|
1510
1497
|
getName(): string;
|
|
1511
1498
|
onInit(): void;
|
|
1512
1499
|
setEnabled(enabled: boolean): void;
|
|
1500
|
+
getSelectedNodesMetadata(transformer: Konva.Transformer): {
|
|
1501
|
+
width: number;
|
|
1502
|
+
height: number;
|
|
1503
|
+
nodes: string[];
|
|
1504
|
+
};
|
|
1513
1505
|
evaluateGuidelines(e: KonvaEventObject<any>): void;
|
|
1514
1506
|
cleanupEvaluateGuidelines(): void;
|
|
1515
1507
|
private initEvents;
|
|
1516
|
-
getLineGuideStops(
|
|
1508
|
+
getLineGuideStops(skipNodes: string[]): LineGuideStop;
|
|
1517
1509
|
getObjectSnappingEdges(node: Konva.Node): NodeSnappingEdges;
|
|
1518
1510
|
getGuides(lineGuideStops: LineGuideStop, itemBounds: NodeSnappingEdges, type: string): Guide[];
|
|
1519
1511
|
drawGuides(guides: Guide[]): void;
|
package/dist/sdk.js
CHANGED
|
@@ -15506,6 +15506,7 @@ var WeaveStore = class {
|
|
|
15506
15506
|
this.instance = instance;
|
|
15507
15507
|
this.logger = this.instance.getChildLogger(this.getName());
|
|
15508
15508
|
this.instance.getMainLogger().info(`Store with name [${this.getName()}] registered`);
|
|
15509
|
+
this.instance.emitEvent("onRoomLoaded", this.isRoomLoaded);
|
|
15509
15510
|
return this;
|
|
15510
15511
|
}
|
|
15511
15512
|
getUser() {
|
|
@@ -15530,8 +15531,7 @@ var WeaveStore = class {
|
|
|
15530
15531
|
return JSON.parse(JSON.stringify(this.state, void 0, 2));
|
|
15531
15532
|
}
|
|
15532
15533
|
setup() {
|
|
15533
|
-
|
|
15534
|
-
config.callbacks?.onRoomLoaded?.(this.isRoomLoaded);
|
|
15534
|
+
this.isRoomLoaded = false;
|
|
15535
15535
|
this.instance.emitEvent("onRoomLoaded", this.isRoomLoaded);
|
|
15536
15536
|
if (this.supportsUndoManager) {
|
|
15537
15537
|
const weaveStateValues = getYjsValue(
|
|
@@ -15552,7 +15552,6 @@ var WeaveStore = class {
|
|
|
15552
15552
|
redoStackLength: this.undoManager.redoStack.length,
|
|
15553
15553
|
undoStackLength: this.undoManager.undoStack.length
|
|
15554
15554
|
};
|
|
15555
|
-
config.callbacks?.onUndoManagerStatusChange?.(change);
|
|
15556
15555
|
this.instance.emitEvent("onUndoManagerStatusChange", change);
|
|
15557
15556
|
});
|
|
15558
15557
|
this.undoManager.on("stack-item-popped", () => {
|
|
@@ -15562,14 +15561,12 @@ var WeaveStore = class {
|
|
|
15562
15561
|
redoStackLength: this.undoManager.redoStack.length,
|
|
15563
15562
|
undoStackLength: this.undoManager.undoStack.length
|
|
15564
15563
|
};
|
|
15565
|
-
config.callbacks?.onUndoManagerStatusChange?.(change);
|
|
15566
15564
|
this.instance.emitEvent("onUndoManagerStatusChange", change);
|
|
15567
15565
|
});
|
|
15568
15566
|
}
|
|
15569
15567
|
}
|
|
15570
15568
|
observeDeep(this.getState(), () => {
|
|
15571
15569
|
const newState = JSON.parse(JSON.stringify(this.getState()));
|
|
15572
|
-
config.callbacks?.onStateChange?.(newState);
|
|
15573
15570
|
this.instance.emitEvent("onStateChange", newState);
|
|
15574
15571
|
const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
15575
15572
|
if (this.isRoomLoaded && nodesSelectionPlugin && nodesSelectionPlugin.getSelectedNodes().length === 1) {
|
|
@@ -15583,7 +15580,6 @@ var WeaveStore = class {
|
|
|
15583
15580
|
if (!this.isRoomLoaded && !(0, import_lodash.isEmpty)(this.state.weave)) {
|
|
15584
15581
|
this.instance.setupRenderer();
|
|
15585
15582
|
this.isRoomLoaded = true;
|
|
15586
|
-
config.callbacks?.onRoomLoaded?.(this.isRoomLoaded);
|
|
15587
15583
|
this.instance.emitEvent("onRoomLoaded", this.isRoomLoaded);
|
|
15588
15584
|
}
|
|
15589
15585
|
if (this.isRoomLoaded && !(0, import_lodash.isEmpty)(this.state.weave)) this.instance.render();
|
|
@@ -15790,7 +15786,7 @@ function moveNodeToContainer(instance, node) {
|
|
|
15790
15786
|
const nodeHandler = instance.getNodeHandler(node.getAttrs().nodeType);
|
|
15791
15787
|
const actualNode = nodeHandler.serialize(node);
|
|
15792
15788
|
instance.removeNode(actualNode);
|
|
15793
|
-
instance.addNode(actualNode, layerToMove
|
|
15789
|
+
instance.addNode(actualNode, layerToMove.getAttrs().id);
|
|
15794
15790
|
}
|
|
15795
15791
|
return layerToMove;
|
|
15796
15792
|
}
|
|
@@ -16459,14 +16455,14 @@ var WeaveNode = class {
|
|
|
16459
16455
|
clearContainerTargets(this.instance);
|
|
16460
16456
|
const layerToMove = checkIfOverContainer(this.instance, e.target);
|
|
16461
16457
|
if (layerToMove) layerToMove.fire(WEAVE_NODE_CUSTOM_EVENTS.onTargetEnter, { bubbles: true });
|
|
16462
|
-
this.instance.updateNode(this.serialize(
|
|
16458
|
+
this.instance.updateNode(this.serialize(e.target));
|
|
16463
16459
|
}
|
|
16464
16460
|
});
|
|
16465
16461
|
node.on("dragend", (e) => {
|
|
16466
16462
|
if (this.isSelecting() && this.isNodeSelected(node)) {
|
|
16467
16463
|
clearContainerTargets(this.instance);
|
|
16468
|
-
const
|
|
16469
|
-
if (
|
|
16464
|
+
const containerToMove = moveNodeToContainer(this.instance, e.target);
|
|
16465
|
+
if (containerToMove) return;
|
|
16470
16466
|
this.instance.updateNode(this.serialize(node));
|
|
16471
16467
|
}
|
|
16472
16468
|
});
|
|
@@ -17166,6 +17162,8 @@ var WeaveTargetingManager = class {
|
|
|
17166
17162
|
};
|
|
17167
17163
|
let measureContainer = mainLayer;
|
|
17168
17164
|
let container = mainLayer;
|
|
17165
|
+
const nodesSelection = this.instance.getPlugin("nodesSelection");
|
|
17166
|
+
if (nodesSelection) nodesSelection.disable();
|
|
17169
17167
|
const intersectedNode = stage.getIntersection(relativeMousePointer);
|
|
17170
17168
|
if (intersectedNode) {
|
|
17171
17169
|
const node = this.instance.getInstanceRecursive(intersectedNode, ["group"]);
|
|
@@ -17185,6 +17183,7 @@ var WeaveTargetingManager = class {
|
|
|
17185
17183
|
x: 0,
|
|
17186
17184
|
y: 0
|
|
17187
17185
|
};
|
|
17186
|
+
if (nodesSelection) nodesSelection.enable();
|
|
17188
17187
|
return {
|
|
17189
17188
|
mousePoint: relativeMousePointer,
|
|
17190
17189
|
container,
|
|
@@ -17913,7 +17912,7 @@ var WeaveRegisterManager = class {
|
|
|
17913
17912
|
|
|
17914
17913
|
//#endregion
|
|
17915
17914
|
//#region package.json
|
|
17916
|
-
var version = "0.
|
|
17915
|
+
var version = "0.15.0";
|
|
17917
17916
|
|
|
17918
17917
|
//#endregion
|
|
17919
17918
|
//#region src/managers/setup.ts
|
|
@@ -18032,7 +18031,6 @@ var WeaveActionsManager = class {
|
|
|
18032
18031
|
return this.activeAction;
|
|
18033
18032
|
}
|
|
18034
18033
|
triggerAction(actionName, params) {
|
|
18035
|
-
const config = this.instance.getConfiguration();
|
|
18036
18034
|
const actionsHandlers = this.instance.getActionsHandlers();
|
|
18037
18035
|
if (!actionsHandlers[actionName]) {
|
|
18038
18036
|
const msg = `Action handler with name [${actionName}] not registered`;
|
|
@@ -18042,7 +18040,6 @@ var WeaveActionsManager = class {
|
|
|
18042
18040
|
if (typeof this.activeAction !== "undefined") this.cancelAction(this.activeAction);
|
|
18043
18041
|
this.activeAction = actionName;
|
|
18044
18042
|
const payload = actionsHandlers[actionName].trigger(this.cancelActionCallback(actionName), params);
|
|
18045
|
-
config.callbacks?.onActiveActionChange?.(this.activeAction);
|
|
18046
18043
|
this.instance.emitEvent("onActiveActionChange", this.activeAction);
|
|
18047
18044
|
return payload;
|
|
18048
18045
|
}
|
|
@@ -18077,7 +18074,6 @@ var WeaveActionsManager = class {
|
|
|
18077
18074
|
return actionsHandlers[actionName].getProps?.();
|
|
18078
18075
|
}
|
|
18079
18076
|
cancelAction(actionName) {
|
|
18080
|
-
const config = this.instance.getConfiguration();
|
|
18081
18077
|
const actionsHandlers = this.instance.getActionsHandlers();
|
|
18082
18078
|
if (!actionsHandlers[actionName]) {
|
|
18083
18079
|
const msg = `Action handler with name [${actionName}] not registered`;
|
|
@@ -18086,7 +18082,6 @@ var WeaveActionsManager = class {
|
|
|
18086
18082
|
}
|
|
18087
18083
|
this.activeAction = void 0;
|
|
18088
18084
|
actionsHandlers[actionName].cleanup?.();
|
|
18089
|
-
config.callbacks?.onActiveActionChange?.(this.activeAction);
|
|
18090
18085
|
this.instance.emitEvent("onActiveActionChange", this.activeAction);
|
|
18091
18086
|
}
|
|
18092
18087
|
cancelActionCallback(actionName) {
|
|
@@ -18310,7 +18305,6 @@ var Weave = class extends Emittery {
|
|
|
18310
18305
|
this.setupManager.setupActions();
|
|
18311
18306
|
this.moduleLogger.info("Instance started");
|
|
18312
18307
|
this.status = WEAVE_INSTANCE_STATUS.RUNNING;
|
|
18313
|
-
this.getConfiguration().callbacks?.onInstanceStatus?.(this.status);
|
|
18314
18308
|
this.emitEvent("onInstanceStatus", this.status);
|
|
18315
18309
|
});
|
|
18316
18310
|
}
|
|
@@ -18325,15 +18319,14 @@ var Weave = class extends Emittery {
|
|
|
18325
18319
|
}
|
|
18326
18320
|
async start() {
|
|
18327
18321
|
this.moduleLogger.info("Start instance");
|
|
18322
|
+
this.emitEvent("onRoomLoaded", false);
|
|
18328
18323
|
this.status = WEAVE_INSTANCE_STATUS.STARTING;
|
|
18329
|
-
this.getConfiguration().callbacks?.onInstanceStatus?.(this.status);
|
|
18330
18324
|
this.emitEvent("onInstanceStatus", this.status);
|
|
18331
18325
|
this.registerManager.registerNodesHandlers();
|
|
18332
18326
|
this.registerManager.registerPlugins();
|
|
18333
18327
|
this.registerManager.registerActionsHandlers();
|
|
18334
18328
|
this.storeManager.registerStore(this.config.store);
|
|
18335
18329
|
this.status = WEAVE_INSTANCE_STATUS.LOADING_FONTS;
|
|
18336
|
-
this.getConfiguration().callbacks?.onInstanceStatus?.(this.status);
|
|
18337
18330
|
this.emitEvent("onInstanceStatus", this.status);
|
|
18338
18331
|
await this.fontsManager.loadFonts();
|
|
18339
18332
|
this.setupManager.setupLog();
|
|
@@ -18342,6 +18335,17 @@ var Weave = class extends Emittery {
|
|
|
18342
18335
|
store.setup();
|
|
18343
18336
|
store.connect();
|
|
18344
18337
|
}
|
|
18338
|
+
destroy() {
|
|
18339
|
+
this.moduleLogger.info(`Destroying the instance`);
|
|
18340
|
+
this.clearListeners();
|
|
18341
|
+
this.status = WEAVE_INSTANCE_STATUS.IDLE;
|
|
18342
|
+
this.emitEvent("onInstanceStatus", this.status);
|
|
18343
|
+
const store = this.storeManager.getStore();
|
|
18344
|
+
store.disconnect();
|
|
18345
|
+
const stage = this.getStage();
|
|
18346
|
+
if (stage) stage.destroy();
|
|
18347
|
+
this.moduleLogger.info(`Instance destroyed`);
|
|
18348
|
+
}
|
|
18345
18349
|
getId() {
|
|
18346
18350
|
return this.id;
|
|
18347
18351
|
}
|
|
@@ -18456,13 +18460,11 @@ var Weave = class extends Emittery {
|
|
|
18456
18460
|
update(newState) {
|
|
18457
18461
|
this.getStore().setState(newState);
|
|
18458
18462
|
this.renderer.render(() => {
|
|
18459
|
-
this.config.callbacks?.onRender?.();
|
|
18460
18463
|
this.emitEvent("onRender", {});
|
|
18461
18464
|
});
|
|
18462
18465
|
}
|
|
18463
18466
|
render() {
|
|
18464
18467
|
this.renderer.render(() => {
|
|
18465
|
-
this.config.callbacks?.onRender?.();
|
|
18466
18468
|
this.emitEvent("onRender", {});
|
|
18467
18469
|
});
|
|
18468
18470
|
}
|
|
@@ -19648,7 +19650,7 @@ const WEAVE_FRAME_NODE_DEFAULT_CONFIG = {
|
|
|
19648
19650
|
},
|
|
19649
19651
|
onTargetEnter: {
|
|
19650
19652
|
borderColor: "#ff6863ff",
|
|
19651
|
-
fill: "#
|
|
19653
|
+
fill: "#ffffffff"
|
|
19652
19654
|
}
|
|
19653
19655
|
};
|
|
19654
19656
|
const WEAVE_FRAME_NODE_DEFAULT_PROPS = {
|
|
@@ -19699,21 +19701,21 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
19699
19701
|
id,
|
|
19700
19702
|
containerId: `${id}-group-internal`,
|
|
19701
19703
|
containerOffsetX: 0,
|
|
19702
|
-
containerOffsetY: titleHeight
|
|
19703
|
-
width: props.frameWidth
|
|
19704
|
-
height: props.frameHeight + titleHeight
|
|
19704
|
+
containerOffsetY: titleHeight,
|
|
19705
|
+
width: props.frameWidth,
|
|
19706
|
+
height: props.frameHeight + titleHeight,
|
|
19705
19707
|
fill: "#ffffffff",
|
|
19706
19708
|
clipX: 0,
|
|
19707
19709
|
clipY: 0,
|
|
19708
|
-
clipWidth: props.frameWidth
|
|
19709
|
-
clipHeight: props.frameHeight + titleHeight
|
|
19710
|
+
clipWidth: props.frameWidth,
|
|
19711
|
+
clipHeight: props.frameHeight + titleHeight,
|
|
19710
19712
|
name: "node"
|
|
19711
19713
|
});
|
|
19712
19714
|
const background = new Konva.Rect({
|
|
19713
19715
|
id: `${id}-bg`,
|
|
19714
19716
|
nodeId: id,
|
|
19715
|
-
x:
|
|
19716
|
-
y: titleHeight
|
|
19717
|
+
x: 0,
|
|
19718
|
+
y: titleHeight,
|
|
19717
19719
|
width: props.frameWidth,
|
|
19718
19720
|
stroke: borderColor,
|
|
19719
19721
|
strokeWidth: borderWidth,
|
|
@@ -19744,18 +19746,18 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
19744
19746
|
const frameInternal = new Konva.Group({
|
|
19745
19747
|
id: `${id}-group-internal`,
|
|
19746
19748
|
nodeId: id,
|
|
19747
|
-
x:
|
|
19748
|
-
y: titleHeight
|
|
19749
|
+
x: 0,
|
|
19750
|
+
y: titleHeight,
|
|
19749
19751
|
width: props.frameWidth,
|
|
19750
19752
|
height: props.frameHeight,
|
|
19751
19753
|
draggable: false,
|
|
19752
19754
|
stroke: "transparent",
|
|
19753
19755
|
strokeScaleEnabled: false,
|
|
19754
|
-
borderWidth,
|
|
19756
|
+
borderWidth: 0,
|
|
19755
19757
|
clipX: 0,
|
|
19756
19758
|
clipY: 0,
|
|
19757
|
-
clipWidth: props.frameWidth
|
|
19758
|
-
clipHeight: props.frameHeight
|
|
19759
|
+
clipWidth: props.frameWidth,
|
|
19760
|
+
clipHeight: props.frameHeight
|
|
19759
19761
|
});
|
|
19760
19762
|
frame.add(frameInternal);
|
|
19761
19763
|
this.setupDefaultNodeEvents(frame);
|
|
@@ -21386,6 +21388,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
21386
21388
|
this.isMouseMiddleButtonPressed = false;
|
|
21387
21389
|
this.isCtrlOrMetaPressed = false;
|
|
21388
21390
|
this.isSpaceKeyPressed = false;
|
|
21391
|
+
this.overStage = false;
|
|
21389
21392
|
this.previousPointer = null;
|
|
21390
21393
|
}
|
|
21391
21394
|
getName() {
|
|
@@ -21426,6 +21429,12 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
21426
21429
|
this.disableMove();
|
|
21427
21430
|
}
|
|
21428
21431
|
});
|
|
21432
|
+
stage.on("mouseenter", () => {
|
|
21433
|
+
this.overStage = true;
|
|
21434
|
+
});
|
|
21435
|
+
stage.on("mouseleave", () => {
|
|
21436
|
+
this.overStage = false;
|
|
21437
|
+
});
|
|
21429
21438
|
stage.on("mousedown", (e) => {
|
|
21430
21439
|
const activeAction = this.instance.getActiveAction();
|
|
21431
21440
|
let enableMove = false;
|
|
@@ -21495,7 +21504,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
21495
21504
|
this.instance.emit("onStageMove", void 0);
|
|
21496
21505
|
});
|
|
21497
21506
|
window.addEventListener("wheel", (e) => {
|
|
21498
|
-
if (!this.enabled || this.isCtrlOrMetaPressed || this.isSpaceKeyPressed || this.isMouseMiddleButtonPressed) return;
|
|
21507
|
+
if (!this.enabled || !this.overStage || this.isCtrlOrMetaPressed || this.isSpaceKeyPressed || this.isMouseMiddleButtonPressed) return;
|
|
21499
21508
|
stage.x(stage.x() - e.deltaX);
|
|
21500
21509
|
stage.y(stage.y() - e.deltaY);
|
|
21501
21510
|
this.instance.emit("stageMove", void 0);
|
|
@@ -21901,24 +21910,60 @@ var WeaveNodesSnappingPlugin = class extends WeavePlugin {
|
|
|
21901
21910
|
setEnabled(enabled) {
|
|
21902
21911
|
this.enabled = enabled;
|
|
21903
21912
|
}
|
|
21913
|
+
getSelectedNodesMetadata(transformer) {
|
|
21914
|
+
const firstNode = transformer.getNodes()[0];
|
|
21915
|
+
const firstNodeClientRect = firstNode.getClientRect();
|
|
21916
|
+
const rectCoordsMin = {
|
|
21917
|
+
x: firstNodeClientRect.x,
|
|
21918
|
+
y: firstNodeClientRect.y
|
|
21919
|
+
};
|
|
21920
|
+
const rectCoordsMax = {
|
|
21921
|
+
x: firstNodeClientRect.x + firstNodeClientRect.width,
|
|
21922
|
+
y: firstNodeClientRect.y + firstNodeClientRect.height
|
|
21923
|
+
};
|
|
21924
|
+
const nodes = [];
|
|
21925
|
+
for (const node of transformer.getNodes()) {
|
|
21926
|
+
const clientRect = node.getClientRect();
|
|
21927
|
+
if (clientRect.x < rectCoordsMin.x) rectCoordsMin.x = clientRect.x;
|
|
21928
|
+
if (clientRect.y < rectCoordsMin.y) rectCoordsMin.y = clientRect.y;
|
|
21929
|
+
if (clientRect.x + clientRect.width > rectCoordsMax.x) rectCoordsMax.x = clientRect.x + clientRect.width;
|
|
21930
|
+
if (clientRect.y + clientRect.height > rectCoordsMax.y) rectCoordsMax.y = clientRect.y + clientRect.height;
|
|
21931
|
+
nodes.push(node.getAttrs().id);
|
|
21932
|
+
}
|
|
21933
|
+
return {
|
|
21934
|
+
width: rectCoordsMax.x - rectCoordsMin.x,
|
|
21935
|
+
height: rectCoordsMax.y - rectCoordsMin.y,
|
|
21936
|
+
nodes
|
|
21937
|
+
};
|
|
21938
|
+
}
|
|
21904
21939
|
evaluateGuidelines(e) {
|
|
21905
21940
|
const utilityLayer = this.instance.getUtilityLayer();
|
|
21906
21941
|
if (!this.enabled) return;
|
|
21907
21942
|
if (!utilityLayer) return;
|
|
21943
|
+
const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
21944
|
+
let skipNodes = [];
|
|
21908
21945
|
let node = void 0;
|
|
21909
|
-
if (e.type === "dragmove" && e.target instanceof Konva.Transformer) {
|
|
21946
|
+
if (e.type === "dragmove" && nodesSelectionPlugin && e.target instanceof Konva.Transformer && e.target.getNodes().length === 1) {
|
|
21910
21947
|
const actualTarget = e.target;
|
|
21911
21948
|
node = actualTarget.getNodes()[0];
|
|
21949
|
+
skipNodes.push(node.getAttrs().id ?? "");
|
|
21950
|
+
}
|
|
21951
|
+
if (e.type === "dragmove" && nodesSelectionPlugin && e.target instanceof Konva.Transformer && e.target.getNodes().length > 1) {
|
|
21952
|
+
const { nodes } = this.getSelectedNodesMetadata(e.target);
|
|
21953
|
+
node = e.target;
|
|
21954
|
+
skipNodes = [...nodes];
|
|
21912
21955
|
}
|
|
21913
21956
|
if (e.type === "transform") node = e.target;
|
|
21914
21957
|
if (typeof node === "undefined") return;
|
|
21915
|
-
const lineGuideStops = this.getLineGuideStops(
|
|
21958
|
+
const lineGuideStops = this.getLineGuideStops(skipNodes);
|
|
21916
21959
|
const itemBounds = this.getObjectSnappingEdges(node);
|
|
21917
21960
|
const guides = this.getGuides(lineGuideStops, itemBounds, e.type);
|
|
21961
|
+
utilityLayer.destroyChildren();
|
|
21918
21962
|
if (!guides.length) return;
|
|
21919
21963
|
utilityLayer.find(`.${GUIDE_LINE_NAME}`).forEach((l) => l.destroy());
|
|
21920
21964
|
this.drawGuides(guides);
|
|
21921
21965
|
if (e.type === "dragmove") {
|
|
21966
|
+
const orgAbsPos = node.absolutePosition();
|
|
21922
21967
|
const absPos = node.absolutePosition();
|
|
21923
21968
|
guides.forEach((lg) => {
|
|
21924
21969
|
switch (lg.orientation) {
|
|
@@ -21932,12 +21977,24 @@ var WeaveNodesSnappingPlugin = class extends WeavePlugin {
|
|
|
21932
21977
|
}
|
|
21933
21978
|
}
|
|
21934
21979
|
});
|
|
21935
|
-
|
|
21980
|
+
const vecDiff = {
|
|
21981
|
+
x: orgAbsPos.x - absPos.x,
|
|
21982
|
+
y: orgAbsPos.y - absPos.y
|
|
21983
|
+
};
|
|
21984
|
+
if (node instanceof Konva.Transformer) node.getNodes().forEach((n) => {
|
|
21985
|
+
const nodeAbsPos = n.getAbsolutePosition();
|
|
21986
|
+
const newPos = {
|
|
21987
|
+
x: nodeAbsPos.x - vecDiff.x,
|
|
21988
|
+
y: nodeAbsPos.y - vecDiff.y
|
|
21989
|
+
};
|
|
21990
|
+
n.setAbsolutePosition(newPos);
|
|
21991
|
+
});
|
|
21992
|
+
else node.absolutePosition(absPos);
|
|
21936
21993
|
}
|
|
21937
21994
|
if (e.type === "transform") {
|
|
21938
|
-
const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
21939
|
-
if (nodesSelectionPlugin) {
|
|
21940
|
-
const transformer = nodesSelectionPlugin.getTransformer();
|
|
21995
|
+
const nodesSelectionPlugin$1 = this.instance.getPlugin("nodesSelection");
|
|
21996
|
+
if (nodesSelectionPlugin$1) {
|
|
21997
|
+
const transformer = nodesSelectionPlugin$1.getTransformer();
|
|
21941
21998
|
transformer.anchorDragBoundFunc((_, newAbsPos) => {
|
|
21942
21999
|
const finalPos = { ...newAbsPos };
|
|
21943
22000
|
for (const lg of guides) switch (lg.orientation) {
|
|
@@ -21961,7 +22018,7 @@ var WeaveNodesSnappingPlugin = class extends WeavePlugin {
|
|
|
21961
22018
|
const utilityLayer = this.instance.getUtilityLayer();
|
|
21962
22019
|
if (!this.enabled) return;
|
|
21963
22020
|
if (!utilityLayer) return;
|
|
21964
|
-
utilityLayer.
|
|
22021
|
+
utilityLayer.destroyChildren();
|
|
21965
22022
|
}
|
|
21966
22023
|
initEvents() {
|
|
21967
22024
|
const stage = this.instance.getStage();
|
|
@@ -21971,7 +22028,7 @@ var WeaveNodesSnappingPlugin = class extends WeavePlugin {
|
|
|
21971
22028
|
stage.on("dragend", this.cleanupEvaluateGuidelines.bind(this));
|
|
21972
22029
|
}
|
|
21973
22030
|
}
|
|
21974
|
-
getLineGuideStops(
|
|
22031
|
+
getLineGuideStops(skipNodes) {
|
|
21975
22032
|
const stage = this.instance.getStage();
|
|
21976
22033
|
const nodesSelection = this.instance.getPlugin("nodesSelection");
|
|
21977
22034
|
if (nodesSelection) nodesSelection.getTransformer().hide();
|
|
@@ -21986,7 +22043,7 @@ var WeaveNodesSnappingPlugin = class extends WeavePlugin {
|
|
|
21986
22043
|
stage.height()
|
|
21987
22044
|
];
|
|
21988
22045
|
stage.find(".node").forEach((guideItem) => {
|
|
21989
|
-
if (guideItem
|
|
22046
|
+
if (skipNodes.includes(guideItem.getAttrs().id ?? "")) return;
|
|
21990
22047
|
const box = guideItem.getClientRect({ skipStroke: true });
|
|
21991
22048
|
vertical.push([
|
|
21992
22049
|
box.x,
|
|
@@ -22006,7 +22063,13 @@ var WeaveNodesSnappingPlugin = class extends WeavePlugin {
|
|
|
22006
22063
|
};
|
|
22007
22064
|
}
|
|
22008
22065
|
getObjectSnappingEdges(node) {
|
|
22009
|
-
|
|
22066
|
+
let box = node.getClientRect({ skipStroke: true });
|
|
22067
|
+
if (node instanceof Konva.Transformer) {
|
|
22068
|
+
const transformerRect = node.getChildren((node$1) => {
|
|
22069
|
+
return node$1.getAttrs().name === "back";
|
|
22070
|
+
})[0];
|
|
22071
|
+
box = transformerRect.getClientRect({ skipStroke: true });
|
|
22072
|
+
}
|
|
22010
22073
|
const absPos = node.absolutePosition();
|
|
22011
22074
|
const snappingEdges = {
|
|
22012
22075
|
vertical: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inditextech/weave-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Jesus Manuel Piñeiro Cid <jesusmpc@inditex.com>",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"version:release": "npm version $RELEASE_VERSION -m \"[npm-scripts] prepare release $RELEASE_VERSION\" --tag-version-prefix \"\""
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@inditextech/weave-types": "0.
|
|
46
|
+
"@inditextech/weave-types": "0.15.0",
|
|
47
47
|
"@syncedstore/core": "0.6.0",
|
|
48
48
|
"canvas": "3.1.0",
|
|
49
49
|
"konva": "9.3.20",
|