@inditextech/weave-sdk 0.3.3 → 0.5.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 +391 -151
- package/dist/sdk.d.cts +137 -31
- package/dist/sdk.d.ts +137 -31
- package/dist/sdk.js +385 -153
- package/package.json +3 -3
package/dist/sdk.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Konva from "konva";
|
|
2
2
|
import "konva/lib/types";
|
|
3
|
-
import { WEAVE_EXPORT_BACKGROUND_COLOR, WEAVE_EXPORT_FILE_FORMAT, WEAVE_EXPORT_FORMATS, WEAVE_INSTANCE_STATUS, WEAVE_NODE_LAYER_ID, WEAVE_NODE_POSITION } from "@inditextech/weave-types";
|
|
3
|
+
import { WEAVE_EXPORT_BACKGROUND_COLOR, WEAVE_EXPORT_FILE_FORMAT, WEAVE_EXPORT_FORMATS, WEAVE_INSTANCE_STATUS, WEAVE_NODE_CUSTOM_EVENTS, WEAVE_NODE_LAYER_ID, WEAVE_NODE_POSITION, WEAVE_UTILITY_LAYER_ID } from "@inditextech/weave-types";
|
|
4
4
|
import { getYjsDoc, getYjsValue, observeDeep, syncedStore } from "@syncedstore/core";
|
|
5
5
|
import { Doc, UndoManager } from "yjs";
|
|
6
6
|
import React from "react";
|
|
@@ -15627,18 +15627,25 @@ const WEAVE_NODES_SELECTION_LAYER_ID = "selectionLayer";
|
|
|
15627
15627
|
//#endregion
|
|
15628
15628
|
//#region src/plugins/context-menu/constants.ts
|
|
15629
15629
|
const WEAVE_CONTEXT_MENU_KEY = "contextMenu";
|
|
15630
|
+
const WEAVE_CONTEXT_MENU_X_OFFSET_DEFAULT = 4;
|
|
15631
|
+
const WEAVE_CONTEXT_MENU_Y_OFFSET_DEFAULT = 4;
|
|
15630
15632
|
|
|
15631
15633
|
//#endregion
|
|
15632
15634
|
//#region src/plugins/context-menu/context-menu.ts
|
|
15633
15635
|
var WeaveContextMenuPlugin = class extends WeavePlugin {
|
|
15634
15636
|
getLayerName = void 0;
|
|
15635
15637
|
initLayer = void 0;
|
|
15636
|
-
constructor(
|
|
15638
|
+
constructor(params) {
|
|
15637
15639
|
super();
|
|
15638
15640
|
this.touchTimer = void 0;
|
|
15639
15641
|
this.tapHold = false;
|
|
15640
|
-
|
|
15641
|
-
this.
|
|
15642
|
+
const { callbacks, config } = params ?? {};
|
|
15643
|
+
this.config = {
|
|
15644
|
+
xOffset: WEAVE_CONTEXT_MENU_X_OFFSET_DEFAULT,
|
|
15645
|
+
yOffset: WEAVE_CONTEXT_MENU_Y_OFFSET_DEFAULT,
|
|
15646
|
+
...config
|
|
15647
|
+
};
|
|
15648
|
+
this.callbacks = { ...callbacks };
|
|
15642
15649
|
}
|
|
15643
15650
|
getName() {
|
|
15644
15651
|
return WEAVE_CONTEXT_MENU_KEY;
|
|
@@ -15648,7 +15655,7 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
|
|
|
15648
15655
|
}
|
|
15649
15656
|
triggerContextMenu(target) {
|
|
15650
15657
|
const stage = this.instance.getStage();
|
|
15651
|
-
const selectionPlugin = this.instance.getPlugin(
|
|
15658
|
+
const selectionPlugin = this.instance.getPlugin(WEAVE_NODES_SELECTION_KEY);
|
|
15652
15659
|
let clickOnTransformer = false;
|
|
15653
15660
|
if (selectionPlugin) {
|
|
15654
15661
|
const transformer = selectionPlugin.getTransformer();
|
|
@@ -15729,9 +15736,46 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
|
|
|
15729
15736
|
//#endregion
|
|
15730
15737
|
//#region src/plugins/nodes-selection/nodes-selection.ts
|
|
15731
15738
|
var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
15732
|
-
constructor(
|
|
15739
|
+
constructor(params) {
|
|
15733
15740
|
super();
|
|
15734
|
-
|
|
15741
|
+
const { config, callbacks } = params ?? {};
|
|
15742
|
+
this.config = { transformer: {
|
|
15743
|
+
rotationSnaps: [
|
|
15744
|
+
0,
|
|
15745
|
+
45,
|
|
15746
|
+
90,
|
|
15747
|
+
135,
|
|
15748
|
+
180,
|
|
15749
|
+
225,
|
|
15750
|
+
270,
|
|
15751
|
+
315,
|
|
15752
|
+
360
|
|
15753
|
+
],
|
|
15754
|
+
rotationSnapTolerance: 3,
|
|
15755
|
+
ignoreStroke: true,
|
|
15756
|
+
flipEnabled: false,
|
|
15757
|
+
useSingleNodeRotation: true,
|
|
15758
|
+
shouldOverdrawWholeArea: true,
|
|
15759
|
+
anchorStyleFunc: (anchor) => {
|
|
15760
|
+
anchor.stroke("#27272aff");
|
|
15761
|
+
anchor.cornerRadius(12);
|
|
15762
|
+
if (anchor.hasName("top-center") || anchor.hasName("bottom-center")) {
|
|
15763
|
+
anchor.height(8);
|
|
15764
|
+
anchor.offsetY(4);
|
|
15765
|
+
anchor.width(32);
|
|
15766
|
+
anchor.offsetX(16);
|
|
15767
|
+
}
|
|
15768
|
+
if (anchor.hasName("middle-left") || anchor.hasName("middle-right")) {
|
|
15769
|
+
anchor.height(32);
|
|
15770
|
+
anchor.offsetY(16);
|
|
15771
|
+
anchor.width(8);
|
|
15772
|
+
anchor.offsetX(4);
|
|
15773
|
+
}
|
|
15774
|
+
},
|
|
15775
|
+
borderStroke: "#1e40afff",
|
|
15776
|
+
...config?.transformer
|
|
15777
|
+
} };
|
|
15778
|
+
this.callbacks = callbacks ?? {};
|
|
15735
15779
|
this.active = false;
|
|
15736
15780
|
this.cameFromSelectingMultiple = false;
|
|
15737
15781
|
this.selecting = false;
|
|
@@ -15765,39 +15809,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
15765
15809
|
selectionLayer?.add(selectionRectangle);
|
|
15766
15810
|
const tr = new Konva.Transformer({
|
|
15767
15811
|
id: "selectionTransformer",
|
|
15768
|
-
|
|
15769
|
-
0,
|
|
15770
|
-
45,
|
|
15771
|
-
90,
|
|
15772
|
-
135,
|
|
15773
|
-
180,
|
|
15774
|
-
225,
|
|
15775
|
-
270,
|
|
15776
|
-
315,
|
|
15777
|
-
360
|
|
15778
|
-
],
|
|
15779
|
-
rotationSnapTolerance: 3,
|
|
15780
|
-
ignoreStroke: true,
|
|
15781
|
-
flipEnabled: false,
|
|
15782
|
-
useSingleNodeRotation: true,
|
|
15783
|
-
shouldOverdrawWholeArea: true,
|
|
15784
|
-
anchorStyleFunc: (anchor) => {
|
|
15785
|
-
anchor.stroke("#27272aff");
|
|
15786
|
-
anchor.cornerRadius(12);
|
|
15787
|
-
if (anchor.hasName("top-center") || anchor.hasName("bottom-center")) {
|
|
15788
|
-
anchor.height(8);
|
|
15789
|
-
anchor.offsetY(4);
|
|
15790
|
-
anchor.width(32);
|
|
15791
|
-
anchor.offsetX(16);
|
|
15792
|
-
}
|
|
15793
|
-
if (anchor.hasName("middle-left") || anchor.hasName("middle-right")) {
|
|
15794
|
-
anchor.height(32);
|
|
15795
|
-
anchor.offsetY(16);
|
|
15796
|
-
anchor.width(8);
|
|
15797
|
-
anchor.offsetX(4);
|
|
15798
|
-
}
|
|
15799
|
-
},
|
|
15800
|
-
borderStroke: "#1e40afff"
|
|
15812
|
+
...this.config.transformer
|
|
15801
15813
|
});
|
|
15802
15814
|
selectionLayer?.add(tr);
|
|
15803
15815
|
tr.on("mouseenter", (e) => {
|
|
@@ -16065,8 +16077,9 @@ const COPY_PASTE_NODES_PLUGIN_STATE = {
|
|
|
16065
16077
|
//#endregion
|
|
16066
16078
|
//#region src/plugins/copy-paste-nodes/copy-paste-nodes.ts
|
|
16067
16079
|
var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
16068
|
-
constructor(
|
|
16080
|
+
constructor(params) {
|
|
16069
16081
|
super();
|
|
16082
|
+
const { callbacks } = params ?? {};
|
|
16070
16083
|
this.callbacks = callbacks;
|
|
16071
16084
|
this.state = COPY_PASTE_NODES_PLUGIN_STATE.IDLE;
|
|
16072
16085
|
}
|
|
@@ -16286,6 +16299,40 @@ var WeaveNode = class {
|
|
|
16286
16299
|
if (selectionPlugin.getSelectedNodes().length === 1 && selectionPlugin.getSelectedNodes()[0].getAttrs().id === ele.getAttrs().id) selected = true;
|
|
16287
16300
|
return selected;
|
|
16288
16301
|
}
|
|
16302
|
+
clearContainerTargets() {
|
|
16303
|
+
const getContainers = this.instance.getContainerNodes();
|
|
16304
|
+
for (const container of getContainers) container.fire(WEAVE_NODE_CUSTOM_EVENTS.onTargetLeave, { bubbles: true });
|
|
16305
|
+
}
|
|
16306
|
+
checkIfOverContainer(node) {
|
|
16307
|
+
const nodesIntersected = this.instance.pointIntersectsContainerElement();
|
|
16308
|
+
let nodeActualContainer = node.getParent();
|
|
16309
|
+
if (nodeActualContainer?.getAttrs().nodeId) nodeActualContainer = this.instance.getStage().findOne(`#${nodeActualContainer.getAttrs().nodeId}`);
|
|
16310
|
+
let layerToMove = void 0;
|
|
16311
|
+
if (!node.getAttrs().containerId && nodesIntersected && nodeActualContainer?.getAttrs().id !== nodesIntersected.getAttrs().id) layerToMove = nodesIntersected;
|
|
16312
|
+
return layerToMove;
|
|
16313
|
+
}
|
|
16314
|
+
moveNodeToContainer(node) {
|
|
16315
|
+
const nodesIntersected = this.instance.pointIntersectsContainerElement();
|
|
16316
|
+
let nodeActualContainer = node.getParent();
|
|
16317
|
+
if (nodeActualContainer?.getAttrs().nodeId) nodeActualContainer = this.instance.getStage().findOne(`#${nodeActualContainer.getAttrs().nodeId}`);
|
|
16318
|
+
let layerToMove = void 0;
|
|
16319
|
+
if (!node.getAttrs().containerId && nodesIntersected && nodeActualContainer?.getAttrs().id !== nodesIntersected.getAttrs().id) layerToMove = nodesIntersected;
|
|
16320
|
+
if (!nodesIntersected && nodeActualContainer?.getAttrs().id !== WEAVE_NODE_LAYER_ID) layerToMove = this.instance.getMainLayer();
|
|
16321
|
+
if (layerToMove) {
|
|
16322
|
+
const nodePos = node.getAbsolutePosition();
|
|
16323
|
+
const nodeRotation = node.getAbsoluteRotation();
|
|
16324
|
+
node.moveTo(layerToMove);
|
|
16325
|
+
node.setAbsolutePosition(nodePos);
|
|
16326
|
+
node.rotation(nodeRotation);
|
|
16327
|
+
node.x(node.x() - (layerToMove.getAttrs().containerOffsetX ?? 0));
|
|
16328
|
+
node.y(node.y() - (layerToMove.getAttrs().containerOffsetY ?? 0));
|
|
16329
|
+
const nodeHandler = this.instance.getNodeHandler(node.getAttrs().nodeType);
|
|
16330
|
+
const actualNode = nodeHandler.serialize(node);
|
|
16331
|
+
this.instance.removeNode(actualNode);
|
|
16332
|
+
this.instance.addNode(actualNode, layerToMove?.getAttrs().id);
|
|
16333
|
+
}
|
|
16334
|
+
return layerToMove;
|
|
16335
|
+
}
|
|
16289
16336
|
setupDefaultNodeEvents(node) {
|
|
16290
16337
|
this.previousPointer = null;
|
|
16291
16338
|
this.instance.addEventListener("onNodesChange", () => {
|
|
@@ -16303,14 +16350,18 @@ var WeaveNode = class {
|
|
|
16303
16350
|
});
|
|
16304
16351
|
node.on("dragmove", (e) => {
|
|
16305
16352
|
if (this.isSelecting() && this.isNodeSelected(node)) {
|
|
16353
|
+
this.clearContainerTargets();
|
|
16354
|
+
const layerToMove = this.checkIfOverContainer(e.target);
|
|
16355
|
+
if (layerToMove) layerToMove.fire(WEAVE_NODE_CUSTOM_EVENTS.onTargetEnter, { bubbles: true });
|
|
16306
16356
|
this.instance.updateNode(this.serialize(node));
|
|
16307
|
-
e.cancelBubble = true;
|
|
16308
16357
|
}
|
|
16309
16358
|
});
|
|
16310
16359
|
node.on("dragend", (e) => {
|
|
16311
16360
|
if (this.isSelecting() && this.isNodeSelected(node)) {
|
|
16361
|
+
this.clearContainerTargets();
|
|
16362
|
+
const layerToMove = this.moveNodeToContainer(e.target);
|
|
16363
|
+
if (layerToMove) return;
|
|
16312
16364
|
this.instance.updateNode(this.serialize(node));
|
|
16313
|
-
e.cancelBubble = true;
|
|
16314
16365
|
}
|
|
16315
16366
|
});
|
|
16316
16367
|
this.previousPointer = null;
|
|
@@ -16960,6 +17011,27 @@ var WeaveTargetingManager = class {
|
|
|
16960
17011
|
this.logger = this.instance.getChildLogger("targeting-manager");
|
|
16961
17012
|
this.logger.debug("Targeting manager created");
|
|
16962
17013
|
}
|
|
17014
|
+
pointIntersectsContainerElement(point) {
|
|
17015
|
+
const stage = this.instance.getStage();
|
|
17016
|
+
const relativeMousePointer = point ? point : stage.getPointerPosition() ?? {
|
|
17017
|
+
x: 0,
|
|
17018
|
+
y: 0
|
|
17019
|
+
};
|
|
17020
|
+
const intersections = this.instance.getMainLayer()?.getAllIntersections(relativeMousePointer);
|
|
17021
|
+
let intersectedNode = void 0;
|
|
17022
|
+
if (intersections) for (const node of intersections) {
|
|
17023
|
+
if (node.getAttrs().nodeId) {
|
|
17024
|
+
const parent = stage.findOne(`#${node.getAttrs().nodeId}`);
|
|
17025
|
+
intersectedNode = parent;
|
|
17026
|
+
break;
|
|
17027
|
+
}
|
|
17028
|
+
if (node.getAttrs().containerId) {
|
|
17029
|
+
intersectedNode = node;
|
|
17030
|
+
break;
|
|
17031
|
+
}
|
|
17032
|
+
}
|
|
17033
|
+
return intersectedNode;
|
|
17034
|
+
}
|
|
16963
17035
|
getMousePointer(point) {
|
|
16964
17036
|
this.logger.debug({ point }, "getMousePointer");
|
|
16965
17037
|
const stage = this.instance.getStage();
|
|
@@ -17431,6 +17503,17 @@ var WeaveStateManager = class {
|
|
|
17431
17503
|
});
|
|
17432
17504
|
return found;
|
|
17433
17505
|
}
|
|
17506
|
+
getContainerNodes(tree) {
|
|
17507
|
+
const found = [];
|
|
17508
|
+
if (tree.props.containerId) {
|
|
17509
|
+
found.push(tree);
|
|
17510
|
+
return found;
|
|
17511
|
+
}
|
|
17512
|
+
if (tree.props?.children && tree.props.children.length > 0) tree.props.children.some((child) => {
|
|
17513
|
+
found.push(...this.getContainerNodes(child));
|
|
17514
|
+
});
|
|
17515
|
+
return found;
|
|
17516
|
+
}
|
|
17434
17517
|
getNode(nodeKey) {
|
|
17435
17518
|
const state = this.instance.getStore().getState().weave;
|
|
17436
17519
|
if ((0, import_lodash.isEmpty)(state)) return {
|
|
@@ -17609,6 +17692,13 @@ var WeaveStateManager = class {
|
|
|
17609
17692
|
}
|
|
17610
17693
|
}, userName);
|
|
17611
17694
|
}
|
|
17695
|
+
getElementsTree() {
|
|
17696
|
+
const state = this.instance.getStore().getState().weave;
|
|
17697
|
+
const jsonState = JSON.parse(JSON.stringify(state, null, 2));
|
|
17698
|
+
const mainLayer = jsonState.props.children.find((node) => node.key === "mainLayer");
|
|
17699
|
+
if (!mainLayer) return [];
|
|
17700
|
+
return mainLayer.props.children;
|
|
17701
|
+
}
|
|
17612
17702
|
};
|
|
17613
17703
|
|
|
17614
17704
|
//#endregion
|
|
@@ -17699,7 +17789,7 @@ var WeaveRegisterManager = class {
|
|
|
17699
17789
|
|
|
17700
17790
|
//#endregion
|
|
17701
17791
|
//#region package.json
|
|
17702
|
-
var version = "0.
|
|
17792
|
+
var version = "0.5.0";
|
|
17703
17793
|
|
|
17704
17794
|
//#endregion
|
|
17705
17795
|
//#region src/managers/setup.ts
|
|
@@ -17771,6 +17861,10 @@ var WeaveStageManager = class {
|
|
|
17771
17861
|
const stage = this.getStage();
|
|
17772
17862
|
return stage.findOne(`#${WEAVE_NODE_LAYER_ID}`);
|
|
17773
17863
|
}
|
|
17864
|
+
getUtilityLayer() {
|
|
17865
|
+
const stage = this.getStage();
|
|
17866
|
+
return stage.findOne(`#${WEAVE_UTILITY_LAYER_ID}`);
|
|
17867
|
+
}
|
|
17774
17868
|
getInstanceRecursive(instance, filterInstanceType = []) {
|
|
17775
17869
|
const attributes = instance.getAttrs();
|
|
17776
17870
|
if (instance.getParent() && instance.getParent()?.getAttrs().nodeType && ![
|
|
@@ -17794,6 +17888,11 @@ var WeaveStageManager = class {
|
|
|
17794
17888
|
stage.draw();
|
|
17795
17889
|
this.setStage(stage);
|
|
17796
17890
|
}
|
|
17891
|
+
getContainerNodes() {
|
|
17892
|
+
return this.instance.getMainLayer()?.find((node) => {
|
|
17893
|
+
return node.getAttrs().containerId;
|
|
17894
|
+
});
|
|
17895
|
+
}
|
|
17797
17896
|
};
|
|
17798
17897
|
|
|
17799
17898
|
//#endregion
|
|
@@ -18153,6 +18252,9 @@ var Weave = class extends Emittery {
|
|
|
18153
18252
|
getMainLayer() {
|
|
18154
18253
|
return this.stageManager.getMainLayer();
|
|
18155
18254
|
}
|
|
18255
|
+
getUtilityLayer() {
|
|
18256
|
+
return this.stageManager.getUtilityLayer();
|
|
18257
|
+
}
|
|
18156
18258
|
setStage(stage) {
|
|
18157
18259
|
this.stageManager.setStage(stage);
|
|
18158
18260
|
}
|
|
@@ -18162,6 +18264,9 @@ var Weave = class extends Emittery {
|
|
|
18162
18264
|
getInstanceRecursive(instance, filterInstanceType = []) {
|
|
18163
18265
|
return this.stageManager.getInstanceRecursive(instance, filterInstanceType);
|
|
18164
18266
|
}
|
|
18267
|
+
getContainerNodes() {
|
|
18268
|
+
return this.stageManager.getContainerNodes();
|
|
18269
|
+
}
|
|
18165
18270
|
getRegisterManager() {
|
|
18166
18271
|
return this.registerManager;
|
|
18167
18272
|
}
|
|
@@ -18264,6 +18369,9 @@ var Weave = class extends Emittery {
|
|
|
18264
18369
|
moveNode(node, position, doRender = true) {
|
|
18265
18370
|
this.stateManager.moveNode(node, position, doRender);
|
|
18266
18371
|
}
|
|
18372
|
+
getElementsTree() {
|
|
18373
|
+
return this.stateManager.getElementsTree();
|
|
18374
|
+
}
|
|
18267
18375
|
moveUp(node) {
|
|
18268
18376
|
this.zIndexManager.moveUp(node);
|
|
18269
18377
|
}
|
|
@@ -18282,12 +18390,26 @@ var Weave = class extends Emittery {
|
|
|
18282
18390
|
unGroup(group) {
|
|
18283
18391
|
this.groupsManager.unGroup(group);
|
|
18284
18392
|
}
|
|
18393
|
+
pointIntersectsContainerElement(point) {
|
|
18394
|
+
return this.targetingManager.pointIntersectsContainerElement(point);
|
|
18395
|
+
}
|
|
18285
18396
|
getMousePointer(point) {
|
|
18286
18397
|
return this.targetingManager.getMousePointer(point);
|
|
18287
18398
|
}
|
|
18288
18399
|
getMousePointerRelativeToContainer(container) {
|
|
18289
18400
|
return this.targetingManager.getMousePointerRelativeToContainer(container);
|
|
18290
18401
|
}
|
|
18402
|
+
selectNodesByKey(nodesIds) {
|
|
18403
|
+
const selectionPlugin = this.getPlugin("nodesSelection");
|
|
18404
|
+
if (selectionPlugin) {
|
|
18405
|
+
const stage = this.getStage();
|
|
18406
|
+
const instanceNodes = nodesIds.map((nodeId) => {
|
|
18407
|
+
const nodeInstance = stage.findOne(`#${nodeId}`);
|
|
18408
|
+
return nodeInstance;
|
|
18409
|
+
});
|
|
18410
|
+
selectionPlugin.setSelectedNodes(instanceNodes);
|
|
18411
|
+
}
|
|
18412
|
+
}
|
|
18291
18413
|
nodesToGroupSerialized(instancesToClone) {
|
|
18292
18414
|
return this.cloningManager.nodesToGroupSerialized(instancesToClone);
|
|
18293
18415
|
}
|
|
@@ -19310,41 +19432,129 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
19310
19432
|
//#endregion
|
|
19311
19433
|
//#region src/nodes/frame/constants.ts
|
|
19312
19434
|
const WEAVE_FRAME_NODE_TYPE = "frame";
|
|
19435
|
+
const WEAVE_FRAME_NODE_SIZES_MULTIPLIER = 5;
|
|
19436
|
+
const WEAVE_FRAME_NODE_SIZES_ORIENTATION = {
|
|
19437
|
+
landscape: "landscape",
|
|
19438
|
+
portrait: "portrait"
|
|
19439
|
+
};
|
|
19440
|
+
const WEAVE_FRAME_NODE_SIZES_TYPES = {
|
|
19441
|
+
A1: "A1",
|
|
19442
|
+
A2: "A2",
|
|
19443
|
+
A3: "A3",
|
|
19444
|
+
A4: "A4",
|
|
19445
|
+
CUSTOM: "custom"
|
|
19446
|
+
};
|
|
19447
|
+
const WEAVE_FRAME_NODE_SIZES = {
|
|
19448
|
+
landscape: {
|
|
19449
|
+
A1: {
|
|
19450
|
+
width: 841,
|
|
19451
|
+
height: 594
|
|
19452
|
+
},
|
|
19453
|
+
A2: {
|
|
19454
|
+
width: 592,
|
|
19455
|
+
height: 420
|
|
19456
|
+
},
|
|
19457
|
+
A3: {
|
|
19458
|
+
width: 420,
|
|
19459
|
+
height: 297
|
|
19460
|
+
},
|
|
19461
|
+
A4: {
|
|
19462
|
+
width: 297,
|
|
19463
|
+
height: 210
|
|
19464
|
+
},
|
|
19465
|
+
custom: {
|
|
19466
|
+
width: 0,
|
|
19467
|
+
height: 0
|
|
19468
|
+
}
|
|
19469
|
+
},
|
|
19470
|
+
portrait: {
|
|
19471
|
+
A1: {
|
|
19472
|
+
width: 594,
|
|
19473
|
+
height: 841
|
|
19474
|
+
},
|
|
19475
|
+
A2: {
|
|
19476
|
+
width: 420,
|
|
19477
|
+
height: 594
|
|
19478
|
+
},
|
|
19479
|
+
A3: {
|
|
19480
|
+
width: 297,
|
|
19481
|
+
height: 420
|
|
19482
|
+
},
|
|
19483
|
+
A4: {
|
|
19484
|
+
width: 210,
|
|
19485
|
+
height: 297
|
|
19486
|
+
},
|
|
19487
|
+
custom: {
|
|
19488
|
+
width: 0,
|
|
19489
|
+
height: 0
|
|
19490
|
+
}
|
|
19491
|
+
}
|
|
19492
|
+
};
|
|
19493
|
+
const WEAVE_FRAME_NODE_DEFAULT_PROPS = {
|
|
19494
|
+
title: "Frame XXX",
|
|
19495
|
+
fontFamily: "Arial",
|
|
19496
|
+
titleHeight: 30,
|
|
19497
|
+
borderColor: "#000000ff",
|
|
19498
|
+
borderWidth: 2,
|
|
19499
|
+
frameWidth: WEAVE_FRAME_NODE_SIZES.landscape.A4.width * WEAVE_FRAME_NODE_SIZES_MULTIPLIER,
|
|
19500
|
+
frameHeight: WEAVE_FRAME_NODE_SIZES.landscape.A4.height * WEAVE_FRAME_NODE_SIZES_MULTIPLIER,
|
|
19501
|
+
frameType: WEAVE_FRAME_NODE_SIZES_TYPES.A4,
|
|
19502
|
+
frameOrientation: WEAVE_FRAME_NODE_SIZES_ORIENTATION.landscape
|
|
19503
|
+
};
|
|
19313
19504
|
|
|
19314
19505
|
//#endregion
|
|
19315
19506
|
//#region src/nodes/frame/frame.ts
|
|
19316
19507
|
var WeaveFrameNode = class extends WeaveNode {
|
|
19317
19508
|
nodeType = WEAVE_FRAME_NODE_TYPE;
|
|
19509
|
+
create(key, props) {
|
|
19510
|
+
return {
|
|
19511
|
+
key,
|
|
19512
|
+
type: this.nodeType,
|
|
19513
|
+
props: {
|
|
19514
|
+
...props,
|
|
19515
|
+
id: key,
|
|
19516
|
+
nodeType: this.nodeType,
|
|
19517
|
+
...WEAVE_FRAME_NODE_DEFAULT_PROPS,
|
|
19518
|
+
...props.fontFamily && { title: props.fontFamily },
|
|
19519
|
+
...props.title && { title: props.title },
|
|
19520
|
+
...props.titleHeight && { titleHeight: props.titleHeight },
|
|
19521
|
+
...props.borderColor && { borderColor: props.borderColor },
|
|
19522
|
+
...props.borderWidth && { borderWidth: props.borderWidth },
|
|
19523
|
+
...props.frameWidth && { frameWidth: props.frameWidth },
|
|
19524
|
+
...props.frameHeight && { frameHeight: props.frameHeight },
|
|
19525
|
+
...props.frameType && { frameType: props.frameType },
|
|
19526
|
+
...props.frameOrientation && { frameOrientation: props.frameOrientation },
|
|
19527
|
+
children: []
|
|
19528
|
+
}
|
|
19529
|
+
};
|
|
19530
|
+
}
|
|
19318
19531
|
onRender(props) {
|
|
19319
|
-
const { id } = props;
|
|
19320
|
-
const frameParams = { ...
|
|
19321
|
-
delete frameParams.fontFamily;
|
|
19322
|
-
delete frameParams.zIndex;
|
|
19323
|
-
const frameWidth = 1403;
|
|
19324
|
-
const frameHeight = 992;
|
|
19325
|
-
const titleHeight = 30;
|
|
19326
|
-
const strokeWidth = 2;
|
|
19532
|
+
const { id, zIndex,...restProps } = props;
|
|
19533
|
+
const frameParams = { ...restProps };
|
|
19327
19534
|
const frame = new Konva.Group({
|
|
19328
19535
|
...frameParams,
|
|
19536
|
+
id,
|
|
19329
19537
|
containerId: `${id}-group-internal`,
|
|
19330
|
-
|
|
19331
|
-
|
|
19538
|
+
containerOffsetX: 0,
|
|
19539
|
+
containerOffsetY: props.titleHeight + props.borderWidth,
|
|
19540
|
+
width: props.frameWidth + props.borderWidth * 2,
|
|
19541
|
+
height: props.frameHeight + props.titleHeight + props.borderWidth * 2,
|
|
19332
19542
|
fill: "#ffffffff",
|
|
19333
19543
|
clipX: 0,
|
|
19334
19544
|
clipY: 0,
|
|
19335
|
-
clipWidth: frameWidth +
|
|
19336
|
-
clipHeight: frameHeight + titleHeight +
|
|
19545
|
+
clipWidth: props.frameWidth + props.borderWidth * 2,
|
|
19546
|
+
clipHeight: props.frameHeight + props.titleHeight + props.borderWidth * 2,
|
|
19337
19547
|
name: "node"
|
|
19338
19548
|
});
|
|
19339
19549
|
const background = new Konva.Rect({
|
|
19340
19550
|
id: `${id}-bg`,
|
|
19341
19551
|
nodeId: id,
|
|
19342
|
-
x:
|
|
19343
|
-
y: titleHeight +
|
|
19344
|
-
width: frameWidth,
|
|
19345
|
-
stroke:
|
|
19346
|
-
strokeWidth:
|
|
19347
|
-
height: frameHeight,
|
|
19552
|
+
x: props.borderWidth,
|
|
19553
|
+
y: props.titleHeight + props.borderWidth,
|
|
19554
|
+
width: props.frameWidth,
|
|
19555
|
+
stroke: props.borderColor,
|
|
19556
|
+
strokeWidth: props.borderWidth,
|
|
19557
|
+
height: props.frameHeight,
|
|
19348
19558
|
fill: "#ffffffff",
|
|
19349
19559
|
draggable: false
|
|
19350
19560
|
});
|
|
@@ -19353,12 +19563,12 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
19353
19563
|
id: `${id}-title`,
|
|
19354
19564
|
x: 0,
|
|
19355
19565
|
y: 0,
|
|
19356
|
-
width: frameWidth,
|
|
19357
|
-
height: titleHeight - 10,
|
|
19566
|
+
width: props.frameWidth,
|
|
19567
|
+
height: props.titleHeight - 10,
|
|
19358
19568
|
fontSize: 20,
|
|
19359
19569
|
fontFamily: props.fontFamily,
|
|
19360
19570
|
align: "left",
|
|
19361
|
-
text:
|
|
19571
|
+
text: props.title,
|
|
19362
19572
|
stroke: "#000000ff",
|
|
19363
19573
|
strokeWidth: 1,
|
|
19364
19574
|
listening: false,
|
|
@@ -19368,20 +19578,34 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
19368
19578
|
const frameInternal = new Konva.Group({
|
|
19369
19579
|
id: `${id}-group-internal`,
|
|
19370
19580
|
nodeId: id,
|
|
19371
|
-
x:
|
|
19372
|
-
y: titleHeight +
|
|
19373
|
-
width: frameWidth,
|
|
19374
|
-
height: frameHeight,
|
|
19581
|
+
x: props.borderWidth,
|
|
19582
|
+
y: props.titleHeight + props.borderWidth,
|
|
19583
|
+
width: props.frameWidth,
|
|
19584
|
+
height: props.frameHeight,
|
|
19375
19585
|
draggable: false,
|
|
19376
19586
|
stroke: "transparent",
|
|
19377
|
-
|
|
19587
|
+
borderWidth: props.borderWidth,
|
|
19378
19588
|
clipX: 0,
|
|
19379
19589
|
clipY: 0,
|
|
19380
|
-
clipWidth: frameWidth,
|
|
19381
|
-
clipHeight: frameHeight
|
|
19590
|
+
clipWidth: props.frameWidth,
|
|
19591
|
+
clipHeight: props.frameHeight
|
|
19382
19592
|
});
|
|
19383
19593
|
frame.add(frameInternal);
|
|
19384
19594
|
this.setupDefaultNodeEvents(frame);
|
|
19595
|
+
frame.on(WEAVE_NODE_CUSTOM_EVENTS.onTargetLeave, () => {
|
|
19596
|
+
background.setAttrs({
|
|
19597
|
+
stroke: "#000000ff",
|
|
19598
|
+
strokeWidth: props.borderWidth,
|
|
19599
|
+
fill: "#ffffffff"
|
|
19600
|
+
});
|
|
19601
|
+
});
|
|
19602
|
+
frame.on(WEAVE_NODE_CUSTOM_EVENTS.onTargetEnter, () => {
|
|
19603
|
+
background.setAttrs({
|
|
19604
|
+
stroke: "#ff6863ff",
|
|
19605
|
+
strokeWidth: props.borderWidth,
|
|
19606
|
+
fill: "#ecececff"
|
|
19607
|
+
});
|
|
19608
|
+
});
|
|
19385
19609
|
return frame;
|
|
19386
19610
|
}
|
|
19387
19611
|
onUpdate(nodeInstance, nextProps) {
|
|
@@ -19429,29 +19653,35 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
|
|
|
19429
19653
|
getLayerName = void 0;
|
|
19430
19654
|
initLayer = void 0;
|
|
19431
19655
|
padding = 100;
|
|
19656
|
+
defaultStep = 3;
|
|
19432
19657
|
constructor(params) {
|
|
19433
19658
|
super();
|
|
19434
|
-
const {
|
|
19435
|
-
|
|
19436
|
-
|
|
19437
|
-
|
|
19438
|
-
|
|
19439
|
-
|
|
19440
|
-
|
|
19441
|
-
|
|
19442
|
-
|
|
19443
|
-
|
|
19444
|
-
|
|
19445
|
-
|
|
19446
|
-
|
|
19659
|
+
const { config, callbacks } = params;
|
|
19660
|
+
this.config = {
|
|
19661
|
+
zoomSteps: [
|
|
19662
|
+
.1,
|
|
19663
|
+
.25,
|
|
19664
|
+
.5,
|
|
19665
|
+
1,
|
|
19666
|
+
2,
|
|
19667
|
+
4,
|
|
19668
|
+
8
|
|
19669
|
+
],
|
|
19670
|
+
defaultZoom: 1,
|
|
19671
|
+
...config
|
|
19672
|
+
};
|
|
19673
|
+
this.callbacks = callbacks ?? {};
|
|
19674
|
+
if (!this.config.zoomSteps.includes(this.config.defaultZoom)) throw new Error(`Default zoom ${this.config.defaultZoom} is not in zoom steps`);
|
|
19675
|
+
this.actualStep = this.config.zoomSteps.findIndex((step) => step === this.config.defaultZoom);
|
|
19676
|
+
this.actualScale = this.config.zoomSteps[this.actualStep];
|
|
19447
19677
|
this.defaultStep = this.actualStep;
|
|
19448
|
-
this.onZoomChangeCb = onZoomChange;
|
|
19678
|
+
this.onZoomChangeCb = this.callbacks?.onZoomChange;
|
|
19449
19679
|
}
|
|
19450
19680
|
getName() {
|
|
19451
19681
|
return WEAVE_STAGE_ZOOM_KEY;
|
|
19452
19682
|
}
|
|
19453
19683
|
onInit() {
|
|
19454
|
-
this.setZoom(this.zoomSteps[this.actualStep]);
|
|
19684
|
+
this.setZoom(this.config.zoomSteps[this.actualStep]);
|
|
19455
19685
|
}
|
|
19456
19686
|
setZoom(scale, centered = true) {
|
|
19457
19687
|
const stage = this.instance.getStage();
|
|
@@ -19485,7 +19715,7 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
|
|
|
19485
19715
|
}
|
|
19486
19716
|
const callbackParams = {
|
|
19487
19717
|
scale,
|
|
19488
|
-
zoomSteps: this.zoomSteps,
|
|
19718
|
+
zoomSteps: this.config.zoomSteps,
|
|
19489
19719
|
actualStep: this.actualStep,
|
|
19490
19720
|
onDefaultStep: this.actualStep === this.defaultStep,
|
|
19491
19721
|
canZoomIn: this.canZoomIn(),
|
|
@@ -19497,52 +19727,52 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
|
|
|
19497
19727
|
}
|
|
19498
19728
|
canZoomOut() {
|
|
19499
19729
|
if (!this.enabled) return false;
|
|
19500
|
-
const actualZoomIsStep = this.zoomSteps.findIndex((scale) => scale === this.actualScale);
|
|
19730
|
+
const actualZoomIsStep = this.config.zoomSteps.findIndex((scale) => scale === this.actualScale);
|
|
19501
19731
|
if (actualZoomIsStep === -1) this.actualStep = this.findClosestStepIndex();
|
|
19502
19732
|
return this.actualStep - 1 > 0;
|
|
19503
19733
|
}
|
|
19504
19734
|
canZoomIn() {
|
|
19505
19735
|
if (!this.enabled) return false;
|
|
19506
|
-
const actualZoomIsStep = this.zoomSteps.findIndex((scale) => scale === this.actualScale);
|
|
19736
|
+
const actualZoomIsStep = this.config.zoomSteps.findIndex((scale) => scale === this.actualScale);
|
|
19507
19737
|
if (actualZoomIsStep === -1) this.actualStep = this.findClosestStepIndex();
|
|
19508
|
-
return this.actualStep + 1 < this.zoomSteps.length;
|
|
19738
|
+
return this.actualStep + 1 < this.config.zoomSteps.length;
|
|
19509
19739
|
}
|
|
19510
19740
|
zoomToStep(step) {
|
|
19511
19741
|
if (!this.enabled) return;
|
|
19512
|
-
if (step < 0 || step >= this.zoomSteps.length) throw new Error(`Defined step ${step} is out of bounds`);
|
|
19742
|
+
if (step < 0 || step >= this.config.zoomSteps.length) throw new Error(`Defined step ${step} is out of bounds`);
|
|
19513
19743
|
this.actualStep = step;
|
|
19514
|
-
this.setZoom(this.zoomSteps[step]);
|
|
19744
|
+
this.setZoom(this.config.zoomSteps[step]);
|
|
19515
19745
|
}
|
|
19516
19746
|
findClosestStepIndex() {
|
|
19517
19747
|
let closestStepIndex = 0;
|
|
19518
19748
|
let actualDiff = Infinity;
|
|
19519
|
-
for (let i = 0; i < this.zoomSteps.length; i++) if (Math.abs(this.zoomSteps[i] - this.actualScale) < actualDiff) {
|
|
19749
|
+
for (let i = 0; i < this.config.zoomSteps.length; i++) if (Math.abs(this.config.zoomSteps[i] - this.actualScale) < actualDiff) {
|
|
19520
19750
|
closestStepIndex = i;
|
|
19521
|
-
actualDiff = Math.abs(this.zoomSteps[i] - this.actualScale);
|
|
19751
|
+
actualDiff = Math.abs(this.config.zoomSteps[i] - this.actualScale);
|
|
19522
19752
|
}
|
|
19523
19753
|
return closestStepIndex;
|
|
19524
19754
|
}
|
|
19525
19755
|
zoomIn() {
|
|
19526
19756
|
if (!this.enabled) return;
|
|
19527
19757
|
if (!this.canZoomIn()) return;
|
|
19528
|
-
const actualZoomIsStep = this.zoomSteps.findIndex((scale) => scale === this.actualScale);
|
|
19758
|
+
const actualZoomIsStep = this.config.zoomSteps.findIndex((scale) => scale === this.actualScale);
|
|
19529
19759
|
if (actualZoomIsStep === -1) this.actualStep = this.findClosestStepIndex();
|
|
19530
19760
|
else this.actualStep += 1;
|
|
19531
|
-
this.setZoom(this.zoomSteps[this.actualStep]);
|
|
19761
|
+
this.setZoom(this.config.zoomSteps[this.actualStep]);
|
|
19532
19762
|
}
|
|
19533
19763
|
zoomOut() {
|
|
19534
19764
|
if (!this.enabled) return;
|
|
19535
19765
|
if (!this.canZoomOut()) return;
|
|
19536
|
-
const actualZoomIsStep = this.zoomSteps.findIndex((scale) => scale === this.actualScale);
|
|
19766
|
+
const actualZoomIsStep = this.config.zoomSteps.findIndex((scale) => scale === this.actualScale);
|
|
19537
19767
|
if (actualZoomIsStep === -1) this.actualStep = this.findClosestStepIndex();
|
|
19538
19768
|
else this.actualStep -= 1;
|
|
19539
|
-
this.setZoom(this.zoomSteps[this.actualStep]);
|
|
19769
|
+
this.setZoom(this.config.zoomSteps[this.actualStep]);
|
|
19540
19770
|
}
|
|
19541
19771
|
fitToScreen() {
|
|
19542
19772
|
if (!this.enabled) return;
|
|
19543
19773
|
const mainLayer = this.instance.getMainLayer();
|
|
19544
19774
|
if (mainLayer?.getChildren().length === 0) {
|
|
19545
|
-
this.setZoom(this.zoomSteps[this.defaultStep]);
|
|
19775
|
+
this.setZoom(this.config.zoomSteps[this.defaultStep]);
|
|
19546
19776
|
return;
|
|
19547
19777
|
}
|
|
19548
19778
|
const stage = this.instance.getStage();
|
|
@@ -20514,8 +20744,8 @@ var WeaveFrameToolAction = class extends WeaveAction {
|
|
|
20514
20744
|
}
|
|
20515
20745
|
initProps(params) {
|
|
20516
20746
|
return {
|
|
20517
|
-
title:
|
|
20518
|
-
fontFamily: params?.fontFamily ??
|
|
20747
|
+
title: params?.title ?? WEAVE_FRAME_NODE_DEFAULT_PROPS.title,
|
|
20748
|
+
fontFamily: params?.fontFamily ?? WEAVE_FRAME_NODE_DEFAULT_PROPS.fontFamily,
|
|
20519
20749
|
editing: false,
|
|
20520
20750
|
opacity: 1
|
|
20521
20751
|
};
|
|
@@ -20684,26 +20914,32 @@ var WeaveExportNodeToolAction = class extends WeaveAction {
|
|
|
20684
20914
|
//#endregion
|
|
20685
20915
|
//#region src/plugins/stage-grid/constants.ts
|
|
20686
20916
|
const WEAVE_STAGE_GRID_KEY = "stageGrid";
|
|
20687
|
-
const WEAVE_GRID_DEFAULT_SIZE = 50;
|
|
20688
|
-
const WEAVE_GRID_LAYER_ID = "gridLayer";
|
|
20689
20917
|
const WEAVE_GRID_TYPES = {
|
|
20690
20918
|
["LINES"]: "lines",
|
|
20691
20919
|
["DOTS"]: "dots"
|
|
20692
20920
|
};
|
|
20921
|
+
const WEAVE_GRID_DEFAULT_SIZE = 50;
|
|
20922
|
+
const WEAVE_GRID_DEFAULT_TYPE = WEAVE_GRID_TYPES.LINES;
|
|
20923
|
+
const WEAVE_GRID_DEFAULT_COLOR = "rgba(0,0,0,0.2)";
|
|
20924
|
+
const WEAVE_GRID_DEFAULT_ORIGIN_COLOR = "rgba(255,0,0,0.2)";
|
|
20925
|
+
const WEAVE_GRID_LAYER_ID = "gridLayer";
|
|
20693
20926
|
|
|
20694
20927
|
//#endregion
|
|
20695
20928
|
//#region src/plugins/stage-grid/stage-grid.ts
|
|
20696
20929
|
var WeaveStageGridPlugin = class extends WeavePlugin {
|
|
20697
|
-
type = "lines";
|
|
20698
|
-
gridColor = "rgba(0,0,0,0.2)";
|
|
20699
|
-
originColor = "rgba(255,0,0,0.2)";
|
|
20700
20930
|
constructor(params) {
|
|
20701
20931
|
super();
|
|
20702
|
-
const {
|
|
20932
|
+
const { config } = params ?? {};
|
|
20703
20933
|
this.moveToolActive = false;
|
|
20704
20934
|
this.isMouseMiddleButtonPressed = false;
|
|
20705
20935
|
this.isSpaceKeyPressed = false;
|
|
20706
|
-
this.
|
|
20936
|
+
this.config = {
|
|
20937
|
+
type: WEAVE_GRID_DEFAULT_TYPE,
|
|
20938
|
+
gridColor: WEAVE_GRID_DEFAULT_COLOR,
|
|
20939
|
+
gridOriginColor: WEAVE_GRID_DEFAULT_ORIGIN_COLOR,
|
|
20940
|
+
gridSize: WEAVE_GRID_DEFAULT_SIZE,
|
|
20941
|
+
...config
|
|
20942
|
+
};
|
|
20707
20943
|
}
|
|
20708
20944
|
getName() {
|
|
20709
20945
|
return WEAVE_STAGE_GRID_KEY;
|
|
@@ -20779,7 +21015,7 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
|
|
|
20779
21015
|
if (!layer) return;
|
|
20780
21016
|
layer.destroyChildren();
|
|
20781
21017
|
if (!this.enabled) return;
|
|
20782
|
-
switch (this.type) {
|
|
21018
|
+
switch (this.config.type) {
|
|
20783
21019
|
case WEAVE_GRID_TYPES.LINES:
|
|
20784
21020
|
this.renderGridLines();
|
|
20785
21021
|
break;
|
|
@@ -20798,41 +21034,41 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
|
|
|
20798
21034
|
const layer = this.getLayer();
|
|
20799
21035
|
if (!layer) return;
|
|
20800
21036
|
const stage = this.instance.getStage();
|
|
20801
|
-
const stageXRound = this.round(stage.x(), this.gridSize) * -1;
|
|
21037
|
+
const stageXRound = this.round(stage.x(), this.config.gridSize) * -1;
|
|
20802
21038
|
const pointsX = [];
|
|
20803
|
-
for (let i = stageXRound; i < stageXRound + stage.width(); i += this.gridSize) pointsX.push(i / stage.scaleX());
|
|
20804
|
-
const stageYRound = this.round(stage.y(), this.gridSize) * -1;
|
|
21039
|
+
for (let i = stageXRound; i < stageXRound + stage.width(); i += this.config.gridSize) pointsX.push(i / stage.scaleX());
|
|
21040
|
+
const stageYRound = this.round(stage.y(), this.config.gridSize) * -1;
|
|
20805
21041
|
const pointsY = [];
|
|
20806
|
-
for (let i = stageYRound; i < stageYRound + stage.height(); i += this.gridSize) pointsY.push(i / stage.scaleY());
|
|
21042
|
+
for (let i = stageYRound; i < stageYRound + stage.height(); i += this.config.gridSize) pointsY.push(i / stage.scaleY());
|
|
20807
21043
|
for (let index = 0; index < pointsX.length; index++) {
|
|
20808
21044
|
const point = pointsX[index];
|
|
20809
|
-
let color = this.gridColor;
|
|
20810
|
-
if (point === 0) color = this.
|
|
21045
|
+
let color = this.config.gridColor;
|
|
21046
|
+
if (point === 0) color = this.config.gridOriginColor;
|
|
20811
21047
|
layer.add(new Line({
|
|
20812
21048
|
points: [
|
|
20813
21049
|
point,
|
|
20814
|
-
(-stage.y() - 2 * this.gridSize) / stage.scaleY(),
|
|
21050
|
+
(-stage.y() - 2 * this.config.gridSize) / stage.scaleY(),
|
|
20815
21051
|
point,
|
|
20816
|
-
(stage.height() - stage.y() + 2 * this.gridSize) / stage.scaleY()
|
|
21052
|
+
(stage.height() - stage.y() + 2 * this.config.gridSize) / stage.scaleY()
|
|
20817
21053
|
],
|
|
20818
21054
|
stroke: color,
|
|
20819
|
-
strokeWidth: (point % (10 * (this.gridSize / stage.scaleX())) === 0 ? 2.5 : .5) / stage.scaleX(),
|
|
21055
|
+
strokeWidth: (point % (10 * (this.config.gridSize / stage.scaleX())) === 0 ? 2.5 : .5) / stage.scaleX(),
|
|
20820
21056
|
listening: false
|
|
20821
21057
|
}));
|
|
20822
21058
|
}
|
|
20823
21059
|
for (let index = 0; index < pointsY.length; index++) {
|
|
20824
21060
|
const point = pointsY[index];
|
|
20825
|
-
let color = this.gridColor;
|
|
20826
|
-
if (point === 0) color = this.
|
|
21061
|
+
let color = this.config.gridColor;
|
|
21062
|
+
if (point === 0) color = this.config.gridOriginColor;
|
|
20827
21063
|
layer.add(new Line({
|
|
20828
21064
|
points: [
|
|
20829
|
-
(-stage.x() - 2 * this.gridSize) / stage.scaleX(),
|
|
21065
|
+
(-stage.x() - 2 * this.config.gridSize) / stage.scaleX(),
|
|
20830
21066
|
point,
|
|
20831
|
-
(stage.width() - stage.x() + 2 * this.gridSize) / stage.scaleX(),
|
|
21067
|
+
(stage.width() - stage.x() + 2 * this.config.gridSize) / stage.scaleX(),
|
|
20832
21068
|
point
|
|
20833
21069
|
],
|
|
20834
21070
|
stroke: color,
|
|
20835
|
-
strokeWidth: (point % (10 * (this.gridSize / stage.scaleY())) === 0 ? 2.5 : .5) / stage.scaleX(),
|
|
21071
|
+
strokeWidth: (point % (10 * (this.config.gridSize / stage.scaleY())) === 0 ? 2.5 : .5) / stage.scaleX(),
|
|
20836
21072
|
listening: false
|
|
20837
21073
|
}));
|
|
20838
21074
|
}
|
|
@@ -20841,18 +21077,18 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
|
|
|
20841
21077
|
const layer = this.getLayer();
|
|
20842
21078
|
if (!layer) return;
|
|
20843
21079
|
const stage = this.instance.getStage();
|
|
20844
|
-
const stageXRound = this.round(stage.x(), this.gridSize) * -1;
|
|
21080
|
+
const stageXRound = this.round(stage.x(), this.config.gridSize) * -1;
|
|
20845
21081
|
const pointsX = [];
|
|
20846
|
-
for (let i = stageXRound; i < stageXRound + stage.width(); i += this.gridSize) pointsX.push(i / stage.scaleX());
|
|
20847
|
-
const stageYRound = this.round(stage.y(), this.gridSize) * -1;
|
|
21082
|
+
for (let i = stageXRound; i < stageXRound + stage.width(); i += this.config.gridSize) pointsX.push(i / stage.scaleX());
|
|
21083
|
+
const stageYRound = this.round(stage.y(), this.config.gridSize) * -1;
|
|
20848
21084
|
const pointsY = [];
|
|
20849
|
-
for (let i = stageYRound; i < stageYRound + stage.height(); i += this.gridSize) pointsY.push(i / stage.scaleY());
|
|
21085
|
+
for (let i = stageYRound; i < stageYRound + stage.height(); i += this.config.gridSize) pointsY.push(i / stage.scaleY());
|
|
20850
21086
|
for (let indexX = 0; indexX < pointsX.length; indexX++) {
|
|
20851
21087
|
const pointX = pointsX[indexX];
|
|
20852
21088
|
for (let indexY = 0; indexY < pointsY.length; indexY++) {
|
|
20853
21089
|
const pointY = pointsY[indexY];
|
|
20854
|
-
let color = this.gridColor;
|
|
20855
|
-
if (pointX === 0 || pointY === 0) color = this.
|
|
21090
|
+
let color = this.config.gridColor;
|
|
21091
|
+
if (pointX === 0 || pointY === 0) color = this.config.gridOriginColor;
|
|
20856
21092
|
layer.add(new Circle({
|
|
20857
21093
|
x: pointX,
|
|
20858
21094
|
y: pointY,
|
|
@@ -20879,10 +21115,10 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
|
|
|
20879
21115
|
this.onRender();
|
|
20880
21116
|
}
|
|
20881
21117
|
getType() {
|
|
20882
|
-
return this.type;
|
|
21118
|
+
return this.config.type;
|
|
20883
21119
|
}
|
|
20884
21120
|
setType(type) {
|
|
20885
|
-
this.type = type;
|
|
21121
|
+
this.config.type = type;
|
|
20886
21122
|
this.onRender();
|
|
20887
21123
|
}
|
|
20888
21124
|
};
|
|
@@ -21062,6 +21298,7 @@ var WeaveStageResizePlugin = class extends WeavePlugin {
|
|
|
21062
21298
|
|
|
21063
21299
|
//#endregion
|
|
21064
21300
|
//#region src/plugins/connected-users/constants.ts
|
|
21301
|
+
const WEAVE_CONNECTED_USERS_KEY = "connectedUsers";
|
|
21065
21302
|
const WEAVE_CONNECTED_USER_INFO_KEY = "userInfo";
|
|
21066
21303
|
|
|
21067
21304
|
//#endregion
|
|
@@ -21071,26 +21308,23 @@ var WeaveConnectedUsersPlugin = class extends WeavePlugin {
|
|
|
21071
21308
|
getLayerName = void 0;
|
|
21072
21309
|
constructor(params) {
|
|
21073
21310
|
super();
|
|
21074
|
-
const {
|
|
21311
|
+
const { config, callbacks } = params ?? {};
|
|
21312
|
+
this.config = config;
|
|
21313
|
+
this.callbacks = callbacks ?? {};
|
|
21075
21314
|
this.connectedUsers = {};
|
|
21076
|
-
this.onConnectedUsersChanged = onConnectedUsersChanged;
|
|
21077
|
-
this.getUser = getUser ?? (() => ({
|
|
21078
|
-
name: "Unknown",
|
|
21079
|
-
email: "unknown@domain.com"
|
|
21080
|
-
}));
|
|
21081
21315
|
}
|
|
21082
21316
|
getName() {
|
|
21083
|
-
return
|
|
21317
|
+
return WEAVE_CONNECTED_USERS_KEY;
|
|
21084
21318
|
}
|
|
21085
21319
|
onInit() {
|
|
21086
21320
|
const store = this.instance.getStore();
|
|
21087
|
-
const userInfo = this.getUser();
|
|
21321
|
+
const userInfo = this.config.getUser();
|
|
21088
21322
|
store.setAwarenessInfo(WEAVE_CONNECTED_USER_INFO_KEY, userInfo);
|
|
21089
|
-
this.onConnectedUsersChanged?.({ [userInfo.name]: userInfo });
|
|
21323
|
+
this.callbacks?.onConnectedUsersChanged?.({ [userInfo.name]: userInfo });
|
|
21090
21324
|
store.onAwarenessChange((changes) => {
|
|
21091
21325
|
if (!this.enabled) {
|
|
21092
21326
|
this.connectedUsers = {};
|
|
21093
|
-
this.onConnectedUsersChanged?.({});
|
|
21327
|
+
this.callbacks?.onConnectedUsersChanged?.({});
|
|
21094
21328
|
return;
|
|
21095
21329
|
}
|
|
21096
21330
|
const newConnectedUsers = {};
|
|
@@ -21101,7 +21335,7 @@ var WeaveConnectedUsersPlugin = class extends WeavePlugin {
|
|
|
21101
21335
|
newConnectedUsers[userInformation.name] = userInformation;
|
|
21102
21336
|
}
|
|
21103
21337
|
}
|
|
21104
|
-
if (!(0, import_lodash.isEqual)(this.connectedUsers, newConnectedUsers)) this.onConnectedUsersChanged?.(newConnectedUsers);
|
|
21338
|
+
if (!(0, import_lodash.isEqual)(this.connectedUsers, newConnectedUsers)) this.callbacks?.onConnectedUsersChanged?.(newConnectedUsers);
|
|
21105
21339
|
this.connectedUsers = newConnectedUsers;
|
|
21106
21340
|
});
|
|
21107
21341
|
}
|
|
@@ -21131,14 +21365,11 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
|
|
|
21131
21365
|
userPointerBackgroundPaddingY = 8;
|
|
21132
21366
|
constructor(params) {
|
|
21133
21367
|
super();
|
|
21134
|
-
const {
|
|
21368
|
+
const { config } = params;
|
|
21135
21369
|
this.renderCursors = true;
|
|
21136
21370
|
this.usersPointers = {};
|
|
21137
21371
|
this.usersPointersTimers = {};
|
|
21138
|
-
this.
|
|
21139
|
-
name: "Unknown",
|
|
21140
|
-
email: "unknown@domain.com"
|
|
21141
|
-
}));
|
|
21372
|
+
this.config = config;
|
|
21142
21373
|
}
|
|
21143
21374
|
getName() {
|
|
21144
21375
|
return WEAVE_USERS_POINTERS_KEY;
|
|
@@ -21159,7 +21390,7 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
|
|
|
21159
21390
|
const store = this.instance.getStore();
|
|
21160
21391
|
const stage = this.instance.getStage();
|
|
21161
21392
|
store.onAwarenessChange((changes) => {
|
|
21162
|
-
const selfUser = this.getUser();
|
|
21393
|
+
const selfUser = this.config.getUser();
|
|
21163
21394
|
for (const change of changes) {
|
|
21164
21395
|
if (!change[WEAVE_USER_POINTER_KEY]) continue;
|
|
21165
21396
|
if (change[WEAVE_USER_POINTER_KEY] && selfUser.name !== change[WEAVE_USER_POINTER_KEY].user) {
|
|
@@ -21178,7 +21409,7 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
|
|
|
21178
21409
|
});
|
|
21179
21410
|
stage.on("dragmove", (e) => {
|
|
21180
21411
|
e.evt.preventDefault();
|
|
21181
|
-
const userInfo = this.getUser();
|
|
21412
|
+
const userInfo = this.config.getUser();
|
|
21182
21413
|
const mousePos = stage.getRelativePointerPosition();
|
|
21183
21414
|
if (mousePos) store.setAwarenessInfo(WEAVE_USER_POINTER_KEY, {
|
|
21184
21415
|
user: userInfo.name,
|
|
@@ -21188,7 +21419,7 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
|
|
|
21188
21419
|
});
|
|
21189
21420
|
stage.on("pointermove", (e) => {
|
|
21190
21421
|
e.evt.preventDefault();
|
|
21191
|
-
const userInfo = this.getUser();
|
|
21422
|
+
const userInfo = this.config.getUser();
|
|
21192
21423
|
const mousePos = stage.getRelativePointerPosition();
|
|
21193
21424
|
if (mousePos) store.setAwarenessInfo(WEAVE_USER_POINTER_KEY, {
|
|
21194
21425
|
user: userInfo.name,
|
|
@@ -21348,8 +21579,9 @@ const WEAVE_STAGE_DROP_AREA_KEY = "stageDropArea";
|
|
|
21348
21579
|
var WeaveStageDropAreaPlugin = class extends WeavePlugin {
|
|
21349
21580
|
getLayerName = void 0;
|
|
21350
21581
|
initLayer = void 0;
|
|
21351
|
-
constructor(
|
|
21582
|
+
constructor(params) {
|
|
21352
21583
|
super();
|
|
21584
|
+
const { callbacks } = params ?? {};
|
|
21353
21585
|
this.callbacks = callbacks;
|
|
21354
21586
|
this.enabled = true;
|
|
21355
21587
|
}
|
|
@@ -21615,4 +21847,4 @@ var WeaveNodesSnappingPlugin = class extends WeavePlugin {
|
|
|
21615
21847
|
};
|
|
21616
21848
|
|
|
21617
21849
|
//#endregion
|
|
21618
|
-
export { BRUSH_TOOL_STATE, COPY_PASTE_NODES_PLUGIN_STATE, FRAME_TOOL_ACTION_NAME, FRAME_TOOL_STATE, GUIDE_LINE_NAME, GUIDE_ORIENTATION, IMAGE_TOOL_STATE, MOVE_TOOL_ACTION_NAME, MOVE_TOOL_STATE, NODE_SNAP, PEN_TOOL_STATE, RECTANGLE_TOOL_ACTION_NAME, RECTANGLE_TOOL_STATE, SELECTION_TOOL_ACTION_NAME, SELECTION_TOOL_STATE, TEXT_TOOL_STATE, WEAVE_COPY_PASTE_NODES_KEY, WEAVE_FRAME_NODE_TYPE, WEAVE_GRID_DEFAULT_SIZE, WEAVE_GRID_LAYER_ID, WEAVE_GRID_TYPES, WEAVE_NODES_SELECTION_KEY, WEAVE_NODES_SELECTION_LAYER_ID, WEAVE_NODES_SNAPPING_KEY, WEAVE_STAGE_GRID_KEY, Weave, WeaveAction, WeaveBrushToolAction, WeaveConnectedUsersPlugin, WeaveContextMenuPlugin, WeaveCopyPasteNodesPlugin, WeaveExportNodeToolAction, WeaveExportStageToolAction, WeaveFitToScreenToolAction, WeaveFitToSelectionToolAction, WeaveFrameNode, WeaveFrameToolAction, WeaveGroupNode, WeaveImageNode, WeaveImageToolAction, WeaveLayerNode, WeaveLineNode, WeaveMoveToolAction, WeaveNode, WeaveNodesSelectionPlugin, WeaveNodesSnappingPlugin, WeavePenToolAction, WeavePlugin, WeaveRectangleNode, WeaveRectangleToolAction, WeaveSelectionToolAction, WeaveStageDropAreaPlugin, WeaveStageGridPlugin, WeaveStageNode, WeaveStagePanningPlugin, WeaveStageResizePlugin, WeaveStageZoomPlugin, WeaveStore, WeaveTextNode, WeaveTextToolAction, WeaveUsersPointersPlugin, WeaveZoomInToolAction, WeaveZoomOutToolAction, resetScale };
|
|
21850
|
+
export { BRUSH_TOOL_STATE, COPY_PASTE_NODES_PLUGIN_STATE, FRAME_TOOL_ACTION_NAME, FRAME_TOOL_STATE, GUIDE_LINE_NAME, GUIDE_ORIENTATION, IMAGE_TOOL_STATE, MOVE_TOOL_ACTION_NAME, MOVE_TOOL_STATE, NODE_SNAP, PEN_TOOL_STATE, RECTANGLE_TOOL_ACTION_NAME, RECTANGLE_TOOL_STATE, SELECTION_TOOL_ACTION_NAME, SELECTION_TOOL_STATE, TEXT_TOOL_STATE, WEAVE_COPY_PASTE_NODES_KEY, WEAVE_FRAME_NODE_DEFAULT_PROPS, WEAVE_FRAME_NODE_SIZES, WEAVE_FRAME_NODE_SIZES_MULTIPLIER, WEAVE_FRAME_NODE_SIZES_ORIENTATION, WEAVE_FRAME_NODE_SIZES_TYPES, WEAVE_FRAME_NODE_TYPE, WEAVE_GRID_DEFAULT_COLOR, WEAVE_GRID_DEFAULT_ORIGIN_COLOR, WEAVE_GRID_DEFAULT_SIZE, WEAVE_GRID_DEFAULT_TYPE, WEAVE_GRID_LAYER_ID, WEAVE_GRID_TYPES, WEAVE_NODES_SELECTION_KEY, WEAVE_NODES_SELECTION_LAYER_ID, WEAVE_NODES_SNAPPING_KEY, WEAVE_STAGE_GRID_KEY, Weave, WeaveAction, WeaveBrushToolAction, WeaveConnectedUsersPlugin, WeaveContextMenuPlugin, WeaveCopyPasteNodesPlugin, WeaveExportNodeToolAction, WeaveExportStageToolAction, WeaveFitToScreenToolAction, WeaveFitToSelectionToolAction, WeaveFrameNode, WeaveFrameToolAction, WeaveGroupNode, WeaveImageNode, WeaveImageToolAction, WeaveLayerNode, WeaveLineNode, WeaveMoveToolAction, WeaveNode, WeaveNodesSelectionPlugin, WeaveNodesSnappingPlugin, WeavePenToolAction, WeavePlugin, WeaveRectangleNode, WeaveRectangleToolAction, WeaveSelectionToolAction, WeaveStageDropAreaPlugin, WeaveStageGridPlugin, WeaveStageNode, WeaveStagePanningPlugin, WeaveStageResizePlugin, WeaveStageZoomPlugin, WeaveStore, WeaveTextNode, WeaveTextToolAction, WeaveUsersPointersPlugin, WeaveZoomInToolAction, WeaveZoomOutToolAction, resetScale };
|