@inditextech/weave-sdk 2.1.0 → 2.2.0

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.node.js CHANGED
@@ -3,7 +3,6 @@ import { randomFillSync, randomUUID } from "crypto";
3
3
  import pino from "pino";
4
4
  import { WEAVE_AWARENESS_LAYER_ID, WEAVE_EXPORT_BACKGROUND_COLOR, WEAVE_EXPORT_FORMATS, WEAVE_INSTANCE_STATUS, WEAVE_KONVA_BACKEND, WEAVE_NODE_CUSTOM_EVENTS, WEAVE_NODE_LAYER_ID, WEAVE_NODE_POSITION, WEAVE_STORE_CONNECTION_STATUS, WEAVE_UTILITY_LAYER_ID } from "@inditextech/weave-types";
5
5
  import { getYjsDoc, getYjsValue, observeDeep, syncedStore } from "@syncedstore/core";
6
- import * as Y$1 from "yjs";
7
6
  import * as Y from "yjs";
8
7
  import React from "react";
9
8
  import ReactReconciler from "react-reconciler";
@@ -15009,28 +15008,29 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
15009
15008
  } else root$8._ = _;
15010
15009
  }).call(exports);
15011
15010
  } });
15011
+ var import_lodash$1 = __toESM(require_lodash());
15012
15012
  var import_lodash = __toESM(require_lodash(), 1);
15013
15013
 
15014
15014
  //#endregion
15015
15015
  //#region src/yjs.ts
15016
- var yjs_default = Y$1;
15016
+ var yjs_default = Y;
15017
15017
 
15018
15018
  //#endregion
15019
15019
  //#region src/stores/default-initial-state.ts
15020
15020
  const yjsLayer = function(id) {
15021
- const newLayerMap = new Y.Map();
15021
+ const newLayerMap = new yjs_default.Map();
15022
15022
  newLayerMap.set("key", id);
15023
15023
  newLayerMap.set("type", "layer");
15024
- const newLayerMapProps = new Y.Map();
15024
+ const newLayerMapProps = new yjs_default.Map();
15025
15025
  newLayerMapProps.set("id", id);
15026
15026
  newLayerMapProps.set("nodeType", "layer");
15027
- newLayerMapProps.set("children", new Y.Array());
15027
+ newLayerMapProps.set("children", new yjs_default.Array());
15028
15028
  newLayerMap.set("props", newLayerMapProps);
15029
15029
  return newLayerMap;
15030
15030
  };
15031
15031
  function defaultInitialState(doc) {
15032
15032
  doc.transact(() => {
15033
- const children = new Y.Array();
15033
+ const children = new yjs_default.Array();
15034
15034
  children.insert(0, [
15035
15035
  yjsLayer("gridLayer"),
15036
15036
  yjsLayer("mainLayer"),
@@ -15038,7 +15038,7 @@ function defaultInitialState(doc) {
15038
15038
  yjsLayer("usersPointersLayer"),
15039
15039
  yjsLayer("utilityLayer")
15040
15040
  ]);
15041
- const stageProps = new Y.Map();
15041
+ const stageProps = new yjs_default.Map();
15042
15042
  stageProps.set("id", "stage");
15043
15043
  stageProps.set("children", children);
15044
15044
  doc.getMap("weave").set("key", "stage");
@@ -15153,13 +15153,13 @@ var WeaveStore = class {
15153
15153
  node: JSON.parse(JSON.stringify(nodeInfo.node))
15154
15154
  });
15155
15155
  }
15156
- if (!this.isRoomLoaded && !(0, import_lodash.isEmpty)(this.state.weave)) {
15156
+ if (!this.isRoomLoaded && !(0, import_lodash$1.isEmpty)(this.state.weave)) {
15157
15157
  this.instance.setupRenderer();
15158
15158
  this.isRoomLoaded = true;
15159
15159
  this.emitOnRoomLoadedEvent();
15160
15160
  return;
15161
15161
  }
15162
- if (this.isRoomLoaded && !(0, import_lodash.isEmpty)(this.state.weave)) this.instance.render();
15162
+ if (this.isRoomLoaded && !(0, import_lodash$1.isEmpty)(this.state.weave)) this.instance.render();
15163
15163
  });
15164
15164
  }
15165
15165
  canUndoStateStep() {
@@ -17602,7 +17602,7 @@ var require_mergeWith = __commonJS({ "../../node_modules/lodash/mergeWith.js"(ex
17602
17602
  });
17603
17603
  module.exports = mergeWith;
17604
17604
  } });
17605
- var import_mergeWith = __toESM(require_mergeWith(), 1);
17605
+ var import_mergeWith = __toESM(require_mergeWith());
17606
17606
 
17607
17607
  //#endregion
17608
17608
  //#region src/utils.ts
@@ -18452,7 +18452,7 @@ var require_throttle = __commonJS({ "../../node_modules/lodash/throttle.js"(expo
18452
18452
  }
18453
18453
  module.exports = throttle;
18454
18454
  } });
18455
- var import_throttle = __toESM(require_throttle(), 1);
18455
+ var import_throttle = __toESM(require_throttle());
18456
18456
 
18457
18457
  //#endregion
18458
18458
  //#region src/nodes/stage/constants.ts
@@ -19348,11 +19348,11 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19348
19348
  }
19349
19349
  if (nodesSelected === 1) {
19350
19350
  transformerAttrs = mergeExceptArrays(transformerAttrs, nodes[0].getTransformerProperties());
19351
- transformerAttrs.enabledAnchors = nodes[0].allowedAnchors();
19351
+ transformerAttrs.enabledAnchors = nodes[0]?.allowedAnchors() ?? [];
19352
19352
  }
19353
19353
  if (nodesSelected > 1) {
19354
19354
  const anchorsArrays = [];
19355
- for (const node of nodes) anchorsArrays.push(node.allowedAnchors());
19355
+ for (const node of nodes) anchorsArrays.push(node?.allowedAnchors() ?? []);
19356
19356
  transformerAttrs.enabledAnchors = intersectArrays(anchorsArrays);
19357
19357
  }
