@netless/forge-whiteboard 0.1.16 → 0.1.17

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.
Files changed (63) hide show
  1. package/README.md +15 -6
  2. package/changelog.md +6 -1
  3. package/dist/LiveCursor.d.ts +20 -0
  4. package/dist/LiveCursor.d.ts.map +1 -0
  5. package/dist/Whiteboard.d.ts +12 -8
  6. package/dist/Whiteboard.d.ts.map +1 -1
  7. package/dist/WhiteboardApplication.d.ts +7 -0
  8. package/dist/WhiteboardApplication.d.ts.map +1 -1
  9. package/dist/model/RenderableModel.d.ts +3 -1
  10. package/dist/model/RenderableModel.d.ts.map +1 -1
  11. package/dist/model/renderable/CurveModel.d.ts +3 -1
  12. package/dist/model/renderable/CurveModel.d.ts.map +1 -1
  13. package/dist/model/renderable/ElementModel.d.ts +4 -1
  14. package/dist/model/renderable/ElementModel.d.ts.map +1 -1
  15. package/dist/model/renderable/EraserModel.d.ts +3 -2
  16. package/dist/model/renderable/EraserModel.d.ts.map +1 -1
  17. package/dist/model/renderable/ImageModel.d.ts +3 -1
  18. package/dist/model/renderable/ImageModel.d.ts.map +1 -1
  19. package/dist/model/renderable/LaserPointerModel.d.ts +3 -1
  20. package/dist/model/renderable/LaserPointerModel.d.ts.map +1 -1
  21. package/dist/model/renderable/LineModel.d.ts +3 -1
  22. package/dist/model/renderable/LineModel.d.ts.map +1 -1
  23. package/dist/model/renderable/PointTextModel.d.ts +3 -1
  24. package/dist/model/renderable/PointTextModel.d.ts.map +1 -1
  25. package/dist/model/renderable/RectangleModel.d.ts +3 -1
  26. package/dist/model/renderable/RectangleModel.d.ts.map +1 -1
  27. package/dist/model/renderable/SegmentsModel.d.ts +3 -1
  28. package/dist/model/renderable/SegmentsModel.d.ts.map +1 -1
  29. package/dist/model/renderable/SelectorModel.d.ts +3 -1
  30. package/dist/model/renderable/SelectorModel.d.ts.map +1 -1
  31. package/dist/model/renderable/StraightLineModel.d.ts +3 -1
  32. package/dist/model/renderable/StraightLineModel.d.ts.map +1 -1
  33. package/dist/model/renderable/TriangleModel.d.ts +3 -1
  34. package/dist/model/renderable/TriangleModel.d.ts.map +1 -1
  35. package/dist/tool/CurveTool.d.ts +1 -0
  36. package/dist/tool/CurveTool.d.ts.map +1 -1
  37. package/dist/tool/EllipseTool.d.ts +1 -0
  38. package/dist/tool/EllipseTool.d.ts.map +1 -1
  39. package/dist/tool/EraserTool.d.ts +3 -1
  40. package/dist/tool/EraserTool.d.ts.map +1 -1
  41. package/dist/tool/GrabTool.d.ts +1 -0
  42. package/dist/tool/GrabTool.d.ts.map +1 -1
  43. package/dist/tool/LaserPointerTool.d.ts +1 -0
  44. package/dist/tool/LaserPointerTool.d.ts.map +1 -1
  45. package/dist/tool/LineTool.d.ts +1 -0
  46. package/dist/tool/LineTool.d.ts.map +1 -1
  47. package/dist/tool/PointerTool.d.ts +1 -0
  48. package/dist/tool/PointerTool.d.ts.map +1 -1
  49. package/dist/tool/RectangleTool.d.ts +1 -0
  50. package/dist/tool/RectangleTool.d.ts.map +1 -1
  51. package/dist/tool/SelectorTool.d.ts +1 -0
  52. package/dist/tool/SelectorTool.d.ts.map +1 -1
  53. package/dist/tool/StraightLineTool.d.ts +1 -0
  54. package/dist/tool/StraightLineTool.d.ts.map +1 -1
  55. package/dist/tool/TextTool.d.ts +1 -0
  56. package/dist/tool/TextTool.d.ts.map +1 -1
  57. package/dist/tool/TriangleTool.d.ts +1 -0
  58. package/dist/tool/TriangleTool.d.ts.map +1 -1
  59. package/dist/whiteboard.esm.js +487 -181
  60. package/dist/whiteboard.esm.js.map +4 -4
  61. package/dist/whiteboard.js +487 -181
  62. package/dist/whiteboard.js.map +4 -4
  63. package/package.json +2 -2
