@inditextech/weave-sdk 4.0.1 → 4.1.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 +115 -42
- package/dist/sdk.node.js +115 -42
- package/dist/sdk.node.stats.html +1 -1
- package/dist/sdk.stats.html +1 -1
- package/dist/types.d.ts +27 -18
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +115 -42
- package/dist/types.js.map +1 -1
- package/dist/types.stats.html +1 -1
- package/package.json +5 -3
package/dist/sdk.js
CHANGED
|
@@ -4,6 +4,7 @@ import { WEAVE_ASYNC_STATUS, WEAVE_AWARENESS_LAYER_ID, WEAVE_EXPORT_BACKGROUND_C
|
|
|
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";
|
|
7
|
+
import simplify from "simplify-js";
|
|
7
8
|
import "konva/lib/types";
|
|
8
9
|
import "konva/lib/Stage";
|
|
9
10
|
|
|
@@ -17871,7 +17872,8 @@ function moveNodeToContainerNT(instance, node, containerToMove, originalNode, or
|
|
|
17871
17872
|
const actualContainerAttrs = nodeActualContainer.getAttrs();
|
|
17872
17873
|
let layerToMove = void 0;
|
|
17873
17874
|
if (actualContainerAttrs.id !== containerToMove.getAttrs().id && !invalidOriginsTypes.includes(node.getAttrs().nodeType)) layerToMove = containerToMove;
|
|
17874
|
-
|
|
17875
|
+
const nodeHandler = instance.getNodeHandler(node.getAttrs().nodeType);
|
|
17876
|
+
if (layerToMove && actualContainerAttrs.id !== layerToMove.getAttrs().id && actualContainerAttrs.id !== layerToMove.getAttrs().containerId && nodeHandler) {
|
|
17875
17877
|
const layerToMoveAttrs = layerToMove.getAttrs();
|
|
17876
17878
|
const nodePos = node.getAbsolutePosition();
|
|
17877
17879
|
const nodeRotation = node.getAbsoluteRotation();
|
|
@@ -17880,7 +17882,6 @@ function moveNodeToContainerNT(instance, node, containerToMove, originalNode, or
|
|
|
17880
17882
|
node.rotation(nodeRotation);
|
|
17881
17883
|
node.x(node.x() - (layerToMoveAttrs.containerOffsetX ?? 0));
|
|
17882
17884
|
node.y(node.y() - (layerToMoveAttrs.containerOffsetY ?? 0));
|
|
17883
|
-
node.destroy();
|
|
17884
17885
|
const newNode = node.clone();
|
|
17885
17886
|
instance.emitEvent("onNodeMovedToContainer", {
|
|
17886
17887
|
node: newNode,
|
|
@@ -17888,17 +17889,15 @@ function moveNodeToContainerNT(instance, node, containerToMove, originalNode, or
|
|
|
17888
17889
|
originalNode,
|
|
17889
17890
|
originalContainer
|
|
17890
17891
|
});
|
|
17891
|
-
const
|
|
17892
|
-
|
|
17893
|
-
|
|
17894
|
-
|
|
17895
|
-
|
|
17896
|
-
|
|
17897
|
-
|
|
17898
|
-
|
|
17899
|
-
|
|
17900
|
-
return true;
|
|
17901
|
-
}
|
|
17892
|
+
const actualNodeState = nodeHandler.serialize(node);
|
|
17893
|
+
const newNodeState = nodeHandler.serialize(newNode);
|
|
17894
|
+
node.destroy();
|
|
17895
|
+
instance.removeNodeNT(actualNodeState, { emitUserChangeEvent: false });
|
|
17896
|
+
instance.addNodeNT(newNodeState, layerToMoveAttrs.id, {
|
|
17897
|
+
emitUserChangeEvent: false,
|
|
17898
|
+
overrideUserChangeType: WEAVE_NODE_CHANGE_TYPE.UPDATE
|
|
17899
|
+
});
|
|
17900
|
+
return true;
|
|
17902
17901
|
}
|
|
17903
17902
|
return false;
|
|
17904
17903
|
}
|
|
@@ -19430,10 +19429,10 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19430
19429
|
}
|
|
19431
19430
|
const isStage = e.target instanceof Konva.Stage;
|
|
19432
19431
|
const isTransformer = e.target?.getParent() instanceof Konva.Transformer;
|
|
19433
|
-
const
|
|
19432
|
+
const canBeTargeted = e.target.getAttrs().canBeTargeted !== false;
|
|
19434
19433
|
const isContainerEmptyArea = e.target.getAttrs().isContainerPrincipal !== void 0 && !e.target.getAttrs().isContainerPrincipal;
|
|
19435
19434
|
if (isTransformer) return;
|
|
19436
|
-
if (!isStage && !isContainerEmptyArea &&
|
|
19435
|
+
if (!isStage && !isContainerEmptyArea && canBeTargeted) {
|
|
19437
19436
|
this.selecting = false;
|
|
19438
19437
|
this.stopPanLoop();
|
|
19439
19438
|
this.hideSelectorArea();
|
|
@@ -20533,6 +20532,9 @@ var WeaveNode = class {
|
|
|
20533
20532
|
mutexUserId: void 0
|
|
20534
20533
|
});
|
|
20535
20534
|
};
|
|
20535
|
+
const isLocked = node.getAttrs().locked ?? false;
|
|
20536
|
+
if (isLocked) node.listening(false);
|
|
20537
|
+
else node.listening(true);
|
|
20536
20538
|
}
|
|
20537
20539
|
isNodeSelected(ele) {
|
|
20538
20540
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
@@ -20906,27 +20908,27 @@ var WeaveNode = class {
|
|
|
20906
20908
|
const activeAction = this.instance.getActiveAction();
|
|
20907
20909
|
const isNodeSelectionEnabled = this.getSelectionPlugin()?.isEnabled();
|
|
20908
20910
|
const realNode = this.instance.getInstanceRecursive(node);
|
|
20909
|
-
const
|
|
20910
|
-
const isLocked =
|
|
20911
|
+
const canBeTargeted = realNode.getAttrs().canBeTargeted !== false;
|
|
20912
|
+
const isLocked = realNode.getAttrs().locked ?? false;
|
|
20911
20913
|
const isMutexLocked = realNode.getAttrs().mutexLocked && realNode.getAttrs().mutexUserId !== user.id;
|
|
20912
20914
|
if ([MOVE_TOOL_ACTION_NAME].includes(activeAction ?? "")) return false;
|
|
20913
20915
|
let showHover = false;
|
|
20914
20916
|
let cancelBubble = false;
|
|
20915
|
-
if (isNodeSelectionEnabled && this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting() && (isLocked || isMutexLocked)) {
|
|
20917
|
+
if (isNodeSelectionEnabled && this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting() && realNode.hasName("node") && (isLocked || isMutexLocked)) {
|
|
20916
20918
|
stage.container().style.cursor = "default";
|
|
20917
20919
|
cancelBubble = true;
|
|
20918
20920
|
}
|
|
20919
|
-
if (isNodeSelectionEnabled && this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting() &&
|
|
20921
|
+
if (isNodeSelectionEnabled && this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting() && canBeTargeted && realNode.hasName("node") && !(isLocked || isMutexLocked) && stage.mode() === WEAVE_STAGE_DEFAULT_MODE) {
|
|
20920
20922
|
showHover = true;
|
|
20921
|
-
stage.container().style.cursor = (typeof
|
|
20923
|
+
stage.container().style.cursor = (typeof realNode?.defineMousePointer === "function" ? realNode.defineMousePointer() : null) ?? "pointer";
|
|
20922
20924
|
cancelBubble = true;
|
|
20923
20925
|
}
|
|
20924
|
-
if (isNodeSelectionEnabled && this.isSelecting() && this.isNodeSelected(realNode) && !this.isPasting() &&
|
|
20926
|
+
if (isNodeSelectionEnabled && this.isSelecting() && this.isNodeSelected(realNode) && !this.isPasting() && realNode.hasName("node") && canBeTargeted && !(isLocked || isMutexLocked) && stage.mode() === WEAVE_STAGE_DEFAULT_MODE) {
|
|
20925
20927
|
showHover = true;
|
|
20926
|
-
stage.container().style.cursor = (typeof
|
|
20928
|
+
stage.container().style.cursor = (typeof realNode?.defineMousePointer === "function" ? realNode.defineMousePointer() : null) ?? "grab";
|
|
20927
20929
|
cancelBubble = true;
|
|
20928
20930
|
}
|
|
20929
|
-
if (!
|
|
20931
|
+
if (!canBeTargeted) cancelBubble = true;
|
|
20930
20932
|
if (this.isPasting()) {
|
|
20931
20933
|
stage.container().style.cursor = "crosshair";
|
|
20932
20934
|
cancelBubble = true;
|
|
@@ -21014,7 +21016,12 @@ var WeaveNode = class {
|
|
|
21014
21016
|
}
|
|
21015
21017
|
lock(instance) {
|
|
21016
21018
|
if (instance.getAttrs().nodeType !== this.getNodeType()) return;
|
|
21017
|
-
instance.
|
|
21019
|
+
const isListening = instance.listening();
|
|
21020
|
+
instance.setAttrs({
|
|
21021
|
+
locked: true,
|
|
21022
|
+
listening: false,
|
|
21023
|
+
previousListening: isListening
|
|
21024
|
+
});
|
|
21018
21025
|
this.instance.updateNode(this.serialize(instance));
|
|
21019
21026
|
const selectionPlugin = this.getSelectionPlugin();
|
|
21020
21027
|
if (selectionPlugin) {
|
|
@@ -21032,7 +21039,12 @@ var WeaveNode = class {
|
|
|
21032
21039
|
let realInstance = instance;
|
|
21033
21040
|
if (instance.getAttrs().nodeId) realInstance = this.instance.getStage().findOne(`#${instance.getAttrs().nodeId}`);
|
|
21034
21041
|
if (!realInstance) return;
|
|
21035
|
-
realInstance.
|
|
21042
|
+
const previousListening = realInstance.getAttrs().previousListening ?? true;
|
|
21043
|
+
realInstance.setAttrs({
|
|
21044
|
+
locked: false,
|
|
21045
|
+
listening: previousListening,
|
|
21046
|
+
previousListening: void 0
|
|
21047
|
+
});
|
|
21036
21048
|
this.instance.updateNode(this.serialize(realInstance));
|
|
21037
21049
|
this.setupDefaultNodeEvents(realInstance);
|
|
21038
21050
|
const stage = this.instance.getStage();
|
|
@@ -22187,7 +22199,7 @@ var WeaveRegisterManager = class {
|
|
|
22187
22199
|
|
|
22188
22200
|
//#endregion
|
|
22189
22201
|
//#region package.json
|
|
22190
|
-
var version = "4.
|
|
22202
|
+
var version = "4.1.1";
|
|
22191
22203
|
|
|
22192
22204
|
//#endregion
|
|
22193
22205
|
//#region src/managers/setup.ts
|
|
@@ -24338,6 +24350,7 @@ async function downscaleImageFile(file, ratio) {
|
|
|
24338
24350
|
ctx.drawImage(bitmap, 0, 0, width, height);
|
|
24339
24351
|
return new Promise((resolve) => {
|
|
24340
24352
|
canvas.toBlob((blob) => resolve(blob), file.type, .9);
|
|
24353
|
+
canvas.remove();
|
|
24341
24354
|
});
|
|
24342
24355
|
}
|
|
24343
24356
|
function getImageSizeFromFile(file) {
|
|
@@ -24393,7 +24406,9 @@ const downscaleImageFromURL = (url, options) => {
|
|
|
24393
24406
|
canvas.height = height;
|
|
24394
24407
|
const ctx = canvas.getContext("2d");
|
|
24395
24408
|
ctx.drawImage(img, 0, 0, width, height);
|
|
24396
|
-
|
|
24409
|
+
const dataURL = canvas.toDataURL(type);
|
|
24410
|
+
canvas.remove();
|
|
24411
|
+
resolve(dataURL);
|
|
24397
24412
|
};
|
|
24398
24413
|
img.onerror = () => {
|
|
24399
24414
|
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
@@ -24455,7 +24470,8 @@ var WeaveStageNode = class extends WeaveNode {
|
|
|
24455
24470
|
globalEventsInitialized = false;
|
|
24456
24471
|
initialize = void 0;
|
|
24457
24472
|
onRender(props) {
|
|
24458
|
-
|
|
24473
|
+
let stage = this.instance.getStage();
|
|
24474
|
+
if (!stage) stage = new Konva.Stage({
|
|
24459
24475
|
...props,
|
|
24460
24476
|
mode: "default"
|
|
24461
24477
|
});
|
|
@@ -26627,6 +26643,7 @@ const doPreloadCursors = async (cursorsToPreload, setCursor, getFallbackCursor,
|
|
|
26627
26643
|
const ctx = canvas.getContext("2d");
|
|
26628
26644
|
ctx?.drawImage(img, 0, 0);
|
|
26629
26645
|
const dataURL = canvas.toDataURL("image/png");
|
|
26646
|
+
canvas.remove();
|
|
26630
26647
|
const tokens = value.split(" ");
|
|
26631
26648
|
tokens[0] = `url(${dataURL})`;
|
|
26632
26649
|
setCursor(state, tokens.join(" "));
|
|
@@ -28183,7 +28200,7 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
28183
28200
|
strokeScaleEnabled: true,
|
|
28184
28201
|
listening: true,
|
|
28185
28202
|
draggable: false,
|
|
28186
|
-
|
|
28203
|
+
canBeTargeted: false
|
|
28187
28204
|
});
|
|
28188
28205
|
frameInternal.clip({
|
|
28189
28206
|
x: 0 * frameInternal.scaleX(),
|
|
@@ -28442,8 +28459,8 @@ var WeaveStrokeNode = class extends WeaveNode {
|
|
|
28442
28459
|
const segLen = Math.hypot(dx, dy) || 1;
|
|
28443
28460
|
const nx = -dy / segLen;
|
|
28444
28461
|
const ny = dx / segLen;
|
|
28445
|
-
const w0 = baseW * p0.pressure / 2;
|
|
28446
|
-
const w1 = baseW * p1.pressure / 2;
|
|
28462
|
+
const w0 = Math.max(baseW * p0.pressure / 2, .5);
|
|
28463
|
+
const w1 = Math.max(baseW * p1.pressure / 2, .5);
|
|
28447
28464
|
let traveled = 0;
|
|
28448
28465
|
while (traveled < segLen) {
|
|
28449
28466
|
const step = Math.min(dashRemaining, segLen - traveled);
|
|
@@ -29511,7 +29528,7 @@ var WeaveCommentNode = class extends WeaveNode {
|
|
|
29511
29528
|
const commentNode = new Konva.Group({
|
|
29512
29529
|
...commentParams,
|
|
29513
29530
|
name: "comment",
|
|
29514
|
-
|
|
29531
|
+
canBeTargeted: false,
|
|
29515
29532
|
isExpanded: false,
|
|
29516
29533
|
commentAction: null,
|
|
29517
29534
|
listening: true,
|
|
@@ -29522,7 +29539,7 @@ var WeaveCommentNode = class extends WeaveNode {
|
|
|
29522
29539
|
id: `${id}-bg`,
|
|
29523
29540
|
x: 0,
|
|
29524
29541
|
y: -heightContracted,
|
|
29525
|
-
|
|
29542
|
+
canBeTargeted: false,
|
|
29526
29543
|
fill: commentParams.userBackgroundColor ?? "#0000FF",
|
|
29527
29544
|
stroke: this.config.style.stroke,
|
|
29528
29545
|
strokeWidth: this.config.style.strokeWidth,
|
|
@@ -34521,6 +34538,11 @@ const BRUSH_TOOL_DEFAULT_CONFIG = { interpolationSteps: 10 };
|
|
|
34521
34538
|
var WeaveBrushToolAction = class extends WeaveAction {
|
|
34522
34539
|
initialized = false;
|
|
34523
34540
|
isSpacePressed = false;
|
|
34541
|
+
penActive = false;
|
|
34542
|
+
lastSmoothedPressure = .5;
|
|
34543
|
+
lastPointerPos = null;
|
|
34544
|
+
lastPointerTime = 0;
|
|
34545
|
+
predictedCount = 0;
|
|
34524
34546
|
onPropsChange = void 0;
|
|
34525
34547
|
onInit = void 0;
|
|
34526
34548
|
constructor(params) {
|
|
@@ -34550,11 +34572,29 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34550
34572
|
};
|
|
34551
34573
|
}
|
|
34552
34574
|
getEventPressure(e) {
|
|
34553
|
-
|
|
34554
|
-
|
|
34575
|
+
const now$2 = performance.now();
|
|
34576
|
+
let velocity = 0;
|
|
34577
|
+
if (this.lastPointerPos && now$2 - this.lastPointerTime > 0) {
|
|
34578
|
+
const dx = e.evt.clientX - this.lastPointerPos.x;
|
|
34579
|
+
const dy = e.evt.clientY - this.lastPointerPos.y;
|
|
34580
|
+
velocity = Math.hypot(dx, dy) / (now$2 - this.lastPointerTime) * 1e3;
|
|
34581
|
+
}
|
|
34582
|
+
this.lastPointerPos = {
|
|
34583
|
+
x: e.evt.clientX,
|
|
34584
|
+
y: e.evt.clientY
|
|
34585
|
+
};
|
|
34586
|
+
this.lastPointerTime = now$2;
|
|
34587
|
+
const alpha = Math.min(Math.max(velocity / 1500, .15), .6);
|
|
34588
|
+
let raw;
|
|
34589
|
+
if (e.evt.pointerType === "pen") raw = e.evt.pressure || .5;
|
|
34590
|
+
else raw = .5;
|
|
34591
|
+
this.lastSmoothedPressure = alpha * raw + (1 - alpha) * this.lastSmoothedPressure;
|
|
34592
|
+
return Math.max(this.lastSmoothedPressure, .15);
|
|
34555
34593
|
}
|
|
34556
34594
|
setupEvents() {
|
|
34557
34595
|
const stage = this.instance.getStage();
|
|
34596
|
+
this.prevTouchAction = stage.container().style.touchAction;
|
|
34597
|
+
stage.container().style.touchAction = "none";
|
|
34558
34598
|
window.addEventListener("keyup", (e) => {
|
|
34559
34599
|
if (e.code === "Space" && this.instance.getActiveAction() === BRUSH_TOOL_ACTION_NAME) this.isSpacePressed = false;
|
|
34560
34600
|
}, { signal: this.instance.getEventsController()?.signal });
|
|
@@ -34580,6 +34620,8 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34580
34620
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
34581
34621
|
if (this.isSpacePressed) return;
|
|
34582
34622
|
if (e?.evt?.button !== 0) return;
|
|
34623
|
+
if (e.evt.pointerType === "touch" && this.penActive) return;
|
|
34624
|
+
if (e.evt.pointerType === "pen") this.penActive = true;
|
|
34583
34625
|
const pointPressure = this.getEventPressure(e);
|
|
34584
34626
|
this.handleStartStroke(pointPressure);
|
|
34585
34627
|
e.evt.stopPropagation();
|
|
@@ -34590,12 +34632,27 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34590
34632
|
this.setCursor();
|
|
34591
34633
|
if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
|
|
34592
34634
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
34593
|
-
const
|
|
34594
|
-
|
|
34635
|
+
const coalescedEvents = e.evt.getCoalescedEvents ? e.evt.getCoalescedEvents() : [];
|
|
34636
|
+
if (coalescedEvents.length > 1) {
|
|
34637
|
+
for (const ce of coalescedEvents) {
|
|
34638
|
+
const pointPressure = ce.pointerType === "pen" && typeof ce.pressure === "number" ? ce.pressure : .5;
|
|
34639
|
+
this.handleMovement(pointPressure, void 0, false);
|
|
34640
|
+
}
|
|
34641
|
+
const predictedEvents = e.evt.getPredictedEvents ? e.evt.getPredictedEvents() : [];
|
|
34642
|
+
if (predictedEvents.length > 0) {
|
|
34643
|
+
const last = predictedEvents[predictedEvents.length - 1];
|
|
34644
|
+
const predPressure = last.pointerType === "pen" && typeof last.pressure === "number" ? last.pressure : .5;
|
|
34645
|
+
this.handleMovement(predPressure, last, true);
|
|
34646
|
+
}
|
|
34647
|
+
} else {
|
|
34648
|
+
const pointPressure = this.getEventPressure(e);
|
|
34649
|
+
this.handleMovement(pointPressure, void 0, false);
|
|
34650
|
+
}
|
|
34595
34651
|
e.evt.stopPropagation();
|
|
34596
34652
|
};
|
|
34597
34653
|
stage.on("pointermove", handlePointerMove);
|
|
34598
34654
|
const handlePointerUp = (e) => {
|
|
34655
|
+
this.penActive = false;
|
|
34599
34656
|
if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
|
|
34600
34657
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
34601
34658
|
this.handleEndStroke();
|
|
@@ -34632,6 +34689,10 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34632
34689
|
};
|
|
34633
34690
|
}
|
|
34634
34691
|
handleStartStroke(pressure) {
|
|
34692
|
+
this.lastSmoothedPressure = .5;
|
|
34693
|
+
this.lastPointerPos = null;
|
|
34694
|
+
this.lastPointerTime = 0;
|
|
34695
|
+
this.predictedCount = 0;
|
|
34635
34696
|
const { mousePoint, container, measureContainer } = this.instance.getMousePointer();
|
|
34636
34697
|
this.clickPoint = mousePoint;
|
|
34637
34698
|
this.container = container;
|
|
@@ -34660,17 +34721,25 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34660
34721
|
}
|
|
34661
34722
|
this.setState(BRUSH_TOOL_STATE.DEFINE_STROKE);
|
|
34662
34723
|
}
|
|
34663
|
-
handleMovement(pressure) {
|
|
34724
|
+
handleMovement(pressure, predictedEvent, isPredicted = false) {
|
|
34664
34725
|
if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
|
|
34726
|
+
const stage = this.instance.getStage();
|
|
34665
34727
|
const tempStroke = this.instance.getStage().findOne(`#${this.strokeId}`);
|
|
34666
34728
|
if (this.measureContainer && tempStroke) {
|
|
34729
|
+
if (predictedEvent) stage.setPointersPositions(predictedEvent);
|
|
34667
34730
|
const { mousePoint } = this.instance.getMousePointerRelativeToContainer(this.measureContainer);
|
|
34668
34731
|
const currentPoint = {
|
|
34669
34732
|
x: mousePoint.x - tempStroke.x(),
|
|
34670
34733
|
y: mousePoint.y - tempStroke.y(),
|
|
34671
34734
|
pressure
|
|
34672
34735
|
};
|
|
34673
|
-
|
|
34736
|
+
let newStrokeElements = [...tempStroke.getAttrs().strokeElements];
|
|
34737
|
+
if (!isPredicted && this.predictedCount > 0) {
|
|
34738
|
+
newStrokeElements = newStrokeElements.slice(0, -1 * this.predictedCount);
|
|
34739
|
+
this.predictedCount = 0;
|
|
34740
|
+
}
|
|
34741
|
+
newStrokeElements.push(currentPoint);
|
|
34742
|
+
if (isPredicted) this.predictedCount++;
|
|
34674
34743
|
const box = this.getBoundingBox(newStrokeElements);
|
|
34675
34744
|
tempStroke.setAttrs({
|
|
34676
34745
|
width: box.width,
|
|
@@ -34690,17 +34759,22 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34690
34759
|
if (nodeHandler) {
|
|
34691
34760
|
const box = this.getBoundingBox(tempStroke.getAttrs().strokeElements);
|
|
34692
34761
|
let newStrokeElements = [...tempStroke.getAttrs().strokeElements];
|
|
34762
|
+
if (this.predictedCount > 0) {
|
|
34763
|
+
newStrokeElements = newStrokeElements.slice(0, -1 * this.predictedCount);
|
|
34764
|
+
this.predictedCount = 0;
|
|
34765
|
+
}
|
|
34693
34766
|
newStrokeElements = newStrokeElements.map((point) => ({
|
|
34694
34767
|
...point,
|
|
34695
34768
|
x: point.x - box.x,
|
|
34696
34769
|
y: point.y - box.y
|
|
34697
34770
|
}));
|
|
34771
|
+
const compressedPoints = simplify(newStrokeElements, 1, true);
|
|
34698
34772
|
tempStroke.setAttrs({
|
|
34699
34773
|
width: box.width,
|
|
34700
34774
|
height: box.height,
|
|
34701
34775
|
x: box.x,
|
|
34702
34776
|
y: box.y,
|
|
34703
|
-
strokeElements:
|
|
34777
|
+
strokeElements: compressedPoints
|
|
34704
34778
|
});
|
|
34705
34779
|
const realNode = this.instance.getStage().findOne(`#${tempStroke.getAttrs().id}`);
|
|
34706
34780
|
if (realNode) realNode.destroy();
|
|
@@ -34736,6 +34810,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34736
34810
|
}
|
|
34737
34811
|
cleanup() {
|
|
34738
34812
|
const stage = this.instance.getStage();
|
|
34813
|
+
stage.container().style.touchAction = this.prevTouchAction;
|
|
34739
34814
|
stage.container().style.cursor = "default";
|
|
34740
34815
|
this.instance.emitEvent("onAddedBrush");
|
|
34741
34816
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
@@ -39741,10 +39816,8 @@ var WeaveStageMinimapPlugin = class extends WeavePlugin {
|
|
|
39741
39816
|
skipStroke: true
|
|
39742
39817
|
});
|
|
39743
39818
|
if (box.width === 0 || box.height === 0) return;
|
|
39744
|
-
console.log("update minimap viewport reference", this.minimapStage);
|
|
39745
39819
|
const width = this.minimapStage?.width();
|
|
39746
39820
|
const height = this.minimapStage?.height();
|
|
39747
|
-
console.log("update minimap viewport reference", width, height);
|
|
39748
39821
|
const fitScale = Math.min(width / box.width, height / box.height);
|
|
39749
39822
|
const centerOffset = {
|
|
39750
39823
|
x: (width - box.width * fitScale) / 2,
|