@inditextech/weave-sdk 3.9.2 → 3.10.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 +118 -41
- package/dist/sdk.node.js +118 -41
- package/dist/sdk.node.stats.html +1 -1
- package/dist/sdk.stats.html +1 -1
- package/dist/types.d.ts +23 -14
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +118 -41
- 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
|
|
|
9
10
|
//#region rolldown:runtime
|
|
@@ -17697,7 +17698,8 @@ function moveNodeToContainerNT(instance, node, containerToMove, originalNode, or
|
|
|
17697
17698
|
const actualContainerAttrs = nodeActualContainer.getAttrs();
|
|
17698
17699
|
let layerToMove = void 0;
|
|
17699
17700
|
if (actualContainerAttrs.id !== containerToMove.getAttrs().id && !invalidOriginsTypes.includes(node.getAttrs().nodeType)) layerToMove = containerToMove;
|
|
17700
|
-
|
|
17701
|
+
const nodeHandler = instance.getNodeHandler(node.getAttrs().nodeType);
|
|
17702
|
+
if (layerToMove && actualContainerAttrs.id !== layerToMove.getAttrs().id && actualContainerAttrs.id !== layerToMove.getAttrs().containerId && nodeHandler) {
|
|
17701
17703
|
const layerToMoveAttrs = layerToMove.getAttrs();
|
|
17702
17704
|
const nodePos = node.getAbsolutePosition();
|
|
17703
17705
|
const nodeRotation = node.getAbsoluteRotation();
|
|
@@ -17706,7 +17708,6 @@ function moveNodeToContainerNT(instance, node, containerToMove, originalNode, or
|
|
|
17706
17708
|
node.rotation(nodeRotation);
|
|
17707
17709
|
node.x(node.x() - (layerToMoveAttrs.containerOffsetX ?? 0));
|
|
17708
17710
|
node.y(node.y() - (layerToMoveAttrs.containerOffsetY ?? 0));
|
|
17709
|
-
node.destroy();
|
|
17710
17711
|
const newNode = node.clone();
|
|
17711
17712
|
instance.emitEvent("onNodeMovedToContainer", {
|
|
17712
17713
|
node: newNode,
|
|
@@ -17714,17 +17715,15 @@ function moveNodeToContainerNT(instance, node, containerToMove, originalNode, or
|
|
|
17714
17715
|
originalNode,
|
|
17715
17716
|
originalContainer
|
|
17716
17717
|
});
|
|
17717
|
-
const
|
|
17718
|
-
|
|
17719
|
-
|
|
17720
|
-
|
|
17721
|
-
|
|
17722
|
-
|
|
17723
|
-
|
|
17724
|
-
|
|
17725
|
-
|
|
17726
|
-
return true;
|
|
17727
|
-
}
|
|
17718
|
+
const actualNodeState = nodeHandler.serialize(node);
|
|
17719
|
+
const newNodeState = nodeHandler.serialize(newNode);
|
|
17720
|
+
node.destroy();
|
|
17721
|
+
instance.removeNodeNT(actualNodeState, { emitUserChangeEvent: false });
|
|
17722
|
+
instance.addNodeNT(newNodeState, layerToMoveAttrs.id, {
|
|
17723
|
+
emitUserChangeEvent: false,
|
|
17724
|
+
overrideUserChangeType: WEAVE_NODE_CHANGE_TYPE.UPDATE
|
|
17725
|
+
});
|
|
17726
|
+
return true;
|
|
17728
17727
|
}
|
|
17729
17728
|
return false;
|
|
17730
17729
|
}
|
|
@@ -19287,10 +19286,10 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19287
19286
|
}
|
|
19288
19287
|
const isStage = e.target instanceof Konva.Stage;
|
|
19289
19288
|
const isTransformer = e.target?.getParent() instanceof Konva.Transformer;
|
|
19290
|
-
const
|
|
19289
|
+
const canBeTargeted = e.target.getAttrs().canBeTargeted !== false;
|
|
19291
19290
|
const isContainerEmptyArea = e.target.getAttrs().isContainerPrincipal !== void 0 && !e.target.getAttrs().isContainerPrincipal;
|
|
19292
19291
|
if (isTransformer) return;
|
|
19293
|
-
if (!isStage && !isContainerEmptyArea &&
|
|
19292
|
+
if (!isStage && !isContainerEmptyArea && canBeTargeted) {
|
|
19294
19293
|
this.selecting = false;
|
|
19295
19294
|
this.stopPanLoop();
|
|
19296
19295
|
this.hideSelectorArea();
|
|
@@ -20402,6 +20401,9 @@ var WeaveNode = class {
|
|
|
20402
20401
|
mutexUserId: void 0
|
|
20403
20402
|
});
|
|
20404
20403
|
};
|
|
20404
|
+
const isLocked = node.getAttrs().locked ?? false;
|
|
20405
|
+
if (isLocked) node.listening(false);
|
|
20406
|
+
else node.listening(true);
|
|
20405
20407
|
}
|
|
20406
20408
|
isNodeSelected(ele) {
|
|
20407
20409
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
@@ -20786,27 +20788,27 @@ var WeaveNode = class {
|
|
|
20786
20788
|
const activeAction = this.instance.getActiveAction();
|
|
20787
20789
|
const isNodeSelectionEnabled = this.getSelectionPlugin()?.isEnabled();
|
|
20788
20790
|
const realNode = this.instance.getInstanceRecursive(node);
|
|
20789
|
-
const
|
|
20790
|
-
const isLocked =
|
|
20791
|
+
const canBeTargeted = realNode.getAttrs().canBeTargeted !== false;
|
|
20792
|
+
const isLocked = realNode.getAttrs().locked ?? false;
|
|
20791
20793
|
const isMutexLocked = realNode.getAttrs().mutexLocked && realNode.getAttrs().mutexUserId !== user.id;
|
|
20792
20794
|
if ([MOVE_TOOL_ACTION_NAME].includes(activeAction ?? "")) return false;
|
|
20793
20795
|
let showHover = false;
|
|
20794
20796
|
let cancelBubble = false;
|
|
20795
|
-
if (isNodeSelectionEnabled && this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting() && (isLocked || isMutexLocked)) {
|
|
20797
|
+
if (isNodeSelectionEnabled && this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting() && realNode.hasName("node") && (isLocked || isMutexLocked)) {
|
|
20796
20798
|
stage.container().style.cursor = "default";
|
|
20797
20799
|
cancelBubble = true;
|
|
20798
20800
|
}
|
|
20799
|
-
if (isNodeSelectionEnabled && this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting() &&
|
|
20801
|
+
if (isNodeSelectionEnabled && this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting() && canBeTargeted && realNode.hasName("node") && !(isLocked || isMutexLocked) && stage.mode() === WEAVE_STAGE_DEFAULT_MODE) {
|
|
20800
20802
|
showHover = true;
|
|
20801
|
-
stage.container().style.cursor = (typeof
|
|
20803
|
+
stage.container().style.cursor = (typeof realNode?.defineMousePointer === "function" ? realNode.defineMousePointer() : null) ?? "pointer";
|
|
20802
20804
|
cancelBubble = true;
|
|
20803
20805
|
}
|
|
20804
|
-
if (isNodeSelectionEnabled && this.isSelecting() && this.isNodeSelected(realNode) && !this.isPasting() &&
|
|
20806
|
+
if (isNodeSelectionEnabled && this.isSelecting() && this.isNodeSelected(realNode) && !this.isPasting() && realNode.hasName("node") && canBeTargeted && !(isLocked || isMutexLocked) && stage.mode() === WEAVE_STAGE_DEFAULT_MODE) {
|
|
20805
20807
|
showHover = true;
|
|
20806
|
-
stage.container().style.cursor = (typeof
|
|
20808
|
+
stage.container().style.cursor = (typeof realNode?.defineMousePointer === "function" ? realNode.defineMousePointer() : null) ?? "grab";
|
|
20807
20809
|
cancelBubble = true;
|
|
20808
20810
|
}
|
|
20809
|
-
if (!
|
|
20811
|
+
if (!canBeTargeted) cancelBubble = true;
|
|
20810
20812
|
if (this.isPasting()) {
|
|
20811
20813
|
stage.container().style.cursor = "crosshair";
|
|
20812
20814
|
cancelBubble = true;
|
|
@@ -20894,7 +20896,12 @@ var WeaveNode = class {
|
|
|
20894
20896
|
}
|
|
20895
20897
|
lock(instance) {
|
|
20896
20898
|
if (instance.getAttrs().nodeType !== this.getNodeType()) return;
|
|
20897
|
-
instance.
|
|
20899
|
+
const isListening = instance.listening();
|
|
20900
|
+
instance.setAttrs({
|
|
20901
|
+
locked: true,
|
|
20902
|
+
listening: false,
|
|
20903
|
+
previousListening: isListening
|
|
20904
|
+
});
|
|
20898
20905
|
this.instance.updateNode(this.serialize(instance));
|
|
20899
20906
|
const selectionPlugin = this.getSelectionPlugin();
|
|
20900
20907
|
if (selectionPlugin) {
|
|
@@ -20912,7 +20919,12 @@ var WeaveNode = class {
|
|
|
20912
20919
|
let realInstance = instance;
|
|
20913
20920
|
if (instance.getAttrs().nodeId) realInstance = this.instance.getStage().findOne(`#${instance.getAttrs().nodeId}`);
|
|
20914
20921
|
if (!realInstance) return;
|
|
20915
|
-
realInstance.
|
|
20922
|
+
const previousListening = realInstance.getAttrs().previousListening ?? true;
|
|
20923
|
+
realInstance.setAttrs({
|
|
20924
|
+
locked: false,
|
|
20925
|
+
listening: previousListening,
|
|
20926
|
+
previousListening: void 0
|
|
20927
|
+
});
|
|
20916
20928
|
this.instance.updateNode(this.serialize(realInstance));
|
|
20917
20929
|
this.setupDefaultNodeEvents(realInstance);
|
|
20918
20930
|
const stage = this.instance.getStage();
|
|
@@ -22075,7 +22087,7 @@ var WeaveRegisterManager = class {
|
|
|
22075
22087
|
|
|
22076
22088
|
//#endregion
|
|
22077
22089
|
//#region package.json
|
|
22078
|
-
var version = "3.
|
|
22090
|
+
var version = "3.10.1";
|
|
22079
22091
|
|
|
22080
22092
|
//#endregion
|
|
22081
22093
|
//#region src/managers/setup.ts
|
|
@@ -24263,6 +24275,7 @@ async function downscaleImageFile(file, ratio) {
|
|
|
24263
24275
|
ctx.drawImage(bitmap, 0, 0, width, height);
|
|
24264
24276
|
return new Promise((resolve) => {
|
|
24265
24277
|
canvas.toBlob((blob) => resolve(blob), file.type, .9);
|
|
24278
|
+
canvas.remove();
|
|
24266
24279
|
});
|
|
24267
24280
|
}
|
|
24268
24281
|
function getImageSizeFromFile(file) {
|
|
@@ -24318,7 +24331,9 @@ const downscaleImageFromURL = (url, options) => {
|
|
|
24318
24331
|
canvas.height = height;
|
|
24319
24332
|
const ctx = canvas.getContext("2d");
|
|
24320
24333
|
ctx.drawImage(img, 0, 0, width, height);
|
|
24321
|
-
|
|
24334
|
+
const dataURL = canvas.toDataURL(type);
|
|
24335
|
+
canvas.remove();
|
|
24336
|
+
resolve(dataURL);
|
|
24322
24337
|
};
|
|
24323
24338
|
img.onerror = () => {
|
|
24324
24339
|
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
@@ -24380,7 +24395,8 @@ var WeaveStageNode = class extends WeaveNode {
|
|
|
24380
24395
|
globalEventsInitialized = false;
|
|
24381
24396
|
initialize = void 0;
|
|
24382
24397
|
onRender(props) {
|
|
24383
|
-
|
|
24398
|
+
let stage = this.instance.getStage();
|
|
24399
|
+
if (!stage) stage = new Konva.Stage({
|
|
24384
24400
|
...props,
|
|
24385
24401
|
mode: "default"
|
|
24386
24402
|
});
|
|
@@ -26430,6 +26446,7 @@ const doPreloadCursors = async (cursorsToPreload, setCursor, getFallbackCursor,
|
|
|
26430
26446
|
const ctx = canvas.getContext("2d");
|
|
26431
26447
|
ctx?.drawImage(img, 0, 0);
|
|
26432
26448
|
const dataURL = canvas.toDataURL("image/png");
|
|
26449
|
+
canvas.remove();
|
|
26433
26450
|
const tokens = value.split(" ");
|
|
26434
26451
|
tokens[0] = `url(${dataURL})`;
|
|
26435
26452
|
setCursor(state, tokens.join(" "));
|
|
@@ -27790,7 +27807,7 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
27790
27807
|
strokeScaleEnabled: true,
|
|
27791
27808
|
listening: true,
|
|
27792
27809
|
draggable: false,
|
|
27793
|
-
|
|
27810
|
+
canBeTargeted: false
|
|
27794
27811
|
});
|
|
27795
27812
|
frameInternal.clip({
|
|
27796
27813
|
x: -(borderWidth / 2) * frameInternal.scaleX(),
|
|
@@ -28051,8 +28068,8 @@ var WeaveStrokeNode = class extends WeaveNode {
|
|
|
28051
28068
|
const segLen = Math.hypot(dx, dy) || 1;
|
|
28052
28069
|
const nx = -dy / segLen;
|
|
28053
28070
|
const ny = dx / segLen;
|
|
28054
|
-
const w0 = baseW * p0.pressure / 2;
|
|
28055
|
-
const w1 = baseW * p1.pressure / 2;
|
|
28071
|
+
const w0 = Math.max(baseW * p0.pressure / 2, .5);
|
|
28072
|
+
const w1 = Math.max(baseW * p1.pressure / 2, .5);
|
|
28056
28073
|
let traveled = 0;
|
|
28057
28074
|
while (traveled < segLen) {
|
|
28058
28075
|
const step = Math.min(dashRemaining, segLen - traveled);
|
|
@@ -29120,7 +29137,7 @@ var WeaveCommentNode = class extends WeaveNode {
|
|
|
29120
29137
|
const commentNode = new Konva.Group({
|
|
29121
29138
|
...commentParams,
|
|
29122
29139
|
name: "comment",
|
|
29123
|
-
|
|
29140
|
+
canBeTargeted: false,
|
|
29124
29141
|
isExpanded: false,
|
|
29125
29142
|
commentAction: null,
|
|
29126
29143
|
listening: true,
|
|
@@ -29131,7 +29148,7 @@ var WeaveCommentNode = class extends WeaveNode {
|
|
|
29131
29148
|
id: `${id}-bg`,
|
|
29132
29149
|
x: 0,
|
|
29133
29150
|
y: -heightContracted,
|
|
29134
|
-
|
|
29151
|
+
canBeTargeted: false,
|
|
29135
29152
|
fill: commentParams.userBackgroundColor ?? "#0000FF",
|
|
29136
29153
|
stroke: this.config.style.stroke,
|
|
29137
29154
|
strokeWidth: this.config.style.strokeWidth,
|
|
@@ -34129,6 +34146,11 @@ const BRUSH_TOOL_DEFAULT_CONFIG = { interpolationSteps: 10 };
|
|
|
34129
34146
|
var WeaveBrushToolAction = class extends WeaveAction {
|
|
34130
34147
|
initialized = false;
|
|
34131
34148
|
isSpacePressed = false;
|
|
34149
|
+
penActive = false;
|
|
34150
|
+
lastSmoothedPressure = .5;
|
|
34151
|
+
lastPointerPos = null;
|
|
34152
|
+
lastPointerTime = 0;
|
|
34153
|
+
predictedCount = 0;
|
|
34132
34154
|
onPropsChange = void 0;
|
|
34133
34155
|
onInit = void 0;
|
|
34134
34156
|
constructor(params) {
|
|
@@ -34158,11 +34180,29 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34158
34180
|
};
|
|
34159
34181
|
}
|
|
34160
34182
|
getEventPressure(e) {
|
|
34161
|
-
|
|
34162
|
-
|
|
34183
|
+
const now$2 = performance.now();
|
|
34184
|
+
let velocity = 0;
|
|
34185
|
+
if (this.lastPointerPos && now$2 - this.lastPointerTime > 0) {
|
|
34186
|
+
const dx = e.evt.clientX - this.lastPointerPos.x;
|
|
34187
|
+
const dy = e.evt.clientY - this.lastPointerPos.y;
|
|
34188
|
+
velocity = Math.hypot(dx, dy) / (now$2 - this.lastPointerTime) * 1e3;
|
|
34189
|
+
}
|
|
34190
|
+
this.lastPointerPos = {
|
|
34191
|
+
x: e.evt.clientX,
|
|
34192
|
+
y: e.evt.clientY
|
|
34193
|
+
};
|
|
34194
|
+
this.lastPointerTime = now$2;
|
|
34195
|
+
const alpha = Math.min(Math.max(velocity / 1500, .15), .6);
|
|
34196
|
+
let raw;
|
|
34197
|
+
if (e.evt.pointerType === "pen") raw = e.evt.pressure || .5;
|
|
34198
|
+
else raw = .5;
|
|
34199
|
+
this.lastSmoothedPressure = alpha * raw + (1 - alpha) * this.lastSmoothedPressure;
|
|
34200
|
+
return Math.max(this.lastSmoothedPressure, .15);
|
|
34163
34201
|
}
|
|
34164
34202
|
setupEvents() {
|
|
34165
34203
|
const stage = this.instance.getStage();
|
|
34204
|
+
this.prevTouchAction = stage.container().style.touchAction;
|
|
34205
|
+
stage.container().style.touchAction = "none";
|
|
34166
34206
|
window.addEventListener("keyup", (e) => {
|
|
34167
34207
|
if (e.code === "Space" && this.instance.getActiveAction() === BRUSH_TOOL_ACTION_NAME) this.isSpacePressed = false;
|
|
34168
34208
|
}, { signal: this.instance.getEventsController()?.signal });
|
|
@@ -34188,6 +34228,8 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34188
34228
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
34189
34229
|
if (this.isSpacePressed) return;
|
|
34190
34230
|
if (e?.evt?.button !== 0) return;
|
|
34231
|
+
if (e.evt.pointerType === "touch" && this.penActive) return;
|
|
34232
|
+
if (e.evt.pointerType === "pen") this.penActive = true;
|
|
34191
34233
|
const pointPressure = this.getEventPressure(e);
|
|
34192
34234
|
this.handleStartStroke(pointPressure);
|
|
34193
34235
|
e.evt.stopPropagation();
|
|
@@ -34198,12 +34240,27 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34198
34240
|
this.setCursor();
|
|
34199
34241
|
if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
|
|
34200
34242
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
34201
|
-
const
|
|
34202
|
-
|
|
34243
|
+
const coalescedEvents = e.evt.getCoalescedEvents ? e.evt.getCoalescedEvents() : [];
|
|
34244
|
+
if (coalescedEvents.length > 1) {
|
|
34245
|
+
for (const ce of coalescedEvents) {
|
|
34246
|
+
const pointPressure = ce.pointerType === "pen" && typeof ce.pressure === "number" ? ce.pressure : .5;
|
|
34247
|
+
this.handleMovement(pointPressure, void 0, false);
|
|
34248
|
+
}
|
|
34249
|
+
const predictedEvents = e.evt.getPredictedEvents ? e.evt.getPredictedEvents() : [];
|
|
34250
|
+
if (predictedEvents.length > 0) {
|
|
34251
|
+
const last = predictedEvents[predictedEvents.length - 1];
|
|
34252
|
+
const predPressure = last.pointerType === "pen" && typeof last.pressure === "number" ? last.pressure : .5;
|
|
34253
|
+
this.handleMovement(predPressure, last, true);
|
|
34254
|
+
}
|
|
34255
|
+
} else {
|
|
34256
|
+
const pointPressure = this.getEventPressure(e);
|
|
34257
|
+
this.handleMovement(pointPressure, void 0, false);
|
|
34258
|
+
}
|
|
34203
34259
|
e.evt.stopPropagation();
|
|
34204
34260
|
};
|
|
34205
34261
|
stage.on("pointermove", handlePointerMove);
|
|
34206
34262
|
const handlePointerUp = (e) => {
|
|
34263
|
+
this.penActive = false;
|
|
34207
34264
|
if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
|
|
34208
34265
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
34209
34266
|
this.handleEndStroke();
|
|
@@ -34240,6 +34297,10 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34240
34297
|
};
|
|
34241
34298
|
}
|
|
34242
34299
|
handleStartStroke(pressure) {
|
|
34300
|
+
this.lastSmoothedPressure = .5;
|
|
34301
|
+
this.lastPointerPos = null;
|
|
34302
|
+
this.lastPointerTime = 0;
|
|
34303
|
+
this.predictedCount = 0;
|
|
34243
34304
|
const { mousePoint, container, measureContainer } = this.instance.getMousePointer();
|
|
34244
34305
|
this.clickPoint = mousePoint;
|
|
34245
34306
|
this.container = container;
|
|
@@ -34268,17 +34329,25 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34268
34329
|
}
|
|
34269
34330
|
this.setState(BRUSH_TOOL_STATE.DEFINE_STROKE);
|
|
34270
34331
|
}
|
|
34271
|
-
handleMovement(pressure) {
|
|
34332
|
+
handleMovement(pressure, predictedEvent, isPredicted = false) {
|
|
34272
34333
|
if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
|
|
34334
|
+
const stage = this.instance.getStage();
|
|
34273
34335
|
const tempStroke = this.instance.getStage().findOne(`#${this.strokeId}`);
|
|
34274
34336
|
if (this.measureContainer && tempStroke) {
|
|
34337
|
+
if (predictedEvent) stage.setPointersPositions(predictedEvent);
|
|
34275
34338
|
const { mousePoint } = this.instance.getMousePointerRelativeToContainer(this.measureContainer);
|
|
34276
34339
|
const currentPoint = {
|
|
34277
34340
|
x: mousePoint.x - tempStroke.x(),
|
|
34278
34341
|
y: mousePoint.y - tempStroke.y(),
|
|
34279
34342
|
pressure
|
|
34280
34343
|
};
|
|
34281
|
-
|
|
34344
|
+
let newStrokeElements = [...tempStroke.getAttrs().strokeElements];
|
|
34345
|
+
if (!isPredicted && this.predictedCount > 0) {
|
|
34346
|
+
newStrokeElements = newStrokeElements.slice(0, -1 * this.predictedCount);
|
|
34347
|
+
this.predictedCount = 0;
|
|
34348
|
+
}
|
|
34349
|
+
newStrokeElements.push(currentPoint);
|
|
34350
|
+
if (isPredicted) this.predictedCount++;
|
|
34282
34351
|
const box = this.getBoundingBox(newStrokeElements);
|
|
34283
34352
|
tempStroke.setAttrs({
|
|
34284
34353
|
width: box.width,
|
|
@@ -34298,17 +34367,22 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34298
34367
|
if (nodeHandler) {
|
|
34299
34368
|
const box = this.getBoundingBox(tempStroke.getAttrs().strokeElements);
|
|
34300
34369
|
let newStrokeElements = [...tempStroke.getAttrs().strokeElements];
|
|
34370
|
+
if (this.predictedCount > 0) {
|
|
34371
|
+
newStrokeElements = newStrokeElements.slice(0, -1 * this.predictedCount);
|
|
34372
|
+
this.predictedCount = 0;
|
|
34373
|
+
}
|
|
34301
34374
|
newStrokeElements = newStrokeElements.map((point) => ({
|
|
34302
34375
|
...point,
|
|
34303
34376
|
x: point.x - box.x,
|
|
34304
34377
|
y: point.y - box.y
|
|
34305
34378
|
}));
|
|
34379
|
+
const compressedPoints = simplify(newStrokeElements, 1, true);
|
|
34306
34380
|
tempStroke.setAttrs({
|
|
34307
34381
|
width: box.width,
|
|
34308
34382
|
height: box.height,
|
|
34309
34383
|
x: box.x,
|
|
34310
34384
|
y: box.y,
|
|
34311
|
-
strokeElements:
|
|
34385
|
+
strokeElements: compressedPoints
|
|
34312
34386
|
});
|
|
34313
34387
|
const realNode = this.instance.getStage().findOne(`#${tempStroke.getAttrs().id}`);
|
|
34314
34388
|
if (realNode) realNode.destroy();
|
|
@@ -34344,6 +34418,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34344
34418
|
}
|
|
34345
34419
|
cleanup() {
|
|
34346
34420
|
const stage = this.instance.getStage();
|
|
34421
|
+
stage.container().style.touchAction = this.prevTouchAction;
|
|
34347
34422
|
stage.container().style.cursor = "default";
|
|
34348
34423
|
this.instance.emitEvent("onAddedBrush");
|
|
34349
34424
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
@@ -38613,7 +38688,9 @@ var WeaveStageMinimapPlugin = class extends WeavePlugin {
|
|
|
38613
38688
|
skipStroke: true
|
|
38614
38689
|
});
|
|
38615
38690
|
if (box.width === 0 || box.height === 0) return;
|
|
38616
|
-
const
|
|
38691
|
+
const width = this.minimapStage?.width();
|
|
38692
|
+
const height = this.minimapStage?.height();
|
|
38693
|
+
const fitScale = Math.min(width / box.width, height / box.height);
|
|
38617
38694
|
const centerOffset = {
|
|
38618
38695
|
x: (this.minimapStage.width() - box.width * fitScale) / 2,
|
|
38619
38696
|
y: (this.minimapStage.height() - box.height * fitScale) / 2
|