@inditextech/weave-sdk 0.7.1 → 0.9.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 +167 -120
- package/dist/sdk.d.cts +87 -115
- package/dist/sdk.d.ts +87 -115
- package/dist/sdk.js +171 -124
- package/package.json +2 -2
package/dist/sdk.cjs
CHANGED
|
@@ -15639,13 +15639,12 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
|
|
|
15639
15639
|
super();
|
|
15640
15640
|
this.touchTimer = void 0;
|
|
15641
15641
|
this.tapHold = false;
|
|
15642
|
-
const {
|
|
15642
|
+
const { config } = params ?? {};
|
|
15643
15643
|
this.config = {
|
|
15644
15644
|
xOffset: WEAVE_CONTEXT_MENU_X_OFFSET_DEFAULT,
|
|
15645
15645
|
yOffset: WEAVE_CONTEXT_MENU_Y_OFFSET_DEFAULT,
|
|
15646
15646
|
...config
|
|
15647
15647
|
};
|
|
15648
|
-
this.callbacks = { ...callbacks };
|
|
15649
15648
|
}
|
|
15650
15649
|
getName() {
|
|
15651
15650
|
return WEAVE_CONTEXT_MENU_KEY;
|
|
@@ -15682,7 +15681,11 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
|
|
|
15682
15681
|
x: containerRect.left + pointerPos.x + (this.config.xOffset ?? 4),
|
|
15683
15682
|
y: containerRect.top + pointerPos.y + (this.config.yOffset ?? 4)
|
|
15684
15683
|
};
|
|
15685
|
-
this.
|
|
15684
|
+
this.instance.emitEvent("onNodeContextMenu", {
|
|
15685
|
+
selection: nodes,
|
|
15686
|
+
point,
|
|
15687
|
+
visible: true
|
|
15688
|
+
});
|
|
15686
15689
|
}
|
|
15687
15690
|
}
|
|
15688
15691
|
initEvents() {
|
|
@@ -15718,7 +15721,11 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
|
|
|
15718
15721
|
x: containerRect.left + pointerPos.x + (this.config.xOffset ?? 4),
|
|
15719
15722
|
y: containerRect.top + pointerPos.y + (this.config.yOffset ?? 4)
|
|
15720
15723
|
};
|
|
15721
|
-
this.
|
|
15724
|
+
this.instance.emitEvent("onNodeContextMenu", {
|
|
15725
|
+
selection: [],
|
|
15726
|
+
point,
|
|
15727
|
+
visible: false
|
|
15728
|
+
});
|
|
15722
15729
|
}
|
|
15723
15730
|
});
|
|
15724
15731
|
}
|
|
@@ -15738,7 +15745,7 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
|
|
|
15738
15745
|
var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
15739
15746
|
constructor(params) {
|
|
15740
15747
|
super();
|
|
15741
|
-
const { config
|
|
15748
|
+
const { config } = params ?? {};
|
|
15742
15749
|
this.config = { transformer: {
|
|
15743
15750
|
rotationSnaps: [
|
|
15744
15751
|
0,
|
|
@@ -15776,7 +15783,6 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
15776
15783
|
borderStroke: "#1e40afff",
|
|
15777
15784
|
...config?.transformer
|
|
15778
15785
|
} };
|
|
15779
|
-
this.callbacks = callbacks ?? {};
|
|
15780
15786
|
this.active = false;
|
|
15781
15787
|
this.cameFromSelectingMultiple = false;
|
|
15782
15788
|
this.selecting = false;
|
|
@@ -15794,6 +15800,10 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
15794
15800
|
const layer = new konva.default.Layer({ id: this.getLayerName() });
|
|
15795
15801
|
stage.add(layer);
|
|
15796
15802
|
}
|
|
15803
|
+
isPasting() {
|
|
15804
|
+
const copyPastePlugin = this.instance.getPlugin("copyPasteNodes");
|
|
15805
|
+
return copyPastePlugin.isPasting();
|
|
15806
|
+
}
|
|
15797
15807
|
isSelecting() {
|
|
15798
15808
|
return this.instance.getActiveAction() === "selectionTool";
|
|
15799
15809
|
}
|
|
@@ -15837,14 +15847,18 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
15837
15847
|
if (nodesSnappingPlugin && this.isSelecting() && this.isNodeSelected(node)) nodesSnappingPlugin.cleanupEvaluateGuidelines();
|
|
15838
15848
|
});
|
|
15839
15849
|
tr.on("mouseenter", (e) => {
|
|
15840
|
-
|
|
15841
|
-
|
|
15842
|
-
|
|
15850
|
+
if (!this.isPasting()) {
|
|
15851
|
+
const stage$1 = this.instance.getStage();
|
|
15852
|
+
stage$1.container().style.cursor = "grab";
|
|
15853
|
+
e.cancelBubble = true;
|
|
15854
|
+
}
|
|
15843
15855
|
});
|
|
15844
15856
|
tr.on("mouseleave", (e) => {
|
|
15845
|
-
|
|
15846
|
-
|
|
15847
|
-
|
|
15857
|
+
if (!this.isPasting()) {
|
|
15858
|
+
const stage$1 = this.instance.getStage();
|
|
15859
|
+
stage$1.container().style.cursor = "default";
|
|
15860
|
+
e.cancelBubble = true;
|
|
15861
|
+
}
|
|
15848
15862
|
});
|
|
15849
15863
|
this.tr = tr;
|
|
15850
15864
|
this.selectionRectangle = selectionRectangle;
|
|
@@ -15892,7 +15906,6 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
15892
15906
|
node: nodeHandler.serialize(node)
|
|
15893
15907
|
};
|
|
15894
15908
|
});
|
|
15895
|
-
this.callbacks?.onNodesChange?.(selectedNodes);
|
|
15896
15909
|
this.instance.emitEvent("onNodesChange", selectedNodes);
|
|
15897
15910
|
}
|
|
15898
15911
|
initEvents() {
|
|
@@ -16012,10 +16025,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
16012
16025
|
if (e.target instanceof konva.default.Stage && !selectedGroup) {
|
|
16013
16026
|
this.tr.nodes([]);
|
|
16014
16027
|
this.triggerSelectedNodesEvent();
|
|
16015
|
-
if (contextMenuPlugin && !contextMenuPlugin.isTapHold())
|
|
16016
|
-
this.callbacks?.onStageSelection?.();
|
|
16017
|
-
this.instance.emitEvent("onStageSelection", void 0);
|
|
16018
|
-
}
|
|
16028
|
+
if (contextMenuPlugin && !contextMenuPlugin.isTapHold()) this.instance.emitEvent("onStageSelection");
|
|
16019
16029
|
return;
|
|
16020
16030
|
}
|
|
16021
16031
|
const metaPressed = e.evt.shiftKey || e.evt.ctrlKey || e.evt.metaKey;
|
|
@@ -16066,6 +16076,17 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
16066
16076
|
getSelectedNodes() {
|
|
16067
16077
|
return this.tr.nodes();
|
|
16068
16078
|
}
|
|
16079
|
+
getSelectedNodesExtended() {
|
|
16080
|
+
const selectedNodes = this.tr.getNodes().map((node) => {
|
|
16081
|
+
const nodeType = node.getAttr("nodeType");
|
|
16082
|
+
const nodeHandler = this.instance.getNodeHandler(nodeType);
|
|
16083
|
+
return {
|
|
16084
|
+
instance: node,
|
|
16085
|
+
node: nodeHandler.serialize(node)
|
|
16086
|
+
};
|
|
16087
|
+
});
|
|
16088
|
+
return selectedNodes;
|
|
16089
|
+
}
|
|
16069
16090
|
removeSelectedNodes() {
|
|
16070
16091
|
const selectedNodes = this.tr.getNodes();
|
|
16071
16092
|
for (const node of selectedNodes) node.destroy();
|
|
@@ -16101,10 +16122,8 @@ const COPY_PASTE_NODES_PLUGIN_STATE = {
|
|
|
16101
16122
|
//#endregion
|
|
16102
16123
|
//#region src/plugins/copy-paste-nodes/copy-paste-nodes.ts
|
|
16103
16124
|
var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
16104
|
-
constructor(
|
|
16125
|
+
constructor() {
|
|
16105
16126
|
super();
|
|
16106
|
-
const { callbacks } = params ?? {};
|
|
16107
|
-
this.callbacks = callbacks;
|
|
16108
16127
|
this.state = COPY_PASTE_NODES_PLUGIN_STATE.IDLE;
|
|
16109
16128
|
}
|
|
16110
16129
|
getName() {
|
|
@@ -16161,18 +16180,15 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
|
16161
16180
|
await this.readClipboardData();
|
|
16162
16181
|
this.performPaste();
|
|
16163
16182
|
} catch (ex) {
|
|
16164
|
-
this.callbacks?.onPaste?.(ex);
|
|
16165
16183
|
this.instance.emitEvent("onPaste", ex);
|
|
16166
16184
|
}
|
|
16167
16185
|
try {
|
|
16168
16186
|
const items$1 = await navigator.clipboard.read();
|
|
16169
16187
|
if (items$1 && items$1.length === 1) {
|
|
16170
16188
|
const item = items$1[0];
|
|
16171
|
-
this.callbacks?.onPasteExternal?.(item);
|
|
16172
16189
|
this.instance.emitEvent("onPasteExternal", item);
|
|
16173
16190
|
}
|
|
16174
16191
|
} catch (ex) {
|
|
16175
|
-
this.callbacks?.onPaste?.(ex);
|
|
16176
16192
|
this.instance.emitEvent("onPaste", ex);
|
|
16177
16193
|
}
|
|
16178
16194
|
};
|
|
@@ -16213,7 +16229,7 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
|
16213
16229
|
node.props.x = mousePoint.x + (node.props.x - this.toPaste.weaveMinPoint.x);
|
|
16214
16230
|
node.props.y = mousePoint.y + (node.props.y - this.toPaste.weaveMinPoint.y);
|
|
16215
16231
|
this.instance.addNode(node, container?.getAttr("id"));
|
|
16216
|
-
this.
|
|
16232
|
+
this.instance.emitEvent("onPaste");
|
|
16217
16233
|
this.instance.emitEvent("onPaste", void 0);
|
|
16218
16234
|
}
|
|
16219
16235
|
this.toPaste = void 0;
|
|
@@ -16243,10 +16259,8 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
|
16243
16259
|
for (const serializedNode of result.serializedNodes) copyClipboard.weave[serializedNode.key ?? ""] = serializedNode;
|
|
16244
16260
|
try {
|
|
16245
16261
|
await this.writeClipboardData(JSON.stringify(copyClipboard));
|
|
16246
|
-
this.
|
|
16247
|
-
this.instance.emitEvent("onCopy", void 0);
|
|
16262
|
+
this.instance.emitEvent("onCopy");
|
|
16248
16263
|
} catch (ex) {
|
|
16249
|
-
this.callbacks?.onCopy?.(ex);
|
|
16250
16264
|
this.instance.emitEvent("onCopy", ex);
|
|
16251
16265
|
}
|
|
16252
16266
|
}
|
|
@@ -16390,6 +16404,14 @@ var WeaveNode = class {
|
|
|
16390
16404
|
this.previousPointer = stage.container().style.cursor;
|
|
16391
16405
|
stage.container().style.cursor = "pointer";
|
|
16392
16406
|
e.cancelBubble = true;
|
|
16407
|
+
return;
|
|
16408
|
+
}
|
|
16409
|
+
if (this.isPasting()) {
|
|
16410
|
+
const stage = this.instance.getStage();
|
|
16411
|
+
this.previousPointer = stage.container().style.cursor;
|
|
16412
|
+
stage.container().style.cursor = "crosshair";
|
|
16413
|
+
e.cancelBubble = true;
|
|
16414
|
+
return;
|
|
16393
16415
|
}
|
|
16394
16416
|
});
|
|
16395
16417
|
node.on("mouseleave", (e) => {
|
|
@@ -16399,6 +16421,14 @@ var WeaveNode = class {
|
|
|
16399
16421
|
stage.container().style.cursor = this.previousPointer ?? "default";
|
|
16400
16422
|
this.previousPointer = null;
|
|
16401
16423
|
e.cancelBubble = true;
|
|
16424
|
+
return;
|
|
16425
|
+
}
|
|
16426
|
+
if (this.isPasting()) {
|
|
16427
|
+
const stage = this.instance.getStage();
|
|
16428
|
+
this.previousPointer = stage.container().style.cursor;
|
|
16429
|
+
stage.container().style.cursor = "crosshair";
|
|
16430
|
+
e.cancelBubble = true;
|
|
16431
|
+
return;
|
|
16402
16432
|
}
|
|
16403
16433
|
});
|
|
16404
16434
|
}
|
|
@@ -16437,12 +16467,14 @@ var WeaveNode = class {
|
|
|
16437
16467
|
//#endregion
|
|
16438
16468
|
//#region src/actions/action.ts
|
|
16439
16469
|
var WeaveAction = class {
|
|
16440
|
-
constructor(
|
|
16441
|
-
this.callbacks = callbacks;
|
|
16470
|
+
constructor() {
|
|
16442
16471
|
return new Proxy(this, { set: (target, key, value) => {
|
|
16443
16472
|
Reflect.set(target, key, value);
|
|
16444
|
-
this.
|
|
16445
|
-
this.
|
|
16473
|
+
this.onPropsChange?.();
|
|
16474
|
+
this.instance?.emitEvent("onPropsChange", {
|
|
16475
|
+
instance: this,
|
|
16476
|
+
props: this.props
|
|
16477
|
+
});
|
|
16446
16478
|
return true;
|
|
16447
16479
|
} });
|
|
16448
16480
|
}
|
|
@@ -17807,7 +17839,7 @@ var WeaveRegisterManager = class {
|
|
|
17807
17839
|
|
|
17808
17840
|
//#endregion
|
|
17809
17841
|
//#region package.json
|
|
17810
|
-
var version = "0.
|
|
17842
|
+
var version = "0.9.0";
|
|
17811
17843
|
|
|
17812
17844
|
//#endregion
|
|
17813
17845
|
//#region src/managers/setup.ts
|
|
@@ -18818,10 +18850,8 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
18818
18850
|
initialized = false;
|
|
18819
18851
|
initialCursor = null;
|
|
18820
18852
|
update = void 0;
|
|
18821
|
-
constructor(
|
|
18822
|
-
|
|
18823
|
-
super({ onPropsChange });
|
|
18824
|
-
this.imageCallbacks = restCallbacks;
|
|
18853
|
+
constructor() {
|
|
18854
|
+
super();
|
|
18825
18855
|
this.initialized = false;
|
|
18826
18856
|
this.state = IMAGE_TOOL_STATE.IDLE;
|
|
18827
18857
|
this.imageId = null;
|
|
@@ -18902,7 +18932,7 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
18902
18932
|
console.error(error);
|
|
18903
18933
|
};
|
|
18904
18934
|
this.preloadImgs[this.imageId].onload = () => {
|
|
18905
|
-
this.
|
|
18935
|
+
this.instance.emitEvent("onImageLoadEnd", void 0);
|
|
18906
18936
|
if (this.imageId) this.props = {
|
|
18907
18937
|
...this.props,
|
|
18908
18938
|
width: this.preloadImgs[this.imageId].width,
|
|
@@ -18911,11 +18941,11 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
18911
18941
|
this.addImageNode();
|
|
18912
18942
|
};
|
|
18913
18943
|
this.preloadImgs[this.imageId].onerror = () => {
|
|
18914
|
-
this.
|
|
18944
|
+
this.instance.emitEvent("onImageLoadEnd", new Error("Error loading image"));
|
|
18915
18945
|
this.cancelAction();
|
|
18916
18946
|
};
|
|
18917
18947
|
this.preloadImgs[this.imageId].src = imageURL;
|
|
18918
|
-
this.
|
|
18948
|
+
this.instance.emitEvent("onImageLoadStart");
|
|
18919
18949
|
}
|
|
18920
18950
|
addImageNode() {
|
|
18921
18951
|
const stage = this.instance.getStage();
|
|
@@ -18941,7 +18971,6 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
18941
18971
|
this.setState(IMAGE_TOOL_STATE.ADDING);
|
|
18942
18972
|
}
|
|
18943
18973
|
addImage() {
|
|
18944
|
-
this.imageCallbacks?.onUploadImage(this.loadImage.bind(this));
|
|
18945
18974
|
this.setState(IMAGE_TOOL_STATE.UPLOADING);
|
|
18946
18975
|
}
|
|
18947
18976
|
handleAdding() {
|
|
@@ -18984,7 +19013,7 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
18984
19013
|
this.addImage();
|
|
18985
19014
|
return { finishUploadCallback: this.loadImage.bind(this) };
|
|
18986
19015
|
}
|
|
18987
|
-
|
|
19016
|
+
onPropsChange() {
|
|
18988
19017
|
const stage = this.instance?.getStage();
|
|
18989
19018
|
if (stage) {
|
|
18990
19019
|
const tempImage = this.instance.getStage().findOne(`#${this.tempImageId}`);
|
|
@@ -19509,12 +19538,23 @@ const WEAVE_FRAME_NODE_SIZES = {
|
|
|
19509
19538
|
}
|
|
19510
19539
|
}
|
|
19511
19540
|
};
|
|
19512
|
-
const
|
|
19513
|
-
title: "Frame XXX",
|
|
19541
|
+
const WEAVE_FRAME_NODE_DEFAULT_CONFIG = {
|
|
19514
19542
|
fontFamily: "Arial",
|
|
19543
|
+
fontStyle: "normal",
|
|
19515
19544
|
titleHeight: 30,
|
|
19516
19545
|
borderColor: "#000000ff",
|
|
19517
19546
|
borderWidth: 2,
|
|
19547
|
+
onTargetLeave: {
|
|
19548
|
+
borderColor: "#000000ff",
|
|
19549
|
+
fill: "#ffffffff"
|
|
19550
|
+
},
|
|
19551
|
+
onTargetEnter: {
|
|
19552
|
+
borderColor: "#ff6863ff",
|
|
19553
|
+
fill: "#ecececff"
|
|
19554
|
+
}
|
|
19555
|
+
};
|
|
19556
|
+
const WEAVE_FRAME_NODE_DEFAULT_PROPS = {
|
|
19557
|
+
title: "Frame XXX",
|
|
19518
19558
|
frameWidth: WEAVE_FRAME_NODE_SIZES.landscape.A4.width * WEAVE_FRAME_NODE_SIZES_MULTIPLIER,
|
|
19519
19559
|
frameHeight: WEAVE_FRAME_NODE_SIZES.landscape.A4.height * WEAVE_FRAME_NODE_SIZES_MULTIPLIER,
|
|
19520
19560
|
frameType: WEAVE_FRAME_NODE_SIZES_TYPES.A4,
|
|
@@ -19525,6 +19565,14 @@ const WEAVE_FRAME_NODE_DEFAULT_PROPS = {
|
|
|
19525
19565
|
//#region src/nodes/frame/frame.ts
|
|
19526
19566
|
var WeaveFrameNode = class extends WeaveNode {
|
|
19527
19567
|
nodeType = WEAVE_FRAME_NODE_TYPE;
|
|
19568
|
+
constructor(params) {
|
|
19569
|
+
super();
|
|
19570
|
+
const { config } = params ?? {};
|
|
19571
|
+
this.config = {
|
|
19572
|
+
...WEAVE_FRAME_NODE_DEFAULT_CONFIG,
|
|
19573
|
+
...config
|
|
19574
|
+
};
|
|
19575
|
+
}
|
|
19528
19576
|
create(key, props) {
|
|
19529
19577
|
return {
|
|
19530
19578
|
key,
|
|
@@ -19533,12 +19581,9 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
19533
19581
|
...props,
|
|
19534
19582
|
id: key,
|
|
19535
19583
|
nodeType: this.nodeType,
|
|
19584
|
+
...this.config,
|
|
19536
19585
|
...WEAVE_FRAME_NODE_DEFAULT_PROPS,
|
|
19537
|
-
...props.fontFamily && { title: props.fontFamily },
|
|
19538
19586
|
...props.title && { title: props.title },
|
|
19539
|
-
...props.titleHeight && { titleHeight: props.titleHeight },
|
|
19540
|
-
...props.borderColor && { borderColor: props.borderColor },
|
|
19541
|
-
...props.borderWidth && { borderWidth: props.borderWidth },
|
|
19542
19587
|
...props.frameWidth && { frameWidth: props.frameWidth },
|
|
19543
19588
|
...props.frameHeight && { frameHeight: props.frameHeight },
|
|
19544
19589
|
...props.frameType && { frameType: props.frameType },
|
|
@@ -19549,30 +19594,31 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
19549
19594
|
}
|
|
19550
19595
|
onRender(props) {
|
|
19551
19596
|
const { id, zIndex,...restProps } = props;
|
|
19597
|
+
const { fontFamily, fontStyle, titleHeight, borderColor, borderWidth, onTargetEnter: { borderColor: onTargetEnterBorderColor, fill: onTargetEnterFill }, onTargetLeave: { borderColor: onTargetLeaveBorderColor, fill: onTargetLeaveFill } } = this.config;
|
|
19552
19598
|
const frameParams = { ...restProps };
|
|
19553
19599
|
const frame = new konva.default.Group({
|
|
19554
19600
|
...frameParams,
|
|
19555
19601
|
id,
|
|
19556
19602
|
containerId: `${id}-group-internal`,
|
|
19557
19603
|
containerOffsetX: 0,
|
|
19558
|
-
containerOffsetY:
|
|
19559
|
-
width: props.frameWidth +
|
|
19560
|
-
height: props.frameHeight +
|
|
19604
|
+
containerOffsetY: titleHeight + borderWidth,
|
|
19605
|
+
width: props.frameWidth + borderWidth * 2,
|
|
19606
|
+
height: props.frameHeight + titleHeight + borderWidth * 2,
|
|
19561
19607
|
fill: "#ffffffff",
|
|
19562
19608
|
clipX: 0,
|
|
19563
19609
|
clipY: 0,
|
|
19564
|
-
clipWidth: props.frameWidth +
|
|
19565
|
-
clipHeight: props.frameHeight +
|
|
19610
|
+
clipWidth: props.frameWidth + borderWidth * 2,
|
|
19611
|
+
clipHeight: props.frameHeight + titleHeight + borderWidth * 2,
|
|
19566
19612
|
name: "node"
|
|
19567
19613
|
});
|
|
19568
19614
|
const background = new konva.default.Rect({
|
|
19569
19615
|
id: `${id}-bg`,
|
|
19570
19616
|
nodeId: id,
|
|
19571
|
-
x:
|
|
19572
|
-
y:
|
|
19617
|
+
x: borderWidth,
|
|
19618
|
+
y: titleHeight + borderWidth,
|
|
19573
19619
|
width: props.frameWidth,
|
|
19574
|
-
stroke:
|
|
19575
|
-
strokeWidth:
|
|
19620
|
+
stroke: borderColor,
|
|
19621
|
+
strokeWidth: borderWidth,
|
|
19576
19622
|
strokeScaleEnabled: false,
|
|
19577
19623
|
height: props.frameHeight,
|
|
19578
19624
|
fill: "#ffffffff",
|
|
@@ -19584,9 +19630,10 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
19584
19630
|
x: 0,
|
|
19585
19631
|
y: 0,
|
|
19586
19632
|
width: props.frameWidth,
|
|
19587
|
-
height:
|
|
19633
|
+
height: titleHeight - 10,
|
|
19588
19634
|
fontSize: 20,
|
|
19589
|
-
fontFamily
|
|
19635
|
+
fontFamily,
|
|
19636
|
+
fontStyle,
|
|
19590
19637
|
align: "left",
|
|
19591
19638
|
text: props.title,
|
|
19592
19639
|
stroke: "#000000ff",
|
|
@@ -19599,14 +19646,14 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
19599
19646
|
const frameInternal = new konva.default.Group({
|
|
19600
19647
|
id: `${id}-group-internal`,
|
|
19601
19648
|
nodeId: id,
|
|
19602
|
-
x:
|
|
19603
|
-
y:
|
|
19649
|
+
x: borderWidth,
|
|
19650
|
+
y: titleHeight + borderWidth,
|
|
19604
19651
|
width: props.frameWidth,
|
|
19605
19652
|
height: props.frameHeight,
|
|
19606
19653
|
draggable: false,
|
|
19607
19654
|
stroke: "transparent",
|
|
19608
19655
|
strokeScaleEnabled: false,
|
|
19609
|
-
borderWidth
|
|
19656
|
+
borderWidth,
|
|
19610
19657
|
clipX: 0,
|
|
19611
19658
|
clipY: 0,
|
|
19612
19659
|
clipWidth: props.frameWidth,
|
|
@@ -19616,16 +19663,16 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
19616
19663
|
this.setupDefaultNodeEvents(frame);
|
|
19617
19664
|
frame.on(__inditextech_weave_types.WEAVE_NODE_CUSTOM_EVENTS.onTargetLeave, () => {
|
|
19618
19665
|
background.setAttrs({
|
|
19619
|
-
stroke:
|
|
19620
|
-
strokeWidth:
|
|
19621
|
-
fill:
|
|
19666
|
+
stroke: onTargetLeaveBorderColor,
|
|
19667
|
+
strokeWidth: borderWidth,
|
|
19668
|
+
fill: onTargetLeaveFill
|
|
19622
19669
|
});
|
|
19623
19670
|
});
|
|
19624
19671
|
frame.on(__inditextech_weave_types.WEAVE_NODE_CUSTOM_EVENTS.onTargetEnter, () => {
|
|
19625
19672
|
background.setAttrs({
|
|
19626
|
-
stroke:
|
|
19627
|
-
strokeWidth:
|
|
19628
|
-
fill:
|
|
19673
|
+
stroke: onTargetEnterBorderColor,
|
|
19674
|
+
strokeWidth: borderWidth,
|
|
19675
|
+
fill: onTargetEnterFill
|
|
19629
19676
|
});
|
|
19630
19677
|
});
|
|
19631
19678
|
return frame;
|
|
@@ -19634,7 +19681,6 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
19634
19681
|
const { id } = nextProps;
|
|
19635
19682
|
const frameNode = nodeInstance;
|
|
19636
19683
|
const newProps = { ...nextProps };
|
|
19637
|
-
delete newProps.title;
|
|
19638
19684
|
nodeInstance.setAttrs({ ...newProps });
|
|
19639
19685
|
const frameTitle = frameNode.findOne(`#${id}-title`);
|
|
19640
19686
|
if (frameTitle) frameTitle.setAttrs({ text: nextProps.title });
|
|
@@ -19678,7 +19724,7 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
|
|
|
19678
19724
|
defaultStep = 3;
|
|
19679
19725
|
constructor(params) {
|
|
19680
19726
|
super();
|
|
19681
|
-
const { config
|
|
19727
|
+
const { config } = params ?? {};
|
|
19682
19728
|
this.config = {
|
|
19683
19729
|
zoomSteps: [
|
|
19684
19730
|
.1,
|
|
@@ -19692,12 +19738,10 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
|
|
|
19692
19738
|
defaultZoom: 1,
|
|
19693
19739
|
...config
|
|
19694
19740
|
};
|
|
19695
|
-
this.callbacks = callbacks ?? {};
|
|
19696
19741
|
if (!this.config.zoomSteps.includes(this.config.defaultZoom)) throw new Error(`Default zoom ${this.config.defaultZoom} is not in zoom steps`);
|
|
19697
19742
|
this.actualStep = this.config.zoomSteps.findIndex((step) => step === this.config.defaultZoom);
|
|
19698
19743
|
this.actualScale = this.config.zoomSteps[this.actualStep];
|
|
19699
19744
|
this.defaultStep = this.actualStep;
|
|
19700
|
-
this.onZoomChangeCb = this.callbacks?.onZoomChange;
|
|
19701
19745
|
}
|
|
19702
19746
|
getName() {
|
|
19703
19747
|
return WEAVE_STAGE_ZOOM_KEY;
|
|
@@ -19743,7 +19787,6 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
|
|
|
19743
19787
|
canZoomIn: this.canZoomIn(),
|
|
19744
19788
|
canZoomOut: this.canZoomOut()
|
|
19745
19789
|
};
|
|
19746
|
-
this.onZoomChangeCb?.(callbackParams);
|
|
19747
19790
|
this.instance.emitEvent("onZoomChange", callbackParams);
|
|
19748
19791
|
}
|
|
19749
19792
|
}
|
|
@@ -19857,7 +19900,7 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
|
|
|
19857
19900
|
//#endregion
|
|
19858
19901
|
//#region src/actions/zoom-out-tool/zoom-out-tool.ts
|
|
19859
19902
|
var WeaveZoomOutToolAction = class extends WeaveAction {
|
|
19860
|
-
|
|
19903
|
+
onPropsChange = void 0;
|
|
19861
19904
|
getName() {
|
|
19862
19905
|
return "zoomOutTool";
|
|
19863
19906
|
}
|
|
@@ -19886,7 +19929,7 @@ var WeaveZoomOutToolAction = class extends WeaveAction {
|
|
|
19886
19929
|
//#endregion
|
|
19887
19930
|
//#region src/actions/zoom-in-tool/zoom-in-tool.ts
|
|
19888
19931
|
var WeaveZoomInToolAction = class extends WeaveAction {
|
|
19889
|
-
|
|
19932
|
+
onPropsChange = void 0;
|
|
19890
19933
|
getName() {
|
|
19891
19934
|
return "zoomInTool";
|
|
19892
19935
|
}
|
|
@@ -19915,7 +19958,7 @@ var WeaveZoomInToolAction = class extends WeaveAction {
|
|
|
19915
19958
|
//#endregion
|
|
19916
19959
|
//#region src/actions/fit-to-screen-tool/fit-to-screen-tool.ts
|
|
19917
19960
|
var WeaveFitToScreenToolAction = class extends WeaveAction {
|
|
19918
|
-
|
|
19961
|
+
onPropsChange = void 0;
|
|
19919
19962
|
getName() {
|
|
19920
19963
|
return "fitToScreenTool";
|
|
19921
19964
|
}
|
|
@@ -19943,7 +19986,7 @@ var WeaveFitToScreenToolAction = class extends WeaveAction {
|
|
|
19943
19986
|
//#endregion
|
|
19944
19987
|
//#region src/actions/fit-to-selection-tool/fit-to-selection-tool.ts
|
|
19945
19988
|
var WeaveFitToSelectionToolAction = class extends WeaveAction {
|
|
19946
|
-
|
|
19989
|
+
onPropsChange = void 0;
|
|
19947
19990
|
getName() {
|
|
19948
19991
|
return "fitToSelectionTool";
|
|
19949
19992
|
}
|
|
@@ -19985,7 +20028,7 @@ const MOVE_TOOL_STATE = {
|
|
|
19985
20028
|
//#region src/actions/move-tool/move-tool.ts
|
|
19986
20029
|
var WeaveMoveToolAction = class extends WeaveAction {
|
|
19987
20030
|
initialized = false;
|
|
19988
|
-
|
|
20031
|
+
onPropsChange = void 0;
|
|
19989
20032
|
onInit = void 0;
|
|
19990
20033
|
constructor() {
|
|
19991
20034
|
super();
|
|
@@ -20041,7 +20084,7 @@ const SELECTION_TOOL_STATE = {
|
|
|
20041
20084
|
//#region src/actions/selection-tool/selection-tool.ts
|
|
20042
20085
|
var WeaveSelectionToolAction = class extends WeaveAction {
|
|
20043
20086
|
initialized = false;
|
|
20044
|
-
|
|
20087
|
+
onPropsChange = void 0;
|
|
20045
20088
|
onInit = void 0;
|
|
20046
20089
|
constructor() {
|
|
20047
20090
|
super();
|
|
@@ -20105,10 +20148,10 @@ const RECTANGLE_TOOL_STATE = {
|
|
|
20105
20148
|
//#region src/actions/rectangle-tool/rectangle-tool.ts
|
|
20106
20149
|
var WeaveRectangleToolAction = class extends WeaveAction {
|
|
20107
20150
|
initialized = false;
|
|
20108
|
-
|
|
20151
|
+
onPropsChange = void 0;
|
|
20109
20152
|
onInit = void 0;
|
|
20110
|
-
constructor(
|
|
20111
|
-
super(
|
|
20153
|
+
constructor() {
|
|
20154
|
+
super();
|
|
20112
20155
|
this.initialized = false;
|
|
20113
20156
|
this.state = RECTANGLE_TOOL_STATE.IDLE;
|
|
20114
20157
|
this.rectId = null;
|
|
@@ -20268,10 +20311,10 @@ const PEN_TOOL_STATE = {
|
|
|
20268
20311
|
var WeavePenToolAction = class extends WeaveAction {
|
|
20269
20312
|
initialized = false;
|
|
20270
20313
|
initialCursor = null;
|
|
20271
|
-
|
|
20314
|
+
onPropsChange = void 0;
|
|
20272
20315
|
onInit = void 0;
|
|
20273
|
-
constructor(
|
|
20274
|
-
super(
|
|
20316
|
+
constructor() {
|
|
20317
|
+
super();
|
|
20275
20318
|
this.initialized = false;
|
|
20276
20319
|
this.state = PEN_TOOL_STATE.IDLE;
|
|
20277
20320
|
this.lineId = null;
|
|
@@ -20501,10 +20544,10 @@ const BRUSH_TOOL_STATE = {
|
|
|
20501
20544
|
//#region src/actions/brush-tool/brush-tool.ts
|
|
20502
20545
|
var WeaveBrushToolAction = class extends WeaveAction {
|
|
20503
20546
|
initialized = false;
|
|
20504
|
-
|
|
20547
|
+
onPropsChange = void 0;
|
|
20505
20548
|
onInit = void 0;
|
|
20506
|
-
constructor(
|
|
20507
|
-
super(
|
|
20549
|
+
constructor() {
|
|
20550
|
+
super();
|
|
20508
20551
|
this.initialized = false;
|
|
20509
20552
|
this.state = BRUSH_TOOL_STATE.INACTIVE;
|
|
20510
20553
|
this.strokeId = null;
|
|
@@ -20650,7 +20693,7 @@ const TEXT_TOOL_STATE = {
|
|
|
20650
20693
|
var WeaveTextToolAction = class extends WeaveAction {
|
|
20651
20694
|
initialized = false;
|
|
20652
20695
|
initialCursor = null;
|
|
20653
|
-
|
|
20696
|
+
onPropsChange = void 0;
|
|
20654
20697
|
onInit = void 0;
|
|
20655
20698
|
constructor() {
|
|
20656
20699
|
super();
|
|
@@ -20757,10 +20800,10 @@ const FRAME_TOOL_STATE = {
|
|
|
20757
20800
|
//#region src/actions/frame-tool/frame-tool.ts
|
|
20758
20801
|
var WeaveFrameToolAction = class extends WeaveAction {
|
|
20759
20802
|
initialized = false;
|
|
20760
|
-
|
|
20803
|
+
onPropsChange = void 0;
|
|
20761
20804
|
onInit = void 0;
|
|
20762
|
-
constructor(
|
|
20763
|
-
super(
|
|
20805
|
+
constructor() {
|
|
20806
|
+
super();
|
|
20764
20807
|
this.initialized = false;
|
|
20765
20808
|
this.state = FRAME_TOOL_STATE.IDLE;
|
|
20766
20809
|
this.frameId = null;
|
|
@@ -20773,7 +20816,6 @@ var WeaveFrameToolAction = class extends WeaveAction {
|
|
|
20773
20816
|
initProps(params) {
|
|
20774
20817
|
return {
|
|
20775
20818
|
title: params?.title ?? WEAVE_FRAME_NODE_DEFAULT_PROPS.title,
|
|
20776
|
-
fontFamily: params?.fontFamily ?? WEAVE_FRAME_NODE_DEFAULT_PROPS.fontFamily,
|
|
20777
20819
|
editing: false,
|
|
20778
20820
|
opacity: 1
|
|
20779
20821
|
};
|
|
@@ -20861,7 +20903,7 @@ var WeaveExportStageToolAction = class extends WeaveAction {
|
|
|
20861
20903
|
backgroundColor: __inditextech_weave_types.WEAVE_EXPORT_BACKGROUND_COLOR,
|
|
20862
20904
|
quality: 1
|
|
20863
20905
|
};
|
|
20864
|
-
|
|
20906
|
+
onPropsChange = void 0;
|
|
20865
20907
|
onInit = void 0;
|
|
20866
20908
|
getName() {
|
|
20867
20909
|
return "exportStageTool";
|
|
@@ -20905,7 +20947,7 @@ var WeaveExportNodeToolAction = class extends WeaveAction {
|
|
|
20905
20947
|
backgroundColor: __inditextech_weave_types.WEAVE_EXPORT_BACKGROUND_COLOR,
|
|
20906
20948
|
quality: 1
|
|
20907
20949
|
};
|
|
20908
|
-
|
|
20950
|
+
onPropsChange = void 0;
|
|
20909
20951
|
onInit = void 0;
|
|
20910
20952
|
getName() {
|
|
20911
20953
|
return "exportNodeTool";
|
|
@@ -21297,24 +21339,32 @@ var WeaveStageResizePlugin = class extends WeavePlugin {
|
|
|
21297
21339
|
getName() {
|
|
21298
21340
|
return WEAVE_STAGE_RESIZE_KEY;
|
|
21299
21341
|
}
|
|
21300
|
-
|
|
21342
|
+
resizeStage() {
|
|
21301
21343
|
const stage = this.instance.getStage();
|
|
21302
|
-
|
|
21303
|
-
|
|
21304
|
-
|
|
21305
|
-
|
|
21306
|
-
|
|
21307
|
-
|
|
21308
|
-
|
|
21309
|
-
|
|
21310
|
-
|
|
21311
|
-
|
|
21312
|
-
|
|
21313
|
-
|
|
21314
|
-
pluginInstance.onRender?.();
|
|
21315
|
-
}
|
|
21344
|
+
const containerParent = stage.container().parentNode;
|
|
21345
|
+
if (!this.enabled) return;
|
|
21346
|
+
if (containerParent) {
|
|
21347
|
+
const containerBoundBox = stage.container().getBoundingClientRect();
|
|
21348
|
+
const containerWidth = containerBoundBox.width;
|
|
21349
|
+
const containerHeight = containerBoundBox.height;
|
|
21350
|
+
stage.width(containerWidth);
|
|
21351
|
+
stage.height(containerHeight);
|
|
21352
|
+
const plugins = this.instance.getPlugins();
|
|
21353
|
+
for (const pluginId of Object.keys(plugins)) {
|
|
21354
|
+
const pluginInstance = plugins[pluginId];
|
|
21355
|
+
pluginInstance.onRender?.();
|
|
21316
21356
|
}
|
|
21357
|
+
}
|
|
21358
|
+
}
|
|
21359
|
+
onInit() {
|
|
21360
|
+
window.addEventListener("resize", () => {
|
|
21361
|
+
this.resizeStage();
|
|
21317
21362
|
});
|
|
21363
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
21364
|
+
this.resizeStage();
|
|
21365
|
+
});
|
|
21366
|
+
const stage = this.instance.getStage();
|
|
21367
|
+
resizeObserver.observe(stage.container());
|
|
21318
21368
|
}
|
|
21319
21369
|
enable() {
|
|
21320
21370
|
this.enabled = true;
|
|
@@ -21336,9 +21386,8 @@ var WeaveConnectedUsersPlugin = class extends WeavePlugin {
|
|
|
21336
21386
|
getLayerName = void 0;
|
|
21337
21387
|
constructor(params) {
|
|
21338
21388
|
super();
|
|
21339
|
-
const { config
|
|
21389
|
+
const { config } = params ?? {};
|
|
21340
21390
|
this.config = config;
|
|
21341
|
-
this.callbacks = callbacks ?? {};
|
|
21342
21391
|
this.connectedUsers = {};
|
|
21343
21392
|
}
|
|
21344
21393
|
getName() {
|
|
@@ -21348,11 +21397,11 @@ var WeaveConnectedUsersPlugin = class extends WeavePlugin {
|
|
|
21348
21397
|
const store = this.instance.getStore();
|
|
21349
21398
|
const userInfo = this.config.getUser();
|
|
21350
21399
|
store.setAwarenessInfo(WEAVE_CONNECTED_USER_INFO_KEY, userInfo);
|
|
21351
|
-
this.
|
|
21352
|
-
|
|
21400
|
+
this.instance.emitEvent("onConnectedUsersChange", { [userInfo.name]: userInfo });
|
|
21401
|
+
this.instance.addEventListener("onAwarenessChange", (changes) => {
|
|
21353
21402
|
if (!this.enabled) {
|
|
21354
21403
|
this.connectedUsers = {};
|
|
21355
|
-
this.
|
|
21404
|
+
this.instance.emitEvent("onConnectedUsersChange", {});
|
|
21356
21405
|
return;
|
|
21357
21406
|
}
|
|
21358
21407
|
const newConnectedUsers = {};
|
|
@@ -21363,7 +21412,7 @@ var WeaveConnectedUsersPlugin = class extends WeavePlugin {
|
|
|
21363
21412
|
newConnectedUsers[userInformation.name] = userInformation;
|
|
21364
21413
|
}
|
|
21365
21414
|
}
|
|
21366
|
-
if (!(0, import_lodash.isEqual)(this.connectedUsers, newConnectedUsers)) this.
|
|
21415
|
+
if (!(0, import_lodash.isEqual)(this.connectedUsers, newConnectedUsers)) this.instance.emitEvent("onConnectedUsersChange", newConnectedUsers);
|
|
21367
21416
|
this.connectedUsers = newConnectedUsers;
|
|
21368
21417
|
});
|
|
21369
21418
|
}
|
|
@@ -21417,7 +21466,7 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
|
|
|
21417
21466
|
onInit() {
|
|
21418
21467
|
const store = this.instance.getStore();
|
|
21419
21468
|
const stage = this.instance.getStage();
|
|
21420
|
-
|
|
21469
|
+
this.instance.addEventListener("onAwarenessChange", (changes) => {
|
|
21421
21470
|
const selfUser = this.config.getUser();
|
|
21422
21471
|
for (const change of changes) {
|
|
21423
21472
|
if (!change[WEAVE_USER_POINTER_KEY]) continue;
|
|
@@ -21607,10 +21656,8 @@ const WEAVE_STAGE_DROP_AREA_KEY = "stageDropArea";
|
|
|
21607
21656
|
var WeaveStageDropAreaPlugin = class extends WeavePlugin {
|
|
21608
21657
|
getLayerName = void 0;
|
|
21609
21658
|
initLayer = void 0;
|
|
21610
|
-
constructor(
|
|
21659
|
+
constructor() {
|
|
21611
21660
|
super();
|
|
21612
|
-
const { callbacks } = params ?? {};
|
|
21613
|
-
this.callbacks = callbacks;
|
|
21614
21661
|
this.enabled = true;
|
|
21615
21662
|
}
|
|
21616
21663
|
getName() {
|
|
@@ -21628,7 +21675,6 @@ var WeaveStageDropAreaPlugin = class extends WeavePlugin {
|
|
|
21628
21675
|
stage.container().addEventListener("drop", (e) => {
|
|
21629
21676
|
e.preventDefault();
|
|
21630
21677
|
e.stopPropagation();
|
|
21631
|
-
this.callbacks?.onStageDrop?.(e);
|
|
21632
21678
|
this.instance.emitEvent("onStageDrop", e);
|
|
21633
21679
|
});
|
|
21634
21680
|
}
|
|
@@ -21961,6 +22007,7 @@ exports.SELECTION_TOOL_ACTION_NAME = SELECTION_TOOL_ACTION_NAME
|
|
|
21961
22007
|
exports.SELECTION_TOOL_STATE = SELECTION_TOOL_STATE
|
|
21962
22008
|
exports.TEXT_TOOL_STATE = TEXT_TOOL_STATE
|
|
21963
22009
|
exports.WEAVE_COPY_PASTE_NODES_KEY = WEAVE_COPY_PASTE_NODES_KEY
|
|
22010
|
+
exports.WEAVE_FRAME_NODE_DEFAULT_CONFIG = WEAVE_FRAME_NODE_DEFAULT_CONFIG
|
|
21964
22011
|
exports.WEAVE_FRAME_NODE_DEFAULT_PROPS = WEAVE_FRAME_NODE_DEFAULT_PROPS
|
|
21965
22012
|
exports.WEAVE_FRAME_NODE_SIZES = WEAVE_FRAME_NODE_SIZES
|
|
21966
22013
|
exports.WEAVE_FRAME_NODE_SIZES_MULTIPLIER = WEAVE_FRAME_NODE_SIZES_MULTIPLIER
|