@inditextech/weave-sdk 0.29.1 → 0.30.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.cjs +128 -89
- package/dist/sdk.d.cts +7 -2
- package/dist/sdk.d.cts.map +1 -1
- package/dist/sdk.d.ts +7 -2
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +128 -89
- package/dist/sdk.js.map +1 -1
- package/package.json +3 -3
package/dist/sdk.cjs
CHANGED
|
@@ -16195,6 +16195,11 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
16195
16195
|
if (!this.initialized) return;
|
|
16196
16196
|
if (!this.active) return;
|
|
16197
16197
|
if (e.evt instanceof TouchEvent && e.evt.touches && e.evt.touches.length > 1) return;
|
|
16198
|
+
const contextMenuPlugin = this.instance.getPlugin("contextMenu");
|
|
16199
|
+
if (contextMenuPlugin && contextMenuPlugin.isContextMenuVisible()) {
|
|
16200
|
+
this.selecting = false;
|
|
16201
|
+
return;
|
|
16202
|
+
}
|
|
16198
16203
|
if (!this.selecting) {
|
|
16199
16204
|
this.cameFromSelectingMultiple = false;
|
|
16200
16205
|
return;
|
|
@@ -16217,7 +16222,10 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
16217
16222
|
if (!this.active) return;
|
|
16218
16223
|
if (e.evt instanceof TouchEvent && e.evt.touches && e.evt.touches.length > 1) return;
|
|
16219
16224
|
const contextMenuPlugin = this.instance.getPlugin("contextMenu");
|
|
16220
|
-
if (contextMenuPlugin && contextMenuPlugin.isContextMenuVisible())
|
|
16225
|
+
if (contextMenuPlugin && contextMenuPlugin.isContextMenuVisible()) {
|
|
16226
|
+
this.selecting = false;
|
|
16227
|
+
return;
|
|
16228
|
+
}
|
|
16221
16229
|
this.selecting = false;
|
|
16222
16230
|
this.instance.emitEvent("onSelectionState", false);
|
|
16223
16231
|
if (!this.selectionRectangle.visible()) {
|
|
@@ -16263,7 +16271,10 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
16263
16271
|
stage.on("click tap", (e) => {
|
|
16264
16272
|
if (!this.enabled) return;
|
|
16265
16273
|
const contextMenuPlugin = this.instance.getPlugin("contextMenu");
|
|
16266
|
-
if (contextMenuPlugin && contextMenuPlugin.isContextMenuVisible())
|
|
16274
|
+
if (contextMenuPlugin && contextMenuPlugin.isContextMenuVisible()) {
|
|
16275
|
+
this.selecting = false;
|
|
16276
|
+
return;
|
|
16277
|
+
}
|
|
16267
16278
|
if (this.cameFromSelectingMultiple) {
|
|
16268
16279
|
this.cameFromSelectingMultiple = false;
|
|
16269
16280
|
return;
|
|
@@ -18218,7 +18229,7 @@ var WeaveRegisterManager = class {
|
|
|
18218
18229
|
|
|
18219
18230
|
//#endregion
|
|
18220
18231
|
//#region package.json
|
|
18221
|
-
var version = "0.
|
|
18232
|
+
var version = "0.30.1";
|
|
18222
18233
|
|
|
18223
18234
|
//#endregion
|
|
18224
18235
|
//#region src/managers/setup.ts
|
|
@@ -18482,6 +18493,17 @@ var WeaveExportManager = class {
|
|
|
18482
18493
|
}
|
|
18483
18494
|
});
|
|
18484
18495
|
}
|
|
18496
|
+
imageToBase64(img, mimeType) {
|
|
18497
|
+
const canvas = document.createElement("canvas");
|
|
18498
|
+
canvas.width = img.naturalWidth;
|
|
18499
|
+
canvas.height = img.naturalHeight;
|
|
18500
|
+
const ctx = canvas.getContext("2d");
|
|
18501
|
+
if (!ctx) throw new Error("Could not get canvas context");
|
|
18502
|
+
ctx.drawImage(img, 0, 0);
|
|
18503
|
+
const URL = canvas.toDataURL(mimeType);
|
|
18504
|
+
canvas.remove();
|
|
18505
|
+
return URL;
|
|
18506
|
+
}
|
|
18485
18507
|
};
|
|
18486
18508
|
|
|
18487
18509
|
//#endregion
|
|
@@ -18844,6 +18866,9 @@ var Weave = class extends Emittery {
|
|
|
18844
18866
|
getFonts() {
|
|
18845
18867
|
return this.fontsManager.getFonts();
|
|
18846
18868
|
}
|
|
18869
|
+
imageToBase64(img, mimeType) {
|
|
18870
|
+
return this.exportManager.imageToBase64(img, mimeType);
|
|
18871
|
+
}
|
|
18847
18872
|
async exportNodes(nodes, options) {
|
|
18848
18873
|
return await this.exportManager.exportNodes(nodes, options);
|
|
18849
18874
|
}
|
|
@@ -19154,6 +19179,7 @@ const TEXT_LAYOUT = {
|
|
|
19154
19179
|
var WeaveTextNode = class extends WeaveNode {
|
|
19155
19180
|
nodeType = WEAVE_TEXT_NODE_TYPE;
|
|
19156
19181
|
editing = false;
|
|
19182
|
+
textArea = null;
|
|
19157
19183
|
constructor(params) {
|
|
19158
19184
|
super();
|
|
19159
19185
|
const { config } = params ?? {};
|
|
@@ -19162,6 +19188,7 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
19162
19188
|
...config?.transform
|
|
19163
19189
|
} };
|
|
19164
19190
|
this.editing = false;
|
|
19191
|
+
this.textArea = null;
|
|
19165
19192
|
}
|
|
19166
19193
|
updateNode(nodeInstance) {
|
|
19167
19194
|
const clonedText = nodeInstance.clone();
|
|
@@ -19199,14 +19226,11 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
19199
19226
|
};
|
|
19200
19227
|
text.on("transform", (0, import_lodash.throttle)(handleTextTransform, 50));
|
|
19201
19228
|
window.addEventListener("keypress", (e) => {
|
|
19202
|
-
if (e.key === "Enter" && this.instance.getActiveAction() === SELECTION_TOOL_ACTION_NAME && !this.editing) {
|
|
19229
|
+
if (e.key === "Enter" && this.instance.getActiveAction() === SELECTION_TOOL_ACTION_NAME && !this.editing && e.target !== this.textArea) {
|
|
19203
19230
|
e.preventDefault();
|
|
19204
19231
|
if (this.isSelecting() && this.isNodeSelected(text)) {
|
|
19205
19232
|
const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
19206
|
-
if (nodesSelectionPlugin && nodesSelectionPlugin.getSelectedNodes().length === 1 && nodesSelectionPlugin.getSelectedNodes()[0].getAttrs().nodeType === WEAVE_TEXT_NODE_TYPE && !window.weaveTextEditing[nodesSelectionPlugin.getSelectedNodes()[0].id()])
|
|
19207
|
-
e.preventDefault();
|
|
19208
|
-
this.triggerEditMode(nodesSelectionPlugin.getSelectedNodes()[0]);
|
|
19209
|
-
}
|
|
19233
|
+
if (nodesSelectionPlugin && nodesSelectionPlugin.getSelectedNodes().length === 1 && nodesSelectionPlugin.getSelectedNodes()[0].getAttrs().nodeType === WEAVE_TEXT_NODE_TYPE && !window.weaveTextEditing[nodesSelectionPlugin.getSelectedNodes()[0].id()]) this.triggerEditMode(nodesSelectionPlugin.getSelectedNodes()[0]);
|
|
19210
19234
|
}
|
|
19211
19235
|
}
|
|
19212
19236
|
});
|
|
@@ -19320,6 +19344,25 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
19320
19344
|
height
|
|
19321
19345
|
};
|
|
19322
19346
|
}
|
|
19347
|
+
mimicTextNode(textNode, textArea) {
|
|
19348
|
+
textArea.style.fontSize = textNode.fontSize() * textNode.getAbsoluteScale().x + "px";
|
|
19349
|
+
textArea.rows = textNode.text().split("\n").length;
|
|
19350
|
+
textArea.style.letterSpacing = `${textNode.letterSpacing()}`;
|
|
19351
|
+
textArea.style.opacity = `${textNode.getAttrs().opacity}`;
|
|
19352
|
+
textArea.style.lineHeight = `${textNode.lineHeight()}`;
|
|
19353
|
+
textArea.style.fontFamily = textNode.fontFamily();
|
|
19354
|
+
let fontWeight = "normal";
|
|
19355
|
+
let fontStyle = "normal";
|
|
19356
|
+
if ((textNode.fontStyle() ?? "normal").indexOf("bold") !== -1) fontWeight = "bold";
|
|
19357
|
+
if ((textNode.fontStyle() ?? "normal").indexOf("italic") !== -1) fontStyle = "italic";
|
|
19358
|
+
textArea.style.fontWeight = fontWeight;
|
|
19359
|
+
textArea.style.backgroundColor = "transparent";
|
|
19360
|
+
textArea.style.fontStyle = fontStyle;
|
|
19361
|
+
textArea.style.fontVariant = textNode.fontVariant();
|
|
19362
|
+
textArea.style.textDecoration = textNode.textDecoration();
|
|
19363
|
+
textArea.style.textAlign = textNode.align();
|
|
19364
|
+
textArea.style.color = `${textNode.fill()}`;
|
|
19365
|
+
}
|
|
19323
19366
|
createTextAreaDOM(textNode, position) {
|
|
19324
19367
|
const stage = this.instance.getStage();
|
|
19325
19368
|
const textAreaSuperContainer = document.createElement("div");
|
|
@@ -19333,19 +19376,19 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
19333
19376
|
textAreaSuperContainer.style.pointerEvents = "none";
|
|
19334
19377
|
const textAreaContainer = document.createElement("div");
|
|
19335
19378
|
textAreaContainer.id = `${textNode.id()}_container`;
|
|
19336
|
-
|
|
19337
|
-
textArea.id = textNode.id();
|
|
19338
|
-
textAreaContainer.appendChild(textArea);
|
|
19379
|
+
this.textArea = document.createElement("textarea");
|
|
19380
|
+
this.textArea.id = textNode.id();
|
|
19381
|
+
textAreaContainer.appendChild(this.textArea);
|
|
19339
19382
|
textAreaSuperContainer.appendChild(textAreaContainer);
|
|
19340
19383
|
stage.container().appendChild(textAreaSuperContainer);
|
|
19341
19384
|
textAreaContainer.style.pointerEvents = "auto";
|
|
19342
19385
|
textAreaContainer.style.backgroundColor = "transparent";
|
|
19343
|
-
textArea.style.pointerEvents = "auto";
|
|
19386
|
+
this.textArea.style.pointerEvents = "auto";
|
|
19344
19387
|
this.instance.addEventListener("onZoomChange", this.onZoomChangeHandler(textNode).bind(this));
|
|
19345
19388
|
this.instance.addEventListener("onStageMove", this.onStageMoveHandler(textNode).bind(this));
|
|
19346
19389
|
window.weaveTextEditing[textNode.id()] = "editing";
|
|
19347
|
-
textArea.value = textNode.text();
|
|
19348
|
-
textArea.id = textNode.id();
|
|
19390
|
+
this.textArea.value = textNode.text();
|
|
19391
|
+
this.textArea.id = textNode.id();
|
|
19349
19392
|
textAreaContainer.style.overflow = "hidden";
|
|
19350
19393
|
textAreaContainer.style.display = "flex";
|
|
19351
19394
|
textAreaContainer.style.justifyContent = "start";
|
|
@@ -19356,7 +19399,7 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
19356
19399
|
textAreaContainer.style.top = position.y + "px";
|
|
19357
19400
|
textAreaContainer.style.left = position.x + "px";
|
|
19358
19401
|
if (!textNode.getAttrs().layout || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_ALL) {
|
|
19359
|
-
textAreaContainer.style.width = textArea.scrollWidth + "px";
|
|
19402
|
+
textAreaContainer.style.width = this.textArea.scrollWidth + "px";
|
|
19360
19403
|
textAreaContainer.style.height = (textNode.height() - textNode.padding() * 2) * textNode.getAbsoluteScale().x + 2 + "px";
|
|
19361
19404
|
}
|
|
19362
19405
|
if (textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_HEIGHT) {
|
|
@@ -19367,54 +19410,40 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
19367
19410
|
textAreaContainer.style.width = (textNode.width() - textNode.padding() * 2) * textNode.getAbsoluteScale().x + "px";
|
|
19368
19411
|
textAreaContainer.style.height = (textNode.height() - textNode.padding() * 2) * textNode.getAbsoluteScale().x + 2 + "px";
|
|
19369
19412
|
}
|
|
19370
|
-
textArea.style.fontSize = textNode.fontSize() * textNode.getAbsoluteScale().x + "px";
|
|
19371
|
-
textArea.rows = textNode.text().split("\n").length;
|
|
19372
19413
|
textAreaContainer.style.border = "solid 1px #1e40af";
|
|
19373
|
-
textArea.style.position = "absolute";
|
|
19374
|
-
textArea.style.top = "0px";
|
|
19375
|
-
textArea.style.left = "0px";
|
|
19376
|
-
textArea.style.overscrollBehavior = "contains";
|
|
19377
|
-
textArea.style.scrollBehavior = "auto";
|
|
19378
|
-
textArea.style.caretColor = "black";
|
|
19379
|
-
textArea.style.width = "100%";
|
|
19380
|
-
textArea.style.
|
|
19381
|
-
textArea.style.
|
|
19382
|
-
textArea.style.
|
|
19383
|
-
textArea.style.
|
|
19384
|
-
textArea.style.
|
|
19385
|
-
textArea.style.
|
|
19386
|
-
textArea.style.
|
|
19387
|
-
textArea.style.
|
|
19388
|
-
textArea.style.
|
|
19389
|
-
textArea.style.
|
|
19390
|
-
textArea.style.lineHeight = `${textNode.lineHeight()}`;
|
|
19391
|
-
textArea.style.fontFamily = textNode.fontFamily();
|
|
19392
|
-
let fontWeight = "normal";
|
|
19393
|
-
let fontStyle = "normal";
|
|
19394
|
-
if ((textNode.fontStyle() ?? "normal").indexOf("bold") !== -1) fontWeight = "bold";
|
|
19395
|
-
if ((textNode.fontStyle() ?? "normal").indexOf("italic") !== -1) fontStyle = "italic";
|
|
19396
|
-
textArea.style.fontWeight = fontWeight;
|
|
19397
|
-
textArea.style.backgroundColor = "transparent";
|
|
19398
|
-
textArea.style.fontStyle = fontStyle;
|
|
19399
|
-
textArea.style.fontVariant = textNode.fontVariant();
|
|
19400
|
-
textArea.style.textDecoration = textNode.textDecoration();
|
|
19414
|
+
this.textArea.style.position = "absolute";
|
|
19415
|
+
this.textArea.style.top = "0px";
|
|
19416
|
+
this.textArea.style.left = "0px";
|
|
19417
|
+
this.textArea.style.overscrollBehavior = "contains";
|
|
19418
|
+
this.textArea.style.scrollBehavior = "auto";
|
|
19419
|
+
this.textArea.style.caretColor = "black";
|
|
19420
|
+
this.textArea.style.width = "100%";
|
|
19421
|
+
this.textArea.style.minHeight = "auto";
|
|
19422
|
+
this.textArea.style.margin = "0px";
|
|
19423
|
+
this.textArea.style.padding = "0px";
|
|
19424
|
+
this.textArea.style.boxSizing = "content-box";
|
|
19425
|
+
this.textArea.style.overflow = "hidden";
|
|
19426
|
+
this.textArea.style.background = "transparent";
|
|
19427
|
+
this.textArea.style.border = "none";
|
|
19428
|
+
this.textArea.style.outline = "none";
|
|
19429
|
+
this.textArea.style.resize = "none";
|
|
19430
|
+
this.textArea.style.backgroundColor = "transparent";
|
|
19401
19431
|
textAreaContainer.style.transformOrigin = "left top";
|
|
19402
|
-
|
|
19403
|
-
textArea.
|
|
19404
|
-
|
|
19405
|
-
this.textAreaDomResize(textAreaContainer, textArea, textNode);
|
|
19432
|
+
this.mimicTextNode(textNode, this.textArea);
|
|
19433
|
+
this.textArea.onfocus = () => {
|
|
19434
|
+
this.textAreaDomResize(textAreaContainer, this.textArea, textNode);
|
|
19406
19435
|
};
|
|
19407
|
-
textArea.onkeydown = () => {
|
|
19408
|
-
this.textAreaDomResize(textAreaContainer, textArea, textNode);
|
|
19436
|
+
this.textArea.onkeydown = () => {
|
|
19437
|
+
this.textAreaDomResize(textAreaContainer, this.textArea, textNode);
|
|
19409
19438
|
};
|
|
19410
|
-
textArea.onkeyup = () => {
|
|
19411
|
-
this.textAreaDomResize(textAreaContainer, textArea, textNode);
|
|
19439
|
+
this.textArea.onkeyup = () => {
|
|
19440
|
+
this.textAreaDomResize(textAreaContainer, this.textArea, textNode);
|
|
19412
19441
|
};
|
|
19413
|
-
textArea.onpaste = () => {
|
|
19414
|
-
this.textAreaDomResize(textAreaContainer, textArea, textNode);
|
|
19442
|
+
this.textArea.onpaste = () => {
|
|
19443
|
+
this.textAreaDomResize(textAreaContainer, this.textArea, textNode);
|
|
19415
19444
|
};
|
|
19416
|
-
textArea.oninput = () => {
|
|
19417
|
-
this.textAreaDomResize(textAreaContainer, textArea, textNode);
|
|
19445
|
+
this.textArea.oninput = () => {
|
|
19446
|
+
this.textAreaDomResize(textAreaContainer, this.textArea, textNode);
|
|
19418
19447
|
};
|
|
19419
19448
|
textAreaSuperContainer.addEventListener("scroll", () => {
|
|
19420
19449
|
textAreaSuperContainer.scrollTop = 0;
|
|
@@ -19424,28 +19453,32 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
19424
19453
|
textAreaContainer.scrollTop = 0;
|
|
19425
19454
|
textAreaContainer.scrollLeft = 0;
|
|
19426
19455
|
});
|
|
19427
|
-
textArea.addEventListener("scroll", () => {
|
|
19428
|
-
textArea
|
|
19429
|
-
textArea.
|
|
19456
|
+
this.textArea.addEventListener("scroll", () => {
|
|
19457
|
+
if (!this.textArea) return;
|
|
19458
|
+
this.textArea.scrollTop = 0;
|
|
19459
|
+
this.textArea.scrollLeft = 0;
|
|
19430
19460
|
});
|
|
19431
|
-
const rotation = textNode.
|
|
19432
|
-
|
|
19433
|
-
|
|
19461
|
+
const rotation = textNode.getAbsoluteRotation();
|
|
19462
|
+
if (rotation) {
|
|
19463
|
+
const transform$1 = "rotate(" + rotation + "deg)";
|
|
19464
|
+
textAreaContainer.style.transform = transform$1;
|
|
19465
|
+
}
|
|
19434
19466
|
const measures = textNode.measureSize(textNode.text());
|
|
19435
19467
|
const px = 0 * stage.scaleX();
|
|
19436
19468
|
const py = 2 * (measures.fontBoundingBoxAscent - measures.hangingBaseline - measures.fontBoundingBoxDescent) * stage.scaleY();
|
|
19469
|
+
let transform = "";
|
|
19437
19470
|
transform += "translateX(" + px + "px)";
|
|
19438
19471
|
transform += "translateY(" + py + "px)";
|
|
19439
|
-
textArea.style.transform = transform;
|
|
19472
|
+
this.textArea.style.transform = transform;
|
|
19440
19473
|
const handleKeyDown = (e) => {
|
|
19441
|
-
if (textArea && textNode && e.key === "Escape") {
|
|
19474
|
+
if (this.textArea && textNode && e.key === "Escape") {
|
|
19442
19475
|
e.stopPropagation();
|
|
19443
19476
|
if (!textNode.getAttrs().layout || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_ALL) {
|
|
19444
|
-
const { width: textAreaWidth } = this.textRenderedSize(textArea.value, textNode);
|
|
19477
|
+
const { width: textAreaWidth } = this.textRenderedSize(this.textArea.value, textNode);
|
|
19445
19478
|
textNode.width(textAreaWidth + 3.2);
|
|
19446
19479
|
}
|
|
19447
|
-
if (!textNode.getAttrs().layout || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_HEIGHT || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_ALL) textNode.height((textArea.scrollHeight + 1.6) * (1 / textNode.getAbsoluteScale().x));
|
|
19448
|
-
textNode.text(textArea.value);
|
|
19480
|
+
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));
|
|
19481
|
+
textNode.text(this.textArea.value);
|
|
19449
19482
|
this.removeTextAreaDOM(textNode);
|
|
19450
19483
|
this.instance.removeEventListener("onZoomChange", this.onZoomChangeHandler(textNode).bind(this));
|
|
19451
19484
|
this.instance.removeEventListener("onStageMove", this.onStageMoveHandler(textNode).bind(this));
|
|
@@ -19454,28 +19487,30 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
19454
19487
|
}
|
|
19455
19488
|
};
|
|
19456
19489
|
const handleKeyUp = () => {
|
|
19457
|
-
|
|
19458
|
-
|
|
19490
|
+
if (!this.textArea) return;
|
|
19491
|
+
textNode.text(this.textArea.value);
|
|
19492
|
+
if (this.textArea && textNode) {
|
|
19459
19493
|
if (!textNode.getAttrs().layout || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_ALL || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_HEIGHT) {
|
|
19460
19494
|
textAreaContainer.style.height = "auto";
|
|
19461
|
-
textAreaContainer.style.height = textArea.scrollHeight + 1.6 * textNode.getAbsoluteScale().x + "px";
|
|
19495
|
+
textAreaContainer.style.height = this.textArea.scrollHeight + 1.6 * textNode.getAbsoluteScale().x + "px";
|
|
19462
19496
|
}
|
|
19463
|
-
this.textAreaDomResize(textAreaContainer, textArea, textNode);
|
|
19497
|
+
this.textAreaDomResize(textAreaContainer, this.textArea, textNode);
|
|
19464
19498
|
}
|
|
19465
19499
|
};
|
|
19466
|
-
textArea.addEventListener("keydown", handleKeyDown);
|
|
19467
|
-
textArea.addEventListener("keyup", handleKeyUp);
|
|
19468
|
-
textArea.tabIndex = 1;
|
|
19469
|
-
textArea.focus();
|
|
19500
|
+
this.textArea.addEventListener("keydown", handleKeyDown);
|
|
19501
|
+
this.textArea.addEventListener("keyup", handleKeyUp);
|
|
19502
|
+
this.textArea.tabIndex = 1;
|
|
19503
|
+
this.textArea.focus();
|
|
19470
19504
|
const handleOutsideClick = (e) => {
|
|
19471
19505
|
e.stopPropagation();
|
|
19506
|
+
if (!this.textArea) return;
|
|
19472
19507
|
let clickedOnCanvas = false;
|
|
19473
19508
|
if (e.target?.id !== `${textNode.id()}`) clickedOnCanvas = true;
|
|
19474
19509
|
if (clickedOnCanvas) {
|
|
19475
|
-
textNode.text(textArea.value);
|
|
19510
|
+
textNode.text(this.textArea.value);
|
|
19476
19511
|
this.removeTextAreaDOM(textNode);
|
|
19477
|
-
textArea.removeEventListener("keydown", handleKeyDown);
|
|
19478
|
-
textArea.removeEventListener("keyup", handleKeyUp);
|
|
19512
|
+
this.textArea.removeEventListener("keydown", handleKeyDown);
|
|
19513
|
+
this.textArea.removeEventListener("keyup", handleKeyUp);
|
|
19479
19514
|
window.removeEventListener("click", handleOutsideClick);
|
|
19480
19515
|
window.removeEventListener("touchstart", handleOutsideClick);
|
|
19481
19516
|
return;
|
|
@@ -19502,19 +19537,17 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
19502
19537
|
if (textNode.getAttrs().verticalAlign === "top") textAreaContainer.style.alignItems = "start";
|
|
19503
19538
|
if (textNode.getAttrs().verticalAlign === "middle") textAreaContainer.style.alignItems = "center";
|
|
19504
19539
|
if (textNode.getAttrs().verticalAlign === "bottom") textAreaContainer.style.alignItems = "end";
|
|
19505
|
-
|
|
19506
|
-
textArea.rows = textNode.text().split("\n").length;
|
|
19507
|
-
textArea.style.lineHeight = `${textNode.lineHeight()}`;
|
|
19508
|
-
textArea.style.fontFamily = textNode.fontFamily();
|
|
19509
|
-
textArea.style.textAlign = textNode.align();
|
|
19510
|
-
textArea.style.color = `${textNode.fill()}`;
|
|
19540
|
+
this.mimicTextNode(textNode, textArea);
|
|
19511
19541
|
this.textAreaDomResize(textAreaContainer, textArea, textNode);
|
|
19512
19542
|
this.textAreaDomResize(textAreaContainer, textArea, textNode);
|
|
19513
|
-
const rotation = textNode.
|
|
19514
|
-
|
|
19515
|
-
|
|
19543
|
+
const rotation = textNode.getAbsoluteRotation();
|
|
19544
|
+
if (rotation) {
|
|
19545
|
+
const transform$1 = "rotate(" + rotation + "deg)";
|
|
19546
|
+
textAreaContainer.style.transform = transform$1;
|
|
19547
|
+
}
|
|
19516
19548
|
const px = 0;
|
|
19517
19549
|
const py = -3 * stage.scaleY();
|
|
19550
|
+
let transform = "";
|
|
19518
19551
|
transform += "translateX(" + px + "px)";
|
|
19519
19552
|
transform += "translateY(" + py + "px)";
|
|
19520
19553
|
textArea.style.transform = transform;
|
|
@@ -24984,7 +25017,7 @@ var WeaveExportNodesToolAction = class extends WeaveAction {
|
|
|
24984
25017
|
link.click();
|
|
24985
25018
|
this.cancelAction?.();
|
|
24986
25019
|
}
|
|
24987
|
-
async trigger(cancelAction, { nodes, options }) {
|
|
25020
|
+
async trigger(cancelAction, { nodes, options, download = true }) {
|
|
24988
25021
|
if (!this.instance) throw new Error("Instance not defined");
|
|
24989
25022
|
const stage = this.instance.getStage();
|
|
24990
25023
|
stage.container().tabIndex = 1;
|
|
@@ -24994,6 +25027,12 @@ var WeaveExportNodesToolAction = class extends WeaveAction {
|
|
|
24994
25027
|
...this.defaultFormatOptions,
|
|
24995
25028
|
...options
|
|
24996
25029
|
};
|
|
25030
|
+
if (!download) {
|
|
25031
|
+
const img = await this.instance.exportNodes(nodes, this.options);
|
|
25032
|
+
const base64URL = this.instance.imageToBase64(img, this.options.format ?? "image/png");
|
|
25033
|
+
this.cancelAction?.();
|
|
25034
|
+
return base64URL;
|
|
25035
|
+
}
|
|
24997
25036
|
await this.exportNodes(nodes);
|
|
24998
25037
|
}
|
|
24999
25038
|
cleanup() {
|
package/dist/sdk.d.cts
CHANGED
|
@@ -500,6 +500,7 @@ declare class Weave extends Emittery {
|
|
|
500
500
|
nodesToGroupSerialized(instancesToClone: Konva.Node[]): WeaveSerializedGroup;
|
|
501
501
|
cloneNodes(instancesToClone: Konva.Node[], targetContainer: Konva.Layer | Konva.Group | undefined, onPoint: Vector2d): void;
|
|
502
502
|
getFonts(): WeaveFont[];
|
|
503
|
+
imageToBase64(img: HTMLImageElement, mimeType: string): string;
|
|
503
504
|
exportNodes(nodes: WeaveElementInstance[], options: WeaveExportNodesOptions): Promise<HTMLImageElement>;
|
|
504
505
|
}
|
|
505
506
|
|
|
@@ -694,6 +695,7 @@ declare class WeaveTextNode extends WeaveNode {
|
|
|
694
695
|
private config;
|
|
695
696
|
protected nodeType: string;
|
|
696
697
|
private editing;
|
|
698
|
+
private textArea;
|
|
697
699
|
constructor(params?: WeaveTextNodeParams);
|
|
698
700
|
private updateNode;
|
|
699
701
|
onRender(props: WeaveElementAttributes): WeaveElementInstance;
|
|
@@ -710,6 +712,7 @@ declare class WeaveTextNode extends WeaveNode {
|
|
|
710
712
|
width: number;
|
|
711
713
|
height: number;
|
|
712
714
|
};
|
|
715
|
+
private mimicTextNode;
|
|
713
716
|
private createTextAreaDOM;
|
|
714
717
|
private updateTextAreaDOM;
|
|
715
718
|
private removeTextAreaDOM;
|
|
@@ -1654,6 +1657,7 @@ declare class WeaveFrameToolAction extends WeaveAction {
|
|
|
1654
1657
|
type WeaveExportNodesActionParams = {
|
|
1655
1658
|
nodes: WeaveElementInstance[];
|
|
1656
1659
|
options?: WeaveExportNodesOptions;
|
|
1660
|
+
download?: boolean;
|
|
1657
1661
|
};
|
|
1658
1662
|
|
|
1659
1663
|
//#endregion
|
|
@@ -1693,8 +1697,9 @@ declare class WeaveExportNodesToolAction extends WeaveAction {
|
|
|
1693
1697
|
private exportNodes;
|
|
1694
1698
|
trigger(cancelAction: () => void, {
|
|
1695
1699
|
nodes,
|
|
1696
|
-
options
|
|
1697
|
-
|
|
1700
|
+
options,
|
|
1701
|
+
download
|
|
1702
|
+
}: WeaveExportNodesActionParams): Promise<void | string>;
|
|
1698
1703
|
cleanup(): void;
|
|
1699
1704
|
}
|
|
1700
1705
|
|