@inditextech/weave-sdk 3.6.0-SNAPSHOT.112.1 → 3.7.0-SNAPSHOT.134.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 +358 -13
- package/dist/sdk.node.js +358 -13
- package/dist/types.d.ts +17 -17
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +358 -13
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
package/dist/sdk.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Konva from "konva";
|
|
2
2
|
import pino from "pino";
|
|
3
|
-
import { WEAVE_ASYNC_STATUS, WEAVE_AWARENESS_LAYER_ID, WEAVE_EXPORT_BACKGROUND_COLOR, WEAVE_EXPORT_FORMATS, WEAVE_INSTANCE_STATUS, WEAVE_KONVA_BACKEND, WEAVE_LOG_LEVEL, WEAVE_NODE_CHANGE_TYPE, WEAVE_NODE_CUSTOM_EVENTS, WEAVE_NODE_LAYER_ID, WEAVE_NODE_POSITION, WEAVE_STORE_CONNECTION_STATUS, WEAVE_UTILITY_LAYER_ID } from "@inditextech/weave-types";
|
|
3
|
+
import { WEAVE_ASYNC_STATUS, WEAVE_AWARENESS_LAYER_ID, WEAVE_EXPORT_BACKGROUND_COLOR, WEAVE_EXPORT_FORMATS, WEAVE_EXPORT_RETURN_FORMAT, WEAVE_INSTANCE_STATUS, WEAVE_KONVA_BACKEND, WEAVE_LOG_LEVEL, WEAVE_NODE_CHANGE_TYPE, WEAVE_NODE_CUSTOM_EVENTS, WEAVE_NODE_LAYER_ID, WEAVE_NODE_POSITION, WEAVE_STORE_CONNECTION_STATUS, WEAVE_UTILITY_LAYER_ID } from "@inditextech/weave-types";
|
|
4
4
|
import { getYjsDoc, getYjsValue, observeDeep, syncedStore } from "@syncedstore/core";
|
|
5
5
|
import * as Y$1 from "yjs";
|
|
6
6
|
import * as Y from "yjs";
|
|
@@ -19236,6 +19236,10 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19236
19236
|
initEvents() {
|
|
19237
19237
|
this.selecting = false;
|
|
19238
19238
|
const stage = this.instance.getStage();
|
|
19239
|
+
window.addEventListener("blur", () => {
|
|
19240
|
+
this.isCtrlMetaPressed = false;
|
|
19241
|
+
this.isSpaceKeyPressed = false;
|
|
19242
|
+
}, { signal: this.instance.getEventsController()?.signal });
|
|
19239
19243
|
stage.container().addEventListener("keydown", (e) => {
|
|
19240
19244
|
if (e.ctrlKey || e.metaKey) this.isCtrlMetaPressed = true;
|
|
19241
19245
|
if (e.code === "Space") this.isSpaceKeyPressed = true;
|
|
@@ -22018,7 +22022,7 @@ var WeaveRegisterManager = class {
|
|
|
22018
22022
|
|
|
22019
22023
|
//#endregion
|
|
22020
22024
|
//#region package.json
|
|
22021
|
-
var version = "3.
|
|
22025
|
+
var version = "3.7.0-SNAPSHOT.134.1";
|
|
22022
22026
|
|
|
22023
22027
|
//#endregion
|
|
22024
22028
|
//#region src/managers/setup.ts
|
|
@@ -22350,6 +22354,172 @@ var WeaveExportManager = class {
|
|
|
22350
22354
|
}
|
|
22351
22355
|
});
|
|
22352
22356
|
}
|
|
22357
|
+
exportNodesAsBlob(nodes, boundingNodes, options) {
|
|
22358
|
+
return new Promise((resolve) => {
|
|
22359
|
+
const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
|
|
22360
|
+
const nodesSelectionPluginPrev = this.getNodesSelectionPlugin()?.isEnabled();
|
|
22361
|
+
const nodesDistanceSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
|
|
22362
|
+
const nodesEdgeSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
|
|
22363
|
+
const nodesStageGridPluginPrev = this.getStageGridPlugin()?.isEnabled();
|
|
22364
|
+
this.getNodesSelectionPlugin()?.disable();
|
|
22365
|
+
this.getNodesDistanceSnappingPlugin()?.disable();
|
|
22366
|
+
this.getNodesEdgeSnappingPlugin()?.disable();
|
|
22367
|
+
this.getStageGridPlugin()?.disable();
|
|
22368
|
+
const stage = this.instance.getStage();
|
|
22369
|
+
const mainLayer = this.instance.getMainLayer();
|
|
22370
|
+
const originalPosition = {
|
|
22371
|
+
x: stage.x(),
|
|
22372
|
+
y: stage.y()
|
|
22373
|
+
};
|
|
22374
|
+
const originalScale = {
|
|
22375
|
+
x: stage.scaleX(),
|
|
22376
|
+
y: stage.scaleY()
|
|
22377
|
+
};
|
|
22378
|
+
stage.scale({
|
|
22379
|
+
x: 1,
|
|
22380
|
+
y: 1
|
|
22381
|
+
});
|
|
22382
|
+
if (mainLayer) {
|
|
22383
|
+
const bounds = getExportBoundingBox(boundingNodes(nodes));
|
|
22384
|
+
const scaleX = stage.scaleX();
|
|
22385
|
+
const scaleY = stage.scaleY();
|
|
22386
|
+
const unscaledBounds = {
|
|
22387
|
+
x: bounds.x / scaleX,
|
|
22388
|
+
y: bounds.y / scaleY,
|
|
22389
|
+
width: bounds.width / scaleX,
|
|
22390
|
+
height: bounds.height / scaleY
|
|
22391
|
+
};
|
|
22392
|
+
const exportGroup = new Konva.Group();
|
|
22393
|
+
const background = new Konva.Rect({
|
|
22394
|
+
x: unscaledBounds.x - padding,
|
|
22395
|
+
y: unscaledBounds.y - padding,
|
|
22396
|
+
width: unscaledBounds.width + 2 * padding,
|
|
22397
|
+
height: unscaledBounds.height + 2 * padding,
|
|
22398
|
+
strokeWidth: 0,
|
|
22399
|
+
fill: backgroundColor
|
|
22400
|
+
});
|
|
22401
|
+
exportGroup.add(background);
|
|
22402
|
+
for (const node of nodes) {
|
|
22403
|
+
const clonedNode = node.clone({ id: v4_default() });
|
|
22404
|
+
const absPos = node.getAbsolutePosition();
|
|
22405
|
+
clonedNode.absolutePosition({
|
|
22406
|
+
x: absPos.x / scaleX,
|
|
22407
|
+
y: absPos.y / scaleY
|
|
22408
|
+
});
|
|
22409
|
+
exportGroup.add(clonedNode);
|
|
22410
|
+
}
|
|
22411
|
+
mainLayer.add(exportGroup);
|
|
22412
|
+
const backgroundRect = background.getClientRect();
|
|
22413
|
+
stage.batchDraw();
|
|
22414
|
+
const { pixelRatio: finalPixelRatio } = this.fitKonvaPixelRatio(Math.round(backgroundRect.width), Math.round(backgroundRect.height), pixelRatio);
|
|
22415
|
+
exportGroup.toBlob({
|
|
22416
|
+
x: Math.round(backgroundRect.x),
|
|
22417
|
+
y: Math.round(backgroundRect.y),
|
|
22418
|
+
width: Math.round(backgroundRect.width),
|
|
22419
|
+
height: Math.round(backgroundRect.height),
|
|
22420
|
+
mimeType: format,
|
|
22421
|
+
pixelRatio: finalPixelRatio,
|
|
22422
|
+
quality: options.quality ?? 1,
|
|
22423
|
+
callback: (blob) => {
|
|
22424
|
+
exportGroup.destroy();
|
|
22425
|
+
stage.position(originalPosition);
|
|
22426
|
+
stage.scale(originalScale);
|
|
22427
|
+
stage.batchDraw();
|
|
22428
|
+
if (nodesSelectionPluginPrev) this.getNodesSelectionPlugin()?.enable();
|
|
22429
|
+
if (nodesDistanceSnappingPluginPrev) this.getNodesDistanceSnappingPlugin()?.enable();
|
|
22430
|
+
if (nodesEdgeSnappingPluginPrev) this.getNodesEdgeSnappingPlugin()?.enable();
|
|
22431
|
+
if (nodesStageGridPluginPrev) this.getStageGridPlugin()?.enable();
|
|
22432
|
+
if (!blob) {
|
|
22433
|
+
(0, import_lodash.reject)(new Error("Failed to generate image blob"));
|
|
22434
|
+
return;
|
|
22435
|
+
}
|
|
22436
|
+
resolve(blob);
|
|
22437
|
+
}
|
|
22438
|
+
});
|
|
22439
|
+
}
|
|
22440
|
+
});
|
|
22441
|
+
}
|
|
22442
|
+
exportNodesAsCanvas(nodes, boundingNodes, options) {
|
|
22443
|
+
return new Promise((resolve) => {
|
|
22444
|
+
const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
|
|
22445
|
+
const nodesSelectionPluginPrev = this.getNodesSelectionPlugin()?.isEnabled();
|
|
22446
|
+
const nodesDistanceSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
|
|
22447
|
+
const nodesEdgeSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
|
|
22448
|
+
const nodesStageGridPluginPrev = this.getStageGridPlugin()?.isEnabled();
|
|
22449
|
+
this.getNodesSelectionPlugin()?.disable();
|
|
22450
|
+
this.getNodesDistanceSnappingPlugin()?.disable();
|
|
22451
|
+
this.getNodesEdgeSnappingPlugin()?.disable();
|
|
22452
|
+
this.getStageGridPlugin()?.disable();
|
|
22453
|
+
const stage = this.instance.getStage();
|
|
22454
|
+
const mainLayer = this.instance.getMainLayer();
|
|
22455
|
+
const originalPosition = {
|
|
22456
|
+
x: stage.x(),
|
|
22457
|
+
y: stage.y()
|
|
22458
|
+
};
|
|
22459
|
+
const originalScale = {
|
|
22460
|
+
x: stage.scaleX(),
|
|
22461
|
+
y: stage.scaleY()
|
|
22462
|
+
};
|
|
22463
|
+
stage.scale({
|
|
22464
|
+
x: 1,
|
|
22465
|
+
y: 1
|
|
22466
|
+
});
|
|
22467
|
+
if (mainLayer) {
|
|
22468
|
+
const bounds = getExportBoundingBox(boundingNodes(nodes));
|
|
22469
|
+
const scaleX = stage.scaleX();
|
|
22470
|
+
const scaleY = stage.scaleY();
|
|
22471
|
+
const unscaledBounds = {
|
|
22472
|
+
x: bounds.x / scaleX,
|
|
22473
|
+
y: bounds.y / scaleY,
|
|
22474
|
+
width: bounds.width / scaleX,
|
|
22475
|
+
height: bounds.height / scaleY
|
|
22476
|
+
};
|
|
22477
|
+
const exportGroup = new Konva.Group();
|
|
22478
|
+
const background = new Konva.Rect({
|
|
22479
|
+
x: unscaledBounds.x - padding,
|
|
22480
|
+
y: unscaledBounds.y - padding,
|
|
22481
|
+
width: unscaledBounds.width + 2 * padding,
|
|
22482
|
+
height: unscaledBounds.height + 2 * padding,
|
|
22483
|
+
strokeWidth: 0,
|
|
22484
|
+
fill: backgroundColor
|
|
22485
|
+
});
|
|
22486
|
+
exportGroup.add(background);
|
|
22487
|
+
for (const node of nodes) {
|
|
22488
|
+
const clonedNode = node.clone({ id: v4_default() });
|
|
22489
|
+
const absPos = node.getAbsolutePosition();
|
|
22490
|
+
clonedNode.absolutePosition({
|
|
22491
|
+
x: absPos.x / scaleX,
|
|
22492
|
+
y: absPos.y / scaleY
|
|
22493
|
+
});
|
|
22494
|
+
exportGroup.add(clonedNode);
|
|
22495
|
+
}
|
|
22496
|
+
mainLayer.add(exportGroup);
|
|
22497
|
+
const backgroundRect = background.getClientRect();
|
|
22498
|
+
stage.batchDraw();
|
|
22499
|
+
const { pixelRatio: finalPixelRatio } = this.fitKonvaPixelRatio(Math.round(backgroundRect.width), Math.round(backgroundRect.height), pixelRatio);
|
|
22500
|
+
exportGroup.toCanvas({
|
|
22501
|
+
x: Math.round(backgroundRect.x),
|
|
22502
|
+
y: Math.round(backgroundRect.y),
|
|
22503
|
+
width: Math.round(backgroundRect.width),
|
|
22504
|
+
height: Math.round(backgroundRect.height),
|
|
22505
|
+
mimeType: format,
|
|
22506
|
+
pixelRatio: finalPixelRatio,
|
|
22507
|
+
quality: options.quality ?? 1,
|
|
22508
|
+
callback: (canvas) => {
|
|
22509
|
+
exportGroup.destroy();
|
|
22510
|
+
stage.position(originalPosition);
|
|
22511
|
+
stage.scale(originalScale);
|
|
22512
|
+
stage.batchDraw();
|
|
22513
|
+
if (nodesSelectionPluginPrev) this.getNodesSelectionPlugin()?.enable();
|
|
22514
|
+
if (nodesDistanceSnappingPluginPrev) this.getNodesDistanceSnappingPlugin()?.enable();
|
|
22515
|
+
if (nodesEdgeSnappingPluginPrev) this.getNodesEdgeSnappingPlugin()?.enable();
|
|
22516
|
+
if (nodesStageGridPluginPrev) this.getStageGridPlugin()?.enable();
|
|
22517
|
+
resolve(canvas);
|
|
22518
|
+
}
|
|
22519
|
+
});
|
|
22520
|
+
}
|
|
22521
|
+
});
|
|
22522
|
+
}
|
|
22353
22523
|
exportAreaAsImage(area, options) {
|
|
22354
22524
|
return new Promise((resolve) => {
|
|
22355
22525
|
const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
|
|
@@ -22414,6 +22584,138 @@ var WeaveExportManager = class {
|
|
|
22414
22584
|
});
|
|
22415
22585
|
});
|
|
22416
22586
|
}
|
|
22587
|
+
exportAreaAsBlob(area, options) {
|
|
22588
|
+
return new Promise((resolve) => {
|
|
22589
|
+
const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
|
|
22590
|
+
const nodesSelectionPluginPrev = this.getNodesSelectionPlugin()?.isEnabled();
|
|
22591
|
+
const nodesDistanceSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
|
|
22592
|
+
const nodesEdgeSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
|
|
22593
|
+
const nodesStageGridPluginPrev = this.getStageGridPlugin()?.isEnabled();
|
|
22594
|
+
this.getNodesSelectionPlugin()?.disable();
|
|
22595
|
+
this.getNodesDistanceSnappingPlugin()?.disable();
|
|
22596
|
+
this.getNodesEdgeSnappingPlugin()?.disable();
|
|
22597
|
+
this.getStageGridPlugin()?.disable();
|
|
22598
|
+
const stage = this.instance.getStage();
|
|
22599
|
+
const mainLayer = this.instance.getMainLayer();
|
|
22600
|
+
if (!mainLayer) throw new Error("Main layer not found");
|
|
22601
|
+
const originalPosition = {
|
|
22602
|
+
x: stage.x(),
|
|
22603
|
+
y: stage.y()
|
|
22604
|
+
};
|
|
22605
|
+
const originalScale = {
|
|
22606
|
+
x: stage.scaleX(),
|
|
22607
|
+
y: stage.scaleY()
|
|
22608
|
+
};
|
|
22609
|
+
stage.scale({
|
|
22610
|
+
x: 1,
|
|
22611
|
+
y: 1
|
|
22612
|
+
});
|
|
22613
|
+
stage.position({
|
|
22614
|
+
x: 0,
|
|
22615
|
+
y: 0
|
|
22616
|
+
});
|
|
22617
|
+
const bounds = area;
|
|
22618
|
+
const background = new Konva.Rect({
|
|
22619
|
+
x: bounds.x - padding,
|
|
22620
|
+
y: bounds.y - padding,
|
|
22621
|
+
width: bounds.width + 2 * padding,
|
|
22622
|
+
height: bounds.height + 2 * padding,
|
|
22623
|
+
strokeWidth: 0,
|
|
22624
|
+
fill: backgroundColor
|
|
22625
|
+
});
|
|
22626
|
+
mainLayer.add(background);
|
|
22627
|
+
background.moveToBottom();
|
|
22628
|
+
stage.batchDraw();
|
|
22629
|
+
stage.toBlob({
|
|
22630
|
+
x: area.x,
|
|
22631
|
+
y: area.y,
|
|
22632
|
+
width: area.width,
|
|
22633
|
+
height: area.height,
|
|
22634
|
+
mimeType: format,
|
|
22635
|
+
pixelRatio,
|
|
22636
|
+
quality: options.quality ?? 1,
|
|
22637
|
+
callback: (blob) => {
|
|
22638
|
+
background.destroy();
|
|
22639
|
+
stage.position(originalPosition);
|
|
22640
|
+
stage.scale(originalScale);
|
|
22641
|
+
stage.batchDraw();
|
|
22642
|
+
if (nodesSelectionPluginPrev) this.getNodesSelectionPlugin()?.enable();
|
|
22643
|
+
if (nodesDistanceSnappingPluginPrev) this.getNodesDistanceSnappingPlugin()?.enable();
|
|
22644
|
+
if (nodesEdgeSnappingPluginPrev) this.getNodesEdgeSnappingPlugin()?.enable();
|
|
22645
|
+
if (nodesStageGridPluginPrev) this.getStageGridPlugin()?.enable();
|
|
22646
|
+
if (!blob) {
|
|
22647
|
+
(0, import_lodash.reject)(new Error("Failed to generate image blob"));
|
|
22648
|
+
return;
|
|
22649
|
+
}
|
|
22650
|
+
resolve(blob);
|
|
22651
|
+
}
|
|
22652
|
+
});
|
|
22653
|
+
});
|
|
22654
|
+
}
|
|
22655
|
+
exportAreaAsCanvas(area, options) {
|
|
22656
|
+
return new Promise((resolve) => {
|
|
22657
|
+
const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
|
|
22658
|
+
const nodesSelectionPluginPrev = this.getNodesSelectionPlugin()?.isEnabled();
|
|
22659
|
+
const nodesDistanceSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
|
|
22660
|
+
const nodesEdgeSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
|
|
22661
|
+
const nodesStageGridPluginPrev = this.getStageGridPlugin()?.isEnabled();
|
|
22662
|
+
this.getNodesSelectionPlugin()?.disable();
|
|
22663
|
+
this.getNodesDistanceSnappingPlugin()?.disable();
|
|
22664
|
+
this.getNodesEdgeSnappingPlugin()?.disable();
|
|
22665
|
+
this.getStageGridPlugin()?.disable();
|
|
22666
|
+
const stage = this.instance.getStage();
|
|
22667
|
+
const mainLayer = this.instance.getMainLayer();
|
|
22668
|
+
if (!mainLayer) throw new Error("Main layer not found");
|
|
22669
|
+
const originalPosition = {
|
|
22670
|
+
x: stage.x(),
|
|
22671
|
+
y: stage.y()
|
|
22672
|
+
};
|
|
22673
|
+
const originalScale = {
|
|
22674
|
+
x: stage.scaleX(),
|
|
22675
|
+
y: stage.scaleY()
|
|
22676
|
+
};
|
|
22677
|
+
stage.scale({
|
|
22678
|
+
x: 1,
|
|
22679
|
+
y: 1
|
|
22680
|
+
});
|
|
22681
|
+
stage.position({
|
|
22682
|
+
x: 0,
|
|
22683
|
+
y: 0
|
|
22684
|
+
});
|
|
22685
|
+
const bounds = area;
|
|
22686
|
+
const background = new Konva.Rect({
|
|
22687
|
+
x: bounds.x - padding,
|
|
22688
|
+
y: bounds.y - padding,
|
|
22689
|
+
width: bounds.width + 2 * padding,
|
|
22690
|
+
height: bounds.height + 2 * padding,
|
|
22691
|
+
strokeWidth: 0,
|
|
22692
|
+
fill: backgroundColor
|
|
22693
|
+
});
|
|
22694
|
+
mainLayer.add(background);
|
|
22695
|
+
background.moveToBottom();
|
|
22696
|
+
stage.batchDraw();
|
|
22697
|
+
stage.toCanvas({
|
|
22698
|
+
x: area.x,
|
|
22699
|
+
y: area.y,
|
|
22700
|
+
width: area.width,
|
|
22701
|
+
height: area.height,
|
|
22702
|
+
mimeType: format,
|
|
22703
|
+
pixelRatio,
|
|
22704
|
+
quality: options.quality ?? 1,
|
|
22705
|
+
callback: (canvas) => {
|
|
22706
|
+
background.destroy();
|
|
22707
|
+
stage.position(originalPosition);
|
|
22708
|
+
stage.scale(originalScale);
|
|
22709
|
+
stage.batchDraw();
|
|
22710
|
+
if (nodesSelectionPluginPrev) this.getNodesSelectionPlugin()?.enable();
|
|
22711
|
+
if (nodesDistanceSnappingPluginPrev) this.getNodesDistanceSnappingPlugin()?.enable();
|
|
22712
|
+
if (nodesEdgeSnappingPluginPrev) this.getNodesEdgeSnappingPlugin()?.enable();
|
|
22713
|
+
if (nodesStageGridPluginPrev) this.getStageGridPlugin()?.enable();
|
|
22714
|
+
resolve(canvas);
|
|
22715
|
+
}
|
|
22716
|
+
});
|
|
22717
|
+
});
|
|
22718
|
+
}
|
|
22417
22719
|
async exportNodesServerSide(nodes, boundingNodes, options) {
|
|
22418
22720
|
const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
|
|
22419
22721
|
this.getNodesSelectionPlugin()?.disable();
|
|
@@ -22629,6 +22931,14 @@ var WeaveExportManager = class {
|
|
|
22629
22931
|
const snappingPlugin = this.instance.getPlugin(WEAVE_NODES_DISTANCE_SNAPPING_PLUGIN_KEY);
|
|
22630
22932
|
return snappingPlugin;
|
|
22631
22933
|
}
|
|
22934
|
+
blobToDataURL(blob) {
|
|
22935
|
+
return new Promise((resolve, reject) => {
|
|
22936
|
+
const reader = new FileReader();
|
|
22937
|
+
reader.onloadend = () => resolve(reader.result);
|
|
22938
|
+
reader.onerror = () => reject(new Error("Failed to convert blob to data URL"));
|
|
22939
|
+
reader.readAsDataURL(blob);
|
|
22940
|
+
});
|
|
22941
|
+
}
|
|
22632
22942
|
};
|
|
22633
22943
|
|
|
22634
22944
|
//#endregion
|
|
@@ -23680,11 +23990,27 @@ var Weave = class {
|
|
|
23680
23990
|
async exportAreaServerSide(area, options) {
|
|
23681
23991
|
return await this.exportManager.exportAreaServerSide(area, options);
|
|
23682
23992
|
}
|
|
23683
|
-
async exportNodes(nodes, boundingNodes, options) {
|
|
23684
|
-
|
|
23993
|
+
async exportNodes(nodes, boundingNodes, options, returnFormat = WEAVE_EXPORT_RETURN_FORMAT.IMAGE) {
|
|
23994
|
+
switch (returnFormat) {
|
|
23995
|
+
case WEAVE_EXPORT_RETURN_FORMAT.BLOB: return await this.exportManager.exportNodesAsBlob(nodes, boundingNodes, options);
|
|
23996
|
+
case WEAVE_EXPORT_RETURN_FORMAT.CANVAS: return await this.exportManager.exportNodesAsCanvas(nodes, boundingNodes, options);
|
|
23997
|
+
case WEAVE_EXPORT_RETURN_FORMAT.DATA_URL: {
|
|
23998
|
+
const blob = await this.exportManager.exportNodesAsBlob(nodes, boundingNodes, options);
|
|
23999
|
+
return await this.exportManager.blobToDataURL(blob);
|
|
24000
|
+
}
|
|
24001
|
+
case WEAVE_EXPORT_RETURN_FORMAT.IMAGE: return await this.exportManager.exportNodesAsImage(nodes, boundingNodes, options);
|
|
24002
|
+
}
|
|
23685
24003
|
}
|
|
23686
|
-
async exportArea(area, options) {
|
|
23687
|
-
|
|
24004
|
+
async exportArea(area, options, returnFormat = WEAVE_EXPORT_RETURN_FORMAT.IMAGE) {
|
|
24005
|
+
switch (returnFormat) {
|
|
24006
|
+
case WEAVE_EXPORT_RETURN_FORMAT.BLOB: return await this.exportManager.exportAreaAsBlob(area, options);
|
|
24007
|
+
case WEAVE_EXPORT_RETURN_FORMAT.CANVAS: return await this.exportManager.exportAreaAsCanvas(area, options);
|
|
24008
|
+
case WEAVE_EXPORT_RETURN_FORMAT.DATA_URL: {
|
|
24009
|
+
const blob = await this.exportManager.exportAreaAsBlob(area, options);
|
|
24010
|
+
return await this.exportManager.blobToDataURL(blob);
|
|
24011
|
+
}
|
|
24012
|
+
case WEAVE_EXPORT_RETURN_FORMAT.IMAGE: return await this.exportManager.exportAreaAsImage(area, options);
|
|
24013
|
+
}
|
|
23688
24014
|
}
|
|
23689
24015
|
getExportBoundingBox(nodesIds) {
|
|
23690
24016
|
const nodes = [];
|
|
@@ -24074,6 +24400,9 @@ var WeaveStageNode = class extends WeaveNode {
|
|
|
24074
24400
|
setupEvents() {
|
|
24075
24401
|
if (this.globalEventsInitialized) return;
|
|
24076
24402
|
if (this.instance.isServerSide()) return;
|
|
24403
|
+
window.addEventListener("blur", () => {
|
|
24404
|
+
this.isCmdCtrlPressed = false;
|
|
24405
|
+
}, { signal: this.instance.getEventsController()?.signal });
|
|
24077
24406
|
window.addEventListener("keydown", (e) => {
|
|
24078
24407
|
if (this.isOnlyCtrlOrMeta(e)) {
|
|
24079
24408
|
this.isCmdCtrlPressed = true;
|
|
@@ -24778,6 +25107,9 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
24778
25107
|
}
|
|
24779
25108
|
initEvents() {
|
|
24780
25109
|
if (!this.eventsInitialized && !globalThis._weave_isServerSide) {
|
|
25110
|
+
window.addEventListener("blur", () => {
|
|
25111
|
+
this.isCtrlMetaPressed = false;
|
|
25112
|
+
}, { signal: this.instance.getEventsController()?.signal });
|
|
24781
25113
|
window.addEventListener("keydown", (e) => {
|
|
24782
25114
|
if (e.ctrlKey || e.metaKey) this.isCtrlMetaPressed = true;
|
|
24783
25115
|
}, { signal: this.instance.getEventsController()?.signal });
|
|
@@ -27311,15 +27643,16 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
27311
27643
|
width: props.frameWidth - borderWidth * 2,
|
|
27312
27644
|
height: props.frameHeight - borderWidth * 2,
|
|
27313
27645
|
strokeScaleEnabled: true,
|
|
27314
|
-
clipFunc: (ctx) => {
|
|
27315
|
-
const width = (frameInternal.width() + borderWidth) * frameInternal.scaleX();
|
|
27316
|
-
const height = (frameInternal.height() + borderWidth) * frameInternal.scaleY();
|
|
27317
|
-
ctx.rect(-(borderWidth / 2) * frameInternal.scaleX(), -(borderWidth / 2) * frameInternal.scaleY(), width, height);
|
|
27318
|
-
},
|
|
27319
27646
|
listening: true,
|
|
27320
27647
|
draggable: false,
|
|
27321
27648
|
isTargetable: false
|
|
27322
27649
|
});
|
|
27650
|
+
frameInternal.clip({
|
|
27651
|
+
x: -(borderWidth / 2) * frameInternal.scaleX(),
|
|
27652
|
+
y: -(borderWidth / 2) * frameInternal.scaleX(),
|
|
27653
|
+
width: (frameInternal.width() + borderWidth) * frameInternal.scaleX(),
|
|
27654
|
+
height: (frameInternal.height() + borderWidth) * frameInternal.scaleY()
|
|
27655
|
+
});
|
|
27323
27656
|
frame.add(frameInternal);
|
|
27324
27657
|
const selectionArea = new Konva.Rect({
|
|
27325
27658
|
...frameParams,
|
|
@@ -27419,6 +27752,12 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
27419
27752
|
frame.getNodeAnchors = function() {
|
|
27420
27753
|
return [];
|
|
27421
27754
|
};
|
|
27755
|
+
frame.clip({
|
|
27756
|
+
x: 0,
|
|
27757
|
+
y: text.y(),
|
|
27758
|
+
width: frame.width(),
|
|
27759
|
+
height: frame.height() + text.height()
|
|
27760
|
+
});
|
|
27422
27761
|
return frame;
|
|
27423
27762
|
}
|
|
27424
27763
|
onUpdate(nodeInstance, nextProps) {
|
|
@@ -32110,6 +32449,9 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
|
|
|
32110
32449
|
};
|
|
32111
32450
|
}
|
|
32112
32451
|
initEvents() {
|
|
32452
|
+
window.addEventListener("blur", () => {
|
|
32453
|
+
this.isCtrlOrMetaPressed = false;
|
|
32454
|
+
}, { signal: this.instance.getEventsController()?.signal });
|
|
32113
32455
|
window.addEventListener("keydown", (e) => {
|
|
32114
32456
|
if (e.ctrlKey || e.metaKey) this.isCtrlOrMetaPressed = true;
|
|
32115
32457
|
}, { signal: this.instance.getEventsController()?.signal });
|
|
@@ -36053,7 +36395,7 @@ var WeaveExportStageToolAction = class extends WeaveAction {
|
|
|
36053
36395
|
}
|
|
36054
36396
|
async exportStage(boundingNodes) {
|
|
36055
36397
|
const mainLayer = this.instance.getMainLayer();
|
|
36056
|
-
const img = await this.instance.exportNodes(mainLayer?.getChildren() ?? [], boundingNodes, this.options);
|
|
36398
|
+
const img = await this.instance.exportNodes(mainLayer?.getChildren() ?? [], boundingNodes, this.options, WEAVE_EXPORT_RETURN_FORMAT.IMAGE);
|
|
36057
36399
|
return img;
|
|
36058
36400
|
}
|
|
36059
36401
|
async trigger(cancelAction, { boundingNodes, options }) {
|
|
@@ -36103,7 +36445,7 @@ var WeaveExportNodesToolAction = class extends WeaveAction {
|
|
|
36103
36445
|
return EXPORT_NODES_TOOL_ACTION_NAME;
|
|
36104
36446
|
}
|
|
36105
36447
|
async exportNodes(nodes, boundingNodes) {
|
|
36106
|
-
const img = await this.instance.exportNodes(nodes, boundingNodes ?? ((nodes$1) => nodes$1), this.options);
|
|
36448
|
+
const img = await this.instance.exportNodes(nodes, boundingNodes ?? ((nodes$1) => nodes$1), this.options, WEAVE_EXPORT_RETURN_FORMAT.IMAGE);
|
|
36107
36449
|
return img;
|
|
36108
36450
|
}
|
|
36109
36451
|
async trigger(cancelAction, { nodes, boundingNodes, options, triggerSelectionTool = true }) {
|
|
@@ -37828,6 +38170,9 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
37828
38170
|
}
|
|
37829
38171
|
initEvents() {
|
|
37830
38172
|
const stage = this.instance.getStage();
|
|
38173
|
+
window.addEventListener("blur", () => {
|
|
38174
|
+
this.isCtrlOrMetaPressed = false;
|
|
38175
|
+
}, { signal: this.instance.getEventsController()?.signal });
|
|
37831
38176
|
window.addEventListener("keydown", (e) => {
|
|
37832
38177
|
if (e.ctrlKey || e.metaKey) this.isCtrlOrMetaPressed = true;
|
|
37833
38178
|
if (e.code === "Space") {
|