@inditextech/weave-sdk 5.0.0-SNAPSHOT.366.1 → 5.0.0-SNAPSHOT.377.1
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.js +92 -59
- package/dist/sdk.node.js +92 -59
- package/dist/sdk.node.stats.html +1 -1
- package/dist/sdk.stats.html +1 -1
- package/dist/types.d.ts +34 -22
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +92 -59
- package/dist/types.js.map +1 -1
- package/dist/types.stats.html +1 -1
- package/package.json +2 -2
package/dist/types.js
CHANGED
|
@@ -9493,7 +9493,7 @@ var WeaveRegisterManager = class {
|
|
|
9493
9493
|
|
|
9494
9494
|
//#endregion
|
|
9495
9495
|
//#region package.json
|
|
9496
|
-
var version = "5.0.0-SNAPSHOT.
|
|
9496
|
+
var version = "5.0.0-SNAPSHOT.377.1";
|
|
9497
9497
|
|
|
9498
9498
|
//#endregion
|
|
9499
9499
|
//#region src/managers/setup.ts
|
|
@@ -12728,7 +12728,8 @@ const WEAVE_STAGE_TEXT_EDITION_MODE = "text-edition";
|
|
|
12728
12728
|
const WEAVE_TEXT_NODE_DEFAULT_CONFIG = {
|
|
12729
12729
|
transform: { ...WEAVE_NODES_SELECTION_DEFAULT_CONFIG.selection },
|
|
12730
12730
|
outline: { enabled: false },
|
|
12731
|
-
cursor: { color: "#000000" }
|
|
12731
|
+
cursor: { color: "#000000" },
|
|
12732
|
+
edition: { borderSize: 2 }
|
|
12732
12733
|
};
|
|
12733
12734
|
const TEXT_LAYOUT = {
|
|
12734
12735
|
["SMART"]: "smart",
|
|
@@ -13024,7 +13025,8 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
13024
13025
|
if (!this.textArea || !this.textAreaContainer) return;
|
|
13025
13026
|
if (!textNode.getAttrs().layout || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_ALL || textNode.getAttrs().layout === TEXT_LAYOUT.SMART && !textNode.getAttrs().smartFixedWidth) {
|
|
13026
13027
|
const { width: textAreaWidth } = this.textRenderedSize(this.textArea.value, textNode);
|
|
13027
|
-
const
|
|
13028
|
+
const borderSize = this.config.edition.borderSize;
|
|
13029
|
+
const width = (textAreaWidth + borderSize * 2) * textNode.getAbsoluteScale().x / this.instance.getStage().scaleX();
|
|
13028
13030
|
this.textAreaContainer.style.width = width + "px";
|
|
13029
13031
|
}
|
|
13030
13032
|
if (!textNode.getAttrs().layout || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_ALL || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_HEIGHT || textNode.getAttrs().layout === TEXT_LAYOUT.SMART) {
|
|
@@ -13123,13 +13125,15 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
13123
13125
|
this.textAreaContainer.style.top = position.y * upscaleScale + "px";
|
|
13124
13126
|
this.textAreaContainer.style.left = position.x * upscaleScale + "px";
|
|
13125
13127
|
if (textNode.getAttrs().layout === TEXT_LAYOUT.SMART && !textNode.getAttrs().smartFixedWidth) {
|
|
13128
|
+
const borderSize$1 = this.config.edition.borderSize;
|
|
13126
13129
|
const rect = textNode.getClientRect({ relativeTo: stage });
|
|
13127
|
-
this.textAreaContainer.style.width = (rect.width + 2) * textNode.getAbsoluteScale().x + "px";
|
|
13130
|
+
this.textAreaContainer.style.width = (rect.width + borderSize$1 * 2) * textNode.getAbsoluteScale().x + "px";
|
|
13128
13131
|
this.textAreaContainer.style.height = (textNode.height() - textNode.padding() * 2) * textNode.getAbsoluteScale().x + "px";
|
|
13129
13132
|
}
|
|
13130
13133
|
if (!textNode.getAttrs().layout || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_ALL) {
|
|
13134
|
+
const borderSize$1 = this.config.edition.borderSize;
|
|
13131
13135
|
const rect = textNode.getClientRect({ relativeTo: stage });
|
|
13132
|
-
this.textAreaContainer.style.width = (rect.width + 2) * textNode.getAbsoluteScale().x + "px";
|
|
13136
|
+
this.textAreaContainer.style.width = (rect.width + borderSize$1 * 2) * textNode.getAbsoluteScale().x + "px";
|
|
13133
13137
|
this.textAreaContainer.style.height = (textNode.height() - textNode.padding() * 2) * textNode.getAbsoluteScale().x + "px";
|
|
13134
13138
|
}
|
|
13135
13139
|
if (textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_HEIGHT || textNode.getAttrs().layout === TEXT_LAYOUT.SMART && textNode.getAttrs().smartFixedWidth) {
|
|
@@ -13142,7 +13146,9 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
13142
13146
|
this.textAreaContainer.style.width = (textNode.width() - textNode.padding() * 2) * textNode.getAbsoluteScale().x + "px";
|
|
13143
13147
|
this.textAreaContainer.style.height = (textNode.height() - textNode.padding() * 2) * textNode.getAbsoluteScale().x + "px";
|
|
13144
13148
|
}
|
|
13145
|
-
this.
|
|
13149
|
+
const size = this.textRenderedSize(textNode.text(), textNode);
|
|
13150
|
+
const borderSize = this.config.edition.borderSize;
|
|
13151
|
+
this.textAreaContainer.style.border = `solid ${borderSize}px #1e40af`;
|
|
13146
13152
|
this.textArea.style.position = "absolute";
|
|
13147
13153
|
this.textArea.style.top = "0px";
|
|
13148
13154
|
this.textArea.style.left = "0px";
|
|
@@ -13151,11 +13157,12 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
13151
13157
|
this.textArea.style.scrollBehavior = "auto";
|
|
13152
13158
|
this.textArea.style.caretColor = "black";
|
|
13153
13159
|
this.textArea.style.width = "100%";
|
|
13160
|
+
this.textArea.style.height = `${size.height}px`;
|
|
13154
13161
|
this.textArea.style.minHeight = "auto";
|
|
13155
13162
|
this.textArea.style.margin = "0px";
|
|
13156
13163
|
this.textArea.style.padding = "0px";
|
|
13157
13164
|
this.textArea.style.paddingTop = "0px";
|
|
13158
|
-
this.textArea.style.boxSizing = "
|
|
13165
|
+
this.textArea.style.boxSizing = "content-box";
|
|
13159
13166
|
this.textArea.style.overflow = "hidden";
|
|
13160
13167
|
this.textArea.style.background = "transparent";
|
|
13161
13168
|
this.textArea.style.border = "none";
|
|
@@ -13169,8 +13176,8 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
13169
13176
|
this.textArea.style.backgroundColor = "transparent";
|
|
13170
13177
|
this.textAreaContainer.style.transformOrigin = "left top";
|
|
13171
13178
|
this.mimicTextNode(textNode);
|
|
13172
|
-
this.textArea.style.left =
|
|
13173
|
-
this.textArea.style.top =
|
|
13179
|
+
this.textArea.style.left = `${-borderSize}px`;
|
|
13180
|
+
this.textArea.style.top = `${-borderSize + (size.height - this.textArea.offsetHeight)}px`;
|
|
13174
13181
|
this.textArea.onfocus = () => {
|
|
13175
13182
|
this.textAreaDomResize(textNode);
|
|
13176
13183
|
};
|
|
@@ -13216,7 +13223,10 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
13216
13223
|
const width = textAreaWidth / this.instance.getStage().scaleX();
|
|
13217
13224
|
textNode.width(width);
|
|
13218
13225
|
}
|
|
13219
|
-
if (!textNode.getAttrs().layout || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_HEIGHT || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_ALL || textNode.getAttrs().layout === TEXT_LAYOUT.SMART)
|
|
13226
|
+
if (!textNode.getAttrs().layout || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_HEIGHT || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_ALL || textNode.getAttrs().layout === TEXT_LAYOUT.SMART) {
|
|
13227
|
+
const size$1 = this.textRenderedSize(this.textArea.value, textNode);
|
|
13228
|
+
textNode.height(size$1.height * (1 / textNode.getAbsoluteScale().x));
|
|
13229
|
+
}
|
|
13220
13230
|
};
|
|
13221
13231
|
const handleKeyDown = (e) => {
|
|
13222
13232
|
if (this.textArea && textNode && e.code === "Escape") {
|
|
@@ -16283,9 +16293,48 @@ var WeaveStrokeNode = class extends WeaveNode {
|
|
|
16283
16293
|
result.push(pts[pts.length - 1]);
|
|
16284
16294
|
return result;
|
|
16285
16295
|
}
|
|
16296
|
+
drawRoundCap(ctx, a, b, color) {
|
|
16297
|
+
const cx = (a.x + b.x) / 2;
|
|
16298
|
+
const cy = (a.y + b.y) / 2;
|
|
16299
|
+
const r = Math.hypot(a.x - b.x, a.y - b.y) / 2;
|
|
16300
|
+
ctx.beginPath();
|
|
16301
|
+
ctx.fillStyle = color;
|
|
16302
|
+
ctx.arc(cx, cy, r, 0, Math.PI * 2);
|
|
16303
|
+
ctx.fill();
|
|
16304
|
+
}
|
|
16305
|
+
/**
|
|
16306
|
+
* Draws a filled polygon from the accumulated left/right outline points of a
|
|
16307
|
+
* dash segment and adds round caps at both ends.
|
|
16308
|
+
* NOTE: mutates `rightSide` via Array.reverse() — callers must not reuse it after this call.
|
|
16309
|
+
*/
|
|
16310
|
+
drawDashPolygon(ctx, leftSide, rightSide, color) {
|
|
16311
|
+
const capStartL = leftSide[0];
|
|
16312
|
+
const capStartR = rightSide[0];
|
|
16313
|
+
const capEndL = leftSide.at(-1);
|
|
16314
|
+
const capEndR = rightSide.at(-1);
|
|
16315
|
+
const smoothLeft = this.getSplinePoints(leftSide, 4);
|
|
16316
|
+
const smoothRight = this.getSplinePoints(rightSide.reverse(), 4);
|
|
16317
|
+
ctx.beginPath();
|
|
16318
|
+
ctx.fillStyle = color;
|
|
16319
|
+
ctx.moveTo(smoothLeft[0].x, smoothLeft[0].y);
|
|
16320
|
+
for (const p of smoothLeft) ctx.lineTo(p.x, p.y);
|
|
16321
|
+
for (const p of smoothRight) ctx.lineTo(p.x, p.y);
|
|
16322
|
+
ctx.closePath();
|
|
16323
|
+
ctx.fill();
|
|
16324
|
+
this.drawRoundCap(ctx, capStartL, capStartR, color);
|
|
16325
|
+
this.drawRoundCap(ctx, capEndL, capEndR, color);
|
|
16326
|
+
}
|
|
16286
16327
|
drawRibbonWithDash(ctx, pts, baseW, color, dash) {
|
|
16287
16328
|
if (!pts) return;
|
|
16288
|
-
if (pts.length < 2)
|
|
16329
|
+
if (pts.length < 2) {
|
|
16330
|
+
const pt = pts[0];
|
|
16331
|
+
const r = Math.max(baseW * pt.pressure / 2, .5);
|
|
16332
|
+
ctx.beginPath();
|
|
16333
|
+
ctx.fillStyle = color;
|
|
16334
|
+
ctx.arc(pt.x, pt.y, r, 0, Math.PI * 2);
|
|
16335
|
+
ctx.fill();
|
|
16336
|
+
return;
|
|
16337
|
+
}
|
|
16289
16338
|
const filtered = this.resamplePoints(pts, 2);
|
|
16290
16339
|
const centerline = this.getSplinePoints(filtered, 8);
|
|
16291
16340
|
let dashIndex = 0;
|
|
@@ -16338,17 +16387,7 @@ var WeaveStrokeNode = class extends WeaveNode {
|
|
|
16338
16387
|
}
|
|
16339
16388
|
dashRemaining -= step;
|
|
16340
16389
|
if (dashRemaining <= 0) {
|
|
16341
|
-
if (dashOn && leftSide.length && rightSide.length)
|
|
16342
|
-
const smoothLeft = this.getSplinePoints(leftSide, 4);
|
|
16343
|
-
const smoothRight = this.getSplinePoints(rightSide.reverse(), 4);
|
|
16344
|
-
ctx.beginPath();
|
|
16345
|
-
ctx.fillStyle = color;
|
|
16346
|
-
ctx.moveTo(smoothLeft[0].x, smoothLeft[0].y);
|
|
16347
|
-
for (const p of smoothLeft) ctx.lineTo(p.x, p.y);
|
|
16348
|
-
for (const p of smoothRight) ctx.lineTo(p.x, p.y);
|
|
16349
|
-
ctx.closePath();
|
|
16350
|
-
ctx.fill();
|
|
16351
|
-
}
|
|
16390
|
+
if (dashOn && leftSide.length && rightSide.length) this.drawDashPolygon(ctx, leftSide, rightSide, color);
|
|
16352
16391
|
leftSide = [];
|
|
16353
16392
|
rightSide = [];
|
|
16354
16393
|
dashOn = !dashOn;
|
|
@@ -16358,17 +16397,7 @@ var WeaveStrokeNode = class extends WeaveNode {
|
|
|
16358
16397
|
traveled += step;
|
|
16359
16398
|
}
|
|
16360
16399
|
}
|
|
16361
|
-
if (dashOn && leftSide.length && rightSide.length)
|
|
16362
|
-
const smoothLeft = this.getSplinePoints(leftSide, 4);
|
|
16363
|
-
const smoothRight = this.getSplinePoints(rightSide.reverse(), 4);
|
|
16364
|
-
ctx.beginPath();
|
|
16365
|
-
ctx.fillStyle = color;
|
|
16366
|
-
ctx.moveTo(smoothLeft[0].x, smoothLeft[0].y);
|
|
16367
|
-
for (const p of smoothLeft) ctx.lineTo(p.x, p.y);
|
|
16368
|
-
for (const p of smoothRight) ctx.lineTo(p.x, p.y);
|
|
16369
|
-
ctx.closePath();
|
|
16370
|
-
ctx.fill();
|
|
16371
|
-
}
|
|
16400
|
+
if (dashOn && leftSide.length && rightSide.length) this.drawDashPolygon(ctx, leftSide, rightSide, color);
|
|
16372
16401
|
}
|
|
16373
16402
|
drawShape(ctx, shape) {
|
|
16374
16403
|
const strokeElements = shape.getAttrs().strokeElements;
|
|
@@ -16385,8 +16414,6 @@ var WeaveStrokeNode = class extends WeaveNode {
|
|
|
16385
16414
|
sceneFunc: (ctx, shape) => {
|
|
16386
16415
|
this.drawShape(ctx, shape);
|
|
16387
16416
|
},
|
|
16388
|
-
lineCap: "round",
|
|
16389
|
-
lineJoin: "round",
|
|
16390
16417
|
dashEnabled: false,
|
|
16391
16418
|
hitFunc: (context, shape) => {
|
|
16392
16419
|
context.beginPath();
|
|
@@ -22668,34 +22695,40 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
22668
22695
|
if (nodeHandler) nodeHandler.onUpdate(tempStroke, tempStroke.getAttrs());
|
|
22669
22696
|
}
|
|
22670
22697
|
}
|
|
22698
|
+
finalizeStroke(tempStroke, nodeHandler) {
|
|
22699
|
+
const box = this.getBoundingBox(tempStroke.getAttrs().strokeElements);
|
|
22700
|
+
let newStrokeElements = [...tempStroke.getAttrs().strokeElements];
|
|
22701
|
+
if (this.predictedCount > 0) {
|
|
22702
|
+
newStrokeElements = newStrokeElements.slice(0, -1 * this.predictedCount);
|
|
22703
|
+
this.predictedCount = 0;
|
|
22704
|
+
}
|
|
22705
|
+
newStrokeElements = newStrokeElements.map((point) => ({
|
|
22706
|
+
...point,
|
|
22707
|
+
x: point.x - box.x,
|
|
22708
|
+
y: point.y - box.y
|
|
22709
|
+
}));
|
|
22710
|
+
const compressedPoints = simplify(newStrokeElements, 1, true);
|
|
22711
|
+
const sw = tempStroke.getAttrs().strokeWidth ?? 1;
|
|
22712
|
+
const finalWidth = Math.max(box.width, sw);
|
|
22713
|
+
const finalHeight = Math.max(box.height, sw);
|
|
22714
|
+
const finalX = box.width === 0 ? box.x - sw / 2 : box.x;
|
|
22715
|
+
const finalY = box.height === 0 ? box.y - sw / 2 : box.y;
|
|
22716
|
+
tempStroke.setAttrs({
|
|
22717
|
+
width: finalWidth,
|
|
22718
|
+
height: finalHeight,
|
|
22719
|
+
x: finalX,
|
|
22720
|
+
y: finalY,
|
|
22721
|
+
strokeElements: compressedPoints
|
|
22722
|
+
});
|
|
22723
|
+
const realNode = this.instance.getStage().findOne(`#${tempStroke.getAttrs().id}`);
|
|
22724
|
+
if (realNode) realNode.destroy();
|
|
22725
|
+
if (tempStroke.getAttrs().strokeElements.length >= 1) this.instance.addNode(nodeHandler.serialize(tempStroke), this.container?.getAttrs().id);
|
|
22726
|
+
}
|
|
22671
22727
|
handleEndStroke() {
|
|
22672
22728
|
const tempStroke = this.instance.getStage().findOne(`#${this.strokeId}`);
|
|
22673
22729
|
if (tempStroke) {
|
|
22674
22730
|
const nodeHandler = this.instance.getNodeHandler("stroke");
|
|
22675
|
-
if (nodeHandler)
|
|
22676
|
-
const box = this.getBoundingBox(tempStroke.getAttrs().strokeElements);
|
|
22677
|
-
let newStrokeElements = [...tempStroke.getAttrs().strokeElements];
|
|
22678
|
-
if (this.predictedCount > 0) {
|
|
22679
|
-
newStrokeElements = newStrokeElements.slice(0, -1 * this.predictedCount);
|
|
22680
|
-
this.predictedCount = 0;
|
|
22681
|
-
}
|
|
22682
|
-
newStrokeElements = newStrokeElements.map((point) => ({
|
|
22683
|
-
...point,
|
|
22684
|
-
x: point.x - box.x,
|
|
22685
|
-
y: point.y - box.y
|
|
22686
|
-
}));
|
|
22687
|
-
const compressedPoints = simplify(newStrokeElements, 1, true);
|
|
22688
|
-
tempStroke.setAttrs({
|
|
22689
|
-
width: box.width,
|
|
22690
|
-
height: box.height,
|
|
22691
|
-
x: box.x,
|
|
22692
|
-
y: box.y,
|
|
22693
|
-
strokeElements: compressedPoints
|
|
22694
|
-
});
|
|
22695
|
-
const realNode = this.instance.getStage().findOne(`#${tempStroke.getAttrs().id}`);
|
|
22696
|
-
if (realNode) realNode.destroy();
|
|
22697
|
-
if (tempStroke.getAttrs().strokeElements.length >= 3) this.instance.addNode(nodeHandler.serialize(tempStroke), this.container?.getAttrs().id);
|
|
22698
|
-
}
|
|
22731
|
+
if (nodeHandler) this.finalizeStroke(tempStroke, nodeHandler);
|
|
22699
22732
|
this.clickPoint = null;
|
|
22700
22733
|
this.setCursor();
|
|
22701
22734
|
this.setFocusStage();
|