@@ -21876,7 +21876,7 @@ var require_lodash = __commonJS({
21876
21876
  end = end === undefined2 ? length : end;
21877
21877
  return !start && end >= length ? array : baseSlice(array, start, end);
21878
21878
  }
21879
- var clearTimeout = ctxClearTimeout || function(id) {
21879
+ var clearTimeout2 = ctxClearTimeout || function(id) {
21880
21880
  return root.clearTimeout(id);
21881
21881
  };
21882
21882
  function cloneBuffer(buffer, isDeep) {
@@ -23747,7 +23747,7 @@ var require_lodash = __commonJS({
23747
23747
  }
23748
23748
  function cancel() {
23749
23749
  if (timerId !== undefined2) {
23750
- clearTimeout(timerId);
23750
+ clearTimeout2(timerId);
23751
23751
  }
23752
23752
  lastInvokeTime = 0;
23753
23753
  lastArgs = lastCallTime = lastThis = timerId = undefined2;
@@ -23765,7 +23765,7 @@ var require_lodash = __commonJS({
23765
23765
  return leadingEdge(lastCallTime);
23766
23766
  }
23767
23767
  if (maxing) {
23768
- clearTimeout(timerId);
23768
+ clearTimeout2(timerId);
23769
23769
  timerId = setTimeout2(timerExpired, wait);
23770
23770
  return invokeFunc(lastCallTime);
23771
23771
  }
@@ -25618,11 +25618,12 @@ var ElementModel = class _ElementModel {
25618
25618
  set shadow(value) {
25619
25619
  this.root.set(_ElementModel.KEYS.shadow, value);
25620
25620
  }
25621
- constructor(root, scope) {
25621
+ constructor(root, scope, liveCursor) {
25622
25622
  _defineProperty(this, "shadowEmitter", null);
25623
25623
  _defineProperty(this, "root", void 0);
25624
25624
  _defineProperty(this, "scope", void 0);
25625
25625
  _defineProperty(this, "item", void 0);
25626
+ _defineProperty(this, "liveCursor", void 0);
25626
25627
  _defineProperty(this, "handlePropChange", (events) => {
25627
25628
  if (!this.item) {
25628
25629
  return;
@@ -25631,7 +25632,7 @@ var ElementModel = class _ElementModel {
25631
25632
  if (event.target === this.root) {
25632
25633
  const updatePaperItemKeys = this.vectorKeys().concat([_ElementModel.KEYS.pointsMatrix]);
25633
25634
  for (const [key, value] of event.changes.keys.entries()) {
25634
- if (value.action === "update") {
25635
+ if (value.action === "update" || value.action == "add") {
25635
25636
  const includeKeys = this.styleKeys().include;
25636
25637
  if (includeKeys.indexOf(key) >= 0) {
25637
25638
  this.onStyleKeyUpdate(key);
@@ -25651,6 +25652,10 @@ var ElementModel = class _ElementModel {
25651
25652
  if (this.shadow !== "") {
25652
25653
  this.shadowEmitter?.emit("translateIn", [this.uuid], this.shadow);
25653
25654
  } else {
25655
+ const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
25656
+ if (ownerId) {
25657
+ this.liveCursor.updateCursorVisible(false, ownerId);
25658
+ }
25654
25659
  this.shadowEmitter?.emit("translateOut", [this.uuid], value.oldValue);
25655
25660
  }
25656
25661
  }
@@ -25658,11 +25663,17 @@ var ElementModel = class _ElementModel {
25658
25663
  }
25659
25664
  } else if (event.target === this.root.get(_ElementModel.KEYS.points)) {
25660
25665
  this.onVectorUpdate();
25666
+ const liveCursorPoint = this.liveCursorPoint();
25667
+ const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
25668
+ if (liveCursorPoint && ownerId) {
25669
+ this.liveCursor.updateCursorPosition(liveCursorPoint, this.root.get(_ElementModel.KEYS.ownerId));
25670
+ }
25661
25671
  } else {
25662
25672
  }
25663
25673
  }
25664
25674
  });
25665
25675
  this.scope = scope;
25676
+ this.liveCursor = liveCursor;
25666
25677
  this.root = root;
25667
25678
  if (!this.root.has(_ElementModel.KEYS.pointsMatrix)) {
25668
25679
  this.root.set(_ElementModel.KEYS.pointsMatrix, [1, 0, 0, 1, 0, 0]);
@@ -25794,8 +25805,8 @@ function _toPrimitive3(t, r) {
25794
25805
  return ("string" === r ? String : Number)(t);
25795
25806
  }
25796
25807
  var CurveModel = class extends ElementModel {
25797
- constructor(root, scope) {
25798
- super(root, scope);
25808
+ constructor(root, scope, liveCursor) {
25809
+ super(root, scope, liveCursor);
25799
25810
  _defineProperty3(this, "item", null);
25800
25811
  _defineProperty3(this, "debugPath", void 0);
25801
25812
  _defineProperty3(this, "debug", false);
@@ -25912,6 +25923,15 @@ var CurveModel = class extends ElementModel {
25912
25923
  exclude: ["dashArray", "fillColor"]
25913
25924
  };
25914
25925
  }
25926
+ liveCursorPoint() {
25927
+ const yArray = this.root.get(ElementModel.KEYS.points);
25928
+ if (yArray.length < 2) {
25929
+ return null;
25930
+ }
25931
+ const len = yArray.length;
25932
+ const point = new this.scope.Point(yArray.get(len - 2), yArray.get(len - 1));
25933
+ return point.transform(new this.scope.Matrix(this.pointsMatrix));
25934
+ }
25915
25935
  onStyleKeyUpdate(key) {
25916
25936
  if (!this.item) {
25917
25937
  return;
@@ -25947,8 +25967,8 @@ function _toPrimitive4(t, r) {
25947
25967
  return ("string" === r ? String : Number)(t);
25948
25968
  }
25949
25969
  var SelectorModel = class extends ElementModel {
25950
- constructor(root, scope) {
25951
- super(root, scope);
25970
+ constructor(root, scope, liveCursor) {
25971
+ super(root, scope, liveCursor);
25952
25972
  _defineProperty4(this, "item", null);
25953
25973
  if (!this.root.has("type")) {
25954
25974
  this.root.set("type", "selector");
@@ -25959,6 +25979,9 @@ var SelectorModel = class extends ElementModel {
25959
25979
  this.root.set("points", initPoints);
25960
25980
  }
25961
25981
  }
25982
+ liveCursorPoint() {
25983
+ return null;
25984
+ }
25962
25985
  subDispose() {
25963
25986
  }
25964
25987
  createPaperRect() {
@@ -26085,8 +26108,8 @@ function _toPrimitive6(t, r) {
26085
26108
  return ("string" === r ? String : Number)(t);
26086
26109
  }
26087
26110
  var SegmentsModel = class extends ElementModel {
26088
- constructor(root, scope, type) {
26089
- super(root, scope);
26111
+ constructor(root, scope, type, liveCursor) {
26112
+ super(root, scope, liveCursor);
26090
26113
  _defineProperty6(this, "item", null);
26091
26114
  if (!this.root.has("type")) {
26092
26115
  this.root.set("type", type);
@@ -26097,6 +26120,14 @@ var SegmentsModel = class extends ElementModel {
26097
26120
  }
26098
26121
  subDispose() {
26099
26122
  }
26123
+ liveCursorPoint() {
26124
+ const yArray = this.root.get(ElementModel.KEYS.points);
26125
+ if (yArray.length < 2) {
26126
+ return null;
26127
+ }
26128
+ const point = new this.scope.Point(yArray.get(0), yArray.get(1));
26129
+ return point.transform(new this.scope.Matrix(this.pointsMatrix));
26130
+ }
26100
26131
  onVectorUpdate() {
26101
26132
  if (!this.item) {
26102
26133
  return;
@@ -26222,6 +26253,7 @@ var LineTool = class extends WhiteboardTool {
26222
26253
  _defineProperty8(this, "elementModel", null);
26223
26254
  _defineProperty8(this, "from", null);
26224
26255
  _defineProperty8(this, "to", null);
26256
+ _defineProperty8(this, "showLiveCursor", true);
26225
26257
  this.tool.minDistance = 1;
26226
26258
  }
26227
26259
  onMouseDown(event) {
@@ -26286,8 +26318,8 @@ var LineModel = class extends ElementModel {
26286
26318
  set tailArrow(value) {
26287
26319
  this.root.set("tailArrow", value);
26288
26320
  }
26289
- constructor(root, scope) {
26290
- super(root, scope);
26321
+ constructor(root, scope, liveCursor) {
26322
+ super(root, scope, liveCursor);
26291
26323
  _defineProperty9(this, "controlledPoints", []);
26292
26324
  _defineProperty9(this, "item", null);
26293
26325
  if (!this.root.has("type")) {
@@ -26336,6 +26368,15 @@ var LineModel = class extends ElementModel {
26336
26368
  });
26337
26369
  return [head, path, tail];
26338
26370
  }
26371
+ liveCursorPoint() {
26372
+ const yArray = this.root.get(ElementModel.KEYS.points);
26373
+ if (yArray.length < 2) {
26374
+ return null;
26375
+ }
26376
+ const len = yArray.length;
26377
+ const point = new this.scope.Point(yArray.get(len - 2), yArray.get(len - 1));
26378
+ return point.transform(new this.scope.Matrix(this.pointsMatrix));
26379
+ }
26339
26380
  createPaperItem() {
26340
26381
  this.item = new this.scope.Group();
26341
26382
  this.item.addChildren(this.renderLine());
@@ -26487,8 +26528,8 @@ var PointTextModel = class extends ElementModel {
26487
26528
  set fontFamily(value) {
26488
26529
  this.root.set("font-family", value);
26489
26530
  }
26490
- constructor(root, scope) {
26491
- super(root, scope);
26531
+ constructor(root, scope, liveCursor) {
26532
+ super(root, scope, liveCursor);
26492
26533
  _defineProperty10(this, "item", null);
26493
26534
  _defineProperty10(this, "handleTextPropChange", (event) => {
26494
26535
  if (!this.item) {
@@ -26522,6 +26563,15 @@ var PointTextModel = class extends ElementModel {
26522
26563
  subDispose() {
26523
26564
  (0, import_forge_room2.removeObserver)(this.root, this.handleTextPropChange);
26524
26565
  }
26566
+ liveCursorPoint() {
26567
+ const points = this.points;
26568
+ if (points.length < 1) {
26569
+ return null;
26570
+ }
26571
+ const matrix = new this.scope.Matrix(this.pointsMatrix);
26572
+ const topLeft = new this.scope.Point(points[0], points[1]).transform(matrix);
26573
+ return topLeft;
26574
+ }
26525
26575
  getInternalMeasurement() {
26526
26576
  if (!this.item) {
26527
26577
  return null;
@@ -26617,8 +26667,8 @@ function _toPrimitive11(t, r) {
26617
26667
  return ("string" === r ? String : Number)(t);
26618
26668
  }
26619
26669
  var TriangleModel = class extends ElementModel {
26620
- constructor(root, scope) {
26621
- super(root, scope);
26670
+ constructor(root, scope, liveCursor) {
26671
+ super(root, scope, liveCursor);
26622
26672
  _defineProperty11(this, "item", null);
26623
26673
  if (!this.root.has("type")) {
26624
26674
  this.root.set("type", "triangle");
@@ -26627,6 +26677,15 @@ var TriangleModel = class extends ElementModel {
26627
26677
  this.root.set("points", new Y7.Array());
26628
26678
  }
26629
26679
  }
26680
+ liveCursorPoint() {
26681
+ const yArray = this.root.get(ElementModel.KEYS.points);
26682
+ if (yArray.length < 6) {
26683
+ return null;
26684
+ }
26685
+ const len = yArray.length;
26686
+ const point = new this.scope.Point(yArray.get(len - 4), yArray.get(len - 3));
26687
+ return point.transform(new this.scope.Matrix(this.pointsMatrix));
26688
+ }
26630
26689
  subDispose() {
26631
26690
  }
26632
26691
  createPaperItem() {
@@ -26709,8 +26768,8 @@ function _toPrimitive12(t, r) {
26709
26768
  return ("string" === r ? String : Number)(t);
26710
26769
  }
26711
26770
  var RectangleModel = class extends ElementModel {
26712
- constructor(root, scope) {
26713
- super(root, scope);
26771
+ constructor(root, scope, liveCursor) {
26772
+ super(root, scope, liveCursor);
26714
26773
  _defineProperty12(this, "item", null);
26715
26774
  if (!this.root.has("type")) {
26716
26775
  this.root.set("type", "rectangle");
@@ -26726,6 +26785,14 @@ var RectangleModel = class extends ElementModel {
26726
26785
  }
26727
26786
  subDispose() {
26728
26787
  }
26788
+ liveCursorPoint() {
26789
+ const points = this.points;
26790
+ if (points.length < 4) {
26791
+ return null;
26792
+ }
26793
+ const matrix = new this.scope.Matrix(this.pointsMatrix);
26794
+ return new this.scope.Point(points[2], points[3]).transform(matrix);
26795
+ }
26729
26796
  createSegments() {
26730
26797
  const [a2, b2, c, d] = this.points;
26731
26798
  const matrix = new this.scope.Matrix(this.pointsMatrix);
@@ -26885,8 +26952,8 @@ function _toPrimitive13(t, r) {
26885
26952
  return ("string" === r ? String : Number)(t);
26886
26953
  }
26887
26954
  var EraserModel = class extends ElementModel {
26888
- constructor(root, scope) {
26889
- super(root, scope);
26955
+ constructor(root, scope, liveCursor) {
26956
+ super(root, scope, liveCursor);
26890
26957
  _defineProperty13(this, "item", null);
26891
26958
  _defineProperty13(this, "sliceBegin", 0);
26892
26959
  if (!this.root.has("type")) {
@@ -26925,41 +26992,42 @@ var EraserModel = class extends ElementModel {
26925
26992
  return path;
26926
26993
  }
26927
26994
  parsePoints(points) {
26928
- return ae(points, {
26995
+ const groupPoints = (0, import_lodash5.chunk)(points, 2);
26996
+ return ae(groupPoints, {
26929
26997
  size: this.strokeWidth,
26930
- smoothing: 0,
26931
- thinning: 0.5,
26998
+ smoothing: 0.5,
26999
+ thinning: -0.5,
26932
27000
  streamline: 0.5,
26933
27001
  simulatePressure: true,
26934
27002
  start: {
26935
- taper: true,
27003
+ taper: this.strokeWidth * 10,
26936
27004
  cap: true
26937
27005
  },
26938
27006
  end: {
26939
- taper: 0,
27007
+ taper: this.strokeWidth * 20,
26940
27008
  cap: true
26941
27009
  }
26942
27010
  });
26943
27011
  }
26944
27012
  matrixedPoints() {
26945
- const matrix = new this.scope.Matrix(this.pointsMatrix);
26946
- const groupPoints = (0, import_lodash5.chunk)(this.points, 2).slice(this.sliceBegin);
26947
- return groupPoints.map((_ref) => {
27013
+ const currentPoints = (0, import_lodash5.chunk)(this.points, 2).slice(this.sliceBegin);
27014
+ return currentPoints.map((_ref) => {
26948
27015
  let [x, y] = _ref;
26949
- return matrix.transform([x, y]);
26950
- }).map((p) => [p.x, p.y]);
26951
- }
26952
- getNextSegments() {
26953
- const points = this.parsePoints(this.matrixedPoints());
26954
- const path = this.createPath(points);
26955
- return path.segments;
27016
+ return new this.scope.Point(x, y);
27017
+ }).map((p) => p.transform(new this.scope.Matrix(this.pointsMatrix))).reduce((result, next) => {
27018
+ result.push(next.x);
27019
+ result.push(next.y);
27020
+ return result;
27021
+ }, []);
26956
27022
  }
26957
27023
  onVectorUpdate() {
26958
27024
  if (!this.item) {
26959
27025
  return;
26960
27026
  }
27027
+ const points = this.parsePoints(this.matrixedPoints());
27028
+ const path = this.createPath(points);
26961
27029
  this.item.removeSegments();
26962
- this.item.addSegments(this.getNextSegments());
27030
+ this.item.addSegments(path.segments);
26963
27031
  }
26964
27032
  createPaperItem() {
26965
27033
  this.item = new this.scope.Path();
@@ -26968,21 +27036,13 @@ var EraserModel = class extends ElementModel {
26968
27036
  this.item.strokeScaling = false;
26969
27037
  this.item.strokeColor = new this.scope.Color(this.strokeColor);
26970
27038
  this.item.fillColor = new this.scope.Color(this.strokeColor);
26971
- this.item.addSegments(this.getNextSegments());
26972
- let isBegin = false;
27039
+ this.onVectorUpdate();
26973
27040
  this.item.onFrame = () => {
26974
27041
  if (!this.points) {
26975
27042
  return;
26976
27043
  }
26977
- if (this.points.length / 2 - this.sliceBegin >= 10 && !isBegin) {
26978
- isBegin = true;
26979
- }
26980
- if (this.points.length / 2 <= this.sliceBegin) {
26981
- isBegin = false;
26982
- }
26983
- if (isBegin) {
26984
- this.sliceBegin += 1;
26985
- this.onVectorUpdate();
27044
+ if (this.points.length / 2 > 50) {
27045
+ this.sliceBegin = this.points.length / 2 - 50;
26986
27046
  }
26987
27047
  };
26988
27048
  }
@@ -27003,6 +27063,15 @@ var EraserModel = class extends ElementModel {
27003
27063
  }
27004
27064
  subDispose() {
27005
27065
  }
27066
+ liveCursorPoint() {
27067
+ const yArray = this.root.get(ElementModel.KEYS.points);
27068
+ if (yArray.length < 2) {
27069
+ return null;
27070
+ }
27071
+ const len = yArray.length;
27072
+ const point = new this.scope.Point(yArray.get(len - 2), yArray.get(len - 1));
27073
+ return point.transform(new this.scope.Matrix(this.pointsMatrix));
27074
+ }
27006
27075
  };
27007
27076
 
27008
27077
  // src/model/renderable/LaserPointerModel.ts
@@ -27026,8 +27095,8 @@ function _toPrimitive14(t, r) {
27026
27095
  return ("string" === r ? String : Number)(t);
27027
27096
  }
27028
27097
  var LaserPointerModel = class extends ElementModel {
27029
- constructor(clientId, root, scope, removeElement) {
27030
- super(root, scope);
27098
+ constructor(clientId, root, scope, liveCursor, removeElement) {
27099
+ super(root, scope, liveCursor);
27031
27100
  _defineProperty14(this, "item", null);
27032
27101
  _defineProperty14(this, "clientId", void 0);
27033
27102
  _defineProperty14(this, "sliceBegin", 0);
@@ -27164,6 +27233,15 @@ var LaserPointerModel = class extends ElementModel {
27164
27233
  }
27165
27234
  subDispose() {
27166
27235
  }
27236
+ liveCursorPoint() {
27237
+ const yArray = this.root.get(ElementModel.KEYS.points);
27238
+ if (yArray.length < 2) {
27239
+ return null;
27240
+ }
27241
+ const len = yArray.length;
27242
+ const point = new this.scope.Point(yArray.get(len - 2), yArray.get(len - 1));
27243
+ return point.transform(new this.scope.Matrix(this.pointsMatrix));
27244
+ }
27167
27245
  };
27168
27246
 
27169
27247
  // src/WhitePermissions.ts
@@ -27212,8 +27290,8 @@ function _toPrimitive15(t, r) {
27212
27290
  return ("string" === r ? String : Number)(t);
27213
27291
  }
27214
27292
  var StraightLineModel = class extends ElementModel {
27215
- constructor(root, scope) {
27216
- super(root, scope);
27293
+ constructor(root, scope, liveCursor) {
27294
+ super(root, scope, liveCursor);
27217
27295
  _defineProperty15(this, "item", null);
27218
27296
  if (!this.root.has("type")) {
27219
27297
  this.root.set("type", "line");
@@ -27222,6 +27300,15 @@ var StraightLineModel = class extends ElementModel {
27222
27300
  this.root.set("points", new Y11.Array());
27223
27301
  }
27224
27302
  }
27303
+ liveCursorPoint() {
27304
+ const yArray = this.root.get(ElementModel.KEYS.points);
27305
+ if (yArray.length < 2) {
27306
+ return null;
27307
+ }
27308
+ const len = yArray.length;
27309
+ const point = new this.scope.Point(yArray.get(len - 2), yArray.get(len - 1));
27310
+ return point.transform(new this.scope.Matrix(this.pointsMatrix));
27311
+ }
27225
27312
  subDispose() {
27226
27313
  }
27227
27314
  onVectorUpdate() {
@@ -27329,8 +27416,8 @@ var ImageModel = class extends ElementModel {
27329
27416
  get src() {
27330
27417
  return this.root.get("src");
27331
27418
  }
27332
- constructor(root, scope, imageSets) {
27333
- super(root, scope);
27419
+ constructor(root, scope, imageSets, liveCursor) {
27420
+ super(root, scope, liveCursor);
27334
27421
  _defineProperty16(this, "item", null);
27335
27422
  _defineProperty16(this, "imageSets", void 0);
27336
27423
  this.imageSets = imageSets;
@@ -27382,6 +27469,9 @@ var ImageModel = class extends ElementModel {
27382
27469
  cfg.uniformScale = () => true;
27383
27470
  return cfg;
27384
27471
  }
27472
+ liveCursorPoint() {
27473
+ return null;
27474
+ }
27385
27475
  };
27386
27476
 
27387
27477
  // src/model/RenderableModel.ts
@@ -27406,7 +27496,7 @@ var RenderableModel = class extends import_eventemitter3.default {
27406
27496
  get uuid() {
27407
27497
  return (0, import_uuid.v4)().replace(/-/g, "");
27408
27498
  }
27409
- constructor(layerId, shadowEmitter, elements, scope, toolbarModel, userManager, imageSets, hasPermission) {
27499
+ constructor(layerId, shadowEmitter, elements, scope, toolbarModel, userManager, imageSets, liveCursor, hasPermission) {
27410
27500
  super();
27411
27501
  _defineProperty17(this, "scope", void 0);
27412
27502
  _defineProperty17(this, "toolbarModel", void 0);
@@ -27418,6 +27508,7 @@ var RenderableModel = class extends import_eventemitter3.default {
27418
27508
  _defineProperty17(this, "hasPermission", void 0);
27419
27509
  _defineProperty17(this, "shadowEmitter", void 0);
27420
27510
  _defineProperty17(this, "imageSets", void 0);
27511
+ _defineProperty17(this, "liveCursor", void 0);
27421
27512
  _defineProperty17(this, "onElementsChange", (event) => {
27422
27513
  for (const [key, value] of event.changes.keys.entries()) {
27423
27514
  if (value.action === "add") {
@@ -27425,7 +27516,9 @@ var RenderableModel = class extends import_eventemitter3.default {
27425
27516
  if (root) {
27426
27517
  const model = this.convertToModel(root);
27427
27518
  if (model) {
27428
- this.emit("elementInsert", [model]);
27519
+ setTimeout(() => {
27520
+ this.emit("elementInsert", [model]);
27521
+ });
27429
27522
  }
27430
27523
  }
27431
27524
  } else if (value.action === "delete") {
@@ -27433,6 +27526,7 @@ var RenderableModel = class extends import_eventemitter3.default {
27433
27526
  }
27434
27527
  }
27435
27528
  });
27529
+ this.liveCursor = liveCursor;
27436
27530
  this.imageSets = imageSets;
27437
27531
  this.hasPermission = hasPermission;
27438
27532
  this.shadowEmitter = shadowEmitter;
@@ -27472,29 +27566,29 @@ var RenderableModel = class extends import_eventemitter3.default {
27472
27566
  const type = yMap.get("type");
27473
27567
  let model = null;
27474
27568
  if (type === "curve") {
27475
- model = new CurveModel(yMap, this.scope);
27569
+ model = new CurveModel(yMap, this.scope, this.liveCursor);
27476
27570
  } else if (["ellipse"].indexOf(type) >= 0) {
27477
- model = new SegmentsModel(yMap, this.scope, type);
27571
+ model = new SegmentsModel(yMap, this.scope, type, this.liveCursor);
27478
27572
  } else if (type === "selector") {
27479
- model = new SelectorModel(yMap, this.scope);
27573
+ model = new SelectorModel(yMap, this.scope, this.liveCursor);
27480
27574
  } else if (type === "arrow") {
27481
- model = new LineModel(yMap, this.scope);
27575
+ model = new LineModel(yMap, this.scope, this.liveCursor);
27482
27576
  } else if (type === "line") {
27483
- model = new StraightLineModel(yMap, this.scope);
27577
+ model = new StraightLineModel(yMap, this.scope, this.liveCursor);
27484
27578
  } else if (type === "point-text") {
27485
- model = new PointTextModel(yMap, this.scope);
27579
+ model = new PointTextModel(yMap, this.scope, this.liveCursor);
27486
27580
  } else if (type === "triangle") {
27487
- model = new TriangleModel(yMap, this.scope);
27581
+ model = new TriangleModel(yMap, this.scope, this.liveCursor);
27488
27582
  } else if (type === "rectangle") {
27489
- model = new RectangleModel(yMap, this.scope);
27583
+ model = new RectangleModel(yMap, this.scope, this.liveCursor);
27490
27584
  } else if (type === "eraser") {
27491
- model = new EraserModel(yMap, this.scope);
27585
+ model = new EraserModel(yMap, this.scope, this.liveCursor);
27492
27586
  } else if (type === "laser") {
27493
- model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, (uuid) => {
27587
+ model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid) => {
27494
27588
  this.removeElementItem(uuid);
27495
27589
  });
27496
27590
  } else if (type === "image") {
27497
- model = new ImageModel(yMap, this.scope, this.imageSets);
27591
+ model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor);
27498
27592
  }
27499
27593
  if (model) {
27500
27594
  model.shadowEmitter = this.shadowEmitter;
@@ -27516,11 +27610,12 @@ var RenderableModel = class extends import_eventemitter3.default {
27516
27610
  removeElementItem(uuid) {
27517
27611
  this.elements.delete(uuid);
27518
27612
  }
27519
- addElementToDoc(map) {
27613
+ addElementToDoc(map, type) {
27520
27614
  this.elements.doc?.transact(() => {
27521
27615
  const uuid = this.uuid;
27522
27616
  map.set(ElementModel.KEYS.index, ++this.maxIndex);
27523
27617
  map.set(ElementModel.KEYS.uuid, uuid);
27618
+ map.set("type", type);
27524
27619
  this.elements.set(uuid, map);
27525
27620
  }, elementsUndoOrigin);
27526
27621
  }
@@ -27535,7 +27630,9 @@ var RenderableModel = class extends import_eventemitter3.default {
27535
27630
  if (!this.confirmPermission()) {
27536
27631
  return;
27537
27632
  }
27538
- const model = new ImageModel(new Y12.Map(), this.scope, this.imageSets);
27633
+ const yMap = new Y12.Map();
27634
+ this.addElementToDoc(yMap, "image");
27635
+ const model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor);
27539
27636
  model.root.set("src", src);
27540
27637
  const initMatrix = new this.scope.Matrix();
27541
27638
  const center = this.scope.project.view.center;
@@ -27545,23 +27642,25 @@ var RenderableModel = class extends import_eventemitter3.default {
27545
27642
  });
27546
27643
  model.appendPointsMatrix(initMatrix);
27547
27644
  model.ownerId = this.userManager.selfId;
27548
- this.addElementToDoc(model.root);
27549
27645
  }
27550
27646
  createCurve() {
27551
27647
  let shadow = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
27552
27648
  if (!this.confirmPermission()) {
27553
27649
  return null;
27554
27650
  }
27555
- const curveModel = new CurveModel(new Y12.Map(), this.scope);
27651
+ const yMap = new Y12.Map();
27652
+ this.addElementToDoc(yMap, "curve");
27653
+ const curveModel = new CurveModel(yMap, this.scope, this.liveCursor);
27556
27654
  this.initElement(curveModel, shadow);
27557
- this.addElementToDoc(curveModel.root);
27558
27655
  return curveModel;
27559
27656
  }
27560
27657
  createLaserPointer() {
27561
27658
  if (!this.confirmPermission()) {
27562
27659
  return null;
27563
27660
  }
27564
- const model = new LaserPointerModel(this.userManager.selfId, new Y12.Map(), this.scope, (uuid) => {
27661
+ const yMap = new Y12.Map();
27662
+ this.addElementToDoc(yMap, "laser");
27663
+ const model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid) => {
27565
27664
  this.removeElementItem(uuid);
27566
27665
  });
27567
27666
  model.strokeWidth = 8;
@@ -27569,50 +27668,53 @@ var RenderableModel = class extends import_eventemitter3.default {
27569
27668
  model.fillColor = "#F44336";
27570
27669
  model.ownerId = this.userManager.selfId;
27571
27670
  model.shadow = "layer";
27572
- this.addElementToDoc(model.root);
27573
27671
  return model;
27574
27672
  }
27575
27673
  createEraser() {
27576
27674
  if (!this.hasPermission(WhiteboardPermissionFlag.deleteSelf) && !this.hasPermission(WhiteboardPermissionFlag.deleteOthers)) {
27577
27675
  return null;
27578
27676
  }
27579
- const model = new EraserModel(new Y12.Map(), this.scope);
27580
- model.strokeWidth = 12;
27677
+ const yMap = new Y12.Map();
27678
+ this.addElementToDoc(yMap, "eraser");
27679
+ const model = new EraserModel(yMap, this.scope, this.liveCursor);
27680
+ model.strokeWidth = 4;
27581
27681
  model.strokeColor = "#9E9E9E";
27582
27682
  model.fillColor = "#9E9E9E";
27583
27683
  model.ownerId = this.userManager.selfId;
27584
27684
  model.shadow = "layer";
27585
- this.addElementToDoc(model.root);
27586
27685
  return model;
27587
27686
  }
27588
27687
  createTriangle(shadow) {
27589
27688
  if (!this.confirmPermission()) {
27590
27689
  return null;
27591
27690
  }
27592
- const triangle = new TriangleModel(new Y12.Map(), this.scope);
27691
+ const yMap = new Y12.Map();
27692
+ this.addElementToDoc(yMap, "triangle");
27693
+ const triangle = new TriangleModel(yMap, this.scope, this.liveCursor);
27593
27694
  this.initElement(triangle, shadow);
27594
27695
  triangle.dashArray = this.toolbarModel.dashArray;
27595
- this.addElementToDoc(triangle.root);
27596
27696
  return triangle;
27597
27697
  }
27598
27698
  createRectangle(shadow) {
27599
27699
  if (!this.confirmPermission()) {
27600
27700
  return null;
27601
27701
  }
27602
- const rect = new RectangleModel(new Y12.Map(), this.scope);
27702
+ const yMap = new Y12.Map();
27703
+ this.addElementToDoc(yMap, "rectangle");
27704
+ const rect = new RectangleModel(yMap, this.scope, this.liveCursor);
27603
27705
  this.initElement(rect, shadow);
27604
27706
  rect.dashArray = this.toolbarModel.dashArray;
27605
- this.addElementToDoc(rect.root);
27606
27707
  return rect;
27607
27708
  }
27608
27709
  createSegmentedPath(type, shadow) {
27609
27710
  if (!this.confirmPermission()) {
27610
27711
  return null;
27611
27712
  }
27612
- const segmentsModel = new SegmentsModel(new Y12.Map(), this.scope, type);
27713
+ const yMap = new Y12.Map();
27714
+ this.addElementToDoc(yMap, type);
27715
+ const segmentsModel = new SegmentsModel(yMap, this.scope, type, this.liveCursor);
27613
27716
  this.initElement(segmentsModel, shadow);
27614
27717
  segmentsModel.dashArray = this.toolbarModel.dashArray;
27615
- this.addElementToDoc(segmentsModel.root);
27616
27718
  return segmentsModel;
27617
27719
  }
27618
27720
  createSelector() {
@@ -27620,41 +27722,45 @@ var RenderableModel = class extends import_eventemitter3.default {
27620
27722
  if (!this.hasPermission(WhiteboardPermissionFlag.editSelf) && !this.hasPermission(WhiteboardPermissionFlag.deleteOthers)) {
27621
27723
  return null;
27622
27724
  }
27623
- const selectorModel = new SelectorModel(new Y12.Map(), this.scope);
27725
+ const yMap = new Y12.Map();
27726
+ this.addElementToDoc(yMap, "selector");
27727
+ const selectorModel = new SelectorModel(yMap, this.scope, this.liveCursor);
27624
27728
  selectorModel.shadow = "layer";
27625
- this.addElementToDoc(selectorModel.root);
27626
27729
  return selectorModel;
27627
27730
  }
27628
27731
  createStraightLine(shadow) {
27629
27732
  if (!this.confirmPermission()) {
27630
27733
  return null;
27631
27734
  }
27632
- const straightLineModel = new StraightLineModel(new Y12.Map(), this.scope);
27735
+ const yMap = new Y12.Map();
27736
+ this.addElementToDoc(yMap, "line");
27737
+ const straightLineModel = new StraightLineModel(yMap, this.scope, this.liveCursor);
27633
27738
  this.initElement(straightLineModel, shadow);
27634
27739
  straightLineModel.dashArray = this.toolbarModel.dashArray;
27635
- this.addElementToDoc(straightLineModel.root);
27636
27740
  return straightLineModel;
27637
27741
  }
27638
27742
  createLinePath(shadow) {
27639
27743
  if (!this.confirmPermission()) {
27640
27744
  return null;
27641
27745
  }
27642
- const lineModel = new LineModel(new Y12.Map(), this.scope);
27746
+ const yMap = new Y12.Map();
27747
+ this.addElementToDoc(yMap, "arrow");
27748
+ const lineModel = new LineModel(yMap, this.scope, this.liveCursor);
27643
27749
  this.initElement(lineModel, shadow);
27644
27750
  lineModel.dashArray = this.toolbarModel.dashArray;
27645
- this.addElementToDoc(lineModel.root);
27646
27751
  return lineModel;
27647
27752
  }
27648
27753
  createPointText(x, y, shadow) {
27649
27754
  if (!this.confirmPermission()) {
27650
27755
  return null;
27651
27756
  }
27652
- const pointTextModel = new PointTextModel(new Y12.Map(), this.scope);
27757
+ const yMap = new Y12.Map();
27758
+ this.addElementToDoc(yMap, "point-text");
27759
+ const pointTextModel = new PointTextModel(yMap, this.scope, this.liveCursor);
27653
27760
  pointTextModel.setPoints([x, y]);
27654
27761
  pointTextModel.fontSize = this.toolbarModel.fontSize;
27655
27762
  pointTextModel.fontFamily = this.toolbarModel.fontFamily;
27656
27763
  this.initElement(pointTextModel, shadow);
27657
- this.addElementToDoc(pointTextModel.root);
27658
27764
  return pointTextModel;
27659
27765
  }
27660
27766
  clearElement() {
@@ -27973,7 +28079,8 @@ var CurveTool = class extends WhiteboardTool {
27973
28079
  _defineProperty19(this, "elementModel", null);
27974
28080
  _defineProperty19(this, "recognizer", new Recognizer());
27975
28081
  _defineProperty19(this, "pointCount", 0);
27976
- this.tool.minDistance = 1;
28082
+ _defineProperty19(this, "showLiveCursor", true);
28083
+ this.tool.minDistance = 5;
27977
28084
  }
27978
28085
  onMouseDown(_event) {
27979
28086
  this.pointCount = 0;
@@ -28062,6 +28169,7 @@ var RectangleTool = class extends WhiteboardTool {
28062
28169
  _defineProperty20(this, "elementModel", null);
28063
28170
  _defineProperty20(this, "from", null);
28064
28171
  _defineProperty20(this, "to", null);
28172
+ _defineProperty20(this, "showLiveCursor", true);
28065
28173
  this.tool.minDistance = 1;
28066
28174
  }
28067
28175
  onMouseDown(event) {
@@ -28218,6 +28326,7 @@ var SelectorTool = class extends WhiteboardTool {
28218
28326
  _defineProperty22(this, "to", null);
28219
28327
  _defineProperty22(this, "selectElementsModel", void 0);
28220
28328
  _defineProperty22(this, "selectElements", /* @__PURE__ */ new Map());
28329
+ _defineProperty22(this, "showLiveCursor", false);
28221
28330
  this.selectElementsModel = selectElementsModel;
28222
28331
  }
28223
28332
  onMouseDown(event) {
@@ -29172,6 +29281,7 @@ var TextTool = class extends WhiteboardTool {
29172
29281
  _defineProperty26(this, "elementModel", null);
29173
29282
  _defineProperty26(this, "toolbarModel", void 0);
29174
29283
  _defineProperty26(this, "camera", void 0);
29284
+ _defineProperty26(this, "showLiveCursor", false);
29175
29285
  this.rootView = rootView;
29176
29286
  this.canvasElement = canvasElement;
29177
29287
  this.toolbarModel = toolbarModel;
@@ -29741,6 +29851,7 @@ var EllipseTool = class extends WhiteboardTool {
29741
29851
  _defineProperty29(this, "elementModel", null);
29742
29852
  _defineProperty29(this, "from", null);
29743
29853
  _defineProperty29(this, "to", null);
29854
+ _defineProperty29(this, "showLiveCursor", true);
29744
29855
  this.tool.minDistance = 1;
29745
29856
  }
29746
29857
  onMouseDown(event) {
@@ -29795,6 +29906,7 @@ var TriangleTool = class extends WhiteboardTool {
29795
29906
  _defineProperty30(this, "elementModel", null);
29796
29907
  _defineProperty30(this, "from", null);
29797
29908
  _defineProperty30(this, "to", null);
29909
+ _defineProperty30(this, "showLiveCursor", true);
29798
29910
  this.tool.minDistance = 1;
29799
29911
  }
29800
29912
  onMouseDown(event) {
@@ -29874,6 +29986,7 @@ var Whiteboard = class extends import_eventemitter38.default {
29874
29986
  _defineProperty31(this, "translateCamera", void 0);
29875
29987
  _defineProperty31(this, "scaleCamera", void 0);
29876
29988
  _defineProperty31(this, "resetCamera", void 0);
29989
+ _defineProperty31(this, "showLiveCursor", void 0);
29877
29990
  _defineProperty31(this, "setFreeModelUserPage", void 0);
29878
29991
  _defineProperty31(this, "indexedNavigation", void 0);
29879
29992
  _defineProperty31(this, "setViewModeToFree", void 0);
@@ -29910,13 +30023,16 @@ function _toPrimitive32(t, r) {
29910
30023
  return ("string" === r ? String : Number)(t);
29911
30024
  }
29912
30025
  var EraserTool = class extends WhiteboardTool {
29913
- constructor(enableToolEvent, renderableModel, shadowEmitter, scope, trashedElementsModel) {
30026
+ constructor(enableToolEvent, renderableModel, shadowEmitter, scope, trashedElementsModel, shadowScope) {
29914
30027
  super(enableToolEvent, renderableModel, shadowEmitter, scope);
29915
30028
  _defineProperty32(this, "elementModel", null);
29916
30029
  _defineProperty32(this, "trashedElementsModel", void 0);
29917
30030
  _defineProperty32(this, "pointCount", 0);
30031
+ _defineProperty32(this, "showLiveCursor", true);
30032
+ _defineProperty32(this, "shadowScope", void 0);
29918
30033
  this.trashedElementsModel = trashedElementsModel;
29919
- this.tool.minDistance = 1;
30034
+ this.tool.minDistance = 2;
30035
+ this.shadowScope = shadowScope;
29920
30036
  }
29921
30037
  onMouseDown(_event) {
29922
30038
  this.pointCount = 0;
@@ -29943,6 +30059,16 @@ var EraserTool = class extends WhiteboardTool {
29943
30059
  this.trashedElementsModel.addTrashedElementForSelf(item.data.uuid, item.data.ownerId);
29944
30060
  }
29945
30061
  });
30062
+ this.shadowScope.project.activeLayer.children.forEach((item) => {
30063
+ if (item.data.type && ["selector", "eraser", "laser"].indexOf(item.data.type) < 0 && item.hitTest(event.point, {
30064
+ segments: true,
30065
+ stroke: true,
30066
+ fill: true,
30067
+ tolerance: 5
30068
+ })) {
30069
+ this.trashedElementsModel.addTrashedElementForSelf(item.data.uuid, item.data.ownerId);
30070
+ }
30071
+ });
29946
30072
  }
29947
30073
  onMouseUp(_event) {
29948
30074
  if (this.elementModel) {
@@ -30099,6 +30225,7 @@ var LaserPointerTool = class extends WhiteboardTool {
30099
30225
  super(enableToolEvent, modelGetter, shadowEmitter, scope);
30100
30226
  _defineProperty34(this, "elementModel", null);
30101
30227
  _defineProperty34(this, "pointCount", 0);
30228
+ _defineProperty34(this, "showLiveCursor", true);
30102
30229
  this.tool.minDistance = 5;
30103
30230
  }
30104
30231
  onMouseDown(_event) {
@@ -30725,6 +30852,7 @@ var StraightLineTool = class extends WhiteboardTool {
30725
30852
  _defineProperty38(this, "elementModel", null);
30726
30853
  _defineProperty38(this, "from", null);
30727
30854
  _defineProperty38(this, "to", null);
30855
+ _defineProperty38(this, "showLiveCursor", true);
30728
30856
  this.tool.minDistance = 1;
30729
30857
  }
30730
30858
  onMouseDown(event) {
@@ -30774,6 +30902,7 @@ var GrabTool = class extends WhiteboardTool {
30774
30902
  super(enableToolEvent, modelGetter, shadowEmitter, scope);
30775
30903
  _defineProperty39(this, "camera", void 0);
30776
30904
  _defineProperty39(this, "downPoint", null);
30905
+ _defineProperty39(this, "showLiveCursor", false);
30777
30906
  this.camera = camera;
30778
30907
  }
30779
30908
  onMouseDown(event) {
@@ -30794,9 +30923,27 @@ var GrabTool = class extends WhiteboardTool {
30794
30923
  };
30795
30924
 
30796
30925
  // src/tool/PointerTool.ts
30926
+ function _defineProperty40(e, r, t) {
30927
+ return (r = _toPropertyKey40(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
30928
+ }
30929
+ function _toPropertyKey40(t) {
30930
+ var i = _toPrimitive40(t, "string");
30931
+ return "symbol" == typeof i ? i : i + "";
30932
+ }
30933
+ function _toPrimitive40(t, r) {
30934
+ if ("object" != typeof t || !t) return t;
30935
+ var e = t[Symbol.toPrimitive];
30936
+ if (void 0 !== e) {
30937
+ var i = e.call(t, r || "default");
30938
+ if ("object" != typeof i) return i;
30939
+ throw new TypeError("@@toPrimitive must return a primitive value.");
30940
+ }
30941
+ return ("string" === r ? String : Number)(t);
30942
+ }
30797
30943
  var PointerTool = class extends WhiteboardTool {
30798
30944
  constructor(enableToolEvent, modelGetter, shadowEmitter, scope) {
30799
30945
  super(enableToolEvent, modelGetter, shadowEmitter, scope);
30946
+ _defineProperty40(this, "showLiveCursor", false);
30800
30947
  }
30801
30948
  onMouseDown(_event) {
30802
30949
  }
@@ -30807,14 +30954,14 @@ var PointerTool = class extends WhiteboardTool {
30807
30954
  };
30808
30955
 
30809
30956
  // src/SequenceExecutor.ts
30810
- function _defineProperty40(e, r, t) {
30811
- return (r = _toPropertyKey40(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
30957
+ function _defineProperty41(e, r, t) {
30958
+ return (r = _toPropertyKey41(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
30812
30959
  }
30813
- function _toPropertyKey40(t) {
30814
- var i = _toPrimitive40(t, "string");
30960
+ function _toPropertyKey41(t) {
30961
+ var i = _toPrimitive41(t, "string");
30815
30962
  return "symbol" == typeof i ? i : i + "";
30816
30963
  }
30817
- function _toPrimitive40(t, r) {
30964
+ function _toPrimitive41(t, r) {
30818
30965
  if ("object" != typeof t || !t) return t;
30819
30966
  var e = t[Symbol.toPrimitive];
30820
30967
  if (void 0 !== e) {
@@ -30826,8 +30973,8 @@ function _toPrimitive40(t, r) {
30826
30973
  }
30827
30974
  var SequenceExecutor = class {
30828
30975
  constructor() {
30829
- _defineProperty40(this, "tasks", []);
30830
- _defineProperty40(this, "isRunning", false);
30976
+ _defineProperty41(this, "tasks", []);
30977
+ _defineProperty41(this, "isRunning", false);
30831
30978
  }
30832
30979
  addTask(task) {
30833
30980
  this.tasks.push(task);
@@ -30855,14 +31002,137 @@ var SequenceExecutor = class {
30855
31002
 
30856
31003
  // src/WhiteboardApplication.ts
30857
31004
  var import_forge_room13 = require("@netless/forge-room");
30858
- function _defineProperty41(e, r, t) {
30859
- return (r = _toPropertyKey41(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
31005
+
31006
+ // src/LiveCursor.ts
31007
+ function _defineProperty42(e, r, t) {
31008
+ return (r = _toPropertyKey42(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
30860
31009
  }
30861
- function _toPropertyKey41(t) {
30862
- var i = _toPrimitive41(t, "string");
31010
+ function _toPropertyKey42(t) {
31011
+ var i = _toPrimitive42(t, "string");
30863
31012
  return "symbol" == typeof i ? i : i + "";
30864
31013
  }
30865
- function _toPrimitive41(t, r) {
31014
+ function _toPrimitive42(t, r) {
31015
+ if ("object" != typeof t || !t) return t;
31016
+ var e = t[Symbol.toPrimitive];
31017
+ if (void 0 !== e) {
31018
+ var i = e.call(t, r || "default");
31019
+ if ("object" != typeof i) return i;
31020
+ throw new TypeError("@@toPrimitive must return a primitive value.");
31021
+ }
31022
+ return ("string" === r ? String : Number)(t);
31023
+ }
31024
+ var LiveCursor = class {
31025
+ constructor(canvasElement, paperScope, userManager, requestUserMap) {
31026
+ _defineProperty42(this, "container", document.createElement("div"));
31027
+ _defineProperty42(this, "showLiveCursor", true);
31028
+ _defineProperty42(this, "userManager", void 0);
31029
+ _defineProperty42(this, "requestUserMap", void 0);
31030
+ _defineProperty42(this, "cursors", /* @__PURE__ */ new Map());
31031
+ _defineProperty42(this, "paperScope", void 0);
31032
+ _defineProperty42(this, "resizeobserver", void 0);
31033
+ _defineProperty42(this, "timeoutIdMap", /* @__PURE__ */ new Map());
31034
+ _defineProperty42(this, "lastVisibleChangeTimes", /* @__PURE__ */ new Map());
31035
+ this.userManager = userManager;
31036
+ this.paperScope = paperScope;
31037
+ this.requestUserMap = requestUserMap;
31038
+ this.container.setAttribute("data-forge-cursors", "");
31039
+ this.container.style.cssText = "overflow:hidden;pointer-events:none;z-index:999;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);";
31040
+ this.container.style.pointerEvents = "none";
31041
+ this.resizeobserver = new ResizeObserver(() => {
31042
+ const bounds = canvasElement.getBoundingClientRect();
31043
+ this.container.style.width = bounds.width + "px";
31044
+ this.container.style.height = bounds.height + "px";
31045
+ });
31046
+ this.resizeobserver.observe(canvasElement);
31047
+ }
31048
+ createCursor(userId) {
31049
+ const cursor = document.createElement("fcursor");
31050
+ cursor.setAttribute("data-forge-cursor", userId);
31051
+ cursor.style.backgroundColor = this.requestUserMap(userId).get(WhiteboardKeys.themeColor);
31052
+ cursor.style.color = "#fff";
31053
+ cursor.style.position = "absolute";
31054
+ cursor.style.whiteSpace = "nowrap";
31055
+ cursor.style.display = "block";
31056
+ cursor.style.fontSize = "12px";
31057
+ cursor.style.padding = "2px 4px";
31058
+ cursor.style.borderRadius = "4px";
31059
+ cursor.textContent = this.userManager.getUser(userId)?.nickName ?? userId;
31060
+ return cursor;
31061
+ }
31062
+ isOnSamePage(userId) {
31063
+ const otherPage = this.requestUserMap(userId).get(WhiteboardKeys.currentPage);
31064
+ const selfPage = this.requestUserMap(this.userManager.selfId).get(WhiteboardKeys.currentPage);
31065
+ if (otherPage !== selfPage) {
31066
+ return false;
31067
+ }
31068
+ return true;
31069
+ }
31070
+ detectEnable(userId) {
31071
+ if (!this.showLiveCursor) {
31072
+ const cursor = this.cursors.get(userId);
31073
+ if (cursor) {
31074
+ cursor.style.display = "none";
31075
+ }
31076
+ }
31077
+ return this.showLiveCursor;
31078
+ }
31079
+ updateCursorPosition(point, userId) {
31080
+ if (!this.isOnSamePage(userId) || userId === this.userManager.selfId) {
31081
+ return;
31082
+ }
31083
+ if (!this.detectEnable(userId)) {
31084
+ return;
31085
+ }
31086
+ const lastVisibleChangeTime = this.lastVisibleChangeTimes.get(userId);
31087
+ if (lastVisibleChangeTime && Date.now() - lastVisibleChangeTime < 100) {
31088
+ return;
31089
+ }
31090
+ if (!this.cursors.has(userId)) {
31091
+ const cursor2 = this.createCursor(userId);
31092
+ this.cursors.set(userId, cursor2);
31093
+ this.container.appendChild(cursor2);
31094
+ }
31095
+ const cursor = this.cursors.get(userId);
31096
+ if (cursor) {
31097
+ const viewPoint = this.paperScope.project.view.projectToView(point);
31098
+ cursor.style.left = viewPoint.x + "px";
31099
+ cursor.style.top = viewPoint.y + "px";
31100
+ cursor.style.display = "block";
31101
+ }
31102
+ if (this.timeoutIdMap.has(userId)) {
31103
+ clearTimeout(this.timeoutIdMap.get(userId));
31104
+ }
31105
+ this.timeoutIdMap.set(userId, setTimeout(() => {
31106
+ const cursor2 = this.cursors.get(userId);
31107
+ if (cursor2) {
31108
+ cursor2.style.display = "none";
31109
+ }
31110
+ }, 5e3));
31111
+ }
31112
+ updateCursorVisible(visible, userId) {
31113
+ if (!this.isOnSamePage(userId) || userId === this.userManager.selfId) {
31114
+ return;
31115
+ }
31116
+ if (!this.detectEnable(userId)) {
31117
+ return;
31118
+ }
31119
+ this.lastVisibleChangeTimes.set(userId, Date.now());
31120
+ const cursor = this.cursors.get(userId);
31121
+ if (cursor) {
31122
+ cursor.style.display = visible ? "block" : "none";
31123
+ }
31124
+ }
31125
+ };
31126
+
31127
+ // src/WhiteboardApplication.ts
31128
+ function _defineProperty43(e, r, t) {
31129
+ return (r = _toPropertyKey43(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
31130
+ }
31131
+ function _toPropertyKey43(t) {
31132
+ var i = _toPrimitive43(t, "string");
31133
+ return "symbol" == typeof i ? i : i + "";
31134
+ }
31135
+ function _toPrimitive43(t, r) {
30866
31136
  if ("object" != typeof t || !t) return t;
30867
31137
  var e = t[Symbol.toPrimitive];
30868
31138
  if (void 0 !== e) {
@@ -30885,40 +31155,71 @@ var WhiteboardApplication = class extends import_forge_room12.AbstractApplicatio
30885
31155
  var _this;
30886
31156
  super();
30887
31157
  _this = this;
30888
- _defineProperty41(this, "name", WHITEBOARD_APP_NAME);
30889
- _defineProperty41(this, "emitter", void 0);
30890
- _defineProperty41(this, "toolbarModel", void 0);
30891
- _defineProperty41(this, "selectElementsModel", void 0);
30892
- _defineProperty41(this, "trashedElementsModel", void 0);
30893
- _defineProperty41(this, "pageModel", void 0);
30894
- _defineProperty41(this, "layers", /* @__PURE__ */ new Map());
30895
- _defineProperty41(this, "undoManagers", /* @__PURE__ */ new Map());
30896
- _defineProperty41(this, "imageSets", document.createElement("div"));
30897
- _defineProperty41(this, "rootElement", document.createElement("div"));
30898
- _defineProperty41(this, "paperScope", new import_paper.default.PaperScope());
30899
- _defineProperty41(this, "canvasElement", document.createElement("canvas"));
30900
- _defineProperty41(this, "shadowScope", new import_paper.default.PaperScope());
30901
- _defineProperty41(this, "snapshotCanvasElement", document.createElement("canvas"));
30902
- _defineProperty41(this, "snapshotScope", new import_paper.default.PaperScope());
30903
- _defineProperty41(this, "shadowCanvasElement", document.createElement("canvas"));
30904
- _defineProperty41(this, "shadowEmitter", void 0);
30905
- _defineProperty41(this, "tools", void 0);
30906
- _defineProperty41(this, "editors", /* @__PURE__ */ new Map());
30907
- _defineProperty41(this, "camera", void 0);
30908
- _defineProperty41(this, "resizeObserver", void 0);
30909
- _defineProperty41(this, "option", void 0);
30910
- _defineProperty41(this, "permissions", void 0);
30911
- _defineProperty41(this, "inputType", "any");
30912
- _defineProperty41(this, "isPenEvent", false);
30913
- _defineProperty41(this, "hasPenInput", null);
30914
- _defineProperty41(this, "disableViewModelUpdate", false);
30915
- _defineProperty41(this, "internalResizeObserver", true);
30916
- _defineProperty41(this, "sequenceExecutor", new SequenceExecutor());
30917
- _defineProperty41(this, "linkTarget", null);
30918
- _defineProperty41(this, "enableToolEvent", () => {
31158
+ _defineProperty43(this, "name", WHITEBOARD_APP_NAME);
31159
+ _defineProperty43(this, "emitter", void 0);
31160
+ _defineProperty43(this, "toolbarModel", void 0);
31161
+ _defineProperty43(this, "selectElementsModel", void 0);
31162
+ _defineProperty43(this, "trashedElementsModel", void 0);
31163
+ _defineProperty43(this, "pageModel", void 0);
31164
+ _defineProperty43(this, "layers", /* @__PURE__ */ new Map());
31165
+ _defineProperty43(this, "undoManagers", /* @__PURE__ */ new Map());
31166
+ _defineProperty43(this, "imageSets", document.createElement("div"));
31167
+ _defineProperty43(this, "rootElement", document.createElement("div"));
31168
+ _defineProperty43(this, "paperScope", new import_paper.default.PaperScope());
31169
+ _defineProperty43(this, "canvasElement", document.createElement("canvas"));
31170
+ _defineProperty43(this, "shadowScope", new import_paper.default.PaperScope());
31171
+ _defineProperty43(this, "snapshotCanvasElement", document.createElement("canvas"));
31172
+ _defineProperty43(this, "snapshotScope", new import_paper.default.PaperScope());
31173
+ _defineProperty43(this, "shadowCanvasElement", document.createElement("canvas"));
31174
+ _defineProperty43(this, "shadowEmitter", void 0);
31175
+ _defineProperty43(this, "tools", void 0);
31176
+ _defineProperty43(this, "editors", /* @__PURE__ */ new Map());
31177
+ _defineProperty43(this, "camera", void 0);
31178
+ _defineProperty43(this, "resizeObserver", void 0);
31179
+ _defineProperty43(this, "option", void 0);
31180
+ _defineProperty43(this, "permissions", void 0);
31181
+ _defineProperty43(this, "inputType", "any");
31182
+ _defineProperty43(this, "isPenEvent", false);
31183
+ _defineProperty43(this, "hasPenInput", null);
31184
+ _defineProperty43(this, "disableViewModelUpdate", false);
31185
+ _defineProperty43(this, "internalResizeObserver", true);
31186
+ _defineProperty43(this, "sequenceExecutor", new SequenceExecutor());
31187
+ _defineProperty43(this, "linkTarget", null);
31188
+ _defineProperty43(this, "liveCursor", void 0);
31189
+ _defineProperty43(this, "delayTranslateOut", -1);
31190
+ _defineProperty43(this, "enableToolEvent", () => {
30919
31191
  return !(this.inputType === "pen" && !this.isPenEvent);
30920
31192
  });
30921
- _defineProperty41(this, "handlePageSwitch", (pageId) => {
31193
+ _defineProperty43(this, "handleElementTranslateOut", (ids, container) => {
31194
+ const shadowLayer = this.shadowScope.project.activeLayer;
31195
+ let parent = null;
31196
+ if (container === "layer") {
31197
+ parent = shadowLayer;
31198
+ } else {
31199
+ parent = shadowLayer.children.find((child) => child.data.uuid === container) ?? null;
31200
+ }
31201
+ if (parent) {
31202
+ ids.forEach((id) => {
31203
+ const target = parent.children.find((child) => child.data.uuid === id);
31204
+ if (target) {
31205
+ target.remove();
31206
+ this.insertElementToParent(target, this.paperScope.project.activeLayer);
31207
+ } else {
31208
+ const pageId = this.pageModel.getCurrentPage(this.userId);
31209
+ if (pageId) {
31210
+ const page = this.layers.get(pageId);
31211
+ if (page) {
31212
+ const model = page.elementModels.get(id);
31213
+ if (model && model.item) {
31214
+ this.insertElementToParent(model.item, this.paperScope.project.activeLayer);
31215
+ }
31216
+ }
31217
+ }
31218
+ }
31219
+ });
31220
+ }
31221
+ });
31222
+ _defineProperty43(this, "handlePageSwitch", (pageId) => {
30922
31223
  this.sequenceExecutor.addTask(async () => {
30923
31224
  for (const editor of this.editors.values()) {
30924
31225
  editor.hidden();
@@ -30966,24 +31267,24 @@ var WhiteboardApplication = class extends import_forge_room12.AbstractApplicatio
30966
31267
  this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
30967
31268
  });
30968
31269
  });
30969
- _defineProperty41(this, "hasPermission", (flag) => {
31270
+ _defineProperty43(this, "hasPermission", (flag) => {
30970
31271
  return this.permissions.hasPermission(flag, this.userId);
30971
31272
  });
30972
- _defineProperty41(this, "handleStackItemAdded", () => {
31273
+ _defineProperty43(this, "handleStackItemAdded", () => {
30973
31274
  this.selectElementsModel.clearSelectElementForSelf();
30974
31275
  this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
30975
31276
  this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
30976
31277
  });
30977
- _defineProperty41(this, "handleStackItemPopped", () => {
31278
+ _defineProperty43(this, "handleStackItemPopped", () => {
30978
31279
  this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
30979
31280
  this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
30980
31281
  });
30981
- _defineProperty41(this, "handleLayersChange", (ids) => {
31282
+ _defineProperty43(this, "handleLayersChange", (ids) => {
30982
31283
  for (let i = 0, len = ids.length; i < len; i++) {
30983
31284
  const id = ids[i];
30984
31285
  if (!this.layers.has(id)) {
30985
31286
  const elementsMap = this.getMap(`layer/${id}/elements`);
30986
- const renderableModel = new RenderableModel(id, this.shadowEmitter, elementsMap, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.hasPermission);
31287
+ const renderableModel = new RenderableModel(id, this.shadowEmitter, elementsMap, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.liveCursor, this.hasPermission);
30987
31288
  this.layers.set(id, renderableModel);
30988
31289
  }
30989
31290
  if (!this.undoManagers.has(id)) {
@@ -31010,17 +31311,17 @@ var WhiteboardApplication = class extends import_forge_room12.AbstractApplicatio
31010
31311
  }
31011
31312
  }
31012
31313
  });
31013
- _defineProperty41(this, "getCurrentRenderableModel", () => {
31314
+ _defineProperty43(this, "getCurrentRenderableModel", () => {
31014
31315
  const layerId = this.userMap(this.userId).get(WhiteboardKeys.currentPage);
31015
31316
  if (!this.layers.has(layerId)) {
31016
31317
  this.emitter.emit("error", 300002, `target page: ${layerId} not found`);
31017
31318
  }
31018
31319
  return this.layers.get(layerId);
31019
31320
  });
31020
- _defineProperty41(this, "handleElementClear", () => {
31321
+ _defineProperty43(this, "handleElementClear", () => {
31021
31322
  this.paperScope.project.activeLayer.removeChildren();
31022
31323
  });
31023
- _defineProperty41(this, "handleElementInsert", (elements) => {
31324
+ _defineProperty43(this, "handleElementInsert", (elements) => {
31024
31325
  for (const element of elements) {
31025
31326
  element.createPaperElement();
31026
31327
  const scope = element.shadow === "" ? this.paperScope : this.shadowScope;
@@ -31032,7 +31333,7 @@ var WhiteboardApplication = class extends import_forge_room12.AbstractApplicatio
31032
31333
  this.insertElementToParent(element.item, scope.project.activeLayer);
31033
31334
  }
31034
31335
  });
31035
- _defineProperty41(this, "handleElementRemove", (elementId, layerId) => {
31336
+ _defineProperty43(this, "handleElementRemove", (elementId, layerId) => {
31036
31337
  const layerModel = this.layers.get(layerId);
31037
31338
  if (!layerModel) {
31038
31339
  return;
@@ -31043,11 +31344,11 @@ var WhiteboardApplication = class extends import_forge_room12.AbstractApplicatio
31043
31344
  }
31044
31345
  layerModel.elementModels.delete(elementId);
31045
31346
  });
31046
- _defineProperty41(this, "handleRemoveTrashedElementForSelf", (userId, elementId) => {
31347
+ _defineProperty43(this, "handleRemoveTrashedElementForSelf", (userId, elementId) => {
31047
31348
  const selfLayerId = this.userMap(this.userId).get(WhiteboardKeys.currentPage);
31048
31349
  this.layers.get(selfLayerId)?.removeElementItem(elementId);
31049
31350
  });
31050
- _defineProperty41(this, "handleElementsTrash", (userId, elements) => {
31351
+ _defineProperty43(this, "handleElementsTrash", (userId, elements) => {
31051
31352
  const targetLayerId = this.userMap(userId).get(WhiteboardKeys.currentPage);
31052
31353
  const selfLayerId = this.userMap(this.userId).get(WhiteboardKeys.currentPage);
31053
31354
  if (targetLayerId !== selfLayerId || !this.layers.has(targetLayerId)) {
@@ -31060,7 +31361,7 @@ var WhiteboardApplication = class extends import_forge_room12.AbstractApplicatio
31060
31361
  }
31061
31362
  });
31062
31363
  });
31063
- _defineProperty41(this, "handleElementsSelect", (userId, elements) => {
31364
+ _defineProperty43(this, "handleElementsSelect", (userId, elements) => {
31064
31365
  if (!this.editors.has(userId)) {
31065
31366
  const ctrl = this.userManager.getUser(userId);
31066
31367
  const editor2 = new Editor(this.paperScope, this.shadowScope, this.shadowEmitter, this.canvasElement, this.camera, {
@@ -31103,7 +31404,7 @@ var WhiteboardApplication = class extends import_forge_room12.AbstractApplicatio
31103
31404
  this.emitter.emit("elementDeselected", userId);
31104
31405
  }
31105
31406
  });
31106
- _defineProperty41(this, "handleLinkedMapChange", (evt) => {
31407
+ _defineProperty43(this, "handleLinkedMapChange", (evt) => {
31107
31408
  for (const [key, value] of evt.changes.keys.entries()) {
31108
31409
  if (Object.keys(TOOLBAR_KEYS).indexOf(key) >= 0 && (value.action === "add" || value.action === "update")) {
31109
31410
  this.toolbarModel.currentTool = evt.target.get(TOOLBAR_KEYS.tool);
@@ -31120,7 +31421,7 @@ var WhiteboardApplication = class extends import_forge_room12.AbstractApplicatio
31120
31421
  }
31121
31422
  }
31122
31423
  });
31123
- _defineProperty41(this, "adjustByOutFrame", (frameWidth, frameHeight) => {
31424
+ _defineProperty43(this, "adjustByOutFrame", (frameWidth, frameHeight) => {
31124
31425
  if (this.option.width > 0 && this.option.height > 0) {
31125
31426
  const minWidth = Math.max(frameWidth, 10);
31126
31427
  const minHeight = Math.max(frameHeight, 10);
@@ -31136,7 +31437,6 @@ var WhiteboardApplication = class extends import_forge_room12.AbstractApplicatio
31136
31437
  this.camera.triggerZoom();
31137
31438
  }
31138
31439
  });
31139
- window.__wb = this;
31140
31440
  requestAnimationFrameHook(this.paperScope);
31141
31441
  requestAnimationFrameHook(this.shadowScope);
31142
31442
  const that = this;
@@ -31282,7 +31582,7 @@ var WhiteboardApplication = class extends import_forge_room12.AbstractApplicatio
31282
31582
  const source = this.getMap(`layer/${sourceId}/elements`);
31283
31583
  const target = this.getMap(`layer/${targetId}/elements`);
31284
31584
  if (!this.layers.has(targetId)) {
31285
- this.layers.set(targetId, new RenderableModel(targetId, this.shadowEmitter, target, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.hasPermission));
31585
+ this.layers.set(targetId, new RenderableModel(targetId, this.shadowEmitter, target, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.liveCursor, this.hasPermission));
31286
31586
  }
31287
31587
  if (!this.undoManagers.has(targetId)) {
31288
31588
  const undoManager = new Y15.UndoManager(target, {
@@ -31332,12 +31632,23 @@ var WhiteboardApplication = class extends import_forge_room12.AbstractApplicatio
31332
31632
  this.emitter.resetCamera = () => {
31333
31633
  this.camera.reset();
31334
31634
  };
31635
+ this.emitter.showLiveCursor = (value) => {
31636
+ this.liveCursor.showLiveCursor = value;
31637
+ };
31335
31638
  this.emitter.on("error", (errorCode, errorMessage) => {
31336
31639
  (0, import_forge_room12.log)("WhiteboardApplicationError", {
31337
31640
  errorCode,
31338
31641
  errorMessage
31339
31642
  });
31340
31643
  });
31644
+ Object.defineProperty(this.emitter, "__delayTranslateOut", {
31645
+ get() {
31646
+ return that.delayTranslateOut;
31647
+ },
31648
+ set(value) {
31649
+ that.delayTranslateOut = value;
31650
+ }
31651
+ });
31341
31652
  Object.defineProperty(this.emitter, "tool", {
31342
31653
  get() {
31343
31654
  return that.toolbarModel.currentTool;
@@ -31438,6 +31749,10 @@ var WhiteboardApplication = class extends import_forge_room12.AbstractApplicatio
31438
31749
  this.emitter["permissions"] = this.permissions;
31439
31750
  this.emitter["selfUserId"] = this.userId;
31440
31751
  this.option = option;
31752
+ if (this.option.stretchToFill) {
31753
+ this.option.width = -1;
31754
+ this.option.height = -1;
31755
+ }
31441
31756
  this.userMap(this.userId).set(WhiteboardKeys.themeColor, "#009688");
31442
31757
  this.shadowEmitter = new ShadowEmitter(this.userMap(this.userId));
31443
31758
  this.pageModel = new PageModel(this.getMap("attrs"), this.userManager, (userId) => {
@@ -31486,6 +31801,9 @@ var WhiteboardApplication = class extends import_forge_room12.AbstractApplicatio
31486
31801
  this.selectElementsModel = new SelectElementsModel(this.userManager, (userId) => {
31487
31802
  return this.userMap(userId);
31488
31803
  }, this.hasPermission);
31804
+ this.liveCursor = new LiveCursor(this.canvasElement, this.paperScope, this.userManager, (userId) => {
31805
+ return this.userMap(userId);
31806
+ });
31489
31807
  this.tools = {
31490
31808
  pointer: new PointerTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
31491
31809
  curve: new CurveTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
@@ -31496,7 +31814,7 @@ var WhiteboardApplication = class extends import_forge_room12.AbstractApplicatio
31496
31814
  text: new TextTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope, this.rootElement, this.canvasElement, this.toolbarModel, this.camera),
31497
31815
  ellipse: new EllipseTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
31498
31816
  triangle: new TriangleTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
31499
- eraser: new EraserTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope, this.trashedElementsModel),
31817
+ eraser: new EraserTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope, this.trashedElementsModel, this.shadowScope),
31500
31818
  laser: new LaserPointerTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
31501
31819
  grab: new GrabTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope, this.camera)
31502
31820
  };
@@ -31568,32 +31886,12 @@ var WhiteboardApplication = class extends import_forge_room12.AbstractApplicatio
31568
31886
  }
31569
31887
  });
31570
31888
  this.shadowEmitter.on("translateOut", (ids, container) => {
31571
- const shadowLayer = this.shadowScope.project.activeLayer;
31572
- let parent = null;
31573
- if (container === "layer") {
31574
- parent = shadowLayer;
31889
+ if (this.delayTranslateOut > 0) {
31890
+ setTimeout(() => {
31891
+ this.handleElementTranslateOut(ids, container);
31892
+ }, this.delayTranslateOut);
31575
31893
  } else {
31576
- parent = shadowLayer.children.find((child) => child.data.uuid === container) ?? null;
31577
- }
31578
- if (parent) {
31579
- ids.forEach((id) => {
31580
- const target = parent.children.find((child) => child.data.uuid === id);
31581
- if (target) {
31582
- target.remove();
31583
- this.insertElementToParent(target, this.paperScope.project.activeLayer);
31584
- } else {
31585
- const pageId = this.pageModel.getCurrentPage(this.userId);
31586
- if (pageId) {
31587
- const page = this.layers.get(pageId);
31588
- if (page) {
31589
- const model = page.elementModels.get(id);
31590
- if (model && model.item) {
31591
- this.insertElementToParent(model.item, this.paperScope.project.activeLayer);
31592
- }
31593
- }
31594
- }
31595
- }
31596
- });
31894
+ this.handleElementTranslateOut(ids, container);
31597
31895
  }
31598
31896
  });
31599
31897
  this.shadowEmitter.on("translateIn", (ids, container) => {
@@ -31620,6 +31918,14 @@ var WhiteboardApplication = class extends import_forge_room12.AbstractApplicatio
31620
31918
  this.emitter.emit("grabUp");
31621
31919
  });
31622
31920
  this.clearElements();
31921
+ if (this.option.stretchToFill) {
31922
+ window.addEventListener("resize", () => {
31923
+ const bounds = document.body.getBoundingClientRect();
31924
+ this.updateOptionSize(bounds.width, bounds.height);
31925
+ this.adjustByOutFrame(bounds.width, bounds.height);
31926
+ });
31927
+ }
31928
+ this.rootElement.appendChild(this.liveCursor.container);
31623
31929
  }
31624
31930
  clearElements() {
31625
31931
  const userIds = this.userManager.userIdList();
@@ -31815,7 +32121,7 @@ var WhiteboardApplication = class extends import_forge_room12.AbstractApplicatio
31815
32121
  this.permissions.dispose();
31816
32122
  }
31817
32123
  };
31818
- _defineProperty41(WhiteboardApplication, "applicationName", WHITEBOARD_APP_NAME);
32124
+ _defineProperty43(WhiteboardApplication, "applicationName", WHITEBOARD_APP_NAME);
31819
32125
  /*! Bundled license information:
31820
32126
 
31821
32127
  paper/dist/paper-full.js: