@inditextech/weave-sdk 0.69.2 → 0.71.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 +51 -42
- package/dist/sdk.d.cts +21 -2
- package/dist/sdk.d.cts.map +1 -1
- package/dist/sdk.d.ts +25 -6
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +51 -42
- package/dist/sdk.js.map +1 -1
- package/package.json +2 -2
package/dist/sdk.js
CHANGED
|
@@ -18064,7 +18064,7 @@ function containerOverCursor(instance, ignoreNodes, definedCursorPosition) {
|
|
|
18064
18064
|
stage.find(".containerCapable").reverse().forEach((node) => {
|
|
18065
18065
|
if (!node.isVisible()) return;
|
|
18066
18066
|
if (containsNodeDeep(ignoreNodes, node)) return;
|
|
18067
|
-
const shapeRect = getBoundingBox(
|
|
18067
|
+
const shapeRect = getBoundingBox([node], { relativeTo: stage });
|
|
18068
18068
|
if (cursorPosition.x >= shapeRect.x && cursorPosition.x <= shapeRect.x + shapeRect.width && cursorPosition.y >= shapeRect.y && cursorPosition.y <= shapeRect.y + shapeRect.height) {
|
|
18069
18069
|
if (node?.getAttrs().isContainerPrincipal) containerUnderPointer.add(node);
|
|
18070
18070
|
}
|
|
@@ -18108,7 +18108,7 @@ function moveNodeToContainer(instance, node, containerToMove, invalidOriginsType
|
|
|
18108
18108
|
}
|
|
18109
18109
|
return false;
|
|
18110
18110
|
}
|
|
18111
|
-
function getExportBoundingBox(
|
|
18111
|
+
function getExportBoundingBox(nodes) {
|
|
18112
18112
|
if (nodes.length === 0) return {
|
|
18113
18113
|
x: 0,
|
|
18114
18114
|
y: 0,
|
|
@@ -18133,7 +18133,7 @@ function getExportBoundingBox(stage, nodes) {
|
|
|
18133
18133
|
height: maxY - minY
|
|
18134
18134
|
};
|
|
18135
18135
|
}
|
|
18136
|
-
function getBoundingBox(
|
|
18136
|
+
function getBoundingBox(nodes, config) {
|
|
18137
18137
|
if (nodes.length === 0) return {
|
|
18138
18138
|
x: 0,
|
|
18139
18139
|
y: 0,
|
|
@@ -18145,10 +18145,7 @@ function getBoundingBox(stage, nodes) {
|
|
|
18145
18145
|
let maxX = -Infinity;
|
|
18146
18146
|
let maxY = -Infinity;
|
|
18147
18147
|
for (const node of nodes) {
|
|
18148
|
-
const box = node.getRealClientRect(
|
|
18149
|
-
relativeTo: stage,
|
|
18150
|
-
skipTransform: false
|
|
18151
|
-
});
|
|
18148
|
+
const box = node.getRealClientRect(config);
|
|
18152
18149
|
minX = Math.min(minX, box.x);
|
|
18153
18150
|
minY = Math.min(minY, box.y);
|
|
18154
18151
|
maxX = Math.max(maxX, box.x + box.width);
|
|
@@ -19323,7 +19320,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19323
19320
|
this.getStageGridPlugin()?.onRender();
|
|
19324
19321
|
this.updateSelectionRect();
|
|
19325
19322
|
}
|
|
19326
|
-
this.panLoopId = requestAnimationFrame(() => this.panLoop());
|
|
19323
|
+
if (this.isAreaSelecting()) this.panLoopId = requestAnimationFrame(() => this.panLoop());
|
|
19327
19324
|
}
|
|
19328
19325
|
setTapStart(e) {
|
|
19329
19326
|
this.tapStart = {
|
|
@@ -19445,7 +19442,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19445
19442
|
this.selecting = true;
|
|
19446
19443
|
this.tr.nodes([]);
|
|
19447
19444
|
this.instance.emitEvent("onSelectionState", true);
|
|
19448
|
-
|
|
19445
|
+
this.panLoopId = requestAnimationFrame(() => this.panLoop());
|
|
19449
19446
|
});
|
|
19450
19447
|
const handleMouseMove = (e) => {
|
|
19451
19448
|
const moved = this.checkMoved(e);
|
|
@@ -20034,7 +20031,7 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
|
20034
20031
|
const nodesSelectionPlugin = this.getNodesSelectionPlugin();
|
|
20035
20032
|
const selectedNodes = nodesSelectionPlugin?.getSelectedNodes();
|
|
20036
20033
|
if (!selectedNodes || selectedNodes.length === 0) return;
|
|
20037
|
-
const box = getBoundingBox(
|
|
20034
|
+
const box = getBoundingBox(selectedNodes, { relativeTo: stage });
|
|
20038
20035
|
const copyClipboard = {
|
|
20039
20036
|
weaveInstanceId: this.instance.getId(),
|
|
20040
20037
|
weave: {},
|
|
@@ -21249,7 +21246,7 @@ var WeaveTargetingManager = class {
|
|
|
21249
21246
|
}
|
|
21250
21247
|
isNodesBoundingBoxIntersecting(nodes, nodeB) {
|
|
21251
21248
|
const stage = this.instance.getStage();
|
|
21252
|
-
const a = getBoundingBox(
|
|
21249
|
+
const a = getBoundingBox(nodes, { relativeTo: stage });
|
|
21253
21250
|
const b = nodeB.getClientRect({ relativeTo: stage });
|
|
21254
21251
|
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);
|
|
21255
21252
|
}
|
|
@@ -21913,7 +21910,7 @@ var WeaveRegisterManager = class {
|
|
|
21913
21910
|
|
|
21914
21911
|
//#endregion
|
|
21915
21912
|
//#region package.json
|
|
21916
|
-
var version = "0.
|
|
21913
|
+
var version = "0.71.0";
|
|
21917
21914
|
|
|
21918
21915
|
//#endregion
|
|
21919
21916
|
//#region src/managers/setup.ts
|
|
@@ -22174,7 +22171,7 @@ var WeaveExportManager = class {
|
|
|
22174
22171
|
y: 1
|
|
22175
22172
|
});
|
|
22176
22173
|
if (mainLayer) {
|
|
22177
|
-
const bounds = getExportBoundingBox(
|
|
22174
|
+
const bounds = getExportBoundingBox(boundingNodes(nodes));
|
|
22178
22175
|
const scaleX = stage.scaleX();
|
|
22179
22176
|
const scaleY = stage.scaleY();
|
|
22180
22177
|
const unscaledBounds = {
|
|
@@ -22257,7 +22254,7 @@ var WeaveExportManager = class {
|
|
|
22257
22254
|
if (node) konvaNodes.push(node);
|
|
22258
22255
|
}
|
|
22259
22256
|
if (mainLayer) {
|
|
22260
|
-
const bounds = getExportBoundingBox(
|
|
22257
|
+
const bounds = getExportBoundingBox(boundingNodes(konvaNodes));
|
|
22261
22258
|
const scaleX = stage.scaleX();
|
|
22262
22259
|
const scaleY = stage.scaleY();
|
|
22263
22260
|
const unscaledBounds = {
|
|
@@ -22746,6 +22743,9 @@ var Weave = class {
|
|
|
22746
22743
|
}
|
|
22747
22744
|
return nodeContainer;
|
|
22748
22745
|
}
|
|
22746
|
+
getBoundingBox(nodes, config) {
|
|
22747
|
+
return getBoundingBox(nodes, config);
|
|
22748
|
+
}
|
|
22749
22749
|
moveUp(node) {
|
|
22750
22750
|
this.zIndexManager.moveUp(node);
|
|
22751
22751
|
}
|
|
@@ -23425,12 +23425,12 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
23425
23425
|
let height = nextProps.height;
|
|
23426
23426
|
if (nextProps.layout === TEXT_LAYOUT.AUTO_ALL) {
|
|
23427
23427
|
const { width: textAreaWidth, height: textAreaHeight } = this.textRenderedSize(nextProps.text, nodeInstance);
|
|
23428
|
-
width = textAreaWidth
|
|
23429
|
-
height = textAreaHeight
|
|
23428
|
+
width = textAreaWidth;
|
|
23429
|
+
height = textAreaHeight;
|
|
23430
23430
|
}
|
|
23431
23431
|
if (nextProps.layout === TEXT_LAYOUT.AUTO_HEIGHT) {
|
|
23432
23432
|
const { height: textAreaHeight } = this.textRenderedSize(nextProps.text, nodeInstance);
|
|
23433
|
-
height = textAreaHeight
|
|
23433
|
+
height = textAreaHeight;
|
|
23434
23434
|
}
|
|
23435
23435
|
if (nextProps.layout === TEXT_LAYOUT.FIXED) updateNeeded = false;
|
|
23436
23436
|
nodeInstance.setAttrs({
|
|
@@ -23479,10 +23479,10 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
23479
23479
|
if (!textNode.getAttrs().layout || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_HEIGHT) this.textAreaContainer.style.height = "auto";
|
|
23480
23480
|
if (!textNode.getAttrs().layout || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_ALL || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_HEIGHT) {
|
|
23481
23481
|
this.textAreaContainer.style.height = "auto";
|
|
23482
|
-
this.textAreaContainer.style.height = this.textArea.scrollHeight +
|
|
23482
|
+
this.textAreaContainer.style.height = this.textArea.scrollHeight + textNode.getAbsoluteScale().y + "px";
|
|
23483
23483
|
}
|
|
23484
23484
|
this.textArea.style.height = "auto";
|
|
23485
|
-
this.textArea.style.height = this.textArea.scrollHeight +
|
|
23485
|
+
this.textArea.style.height = this.textArea.scrollHeight + textNode.getAbsoluteScale().x + "px";
|
|
23486
23486
|
this.textArea.rows = this.textArea.value.split("\n").length;
|
|
23487
23487
|
}
|
|
23488
23488
|
measureMultilineText(textNode) {
|
|
@@ -23560,16 +23560,18 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
23560
23560
|
this.textAreaContainer.style.top = position.y + "px";
|
|
23561
23561
|
this.textAreaContainer.style.left = position.x + "px";
|
|
23562
23562
|
if (!textNode.getAttrs().layout || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_ALL) {
|
|
23563
|
-
|
|
23564
|
-
this.textAreaContainer.style.
|
|
23563
|
+
const rect = textNode.getClientRect({ relativeTo: stage });
|
|
23564
|
+
this.textAreaContainer.style.width = (rect.width + 1) * stage.scaleX() + "px";
|
|
23565
|
+
this.textAreaContainer.style.height = (textNode.height() - textNode.padding() * 2) * textNode.getAbsoluteScale().x + "px";
|
|
23565
23566
|
}
|
|
23566
23567
|
if (textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_HEIGHT) {
|
|
23567
|
-
|
|
23568
|
-
this.textAreaContainer.style.
|
|
23568
|
+
const rect = textNode.getClientRect({ relativeTo: stage });
|
|
23569
|
+
this.textAreaContainer.style.width = (rect.width + 1) * stage.scaleX() + "px";
|
|
23570
|
+
this.textAreaContainer.style.height = (textNode.height() - textNode.padding() * 2) * textNode.getAbsoluteScale().x + "px";
|
|
23569
23571
|
}
|
|
23570
23572
|
if (textNode.getAttrs().layout === TEXT_LAYOUT.FIXED) {
|
|
23571
23573
|
this.textAreaContainer.style.width = (textNode.width() - textNode.padding() * 2) * textNode.getAbsoluteScale().x + "px";
|
|
23572
|
-
this.textAreaContainer.style.height = (textNode.height() - textNode.padding() * 2) * textNode.getAbsoluteScale().x +
|
|
23574
|
+
this.textAreaContainer.style.height = (textNode.height() - textNode.padding() * 2) * textNode.getAbsoluteScale().x + "px";
|
|
23573
23575
|
}
|
|
23574
23576
|
this.textAreaContainer.style.border = "solid 1px #1e40af";
|
|
23575
23577
|
this.textArea.style.position = "absolute";
|
|
@@ -23589,9 +23591,17 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
23589
23591
|
this.textArea.style.border = "none";
|
|
23590
23592
|
this.textArea.style.outline = "none";
|
|
23591
23593
|
this.textArea.style.resize = "none";
|
|
23594
|
+
this.textArea.style.overflow = "hidden";
|
|
23592
23595
|
this.textArea.style.backgroundColor = "transparent";
|
|
23593
23596
|
this.textAreaContainer.style.transformOrigin = "left top";
|
|
23594
23597
|
this.mimicTextNode(textNode);
|
|
23598
|
+
const loadedFonts = this.instance.getFonts();
|
|
23599
|
+
const fontFamily = this.textArea.style.fontFamily;
|
|
23600
|
+
const actualFont = loadedFonts.find((f) => f.name === fontFamily);
|
|
23601
|
+
const correctionX = (actualFont === void 0 ? 0 : actualFont.offsetX ?? 0) * stage.scaleX();
|
|
23602
|
+
const correctionY = (actualFont === void 0 ? 0 : actualFont.offsetY ?? 0) * stage.scaleX();
|
|
23603
|
+
this.textArea.style.left = `${correctionX - 1}px`;
|
|
23604
|
+
this.textArea.style.top = `${correctionY}px`;
|
|
23595
23605
|
this.textArea.onfocus = () => {
|
|
23596
23606
|
this.textAreaDomResize(textNode);
|
|
23597
23607
|
};
|
|
@@ -23628,19 +23638,24 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
23628
23638
|
const transform = "rotate(" + rotation + "deg)";
|
|
23629
23639
|
this.textAreaContainer.style.transform = transform;
|
|
23630
23640
|
}
|
|
23641
|
+
const updateTextNodeSize = () => {
|
|
23642
|
+
if (!this.textArea) return;
|
|
23643
|
+
if (!textNode.getAttrs().layout || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_ALL) {
|
|
23644
|
+
const { width: textAreaWidth } = this.textRenderedSize(this.textArea.value, textNode);
|
|
23645
|
+
textNode.width(textAreaWidth);
|
|
23646
|
+
}
|
|
23647
|
+
if (!textNode.getAttrs().layout || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_HEIGHT || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_ALL) textNode.height(this.textArea.scrollHeight * (1 / textNode.getAbsoluteScale().x));
|
|
23648
|
+
};
|
|
23631
23649
|
const handleKeyDown = (e) => {
|
|
23632
23650
|
if (this.textArea && textNode && e.key === "Escape") {
|
|
23633
23651
|
e.stopPropagation();
|
|
23634
|
-
|
|
23635
|
-
const { width: textAreaWidth } = this.textRenderedSize(this.textArea.value, textNode);
|
|
23636
|
-
textNode.width(textAreaWidth + 3.2);
|
|
23637
|
-
}
|
|
23638
|
-
if (!textNode.getAttrs().layout || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_HEIGHT || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_ALL) textNode.height((this.textArea.scrollHeight + 1.6) * (1 / textNode.getAbsoluteScale().x));
|
|
23652
|
+
updateTextNodeSize();
|
|
23639
23653
|
textNode.text(this.textArea.value);
|
|
23640
23654
|
this.removeTextAreaDOM(textNode);
|
|
23641
23655
|
this.instance.removeEventListener("onZoomChange", this.onZoomChangeHandler(textNode).bind(this));
|
|
23642
23656
|
this.instance.removeEventListener("onStageMove", this.onStageMoveHandler(textNode).bind(this));
|
|
23643
23657
|
window.removeEventListener("pointerup", handleOutsideClick);
|
|
23658
|
+
window.removeEventListener("pointerdown", handleOutsideClick);
|
|
23644
23659
|
return;
|
|
23645
23660
|
}
|
|
23646
23661
|
};
|
|
@@ -23651,7 +23666,7 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
23651
23666
|
if (!textNode.getAttrs().layout || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_ALL || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_HEIGHT) {
|
|
23652
23667
|
if (this.textAreaContainer) {
|
|
23653
23668
|
this.textAreaContainer.style.height = "auto";
|
|
23654
|
-
this.textAreaContainer.style.height = this.textArea.scrollHeight +
|
|
23669
|
+
this.textAreaContainer.style.height = this.textArea.scrollHeight + textNode.getAbsoluteScale().x + "px";
|
|
23655
23670
|
}
|
|
23656
23671
|
}
|
|
23657
23672
|
this.textAreaDomResize(textNode);
|
|
@@ -23674,6 +23689,7 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
23674
23689
|
let clickedOnCanvas = false;
|
|
23675
23690
|
if (elementUnderMouse?.id !== `${textNode.id()}`) clickedOnCanvas = true;
|
|
23676
23691
|
if (clickedOnCanvas) {
|
|
23692
|
+
updateTextNodeSize();
|
|
23677
23693
|
textNode.text(this.textArea.value);
|
|
23678
23694
|
this.removeTextAreaDOM(textNode);
|
|
23679
23695
|
this.textArea.removeEventListener("keydown", handleKeyDown);
|
|
@@ -23691,7 +23707,6 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
23691
23707
|
}
|
|
23692
23708
|
updateTextAreaDOM(textNode) {
|
|
23693
23709
|
if (!this.textAreaContainer || !this.textArea) return;
|
|
23694
|
-
const stage = this.instance.getStage();
|
|
23695
23710
|
const textPosition = textNode.getClientRect();
|
|
23696
23711
|
const position = {
|
|
23697
23712
|
x: textPosition.x,
|
|
@@ -23707,15 +23722,9 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
23707
23722
|
this.textAreaDomResize(textNode);
|
|
23708
23723
|
const rotation = textNode.getAbsoluteRotation();
|
|
23709
23724
|
if (rotation) {
|
|
23710
|
-
const transform
|
|
23711
|
-
this.textAreaContainer.style.transform = transform
|
|
23712
|
-
}
|
|
23713
|
-
const px = 0;
|
|
23714
|
-
const py = -3 * stage.scaleY();
|
|
23715
|
-
let transform = "";
|
|
23716
|
-
transform += "translateX(" + px + "px)";
|
|
23717
|
-
transform += "translateY(" + py + "px)";
|
|
23718
|
-
this.textArea.style.transform = transform;
|
|
23725
|
+
const transform = "rotate(" + rotation + "deg)";
|
|
23726
|
+
this.textAreaContainer.style.transform = transform;
|
|
23727
|
+
}
|
|
23719
23728
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
23720
23729
|
if (selectionPlugin) {
|
|
23721
23730
|
const tr = selectionPlugin.getTransformer();
|
|
@@ -26456,7 +26465,7 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
|
|
|
26456
26465
|
});
|
|
26457
26466
|
let realNodes = mainLayer.getChildren();
|
|
26458
26467
|
realNodes = realNodes.filter((node) => typeof node.getAttrs().visible === "undefined" || node.getAttrs().visible);
|
|
26459
|
-
const bounds = getBoundingBox(
|
|
26468
|
+
const bounds = getBoundingBox(realNodes, { relativeTo: stage });
|
|
26460
26469
|
if (bounds.width === 0 || bounds.height === 0) {
|
|
26461
26470
|
stage.position(centerPoint);
|
|
26462
26471
|
this.setZoom(this.config.zoomSteps[this.defaultStep]);
|
|
@@ -26486,7 +26495,7 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
|
|
|
26486
26495
|
if (!selectionPlugin) return;
|
|
26487
26496
|
const nodes = selectionPlugin.getTransformer().getNodes();
|
|
26488
26497
|
if (nodes.length === 0) return;
|
|
26489
|
-
const box = getBoundingBox(
|
|
26498
|
+
const box = getBoundingBox(selectionPlugin.getTransformer().getNodes(), { relativeTo: stage });
|
|
26490
26499
|
if (box.width === 0 || box.height === 0) return;
|
|
26491
26500
|
const container = stage.container();
|
|
26492
26501
|
const scale = stage.scale();
|