@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
  }
@@ -25608,11 +25608,12 @@ var ElementModel = class _ElementModel {
25608
25608
  set shadow(value) {
25609
25609
  this.root.set(_ElementModel.KEYS.shadow, value);
25610
25610
  }
25611
- constructor(root, scope) {
25611
+ constructor(root, scope, liveCursor) {
25612
25612
  _defineProperty(this, "shadowEmitter", null);
25613
25613
  _defineProperty(this, "root", void 0);
25614
25614
  _defineProperty(this, "scope", void 0);
25615
25615
  _defineProperty(this, "item", void 0);
25616
+ _defineProperty(this, "liveCursor", void 0);
25616
25617
  _defineProperty(this, "handlePropChange", (events) => {
25617
25618
  if (!this.item) {
25618
25619
  return;
@@ -25621,7 +25622,7 @@ var ElementModel = class _ElementModel {
25621
25622
  if (event.target === this.root) {
25622
25623
  const updatePaperItemKeys = this.vectorKeys().concat([_ElementModel.KEYS.pointsMatrix]);
25623
25624
  for (const [key, value] of event.changes.keys.entries()) {
25624
- if (value.action === "update") {
25625
+ if (value.action === "update" || value.action == "add") {
25625
25626
  const includeKeys = this.styleKeys().include;
25626
25627
  if (includeKeys.indexOf(key) >= 0) {
25627
25628
  this.onStyleKeyUpdate(key);
@@ -25641,6 +25642,10 @@ var ElementModel = class _ElementModel {
25641
25642
  if (this.shadow !== "") {
25642
25643
  this.shadowEmitter?.emit("translateIn", [this.uuid], this.shadow);
25643
25644
  } else {
25645
+ const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
25646
+ if (ownerId) {
25647
+ this.liveCursor.updateCursorVisible(false, ownerId);
25648
+ }
25644
25649
  this.shadowEmitter?.emit("translateOut", [this.uuid], value.oldValue);
25645
25650
  }
25646
25651
  }
@@ -25648,11 +25653,17 @@ var ElementModel = class _ElementModel {
25648
25653
  }
25649
25654
  } else if (event.target === this.root.get(_ElementModel.KEYS.points)) {
25650
25655
  this.onVectorUpdate();
25656
+ const liveCursorPoint = this.liveCursorPoint();
25657
+ const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
25658
+ if (liveCursorPoint && ownerId) {
25659
+ this.liveCursor.updateCursorPosition(liveCursorPoint, this.root.get(_ElementModel.KEYS.ownerId));
25660
+ }
25651
25661
  } else {
25652
25662
  }
25653
25663
  }
25654
25664
  });
25655
25665
  this.scope = scope;
25666
+ this.liveCursor = liveCursor;
25656
25667
  this.root = root;
25657
25668
  if (!this.root.has(_ElementModel.KEYS.pointsMatrix)) {
25658
25669
  this.root.set(_ElementModel.KEYS.pointsMatrix, [1, 0, 0, 1, 0, 0]);
@@ -25784,8 +25795,8 @@ function _toPrimitive3(t, r) {
25784
25795
  return ("string" === r ? String : Number)(t);
25785
25796
  }
25786
25797
  var CurveModel = class extends ElementModel {
25787
- constructor(root, scope) {
25788
- super(root, scope);
25798
+ constructor(root, scope, liveCursor) {
25799
+ super(root, scope, liveCursor);
25789
25800
  _defineProperty3(this, "item", null);
25790
25801
  _defineProperty3(this, "debugPath", void 0);
25791
25802
  _defineProperty3(this, "debug", false);
@@ -25902,6 +25913,15 @@ var CurveModel = class extends ElementModel {
25902
25913
  exclude: ["dashArray", "fillColor"]
25903
25914
  };
25904
25915
  }
25916
+ liveCursorPoint() {
25917
+ const yArray = this.root.get(ElementModel.KEYS.points);
25918
+ if (yArray.length < 2) {
25919
+ return null;
25920
+ }
25921
+ const len = yArray.length;
25922
+ const point = new this.scope.Point(yArray.get(len - 2), yArray.get(len - 1));
25923
+ return point.transform(new this.scope.Matrix(this.pointsMatrix));
25924
+ }
25905
25925
  onStyleKeyUpdate(key) {
25906
25926
  if (!this.item) {
25907
25927
  return;
@@ -25937,8 +25957,8 @@ function _toPrimitive4(t, r) {
25937
25957
  return ("string" === r ? String : Number)(t);
25938
25958
  }
25939
25959
  var SelectorModel = class extends ElementModel {
25940
- constructor(root, scope) {
25941
- super(root, scope);
25960
+ constructor(root, scope, liveCursor) {
25961
+ super(root, scope, liveCursor);
25942
25962
  _defineProperty4(this, "item", null);
25943
25963
  if (!this.root.has("type")) {
25944
25964
  this.root.set("type", "selector");
@@ -25949,6 +25969,9 @@ var SelectorModel = class extends ElementModel {
25949
25969
  this.root.set("points", initPoints);
25950
25970
  }
25951
25971
  }
25972
+ liveCursorPoint() {
25973
+ return null;
25974
+ }
25952
25975
  subDispose() {
25953
25976
  }
25954
25977
  createPaperRect() {
@@ -26075,8 +26098,8 @@ function _toPrimitive6(t, r) {
26075
26098
  return ("string" === r ? String : Number)(t);
26076
26099
  }
26077
26100
  var SegmentsModel = class extends ElementModel {
26078
- constructor(root, scope, type) {
26079
- super(root, scope);
26101
+ constructor(root, scope, type, liveCursor) {
26102
+ super(root, scope, liveCursor);
26080
26103
  _defineProperty6(this, "item", null);
26081
26104
  if (!this.root.has("type")) {
26082
26105
  this.root.set("type", type);
@@ -26087,6 +26110,14 @@ var SegmentsModel = class extends ElementModel {
26087
26110
  }
26088
26111
  subDispose() {
26089
26112
  }
26113
+ liveCursorPoint() {
26114
+ const yArray = this.root.get(ElementModel.KEYS.points);
26115
+ if (yArray.length < 2) {
26116
+ return null;
26117
+ }
26118
+ const point = new this.scope.Point(yArray.get(0), yArray.get(1));
26119
+ return point.transform(new this.scope.Matrix(this.pointsMatrix));
26120
+ }
26090
26121
  onVectorUpdate() {
26091
26122
  if (!this.item) {
26092
26123
  return;
@@ -26212,6 +26243,7 @@ var LineTool = class extends WhiteboardTool {
26212
26243
  _defineProperty8(this, "elementModel", null);
26213
26244
  _defineProperty8(this, "from", null);
26214
26245
  _defineProperty8(this, "to", null);
26246
+ _defineProperty8(this, "showLiveCursor", true);
26215
26247
  this.tool.minDistance = 1;
26216
26248
  }
26217
26249
  onMouseDown(event) {
@@ -26276,8 +26308,8 @@ var LineModel = class extends ElementModel {
26276
26308
  set tailArrow(value) {
26277
26309
  this.root.set("tailArrow", value);
26278
26310
  }
26279
- constructor(root, scope) {
26280
- super(root, scope);
26311
+ constructor(root, scope, liveCursor) {
26312
+ super(root, scope, liveCursor);
26281
26313
  _defineProperty9(this, "controlledPoints", []);
26282
26314
  _defineProperty9(this, "item", null);
26283
26315
  if (!this.root.has("type")) {
@@ -26326,6 +26358,15 @@ var LineModel = class extends ElementModel {
26326
26358
  });
26327
26359
  return [head, path, tail];
26328
26360
  }
26361
+ liveCursorPoint() {
26362
+ const yArray = this.root.get(ElementModel.KEYS.points);
26363
+ if (yArray.length < 2) {
26364
+ return null;
26365
+ }
26366
+ const len = yArray.length;
26367
+ const point = new this.scope.Point(yArray.get(len - 2), yArray.get(len - 1));
26368
+ return point.transform(new this.scope.Matrix(this.pointsMatrix));
26369
+ }
26329
26370
  createPaperItem() {
26330
26371
  this.item = new this.scope.Group();
26331
26372
  this.item.addChildren(this.renderLine());
@@ -26477,8 +26518,8 @@ var PointTextModel = class extends ElementModel {
26477
26518
  set fontFamily(value) {
26478
26519
  this.root.set("font-family", value);
26479
26520
  }
26480
- constructor(root, scope) {
26481
- super(root, scope);
26521
+ constructor(root, scope, liveCursor) {
26522
+ super(root, scope, liveCursor);
26482
26523
  _defineProperty10(this, "item", null);
26483
26524
  _defineProperty10(this, "handleTextPropChange", (event) => {
26484
26525
  if (!this.item) {
@@ -26512,6 +26553,15 @@ var PointTextModel = class extends ElementModel {
26512
26553
  subDispose() {
26513
26554
  removeObserver(this.root, this.handleTextPropChange);
26514
26555
  }
26556
+ liveCursorPoint() {
26557
+ const points = this.points;
26558
+ if (points.length < 1) {
26559
+ return null;
26560
+ }
26561
+ const matrix = new this.scope.Matrix(this.pointsMatrix);
26562
+ const topLeft = new this.scope.Point(points[0], points[1]).transform(matrix);
26563
+ return topLeft;
26564
+ }
26515
26565
  getInternalMeasurement() {
26516
26566
  if (!this.item) {
26517
26567
  return null;
@@ -26607,8 +26657,8 @@ function _toPrimitive11(t, r) {
26607
26657
  return ("string" === r ? String : Number)(t);
26608
26658
  }
26609
26659
  var TriangleModel = class extends ElementModel {
26610
- constructor(root, scope) {
26611
- super(root, scope);
26660
+ constructor(root, scope, liveCursor) {
26661
+ super(root, scope, liveCursor);
26612
26662
  _defineProperty11(this, "item", null);
26613
26663
  if (!this.root.has("type")) {
26614
26664
  this.root.set("type", "triangle");
@@ -26617,6 +26667,15 @@ var TriangleModel = class extends ElementModel {
26617
26667
  this.root.set("points", new Y7.Array());
26618
26668
  }
26619
26669
  }
26670
+ liveCursorPoint() {
26671
+ const yArray = this.root.get(ElementModel.KEYS.points);
26672
+ if (yArray.length < 6) {
26673
+ return null;
26674
+ }
26675
+ const len = yArray.length;
26676
+ const point = new this.scope.Point(yArray.get(len - 4), yArray.get(len - 3));
26677
+ return point.transform(new this.scope.Matrix(this.pointsMatrix));
26678
+ }
26620
26679
  subDispose() {
26621
26680
  }
26622
26681
  createPaperItem() {
@@ -26699,8 +26758,8 @@ function _toPrimitive12(t, r) {
26699
26758
  return ("string" === r ? String : Number)(t);
26700
26759
  }
26701
26760
  var RectangleModel = class extends ElementModel {
26702
- constructor(root, scope) {
26703
- super(root, scope);
26761
+ constructor(root, scope, liveCursor) {
26762
+ super(root, scope, liveCursor);
26704
26763
  _defineProperty12(this, "item", null);
26705
26764
  if (!this.root.has("type")) {
26706
26765
  this.root.set("type", "rectangle");
@@ -26716,6 +26775,14 @@ var RectangleModel = class extends ElementModel {
26716
26775
  }
26717
26776
  subDispose() {
26718
26777
  }
26778
+ liveCursorPoint() {
26779
+ const points = this.points;
26780
+ if (points.length < 4) {
26781
+ return null;
26782
+ }
26783
+ const matrix = new this.scope.Matrix(this.pointsMatrix);
26784
+ return new this.scope.Point(points[2], points[3]).transform(matrix);
26785
+ }
26719
26786
  createSegments() {
26720
26787
  const [a2, b2, c, d] = this.points;
26721
26788
  const matrix = new this.scope.Matrix(this.pointsMatrix);
@@ -26875,8 +26942,8 @@ function _toPrimitive13(t, r) {
26875
26942
  return ("string" === r ? String : Number)(t);
26876
26943
  }
26877
26944
  var EraserModel = class extends ElementModel {
26878
- constructor(root, scope) {
26879
- super(root, scope);
26945
+ constructor(root, scope, liveCursor) {
26946
+ super(root, scope, liveCursor);
26880
26947
  _defineProperty13(this, "item", null);
26881
26948
  _defineProperty13(this, "sliceBegin", 0);
26882
26949
  if (!this.root.has("type")) {
@@ -26915,41 +26982,42 @@ var EraserModel = class extends ElementModel {
26915
26982
  return path;
26916
26983
  }
26917
26984
  parsePoints(points) {
26918
- return ae(points, {
26985
+ const groupPoints = (0, import_lodash5.chunk)(points, 2);
26986
+ return ae(groupPoints, {
26919
26987
  size: this.strokeWidth,
26920
- smoothing: 0,
26921
- thinning: 0.5,
26988
+ smoothing: 0.5,
26989
+ thinning: -0.5,
26922
26990
  streamline: 0.5,
26923
26991
  simulatePressure: true,
26924
26992
  start: {
26925
- taper: true,
26993
+ taper: this.strokeWidth * 10,
26926
26994
  cap: true
26927
26995
  },
26928
26996
  end: {
26929
- taper: 0,
26997
+ taper: this.strokeWidth * 20,
26930
26998
  cap: true
26931
26999
  }
26932
27000
  });
26933
27001
  }
26934
27002
  matrixedPoints() {
26935
- const matrix = new this.scope.Matrix(this.pointsMatrix);
26936
- const groupPoints = (0, import_lodash5.chunk)(this.points, 2).slice(this.sliceBegin);
26937
- return groupPoints.map((_ref) => {
27003
+ const currentPoints = (0, import_lodash5.chunk)(this.points, 2).slice(this.sliceBegin);
27004
+ return currentPoints.map((_ref) => {
26938
27005
  let [x, y] = _ref;
26939
- return matrix.transform([x, y]);
26940
- }).map((p) => [p.x, p.y]);
26941
- }
26942
- getNextSegments() {
26943
- const points = this.parsePoints(this.matrixedPoints());
26944
- const path = this.createPath(points);
26945
- return path.segments;
27006
+ return new this.scope.Point(x, y);
27007
+ }).map((p) => p.transform(new this.scope.Matrix(this.pointsMatrix))).reduce((result, next) => {
27008
+ result.push(next.x);
27009
+ result.push(next.y);
27010
+ return result;
27011
+ }, []);
26946
27012
  }
26947
27013
  onVectorUpdate() {
26948
27014
  if (!this.item) {
26949
27015
  return;
26950
27016
  }
27017
+ const points = this.parsePoints(this.matrixedPoints());
27018
+ const path = this.createPath(points);
26951
27019
  this.item.removeSegments();
26952
- this.item.addSegments(this.getNextSegments());
27020
+ this.item.addSegments(path.segments);
26953
27021
  }
26954
27022
  createPaperItem() {
26955
27023
  this.item = new this.scope.Path();
@@ -26958,21 +27026,13 @@ var EraserModel = class extends ElementModel {
26958
27026
  this.item.strokeScaling = false;
26959
27027
  this.item.strokeColor = new this.scope.Color(this.strokeColor);
26960
27028
  this.item.fillColor = new this.scope.Color(this.strokeColor);
26961
- this.item.addSegments(this.getNextSegments());
26962
- let isBegin = false;
27029
+ this.onVectorUpdate();
26963
27030
  this.item.onFrame = () => {
26964
27031
  if (!this.points) {
26965
27032
  return;
26966
27033
  }
26967
- if (this.points.length / 2 - this.sliceBegin >= 10 && !isBegin) {
26968
- isBegin = true;
26969
- }
26970
- if (this.points.length / 2 <= this.sliceBegin) {
26971
- isBegin = false;
26972
- }
26973
- if (isBegin) {
26974
- this.sliceBegin += 1;
26975
- this.onVectorUpdate();
27034
+ if (this.points.length / 2 > 50) {
27035
+ this.sliceBegin = this.points.length / 2 - 50;
26976
27036
  }
26977
27037
  };
26978
27038
  }
@@ -26993,6 +27053,15 @@ var EraserModel = class extends ElementModel {
26993
27053
  }
26994
27054
  subDispose() {
26995
27055
  }
27056
+ liveCursorPoint() {
27057
+ const yArray = this.root.get(ElementModel.KEYS.points);
27058
+ if (yArray.length < 2) {
27059
+ return null;
27060
+ }
27061
+ const len = yArray.length;
27062
+ const point = new this.scope.Point(yArray.get(len - 2), yArray.get(len - 1));
27063
+ return point.transform(new this.scope.Matrix(this.pointsMatrix));
27064
+ }
26996
27065
  };
26997
27066
 
26998
27067
  // src/model/renderable/LaserPointerModel.ts
@@ -27016,8 +27085,8 @@ function _toPrimitive14(t, r) {
27016
27085
  return ("string" === r ? String : Number)(t);
27017
27086
  }
27018
27087
  var LaserPointerModel = class extends ElementModel {
27019
- constructor(clientId, root, scope, removeElement) {
27020
- super(root, scope);
27088
+ constructor(clientId, root, scope, liveCursor, removeElement) {
27089
+ super(root, scope, liveCursor);
27021
27090
  _defineProperty14(this, "item", null);
27022
27091
  _defineProperty14(this, "clientId", void 0);
27023
27092
  _defineProperty14(this, "sliceBegin", 0);
@@ -27154,6 +27223,15 @@ var LaserPointerModel = class extends ElementModel {
27154
27223
  }
27155
27224
  subDispose() {
27156
27225
  }
27226
+ liveCursorPoint() {
27227
+ const yArray = this.root.get(ElementModel.KEYS.points);
27228
+ if (yArray.length < 2) {
27229
+ return null;
27230
+ }
27231
+ const len = yArray.length;
27232
+ const point = new this.scope.Point(yArray.get(len - 2), yArray.get(len - 1));
27233
+ return point.transform(new this.scope.Matrix(this.pointsMatrix));
27234
+ }
27157
27235
  };
27158
27236
 
27159
27237
  // src/WhitePermissions.ts
@@ -27202,8 +27280,8 @@ function _toPrimitive15(t, r) {
27202
27280
  return ("string" === r ? String : Number)(t);
27203
27281
  }
27204
27282
  var StraightLineModel = class extends ElementModel {
27205
- constructor(root, scope) {
27206
- super(root, scope);
27283
+ constructor(root, scope, liveCursor) {
27284
+ super(root, scope, liveCursor);
27207
27285
  _defineProperty15(this, "item", null);
27208
27286
  if (!this.root.has("type")) {
27209
27287
  this.root.set("type", "line");
@@ -27212,6 +27290,15 @@ var StraightLineModel = class extends ElementModel {
27212
27290
  this.root.set("points", new Y11.Array());
27213
27291
  }
27214
27292
  }
27293
+ liveCursorPoint() {
27294
+ const yArray = this.root.get(ElementModel.KEYS.points);
27295
+ if (yArray.length < 2) {
27296
+ return null;
27297
+ }
27298
+ const len = yArray.length;
27299
+ const point = new this.scope.Point(yArray.get(len - 2), yArray.get(len - 1));
27300
+ return point.transform(new this.scope.Matrix(this.pointsMatrix));
27301
+ }
27215
27302
  subDispose() {
27216
27303
  }
27217
27304
  onVectorUpdate() {
@@ -27319,8 +27406,8 @@ var ImageModel = class extends ElementModel {
27319
27406
  get src() {
27320
27407
  return this.root.get("src");
27321
27408
  }
27322
- constructor(root, scope, imageSets) {
27323
- super(root, scope);
27409
+ constructor(root, scope, imageSets, liveCursor) {
27410
+ super(root, scope, liveCursor);
27324
27411
  _defineProperty16(this, "item", null);
27325
27412
  _defineProperty16(this, "imageSets", void 0);
27326
27413
  this.imageSets = imageSets;
@@ -27372,6 +27459,9 @@ var ImageModel = class extends ElementModel {
27372
27459
  cfg.uniformScale = () => true;
27373
27460
  return cfg;
27374
27461
  }
27462
+ liveCursorPoint() {
27463
+ return null;
27464
+ }
27375
27465
  };
27376
27466
 
27377
27467
  // src/model/RenderableModel.ts
@@ -27396,7 +27486,7 @@ var RenderableModel = class extends EventEmitter {
27396
27486
  get uuid() {
27397
27487
  return uuidv4().replace(/-/g, "");
27398
27488
  }
27399
- constructor(layerId, shadowEmitter, elements, scope, toolbarModel, userManager, imageSets, hasPermission) {
27489
+ constructor(layerId, shadowEmitter, elements, scope, toolbarModel, userManager, imageSets, liveCursor, hasPermission) {
27400
27490
  super();
27401
27491
  _defineProperty17(this, "scope", void 0);
27402
27492
  _defineProperty17(this, "toolbarModel", void 0);
@@ -27408,6 +27498,7 @@ var RenderableModel = class extends EventEmitter {
27408
27498
  _defineProperty17(this, "hasPermission", void 0);
27409
27499
  _defineProperty17(this, "shadowEmitter", void 0);
27410
27500
  _defineProperty17(this, "imageSets", void 0);
27501
+ _defineProperty17(this, "liveCursor", void 0);
27411
27502
  _defineProperty17(this, "onElementsChange", (event) => {
27412
27503
  for (const [key, value] of event.changes.keys.entries()) {
27413
27504
  if (value.action === "add") {
@@ -27415,7 +27506,9 @@ var RenderableModel = class extends EventEmitter {
27415
27506
  if (root) {
27416
27507
  const model = this.convertToModel(root);
27417
27508
  if (model) {
27418
- this.emit("elementInsert", [model]);
27509
+ setTimeout(() => {
27510
+ this.emit("elementInsert", [model]);
27511
+ });
27419
27512
  }
27420
27513
  }
27421
27514
  } else if (value.action === "delete") {
@@ -27423,6 +27516,7 @@ var RenderableModel = class extends EventEmitter {
27423
27516
  }
27424
27517
  }
27425
27518
  });
27519
+ this.liveCursor = liveCursor;
27426
27520
  this.imageSets = imageSets;
27427
27521
  this.hasPermission = hasPermission;
27428
27522
  this.shadowEmitter = shadowEmitter;
@@ -27462,29 +27556,29 @@ var RenderableModel = class extends EventEmitter {
27462
27556
  const type = yMap.get("type");
27463
27557
  let model = null;
27464
27558
  if (type === "curve") {
27465
- model = new CurveModel(yMap, this.scope);
27559
+ model = new CurveModel(yMap, this.scope, this.liveCursor);
27466
27560
  } else if (["ellipse"].indexOf(type) >= 0) {
27467
- model = new SegmentsModel(yMap, this.scope, type);
27561
+ model = new SegmentsModel(yMap, this.scope, type, this.liveCursor);
27468
27562
  } else if (type === "selector") {
27469
- model = new SelectorModel(yMap, this.scope);
27563
+ model = new SelectorModel(yMap, this.scope, this.liveCursor);
27470
27564
  } else if (type === "arrow") {
27471
- model = new LineModel(yMap, this.scope);
27565
+ model = new LineModel(yMap, this.scope, this.liveCursor);
27472
27566
  } else if (type === "line") {
27473
- model = new StraightLineModel(yMap, this.scope);
27567
+ model = new StraightLineModel(yMap, this.scope, this.liveCursor);
27474
27568
  } else if (type === "point-text") {
27475
- model = new PointTextModel(yMap, this.scope);
27569
+ model = new PointTextModel(yMap, this.scope, this.liveCursor);
27476
27570
  } else if (type === "triangle") {
27477
- model = new TriangleModel(yMap, this.scope);
27571
+ model = new TriangleModel(yMap, this.scope, this.liveCursor);
27478
27572
  } else if (type === "rectangle") {
27479
- model = new RectangleModel(yMap, this.scope);
27573
+ model = new RectangleModel(yMap, this.scope, this.liveCursor);
27480
27574
  } else if (type === "eraser") {
27481
- model = new EraserModel(yMap, this.scope);
27575
+ model = new EraserModel(yMap, this.scope, this.liveCursor);
27482
27576
  } else if (type === "laser") {
27483
- model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, (uuid) => {
27577
+ model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid) => {
27484
27578
  this.removeElementItem(uuid);
27485
27579
  });
27486
27580
  } else if (type === "image") {
27487
- model = new ImageModel(yMap, this.scope, this.imageSets);
27581
+ model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor);
27488
27582
  }
27489
27583
  if (model) {
27490
27584
  model.shadowEmitter = this.shadowEmitter;
@@ -27506,11 +27600,12 @@ var RenderableModel = class extends EventEmitter {
27506
27600
  removeElementItem(uuid) {
27507
27601
  this.elements.delete(uuid);
27508
27602
  }
27509
- addElementToDoc(map) {
27603
+ addElementToDoc(map, type) {
27510
27604
  this.elements.doc?.transact(() => {
27511
27605
  const uuid = this.uuid;
27512
27606
  map.set(ElementModel.KEYS.index, ++this.maxIndex);
27513
27607
  map.set(ElementModel.KEYS.uuid, uuid);
27608
+ map.set("type", type);
27514
27609
  this.elements.set(uuid, map);
27515
27610
  }, elementsUndoOrigin);
27516
27611
  }
@@ -27525,7 +27620,9 @@ var RenderableModel = class extends EventEmitter {
27525
27620
  if (!this.confirmPermission()) {
27526
27621
  return;
27527
27622
  }
27528
- const model = new ImageModel(new Y12.Map(), this.scope, this.imageSets);
27623
+ const yMap = new Y12.Map();
27624
+ this.addElementToDoc(yMap, "image");
27625
+ const model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor);
27529
27626
  model.root.set("src", src);
27530
27627
  const initMatrix = new this.scope.Matrix();
27531
27628
  const center = this.scope.project.view.center;
@@ -27535,23 +27632,25 @@ var RenderableModel = class extends EventEmitter {
27535
27632
  });
27536
27633
  model.appendPointsMatrix(initMatrix);
27537
27634
  model.ownerId = this.userManager.selfId;
27538
- this.addElementToDoc(model.root);
27539
27635
  }
27540
27636
  createCurve() {
27541
27637
  let shadow = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
27542
27638
  if (!this.confirmPermission()) {
27543
27639
  return null;
27544
27640
  }
27545
- const curveModel = new CurveModel(new Y12.Map(), this.scope);
27641
+ const yMap = new Y12.Map();
27642
+ this.addElementToDoc(yMap, "curve");
27643
+ const curveModel = new CurveModel(yMap, this.scope, this.liveCursor);
27546
27644
  this.initElement(curveModel, shadow);
27547
- this.addElementToDoc(curveModel.root);
27548
27645
  return curveModel;
27549
27646
  }
27550
27647
  createLaserPointer() {
27551
27648
  if (!this.confirmPermission()) {
27552
27649
  return null;
27553
27650
  }
27554
- const model = new LaserPointerModel(this.userManager.selfId, new Y12.Map(), this.scope, (uuid) => {
27651
+ const yMap = new Y12.Map();
27652
+ this.addElementToDoc(yMap, "laser");
27653
+ const model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid) => {
27555
27654
  this.removeElementItem(uuid);
27556
27655
  });
27557
27656
  model.strokeWidth = 8;
@@ -27559,50 +27658,53 @@ var RenderableModel = class extends EventEmitter {
27559
27658
  model.fillColor = "#F44336";
27560
27659
  model.ownerId = this.userManager.selfId;
27561
27660
  model.shadow = "layer";
27562
- this.addElementToDoc(model.root);
27563
27661
  return model;
27564
27662
  }
27565
27663
  createEraser() {
27566
27664
  if (!this.hasPermission(WhiteboardPermissionFlag.deleteSelf) && !this.hasPermission(WhiteboardPermissionFlag.deleteOthers)) {
27567
27665
  return null;
27568
27666
  }
27569
- const model = new EraserModel(new Y12.Map(), this.scope);
27570
- model.strokeWidth = 12;
27667
+ const yMap = new Y12.Map();
27668
+ this.addElementToDoc(yMap, "eraser");
27669
+ const model = new EraserModel(yMap, this.scope, this.liveCursor);
27670
+ model.strokeWidth = 4;
27571
27671
  model.strokeColor = "#9E9E9E";
27572
27672
  model.fillColor = "#9E9E9E";
27573
27673
  model.ownerId = this.userManager.selfId;
27574
27674
  model.shadow = "layer";
27575
- this.addElementToDoc(model.root);
27576
27675
  return model;
27577
27676
  }
27578
27677
  createTriangle(shadow) {
27579
27678
  if (!this.confirmPermission()) {
27580
27679
  return null;
27581
27680
  }
27582
- const triangle = new TriangleModel(new Y12.Map(), this.scope);
27681
+ const yMap = new Y12.Map();
27682
+ this.addElementToDoc(yMap, "triangle");
27683
+ const triangle = new TriangleModel(yMap, this.scope, this.liveCursor);
27583
27684
  this.initElement(triangle, shadow);
27584
27685
  triangle.dashArray = this.toolbarModel.dashArray;
27585
- this.addElementToDoc(triangle.root);
27586
27686
  return triangle;
27587
27687
  }
27588
27688
  createRectangle(shadow) {
27589
27689
  if (!this.confirmPermission()) {
27590
27690
  return null;
27591
27691
  }
27592
- const rect = new RectangleModel(new Y12.Map(), this.scope);
27692
+ const yMap = new Y12.Map();
27693
+ this.addElementToDoc(yMap, "rectangle");
27694
+ const rect = new RectangleModel(yMap, this.scope, this.liveCursor);
27593
27695
  this.initElement(rect, shadow);
27594
27696
  rect.dashArray = this.toolbarModel.dashArray;
27595
- this.addElementToDoc(rect.root);
27596
27697
  return rect;
27597
27698
  }
27598
27699
  createSegmentedPath(type, shadow) {
27599
27700
  if (!this.confirmPermission()) {
27600
27701
  return null;
27601
27702
  }
27602
- const segmentsModel = new SegmentsModel(new Y12.Map(), this.scope, type);
27703
+ const yMap = new Y12.Map();
27704
+ this.addElementToDoc(yMap, type);
27705
+ const segmentsModel = new SegmentsModel(yMap, this.scope, type, this.liveCursor);
27603
27706
  this.initElement(segmentsModel, shadow);
27604
27707
  segmentsModel.dashArray = this.toolbarModel.dashArray;
27605
- this.addElementToDoc(segmentsModel.root);
27606
27708
  return segmentsModel;
27607
27709
  }
27608
27710
  createSelector() {
@@ -27610,41 +27712,45 @@ var RenderableModel = class extends EventEmitter {
27610
27712
  if (!this.hasPermission(WhiteboardPermissionFlag.editSelf) && !this.hasPermission(WhiteboardPermissionFlag.deleteOthers)) {
27611
27713
  return null;
27612
27714
  }
27613
- const selectorModel = new SelectorModel(new Y12.Map(), this.scope);
27715
+ const yMap = new Y12.Map();
27716
+ this.addElementToDoc(yMap, "selector");
27717
+ const selectorModel = new SelectorModel(yMap, this.scope, this.liveCursor);
27614
27718
  selectorModel.shadow = "layer";
27615
- this.addElementToDoc(selectorModel.root);
27616
27719
  return selectorModel;
27617
27720
  }
27618
27721
  createStraightLine(shadow) {
27619
27722
  if (!this.confirmPermission()) {
27620
27723
  return null;
27621
27724
  }
27622
- const straightLineModel = new StraightLineModel(new Y12.Map(), this.scope);
27725
+ const yMap = new Y12.Map();
27726
+ this.addElementToDoc(yMap, "line");
27727
+ const straightLineModel = new StraightLineModel(yMap, this.scope, this.liveCursor);
27623
27728
  this.initElement(straightLineModel, shadow);
27624
27729
  straightLineModel.dashArray = this.toolbarModel.dashArray;
27625
- this.addElementToDoc(straightLineModel.root);
27626
27730
  return straightLineModel;
27627
27731
  }
27628
27732
  createLinePath(shadow) {
27629
27733
  if (!this.confirmPermission()) {
27630
27734
  return null;
27631
27735
  }
27632
- const lineModel = new LineModel(new Y12.Map(), this.scope);
27736
+ const yMap = new Y12.Map();
27737
+ this.addElementToDoc(yMap, "arrow");
27738
+ const lineModel = new LineModel(yMap, this.scope, this.liveCursor);
27633
27739
  this.initElement(lineModel, shadow);
27634
27740
  lineModel.dashArray = this.toolbarModel.dashArray;
27635
- this.addElementToDoc(lineModel.root);
27636
27741
  return lineModel;
27637
27742
  }
27638
27743
  createPointText(x, y, shadow) {
27639
27744
  if (!this.confirmPermission()) {
27640
27745
  return null;
27641
27746
  }
27642
- const pointTextModel = new PointTextModel(new Y12.Map(), this.scope);
27747
+ const yMap = new Y12.Map();
27748
+ this.addElementToDoc(yMap, "point-text");
27749
+ const pointTextModel = new PointTextModel(yMap, this.scope, this.liveCursor);
27643
27750
  pointTextModel.setPoints([x, y]);
27644
27751
  pointTextModel.fontSize = this.toolbarModel.fontSize;
27645
27752
  pointTextModel.fontFamily = this.toolbarModel.fontFamily;
27646
27753
  this.initElement(pointTextModel, shadow);
27647
- this.addElementToDoc(pointTextModel.root);
27648
27754
  return pointTextModel;
27649
27755
  }
27650
27756
  clearElement() {
@@ -27963,7 +28069,8 @@ var CurveTool = class extends WhiteboardTool {
27963
28069
  _defineProperty19(this, "elementModel", null);
27964
28070
  _defineProperty19(this, "recognizer", new Recognizer());
27965
28071
  _defineProperty19(this, "pointCount", 0);
27966
- this.tool.minDistance = 1;
28072
+ _defineProperty19(this, "showLiveCursor", true);
28073
+ this.tool.minDistance = 5;
27967
28074
  }
27968
28075
  onMouseDown(_event) {
27969
28076
  this.pointCount = 0;
@@ -28052,6 +28159,7 @@ var RectangleTool = class extends WhiteboardTool {
28052
28159
  _defineProperty20(this, "elementModel", null);
28053
28160
  _defineProperty20(this, "from", null);
28054
28161
  _defineProperty20(this, "to", null);
28162
+ _defineProperty20(this, "showLiveCursor", true);
28055
28163
  this.tool.minDistance = 1;
28056
28164
  }
28057
28165
  onMouseDown(event) {
@@ -28208,6 +28316,7 @@ var SelectorTool = class extends WhiteboardTool {
28208
28316
  _defineProperty22(this, "to", null);
28209
28317
  _defineProperty22(this, "selectElementsModel", void 0);
28210
28318
  _defineProperty22(this, "selectElements", /* @__PURE__ */ new Map());
28319
+ _defineProperty22(this, "showLiveCursor", false);
28211
28320
  this.selectElementsModel = selectElementsModel;
28212
28321
  }
28213
28322
  onMouseDown(event) {
@@ -29162,6 +29271,7 @@ var TextTool = class extends WhiteboardTool {
29162
29271
  _defineProperty26(this, "elementModel", null);
29163
29272
  _defineProperty26(this, "toolbarModel", void 0);
29164
29273
  _defineProperty26(this, "camera", void 0);
29274
+ _defineProperty26(this, "showLiveCursor", false);
29165
29275
  this.rootView = rootView;
29166
29276
  this.canvasElement = canvasElement;
29167
29277
  this.toolbarModel = toolbarModel;
@@ -29731,6 +29841,7 @@ var EllipseTool = class extends WhiteboardTool {
29731
29841
  _defineProperty29(this, "elementModel", null);
29732
29842
  _defineProperty29(this, "from", null);
29733
29843
  _defineProperty29(this, "to", null);
29844
+ _defineProperty29(this, "showLiveCursor", true);
29734
29845
  this.tool.minDistance = 1;
29735
29846
  }
29736
29847
  onMouseDown(event) {
@@ -29785,6 +29896,7 @@ var TriangleTool = class extends WhiteboardTool {
29785
29896
  _defineProperty30(this, "elementModel", null);
29786
29897
  _defineProperty30(this, "from", null);
29787
29898
  _defineProperty30(this, "to", null);
29899
+ _defineProperty30(this, "showLiveCursor", true);
29788
29900
  this.tool.minDistance = 1;
29789
29901
  }
29790
29902
  onMouseDown(event) {
@@ -29864,6 +29976,7 @@ var Whiteboard = class extends EventEmitter8 {
29864
29976
  _defineProperty31(this, "translateCamera", void 0);
29865
29977
  _defineProperty31(this, "scaleCamera", void 0);
29866
29978
  _defineProperty31(this, "resetCamera", void 0);
29979
+ _defineProperty31(this, "showLiveCursor", void 0);
29867
29980
  _defineProperty31(this, "setFreeModelUserPage", void 0);
29868
29981
  _defineProperty31(this, "indexedNavigation", void 0);
29869
29982
  _defineProperty31(this, "setViewModeToFree", void 0);
@@ -29900,13 +30013,16 @@ function _toPrimitive32(t, r) {
29900
30013
  return ("string" === r ? String : Number)(t);
29901
30014
  }
29902
30015
  var EraserTool = class extends WhiteboardTool {
29903
- constructor(enableToolEvent, renderableModel, shadowEmitter, scope, trashedElementsModel) {
30016
+ constructor(enableToolEvent, renderableModel, shadowEmitter, scope, trashedElementsModel, shadowScope) {
29904
30017
  super(enableToolEvent, renderableModel, shadowEmitter, scope);
29905
30018
  _defineProperty32(this, "elementModel", null);
29906
30019
  _defineProperty32(this, "trashedElementsModel", void 0);
29907
30020
  _defineProperty32(this, "pointCount", 0);
30021
+ _defineProperty32(this, "showLiveCursor", true);
30022
+ _defineProperty32(this, "shadowScope", void 0);
29908
30023
  this.trashedElementsModel = trashedElementsModel;
29909
- this.tool.minDistance = 1;
30024
+ this.tool.minDistance = 2;
30025
+ this.shadowScope = shadowScope;
29910
30026
  }
29911
30027
  onMouseDown(_event) {
29912
30028
  this.pointCount = 0;
@@ -29933,6 +30049,16 @@ var EraserTool = class extends WhiteboardTool {
29933
30049
  this.trashedElementsModel.addTrashedElementForSelf(item.data.uuid, item.data.ownerId);
29934
30050
  }
29935
30051
  });
30052
+ this.shadowScope.project.activeLayer.children.forEach((item) => {
30053
+ if (item.data.type && ["selector", "eraser", "laser"].indexOf(item.data.type) < 0 && item.hitTest(event.point, {
30054
+ segments: true,
30055
+ stroke: true,
30056
+ fill: true,
30057
+ tolerance: 5
30058
+ })) {
30059
+ this.trashedElementsModel.addTrashedElementForSelf(item.data.uuid, item.data.ownerId);
30060
+ }
30061
+ });
29936
30062
  }
29937
30063
  onMouseUp(_event) {
29938
30064
  if (this.elementModel) {
@@ -30089,6 +30215,7 @@ var LaserPointerTool = class extends WhiteboardTool {
30089
30215
  super(enableToolEvent, modelGetter, shadowEmitter, scope);
30090
30216
  _defineProperty34(this, "elementModel", null);
30091
30217
  _defineProperty34(this, "pointCount", 0);
30218
+ _defineProperty34(this, "showLiveCursor", true);
30092
30219
  this.tool.minDistance = 5;
30093
30220
  }
30094
30221
  onMouseDown(_event) {
@@ -30715,6 +30842,7 @@ var StraightLineTool = class extends WhiteboardTool {
30715
30842
  _defineProperty38(this, "elementModel", null);
30716
30843
  _defineProperty38(this, "from", null);
30717
30844
  _defineProperty38(this, "to", null);
30845
+ _defineProperty38(this, "showLiveCursor", true);
30718
30846
  this.tool.minDistance = 1;
30719
30847
  }
30720
30848
  onMouseDown(event) {
@@ -30764,6 +30892,7 @@ var GrabTool = class extends WhiteboardTool {
30764
30892
  super(enableToolEvent, modelGetter, shadowEmitter, scope);
30765
30893
  _defineProperty39(this, "camera", void 0);
30766
30894
  _defineProperty39(this, "downPoint", null);
30895
+ _defineProperty39(this, "showLiveCursor", false);
30767
30896
  this.camera = camera;
30768
30897
  }
30769
30898
  onMouseDown(event) {
@@ -30784,9 +30913,27 @@ var GrabTool = class extends WhiteboardTool {
30784
30913
  };
30785
30914
 
30786
30915
  // src/tool/PointerTool.ts
30916
+ function _defineProperty40(e, r, t) {
30917
+ return (r = _toPropertyKey40(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
30918
+ }
30919
+ function _toPropertyKey40(t) {
30920
+ var i = _toPrimitive40(t, "string");
30921
+ return "symbol" == typeof i ? i : i + "";
30922
+ }
30923
+ function _toPrimitive40(t, r) {
30924
+ if ("object" != typeof t || !t) return t;
30925
+ var e = t[Symbol.toPrimitive];
30926
+ if (void 0 !== e) {
30927
+ var i = e.call(t, r || "default");
30928
+ if ("object" != typeof i) return i;
30929
+ throw new TypeError("@@toPrimitive must return a primitive value.");
30930
+ }
30931
+ return ("string" === r ? String : Number)(t);
30932
+ }
30787
30933
  var PointerTool = class extends WhiteboardTool {
30788
30934
  constructor(enableToolEvent, modelGetter, shadowEmitter, scope) {
30789
30935
  super(enableToolEvent, modelGetter, shadowEmitter, scope);
30936
+ _defineProperty40(this, "showLiveCursor", false);
30790
30937
  }
30791
30938
  onMouseDown(_event) {
30792
30939
  }
@@ -30797,14 +30944,14 @@ var PointerTool = class extends WhiteboardTool {
30797
30944
  };
30798
30945
 
30799
30946
  // src/SequenceExecutor.ts
30800
- function _defineProperty40(e, r, t) {
30801
- return (r = _toPropertyKey40(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
30947
+ function _defineProperty41(e, r, t) {
30948
+ return (r = _toPropertyKey41(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
30802
30949
  }
30803
- function _toPropertyKey40(t) {
30804
- var i = _toPrimitive40(t, "string");
30950
+ function _toPropertyKey41(t) {
30951
+ var i = _toPrimitive41(t, "string");
30805
30952
  return "symbol" == typeof i ? i : i + "";
30806
30953
  }
30807
- function _toPrimitive40(t, r) {
30954
+ function _toPrimitive41(t, r) {
30808
30955
  if ("object" != typeof t || !t) return t;
30809
30956
  var e = t[Symbol.toPrimitive];
30810
30957
  if (void 0 !== e) {
@@ -30816,8 +30963,8 @@ function _toPrimitive40(t, r) {
30816
30963
  }
30817
30964
  var SequenceExecutor = class {
30818
30965
  constructor() {
30819
- _defineProperty40(this, "tasks", []);
30820
- _defineProperty40(this, "isRunning", false);
30966
+ _defineProperty41(this, "tasks", []);
30967
+ _defineProperty41(this, "isRunning", false);
30821
30968
  }
30822
30969
  addTask(task) {
30823
30970
  this.tasks.push(task);
@@ -30845,14 +30992,137 @@ var SequenceExecutor = class {
30845
30992
 
30846
30993
  // src/WhiteboardApplication.ts
30847
30994
  import { removeObserver as removeObserver7 } from "@netless/forge-room";
30848
- function _defineProperty41(e, r, t) {
30849
- return (r = _toPropertyKey41(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
30995
+
30996
+ // src/LiveCursor.ts
30997
+ function _defineProperty42(e, r, t) {
30998
+ return (r = _toPropertyKey42(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
30850
30999
  }
30851
- function _toPropertyKey41(t) {
30852
- var i = _toPrimitive41(t, "string");
31000
+ function _toPropertyKey42(t) {
31001
+ var i = _toPrimitive42(t, "string");
30853
31002
  return "symbol" == typeof i ? i : i + "";
30854
31003
  }
30855
- function _toPrimitive41(t, r) {
31004
+ function _toPrimitive42(t, r) {
31005
+ if ("object" != typeof t || !t) return t;
31006
+ var e = t[Symbol.toPrimitive];
31007
+ if (void 0 !== e) {
31008
+ var i = e.call(t, r || "default");
31009
+ if ("object" != typeof i) return i;
31010
+ throw new TypeError("@@toPrimitive must return a primitive value.");
31011
+ }
31012
+ return ("string" === r ? String : Number)(t);
31013
+ }
31014
+ var LiveCursor = class {
31015
+ constructor(canvasElement, paperScope, userManager, requestUserMap) {
31016
+ _defineProperty42(this, "container", document.createElement("div"));
31017
+ _defineProperty42(this, "showLiveCursor", true);
31018
+ _defineProperty42(this, "userManager", void 0);
31019
+ _defineProperty42(this, "requestUserMap", void 0);
31020
+ _defineProperty42(this, "cursors", /* @__PURE__ */ new Map());
31021
+ _defineProperty42(this, "paperScope", void 0);
31022
+ _defineProperty42(this, "resizeobserver", void 0);
31023
+ _defineProperty42(this, "timeoutIdMap", /* @__PURE__ */ new Map());
31024
+ _defineProperty42(this, "lastVisibleChangeTimes", /* @__PURE__ */ new Map());
31025
+ this.userManager = userManager;
31026
+ this.paperScope = paperScope;
31027
+ this.requestUserMap = requestUserMap;
31028
+ this.container.setAttribute("data-forge-cursors", "");
31029
+ this.container.style.cssText = "overflow:hidden;pointer-events:none;z-index:999;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);";
31030
+ this.container.style.pointerEvents = "none";
31031
+ this.resizeobserver = new ResizeObserver(() => {
31032
+ const bounds = canvasElement.getBoundingClientRect();
31033
+ this.container.style.width = bounds.width + "px";
31034
+ this.container.style.height = bounds.height + "px";
31035
+ });
31036
+ this.resizeobserver.observe(canvasElement);
31037
+ }
31038
+ createCursor(userId) {
31039
+ const cursor = document.createElement("fcursor");
31040
+ cursor.setAttribute("data-forge-cursor", userId);
31041
+ cursor.style.backgroundColor = this.requestUserMap(userId).get(WhiteboardKeys.themeColor);
31042
+ cursor.style.color = "#fff";
31043
+ cursor.style.position = "absolute";
31044
+ cursor.style.whiteSpace = "nowrap";
31045
+ cursor.style.display = "block";
31046
+ cursor.style.fontSize = "12px";
31047
+ cursor.style.padding = "2px 4px";
31048
+ cursor.style.borderRadius = "4px";
31049
+ cursor.textContent = this.userManager.getUser(userId)?.nickName ?? userId;
31050
+ return cursor;
31051
+ }
31052
+ isOnSamePage(userId) {
31053
+ const otherPage = this.requestUserMap(userId).get(WhiteboardKeys.currentPage);
31054
+ const selfPage = this.requestUserMap(this.userManager.selfId).get(WhiteboardKeys.currentPage);
31055
+ if (otherPage !== selfPage) {
31056
+ return false;
31057
+ }
31058
+ return true;
31059
+ }
31060
+ detectEnable(userId) {
31061
+ if (!this.showLiveCursor) {
31062
+ const cursor = this.cursors.get(userId);
31063
+ if (cursor) {
31064
+ cursor.style.display = "none";
31065
+ }
31066
+ }
31067
+ return this.showLiveCursor;
31068
+ }
31069
+ updateCursorPosition(point, userId) {
31070
+ if (!this.isOnSamePage(userId) || userId === this.userManager.selfId) {
31071
+ return;
31072
+ }
31073
+ if (!this.detectEnable(userId)) {
31074
+ return;
31075
+ }
31076
+ const lastVisibleChangeTime = this.lastVisibleChangeTimes.get(userId);
31077
+ if (lastVisibleChangeTime && Date.now() - lastVisibleChangeTime < 100) {
31078
+ return;
31079
+ }
31080
+ if (!this.cursors.has(userId)) {
31081
+ const cursor2 = this.createCursor(userId);
31082
+ this.cursors.set(userId, cursor2);
31083
+ this.container.appendChild(cursor2);
31084
+ }
31085
+ const cursor = this.cursors.get(userId);
31086
+ if (cursor) {
31087
+ const viewPoint = this.paperScope.project.view.projectToView(point);
31088
+ cursor.style.left = viewPoint.x + "px";
31089
+ cursor.style.top = viewPoint.y + "px";
31090
+ cursor.style.display = "block";
31091
+ }
31092
+ if (this.timeoutIdMap.has(userId)) {
31093
+ clearTimeout(this.timeoutIdMap.get(userId));
31094
+ }
31095
+ this.timeoutIdMap.set(userId, setTimeout(() => {
31096
+ const cursor2 = this.cursors.get(userId);
31097
+ if (cursor2) {
31098
+ cursor2.style.display = "none";
31099
+ }
31100
+ }, 5e3));
31101
+ }
31102
+ updateCursorVisible(visible, userId) {
31103
+ if (!this.isOnSamePage(userId) || userId === this.userManager.selfId) {
31104
+ return;
31105
+ }
31106
+ if (!this.detectEnable(userId)) {
31107
+ return;
31108
+ }
31109
+ this.lastVisibleChangeTimes.set(userId, Date.now());
31110
+ const cursor = this.cursors.get(userId);
31111
+ if (cursor) {
31112
+ cursor.style.display = visible ? "block" : "none";
31113
+ }
31114
+ }
31115
+ };
31116
+
31117
+ // src/WhiteboardApplication.ts
31118
+ function _defineProperty43(e, r, t) {
31119
+ return (r = _toPropertyKey43(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
31120
+ }
31121
+ function _toPropertyKey43(t) {
31122
+ var i = _toPrimitive43(t, "string");
31123
+ return "symbol" == typeof i ? i : i + "";
31124
+ }
31125
+ function _toPrimitive43(t, r) {
30856
31126
  if ("object" != typeof t || !t) return t;
30857
31127
  var e = t[Symbol.toPrimitive];
30858
31128
  if (void 0 !== e) {
@@ -30875,40 +31145,71 @@ var WhiteboardApplication = class extends AbstractApplication {
30875
31145
  var _this;
30876
31146
  super();
30877
31147
  _this = this;
30878
- _defineProperty41(this, "name", WHITEBOARD_APP_NAME);
30879
- _defineProperty41(this, "emitter", void 0);
30880
- _defineProperty41(this, "toolbarModel", void 0);
30881
- _defineProperty41(this, "selectElementsModel", void 0);
30882
- _defineProperty41(this, "trashedElementsModel", void 0);
30883
- _defineProperty41(this, "pageModel", void 0);
30884
- _defineProperty41(this, "layers", /* @__PURE__ */ new Map());
30885
- _defineProperty41(this, "undoManagers", /* @__PURE__ */ new Map());
30886
- _defineProperty41(this, "imageSets", document.createElement("div"));
30887
- _defineProperty41(this, "rootElement", document.createElement("div"));
30888
- _defineProperty41(this, "paperScope", new import_paper.default.PaperScope());
30889
- _defineProperty41(this, "canvasElement", document.createElement("canvas"));
30890
- _defineProperty41(this, "shadowScope", new import_paper.default.PaperScope());
30891
- _defineProperty41(this, "snapshotCanvasElement", document.createElement("canvas"));
30892
- _defineProperty41(this, "snapshotScope", new import_paper.default.PaperScope());
30893
- _defineProperty41(this, "shadowCanvasElement", document.createElement("canvas"));
30894
- _defineProperty41(this, "shadowEmitter", void 0);
30895
- _defineProperty41(this, "tools", void 0);
30896
- _defineProperty41(this, "editors", /* @__PURE__ */ new Map());
30897
- _defineProperty41(this, "camera", void 0);
30898
- _defineProperty41(this, "resizeObserver", void 0);
30899
- _defineProperty41(this, "option", void 0);
30900
- _defineProperty41(this, "permissions", void 0);
30901
- _defineProperty41(this, "inputType", "any");
30902
- _defineProperty41(this, "isPenEvent", false);
30903
- _defineProperty41(this, "hasPenInput", null);
30904
- _defineProperty41(this, "disableViewModelUpdate", false);
30905
- _defineProperty41(this, "internalResizeObserver", true);
30906
- _defineProperty41(this, "sequenceExecutor", new SequenceExecutor());
30907
- _defineProperty41(this, "linkTarget", null);
30908
- _defineProperty41(this, "enableToolEvent", () => {
31148
+ _defineProperty43(this, "name", WHITEBOARD_APP_NAME);
31149
+ _defineProperty43(this, "emitter", void 0);
31150
+ _defineProperty43(this, "toolbarModel", void 0);
31151
+ _defineProperty43(this, "selectElementsModel", void 0);
31152
+ _defineProperty43(this, "trashedElementsModel", void 0);
31153
+ _defineProperty43(this, "pageModel", void 0);
31154
+ _defineProperty43(this, "layers", /* @__PURE__ */ new Map());
31155
+ _defineProperty43(this, "undoManagers", /* @__PURE__ */ new Map());
31156
+ _defineProperty43(this, "imageSets", document.createElement("div"));
31157
+ _defineProperty43(this, "rootElement", document.createElement("div"));
31158
+ _defineProperty43(this, "paperScope", new import_paper.default.PaperScope());
31159
+ _defineProperty43(this, "canvasElement", document.createElement("canvas"));
31160
+ _defineProperty43(this, "shadowScope", new import_paper.default.PaperScope());
31161
+ _defineProperty43(this, "snapshotCanvasElement", document.createElement("canvas"));
31162
+ _defineProperty43(this, "snapshotScope", new import_paper.default.PaperScope());
31163
+ _defineProperty43(this, "shadowCanvasElement", document.createElement("canvas"));
31164
+ _defineProperty43(this, "shadowEmitter", void 0);
31165
+ _defineProperty43(this, "tools", void 0);
31166
+ _defineProperty43(this, "editors", /* @__PURE__ */ new Map());
31167
+ _defineProperty43(this, "camera", void 0);
31168
+ _defineProperty43(this, "resizeObserver", void 0);
31169
+ _defineProperty43(this, "option", void 0);
31170
+ _defineProperty43(this, "permissions", void 0);
31171
+ _defineProperty43(this, "inputType", "any");
31172
+ _defineProperty43(this, "isPenEvent", false);
31173
+ _defineProperty43(this, "hasPenInput", null);
31174
+ _defineProperty43(this, "disableViewModelUpdate", false);
31175
+ _defineProperty43(this, "internalResizeObserver", true);
31176
+ _defineProperty43(this, "sequenceExecutor", new SequenceExecutor());
31177
+ _defineProperty43(this, "linkTarget", null);
31178
+ _defineProperty43(this, "liveCursor", void 0);
31179
+ _defineProperty43(this, "delayTranslateOut", -1);
31180
+ _defineProperty43(this, "enableToolEvent", () => {
30909
31181
  return !(this.inputType === "pen" && !this.isPenEvent);
30910
31182
  });
30911
- _defineProperty41(this, "handlePageSwitch", (pageId) => {
31183
+ _defineProperty43(this, "handleElementTranslateOut", (ids, container) => {
31184
+ const shadowLayer = this.shadowScope.project.activeLayer;
31185
+ let parent = null;
31186
+ if (container === "layer") {
31187
+ parent = shadowLayer;
31188
+ } else {
31189
+ parent = shadowLayer.children.find((child) => child.data.uuid === container) ?? null;
31190
+ }
31191
+ if (parent) {
31192
+ ids.forEach((id) => {
31193
+ const target = parent.children.find((child) => child.data.uuid === id);
31194
+ if (target) {
31195
+ target.remove();
31196
+ this.insertElementToParent(target, this.paperScope.project.activeLayer);
31197
+ } else {
31198
+ const pageId = this.pageModel.getCurrentPage(this.userId);
31199
+ if (pageId) {
31200
+ const page = this.layers.get(pageId);
31201
+ if (page) {
31202
+ const model = page.elementModels.get(id);
31203
+ if (model && model.item) {
31204
+ this.insertElementToParent(model.item, this.paperScope.project.activeLayer);
31205
+ }
31206
+ }
31207
+ }
31208
+ }
31209
+ });
31210
+ }
31211
+ });
31212
+ _defineProperty43(this, "handlePageSwitch", (pageId) => {
30912
31213
  this.sequenceExecutor.addTask(async () => {
30913
31214
  for (const editor of this.editors.values()) {
30914
31215
  editor.hidden();
@@ -30956,24 +31257,24 @@ var WhiteboardApplication = class extends AbstractApplication {
30956
31257
  this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
30957
31258
  });
30958
31259
  });
30959
- _defineProperty41(this, "hasPermission", (flag) => {
31260
+ _defineProperty43(this, "hasPermission", (flag) => {
30960
31261
  return this.permissions.hasPermission(flag, this.userId);
30961
31262
  });
30962
- _defineProperty41(this, "handleStackItemAdded", () => {
31263
+ _defineProperty43(this, "handleStackItemAdded", () => {
30963
31264
  this.selectElementsModel.clearSelectElementForSelf();
30964
31265
  this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
30965
31266
  this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
30966
31267
  });
30967
- _defineProperty41(this, "handleStackItemPopped", () => {
31268
+ _defineProperty43(this, "handleStackItemPopped", () => {
30968
31269
  this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
30969
31270
  this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
30970
31271
  });
30971
- _defineProperty41(this, "handleLayersChange", (ids) => {
31272
+ _defineProperty43(this, "handleLayersChange", (ids) => {
30972
31273
  for (let i = 0, len = ids.length; i < len; i++) {
30973
31274
  const id = ids[i];
30974
31275
  if (!this.layers.has(id)) {
30975
31276
  const elementsMap = this.getMap(`layer/${id}/elements`);
30976
- const renderableModel = new RenderableModel(id, this.shadowEmitter, elementsMap, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.hasPermission);
31277
+ const renderableModel = new RenderableModel(id, this.shadowEmitter, elementsMap, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.liveCursor, this.hasPermission);
30977
31278
  this.layers.set(id, renderableModel);
30978
31279
  }
30979
31280
  if (!this.undoManagers.has(id)) {
@@ -31000,17 +31301,17 @@ var WhiteboardApplication = class extends AbstractApplication {
31000
31301
  }
31001
31302
  }
31002
31303
  });
31003
- _defineProperty41(this, "getCurrentRenderableModel", () => {
31304
+ _defineProperty43(this, "getCurrentRenderableModel", () => {
31004
31305
  const layerId = this.userMap(this.userId).get(WhiteboardKeys.currentPage);
31005
31306
  if (!this.layers.has(layerId)) {
31006
31307
  this.emitter.emit("error", 300002, `target page: ${layerId} not found`);
31007
31308
  }
31008
31309
  return this.layers.get(layerId);
31009
31310
  });
31010
- _defineProperty41(this, "handleElementClear", () => {
31311
+ _defineProperty43(this, "handleElementClear", () => {
31011
31312
  this.paperScope.project.activeLayer.removeChildren();
31012
31313
  });
31013
- _defineProperty41(this, "handleElementInsert", (elements) => {
31314
+ _defineProperty43(this, "handleElementInsert", (elements) => {
31014
31315
  for (const element of elements) {
31015
31316
  element.createPaperElement();
31016
31317
  const scope = element.shadow === "" ? this.paperScope : this.shadowScope;
@@ -31022,7 +31323,7 @@ var WhiteboardApplication = class extends AbstractApplication {
31022
31323
  this.insertElementToParent(element.item, scope.project.activeLayer);
31023
31324
  }
31024
31325
  });
31025
- _defineProperty41(this, "handleElementRemove", (elementId, layerId) => {
31326
+ _defineProperty43(this, "handleElementRemove", (elementId, layerId) => {
31026
31327
  const layerModel = this.layers.get(layerId);
31027
31328
  if (!layerModel) {
31028
31329
  return;
@@ -31033,11 +31334,11 @@ var WhiteboardApplication = class extends AbstractApplication {
31033
31334
  }
31034
31335
  layerModel.elementModels.delete(elementId);
31035
31336
  });
31036
- _defineProperty41(this, "handleRemoveTrashedElementForSelf", (userId, elementId) => {
31337
+ _defineProperty43(this, "handleRemoveTrashedElementForSelf", (userId, elementId) => {
31037
31338
  const selfLayerId = this.userMap(this.userId).get(WhiteboardKeys.currentPage);
31038
31339
  this.layers.get(selfLayerId)?.removeElementItem(elementId);
31039
31340
  });
31040
- _defineProperty41(this, "handleElementsTrash", (userId, elements) => {
31341
+ _defineProperty43(this, "handleElementsTrash", (userId, elements) => {
31041
31342
  const targetLayerId = this.userMap(userId).get(WhiteboardKeys.currentPage);
31042
31343
  const selfLayerId = this.userMap(this.userId).get(WhiteboardKeys.currentPage);
31043
31344
  if (targetLayerId !== selfLayerId || !this.layers.has(targetLayerId)) {
@@ -31050,7 +31351,7 @@ var WhiteboardApplication = class extends AbstractApplication {
31050
31351
  }
31051
31352
  });
31052
31353
  });
31053
- _defineProperty41(this, "handleElementsSelect", (userId, elements) => {
31354
+ _defineProperty43(this, "handleElementsSelect", (userId, elements) => {
31054
31355
  if (!this.editors.has(userId)) {
31055
31356
  const ctrl = this.userManager.getUser(userId);
31056
31357
  const editor2 = new Editor(this.paperScope, this.shadowScope, this.shadowEmitter, this.canvasElement, this.camera, {
@@ -31093,7 +31394,7 @@ var WhiteboardApplication = class extends AbstractApplication {
31093
31394
  this.emitter.emit("elementDeselected", userId);
31094
31395
  }
31095
31396
  });
31096
- _defineProperty41(this, "handleLinkedMapChange", (evt) => {
31397
+ _defineProperty43(this, "handleLinkedMapChange", (evt) => {
31097
31398
  for (const [key, value] of evt.changes.keys.entries()) {
31098
31399
  if (Object.keys(TOOLBAR_KEYS).indexOf(key) >= 0 && (value.action === "add" || value.action === "update")) {
31099
31400
  this.toolbarModel.currentTool = evt.target.get(TOOLBAR_KEYS.tool);
@@ -31110,7 +31411,7 @@ var WhiteboardApplication = class extends AbstractApplication {
31110
31411
  }
31111
31412
  }
31112
31413
  });
31113
- _defineProperty41(this, "adjustByOutFrame", (frameWidth, frameHeight) => {
31414
+ _defineProperty43(this, "adjustByOutFrame", (frameWidth, frameHeight) => {
31114
31415
  if (this.option.width > 0 && this.option.height > 0) {
31115
31416
  const minWidth = Math.max(frameWidth, 10);
31116
31417
  const minHeight = Math.max(frameHeight, 10);
@@ -31126,7 +31427,6 @@ var WhiteboardApplication = class extends AbstractApplication {
31126
31427
  this.camera.triggerZoom();
31127
31428
  }
31128
31429
  });
31129
- window.__wb = this;
31130
31430
  requestAnimationFrameHook(this.paperScope);
31131
31431
  requestAnimationFrameHook(this.shadowScope);
31132
31432
  const that = this;
@@ -31272,7 +31572,7 @@ var WhiteboardApplication = class extends AbstractApplication {
31272
31572
  const source = this.getMap(`layer/${sourceId}/elements`);
31273
31573
  const target = this.getMap(`layer/${targetId}/elements`);
31274
31574
  if (!this.layers.has(targetId)) {
31275
- this.layers.set(targetId, new RenderableModel(targetId, this.shadowEmitter, target, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.hasPermission));
31575
+ this.layers.set(targetId, new RenderableModel(targetId, this.shadowEmitter, target, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.liveCursor, this.hasPermission));
31276
31576
  }
31277
31577
  if (!this.undoManagers.has(targetId)) {
31278
31578
  const undoManager = new Y15.UndoManager(target, {
@@ -31322,12 +31622,23 @@ var WhiteboardApplication = class extends AbstractApplication {
31322
31622
  this.emitter.resetCamera = () => {
31323
31623
  this.camera.reset();
31324
31624
  };
31625
+ this.emitter.showLiveCursor = (value) => {
31626
+ this.liveCursor.showLiveCursor = value;
31627
+ };
31325
31628
  this.emitter.on("error", (errorCode, errorMessage) => {
31326
31629
  log4("WhiteboardApplicationError", {
31327
31630
  errorCode,
31328
31631
  errorMessage
31329
31632
  });
31330
31633
  });
31634
+ Object.defineProperty(this.emitter, "__delayTranslateOut", {
31635
+ get() {
31636
+ return that.delayTranslateOut;
31637
+ },
31638
+ set(value) {
31639
+ that.delayTranslateOut = value;
31640
+ }
31641
+ });
31331
31642
  Object.defineProperty(this.emitter, "tool", {
31332
31643
  get() {
31333
31644
  return that.toolbarModel.currentTool;
@@ -31428,6 +31739,10 @@ var WhiteboardApplication = class extends AbstractApplication {
31428
31739
  this.emitter["permissions"] = this.permissions;
31429
31740
  this.emitter["selfUserId"] = this.userId;
31430
31741
  this.option = option;
31742
+ if (this.option.stretchToFill) {
31743
+ this.option.width = -1;
31744
+ this.option.height = -1;
31745
+ }
31431
31746
  this.userMap(this.userId).set(WhiteboardKeys.themeColor, "#009688");
31432
31747
  this.shadowEmitter = new ShadowEmitter(this.userMap(this.userId));
31433
31748
  this.pageModel = new PageModel(this.getMap("attrs"), this.userManager, (userId) => {
@@ -31476,6 +31791,9 @@ var WhiteboardApplication = class extends AbstractApplication {
31476
31791
  this.selectElementsModel = new SelectElementsModel(this.userManager, (userId) => {
31477
31792
  return this.userMap(userId);
31478
31793
  }, this.hasPermission);
31794
+ this.liveCursor = new LiveCursor(this.canvasElement, this.paperScope, this.userManager, (userId) => {
31795
+ return this.userMap(userId);
31796
+ });
31479
31797
  this.tools = {
31480
31798
  pointer: new PointerTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
31481
31799
  curve: new CurveTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
@@ -31486,7 +31804,7 @@ var WhiteboardApplication = class extends AbstractApplication {
31486
31804
  text: new TextTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope, this.rootElement, this.canvasElement, this.toolbarModel, this.camera),
31487
31805
  ellipse: new EllipseTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
31488
31806
  triangle: new TriangleTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
31489
- eraser: new EraserTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope, this.trashedElementsModel),
31807
+ eraser: new EraserTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope, this.trashedElementsModel, this.shadowScope),
31490
31808
  laser: new LaserPointerTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
31491
31809
  grab: new GrabTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope, this.camera)
31492
31810
  };
@@ -31558,32 +31876,12 @@ var WhiteboardApplication = class extends AbstractApplication {
31558
31876
  }
31559
31877
  });
31560
31878
  this.shadowEmitter.on("translateOut", (ids, container) => {
31561
- const shadowLayer = this.shadowScope.project.activeLayer;
31562
- let parent = null;
31563
- if (container === "layer") {
31564
- parent = shadowLayer;
31879
+ if (this.delayTranslateOut > 0) {
31880
+ setTimeout(() => {
31881
+ this.handleElementTranslateOut(ids, container);
31882
+ }, this.delayTranslateOut);
31565
31883
  } else {
31566
- parent = shadowLayer.children.find((child) => child.data.uuid === container) ?? null;
31567
- }
31568
- if (parent) {
31569
- ids.forEach((id) => {
31570
- const target = parent.children.find((child) => child.data.uuid === id);
31571
- if (target) {
31572
- target.remove();
31573
- this.insertElementToParent(target, this.paperScope.project.activeLayer);
31574
- } else {
31575
- const pageId = this.pageModel.getCurrentPage(this.userId);
31576
- if (pageId) {
31577
- const page = this.layers.get(pageId);
31578
- if (page) {
31579
- const model = page.elementModels.get(id);
31580
- if (model && model.item) {
31581
- this.insertElementToParent(model.item, this.paperScope.project.activeLayer);
31582
- }
31583
- }
31584
- }
31585
- }
31586
- });
31884
+ this.handleElementTranslateOut(ids, container);
31587
31885
  }
31588
31886
  });
31589
31887
  this.shadowEmitter.on("translateIn", (ids, container) => {
@@ -31610,6 +31908,14 @@ var WhiteboardApplication = class extends AbstractApplication {
31610
31908
  this.emitter.emit("grabUp");
31611
31909
  });
31612
31910
  this.clearElements();
31911
+ if (this.option.stretchToFill) {
31912
+ window.addEventListener("resize", () => {
31913
+ const bounds = document.body.getBoundingClientRect();
31914
+ this.updateOptionSize(bounds.width, bounds.height);
31915
+ this.adjustByOutFrame(bounds.width, bounds.height);
31916
+ });
31917
+ }
31918
+ this.rootElement.appendChild(this.liveCursor.container);
31613
31919
  }
31614
31920
  clearElements() {
31615
31921
  const userIds = this.userManager.userIdList();
@@ -31805,7 +32111,7 @@ var WhiteboardApplication = class extends AbstractApplication {
31805
32111
  this.permissions.dispose();
31806
32112
  }
31807
32113
  };
31808
- _defineProperty41(WhiteboardApplication, "applicationName", WHITEBOARD_APP_NAME);
32114
+ _defineProperty43(WhiteboardApplication, "applicationName", WHITEBOARD_APP_NAME);
31809
32115
  export {
31810
32116
  Whiteboard,
31811
32117
  WhiteboardApplication,