@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/types.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 { Stage } from "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();
|
|
@@ -22198,7 +22210,7 @@ var WeaveRegisterManager = class {
|
|
|
22198
22210
|
|
|
22199
22211
|
//#endregion
|
|
22200
22212
|
//#region package.json
|
|
22201
|
-
var version = "4.
|
|
22213
|
+
var version = "4.1.1";
|
|
22202
22214
|
|
|
22203
22215
|
//#endregion
|
|
22204
22216
|
//#region src/managers/setup.ts
|
|
@@ -24349,6 +24361,7 @@ async function downscaleImageFile(file, ratio) {
|
|
|
24349
24361
|
ctx.drawImage(bitmap, 0, 0, width, height);
|
|
24350
24362
|
return new Promise((resolve) => {
|
|
24351
24363
|
canvas.toBlob((blob) => resolve(blob), file.type, .9);
|
|
24364
|
+
canvas.remove();
|
|
24352
24365
|
});
|
|
24353
24366
|
}
|
|
24354
24367
|
function getImageSizeFromFile(file) {
|
|
@@ -24404,7 +24417,9 @@ const downscaleImageFromURL = (url, options) => {
|
|
|
24404
24417
|
canvas.height = height;
|
|
24405
24418
|
const ctx = canvas.getContext("2d");
|
|
24406
24419
|
ctx.drawImage(img, 0, 0, width, height);
|
|
24407
|
-
|
|
24420
|
+
const dataURL = canvas.toDataURL(type);
|
|
24421
|
+
canvas.remove();
|
|
24422
|
+
resolve(dataURL);
|
|
24408
24423
|
};
|
|
24409
24424
|
img.onerror = () => {
|
|
24410
24425
|
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
@@ -24466,7 +24481,8 @@ var WeaveStageNode = class extends WeaveNode {
|
|
|
24466
24481
|
globalEventsInitialized = false;
|
|
24467
24482
|
initialize = void 0;
|
|
24468
24483
|
onRender(props) {
|
|
24469
|
-
|
|
24484
|
+
let stage = this.instance.getStage();
|
|
24485
|
+
if (!stage) stage = new Konva.Stage({
|
|
24470
24486
|
...props,
|
|
24471
24487
|
mode: "default"
|
|
24472
24488
|
});
|
|
@@ -26638,6 +26654,7 @@ const doPreloadCursors = async (cursorsToPreload, setCursor, getFallbackCursor,
|
|
|
26638
26654
|
const ctx = canvas.getContext("2d");
|
|
26639
26655
|
ctx?.drawImage(img, 0, 0);
|
|
26640
26656
|
const dataURL = canvas.toDataURL("image/png");
|
|
26657
|
+
canvas.remove();
|
|
26641
26658
|
const tokens = value.split(" ");
|
|
26642
26659
|
tokens[0] = `url(${dataURL})`;
|
|
26643
26660
|
setCursor(state, tokens.join(" "));
|
|
@@ -28194,7 +28211,7 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
28194
28211
|
strokeScaleEnabled: true,
|
|
28195
28212
|
listening: true,
|
|
28196
28213
|
draggable: false,
|
|
28197
|
-
|
|
28214
|
+
canBeTargeted: false
|
|
28198
28215
|
});
|
|
28199
28216
|
frameInternal.clip({
|
|
28200
28217
|
x: 0 * frameInternal.scaleX(),
|
|
@@ -28453,8 +28470,8 @@ var WeaveStrokeNode = class extends WeaveNode {
|
|
|
28453
28470
|
const segLen = Math.hypot(dx, dy) || 1;
|
|
28454
28471
|
const nx = -dy / segLen;
|
|
28455
28472
|
const ny = dx / segLen;
|
|
28456
|
-
const w0 = baseW * p0.pressure / 2;
|
|
28457
|
-
const w1 = baseW * p1.pressure / 2;
|
|
28473
|
+
const w0 = Math.max(baseW * p0.pressure / 2, .5);
|
|
28474
|
+
const w1 = Math.max(baseW * p1.pressure / 2, .5);
|
|
28458
28475
|
let traveled = 0;
|
|
28459
28476
|
while (traveled < segLen) {
|
|
28460
28477
|
const step = Math.min(dashRemaining, segLen - traveled);
|
|
@@ -29522,7 +29539,7 @@ var WeaveCommentNode = class extends WeaveNode {
|
|
|
29522
29539
|
const commentNode = new Konva.Group({
|
|
29523
29540
|
...commentParams,
|
|
29524
29541
|
name: "comment",
|
|
29525
|
-
|
|
29542
|
+
canBeTargeted: false,
|
|
29526
29543
|
isExpanded: false,
|
|
29527
29544
|
commentAction: null,
|
|
29528
29545
|
listening: true,
|
|
@@ -29533,7 +29550,7 @@ var WeaveCommentNode = class extends WeaveNode {
|
|
|
29533
29550
|
id: `${id}-bg`,
|
|
29534
29551
|
x: 0,
|
|
29535
29552
|
y: -heightContracted,
|
|
29536
|
-
|
|
29553
|
+
canBeTargeted: false,
|
|
29537
29554
|
fill: commentParams.userBackgroundColor ?? "#0000FF",
|
|
29538
29555
|
stroke: this.config.style.stroke,
|
|
29539
29556
|
strokeWidth: this.config.style.strokeWidth,
|
|
@@ -34532,6 +34549,11 @@ const BRUSH_TOOL_DEFAULT_CONFIG = { interpolationSteps: 10 };
|
|
|
34532
34549
|
var WeaveBrushToolAction = class extends WeaveAction {
|
|
34533
34550
|
initialized = false;
|
|
34534
34551
|
isSpacePressed = false;
|
|
34552
|
+
penActive = false;
|
|
34553
|
+
lastSmoothedPressure = .5;
|
|
34554
|
+
lastPointerPos = null;
|
|
34555
|
+
lastPointerTime = 0;
|
|
34556
|
+
predictedCount = 0;
|
|
34535
34557
|
onPropsChange = void 0;
|
|
34536
34558
|
onInit = void 0;
|
|
34537
34559
|
constructor(params) {
|
|
@@ -34561,11 +34583,29 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34561
34583
|
};
|
|
34562
34584
|
}
|
|
34563
34585
|
getEventPressure(e) {
|
|
34564
|
-
|
|
34565
|
-
|
|
34586
|
+
const now$2 = performance.now();
|
|
34587
|
+
let velocity = 0;
|
|
34588
|
+
if (this.lastPointerPos && now$2 - this.lastPointerTime > 0) {
|
|
34589
|
+
const dx = e.evt.clientX - this.lastPointerPos.x;
|
|
34590
|
+
const dy = e.evt.clientY - this.lastPointerPos.y;
|
|
34591
|
+
velocity = Math.hypot(dx, dy) / (now$2 - this.lastPointerTime) * 1e3;
|
|
34592
|
+
}
|
|
34593
|
+
this.lastPointerPos = {
|
|
34594
|
+
x: e.evt.clientX,
|
|
34595
|
+
y: e.evt.clientY
|
|
34596
|
+
};
|
|
34597
|
+
this.lastPointerTime = now$2;
|
|
34598
|
+
const alpha = Math.min(Math.max(velocity / 1500, .15), .6);
|
|
34599
|
+
let raw;
|
|
34600
|
+
if (e.evt.pointerType === "pen") raw = e.evt.pressure || .5;
|
|
34601
|
+
else raw = .5;
|
|
34602
|
+
this.lastSmoothedPressure = alpha * raw + (1 - alpha) * this.lastSmoothedPressure;
|
|
34603
|
+
return Math.max(this.lastSmoothedPressure, .15);
|
|
34566
34604
|
}
|
|
34567
34605
|
setupEvents() {
|
|
34568
34606
|
const stage = this.instance.getStage();
|
|
34607
|
+
this.prevTouchAction = stage.container().style.touchAction;
|
|
34608
|
+
stage.container().style.touchAction = "none";
|
|
34569
34609
|
window.addEventListener("keyup", (e) => {
|
|
34570
34610
|
if (e.code === "Space" && this.instance.getActiveAction() === BRUSH_TOOL_ACTION_NAME) this.isSpacePressed = false;
|
|
34571
34611
|
}, { signal: this.instance.getEventsController()?.signal });
|
|
@@ -34591,6 +34631,8 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34591
34631
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
34592
34632
|
if (this.isSpacePressed) return;
|
|
34593
34633
|
if (e?.evt?.button !== 0) return;
|
|
34634
|
+
if (e.evt.pointerType === "touch" && this.penActive) return;
|
|
34635
|
+
if (e.evt.pointerType === "pen") this.penActive = true;
|
|
34594
34636
|
const pointPressure = this.getEventPressure(e);
|
|
34595
34637
|
this.handleStartStroke(pointPressure);
|
|
34596
34638
|
e.evt.stopPropagation();
|
|
@@ -34601,12 +34643,27 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34601
34643
|
this.setCursor();
|
|
34602
34644
|
if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
|
|
34603
34645
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
34604
|
-
const
|
|
34605
|
-
|
|
34646
|
+
const coalescedEvents = e.evt.getCoalescedEvents ? e.evt.getCoalescedEvents() : [];
|
|
34647
|
+
if (coalescedEvents.length > 1) {
|
|
34648
|
+
for (const ce of coalescedEvents) {
|
|
34649
|
+
const pointPressure = ce.pointerType === "pen" && typeof ce.pressure === "number" ? ce.pressure : .5;
|
|
34650
|
+
this.handleMovement(pointPressure, void 0, false);
|
|
34651
|
+
}
|
|
34652
|
+
const predictedEvents = e.evt.getPredictedEvents ? e.evt.getPredictedEvents() : [];
|
|
34653
|
+
if (predictedEvents.length > 0) {
|
|
34654
|
+
const last = predictedEvents[predictedEvents.length - 1];
|
|
34655
|
+
const predPressure = last.pointerType === "pen" && typeof last.pressure === "number" ? last.pressure : .5;
|
|
34656
|
+
this.handleMovement(predPressure, last, true);
|
|
34657
|
+
}
|
|
34658
|
+
} else {
|
|
34659
|
+
const pointPressure = this.getEventPressure(e);
|
|
34660
|
+
this.handleMovement(pointPressure, void 0, false);
|
|
34661
|
+
}
|
|
34606
34662
|
e.evt.stopPropagation();
|
|
34607
34663
|
};
|
|
34608
34664
|
stage.on("pointermove", handlePointerMove);
|
|
34609
34665
|
const handlePointerUp = (e) => {
|
|
34666
|
+
this.penActive = false;
|
|
34610
34667
|
if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
|
|
34611
34668
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
34612
34669
|
this.handleEndStroke();
|
|
@@ -34643,6 +34700,10 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34643
34700
|
};
|
|
34644
34701
|
}
|
|
34645
34702
|
handleStartStroke(pressure) {
|
|
34703
|
+
this.lastSmoothedPressure = .5;
|
|
34704
|
+
this.lastPointerPos = null;
|
|
34705
|
+
this.lastPointerTime = 0;
|
|
34706
|
+
this.predictedCount = 0;
|
|
34646
34707
|
const { mousePoint, container, measureContainer } = this.instance.getMousePointer();
|
|
34647
34708
|
this.clickPoint = mousePoint;
|
|
34648
34709
|
this.container = container;
|
|
@@ -34671,17 +34732,25 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34671
34732
|
}
|
|
34672
34733
|
this.setState(BRUSH_TOOL_STATE.DEFINE_STROKE);
|
|
34673
34734
|
}
|
|
34674
|
-
handleMovement(pressure) {
|
|
34735
|
+
handleMovement(pressure, predictedEvent, isPredicted = false) {
|
|
34675
34736
|
if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
|
|
34737
|
+
const stage = this.instance.getStage();
|
|
34676
34738
|
const tempStroke = this.instance.getStage().findOne(`#${this.strokeId}`);
|
|
34677
34739
|
if (this.measureContainer && tempStroke) {
|
|
34740
|
+
if (predictedEvent) stage.setPointersPositions(predictedEvent);
|
|
34678
34741
|
const { mousePoint } = this.instance.getMousePointerRelativeToContainer(this.measureContainer);
|
|
34679
34742
|
const currentPoint = {
|
|
34680
34743
|
x: mousePoint.x - tempStroke.x(),
|
|
34681
34744
|
y: mousePoint.y - tempStroke.y(),
|
|
34682
34745
|
pressure
|
|
34683
34746
|
};
|
|
34684
|
-
|
|
34747
|
+
let newStrokeElements = [...tempStroke.getAttrs().strokeElements];
|
|
34748
|
+
if (!isPredicted && this.predictedCount > 0) {
|
|
34749
|
+
newStrokeElements = newStrokeElements.slice(0, -1 * this.predictedCount);
|
|
34750
|
+
this.predictedCount = 0;
|
|
34751
|
+
}
|
|
34752
|
+
newStrokeElements.push(currentPoint);
|
|
34753
|
+
if (isPredicted) this.predictedCount++;
|
|
34685
34754
|
const box = this.getBoundingBox(newStrokeElements);
|
|
34686
34755
|
tempStroke.setAttrs({
|
|
34687
34756
|
width: box.width,
|
|
@@ -34701,17 +34770,22 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34701
34770
|
if (nodeHandler) {
|
|
34702
34771
|
const box = this.getBoundingBox(tempStroke.getAttrs().strokeElements);
|
|
34703
34772
|
let newStrokeElements = [...tempStroke.getAttrs().strokeElements];
|
|
34773
|
+
if (this.predictedCount > 0) {
|
|
34774
|
+
newStrokeElements = newStrokeElements.slice(0, -1 * this.predictedCount);
|
|
34775
|
+
this.predictedCount = 0;
|
|
34776
|
+
}
|
|
34704
34777
|
newStrokeElements = newStrokeElements.map((point) => ({
|
|
34705
34778
|
...point,
|
|
34706
34779
|
x: point.x - box.x,
|
|
34707
34780
|
y: point.y - box.y
|
|
34708
34781
|
}));
|
|
34782
|
+
const compressedPoints = simplify(newStrokeElements, 1, true);
|
|
34709
34783
|
tempStroke.setAttrs({
|
|
34710
34784
|
width: box.width,
|
|
34711
34785
|
height: box.height,
|
|
34712
34786
|
x: box.x,
|
|
34713
34787
|
y: box.y,
|
|
34714
|
-
strokeElements:
|
|
34788
|
+
strokeElements: compressedPoints
|
|
34715
34789
|
});
|
|
34716
34790
|
const realNode = this.instance.getStage().findOne(`#${tempStroke.getAttrs().id}`);
|
|
34717
34791
|
if (realNode) realNode.destroy();
|
|
@@ -34747,6 +34821,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34747
34821
|
}
|
|
34748
34822
|
cleanup() {
|
|
34749
34823
|
const stage = this.instance.getStage();
|
|
34824
|
+
stage.container().style.touchAction = this.prevTouchAction;
|
|
34750
34825
|
stage.container().style.cursor = "default";
|
|
34751
34826
|
this.instance.emitEvent("onAddedBrush");
|
|
34752
34827
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
@@ -39798,10 +39873,8 @@ var WeaveStageMinimapPlugin = class extends WeavePlugin {
|
|
|
39798
39873
|
skipStroke: true
|
|
39799
39874
|
});
|
|
39800
39875
|
if (box.width === 0 || box.height === 0) return;
|
|
39801
|
-
console.log("update minimap viewport reference", this.minimapStage);
|
|
39802
39876
|
const width = this.minimapStage?.width();
|
|
39803
39877
|
const height = this.minimapStage?.height();
|
|
39804
|
-
console.log("update minimap viewport reference", width, height);
|
|
39805
39878
|
const fitScale = Math.min(width / box.width, height / box.height);
|
|
39806
39879
|
const centerOffset = {
|
|
39807
39880
|
x: (width - box.width * fitScale) / 2,
|