@inditextech/weave-sdk 5.1.1 → 5.1.3
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 +106 -17
- package/dist/sdk.node.js +106 -17
- package/dist/sdk.node.stats.html +1 -1
- package/dist/sdk.stats.html +1 -1
- package/dist/types.d.ts +19 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +106 -17
- package/dist/types.js.map +1 -1
- package/dist/types.stats.html +1 -1
- package/package.json +2 -2
package/dist/sdk.js
CHANGED
|
@@ -4913,6 +4913,12 @@ function handleClickOrTap(ctx, e) {
|
|
|
4913
4913
|
tr.nodes([nodeTargeted]);
|
|
4914
4914
|
tr.show();
|
|
4915
4915
|
areNodesSelected = true;
|
|
4916
|
+
const canMove = typeof nodeTargeted.canDrag === "function" ? nodeTargeted.canDrag() : false;
|
|
4917
|
+
if (canMove && e.evt) {
|
|
4918
|
+
nodeTargeted.draggable(true);
|
|
4919
|
+
ctx.armDrag(nodeTargeted, e.evt.pointerId);
|
|
4920
|
+
return;
|
|
4921
|
+
}
|
|
4916
4922
|
}
|
|
4917
4923
|
if (metaPressed && isSelected) {
|
|
4918
4924
|
const nodes = tr.nodes().slice();
|
|
@@ -5010,6 +5016,7 @@ function handlePointerDown(ctx, e) {
|
|
|
5010
5016
|
if (e.target.getClassName().includes("custom-snap-guide")) return;
|
|
5011
5017
|
ctx.setClickOrTapHandled(false);
|
|
5012
5018
|
ctx.registerPointer(e.evt.pointerId, e.evt);
|
|
5019
|
+
ctx.clearArmedDrag();
|
|
5013
5020
|
if (e.evt.pointerType === "touch" && ctx.getPointerCount() > 1) return;
|
|
5014
5021
|
if (e.evt.pointerType === "mouse" && e.evt?.button !== 0) return;
|
|
5015
5022
|
if (e.evt.pointerType === "pen" && e.evt?.pressure <= .05) return;
|
|
@@ -5022,6 +5029,25 @@ function handlePointerDown(ctx, e) {
|
|
|
5022
5029
|
ctx.setAreaSelecting(false);
|
|
5023
5030
|
ctx.getEdgePanning().stop();
|
|
5024
5031
|
ctx.getAreaSelector().hide();
|
|
5032
|
+
const weave = ctx.getWeaveInstance();
|
|
5033
|
+
const realNode = weave.getRealSelectedNode(selectedGroup);
|
|
5034
|
+
const tr = ctx.getTransformerController().getTransformer();
|
|
5035
|
+
const selectedIds = new Set(tr.nodes().map((node) => node.getAttrs().id));
|
|
5036
|
+
let isWithinSelection = false;
|
|
5037
|
+
for (let cur = realNode; cur; cur = cur.getParent()) {
|
|
5038
|
+
if (typeof cur.getAttrs !== "function") break;
|
|
5039
|
+
if (selectedIds.has(cur.getAttrs().id)) {
|
|
5040
|
+
isWithinSelection = true;
|
|
5041
|
+
break;
|
|
5042
|
+
}
|
|
5043
|
+
}
|
|
5044
|
+
if (!isWithinSelection && realNode.getAttrs().nodeType) {
|
|
5045
|
+
Konva.DD._dragElements.forEach((elem, key) => {
|
|
5046
|
+
if (elem.dragStatus === "ready") Konva.DD._dragElements.delete(key);
|
|
5047
|
+
});
|
|
5048
|
+
tr.setAttrs({ listening: false });
|
|
5049
|
+
handleClickOrTap(ctx, e);
|
|
5050
|
+
}
|
|
5025
5051
|
return;
|
|
5026
5052
|
}
|
|
5027
5053
|
const isStage = e.target instanceof Konva.Stage;
|
|
@@ -5103,6 +5129,7 @@ function handlePointerUp(ctx, e) {
|
|
|
5103
5129
|
ctx.getGesture().checkDoubleTap(e.evt.clientX, e.evt.clientY);
|
|
5104
5130
|
ctx.unregisterPointer(e.evt.pointerId);
|
|
5105
5131
|
ctx.getGesture().commitTap();
|
|
5132
|
+
ctx.clearArmedDrag();
|
|
5106
5133
|
if (stage.mode() !== WEAVE_STAGE_DEFAULT_MODE) return;
|
|
5107
5134
|
const contextMenuPlugin = ctx.getContextMenuPlugin();
|
|
5108
5135
|
if (!ctx.isInitialized()) {
|
|
@@ -5193,6 +5220,35 @@ function handlePointerUp(ctx, e) {
|
|
|
5193
5220
|
ctx.triggerSelectedNodesEvent();
|
|
5194
5221
|
}
|
|
5195
5222
|
|
|
5223
|
+
//#endregion
|
|
5224
|
+
//#region src/plugins/nodes-selection/events/armed-drag.ts
|
|
5225
|
+
/**
|
|
5226
|
+
* Handles the stage `pointermove` for single-gesture select+drag. When a node
|
|
5227
|
+
* has been "armed" by a fresh single-selection click (see click-tap.ts), this
|
|
5228
|
+
* starts the drag on the same gesture as soon as the pointer moves past the
|
|
5229
|
+
* move threshold, so the user does not need a second press to begin moving.
|
|
5230
|
+
*
|
|
5231
|
+
* A plain click (no movement) never reaches the threshold, so it only selects.
|
|
5232
|
+
* Uses the public Konva `startDrag` API — the node's own `dragstart` handler
|
|
5233
|
+
* and the transformer's drag proxy take over from there.
|
|
5234
|
+
*
|
|
5235
|
+
* Wired un-throttled (separate from the throttled selection pointermove) to
|
|
5236
|
+
* keep drag initiation responsive.
|
|
5237
|
+
*/
|
|
5238
|
+
function handleArmedDrag(ctx, e) {
|
|
5239
|
+
const node = ctx.getArmedDragNode();
|
|
5240
|
+
if (!node || !e?.evt) return;
|
|
5241
|
+
if (e.evt.buttons === 0) {
|
|
5242
|
+
ctx.clearArmedDrag();
|
|
5243
|
+
return;
|
|
5244
|
+
}
|
|
5245
|
+
if (e.evt.pointerId !== ctx.getArmedDragPointerId()) return;
|
|
5246
|
+
if (!ctx.getGesture().checkMoved(e.evt.clientX, e.evt.clientY)) return;
|
|
5247
|
+
if (node.isDragging()) return;
|
|
5248
|
+
ctx.clearArmedDrag();
|
|
5249
|
+
node.startDrag({ evt: e.evt });
|
|
5250
|
+
}
|
|
5251
|
+
|
|
5196
5252
|
//#endregion
|
|
5197
5253
|
//#region src/plugins/nodes-selection/nodes-selection.ts
|
|
5198
5254
|
var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
@@ -5200,6 +5256,8 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
5200
5256
|
_handledClickOrTap = false;
|
|
5201
5257
|
dragSelectedNodes = [];
|
|
5202
5258
|
_activeGroupContext = null;
|
|
5259
|
+
_armedDragNode = null;
|
|
5260
|
+
_armedDragPointerId = null;
|
|
5203
5261
|
onRender = void 0;
|
|
5204
5262
|
constructor(params) {
|
|
5205
5263
|
super();
|
|
@@ -5227,6 +5285,8 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
5227
5285
|
this.dragSelectedNodes = [];
|
|
5228
5286
|
this._handledClickOrTap = false;
|
|
5229
5287
|
this._activeGroupContext = null;
|
|
5288
|
+
this._armedDragNode = null;
|
|
5289
|
+
this._armedDragPointerId = null;
|
|
5230
5290
|
}
|
|
5231
5291
|
getName() {
|
|
5232
5292
|
return WEAVE_NODES_SELECTION_KEY;
|
|
@@ -5285,6 +5345,20 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
5285
5345
|
setAreaSelecting(val) {
|
|
5286
5346
|
this.selecting = val;
|
|
5287
5347
|
}
|
|
5348
|
+
armDrag(node, pointerId) {
|
|
5349
|
+
this._armedDragNode = node;
|
|
5350
|
+
this._armedDragPointerId = pointerId;
|
|
5351
|
+
}
|
|
5352
|
+
getArmedDragNode() {
|
|
5353
|
+
return this._armedDragNode;
|
|
5354
|
+
}
|
|
5355
|
+
getArmedDragPointerId() {
|
|
5356
|
+
return this._armedDragPointerId;
|
|
5357
|
+
}
|
|
5358
|
+
clearArmedDrag() {
|
|
5359
|
+
this._armedDragNode = null;
|
|
5360
|
+
this._armedDragPointerId = null;
|
|
5361
|
+
}
|
|
5288
5362
|
initLayer() {
|
|
5289
5363
|
const stage = this.instance.getStage();
|
|
5290
5364
|
const layer = new Konva.Layer({ id: this.getLayerName() });
|
|
@@ -5427,6 +5501,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
5427
5501
|
registerKeyboardHandlers(this);
|
|
5428
5502
|
stage.on("pointerdown", (e) => handlePointerDown(this, e));
|
|
5429
5503
|
stage.on("pointermove", (0, import_throttle.default)((e) => handlePointerMove(this, e), DEFAULT_THROTTLE_MS));
|
|
5504
|
+
stage.on("pointermove", (e) => handleArmedDrag(this, e));
|
|
5430
5505
|
stage.on("pointerup", (e) => handlePointerUp(this, e));
|
|
5431
5506
|
this.instance.addEventListener("onStateChange", () => {
|
|
5432
5507
|
requestAnimationFrame(() => {
|
|
@@ -5507,6 +5582,8 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
5507
5582
|
}
|
|
5508
5583
|
setSelectedNodes(nodes) {
|
|
5509
5584
|
const tr = this.transformerCtrl.getTransformer();
|
|
5585
|
+
const previousNodes = tr.getNodes();
|
|
5586
|
+
for (const previousNode of previousNodes) if (!nodes.includes(previousNode) && typeof previousNode.draggable === "function") previousNode.draggable(false);
|
|
5510
5587
|
tr.setNodes(nodes);
|
|
5511
5588
|
this.handleBehaviors();
|
|
5512
5589
|
if (nodes.length === 0) this.getNodesSelectionFeedbackPlugin()?.cleanupSelectedHalos();
|
|
@@ -6461,7 +6538,7 @@ var WeaveNode = class {
|
|
|
6461
6538
|
if (e.evt?.button === 1) isWheelMousePressed = true;
|
|
6462
6539
|
this.getNodesSelectionFeedbackPlugin()?.hideSelectionHalo(nodeTarget);
|
|
6463
6540
|
const canMove = typeof nodeTarget?.canDrag === "function" ? nodeTarget.canDrag() : false;
|
|
6464
|
-
if (!canMove) {
|
|
6541
|
+
if (!canMove || !this.isSelecting()) {
|
|
6465
6542
|
nodeTarget.stopDrag();
|
|
6466
6543
|
return;
|
|
6467
6544
|
}
|
|
@@ -9701,7 +9778,7 @@ var WeaveRegisterManager = class {
|
|
|
9701
9778
|
|
|
9702
9779
|
//#endregion
|
|
9703
9780
|
//#region package.json
|
|
9704
|
-
var version = "5.1.
|
|
9781
|
+
var version = "5.1.3";
|
|
9705
9782
|
|
|
9706
9783
|
//#endregion
|
|
9707
9784
|
//#region src/managers/setup.ts
|
|
@@ -13710,6 +13787,8 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
13710
13787
|
this.textAreaContainer = null;
|
|
13711
13788
|
this.textArea = null;
|
|
13712
13789
|
this.editing = false;
|
|
13790
|
+
this.editingNodeId = null;
|
|
13791
|
+
this.nodeRenderedAddedRegistered = false;
|
|
13713
13792
|
this.textArea = null;
|
|
13714
13793
|
}
|
|
13715
13794
|
updateNode(nodeInstance) {
|
|
@@ -13725,9 +13804,9 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
13725
13804
|
this.instance.addNode(serializedNode, actualContainer?.getAttrs().id);
|
|
13726
13805
|
} else if (this.createNode && actNode.getAttrs().text === "") actNode.destroy();
|
|
13727
13806
|
else this.instance.updateNode(this.serialize(clonedText));
|
|
13728
|
-
this.createNode = false;
|
|
13729
13807
|
clonedText.destroy();
|
|
13730
13808
|
}
|
|
13809
|
+
this.createNode = false;
|
|
13731
13810
|
}
|
|
13732
13811
|
handleKeyPress = (e) => {
|
|
13733
13812
|
if (e.code === "Enter" && this.instance.getActiveAction() === SELECTION_TOOL_ACTION_NAME && !this.editing && e.target !== this.textArea) {
|
|
@@ -13897,9 +13976,12 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
13897
13976
|
text.on("transformend", () => {
|
|
13898
13977
|
handleTransformEnd();
|
|
13899
13978
|
});
|
|
13900
|
-
this.
|
|
13901
|
-
|
|
13902
|
-
|
|
13979
|
+
if (!this.nodeRenderedAddedRegistered) {
|
|
13980
|
+
this.instance.addEventListener("onNodeRenderedAdded", (node) => {
|
|
13981
|
+
if (this.editing && this.editingNodeId !== null && node.id() === this.editingNodeId && node.getAttr("cancelEditMode")) node.getAttr("cancelEditMode")?.();
|
|
13982
|
+
});
|
|
13983
|
+
this.nodeRenderedAddedRegistered = true;
|
|
13984
|
+
}
|
|
13903
13985
|
if (!this.instance.isServerSide() && !this.keyPressHandler) {
|
|
13904
13986
|
this.keyPressHandler = this.handleKeyPress.bind(this);
|
|
13905
13987
|
window.addEventListener("keypress", this.keyPressHandler, { signal: this.instance.getEventsController().signal });
|
|
@@ -13935,7 +14017,7 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
13935
14017
|
width,
|
|
13936
14018
|
height
|
|
13937
14019
|
});
|
|
13938
|
-
if (this.editing) this.updateTextAreaDOM(nodeInstance);
|
|
14020
|
+
if (this.editing && this.editingNodeId === nodeInstance.id()) this.updateTextAreaDOM(nodeInstance);
|
|
13939
14021
|
if (!this.editing) {
|
|
13940
14022
|
const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
13941
14023
|
if (nodesSelectionPlugin) {
|
|
@@ -14279,27 +14361,29 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
14279
14361
|
this.instance.disablePlugin("nodesSelection");
|
|
14280
14362
|
tr.hide();
|
|
14281
14363
|
}
|
|
14282
|
-
if (this.editing) textNode.visible(false);
|
|
14364
|
+
if (this.editing && this.editingNodeId === textNode.id()) textNode.visible(false);
|
|
14283
14365
|
else textNode.visible(true);
|
|
14284
14366
|
}
|
|
14285
14367
|
removeTextAreaDOM(textNode) {
|
|
14286
14368
|
this.instance.releaseMutexLock();
|
|
14287
14369
|
this.instance.getStage().mode(WEAVE_STAGE_DEFAULT_MODE);
|
|
14288
14370
|
this.editing = false;
|
|
14371
|
+
this.editingNodeId = null;
|
|
14289
14372
|
const stage = this.instance.getStage();
|
|
14290
14373
|
if (this.textAreaSuperContainer) this.textAreaSuperContainer.remove();
|
|
14291
14374
|
textNode.visible(true);
|
|
14292
14375
|
this.updateNode(textNode);
|
|
14376
|
+
const liveNode = stage.findOne(`#${textNode.id()}`) ?? textNode;
|
|
14293
14377
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
14294
14378
|
if (selectionPlugin) {
|
|
14295
14379
|
this.instance.enablePlugin("nodesSelection");
|
|
14296
|
-
selectionPlugin.setSelectedNodes([
|
|
14380
|
+
selectionPlugin.setSelectedNodes([liveNode]);
|
|
14297
14381
|
this.instance.triggerAction(SELECTION_TOOL_ACTION_NAME);
|
|
14298
14382
|
}
|
|
14299
14383
|
stage.container().tabIndex = 1;
|
|
14300
14384
|
stage.container().click();
|
|
14301
14385
|
stage.container().focus();
|
|
14302
|
-
this.instance.emitEvent("onExitTextNodeEditMode", { node:
|
|
14386
|
+
this.instance.emitEvent("onExitTextNodeEditMode", { node: liveNode });
|
|
14303
14387
|
}
|
|
14304
14388
|
triggerEditMode(textNode, create = false) {
|
|
14305
14389
|
if (create) this.createNode = true;
|
|
@@ -14309,6 +14393,7 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
14309
14393
|
});
|
|
14310
14394
|
if (!lockAcquired) return;
|
|
14311
14395
|
this.editing = true;
|
|
14396
|
+
this.editingNodeId = textNode.id();
|
|
14312
14397
|
textNode.visible(false);
|
|
14313
14398
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
14314
14399
|
if (selectionPlugin) {
|
|
@@ -24787,14 +24872,18 @@ var WeaveTextToolAction = class extends WeaveAction {
|
|
|
24787
24872
|
cleanup() {
|
|
24788
24873
|
const stage = this.instance.getStage();
|
|
24789
24874
|
stage.container().style.cursor = "default";
|
|
24790
|
-
const
|
|
24791
|
-
|
|
24792
|
-
|
|
24793
|
-
|
|
24794
|
-
|
|
24875
|
+
const placedId = this.textId;
|
|
24876
|
+
const justAdded = this.state === TEXT_TOOL_STATE.FINISHED && !!placedId;
|
|
24877
|
+
if (justAdded) {
|
|
24878
|
+
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
24879
|
+
if (selectionPlugin) {
|
|
24880
|
+
const node = stage.findOne(`#${placedId}`);
|
|
24881
|
+
if (node) selectionPlugin.setSelectedNodes([node]);
|
|
24882
|
+
this.instance.triggerAction(SELECTION_TOOL_ACTION_NAME);
|
|
24883
|
+
}
|
|
24884
|
+
const textGroup = stage.findOne(`#${placedId}`);
|
|
24885
|
+
if (textGroup) textGroup.getAttr("triggerEditMode")?.(textGroup, true);
|
|
24795
24886
|
}
|
|
24796
|
-
const textGroup = stage.findOne(`#${this.textId}`);
|
|
24797
|
-
if (textGroup) textGroup.getAttr("triggerEditMode")(textGroup, true);
|
|
24798
24887
|
this.initialCursor = null;
|
|
24799
24888
|
this.textId = null;
|
|
24800
24889
|
this.container = void 0;
|
package/dist/sdk.node.js
CHANGED
|
@@ -4912,6 +4912,12 @@ function handleClickOrTap(ctx, e) {
|
|
|
4912
4912
|
tr.nodes([nodeTargeted]);
|
|
4913
4913
|
tr.show();
|
|
4914
4914
|
areNodesSelected = true;
|
|
4915
|
+
const canMove = typeof nodeTargeted.canDrag === "function" ? nodeTargeted.canDrag() : false;
|
|
4916
|
+
if (canMove && e.evt) {
|
|
4917
|
+
nodeTargeted.draggable(true);
|
|
4918
|
+
ctx.armDrag(nodeTargeted, e.evt.pointerId);
|
|
4919
|
+
return;
|
|
4920
|
+
}
|
|
4915
4921
|
}
|
|
4916
4922
|
if (metaPressed && isSelected) {
|
|
4917
4923
|
const nodes = tr.nodes().slice();
|
|
@@ -5009,6 +5015,7 @@ function handlePointerDown(ctx, e) {
|
|
|
5009
5015
|
if (e.target.getClassName().includes("custom-snap-guide")) return;
|
|
5010
5016
|
ctx.setClickOrTapHandled(false);
|
|
5011
5017
|
ctx.registerPointer(e.evt.pointerId, e.evt);
|
|
5018
|
+
ctx.clearArmedDrag();
|
|
5012
5019
|
if (e.evt.pointerType === "touch" && ctx.getPointerCount() > 1) return;
|
|
5013
5020
|
if (e.evt.pointerType === "mouse" && e.evt?.button !== 0) return;
|
|
5014
5021
|
if (e.evt.pointerType === "pen" && e.evt?.pressure <= .05) return;
|
|
@@ -5021,6 +5028,25 @@ function handlePointerDown(ctx, e) {
|
|
|
5021
5028
|
ctx.setAreaSelecting(false);
|
|
5022
5029
|
ctx.getEdgePanning().stop();
|
|
5023
5030
|
ctx.getAreaSelector().hide();
|
|
5031
|
+
const weave = ctx.getWeaveInstance();
|
|
5032
|
+
const realNode = weave.getRealSelectedNode(selectedGroup);
|
|
5033
|
+
const tr = ctx.getTransformerController().getTransformer();
|
|
5034
|
+
const selectedIds = new Set(tr.nodes().map((node) => node.getAttrs().id));
|
|
5035
|
+
let isWithinSelection = false;
|
|
5036
|
+
for (let cur = realNode; cur; cur = cur.getParent()) {
|
|
5037
|
+
if (typeof cur.getAttrs !== "function") break;
|
|
5038
|
+
if (selectedIds.has(cur.getAttrs().id)) {
|
|
5039
|
+
isWithinSelection = true;
|
|
5040
|
+
break;
|
|
5041
|
+
}
|
|
5042
|
+
}
|
|
5043
|
+
if (!isWithinSelection && realNode.getAttrs().nodeType) {
|
|
5044
|
+
Konva.DD._dragElements.forEach((elem, key) => {
|
|
5045
|
+
if (elem.dragStatus === "ready") Konva.DD._dragElements.delete(key);
|
|
5046
|
+
});
|
|
5047
|
+
tr.setAttrs({ listening: false });
|
|
5048
|
+
handleClickOrTap(ctx, e);
|
|
5049
|
+
}
|
|
5024
5050
|
return;
|
|
5025
5051
|
}
|
|
5026
5052
|
const isStage = e.target instanceof Konva.Stage;
|
|
@@ -5102,6 +5128,7 @@ function handlePointerUp(ctx, e) {
|
|
|
5102
5128
|
ctx.getGesture().checkDoubleTap(e.evt.clientX, e.evt.clientY);
|
|
5103
5129
|
ctx.unregisterPointer(e.evt.pointerId);
|
|
5104
5130
|
ctx.getGesture().commitTap();
|
|
5131
|
+
ctx.clearArmedDrag();
|
|
5105
5132
|
if (stage.mode() !== WEAVE_STAGE_DEFAULT_MODE) return;
|
|
5106
5133
|
const contextMenuPlugin = ctx.getContextMenuPlugin();
|
|
5107
5134
|
if (!ctx.isInitialized()) {
|
|
@@ -5192,6 +5219,35 @@ function handlePointerUp(ctx, e) {
|
|
|
5192
5219
|
ctx.triggerSelectedNodesEvent();
|
|
5193
5220
|
}
|
|
5194
5221
|
|
|
5222
|
+
//#endregion
|
|
5223
|
+
//#region src/plugins/nodes-selection/events/armed-drag.ts
|
|
5224
|
+
/**
|
|
5225
|
+
* Handles the stage `pointermove` for single-gesture select+drag. When a node
|
|
5226
|
+
* has been "armed" by a fresh single-selection click (see click-tap.ts), this
|
|
5227
|
+
* starts the drag on the same gesture as soon as the pointer moves past the
|
|
5228
|
+
* move threshold, so the user does not need a second press to begin moving.
|
|
5229
|
+
*
|
|
5230
|
+
* A plain click (no movement) never reaches the threshold, so it only selects.
|
|
5231
|
+
* Uses the public Konva `startDrag` API — the node's own `dragstart` handler
|
|
5232
|
+
* and the transformer's drag proxy take over from there.
|
|
5233
|
+
*
|
|
5234
|
+
* Wired un-throttled (separate from the throttled selection pointermove) to
|
|
5235
|
+
* keep drag initiation responsive.
|
|
5236
|
+
*/
|
|
5237
|
+
function handleArmedDrag(ctx, e) {
|
|
5238
|
+
const node = ctx.getArmedDragNode();
|
|
5239
|
+
if (!node || !e?.evt) return;
|
|
5240
|
+
if (e.evt.buttons === 0) {
|
|
5241
|
+
ctx.clearArmedDrag();
|
|
5242
|
+
return;
|
|
5243
|
+
}
|
|
5244
|
+
if (e.evt.pointerId !== ctx.getArmedDragPointerId()) return;
|
|
5245
|
+
if (!ctx.getGesture().checkMoved(e.evt.clientX, e.evt.clientY)) return;
|
|
5246
|
+
if (node.isDragging()) return;
|
|
5247
|
+
ctx.clearArmedDrag();
|
|
5248
|
+
node.startDrag({ evt: e.evt });
|
|
5249
|
+
}
|
|
5250
|
+
|
|
5195
5251
|
//#endregion
|
|
5196
5252
|
//#region src/plugins/nodes-selection/nodes-selection.ts
|
|
5197
5253
|
var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
@@ -5199,6 +5255,8 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
5199
5255
|
_handledClickOrTap = false;
|
|
5200
5256
|
dragSelectedNodes = [];
|
|
5201
5257
|
_activeGroupContext = null;
|
|
5258
|
+
_armedDragNode = null;
|
|
5259
|
+
_armedDragPointerId = null;
|
|
5202
5260
|
onRender = void 0;
|
|
5203
5261
|
constructor(params) {
|
|
5204
5262
|
super();
|
|
@@ -5226,6 +5284,8 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
5226
5284
|
this.dragSelectedNodes = [];
|
|
5227
5285
|
this._handledClickOrTap = false;
|
|
5228
5286
|
this._activeGroupContext = null;
|
|
5287
|
+
this._armedDragNode = null;
|
|
5288
|
+
this._armedDragPointerId = null;
|
|
5229
5289
|
}
|
|
5230
5290
|
getName() {
|
|
5231
5291
|
return WEAVE_NODES_SELECTION_KEY;
|
|
@@ -5284,6 +5344,20 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
5284
5344
|
setAreaSelecting(val) {
|
|
5285
5345
|
this.selecting = val;
|
|
5286
5346
|
}
|
|
5347
|
+
armDrag(node, pointerId) {
|
|
5348
|
+
this._armedDragNode = node;
|
|
5349
|
+
this._armedDragPointerId = pointerId;
|
|
5350
|
+
}
|
|
5351
|
+
getArmedDragNode() {
|
|
5352
|
+
return this._armedDragNode;
|
|
5353
|
+
}
|
|
5354
|
+
getArmedDragPointerId() {
|
|
5355
|
+
return this._armedDragPointerId;
|
|
5356
|
+
}
|
|
5357
|
+
clearArmedDrag() {
|
|
5358
|
+
this._armedDragNode = null;
|
|
5359
|
+
this._armedDragPointerId = null;
|
|
5360
|
+
}
|
|
5287
5361
|
initLayer() {
|
|
5288
5362
|
const stage = this.instance.getStage();
|
|
5289
5363
|
const layer = new Konva.Layer({ id: this.getLayerName() });
|
|
@@ -5426,6 +5500,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
5426
5500
|
registerKeyboardHandlers(this);
|
|
5427
5501
|
stage.on("pointerdown", (e) => handlePointerDown(this, e));
|
|
5428
5502
|
stage.on("pointermove", (0, import_throttle.default)((e) => handlePointerMove(this, e), DEFAULT_THROTTLE_MS));
|
|
5503
|
+
stage.on("pointermove", (e) => handleArmedDrag(this, e));
|
|
5429
5504
|
stage.on("pointerup", (e) => handlePointerUp(this, e));
|
|
5430
5505
|
this.instance.addEventListener("onStateChange", () => {
|
|
5431
5506
|
requestAnimationFrame(() => {
|
|
@@ -5506,6 +5581,8 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
5506
5581
|
}
|
|
5507
5582
|
setSelectedNodes(nodes) {
|
|
5508
5583
|
const tr = this.transformerCtrl.getTransformer();
|
|
5584
|
+
const previousNodes = tr.getNodes();
|
|
5585
|
+
for (const previousNode of previousNodes) if (!nodes.includes(previousNode) && typeof previousNode.draggable === "function") previousNode.draggable(false);
|
|
5509
5586
|
tr.setNodes(nodes);
|
|
5510
5587
|
this.handleBehaviors();
|
|
5511
5588
|
if (nodes.length === 0) this.getNodesSelectionFeedbackPlugin()?.cleanupSelectedHalos();
|
|
@@ -6460,7 +6537,7 @@ var WeaveNode = class {
|
|
|
6460
6537
|
if (e.evt?.button === 1) isWheelMousePressed = true;
|
|
6461
6538
|
this.getNodesSelectionFeedbackPlugin()?.hideSelectionHalo(nodeTarget);
|
|
6462
6539
|
const canMove = typeof nodeTarget?.canDrag === "function" ? nodeTarget.canDrag() : false;
|
|
6463
|
-
if (!canMove) {
|
|
6540
|
+
if (!canMove || !this.isSelecting()) {
|
|
6464
6541
|
nodeTarget.stopDrag();
|
|
6465
6542
|
return;
|
|
6466
6543
|
}
|
|
@@ -9700,7 +9777,7 @@ var WeaveRegisterManager = class {
|
|
|
9700
9777
|
|
|
9701
9778
|
//#endregion
|
|
9702
9779
|
//#region package.json
|
|
9703
|
-
var version = "5.1.
|
|
9780
|
+
var version = "5.1.3";
|
|
9704
9781
|
|
|
9705
9782
|
//#endregion
|
|
9706
9783
|
//#region src/managers/setup.ts
|
|
@@ -13709,6 +13786,8 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
13709
13786
|
this.textAreaContainer = null;
|
|
13710
13787
|
this.textArea = null;
|
|
13711
13788
|
this.editing = false;
|
|
13789
|
+
this.editingNodeId = null;
|
|
13790
|
+
this.nodeRenderedAddedRegistered = false;
|
|
13712
13791
|
this.textArea = null;
|
|
13713
13792
|
}
|
|
13714
13793
|
updateNode(nodeInstance) {
|
|
@@ -13724,9 +13803,9 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
13724
13803
|
this.instance.addNode(serializedNode, actualContainer?.getAttrs().id);
|
|
13725
13804
|
} else if (this.createNode && actNode.getAttrs().text === "") actNode.destroy();
|
|
13726
13805
|
else this.instance.updateNode(this.serialize(clonedText));
|
|
13727
|
-
this.createNode = false;
|
|
13728
13806
|
clonedText.destroy();
|
|
13729
13807
|
}
|
|
13808
|
+
this.createNode = false;
|
|
13730
13809
|
}
|
|
13731
13810
|
handleKeyPress = (e) => {
|
|
13732
13811
|
if (e.code === "Enter" && this.instance.getActiveAction() === SELECTION_TOOL_ACTION_NAME && !this.editing && e.target !== this.textArea) {
|
|
@@ -13896,9 +13975,12 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
13896
13975
|
text.on("transformend", () => {
|
|
13897
13976
|
handleTransformEnd();
|
|
13898
13977
|
});
|
|
13899
|
-
this.
|
|
13900
|
-
|
|
13901
|
-
|
|
13978
|
+
if (!this.nodeRenderedAddedRegistered) {
|
|
13979
|
+
this.instance.addEventListener("onNodeRenderedAdded", (node) => {
|
|
13980
|
+
if (this.editing && this.editingNodeId !== null && node.id() === this.editingNodeId && node.getAttr("cancelEditMode")) node.getAttr("cancelEditMode")?.();
|
|
13981
|
+
});
|
|
13982
|
+
this.nodeRenderedAddedRegistered = true;
|
|
13983
|
+
}
|
|
13902
13984
|
if (!this.instance.isServerSide() && !this.keyPressHandler) {
|
|
13903
13985
|
this.keyPressHandler = this.handleKeyPress.bind(this);
|
|
13904
13986
|
window.addEventListener("keypress", this.keyPressHandler, { signal: this.instance.getEventsController().signal });
|
|
@@ -13934,7 +14016,7 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
13934
14016
|
width,
|
|
13935
14017
|
height
|
|
13936
14018
|
});
|
|
13937
|
-
if (this.editing) this.updateTextAreaDOM(nodeInstance);
|
|
14019
|
+
if (this.editing && this.editingNodeId === nodeInstance.id()) this.updateTextAreaDOM(nodeInstance);
|
|
13938
14020
|
if (!this.editing) {
|
|
13939
14021
|
const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
13940
14022
|
if (nodesSelectionPlugin) {
|
|
@@ -14278,27 +14360,29 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
14278
14360
|
this.instance.disablePlugin("nodesSelection");
|
|
14279
14361
|
tr.hide();
|
|
14280
14362
|
}
|
|
14281
|
-
if (this.editing) textNode.visible(false);
|
|
14363
|
+
if (this.editing && this.editingNodeId === textNode.id()) textNode.visible(false);
|
|
14282
14364
|
else textNode.visible(true);
|
|
14283
14365
|
}
|
|
14284
14366
|
removeTextAreaDOM(textNode) {
|
|
14285
14367
|
this.instance.releaseMutexLock();
|
|
14286
14368
|
this.instance.getStage().mode(WEAVE_STAGE_DEFAULT_MODE);
|
|
14287
14369
|
this.editing = false;
|
|
14370
|
+
this.editingNodeId = null;
|
|
14288
14371
|
const stage = this.instance.getStage();
|
|
14289
14372
|
if (this.textAreaSuperContainer) this.textAreaSuperContainer.remove();
|
|
14290
14373
|
textNode.visible(true);
|
|
14291
14374
|
this.updateNode(textNode);
|
|
14375
|
+
const liveNode = stage.findOne(`#${textNode.id()}`) ?? textNode;
|
|
14292
14376
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
14293
14377
|
if (selectionPlugin) {
|
|
14294
14378
|
this.instance.enablePlugin("nodesSelection");
|
|
14295
|
-
selectionPlugin.setSelectedNodes([
|
|
14379
|
+
selectionPlugin.setSelectedNodes([liveNode]);
|
|
14296
14380
|
this.instance.triggerAction(SELECTION_TOOL_ACTION_NAME);
|
|
14297
14381
|
}
|
|
14298
14382
|
stage.container().tabIndex = 1;
|
|
14299
14383
|
stage.container().click();
|
|
14300
14384
|
stage.container().focus();
|
|
14301
|
-
this.instance.emitEvent("onExitTextNodeEditMode", { node:
|
|
14385
|
+
this.instance.emitEvent("onExitTextNodeEditMode", { node: liveNode });
|
|
14302
14386
|
}
|
|
14303
14387
|
triggerEditMode(textNode, create = false) {
|
|
14304
14388
|
if (create) this.createNode = true;
|
|
@@ -14308,6 +14392,7 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
14308
14392
|
});
|
|
14309
14393
|
if (!lockAcquired) return;
|
|
14310
14394
|
this.editing = true;
|
|
14395
|
+
this.editingNodeId = textNode.id();
|
|
14311
14396
|
textNode.visible(false);
|
|
14312
14397
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
14313
14398
|
if (selectionPlugin) {
|
|
@@ -24786,14 +24871,18 @@ var WeaveTextToolAction = class extends WeaveAction {
|
|
|
24786
24871
|
cleanup() {
|
|
24787
24872
|
const stage = this.instance.getStage();
|
|
24788
24873
|
stage.container().style.cursor = "default";
|
|
24789
|
-
const
|
|
24790
|
-
|
|
24791
|
-
|
|
24792
|
-
|
|
24793
|
-
|
|
24874
|
+
const placedId = this.textId;
|
|
24875
|
+
const justAdded = this.state === TEXT_TOOL_STATE.FINISHED && !!placedId;
|
|
24876
|
+
if (justAdded) {
|
|
24877
|
+
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
24878
|
+
if (selectionPlugin) {
|
|
24879
|
+
const node = stage.findOne(`#${placedId}`);
|
|
24880
|
+
if (node) selectionPlugin.setSelectedNodes([node]);
|
|
24881
|
+
this.instance.triggerAction(SELECTION_TOOL_ACTION_NAME);
|
|
24882
|
+
}
|
|
24883
|
+
const textGroup = stage.findOne(`#${placedId}`);
|
|
24884
|
+
if (textGroup) textGroup.getAttr("triggerEditMode")?.(textGroup, true);
|
|
24794
24885
|
}
|
|
24795
|
-
const textGroup = stage.findOne(`#${this.textId}`);
|
|
24796
|
-
if (textGroup) textGroup.getAttr("triggerEditMode")(textGroup, true);
|
|
24797
24886
|
this.initialCursor = null;
|
|
24798
24887
|
this.textId = null;
|
|
24799
24888
|
this.container = void 0;
|