@inditextech/weave-sdk 5.1.1 → 5.1.2

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 CHANGED
@@ -4913,6 +4913,11 @@ 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
+ }
4916
4921
  }
4917
4922
  if (metaPressed && isSelected) {
4918
4923
  const nodes = tr.nodes().slice();
@@ -5010,6 +5015,7 @@ function handlePointerDown(ctx, e) {
5010
5015
  if (e.target.getClassName().includes("custom-snap-guide")) return;
5011
5016
  ctx.setClickOrTapHandled(false);
5012
5017
  ctx.registerPointer(e.evt.pointerId, e.evt);
5018
+ ctx.clearArmedDrag();
5013
5019
  if (e.evt.pointerType === "touch" && ctx.getPointerCount() > 1) return;
5014
5020
  if (e.evt.pointerType === "mouse" && e.evt?.button !== 0) return;
5015
5021
  if (e.evt.pointerType === "pen" && e.evt?.pressure <= .05) return;
@@ -5103,6 +5109,7 @@ function handlePointerUp(ctx, e) {
5103
5109
  ctx.getGesture().checkDoubleTap(e.evt.clientX, e.evt.clientY);
5104
5110
  ctx.unregisterPointer(e.evt.pointerId);
5105
5111
  ctx.getGesture().commitTap();
5112
+ ctx.clearArmedDrag();
5106
5113
  if (stage.mode() !== WEAVE_STAGE_DEFAULT_MODE) return;
5107
5114
  const contextMenuPlugin = ctx.getContextMenuPlugin();
5108
5115
  if (!ctx.isInitialized()) {
@@ -5193,6 +5200,35 @@ function handlePointerUp(ctx, e) {
5193
5200
  ctx.triggerSelectedNodesEvent();
5194
5201
  }
5195
5202
 
5203
+ //#endregion
5204
+ //#region src/plugins/nodes-selection/events/armed-drag.ts
5205
+ /**
5206
+ * Handles the stage `pointermove` for single-gesture select+drag. When a node
5207
+ * has been "armed" by a fresh single-selection click (see click-tap.ts), this
5208
+ * starts the drag on the same gesture as soon as the pointer moves past the
5209
+ * move threshold, so the user does not need a second press to begin moving.
5210
+ *
5211
+ * A plain click (no movement) never reaches the threshold, so it only selects.
5212
+ * Uses the public Konva `startDrag` API — the node's own `dragstart` handler
5213
+ * and the transformer's drag proxy take over from there.
5214
+ *
5215
+ * Wired un-throttled (separate from the throttled selection pointermove) to
5216
+ * keep drag initiation responsive.
5217
+ */
5218
+ function handleArmedDrag(ctx, e) {
5219
+ const node = ctx.getArmedDragNode();
5220
+ if (!node || !e?.evt) return;
5221
+ if (e.evt.buttons === 0) {
5222
+ ctx.clearArmedDrag();
5223
+ return;
5224
+ }
5225
+ if (e.evt.pointerId !== ctx.getArmedDragPointerId()) return;
5226
+ if (!ctx.getGesture().checkMoved(e.evt.clientX, e.evt.clientY)) return;
5227
+ if (node.isDragging()) return;
5228
+ ctx.clearArmedDrag();
5229
+ node.startDrag(e.evt);
5230
+ }
5231
+
5196
5232
  //#endregion
5197
5233
  //#region src/plugins/nodes-selection/nodes-selection.ts
5198
5234
  var WeaveNodesSelectionPlugin = class extends WeavePlugin {
@@ -5200,6 +5236,8 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
5200
5236
  _handledClickOrTap = false;
5201
5237
  dragSelectedNodes = [];
5202
5238
  _activeGroupContext = null;
5239
+ _armedDragNode = null;
5240
+ _armedDragPointerId = null;
5203
5241
  onRender = void 0;
5204
5242
  constructor(params) {
5205
5243
  super();
@@ -5227,6 +5265,8 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
5227
5265
  this.dragSelectedNodes = [];
5228
5266
  this._handledClickOrTap = false;
5229
5267
  this._activeGroupContext = null;
5268
+ this._armedDragNode = null;
5269
+ this._armedDragPointerId = null;
5230
5270
  }
5231
5271
  getName() {
5232
5272
  return WEAVE_NODES_SELECTION_KEY;
@@ -5285,6 +5325,20 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
5285
5325
  setAreaSelecting(val) {
5286
5326
  this.selecting = val;
5287
5327
  }
5328
+ armDrag(node, pointerId) {
5329
+ this._armedDragNode = node;
5330
+ this._armedDragPointerId = pointerId;
5331
+ }
5332
+ getArmedDragNode() {
5333
+ return this._armedDragNode;
5334
+ }
5335
+ getArmedDragPointerId() {
5336
+ return this._armedDragPointerId;
5337
+ }
5338
+ clearArmedDrag() {
5339
+ this._armedDragNode = null;
5340
+ this._armedDragPointerId = null;
5341
+ }
5288
5342
  initLayer() {
5289
5343
  const stage = this.instance.getStage();
5290
5344
  const layer = new Konva.Layer({ id: this.getLayerName() });
@@ -5427,6 +5481,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
5427
5481
  registerKeyboardHandlers(this);
5428
5482
  stage.on("pointerdown", (e) => handlePointerDown(this, e));
5429
5483
  stage.on("pointermove", (0, import_throttle.default)((e) => handlePointerMove(this, e), DEFAULT_THROTTLE_MS));
5484
+ stage.on("pointermove", (e) => handleArmedDrag(this, e));
5430
5485
  stage.on("pointerup", (e) => handlePointerUp(this, e));
5431
5486
  this.instance.addEventListener("onStateChange", () => {
5432
5487
  requestAnimationFrame(() => {
@@ -9701,7 +9756,7 @@ var WeaveRegisterManager = class {
9701
9756
 
9702
9757
  //#endregion
9703
9758
  //#region package.json
9704
- var version = "5.1.1";
9759
+ var version = "5.1.2";
9705
9760
 
9706
9761
  //#endregion
9707
9762
  //#region src/managers/setup.ts
@@ -13710,6 +13765,8 @@ var WeaveTextNode = class extends WeaveNode {
13710
13765
  this.textAreaContainer = null;
13711
13766
  this.textArea = null;
13712
13767
  this.editing = false;
13768
+ this.editingNodeId = null;
13769
+ this.nodeRenderedAddedRegistered = false;
13713
13770
  this.textArea = null;
13714
13771
  }
13715
13772
  updateNode(nodeInstance) {
@@ -13725,9 +13782,9 @@ var WeaveTextNode = class extends WeaveNode {
13725
13782
  this.instance.addNode(serializedNode, actualContainer?.getAttrs().id);
13726
13783
  } else if (this.createNode && actNode.getAttrs().text === "") actNode.destroy();
13727
13784
  else this.instance.updateNode(this.serialize(clonedText));
13728
- this.createNode = false;
13729
13785
  clonedText.destroy();
13730
13786
  }
13787
+ this.createNode = false;
13731
13788
  }
13732
13789
  handleKeyPress = (e) => {
13733
13790
  if (e.code === "Enter" && this.instance.getActiveAction() === SELECTION_TOOL_ACTION_NAME && !this.editing && e.target !== this.textArea) {
@@ -13897,9 +13954,12 @@ var WeaveTextNode = class extends WeaveNode {
13897
13954
  text.on("transformend", () => {
13898
13955
  handleTransformEnd();
13899
13956
  });
13900
- this.instance.addEventListener("onNodeRenderedAdded", (node) => {
13901
- if (node.id() === text.id() && node.getParent() !== text.getParent() && this.editing) text.getAttr("cancelEditMode")?.();
13902
- });
13957
+ if (!this.nodeRenderedAddedRegistered) {
13958
+ this.instance.addEventListener("onNodeRenderedAdded", (node) => {
13959
+ if (this.editing && this.editingNodeId !== null && node.id() === this.editingNodeId && node.getAttr("cancelEditMode")) node.getAttr("cancelEditMode")?.();
13960
+ });
13961
+ this.nodeRenderedAddedRegistered = true;
13962
+ }
13903
13963
  if (!this.instance.isServerSide() && !this.keyPressHandler) {
13904
13964
  this.keyPressHandler = this.handleKeyPress.bind(this);
13905
13965
  window.addEventListener("keypress", this.keyPressHandler, { signal: this.instance.getEventsController().signal });
@@ -13935,7 +13995,7 @@ var WeaveTextNode = class extends WeaveNode {
13935
13995
  width,
13936
13996
  height
13937
13997
  });
13938
- if (this.editing) this.updateTextAreaDOM(nodeInstance);
13998
+ if (this.editing && this.editingNodeId === nodeInstance.id()) this.updateTextAreaDOM(nodeInstance);
13939
13999
  if (!this.editing) {
13940
14000
  const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
13941
14001
  if (nodesSelectionPlugin) {
@@ -14279,27 +14339,29 @@ var WeaveTextNode = class extends WeaveNode {
14279
14339
  this.instance.disablePlugin("nodesSelection");
14280
14340
  tr.hide();
14281
14341
  }
14282
- if (this.editing) textNode.visible(false);
14342
+ if (this.editing && this.editingNodeId === textNode.id()) textNode.visible(false);
14283
14343
  else textNode.visible(true);
14284
14344
  }
14285
14345
  removeTextAreaDOM(textNode) {
14286
14346
  this.instance.releaseMutexLock();
14287
14347
  this.instance.getStage().mode(WEAVE_STAGE_DEFAULT_MODE);
14288
14348
  this.editing = false;
14349
+ this.editingNodeId = null;
14289
14350
  const stage = this.instance.getStage();
14290
14351
  if (this.textAreaSuperContainer) this.textAreaSuperContainer.remove();
14291
14352
  textNode.visible(true);
14292
14353
  this.updateNode(textNode);
14354
+ const liveNode = stage.findOne(`#${textNode.id()}`) ?? textNode;
14293
14355
  const selectionPlugin = this.instance.getPlugin("nodesSelection");
14294
14356
  if (selectionPlugin) {
14295
14357
  this.instance.enablePlugin("nodesSelection");
14296
- selectionPlugin.setSelectedNodes([textNode]);
14358
+ selectionPlugin.setSelectedNodes([liveNode]);
14297
14359
  this.instance.triggerAction(SELECTION_TOOL_ACTION_NAME);
14298
14360
  }
14299
14361
  stage.container().tabIndex = 1;
14300
14362
  stage.container().click();
14301
14363
  stage.container().focus();
14302
- this.instance.emitEvent("onExitTextNodeEditMode", { node: textNode });
14364
+ this.instance.emitEvent("onExitTextNodeEditMode", { node: liveNode });
14303
14365
  }
14304
14366
  triggerEditMode(textNode, create = false) {
14305
14367
  if (create) this.createNode = true;
@@ -14309,6 +14371,7 @@ var WeaveTextNode = class extends WeaveNode {
14309
14371
  });
14310
14372
  if (!lockAcquired) return;
14311
14373
  this.editing = true;
14374
+ this.editingNodeId = textNode.id();
14312
14375
  textNode.visible(false);
14313
14376
  const selectionPlugin = this.instance.getPlugin("nodesSelection");
14314
14377
  if (selectionPlugin) {
@@ -24787,14 +24850,18 @@ var WeaveTextToolAction = class extends WeaveAction {
24787
24850
  cleanup() {
24788
24851
  const stage = this.instance.getStage();
24789
24852
  stage.container().style.cursor = "default";
24790
- const selectionPlugin = this.instance.getPlugin("nodesSelection");
24791
- if (selectionPlugin) {
24792
- const node = stage.findOne(`#${this.textId}`);
24793
- if (node) selectionPlugin.setSelectedNodes([node]);
24794
- this.instance.triggerAction(SELECTION_TOOL_ACTION_NAME);
24853
+ const placedId = this.textId;
24854
+ const justAdded = this.state === TEXT_TOOL_STATE.FINISHED && !!placedId;
24855
+ if (justAdded) {
24856
+ const selectionPlugin = this.instance.getPlugin("nodesSelection");
24857
+ if (selectionPlugin) {
24858
+ const node = stage.findOne(`#${placedId}`);
24859
+ if (node) selectionPlugin.setSelectedNodes([node]);
24860
+ this.instance.triggerAction(SELECTION_TOOL_ACTION_NAME);
24861
+ }
24862
+ const textGroup = stage.findOne(`#${placedId}`);
24863
+ if (textGroup) textGroup.getAttr("triggerEditMode")?.(textGroup, true);
24795
24864
  }
24796
- const textGroup = stage.findOne(`#${this.textId}`);
24797
- if (textGroup) textGroup.getAttr("triggerEditMode")(textGroup, true);
24798
24865
  this.initialCursor = null;
24799
24866
  this.textId = null;
24800
24867
  this.container = void 0;
package/dist/sdk.node.js CHANGED
@@ -4912,6 +4912,11 @@ 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
+ }
4915
4920
  }
4916
4921
  if (metaPressed && isSelected) {
4917
4922
  const nodes = tr.nodes().slice();
@@ -5009,6 +5014,7 @@ function handlePointerDown(ctx, e) {
5009
5014
  if (e.target.getClassName().includes("custom-snap-guide")) return;
5010
5015
  ctx.setClickOrTapHandled(false);
5011
5016
  ctx.registerPointer(e.evt.pointerId, e.evt);
5017
+ ctx.clearArmedDrag();
5012
5018
  if (e.evt.pointerType === "touch" && ctx.getPointerCount() > 1) return;
5013
5019
  if (e.evt.pointerType === "mouse" && e.evt?.button !== 0) return;
5014
5020
  if (e.evt.pointerType === "pen" && e.evt?.pressure <= .05) return;
@@ -5102,6 +5108,7 @@ function handlePointerUp(ctx, e) {
5102
5108
  ctx.getGesture().checkDoubleTap(e.evt.clientX, e.evt.clientY);
5103
5109
  ctx.unregisterPointer(e.evt.pointerId);
5104
5110
  ctx.getGesture().commitTap();
5111
+ ctx.clearArmedDrag();
5105
5112
  if (stage.mode() !== WEAVE_STAGE_DEFAULT_MODE) return;
5106
5113
  const contextMenuPlugin = ctx.getContextMenuPlugin();
5107
5114
  if (!ctx.isInitialized()) {
@@ -5192,6 +5199,35 @@ function handlePointerUp(ctx, e) {
5192
5199
  ctx.triggerSelectedNodesEvent();
5193
5200
  }
5194
5201
 
5202
+ //#endregion
5203
+ //#region src/plugins/nodes-selection/events/armed-drag.ts
5204
+ /**
5205
+ * Handles the stage `pointermove` for single-gesture select+drag. When a node
5206
+ * has been "armed" by a fresh single-selection click (see click-tap.ts), this
5207
+ * starts the drag on the same gesture as soon as the pointer moves past the
5208
+ * move threshold, so the user does not need a second press to begin moving.
5209
+ *
5210
+ * A plain click (no movement) never reaches the threshold, so it only selects.
5211
+ * Uses the public Konva `startDrag` API — the node's own `dragstart` handler
5212
+ * and the transformer's drag proxy take over from there.
5213
+ *
5214
+ * Wired un-throttled (separate from the throttled selection pointermove) to
5215
+ * keep drag initiation responsive.
5216
+ */
5217
+ function handleArmedDrag(ctx, e) {
5218
+ const node = ctx.getArmedDragNode();
5219
+ if (!node || !e?.evt) return;
5220
+ if (e.evt.buttons === 0) {
5221
+ ctx.clearArmedDrag();
5222
+ return;
5223
+ }
5224
+ if (e.evt.pointerId !== ctx.getArmedDragPointerId()) return;
5225
+ if (!ctx.getGesture().checkMoved(e.evt.clientX, e.evt.clientY)) return;
5226
+ if (node.isDragging()) return;
5227
+ ctx.clearArmedDrag();
5228
+ node.startDrag(e.evt);
5229
+ }
5230
+
5195
5231
  //#endregion
5196
5232
  //#region src/plugins/nodes-selection/nodes-selection.ts
5197
5233
  var WeaveNodesSelectionPlugin = class extends WeavePlugin {
@@ -5199,6 +5235,8 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
5199
5235
  _handledClickOrTap = false;
5200
5236
  dragSelectedNodes = [];
5201
5237
  _activeGroupContext = null;
5238
+ _armedDragNode = null;
5239
+ _armedDragPointerId = null;
5202
5240
  onRender = void 0;
5203
5241
  constructor(params) {
5204
5242
  super();
@@ -5226,6 +5264,8 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
5226
5264
  this.dragSelectedNodes = [];
5227
5265
  this._handledClickOrTap = false;
5228
5266
  this._activeGroupContext = null;
5267
+ this._armedDragNode = null;
5268
+ this._armedDragPointerId = null;
5229
5269
  }
5230
5270
  getName() {
5231
5271
  return WEAVE_NODES_SELECTION_KEY;
@@ -5284,6 +5324,20 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
5284
5324
  setAreaSelecting(val) {
5285
5325
  this.selecting = val;
5286
5326
  }
5327
+ armDrag(node, pointerId) {
5328
+ this._armedDragNode = node;
5329
+ this._armedDragPointerId = pointerId;
5330
+ }
5331
+ getArmedDragNode() {
5332
+ return this._armedDragNode;
5333
+ }
5334
+ getArmedDragPointerId() {
5335
+ return this._armedDragPointerId;
5336
+ }
5337
+ clearArmedDrag() {
5338
+ this._armedDragNode = null;
5339
+ this._armedDragPointerId = null;
5340
+ }
5287
5341
  initLayer() {
5288
5342
  const stage = this.instance.getStage();
5289
5343
  const layer = new Konva.Layer({ id: this.getLayerName() });
@@ -5426,6 +5480,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
5426
5480
  registerKeyboardHandlers(this);
5427
5481
  stage.on("pointerdown", (e) => handlePointerDown(this, e));
5428
5482
  stage.on("pointermove", (0, import_throttle.default)((e) => handlePointerMove(this, e), DEFAULT_THROTTLE_MS));
5483
+ stage.on("pointermove", (e) => handleArmedDrag(this, e));
5429
5484
  stage.on("pointerup", (e) => handlePointerUp(this, e));
5430
5485
  this.instance.addEventListener("onStateChange", () => {
5431
5486
  requestAnimationFrame(() => {
@@ -9700,7 +9755,7 @@ var WeaveRegisterManager = class {
9700
9755
 
9701
9756
  //#endregion
9702
9757
  //#region package.json
9703
- var version = "5.1.1";
9758
+ var version = "5.1.2";
9704
9759
 
9705
9760
  //#endregion
9706
9761
  //#region src/managers/setup.ts
@@ -13709,6 +13764,8 @@ var WeaveTextNode = class extends WeaveNode {
13709
13764
  this.textAreaContainer = null;
13710
13765
  this.textArea = null;
13711
13766
  this.editing = false;
13767
+ this.editingNodeId = null;
13768
+ this.nodeRenderedAddedRegistered = false;
13712
13769
  this.textArea = null;
13713
13770
  }
13714
13771
  updateNode(nodeInstance) {
@@ -13724,9 +13781,9 @@ var WeaveTextNode = class extends WeaveNode {
13724
13781
  this.instance.addNode(serializedNode, actualContainer?.getAttrs().id);
13725
13782
  } else if (this.createNode && actNode.getAttrs().text === "") actNode.destroy();
13726
13783
  else this.instance.updateNode(this.serialize(clonedText));
13727
- this.createNode = false;
13728
13784
  clonedText.destroy();
13729
13785
  }
13786
+ this.createNode = false;
13730
13787
  }
13731
13788
  handleKeyPress = (e) => {
13732
13789
  if (e.code === "Enter" && this.instance.getActiveAction() === SELECTION_TOOL_ACTION_NAME && !this.editing && e.target !== this.textArea) {
@@ -13896,9 +13953,12 @@ var WeaveTextNode = class extends WeaveNode {
13896
13953
  text.on("transformend", () => {
13897
13954
  handleTransformEnd();
13898
13955
  });
13899
- this.instance.addEventListener("onNodeRenderedAdded", (node) => {
13900
- if (node.id() === text.id() && node.getParent() !== text.getParent() && this.editing) text.getAttr("cancelEditMode")?.();
13901
- });
13956
+ if (!this.nodeRenderedAddedRegistered) {
13957
+ this.instance.addEventListener("onNodeRenderedAdded", (node) => {
13958
+ if (this.editing && this.editingNodeId !== null && node.id() === this.editingNodeId && node.getAttr("cancelEditMode")) node.getAttr("cancelEditMode")?.();
13959
+ });
13960
+ this.nodeRenderedAddedRegistered = true;
13961
+ }
13902
13962
  if (!this.instance.isServerSide() && !this.keyPressHandler) {
13903
13963
  this.keyPressHandler = this.handleKeyPress.bind(this);
13904
13964
  window.addEventListener("keypress", this.keyPressHandler, { signal: this.instance.getEventsController().signal });
@@ -13934,7 +13994,7 @@ var WeaveTextNode = class extends WeaveNode {
13934
13994
  width,
13935
13995
  height
13936
13996
  });
13937
- if (this.editing) this.updateTextAreaDOM(nodeInstance);
13997
+ if (this.editing && this.editingNodeId === nodeInstance.id()) this.updateTextAreaDOM(nodeInstance);
13938
13998
  if (!this.editing) {
13939
13999
  const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
13940
14000
  if (nodesSelectionPlugin) {
@@ -14278,27 +14338,29 @@ var WeaveTextNode = class extends WeaveNode {
14278
14338
  this.instance.disablePlugin("nodesSelection");
14279
14339
  tr.hide();
14280
14340
  }
14281
- if (this.editing) textNode.visible(false);
14341
+ if (this.editing && this.editingNodeId === textNode.id()) textNode.visible(false);
14282
14342
  else textNode.visible(true);
14283
14343
  }
14284
14344
  removeTextAreaDOM(textNode) {
14285
14345
  this.instance.releaseMutexLock();
14286
14346
  this.instance.getStage().mode(WEAVE_STAGE_DEFAULT_MODE);
14287
14347
  this.editing = false;
14348
+ this.editingNodeId = null;
14288
14349
  const stage = this.instance.getStage();
14289
14350
  if (this.textAreaSuperContainer) this.textAreaSuperContainer.remove();
14290
14351
  textNode.visible(true);
14291
14352
  this.updateNode(textNode);
14353
+ const liveNode = stage.findOne(`#${textNode.id()}`) ?? textNode;
14292
14354
  const selectionPlugin = this.instance.getPlugin("nodesSelection");
14293
14355
  if (selectionPlugin) {
14294
14356
  this.instance.enablePlugin("nodesSelection");
14295
- selectionPlugin.setSelectedNodes([textNode]);
14357
+ selectionPlugin.setSelectedNodes([liveNode]);
14296
14358
  this.instance.triggerAction(SELECTION_TOOL_ACTION_NAME);
14297
14359
  }
14298
14360
  stage.container().tabIndex = 1;
14299
14361
  stage.container().click();
14300
14362
  stage.container().focus();
14301
- this.instance.emitEvent("onExitTextNodeEditMode", { node: textNode });
14363
+ this.instance.emitEvent("onExitTextNodeEditMode", { node: liveNode });
14302
14364
  }
14303
14365
  triggerEditMode(textNode, create = false) {
14304
14366
  if (create) this.createNode = true;
@@ -14308,6 +14370,7 @@ var WeaveTextNode = class extends WeaveNode {
14308
14370
  });
14309
14371
  if (!lockAcquired) return;
14310
14372
  this.editing = true;
14373
+ this.editingNodeId = textNode.id();
14311
14374
  textNode.visible(false);
14312
14375
  const selectionPlugin = this.instance.getPlugin("nodesSelection");
14313
14376
  if (selectionPlugin) {
@@ -24786,14 +24849,18 @@ var WeaveTextToolAction = class extends WeaveAction {
24786
24849
  cleanup() {
24787
24850
  const stage = this.instance.getStage();
24788
24851
  stage.container().style.cursor = "default";
24789
- const selectionPlugin = this.instance.getPlugin("nodesSelection");
24790
- if (selectionPlugin) {
24791
- const node = stage.findOne(`#${this.textId}`);
24792
- if (node) selectionPlugin.setSelectedNodes([node]);
24793
- this.instance.triggerAction(SELECTION_TOOL_ACTION_NAME);
24852
+ const placedId = this.textId;
24853
+ const justAdded = this.state === TEXT_TOOL_STATE.FINISHED && !!placedId;
24854
+ if (justAdded) {
24855
+ const selectionPlugin = this.instance.getPlugin("nodesSelection");
24856
+ if (selectionPlugin) {
24857
+ const node = stage.findOne(`#${placedId}`);
24858
+ if (node) selectionPlugin.setSelectedNodes([node]);
24859
+ this.instance.triggerAction(SELECTION_TOOL_ACTION_NAME);
24860
+ }
24861
+ const textGroup = stage.findOne(`#${placedId}`);
24862
+ if (textGroup) textGroup.getAttr("triggerEditMode")?.(textGroup, true);
24794
24863
  }
24795
- const textGroup = stage.findOne(`#${this.textId}`);
24796
- if (textGroup) textGroup.getAttr("triggerEditMode")(textGroup, true);
24797
24864
  this.initialCursor = null;
24798
24865
  this.textId = null;
24799
24866
  this.container = void 0;