@inditextech/weave-sdk 0.51.0 → 0.52.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 +297 -155
- package/dist/sdk.d.cts +24 -8
- package/dist/sdk.d.cts.map +1 -1
- package/dist/sdk.d.ts +24 -8
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +296 -156
- package/dist/sdk.js.map +1 -1
- package/package.json +2 -2
package/dist/sdk.cjs
CHANGED
|
@@ -15665,10 +15665,10 @@ function clearContainerTargets(instance) {
|
|
|
15665
15665
|
const containers = instance.getContainerNodes();
|
|
15666
15666
|
for (const container of containers) container.fire(__inditextech_weave_types.WEAVE_NODE_CUSTOM_EVENTS.onTargetLeave, { bubbles: true });
|
|
15667
15667
|
}
|
|
15668
|
-
function containerOverCursor(instance, ignoreNodes) {
|
|
15668
|
+
function containerOverCursor(instance, ignoreNodes, definedCursorPosition) {
|
|
15669
15669
|
konva.default.hitOnDragEnabled = true;
|
|
15670
15670
|
const stage = instance.getStage();
|
|
15671
|
-
const cursorPosition = stage.getRelativePointerPosition();
|
|
15671
|
+
const cursorPosition = definedCursorPosition ?? stage.getRelativePointerPosition();
|
|
15672
15672
|
if (!cursorPosition) return void 0;
|
|
15673
15673
|
const containerUnderPointer = new Set();
|
|
15674
15674
|
stage.find(".containerCapable").reverse().forEach((node) => {
|
|
@@ -15775,7 +15775,10 @@ function getBoundingBox(stage, nodes) {
|
|
|
15775
15775
|
let maxX = -Infinity;
|
|
15776
15776
|
let maxY = -Infinity;
|
|
15777
15777
|
for (const node of nodes) {
|
|
15778
|
-
const box = node.getRealClientRect({
|
|
15778
|
+
const box = node.getRealClientRect({
|
|
15779
|
+
relativeTo: stage,
|
|
15780
|
+
skipTransform: false
|
|
15781
|
+
});
|
|
15779
15782
|
minX = Math.min(minX, box.x);
|
|
15780
15783
|
minY = Math.min(minY, box.y);
|
|
15781
15784
|
maxX = Math.max(maxX, box.x + box.width);
|
|
@@ -15903,6 +15906,13 @@ function getVisibleNodesInViewport(stage, referenceLayer) {
|
|
|
15903
15906
|
});
|
|
15904
15907
|
return visibleNodes;
|
|
15905
15908
|
}
|
|
15909
|
+
function getClosestParentWithId(el) {
|
|
15910
|
+
while (el) {
|
|
15911
|
+
if (el.id) return el;
|
|
15912
|
+
el = el.parentElement;
|
|
15913
|
+
}
|
|
15914
|
+
return null;
|
|
15915
|
+
}
|
|
15906
15916
|
|
|
15907
15917
|
//#endregion
|
|
15908
15918
|
//#region src/actions/selection-tool/constants.ts
|
|
@@ -15979,14 +15989,16 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
|
|
|
15979
15989
|
const containerRect = stage.container().getBoundingClientRect();
|
|
15980
15990
|
const pointerPos = stage.getPointerPosition();
|
|
15981
15991
|
if (containerRect && pointerPos) {
|
|
15982
|
-
const
|
|
15992
|
+
const contextMenuPoint = {
|
|
15983
15993
|
x: containerRect.left + pointerPos.x + (this.config.xOffset ?? 4),
|
|
15984
15994
|
y: containerRect.top + pointerPos.y + (this.config.yOffset ?? 4)
|
|
15985
15995
|
};
|
|
15996
|
+
const clickPoint = pointerPos;
|
|
15986
15997
|
this.contextMenuVisible = true;
|
|
15987
15998
|
this.instance.emitEvent("onNodeContextMenu", {
|
|
15988
15999
|
selection: nodes,
|
|
15989
|
-
|
|
16000
|
+
contextMenuPoint,
|
|
16001
|
+
clickPoint,
|
|
15990
16002
|
visible: true
|
|
15991
16003
|
});
|
|
15992
16004
|
}
|
|
@@ -15995,7 +16007,11 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
|
|
|
15995
16007
|
this.contextMenuVisible = false;
|
|
15996
16008
|
this.instance.emitEvent("onNodeContextMenu", {
|
|
15997
16009
|
selection: [],
|
|
15998
|
-
|
|
16010
|
+
contextMenuPoint: {
|
|
16011
|
+
x: 0,
|
|
16012
|
+
y: 0
|
|
16013
|
+
},
|
|
16014
|
+
clickPoint: {
|
|
15999
16015
|
x: 0,
|
|
16000
16016
|
y: 0
|
|
16001
16017
|
},
|
|
@@ -16040,9 +16056,6 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
|
|
|
16040
16056
|
this.tapHold = false;
|
|
16041
16057
|
}
|
|
16042
16058
|
});
|
|
16043
|
-
window.addEventListener("contextmenu", (e) => {
|
|
16044
|
-
e.preventDefault();
|
|
16045
|
-
});
|
|
16046
16059
|
stage.on("contextmenu", (e) => {
|
|
16047
16060
|
e.evt.preventDefault();
|
|
16048
16061
|
if (!this.enabled) return;
|
|
@@ -16054,13 +16067,15 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
|
|
|
16054
16067
|
const containerRect = stage.container().getBoundingClientRect();
|
|
16055
16068
|
const pointerPos = stage.getPointerPosition();
|
|
16056
16069
|
if (containerRect && pointerPos) {
|
|
16057
|
-
const
|
|
16070
|
+
const contextMenuPoint = {
|
|
16058
16071
|
x: containerRect.left + pointerPos.x + (this.config.xOffset ?? 4),
|
|
16059
16072
|
y: containerRect.top + pointerPos.y + (this.config.yOffset ?? 4)
|
|
16060
16073
|
};
|
|
16074
|
+
const clickPoint = pointerPos;
|
|
16061
16075
|
this.instance.emitEvent("onNodeContextMenu", {
|
|
16062
16076
|
selection: [],
|
|
16063
|
-
|
|
16077
|
+
contextMenuPoint,
|
|
16078
|
+
clickPoint,
|
|
16064
16079
|
visible: false
|
|
16065
16080
|
});
|
|
16066
16081
|
}
|
|
@@ -16269,7 +16284,8 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
16269
16284
|
selectionLayer?.add(selectionRectangle);
|
|
16270
16285
|
const tr = new konva.default.Transformer({
|
|
16271
16286
|
id: "selectionTransformer",
|
|
16272
|
-
...this.selectionOriginalConfig
|
|
16287
|
+
...this.selectionOriginalConfig,
|
|
16288
|
+
listening: true
|
|
16273
16289
|
});
|
|
16274
16290
|
selectionLayer?.add(tr);
|
|
16275
16291
|
const trHover = new konva.default.Transformer({
|
|
@@ -16281,6 +16297,29 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
16281
16297
|
listening: false
|
|
16282
16298
|
});
|
|
16283
16299
|
selectionLayer?.add(trHover);
|
|
16300
|
+
stage.on("pointermove", () => {
|
|
16301
|
+
if (tr.nodes().length === 1 && tr.nodes()[0].getAttrs().isContainerPrincipal) {
|
|
16302
|
+
const pos = stage.getPointerPosition();
|
|
16303
|
+
if (!pos) return;
|
|
16304
|
+
const shapeUnder = stage.getIntersection(pos);
|
|
16305
|
+
if (!shapeUnder) {
|
|
16306
|
+
tr.setAttrs({ listening: true });
|
|
16307
|
+
tr.forceUpdate();
|
|
16308
|
+
}
|
|
16309
|
+
if (shapeUnder && tr.getChildren().includes(shapeUnder) && shapeUnder.name() === "back") {
|
|
16310
|
+
tr.setAttrs({ listening: false });
|
|
16311
|
+
tr.forceUpdate();
|
|
16312
|
+
}
|
|
16313
|
+
if (shapeUnder && tr.nodes()[0].getChildren().includes(shapeUnder)) {
|
|
16314
|
+
tr.setAttrs({ listening: false });
|
|
16315
|
+
tr.forceUpdate();
|
|
16316
|
+
}
|
|
16317
|
+
if (shapeUnder && !tr.getChildren().includes(shapeUnder) && tr.nodes()[0].getChildren().includes(shapeUnder)) {
|
|
16318
|
+
tr.setAttrs({ listening: true });
|
|
16319
|
+
tr.forceUpdate();
|
|
16320
|
+
}
|
|
16321
|
+
}
|
|
16322
|
+
});
|
|
16284
16323
|
tr.on("transformstart", () => {
|
|
16285
16324
|
this.triggerSelectedNodesEvent();
|
|
16286
16325
|
});
|
|
@@ -16370,12 +16409,10 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
16370
16409
|
const nodeHandler = this.instance.getNodeHandler(node.getAttrs().nodeType);
|
|
16371
16410
|
if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(node));
|
|
16372
16411
|
let containerToMove = this.instance.getMainLayer();
|
|
16373
|
-
if (layerToMove)
|
|
16374
|
-
containerToMove = layerToMove;
|
|
16375
|
-
containerToMove.fire(__inditextech_weave_types.WEAVE_NODE_CUSTOM_EVENTS.onTargetLeave, { bubbles: true });
|
|
16376
|
-
}
|
|
16412
|
+
if (layerToMove) containerToMove = layerToMove;
|
|
16377
16413
|
let moved = false;
|
|
16378
16414
|
if (containerToMove && !selectionContainsFrames) moved = moveNodeToContainer(this.instance, node, containerToMove);
|
|
16415
|
+
if (containerToMove) containerToMove.fire(__inditextech_weave_types.WEAVE_NODE_CUSTOM_EVENTS.onTargetLeave, { bubbles: true });
|
|
16379
16416
|
if (!nodeHandler) return resolve();
|
|
16380
16417
|
toSelect.push(node.getAttrs().id ?? "");
|
|
16381
16418
|
if (!moved) toUpdate.push(nodeHandler.serialize(node));
|
|
@@ -16592,6 +16629,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
16592
16629
|
};
|
|
16593
16630
|
stage.on("pointermove", handleMouseMove);
|
|
16594
16631
|
stage.on("pointerup", (e) => {
|
|
16632
|
+
this.tr.setAttrs({ listening: true });
|
|
16595
16633
|
const moved = this.checkMoved(e);
|
|
16596
16634
|
this.checkDoubleTap(e);
|
|
16597
16635
|
delete this.pointers[e.evt.pointerId];
|
|
@@ -16858,6 +16896,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
16858
16896
|
//#endregion
|
|
16859
16897
|
//#region src/plugins/copy-paste-nodes/constants.ts
|
|
16860
16898
|
const WEAVE_COPY_PASTE_NODES_KEY = "copyPasteNodes";
|
|
16899
|
+
const WEAVE_COPY_PASTE_PASTE_CATCHER_ID = "weave-paste-catcher";
|
|
16861
16900
|
const WEAVE_COPY_PASTE_PASTE_MODES = {
|
|
16862
16901
|
["INTERNAL"]: "internal",
|
|
16863
16902
|
["EXTERNAL"]: "external",
|
|
@@ -16883,18 +16922,6 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
|
16883
16922
|
onInit() {
|
|
16884
16923
|
this.initEvents();
|
|
16885
16924
|
}
|
|
16886
|
-
readClipboardData() {
|
|
16887
|
-
return new Promise((resolve, reject) => {
|
|
16888
|
-
setTimeout(async () => {
|
|
16889
|
-
if (typeof navigator.clipboard === "undefined") return reject(new Error("Clipboard API not supported"));
|
|
16890
|
-
navigator.clipboard.readText().then((text) => {
|
|
16891
|
-
resolve(this.isWeaveData(text));
|
|
16892
|
-
}).catch((error) => {
|
|
16893
|
-
reject(error);
|
|
16894
|
-
});
|
|
16895
|
-
});
|
|
16896
|
-
});
|
|
16897
|
-
}
|
|
16898
16925
|
writeClipboardData(data) {
|
|
16899
16926
|
return new Promise((resolve, reject) => {
|
|
16900
16927
|
setTimeout(async () => {
|
|
@@ -16907,8 +16934,36 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
|
16907
16934
|
});
|
|
16908
16935
|
});
|
|
16909
16936
|
}
|
|
16937
|
+
existsPasteCatcher() {
|
|
16938
|
+
return document.getElementById(WEAVE_COPY_PASTE_PASTE_CATCHER_ID) !== null;
|
|
16939
|
+
}
|
|
16940
|
+
createPasteCatcher() {
|
|
16941
|
+
const stage = this.instance.getStage();
|
|
16942
|
+
if (!this.existsPasteCatcher()) {
|
|
16943
|
+
const catcher = document.createElement("div");
|
|
16944
|
+
catcher.id = WEAVE_COPY_PASTE_PASTE_CATCHER_ID;
|
|
16945
|
+
catcher.contentEditable = "true";
|
|
16946
|
+
catcher.style.position = "absolute";
|
|
16947
|
+
catcher.style.top = "-1px";
|
|
16948
|
+
catcher.style.left = "-1px";
|
|
16949
|
+
catcher.style.width = "1px";
|
|
16950
|
+
catcher.style.height = "1px";
|
|
16951
|
+
catcher.style.zIndex = "-1";
|
|
16952
|
+
catcher.style.outline = "none";
|
|
16953
|
+
catcher.style.opacity = "0";
|
|
16954
|
+
catcher.tabIndex = 0;
|
|
16955
|
+
const stageContainer = stage.container();
|
|
16956
|
+
if (stageContainer?.parentNode) stageContainer.parentNode.appendChild(catcher);
|
|
16957
|
+
}
|
|
16958
|
+
}
|
|
16959
|
+
focusPasteCatcher() {
|
|
16960
|
+
const catcher = document.getElementById(WEAVE_COPY_PASTE_PASTE_CATCHER_ID);
|
|
16961
|
+
catcher?.focus();
|
|
16962
|
+
}
|
|
16910
16963
|
initEvents() {
|
|
16911
16964
|
const stage = this.instance.getStage();
|
|
16965
|
+
this.createPasteCatcher();
|
|
16966
|
+
const catcher = document.getElementById(WEAVE_COPY_PASTE_PASTE_CATCHER_ID);
|
|
16912
16967
|
window.addEventListener("keydown", async (e) => {
|
|
16913
16968
|
if (stage.isFocused() && e.key === "c" && (e.ctrlKey || e.metaKey)) {
|
|
16914
16969
|
e.preventDefault();
|
|
@@ -16916,49 +16971,49 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
|
16916
16971
|
return;
|
|
16917
16972
|
}
|
|
16918
16973
|
if (stage.isFocused() && e.key === "v" && (e.ctrlKey || e.metaKey)) {
|
|
16919
|
-
|
|
16920
|
-
catcher?.focus();
|
|
16974
|
+
this.focusPasteCatcher();
|
|
16921
16975
|
if (!this.enabled) return;
|
|
16922
|
-
try {
|
|
16923
|
-
if (this.isClipboardAPIAvailable()) {
|
|
16924
|
-
const continueToPaste = await this.readClipboardData();
|
|
16925
|
-
if (continueToPaste) {
|
|
16926
|
-
this.state = COPY_PASTE_NODES_PLUGIN_STATE.PASTING;
|
|
16927
|
-
this.handlePaste();
|
|
16928
|
-
e.preventDefault();
|
|
16929
|
-
return;
|
|
16930
|
-
}
|
|
16931
|
-
}
|
|
16932
|
-
} catch (ex) {
|
|
16933
|
-
this.instance.emitEvent("onPaste", ex);
|
|
16934
|
-
}
|
|
16935
|
-
e.preventDefault();
|
|
16936
|
-
stage.container().focus();
|
|
16937
|
-
return;
|
|
16938
16976
|
}
|
|
16939
16977
|
});
|
|
16940
|
-
|
|
16978
|
+
if (catcher) catcher.addEventListener("paste", async (e) => {
|
|
16941
16979
|
e.preventDefault();
|
|
16942
|
-
const
|
|
16943
|
-
|
|
16980
|
+
const dataList = e.clipboardData?.items;
|
|
16981
|
+
let items = void 0;
|
|
16982
|
+
if (!items) {
|
|
16983
|
+
if (this.isClipboardAPIAvailable()) items = await navigator.clipboard.read();
|
|
16984
|
+
}
|
|
16985
|
+
if (!items && !dataList) return;
|
|
16944
16986
|
let hasWeaveData = false;
|
|
16945
16987
|
if (this.isClipboardAPIAvailable()) {
|
|
16946
|
-
|
|
16947
|
-
|
|
16948
|
-
|
|
16949
|
-
|
|
16950
|
-
|
|
16951
|
-
|
|
16988
|
+
const readText = await navigator.clipboard.readText();
|
|
16989
|
+
const continueToPaste = this.isWeaveData(readText);
|
|
16990
|
+
if (continueToPaste) hasWeaveData = true;
|
|
16991
|
+
} else for (const item of dataList ?? []) if (item.type === "text/plain") {
|
|
16992
|
+
const text = await this.getTextFromClipboard(item);
|
|
16993
|
+
if (this.isWeaveData(text)) {
|
|
16994
|
+
hasWeaveData = true;
|
|
16995
|
+
this.toPaste = JSON.parse(text);
|
|
16952
16996
|
}
|
|
16953
16997
|
}
|
|
16954
16998
|
if (hasWeaveData) {
|
|
16955
16999
|
this.handlePaste();
|
|
16956
17000
|
return;
|
|
16957
17001
|
}
|
|
16958
|
-
const
|
|
16959
|
-
|
|
16960
|
-
|
|
16961
|
-
|
|
17002
|
+
const container = stage.container();
|
|
17003
|
+
const scale = stage.scale();
|
|
17004
|
+
const position = stage.position();
|
|
17005
|
+
const width = container.clientWidth;
|
|
17006
|
+
const height = container.clientHeight;
|
|
17007
|
+
const centerX = (width / 2 - position.x) / scale.x;
|
|
17008
|
+
const centerY = (height / 2 - position.y) / scale.y;
|
|
17009
|
+
const pastePosition = {
|
|
17010
|
+
x: centerX,
|
|
17011
|
+
y: centerY
|
|
17012
|
+
};
|
|
17013
|
+
this.instance.emitEvent("onPasteExternal", {
|
|
17014
|
+
position: pastePosition,
|
|
17015
|
+
dataList,
|
|
17016
|
+
items
|
|
16962
17017
|
});
|
|
16963
17018
|
});
|
|
16964
17019
|
}
|
|
@@ -16984,8 +17039,8 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
|
16984
17039
|
}
|
|
16985
17040
|
mapToPasteNodes() {
|
|
16986
17041
|
const nodesSelectionPlugin = this.getNodesSelectionPlugin();
|
|
16987
|
-
const selectedNodes = nodesSelectionPlugin
|
|
16988
|
-
return selectedNodes.map((node) => ({
|
|
17042
|
+
const selectedNodes = nodesSelectionPlugin?.getSelectedNodes();
|
|
17043
|
+
return (selectedNodes ?? []).map((node) => ({
|
|
16989
17044
|
konvaNode: node,
|
|
16990
17045
|
node: node.getAttrs()
|
|
16991
17046
|
}));
|
|
@@ -17001,22 +17056,50 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
|
17001
17056
|
if (child.props.children) this.recursivelyUpdateKeys(child.props.children);
|
|
17002
17057
|
}
|
|
17003
17058
|
}
|
|
17004
|
-
handlePaste() {
|
|
17059
|
+
handlePaste(position) {
|
|
17060
|
+
const stage = this.instance.getStage();
|
|
17005
17061
|
if (this.toPaste) {
|
|
17006
|
-
const
|
|
17062
|
+
const nodesToSelect = [];
|
|
17007
17063
|
for (const element of Object.keys(this.toPaste.weave)) {
|
|
17008
|
-
const node = this.toPaste.weave[element];
|
|
17064
|
+
const node = this.toPaste.weave[element].element;
|
|
17065
|
+
const posRelativeToSelection = this.toPaste.weave[element].posRelativeToSelection;
|
|
17066
|
+
let containerId = this.toPaste.weave[element].containerId;
|
|
17009
17067
|
if (node.props.children) this.recursivelyUpdateKeys(node.props.children);
|
|
17010
17068
|
const newNodeId = v4_default();
|
|
17011
17069
|
delete node.props.containerId;
|
|
17012
17070
|
node.key = newNodeId;
|
|
17013
17071
|
node.props.id = newNodeId;
|
|
17014
|
-
|
|
17015
|
-
|
|
17016
|
-
|
|
17072
|
+
if (position) {
|
|
17073
|
+
const container = containerOverCursor(this.instance, [], position);
|
|
17074
|
+
let localPos = position;
|
|
17075
|
+
if (!container) {
|
|
17076
|
+
containerId = this.instance.getMainLayer()?.getAttrs().id ?? "";
|
|
17077
|
+
const scale = stage.scaleX();
|
|
17078
|
+
const stagePos = stage.position();
|
|
17079
|
+
localPos = {
|
|
17080
|
+
x: (localPos.x - stagePos.x) / scale,
|
|
17081
|
+
y: (localPos.y - stagePos.y) / scale
|
|
17082
|
+
};
|
|
17083
|
+
}
|
|
17084
|
+
if (container && container.getAttrs().nodeType === "frame") {
|
|
17085
|
+
containerId = container.getAttrs().id ?? "";
|
|
17086
|
+
localPos = container.getAbsoluteTransform().copy().invert().point(position);
|
|
17087
|
+
}
|
|
17088
|
+
const nodeHandler = this.instance.getNodeHandler(node.props.nodeType ?? "");
|
|
17089
|
+
if (nodeHandler) {
|
|
17090
|
+
const realOffset = nodeHandler.realOffset(node);
|
|
17091
|
+
node.props.x = localPos.x + realOffset.x + posRelativeToSelection.x;
|
|
17092
|
+
node.props.y = localPos.y + realOffset.y + posRelativeToSelection.y;
|
|
17093
|
+
}
|
|
17094
|
+
}
|
|
17095
|
+
this.instance.addNode(node, containerId);
|
|
17096
|
+
const realNode = this.instance.getStage().findOne(`#${newNodeId}`);
|
|
17097
|
+
if (realNode) nodesToSelect.push(realNode);
|
|
17017
17098
|
this.instance.emitEvent("onPaste");
|
|
17018
|
-
this.instance.emitEvent("onPaste", void 0);
|
|
17019
17099
|
}
|
|
17100
|
+
this.instance.emitEvent("onPaste", void 0);
|
|
17101
|
+
const nodesSelectionPlugin = this.getNodesSelectionPlugin();
|
|
17102
|
+
nodesSelectionPlugin?.setSelectedNodes(nodesToSelect);
|
|
17020
17103
|
this.toPaste = void 0;
|
|
17021
17104
|
}
|
|
17022
17105
|
this.cancel();
|
|
@@ -17028,8 +17111,9 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
|
17028
17111
|
stage.container().focus();
|
|
17029
17112
|
this.setState(COPY_PASTE_NODES_PLUGIN_STATE.IDLE);
|
|
17030
17113
|
const nodesSelectionPlugin = this.getNodesSelectionPlugin();
|
|
17031
|
-
const selectedNodes = nodesSelectionPlugin
|
|
17032
|
-
if (selectedNodes.length === 0) return;
|
|
17114
|
+
const selectedNodes = nodesSelectionPlugin?.getSelectedNodes();
|
|
17115
|
+
if (!selectedNodes || selectedNodes.length === 0) return;
|
|
17116
|
+
const box = getBoundingBox(stage, selectedNodes);
|
|
17033
17117
|
const copyClipboard = {
|
|
17034
17118
|
weaveInstanceId: this.instance.getId(),
|
|
17035
17119
|
weave: {},
|
|
@@ -17038,33 +17122,67 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
|
17038
17122
|
y: 0
|
|
17039
17123
|
}
|
|
17040
17124
|
};
|
|
17041
|
-
const
|
|
17042
|
-
|
|
17043
|
-
|
|
17044
|
-
|
|
17045
|
-
|
|
17046
|
-
|
|
17047
|
-
this.instance.
|
|
17048
|
-
|
|
17049
|
-
|
|
17050
|
-
|
|
17125
|
+
for (const node of selectedNodes) {
|
|
17126
|
+
const nodeHandler = this.instance.getNodeHandler(node.getAttrs().nodeType);
|
|
17127
|
+
if (!nodeHandler) continue;
|
|
17128
|
+
const parentNode = node.getParent();
|
|
17129
|
+
let parentId = parentNode?.getAttrs().id;
|
|
17130
|
+
if (parentNode?.getAttrs().nodeId) {
|
|
17131
|
+
const realParent = this.instance.getStage().findOne(`#${parentNode.getAttrs().nodeId}`);
|
|
17132
|
+
if (realParent) parentId = realParent.getAttrs().id;
|
|
17133
|
+
}
|
|
17134
|
+
if (!parentId) continue;
|
|
17135
|
+
const serializedNode = nodeHandler.serialize(node);
|
|
17136
|
+
const nodeBox = node.getClientRect({ relativeTo: stage });
|
|
17137
|
+
copyClipboard.weave[serializedNode.key ?? ""] = {
|
|
17138
|
+
element: serializedNode,
|
|
17139
|
+
posRelativeToSelection: {
|
|
17140
|
+
x: nodeBox.x - (box?.x ?? 0),
|
|
17141
|
+
y: nodeBox.y - (box?.y ?? 0)
|
|
17142
|
+
},
|
|
17143
|
+
containerId: parentId
|
|
17144
|
+
};
|
|
17145
|
+
}
|
|
17146
|
+
try {
|
|
17147
|
+
await this.writeClipboardData(JSON.stringify(copyClipboard));
|
|
17148
|
+
this.instance.emitEvent("onCopy");
|
|
17149
|
+
} catch (ex) {
|
|
17150
|
+
this.instance.emitEvent("onCopy", ex);
|
|
17051
17151
|
}
|
|
17052
17152
|
}
|
|
17053
17153
|
async copy() {
|
|
17054
17154
|
await this.performCopy();
|
|
17055
17155
|
}
|
|
17056
|
-
async paste() {
|
|
17156
|
+
async paste(position) {
|
|
17157
|
+
const stage = this.instance.getStage();
|
|
17057
17158
|
try {
|
|
17058
|
-
const
|
|
17059
|
-
|
|
17159
|
+
const readText = await navigator.clipboard.readText();
|
|
17160
|
+
const continueToPaste = this.isWeaveData(readText);
|
|
17161
|
+
if (continueToPaste) {
|
|
17162
|
+
this.handlePaste(position);
|
|
17163
|
+
return;
|
|
17164
|
+
}
|
|
17060
17165
|
} catch (ex) {
|
|
17061
17166
|
this.instance.emitEvent("onPaste", ex);
|
|
17062
17167
|
}
|
|
17063
17168
|
try {
|
|
17064
17169
|
const items = await navigator.clipboard.read();
|
|
17065
|
-
|
|
17066
|
-
if (
|
|
17067
|
-
|
|
17170
|
+
let pastePosition = position;
|
|
17171
|
+
if (typeof pastePosition === "undefined") {
|
|
17172
|
+
const container = stage.container();
|
|
17173
|
+
const scale = stage.scale();
|
|
17174
|
+
const position$1 = stage.position();
|
|
17175
|
+
const centerClientX = container.clientWidth / 2;
|
|
17176
|
+
const centerClientY = container.clientHeight / 2;
|
|
17177
|
+
const centerX = (centerClientX - position$1.x) / scale.x;
|
|
17178
|
+
const centerY = (centerClientY - position$1.y) / scale.y;
|
|
17179
|
+
pastePosition = {
|
|
17180
|
+
x: centerX,
|
|
17181
|
+
y: centerY
|
|
17182
|
+
};
|
|
17183
|
+
}
|
|
17184
|
+
this.instance.emitEvent("onPasteExternal", {
|
|
17185
|
+
position: pastePosition,
|
|
17068
17186
|
items
|
|
17069
17187
|
});
|
|
17070
17188
|
} catch (ex) {
|
|
@@ -17086,7 +17204,6 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
|
17086
17204
|
}
|
|
17087
17205
|
getNodesSelectionPlugin() {
|
|
17088
17206
|
const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
17089
|
-
if (!nodesSelectionPlugin) throw new Error("WeaveNodesSelectionPlugin plugin not found");
|
|
17090
17207
|
return nodesSelectionPlugin;
|
|
17091
17208
|
}
|
|
17092
17209
|
isClipboardApiEnabled() {
|
|
@@ -17095,7 +17212,8 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
|
17095
17212
|
async getAvailablePasteMode(canHandleExternal) {
|
|
17096
17213
|
if (!this.isClipboardApiEnabled()) return WEAVE_COPY_PASTE_PASTE_MODES.CLIPBOARD_API_NOT_SUPPORTED;
|
|
17097
17214
|
try {
|
|
17098
|
-
const
|
|
17215
|
+
const readText = await navigator.clipboard.readText();
|
|
17216
|
+
const allowPaste = this.isWeaveData(readText);
|
|
17099
17217
|
if (allowPaste) return WEAVE_COPY_PASTE_PASTE_MODES.INTERNAL;
|
|
17100
17218
|
const items = await navigator.clipboard.read();
|
|
17101
17219
|
if (await canHandleExternal(items)) return WEAVE_COPY_PASTE_PASTE_MODES.EXTERNAL;
|
|
@@ -17314,7 +17432,7 @@ var WeaveNode = class {
|
|
|
17314
17432
|
if (this.isSelecting() && this.isNodeSelected(node) && this.getSelectionPlugin()?.getSelectedNodes().length === 1) {
|
|
17315
17433
|
clearContainerTargets(this.instance);
|
|
17316
17434
|
const layerToMove = containerOverCursor(this.instance, [node]);
|
|
17317
|
-
if (layerToMove && !hasFrames(node)) layerToMove.fire(__inditextech_weave_types.WEAVE_NODE_CUSTOM_EVENTS.onTargetEnter, { bubbles: true });
|
|
17435
|
+
if (layerToMove && !hasFrames(node) && node.isDragging()) layerToMove.fire(__inditextech_weave_types.WEAVE_NODE_CUSTOM_EVENTS.onTargetEnter, { bubbles: true });
|
|
17318
17436
|
}
|
|
17319
17437
|
};
|
|
17320
17438
|
node.on("dragmove", (0, import_lodash.throttle)(handleDragMove, 100));
|
|
@@ -17334,12 +17452,10 @@ var WeaveNode = class {
|
|
|
17334
17452
|
if (nodesDistanceSnappingPlugin) nodesDistanceSnappingPlugin.cleanupGuidelines();
|
|
17335
17453
|
const layerToMove = containerOverCursor(this.instance, [node]);
|
|
17336
17454
|
let containerToMove = this.instance.getMainLayer();
|
|
17337
|
-
if (layerToMove)
|
|
17338
|
-
containerToMove = layerToMove;
|
|
17339
|
-
containerToMove.fire(__inditextech_weave_types.WEAVE_NODE_CUSTOM_EVENTS.onTargetLeave, { bubbles: true });
|
|
17340
|
-
}
|
|
17455
|
+
if (layerToMove) containerToMove = layerToMove;
|
|
17341
17456
|
let moved = false;
|
|
17342
17457
|
if (containerToMove && !hasFrames(node)) moved = moveNodeToContainer(this.instance, e.target, containerToMove);
|
|
17458
|
+
if (containerToMove) containerToMove.fire(__inditextech_weave_types.WEAVE_NODE_CUSTOM_EVENTS.onTargetLeave, { bubbles: true });
|
|
17343
17459
|
if (!moved) this.instance.updateNode(this.serialize(node));
|
|
17344
17460
|
}
|
|
17345
17461
|
});
|
|
@@ -17479,6 +17595,12 @@ var WeaveNode = class {
|
|
|
17479
17595
|
const snappingPlugin = this.instance.getPlugin(WEAVE_NODES_DISTANCE_SNAPPING_PLUGIN_KEY);
|
|
17480
17596
|
return snappingPlugin;
|
|
17481
17597
|
}
|
|
17598
|
+
realOffset(instance) {
|
|
17599
|
+
return {
|
|
17600
|
+
x: 0,
|
|
17601
|
+
y: 0
|
|
17602
|
+
};
|
|
17603
|
+
}
|
|
17482
17604
|
};
|
|
17483
17605
|
|
|
17484
17606
|
//#endregion
|
|
@@ -18192,30 +18314,10 @@ var WeaveTargetingManager = class {
|
|
|
18192
18314
|
}
|
|
18193
18315
|
isNodesBoundingBoxIntersecting(nodes, nodeB) {
|
|
18194
18316
|
const stage = this.instance.getStage();
|
|
18195
|
-
const a =
|
|
18317
|
+
const a = getBoundingBox(stage, nodes);
|
|
18196
18318
|
const b = nodeB.getClientRect({ relativeTo: stage });
|
|
18197
18319
|
return !(a.x + a.width < b.x || a.x > b.x + b.width || a.y + a.height < b.y || a.y > b.y + b.height);
|
|
18198
18320
|
}
|
|
18199
|
-
getBoundingBoxOfNodes(nodes) {
|
|
18200
|
-
const stage = this.instance.getStage();
|
|
18201
|
-
if (!nodes || nodes.length === 0) return {
|
|
18202
|
-
x: 0,
|
|
18203
|
-
y: 0,
|
|
18204
|
-
width: 0,
|
|
18205
|
-
height: 0
|
|
18206
|
-
};
|
|
18207
|
-
const rects = nodes.map((node) => node.getClientRect({ relativeTo: stage }));
|
|
18208
|
-
const minX = Math.min(...rects.map((r) => r.x));
|
|
18209
|
-
const minY = Math.min(...rects.map((r) => r.y));
|
|
18210
|
-
const maxX = Math.max(...rects.map((r) => r.x + r.width));
|
|
18211
|
-
const maxY = Math.max(...rects.map((r) => r.y + r.height));
|
|
18212
|
-
return {
|
|
18213
|
-
x: minX,
|
|
18214
|
-
y: minY,
|
|
18215
|
-
width: maxX - minX,
|
|
18216
|
-
height: maxY - minY
|
|
18217
|
-
};
|
|
18218
|
-
}
|
|
18219
18321
|
nodeIntersectsContainerElement(node, actualLayer) {
|
|
18220
18322
|
const stage = this.instance.getStage();
|
|
18221
18323
|
const containers = stage.find(".containerCapable");
|
|
@@ -18235,7 +18337,7 @@ var WeaveTargetingManager = class {
|
|
|
18235
18337
|
}
|
|
18236
18338
|
} else {
|
|
18237
18339
|
let nodeActualContainer = node.getParent();
|
|
18238
|
-
if (nodeActualContainer
|
|
18340
|
+
if (nodeActualContainer?.getAttrs().nodeId) {
|
|
18239
18341
|
const realParent = stage.findOne(`#${nodeActualContainer.getAttrs().nodeId}`);
|
|
18240
18342
|
if (realParent) nodeActualContainer = realParent;
|
|
18241
18343
|
}
|
|
@@ -18264,7 +18366,7 @@ var WeaveTargetingManager = class {
|
|
|
18264
18366
|
this.logger.debug({ point }, "getMousePointer");
|
|
18265
18367
|
const stage = this.instance.getStage();
|
|
18266
18368
|
const mainLayer = this.instance.getMainLayer();
|
|
18267
|
-
let relativeMousePointer = point ? point : mainLayer?.getRelativePointerPosition() ?? {
|
|
18369
|
+
let relativeMousePointer = typeof point !== "undefined" ? point : mainLayer?.getRelativePointerPosition() ?? {
|
|
18268
18370
|
x: 0,
|
|
18269
18371
|
y: 0
|
|
18270
18372
|
};
|
|
@@ -18287,8 +18389,8 @@ var WeaveTargetingManager = class {
|
|
|
18287
18389
|
measureContainer = containerOfNode;
|
|
18288
18390
|
}
|
|
18289
18391
|
}
|
|
18290
|
-
if (container?.getAttrs().nodeType !== "layer") relativeMousePointer = measureContainer?.getRelativePointerPosition() ?? relativeMousePointer;
|
|
18291
|
-
if (container?.getAttrs().nodeType === "layer") relativeMousePointer = measureContainer?.getRelativePointerPosition() ?? {
|
|
18392
|
+
if (typeof point === "undefined" && container?.getAttrs().nodeType !== "layer") relativeMousePointer = measureContainer?.getRelativePointerPosition() ?? relativeMousePointer;
|
|
18393
|
+
if (typeof point === "undefined" && container?.getAttrs().nodeType === "layer") relativeMousePointer = measureContainer?.getRelativePointerPosition() ?? {
|
|
18292
18394
|
x: 0,
|
|
18293
18395
|
y: 0
|
|
18294
18396
|
};
|
|
@@ -19046,7 +19148,7 @@ var WeaveRegisterManager = class {
|
|
|
19046
19148
|
|
|
19047
19149
|
//#endregion
|
|
19048
19150
|
//#region package.json
|
|
19049
|
-
var version = "0.
|
|
19151
|
+
var version = "0.52.0";
|
|
19050
19152
|
|
|
19051
19153
|
//#endregion
|
|
19052
19154
|
//#region src/managers/setup.ts
|
|
@@ -20089,6 +20191,12 @@ var WeaveEllipseNode = class extends WeaveNode {
|
|
|
20089
20191
|
y: 1
|
|
20090
20192
|
});
|
|
20091
20193
|
}
|
|
20194
|
+
realOffset(element) {
|
|
20195
|
+
return {
|
|
20196
|
+
x: element.props.radiusX,
|
|
20197
|
+
y: element.props.radiusY
|
|
20198
|
+
};
|
|
20199
|
+
}
|
|
20092
20200
|
};
|
|
20093
20201
|
|
|
20094
20202
|
//#endregion
|
|
@@ -20723,10 +20831,8 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
20723
20831
|
crossOrigin: "anonymous",
|
|
20724
20832
|
...options
|
|
20725
20833
|
};
|
|
20726
|
-
|
|
20727
|
-
|
|
20728
|
-
stage.container().focus();
|
|
20729
|
-
}
|
|
20834
|
+
stage.container().style.cursor = "crosshair";
|
|
20835
|
+
stage.container().focus();
|
|
20730
20836
|
this.imageId = v4_default();
|
|
20731
20837
|
this.imageURL = imageURL;
|
|
20732
20838
|
this.preloadImgs[this.imageId] = new Image();
|
|
@@ -20753,10 +20859,8 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
20753
20859
|
}
|
|
20754
20860
|
addImageNode(position) {
|
|
20755
20861
|
const stage = this.instance.getStage();
|
|
20756
|
-
|
|
20757
|
-
|
|
20758
|
-
stage.container().focus();
|
|
20759
|
-
}
|
|
20862
|
+
stage.container().style.cursor = "crosshair";
|
|
20863
|
+
stage.container().focus();
|
|
20760
20864
|
if (position) {
|
|
20761
20865
|
this.setState(IMAGE_TOOL_STATE.SELECTED_POSITION);
|
|
20762
20866
|
this.handleAdding(position);
|
|
@@ -20817,7 +20921,10 @@ var WeaveImageToolAction = class extends WeaveAction {
|
|
|
20817
20921
|
}
|
|
20818
20922
|
});
|
|
20819
20923
|
this.instance.addNode(node, this.container?.getAttrs().id);
|
|
20820
|
-
this.instance.emitEvent("onAddedImage", {
|
|
20924
|
+
this.instance.emitEvent("onAddedImage", {
|
|
20925
|
+
imageURL: this.props.imageURL,
|
|
20926
|
+
nodeId: this.imageId
|
|
20927
|
+
});
|
|
20821
20928
|
}
|
|
20822
20929
|
this.setState(IMAGE_TOOL_STATE.FINISHED);
|
|
20823
20930
|
}
|
|
@@ -21686,6 +21793,12 @@ var WeaveStarNode = class extends WeaveNode {
|
|
|
21686
21793
|
y: 1
|
|
21687
21794
|
});
|
|
21688
21795
|
}
|
|
21796
|
+
realOffset(element) {
|
|
21797
|
+
return {
|
|
21798
|
+
x: element.props.outerRadius,
|
|
21799
|
+
y: element.props.outerRadius
|
|
21800
|
+
};
|
|
21801
|
+
}
|
|
21689
21802
|
};
|
|
21690
21803
|
|
|
21691
21804
|
//#endregion
|
|
@@ -21803,6 +21916,12 @@ var WeaveRegularPolygonNode = class extends WeaveNode {
|
|
|
21803
21916
|
y: 1
|
|
21804
21917
|
});
|
|
21805
21918
|
}
|
|
21919
|
+
realOffset(element) {
|
|
21920
|
+
return {
|
|
21921
|
+
x: element.props.radius,
|
|
21922
|
+
y: element.props.radius
|
|
21923
|
+
};
|
|
21924
|
+
}
|
|
21806
21925
|
};
|
|
21807
21926
|
|
|
21808
21927
|
//#endregion
|
|
@@ -22471,20 +22590,39 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
|
|
|
22471
22590
|
});
|
|
22472
22591
|
this.setZoom(scale, false);
|
|
22473
22592
|
}
|
|
22474
|
-
fitToSelection() {
|
|
22593
|
+
fitToSelection(smartZoom = false) {
|
|
22475
22594
|
if (!this.enabled) return;
|
|
22476
22595
|
const stage = this.instance.getStage();
|
|
22477
22596
|
const selectionPlugin = this.getNodesSelectionPlugin();
|
|
22478
22597
|
if (!selectionPlugin) return;
|
|
22479
22598
|
const nodes = selectionPlugin.getTransformer().getNodes();
|
|
22480
22599
|
if (nodes.length === 0) return;
|
|
22600
|
+
const box = getBoundingBox(stage, selectionPlugin.getTransformer().getNodes());
|
|
22601
|
+
if (box.width === 0 || box.height === 0) return;
|
|
22602
|
+
const container = stage.container();
|
|
22603
|
+
const scale = stage.scale();
|
|
22604
|
+
const viewportWidth = container.clientWidth;
|
|
22605
|
+
const viewportHeight = container.clientHeight;
|
|
22606
|
+
const visibleStageWidth = viewportWidth / scale.x;
|
|
22607
|
+
const visibleStageHeight = viewportHeight / scale.y;
|
|
22608
|
+
const fitsInView = box.width + this.config.fitToSelection.padding * 2 <= visibleStageWidth && box.height + this.config.fitToSelection.padding * 2 <= visibleStageHeight;
|
|
22609
|
+
const selectionCenter = {
|
|
22610
|
+
x: box.x + box.width / 2,
|
|
22611
|
+
y: box.y + box.height / 2
|
|
22612
|
+
};
|
|
22613
|
+
if (smartZoom && fitsInView) {
|
|
22614
|
+
const newPosition = {
|
|
22615
|
+
x: viewportWidth / 2 - selectionCenter.x * scale.x,
|
|
22616
|
+
y: viewportHeight / 2 - selectionCenter.y * scale.y
|
|
22617
|
+
};
|
|
22618
|
+
stage.position(newPosition);
|
|
22619
|
+
return;
|
|
22620
|
+
}
|
|
22481
22621
|
this.setZoom(1, false);
|
|
22482
22622
|
stage.setAttrs({
|
|
22483
22623
|
x: 0,
|
|
22484
22624
|
y: 0
|
|
22485
22625
|
});
|
|
22486
|
-
const box = getBoundingBox(stage, selectionPlugin.getTransformer().getNodes());
|
|
22487
|
-
if (box.width === 0 || box.height === 0) return;
|
|
22488
22626
|
const stageBox = {
|
|
22489
22627
|
width: stage.width(),
|
|
22490
22628
|
height: stage.height()
|
|
@@ -22493,22 +22631,22 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
|
|
|
22493
22631
|
const availableScreenHeight = stageBox.height - 2 * this.config.fitToSelection.padding;
|
|
22494
22632
|
const scaleX = availableScreenWidth / box.width;
|
|
22495
22633
|
const scaleY = availableScreenHeight / box.height;
|
|
22496
|
-
const
|
|
22634
|
+
const finalScale = Math.min(scaleX, scaleY);
|
|
22497
22635
|
stage.scale({
|
|
22498
|
-
x:
|
|
22499
|
-
y:
|
|
22636
|
+
x: finalScale,
|
|
22637
|
+
y: finalScale
|
|
22500
22638
|
});
|
|
22501
22639
|
const selectionCenterX = box.x + box.width / 2;
|
|
22502
22640
|
const selectionCenterY = box.y + box.height / 2;
|
|
22503
|
-
const canvasCenterX = stage.width() / (2 *
|
|
22504
|
-
const canvasCenterY = stage.height() / (2 *
|
|
22505
|
-
const stageX = (canvasCenterX - selectionCenterX) *
|
|
22506
|
-
const stageY = (canvasCenterY - selectionCenterY) *
|
|
22641
|
+
const canvasCenterX = stage.width() / (2 * finalScale);
|
|
22642
|
+
const canvasCenterY = stage.height() / (2 * finalScale);
|
|
22643
|
+
const stageX = (canvasCenterX - selectionCenterX) * finalScale;
|
|
22644
|
+
const stageY = (canvasCenterY - selectionCenterY) * finalScale;
|
|
22507
22645
|
stage.position({
|
|
22508
22646
|
x: stageX,
|
|
22509
22647
|
y: stageY
|
|
22510
22648
|
});
|
|
22511
|
-
this.setZoom(
|
|
22649
|
+
this.setZoom(finalScale, false);
|
|
22512
22650
|
}
|
|
22513
22651
|
enable() {
|
|
22514
22652
|
this.enabled = true;
|
|
@@ -22603,20 +22741,21 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
|
|
|
22603
22741
|
lastCenter = null;
|
|
22604
22742
|
}, { passive: false });
|
|
22605
22743
|
const handleWheel = (e) => {
|
|
22606
|
-
e.
|
|
22607
|
-
const
|
|
22608
|
-
const
|
|
22609
|
-
|
|
22610
|
-
|
|
22744
|
+
const performZoom = this.isCtrlOrMetaPressed || !this.isCtrlOrMetaPressed && e.ctrlKey && e.deltaMode === 0;
|
|
22745
|
+
const mouseX = e.clientX;
|
|
22746
|
+
const mouseY = e.clientY;
|
|
22747
|
+
const elementUnderMouse = document.elementFromPoint(mouseX, mouseY);
|
|
22748
|
+
if (!this.enabled || !performZoom || getClosestParentWithId(elementUnderMouse) !== stage.container()) return;
|
|
22749
|
+
const delta = e.deltaY > 0 ? 1 : -1;
|
|
22611
22750
|
this.zoomVelocity += delta;
|
|
22612
|
-
this.isTrackpad = Math.abs(e.
|
|
22751
|
+
this.isTrackpad = Math.abs(e.deltaY) < 15 && e.deltaMode === 0;
|
|
22613
22752
|
if (!this.zooming) {
|
|
22614
22753
|
this.zooming = true;
|
|
22615
22754
|
this.zoomInertiaType = WEAVE_STAGE_ZOOM_TYPE.MOUSE_WHEEL;
|
|
22616
22755
|
requestAnimationFrame(this.zoomTick.bind(this));
|
|
22617
22756
|
}
|
|
22618
22757
|
};
|
|
22619
|
-
|
|
22758
|
+
window.addEventListener("wheel", handleWheel, { passive: false });
|
|
22620
22759
|
}
|
|
22621
22760
|
getInertiaScale() {
|
|
22622
22761
|
const stage = this.instance.getStage();
|
|
@@ -22789,7 +22928,7 @@ var WeaveFitToSelectionToolAction = class extends WeaveAction {
|
|
|
22789
22928
|
}
|
|
22790
22929
|
trigger(cancelAction, params) {
|
|
22791
22930
|
const stageZoomPlugin = this.getStageZoomPlugin();
|
|
22792
|
-
stageZoomPlugin.fitToSelection();
|
|
22931
|
+
stageZoomPlugin.fitToSelection(params?.smartZoom ?? false);
|
|
22793
22932
|
this.previousAction = params.previousAction;
|
|
22794
22933
|
this.cancelAction = cancelAction;
|
|
22795
22934
|
this.cancelAction();
|
|
@@ -25111,7 +25250,7 @@ const WEAVE_GRID_DEFAULT_MAJOR_LINE_RATIO = 4;
|
|
|
25111
25250
|
const WEAVE_GRID_DEFAULT_RADIUS = 1;
|
|
25112
25251
|
const WEAVE_GRID_DEFAULT_MAJOR_DOT_RATIO = 2;
|
|
25113
25252
|
const WEAVE_GRID_DEFAULT_MAJOR_EVERY = 10;
|
|
25114
|
-
const WEAVE_GRID_DEFAULT_DOT_MAX_DOTS_PER_AXIS =
|
|
25253
|
+
const WEAVE_GRID_DEFAULT_DOT_MAX_DOTS_PER_AXIS = 250;
|
|
25115
25254
|
const WEAVE_GRID_LAYER_ID = "gridLayer";
|
|
25116
25255
|
|
|
25117
25256
|
//#endregion
|
|
@@ -25486,16 +25625,17 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
25486
25625
|
this.panning = false;
|
|
25487
25626
|
});
|
|
25488
25627
|
const handleWheel = (e) => {
|
|
25489
|
-
e.
|
|
25490
|
-
const
|
|
25491
|
-
const
|
|
25492
|
-
|
|
25628
|
+
const performPanning = !this.isCtrlOrMetaPressed && !e.ctrlKey;
|
|
25629
|
+
const mouseX = e.clientX;
|
|
25630
|
+
const mouseY = e.clientY;
|
|
25631
|
+
const elementUnderMouse = document.elementFromPoint(mouseX, mouseY);
|
|
25632
|
+
if (!this.enabled || this.isCtrlOrMetaPressed || e.buttons === 4 || !performPanning || getClosestParentWithId(elementUnderMouse) !== stage.container()) return;
|
|
25493
25633
|
this.getContextMenuPlugin()?.cancelLongPressTimer();
|
|
25494
|
-
stage
|
|
25495
|
-
stage
|
|
25634
|
+
stage.x(stage.x() - e.deltaX);
|
|
25635
|
+
stage.y(stage.y() - e.deltaY);
|
|
25496
25636
|
this.instance.emitEvent("onStageMove");
|
|
25497
25637
|
};
|
|
25498
|
-
|
|
25638
|
+
window.addEventListener("wheel", handleWheel, { passive: false });
|
|
25499
25639
|
stage.container().style.touchAction = "none";
|
|
25500
25640
|
stage.container().style.userSelect = "none";
|
|
25501
25641
|
stage.container().style.setProperty("-webkit-user-drag", "none");
|
|
@@ -26894,6 +27034,7 @@ exports.TEXT_TOOL_ACTION_NAME = TEXT_TOOL_ACTION_NAME
|
|
|
26894
27034
|
exports.TEXT_TOOL_STATE = TEXT_TOOL_STATE
|
|
26895
27035
|
exports.WEAVE_ARROW_NODE_TYPE = WEAVE_ARROW_NODE_TYPE
|
|
26896
27036
|
exports.WEAVE_COPY_PASTE_NODES_KEY = WEAVE_COPY_PASTE_NODES_KEY
|
|
27037
|
+
exports.WEAVE_COPY_PASTE_PASTE_CATCHER_ID = WEAVE_COPY_PASTE_PASTE_CATCHER_ID
|
|
26897
27038
|
exports.WEAVE_COPY_PASTE_PASTE_MODES = WEAVE_COPY_PASTE_PASTE_MODES
|
|
26898
27039
|
exports.WEAVE_DEFAULT_USER_INFO_FUNCTION = WEAVE_DEFAULT_USER_INFO_FUNCTION
|
|
26899
27040
|
exports.WEAVE_ELLIPSE_NODE_TYPE = WEAVE_ELLIPSE_NODE_TYPE
|
|
@@ -26989,6 +27130,7 @@ exports.clearContainerTargets = clearContainerTargets
|
|
|
26989
27130
|
exports.containerOverCursor = containerOverCursor
|
|
26990
27131
|
exports.containsNodeDeep = containsNodeDeep
|
|
26991
27132
|
exports.getBoundingBox = getBoundingBox
|
|
27133
|
+
exports.getClosestParentWithId = getClosestParentWithId
|
|
26992
27134
|
exports.getContrastTextColor = getContrastTextColor
|
|
26993
27135
|
exports.getExportBoundingBox = getExportBoundingBox
|
|
26994
27136
|
exports.getSelectedNodesMetadata = getSelectedNodesMetadata
|