19358
19358
  if (this.tr && this.tr.nodes().length > 0) {
@@ -19986,7 +19986,7 @@ var WeaveNode = class {
19986
19986
  if (nodesSelectionPlugin && this.isSelecting() && this.isNodeSelected(node$1)) nodesSelectionPlugin.getTransformer().forceUpdate();
19987
19987
  if (nodesEdgeSnappingPlugin && transforming && this.isSelecting() && this.isNodeSelected(node$1)) nodesEdgeSnappingPlugin.evaluateGuidelines(e);
19988
19988
  };
19989
- node.on("transform", (0, import_lodash.throttle)(handleTransform, 100));
19989
+ node.on("transform", (0, import_lodash$1.throttle)(handleTransform, 100));
19990
19990
  node.on("transformend", (e) => {
19991
19991
  const node$1 = e.target;
19992
19992
  this.instance.emitEvent("onTransform", null);
@@ -20078,7 +20078,7 @@ var WeaveNode = class {
20078
20078
  if (layerToMove && !hasFrames(realNodeTarget) && realNodeTarget.isDragging()) layerToMove.fire(WEAVE_NODE_CUSTOM_EVENTS.onTargetEnter, { bubbles: true });
20079
20079
  }
20080
20080
  };
20081
- node.on("dragmove", (0, import_lodash.throttle)(handleDragMove, 100));
20081
+ node.on("dragmove", (0, import_lodash$1.throttle)(handleDragMove, 100));
20082
20082
  node.on("dragend", (e) => {
20083
20083
  const nodeTarget = e.target;
20084
20084
  this.getNodesSelectionFeedbackPlugin()?.hideSelectionHalo(nodeTarget);
@@ -20395,29 +20395,50 @@ var WeaveReconciler = class {
20395
20395
  const type = child.getAttrs().nodeType;
20396
20396
  const handler = this.instance.getNodeHandler(type);
20397
20397
  if (!handler) return;
20398
+ let nodeAdded = false;
20398
20399
  if (parentInstance instanceof Konva.Stage && child instanceof Konva.Layer) {
20399
20400
  parentInstance.add(child);
20400
20401
  handler.onAdd?.(child);
20402
+ nodeAdded = true;
20401
20403
  }
20402
20404
  if (parentInstance instanceof Konva.Layer) {
20403
20405
  parentInstance.add(child);
20404
20406
  handler.onAdd?.(child);
20407
+ nodeAdded = true;
20405
20408
  }
20406
20409
  if (parentInstance instanceof Konva.Group && typeof parentAttrs.containerId !== "undefined") {
20407
20410
  const realParent = parentInstance.findOne(`#${parentAttrs.containerId}`);
20408
20411
  realParent?.add(child);
20409
20412
  handler.onAdd?.(child);
20413
+ nodeAdded = true;
20410
20414
  }
20411
20415
  if (parentInstance instanceof Konva.Group && typeof parentAttrs.containerId === "undefined") {
20412
20416
  parentInstance.add(child);
20413
20417
  handler.onAdd?.(child);
20418
+ nodeAdded = true;
20414
20419
  }
20415
20420
  if (childInitialZIndex) child.zIndex(childInitialZIndex);
20421
+ if (nodeAdded) this.instance.emitEvent("onNodeRenderedAdded", child);
20422
+ }
20423
+ updateNode(instance, type, prevProps, nextProps) {
20424
+ if (!(0, import_lodash.isEqual)(prevProps, nextProps)) {
20425
+ const handler = this.instance.getNodeHandler(type);
20426
+ if (!handler) return;
20427
+ handler.onUpdate(instance, nextProps);
20428
+ const childZIndex = nextProps.zIndex;
20429
+ if (childZIndex) instance.zIndex(childZIndex);
20430
+ this.instance.emitEvent("onNodeRenderedUpdated", instance);
20431
+ }
20432
+ }
20433
+ removeNode(node) {
20434
+ this.instance.emitEvent("onNodeRenderedRemoved", node);
20416
20435
  }
20417
20436
  getConfig() {
20418
20437
  const weaveInstance = this.instance;
20419
20438
  const logger = this.logger;
20420
20439
  const addNode = this.addNode.bind(this);
20440
+ const updateNode = this.updateNode.bind(this);
20441
+ const removeNode = this.removeNode.bind(this);
20421
20442
  return {
20422
20443
  noTimeout: -1,
20423
20444
  isPrimaryRenderer: true,
@@ -20611,13 +20632,7 @@ var WeaveReconciler = class {
20611
20632
  nextProps
20612
20633
  }, "commitUpdate");
20613
20634
  if (instance instanceof Weave) return;
20614
- if (!(0, import_lodash.isEqual)(prevProps, nextProps)) {
20615
- const handler = weaveInstance.getNodeHandler(type);
20616
- if (!handler) return;
20617
- handler.onUpdate(instance, nextProps);
20618
- const childZIndex = nextProps.zIndex;
20619
- if (childZIndex) instance.zIndex(childZIndex);
20620
- }
20635
+ updateNode(instance, type, prevProps, nextProps);
20621
20636
  },
20622
20637
  removeChildFromContainer() {
20623
20638
  logger.debug("removeChildFromContainer");
@@ -20628,6 +20643,7 @@ var WeaveReconciler = class {
20628
20643
  const handler = weaveInstance.getNodeHandler(type);
20629
20644
  if (!handler) return;
20630
20645
  handler.onDestroy(child);
20646
+ removeNode(child);
20631
20647
  }
20632
20648
  };
20633
20649
  }
@@ -21528,27 +21544,23 @@ var WeaveStateManager = class {
21528
21544
  }, msg);
21529
21545
  return;
21530
21546
  }
21531
- const doc = getYjsDoc(state);
21532
- const userId = this.instance.getStore().getUser().id;
21533
- doc.transact(() => {
21534
- if (!parent.props.children) parent.props.children = [];
21535
- if (index) {
21536
- parent.props.children.splice(index, 0, node);
21537
- for (let i = 0; i < parent.props.children.length; i++) parent.props.children[i].props.zIndex = i;
21538
- }
21539
- if (!index) {
21540
- const childrenAmount = parent.props.children.length;
21541
- const nodeToAdd = {
21542
- ...node,
21543
- props: {
21544
- ...node.props,
21545
- zIndex: childrenAmount
21546
- }
21547
- };
21548
- parent.props.children.push(nodeToAdd);
21549
- }
21550
- this.instance.emitEvent("onNodeAdded", node);
21551
- }, userId);
21547
+ if (!parent.props.children) parent.props.children = [];
21548
+ if (index) {
21549
+ parent.props.children.splice(index, 0, node);
21550
+ for (let i = 0; i < parent.props.children.length; i++) parent.props.children[i].props.zIndex = i;
21551
+ }
21552
+ if (!index) {
21553
+ const childrenAmount = parent.props.children.length;
21554
+ const nodeToAdd = {
21555
+ ...node,
21556
+ props: {
21557
+ ...node.props,
21558
+ zIndex: childrenAmount
21559
+ }
21560
+ };
21561
+ parent.props.children.push(nodeToAdd);
21562
+ }
21563
+ this.instance.emitEvent("onNodeAdded", node);
21552
21564
  }
21553
21565
  deepSyncSyncedStore(target, source) {
21554
21566
  for (const key in target) if (!(key in source)) delete target[key];
@@ -21585,12 +21597,19 @@ var WeaveStateManager = class {
21585
21597
  this.logger.warn({ node }, msg);
21586
21598
  return;
21587
21599
  }
21600
+ this.deepSyncSyncedStore(nodeState.props, node.props);
21601
+ this.instance.emitEvent("onNodeUpdated", node);
21602
+ }
21603
+ updateNodes(nodes) {
21604
+ for (const node of nodes) this.updateNode(node);
21605
+ }
21606
+ stateTransactional(callback) {
21607
+ const state = this.instance.getStore().getState();
21588
21608
  const doc = getYjsDoc(state);
21589
21609
  const userId = this.instance.getStore().getUser().id;
21590
21610
  doc.transact(() => {
21591
- this.deepSyncSyncedStore(nodeState.props, node.props);
21611
+ callback();
21592
21612
  }, userId);
21593
- this.instance.emitEvent("onNodeUpdated", node);
21594
21613
  }
21595
21614
  removeNode(node) {
21596
21615
  const state = this.instance.getStore().getState();
@@ -21610,21 +21629,14 @@ var WeaveStateManager = class {
21610
21629
  this.logger.warn({ node }, msg);
21611
21630
  return;
21612
21631
  }
21613
- const doc = getYjsDoc(state);
21614
- const userId = this.instance.getStore().getUser().id;
21615
- doc.transact(() => {
21616
- if (parent.props.children) {
21617
- for (let i = parent.props.children.length - 1; i >= 0; i--) if (parent.props.children[i].key === node.key) {
21618
- parent.props.children.splice(i, 1);
21619
- break;
21620
- }
21621
- for (let i = 0; i < parent.props.children.length; i++) parent.props.children[i].props.zIndex = i;
21622
- this.instance.emitEvent("onNodeRemoved", node);
21632
+ if (parent.props.children) {
21633
+ for (let i = parent.props.children.length - 1; i >= 0; i--) if (parent.props.children[i].key === node.key) {
21634
+ parent.props.children.splice(i, 1);
21635
+ break;
21623
21636
  }
21624
- }, userId);
21625
- }
21626
- removeNodes(nodes) {
21627
- for (const node of nodes) this.removeNode(node);
21637
+ for (let i = 0; i < parent.props.children.length; i++) parent.props.children[i].props.zIndex = i;
21638
+ this.instance.emitEvent("onNodeRemoved", node);
21639
+ }
21628
21640
  }
21629
21641
  moveNode(node, position) {
21630
21642
  const state = this.instance.getStore().getState();
@@ -21652,19 +21664,15 @@ var WeaveStateManager = class {
21652
21664
  this.logger.warn({ node }, msg);
21653
21665
  return;
21654
21666
  }
21655
- const doc = getYjsDoc(state);
21656
- const userId = this.instance.getStore().getUser().id;
21657
- doc.transact(() => {
21658
- if (parent.props.children) {
21659
- const item = JSON.parse(JSON.stringify(parent.props.children[nodeIndex]));
21660
- parent.props.children.splice(nodeIndex, 1);
21661
- if (item && position === WEAVE_NODE_POSITION.UP) parent.props.children.splice(nodeIndex + 1, 0, item);
21662
- if (item && position === WEAVE_NODE_POSITION.DOWN) parent.props.children.splice(nodeIndex - 1, 0, item);
21663
- if (item && position === WEAVE_NODE_POSITION.FRONT) parent.props.children.splice(childrenAmount - 1, 0, item);
21664
- if (item && position === WEAVE_NODE_POSITION.BACK) parent.props.children.splice(0, 0, item);
21665
- for (let i = 0; i < parent.props.children.length; i++) parent.props.children[i].props.zIndex = i;
21666
- }
21667
- }, userId);
21667
+ if (parent.props.children) {
21668
+ const item = JSON.parse(JSON.stringify(parent.props.children[nodeIndex]));
21669
+ parent.props.children.splice(nodeIndex, 1);
21670
+ if (item && position === WEAVE_NODE_POSITION.UP) parent.props.children.splice(nodeIndex + 1, 0, item);
21671
+ if (item && position === WEAVE_NODE_POSITION.DOWN) parent.props.children.splice(nodeIndex - 1, 0, item);
21672
+ if (item && position === WEAVE_NODE_POSITION.FRONT) parent.props.children.splice(childrenAmount - 1, 0, item);
21673
+ if (item && position === WEAVE_NODE_POSITION.BACK) parent.props.children.splice(0, 0, item);
21674
+ for (let i = 0; i < parent.props.children.length; i++) parent.props.children[i].props.zIndex = i;
21675
+ }
21668
21676
  }
21669
21677
  }
21670
21678
  getElementsTree() {
@@ -21750,7 +21758,7 @@ var WeaveRegisterManager = class {
21750
21758
 
21751
21759
  //#endregion
21752
21760
  //#region package.json
21753
- var version = "2.1.0";
21761
+ var version = "2.2.0";
21754
21762
 
21755
21763
  //#endregion
21756
21764
  //#region src/managers/setup.ts
@@ -22375,6 +22383,8 @@ var Weave = class {
22375
22383
  store.disconnect();
22376
22384
  const stage = this.getStage();
22377
22385
  if (stage) stage.destroy();
22386
+ globalThis.Konva = void 0;
22387
+ globalThis["__ $YJS$ __"] = void 0;
22378
22388
  this.moduleLogger.info(`Instance destroyed`);
22379
22389
  }
22380
22390
  getId() {
@@ -22535,25 +22545,59 @@ var Weave = class {
22535
22545
  return this.stateManager.getNode(nodeKey);
22536
22546
  }
22537
22547
  addNode(node, parentId = "mainLayer", index = void 0) {
22548
+ this.stateTransactional(() => {
22549
+ this.stateManager.addNode(node, parentId, index);
22550
+ });
22551
+ }
22552
+ addNodeNT(node, parentId = "mainLayer", index = void 0) {
22538
22553
  this.stateManager.addNode(node, parentId, index);
22539
22554
  }
22540
22555
  updateNode(node) {
22556
+ this.stateTransactional(() => {
22557
+ this.stateManager.updateNode(node);
22558
+ });
22559
+ }
22560
+ updateNodeNT(node) {
22541
22561
  this.stateManager.updateNode(node);
22542
22562
  }
22543
22563
  updateNodes(nodes) {
22544
- for (const node of nodes) this.updateNode(node);
22564
+ this.stateTransactional(() => {
22565
+ this.stateManager.updateNodes(nodes);
22566
+ });
22567
+ }
22568
+ updateNodesNT(nodes) {
22569
+ this.stateManager.updateNodes(nodes);
22545
22570
  }
22546
22571
  removeNode(node) {
22572
+ this.stateTransactional(() => {
22573
+ this.stateManager.removeNode(node);
22574
+ const selectionPlugin = this.getPlugin("nodesSelection");
22575
+ if (selectionPlugin) selectionPlugin.setSelectedNodes([]);
22576
+ });
22577
+ }
22578
+ removeNodeNT(node) {
22547
22579
  this.stateManager.removeNode(node);
22548
22580
  const selectionPlugin = this.getPlugin("nodesSelection");
22549
22581
  if (selectionPlugin) selectionPlugin.setSelectedNodes([]);
22550
22582
  }
22551
22583
  removeNodes(nodes) {
22552
- for (const node of nodes) this.removeNode(node);
22584
+ this.stateTransactional(() => {
22585
+ for (const node of nodes) this.removeNodeNT(node);
22586
+ const selectionPlugin = this.getPlugin("nodesSelection");
22587
+ if (selectionPlugin) selectionPlugin.setSelectedNodes([]);
22588
+ });
22589
+ }
22590
+ removeNodesNT(nodes) {
22591
+ for (const node of nodes) this.removeNodeNT(node);
22553
22592
  const selectionPlugin = this.getPlugin("nodesSelection");
22554
22593
  if (selectionPlugin) selectionPlugin.setSelectedNodes([]);
22555
22594
  }
22556
22595
  moveNode(node, position) {
22596
+ this.stateTransactional(() => {
22597
+ this.stateManager.moveNode(node, position);
22598
+ });
22599
+ }
22600
+ moveNodeNT(node, position) {
22557
22601
  this.stateManager.moveNode(node, position);
22558
22602
  }
22559
22603
  getElementsTree() {
@@ -22583,6 +22627,9 @@ var Weave = class {
22583
22627
  getBoundingBox(nodes, config) {
22584
22628
  return getBoundingBox(nodes, config);
22585
22629
  }
22630
+ stateTransactional(callback) {
22631
+ this.stateManager.stateTransactional(callback);
22632
+ }
22586
22633
  moveUp(node) {
22587
22634
  this.zIndexManager.moveUp(node);
22588
22635
  }
@@ -23257,7 +23304,7 @@ var WeaveTextNode = class extends WeaveNode {
23257
23304
  text.on("transformstart", (e) => {
23258
23305
  this.instance.emitEvent("onTransform", e.target);
23259
23306
  });
23260
- text.on("transform", (0, import_lodash.throttle)(handleTextTransform, 50));
23307
+ text.on("transform", (0, import_lodash$1.throttle)(handleTextTransform, 50));
23261
23308
  text.on("transformend", () => {
23262
23309
  this.instance.emitEvent("onTransform", null);
23263
23310
  });
@@ -25071,6 +25118,7 @@ var WeaveStrokeNode = class extends WeaveNode {
25071
25118
  return result;
25072
25119
  }
25073
25120
  drawRibbonWithDash(ctx, pts, baseW, color, dash) {
25121
+ if (!pts) return;
25074
25122
  if (pts.length < 2) return;
25075
25123
  const filtered = this.resamplePoints(pts, 2);
25076
25124
  const centerline = this.getSplinePoints(filtered, 8);
@@ -25158,7 +25206,7 @@ var WeaveStrokeNode = class extends WeaveNode {
25158
25206
  }
25159
25207
  drawShape(ctx, shape) {
25160
25208
  const strokeElements = shape.getAttrs().strokeElements;
25161
- if (strokeElements.length === 0) return;
25209
+ if (strokeElements?.length === 0) return;
25162
25210
  const color = shape.getAttrs().stroke ?? "black";
25163
25211
  const strokeWidth = shape.getAttrs().strokeWidth ?? 1;
25164
25212
  const dash = shape.getAttrs().dash ?? [];
@@ -25325,50 +25373,52 @@ const WEAVE_COMMENT_NODE_DEFAULTS = {
25325
25373
 
25326
25374
  //#endregion
25327
25375
  //#region src/nodes/comment/text-max-lines.ts
25328
- var TextWithMaxLines = class extends Konva.Text {
25329
- constructor(config) {
25330
- super(config);
25331
- this._maxLines = config.maxLines;
25332
- this._fullText = config.text?.toString() ?? "";
25333
- this.on("textChange widthChange fontSizeChange fontFamilyChange fontStyleChange paddingChange alignChange letterSpacingChange lineHeightChange wrapChange", () => this._applyTruncation());
25334
- this._applyTruncation();
25335
- }
25336
- get maxLines() {
25337
- return this._maxLines;
25338
- }
25339
- set maxLines(v) {
25340
- this._maxLines = v;
25341
- this._applyTruncation();
25342
- }
25343
- setText(text) {
25344
- if (typeof text === "undefined") return this;
25345
- this._fullText = text ?? "";
25346
- super.setText(this._fullText);
25347
- this._applyTruncation();
25348
- return this;
25349
- }
25350
- _applyTruncation() {
25351
- if (!this._maxLines || this._maxLines <= 0) {
25376
+ function CreateTextWithMaxLines() {
25377
+ return class TextWithMaxLines extends Konva.Text {
25378
+ constructor(config) {
25379
+ super(config);
25380
+ this._maxLines = config.maxLines;
25381
+ this._fullText = config.text?.toString() ?? "";
25382
+ this.on("textChange widthChange fontSizeChange fontFamilyChange fontStyleChange paddingChange alignChange letterSpacingChange lineHeightChange wrapChange", () => this._applyTruncation());
25383
+ this._applyTruncation();
25384
+ }
25385
+ get maxLines() {
25386
+ return this._maxLines;
25387
+ }
25388
+ set maxLines(v) {
25389
+ this._maxLines = v;
25390
+ this._applyTruncation();
25391
+ }
25392
+ setText(text) {
25393
+ if (typeof text === "undefined") return this;
25394
+ this._fullText = text ?? "";
25352
25395
  super.setText(this._fullText);
25353
- return;
25396
+ this._applyTruncation();
25397
+ return this;
25354
25398
  }
25355
- super.setText(this._fullText);
25356
- const selfAny = this;
25357
- if (typeof selfAny._setTextData === "function") selfAny._setTextData();
25358
- let textArr = selfAny.textArr || [];
25359
- if (textArr.length > this._maxLines) {
25360
- const visible = textArr.slice(0, this._maxLines).map((l) => l.text);
25361
- const candidate = visible[visible.length - 1] + "…";
25362
- super.setText([...visible.slice(0, -1), candidate].join("\n"));
25399
+ _applyTruncation() {
25400
+ if (!this._maxLines || this._maxLines <= 0) {
25401
+ super.setText(this._fullText);
25402
+ return;
25403
+ }
25404
+ super.setText(this._fullText);
25405
+ const selfAny = this;
25363
25406
  if (typeof selfAny._setTextData === "function") selfAny._setTextData();
25364
- textArr = selfAny.textArr || [];
25407
+ let textArr = selfAny.textArr || [];
25408
+ if (textArr.length > this._maxLines) {
25409
+ const visible = textArr.slice(0, this._maxLines).map((l) => l.text);
25410
+ const candidate = visible[visible.length - 1] + "…";
25411
+ super.setText([...visible.slice(0, -1), candidate].join("\n"));
25412
+ if (typeof selfAny._setTextData === "function") selfAny._setTextData();
25413
+ textArr = selfAny.textArr || [];
25414
+ }
25415
+ const lines = textArr.length;
25416
+ const fontSize = this.fontSize();
25417
+ const lineHeight = this.lineHeight() || 1;
25418
+ this.height(fontSize * lineHeight * lines);
25365
25419
  }
25366
- const lines = textArr.length;
25367
- const fontSize = this.fontSize();
25368
- const lineHeight = this.lineHeight() || 1;
25369
- this.height(fontSize * lineHeight * lines);
25370
- }
25371
- };
25420
+ };
25421
+ }
25372
25422
 
25373
25423
  //#endregion
25374
25424
  //#region src/nodes/comment/comment.ts
@@ -25538,7 +25588,7 @@ var WeaveCommentNode = class extends WeaveNode {
25538
25588
  });
25539
25589
  internalUserName.setAttrs({ width: widthExpanded - (widthContracted - 2 * circlePaddingContracted) - userNameLeftMargin - dateLeftMargin - dateWidth.width });
25540
25590
  const commentContent = this.config.model.getContent(commentParams.commentModel);
25541
- const internalComment = new TextWithMaxLines({
25591
+ const internalComment = new (CreateTextWithMaxLines())({
25542
25592
  id: `${id}-comment`,
25543
25593
  x: widthContracted - 2 * circlePaddingContracted + userNameLeftMargin,
25544
25594
  text: commentContent,
@@ -26549,7 +26599,7 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
26549
26599
  this.config.zoomSteps = [minimumZoom, ...this.config.zoomSteps];
26550
26600
  }
26551
26601
  };
26552
- mainLayer?.on("draw", (0, import_lodash.throttle)(handleDraw, 50));
26602
+ mainLayer?.on("draw", (0, import_lodash$1.throttle)(handleDraw, 50));
26553
26603
  this.setZoom(this.config.zoomSteps[this.actualStep]);
26554
26604
  }
26555
26605
  setZoom(scale, centered = true, pointer) {
@@ -30267,7 +30317,7 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
30267
30317
  if (!this.enabled || !(this.isSpaceKeyPressed || this.isMouseMiddleButtonPressed || this.moveToolActive)) return;
30268
30318
  this.onRender();
30269
30319
  };
30270
- stage.on("pointermove", (0, import_lodash.throttle)(handleMouseMove, 50));
30320
+ stage.on("pointermove", (0, import_lodash$1.throttle)(handleMouseMove, 50));
30271
30321
  stage.on("pointermove", () => {
30272
30322
  if (this.enabled) this.onRender();
30273
30323
  });
@@ -30576,7 +30626,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
30576
30626
  lastPos = pos;
30577
30627
  this.instance.emitEvent("onStageMove");
30578
30628
  };
30579
- stage.on("pointermove", (0, import_lodash.throttle)(handleMouseMove, 50));
30629
+ stage.on("pointermove", (0, import_lodash$1.throttle)(handleMouseMove, 50));
30580
30630
  stage.on("pointerup", (e) => {
30581
30631
  this.pointers.delete(e.evt.pointerId);
30582
30632
  this.isMouseLeftButtonPressed = false;
@@ -30840,7 +30890,7 @@ var WeaveStageMinimapPlugin = class extends WeavePlugin {
30840
30890
  this.setupMinimap();
30841
30891
  }
30842
30892
  onInit() {
30843
- const throttledUpdateMinimap = (0, import_lodash.throttle)(async () => {
30893
+ const throttledUpdateMinimap = (0, import_lodash$1.throttle)(async () => {
30844
30894
  await this.updateMinimapContent();
30845
30895
  this.updateMinimapViewportReference();
30846
30896
  }, 100);
@@ -31133,7 +31183,7 @@ var WeaveConnectedUsersPlugin = class extends WeavePlugin {
31133
31183
  newConnectedUsers[userInformation.id] = userInformation;
31134
31184
  }
31135
31185
  }
31136
- if (!(0, import_lodash.isEqual)(this.connectedUsers, newConnectedUsers)) this.instance.emitEvent("onConnectedUsersChange", newConnectedUsers);
31186
+ if (!(0, import_lodash$1.isEqual)(this.connectedUsers, newConnectedUsers)) this.instance.emitEvent("onConnectedUsersChange", newConnectedUsers);
31137
31187
  this.connectedUsers = newConnectedUsers;
31138
31188
  });
31139
31189
  }
@@ -31381,7 +31431,7 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
31381
31431
  for (let i = 0; i < inactiveUsers.length; i++) delete this.usersPointers[inactiveUsers[i]];
31382
31432
  this.renderPointers();
31383
31433
  });
31384
- const sendAwarenessUpdateThrottled = (0, import_lodash.throttle)(this.sendAwarenessUpdate.bind(this), this.config.awarenessThrottleMs);
31434
+ const sendAwarenessUpdateThrottled = (0, import_lodash$1.throttle)(this.sendAwarenessUpdate.bind(this), this.config.awarenessThrottleMs);
31385
31435
  stage.on("dragmove", () => {
31386
31436
  const mousePos = stage.getRelativePointerPosition();
31387
31437
  if (mousePos) sendAwarenessUpdateThrottled(mousePos);