@netless/forge-whiteboard 0.1.15 → 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.
- package/README.md +15 -6
- package/changelog.md +11 -1
- package/dist/Camera.d.ts.map +1 -1
- package/dist/IndexedNavigation.d.ts +1 -0
- package/dist/IndexedNavigation.d.ts.map +1 -1
- package/dist/LiveCursor.d.ts +20 -0
- package/dist/LiveCursor.d.ts.map +1 -0
- package/dist/WhitePermissions.d.ts +3 -43
- package/dist/WhitePermissions.d.ts.map +1 -1
- package/dist/Whiteboard.d.ts +18 -2
- package/dist/Whiteboard.d.ts.map +1 -1
- package/dist/WhiteboardApplication.d.ts +8 -0
- package/dist/WhiteboardApplication.d.ts.map +1 -1
- package/dist/model/PageModel.d.ts.map +1 -1
- package/dist/model/RenderableModel.d.ts +6 -2
- package/dist/model/RenderableModel.d.ts.map +1 -1
- package/dist/model/SelectElementsModel.d.ts +1 -1
- package/dist/model/SelectElementsModel.d.ts.map +1 -1
- package/dist/model/ToolbarModel.d.ts.map +1 -1
- package/dist/model/TrashedElementsModel.d.ts +1 -1
- package/dist/model/TrashedElementsModel.d.ts.map +1 -1
- package/dist/model/renderable/CurveModel.d.ts +6 -2
- package/dist/model/renderable/CurveModel.d.ts.map +1 -1
- package/dist/model/renderable/CurveModel_old.d.ts +28 -0
- package/dist/model/renderable/CurveModel_old.d.ts.map +1 -0
- package/dist/model/renderable/ElementModel.d.ts +4 -1
- package/dist/model/renderable/ElementModel.d.ts.map +1 -1
- package/dist/model/renderable/EraserModel.d.ts +3 -2
- package/dist/model/renderable/EraserModel.d.ts.map +1 -1
- package/dist/model/renderable/ImageModel.d.ts +22 -0
- package/dist/model/renderable/ImageModel.d.ts.map +1 -0
- package/dist/model/renderable/LaserPointerModel.d.ts +3 -1
- package/dist/model/renderable/LaserPointerModel.d.ts.map +1 -1
- package/dist/model/renderable/LineModel.d.ts +3 -1
- package/dist/model/renderable/LineModel.d.ts.map +1 -1
- package/dist/model/renderable/PointTextModel.d.ts +3 -1
- package/dist/model/renderable/PointTextModel.d.ts.map +1 -1
- package/dist/model/renderable/RectangleModel.d.ts +3 -1
- package/dist/model/renderable/RectangleModel.d.ts.map +1 -1
- package/dist/model/renderable/SegmentsModel.d.ts +3 -1
- package/dist/model/renderable/SegmentsModel.d.ts.map +1 -1
- package/dist/model/renderable/SelectorModel.d.ts +3 -1
- package/dist/model/renderable/SelectorModel.d.ts.map +1 -1
- package/dist/model/renderable/StraightLineModel.d.ts +3 -1
- package/dist/model/renderable/StraightLineModel.d.ts.map +1 -1
- package/dist/model/renderable/TriangleModel.d.ts +3 -1
- package/dist/model/renderable/TriangleModel.d.ts.map +1 -1
- package/dist/tool/CurveTool.d.ts +1 -0
- package/dist/tool/CurveTool.d.ts.map +1 -1
- package/dist/tool/EllipseTool.d.ts +1 -0
- package/dist/tool/EllipseTool.d.ts.map +1 -1
- package/dist/tool/EraserTool.d.ts +3 -1
- package/dist/tool/EraserTool.d.ts.map +1 -1
- package/dist/tool/GrabTool.d.ts +1 -0
- package/dist/tool/GrabTool.d.ts.map +1 -1
- package/dist/tool/LaserPointerTool.d.ts +1 -0
- package/dist/tool/LaserPointerTool.d.ts.map +1 -1
- package/dist/tool/LineTool.d.ts +1 -0
- package/dist/tool/LineTool.d.ts.map +1 -1
- package/dist/tool/PointerTool.d.ts +1 -0
- package/dist/tool/PointerTool.d.ts.map +1 -1
- package/dist/tool/RectangleTool.d.ts +1 -0
- package/dist/tool/RectangleTool.d.ts.map +1 -1
- package/dist/tool/SelectorTool.d.ts +1 -0
- package/dist/tool/SelectorTool.d.ts.map +1 -1
- package/dist/tool/StraightLineTool.d.ts +1 -0
- package/dist/tool/StraightLineTool.d.ts.map +1 -1
- package/dist/tool/TextTool.d.ts +1 -0
- package/dist/tool/TextTool.d.ts.map +1 -1
- package/dist/tool/TriangleTool.d.ts +1 -0
- package/dist/tool/TriangleTool.d.ts.map +1 -1
- package/dist/utils/FPS.d.ts +15 -0
- package/dist/utils/FPS.d.ts.map +1 -0
- package/dist/whiteboard.esm.js +747 -389
- package/dist/whiteboard.esm.js.map +4 -4
- package/dist/whiteboard.js +748 -390
- package/dist/whiteboard.js.map +4 -4
- package/package.json +2 -2
package/dist/whiteboard.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
23768
|
+
clearTimeout2(timerId);
|
|
23769
23769
|
timerId = setTimeout2(timerExpired, wait);
|
|
23770
23770
|
return invokeFunc(lastCallTime);
|
|
23771
23771
|
}
|
|
@@ -25371,14 +25371,15 @@ __export(src_exports, {
|
|
|
25371
25371
|
module.exports = __toCommonJS(src_exports);
|
|
25372
25372
|
|
|
25373
25373
|
// src/WhiteboardApplication.ts
|
|
25374
|
-
var
|
|
25374
|
+
var import_forge_room12 = require("@netless/forge-room");
|
|
25375
25375
|
var Y15 = __toESM(require("yjs"), 1);
|
|
25376
25376
|
var import_paper = __toESM(require_paper_full(), 1);
|
|
25377
25377
|
|
|
25378
25378
|
// src/model/RenderableModel.ts
|
|
25379
25379
|
var Y12 = __toESM(require("yjs"), 1);
|
|
25380
|
-
var
|
|
25380
|
+
var import_eventemitter3 = __toESM(require("eventemitter3"), 1);
|
|
25381
25381
|
var import_uuid = require("uuid");
|
|
25382
|
+
var import_forge_room4 = require("@netless/forge-room");
|
|
25382
25383
|
|
|
25383
25384
|
// src/model/renderable/CurveModel.ts
|
|
25384
25385
|
var Y2 = __toESM(require("yjs"), 1);
|
|
@@ -25536,6 +25537,7 @@ var import_lodash = __toESM(require_lodash(), 1);
|
|
|
25536
25537
|
|
|
25537
25538
|
// src/model/renderable/ElementModel.ts
|
|
25538
25539
|
var Y = __toESM(require("yjs"), 1);
|
|
25540
|
+
var import_forge_room = require("@netless/forge-room");
|
|
25539
25541
|
function _defineProperty(e, r, t) {
|
|
25540
25542
|
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
25541
25543
|
}
|
|
@@ -25616,11 +25618,12 @@ var ElementModel = class _ElementModel {
|
|
|
25616
25618
|
set shadow(value) {
|
|
25617
25619
|
this.root.set(_ElementModel.KEYS.shadow, value);
|
|
25618
25620
|
}
|
|
25619
|
-
constructor(root, scope) {
|
|
25621
|
+
constructor(root, scope, liveCursor) {
|
|
25620
25622
|
_defineProperty(this, "shadowEmitter", null);
|
|
25621
25623
|
_defineProperty(this, "root", void 0);
|
|
25622
25624
|
_defineProperty(this, "scope", void 0);
|
|
25623
25625
|
_defineProperty(this, "item", void 0);
|
|
25626
|
+
_defineProperty(this, "liveCursor", void 0);
|
|
25624
25627
|
_defineProperty(this, "handlePropChange", (events) => {
|
|
25625
25628
|
if (!this.item) {
|
|
25626
25629
|
return;
|
|
@@ -25629,7 +25632,7 @@ var ElementModel = class _ElementModel {
|
|
|
25629
25632
|
if (event.target === this.root) {
|
|
25630
25633
|
const updatePaperItemKeys = this.vectorKeys().concat([_ElementModel.KEYS.pointsMatrix]);
|
|
25631
25634
|
for (const [key, value] of event.changes.keys.entries()) {
|
|
25632
|
-
if (value.action === "update") {
|
|
25635
|
+
if (value.action === "update" || value.action == "add") {
|
|
25633
25636
|
const includeKeys = this.styleKeys().include;
|
|
25634
25637
|
if (includeKeys.indexOf(key) >= 0) {
|
|
25635
25638
|
this.onStyleKeyUpdate(key);
|
|
@@ -25649,6 +25652,10 @@ var ElementModel = class _ElementModel {
|
|
|
25649
25652
|
if (this.shadow !== "") {
|
|
25650
25653
|
this.shadowEmitter?.emit("translateIn", [this.uuid], this.shadow);
|
|
25651
25654
|
} else {
|
|
25655
|
+
const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
|
|
25656
|
+
if (ownerId) {
|
|
25657
|
+
this.liveCursor.updateCursorVisible(false, ownerId);
|
|
25658
|
+
}
|
|
25652
25659
|
this.shadowEmitter?.emit("translateOut", [this.uuid], value.oldValue);
|
|
25653
25660
|
}
|
|
25654
25661
|
}
|
|
@@ -25656,11 +25663,17 @@ var ElementModel = class _ElementModel {
|
|
|
25656
25663
|
}
|
|
25657
25664
|
} else if (event.target === this.root.get(_ElementModel.KEYS.points)) {
|
|
25658
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
|
+
}
|
|
25659
25671
|
} else {
|
|
25660
25672
|
}
|
|
25661
25673
|
}
|
|
25662
25674
|
});
|
|
25663
25675
|
this.scope = scope;
|
|
25676
|
+
this.liveCursor = liveCursor;
|
|
25664
25677
|
this.root = root;
|
|
25665
25678
|
if (!this.root.has(_ElementModel.KEYS.pointsMatrix)) {
|
|
25666
25679
|
this.root.set(_ElementModel.KEYS.pointsMatrix, [1, 0, 0, 1, 0, 0]);
|
|
@@ -25720,7 +25733,7 @@ var ElementModel = class _ElementModel {
|
|
|
25720
25733
|
}
|
|
25721
25734
|
dispose() {
|
|
25722
25735
|
this.subDispose();
|
|
25723
|
-
this.root
|
|
25736
|
+
(0, import_forge_room.removeDeepObserver)(this.root, this.handlePropChange);
|
|
25724
25737
|
}
|
|
25725
25738
|
};
|
|
25726
25739
|
_defineProperty(ElementModel, "KEYS", {
|
|
@@ -25792,15 +25805,18 @@ function _toPrimitive3(t, r) {
|
|
|
25792
25805
|
return ("string" === r ? String : Number)(t);
|
|
25793
25806
|
}
|
|
25794
25807
|
var CurveModel = class extends ElementModel {
|
|
25795
|
-
constructor(root, scope) {
|
|
25796
|
-
super(root, scope);
|
|
25808
|
+
constructor(root, scope, liveCursor) {
|
|
25809
|
+
super(root, scope, liveCursor);
|
|
25797
25810
|
_defineProperty3(this, "item", null);
|
|
25811
|
+
_defineProperty3(this, "debugPath", void 0);
|
|
25812
|
+
_defineProperty3(this, "debug", false);
|
|
25798
25813
|
if (!this.root.has("type")) {
|
|
25799
25814
|
this.root.set("type", "curve");
|
|
25800
25815
|
}
|
|
25801
25816
|
if (!this.root.has("points")) {
|
|
25802
25817
|
this.root.set("points", new Y2.Array());
|
|
25803
25818
|
}
|
|
25819
|
+
this.debugPath = new scope.Path();
|
|
25804
25820
|
}
|
|
25805
25821
|
average(a2, b2) {
|
|
25806
25822
|
return (a2 + b2) / 2;
|
|
@@ -25809,23 +25825,23 @@ var CurveModel = class extends ElementModel {
|
|
|
25809
25825
|
const groupPoints = (0, import_lodash.chunk)(points, 2);
|
|
25810
25826
|
return ae(groupPoints, {
|
|
25811
25827
|
size: this.strokeWidth,
|
|
25812
|
-
smoothing: 0,
|
|
25813
|
-
thinning: 0.5,
|
|
25828
|
+
smoothing: 0.5,
|
|
25829
|
+
thinning: -0.5,
|
|
25814
25830
|
streamline: 0.5,
|
|
25815
25831
|
simulatePressure: true,
|
|
25816
25832
|
start: {
|
|
25817
|
-
taper: 10,
|
|
25833
|
+
taper: this.strokeWidth * 10,
|
|
25818
25834
|
cap: true
|
|
25819
25835
|
},
|
|
25820
25836
|
end: {
|
|
25821
|
-
taper:
|
|
25837
|
+
taper: this.strokeWidth * 20,
|
|
25822
25838
|
cap: true
|
|
25823
25839
|
}
|
|
25824
25840
|
});
|
|
25825
25841
|
}
|
|
25826
25842
|
matrixedPoints() {
|
|
25827
|
-
const
|
|
25828
|
-
return
|
|
25843
|
+
const currentPoints = (0, import_lodash.chunk)(this.points, 2);
|
|
25844
|
+
return currentPoints.map((_ref) => {
|
|
25829
25845
|
let [x, y] = _ref;
|
|
25830
25846
|
return new this.scope.Point(x, y);
|
|
25831
25847
|
}).map((p) => p.transform(new this.scope.Matrix(this.pointsMatrix))).reduce((result, next) => {
|
|
@@ -25859,27 +25875,41 @@ var CurveModel = class extends ElementModel {
|
|
|
25859
25875
|
}
|
|
25860
25876
|
return path;
|
|
25861
25877
|
}
|
|
25862
|
-
|
|
25863
|
-
|
|
25864
|
-
const
|
|
25865
|
-
|
|
25878
|
+
updateDebugPath() {
|
|
25879
|
+
this.debugPath = new this.scope.Path();
|
|
25880
|
+
const points = (0, import_lodash.chunk)(this.points, 2);
|
|
25881
|
+
for (let i = 0, len = points.length; i < len; i++) {
|
|
25882
|
+
const point = new this.scope.Point(points[i][0], points[i][1]);
|
|
25883
|
+
if (i === 0) {
|
|
25884
|
+
this.debugPath.moveTo(point);
|
|
25885
|
+
} else {
|
|
25886
|
+
this.debugPath.lineTo(point);
|
|
25887
|
+
}
|
|
25888
|
+
this.debugPath.strokeWidth = 1;
|
|
25889
|
+
this.debugPath.strokeColor = new this.scope.Color(1, 0, 0, 1);
|
|
25890
|
+
}
|
|
25866
25891
|
}
|
|
25867
25892
|
onVectorUpdate() {
|
|
25868
25893
|
if (!this.item) {
|
|
25869
25894
|
return;
|
|
25870
25895
|
}
|
|
25896
|
+
if (this.debug) {
|
|
25897
|
+
this.debugPath.remove();
|
|
25898
|
+
this.updateDebugPath();
|
|
25899
|
+
}
|
|
25900
|
+
const points = this.parsePoints(this.matrixedPoints());
|
|
25901
|
+
const path = this.createPath(points);
|
|
25871
25902
|
this.item.removeSegments();
|
|
25872
|
-
this.item.addSegments(
|
|
25873
|
-
this.
|
|
25903
|
+
this.item.addSegments(path.segments);
|
|
25904
|
+
if (this.debug) {
|
|
25905
|
+
this.item.addChild(this.debugPath);
|
|
25906
|
+
}
|
|
25874
25907
|
}
|
|
25875
25908
|
createPaperItem() {
|
|
25876
25909
|
this.item = new this.scope.Path();
|
|
25877
|
-
this.item.strokeCap = "round";
|
|
25878
|
-
this.item.strokeJoin = "round";
|
|
25879
|
-
this.item.strokeScaling = false;
|
|
25880
25910
|
this.item.strokeColor = new this.scope.Color(this.strokeColor);
|
|
25881
25911
|
this.item.fillColor = new this.scope.Color(this.strokeColor);
|
|
25882
|
-
this.
|
|
25912
|
+
this.onVectorUpdate();
|
|
25883
25913
|
}
|
|
25884
25914
|
editorConfig() {
|
|
25885
25915
|
return new EditorConfig();
|
|
@@ -25889,10 +25919,19 @@ var CurveModel = class extends ElementModel {
|
|
|
25889
25919
|
}
|
|
25890
25920
|
styleKeys() {
|
|
25891
25921
|
return {
|
|
25892
|
-
include: ["strokeColor"],
|
|
25893
|
-
exclude: ["
|
|
25922
|
+
include: ["strokeColor", "strokeWidth"],
|
|
25923
|
+
exclude: ["dashArray", "fillColor"]
|
|
25894
25924
|
};
|
|
25895
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
|
+
}
|
|
25896
25935
|
onStyleKeyUpdate(key) {
|
|
25897
25936
|
if (!this.item) {
|
|
25898
25937
|
return;
|
|
@@ -25900,6 +25939,8 @@ var CurveModel = class extends ElementModel {
|
|
|
25900
25939
|
if (key === "strokeColor") {
|
|
25901
25940
|
this.item.strokeColor = new this.scope.Color(this.strokeColor);
|
|
25902
25941
|
this.item.fillColor = new this.scope.Color(this.strokeColor);
|
|
25942
|
+
} else if (key === "strokeWidth") {
|
|
25943
|
+
this.onVectorUpdate();
|
|
25903
25944
|
}
|
|
25904
25945
|
}
|
|
25905
25946
|
subDispose() {
|
|
@@ -25926,8 +25967,8 @@ function _toPrimitive4(t, r) {
|
|
|
25926
25967
|
return ("string" === r ? String : Number)(t);
|
|
25927
25968
|
}
|
|
25928
25969
|
var SelectorModel = class extends ElementModel {
|
|
25929
|
-
constructor(root, scope) {
|
|
25930
|
-
super(root, scope);
|
|
25970
|
+
constructor(root, scope, liveCursor) {
|
|
25971
|
+
super(root, scope, liveCursor);
|
|
25931
25972
|
_defineProperty4(this, "item", null);
|
|
25932
25973
|
if (!this.root.has("type")) {
|
|
25933
25974
|
this.root.set("type", "selector");
|
|
@@ -25938,6 +25979,9 @@ var SelectorModel = class extends ElementModel {
|
|
|
25938
25979
|
this.root.set("points", initPoints);
|
|
25939
25980
|
}
|
|
25940
25981
|
}
|
|
25982
|
+
liveCursorPoint() {
|
|
25983
|
+
return null;
|
|
25984
|
+
}
|
|
25941
25985
|
subDispose() {
|
|
25942
25986
|
}
|
|
25943
25987
|
createPaperRect() {
|
|
@@ -26064,8 +26108,8 @@ function _toPrimitive6(t, r) {
|
|
|
26064
26108
|
return ("string" === r ? String : Number)(t);
|
|
26065
26109
|
}
|
|
26066
26110
|
var SegmentsModel = class extends ElementModel {
|
|
26067
|
-
constructor(root, scope, type) {
|
|
26068
|
-
super(root, scope);
|
|
26111
|
+
constructor(root, scope, type, liveCursor) {
|
|
26112
|
+
super(root, scope, liveCursor);
|
|
26069
26113
|
_defineProperty6(this, "item", null);
|
|
26070
26114
|
if (!this.root.has("type")) {
|
|
26071
26115
|
this.root.set("type", type);
|
|
@@ -26076,6 +26120,14 @@ var SegmentsModel = class extends ElementModel {
|
|
|
26076
26120
|
}
|
|
26077
26121
|
subDispose() {
|
|
26078
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
|
+
}
|
|
26079
26131
|
onVectorUpdate() {
|
|
26080
26132
|
if (!this.item) {
|
|
26081
26133
|
return;
|
|
@@ -26201,6 +26253,7 @@ var LineTool = class extends WhiteboardTool {
|
|
|
26201
26253
|
_defineProperty8(this, "elementModel", null);
|
|
26202
26254
|
_defineProperty8(this, "from", null);
|
|
26203
26255
|
_defineProperty8(this, "to", null);
|
|
26256
|
+
_defineProperty8(this, "showLiveCursor", true);
|
|
26204
26257
|
this.tool.minDistance = 1;
|
|
26205
26258
|
}
|
|
26206
26259
|
onMouseDown(event) {
|
|
@@ -26265,8 +26318,8 @@ var LineModel = class extends ElementModel {
|
|
|
26265
26318
|
set tailArrow(value) {
|
|
26266
26319
|
this.root.set("tailArrow", value);
|
|
26267
26320
|
}
|
|
26268
|
-
constructor(root, scope) {
|
|
26269
|
-
super(root, scope);
|
|
26321
|
+
constructor(root, scope, liveCursor) {
|
|
26322
|
+
super(root, scope, liveCursor);
|
|
26270
26323
|
_defineProperty9(this, "controlledPoints", []);
|
|
26271
26324
|
_defineProperty9(this, "item", null);
|
|
26272
26325
|
if (!this.root.has("type")) {
|
|
@@ -26315,6 +26368,15 @@ var LineModel = class extends ElementModel {
|
|
|
26315
26368
|
});
|
|
26316
26369
|
return [head, path, tail];
|
|
26317
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
|
+
}
|
|
26318
26380
|
createPaperItem() {
|
|
26319
26381
|
this.item = new this.scope.Group();
|
|
26320
26382
|
this.item.addChildren(this.renderLine());
|
|
@@ -26429,6 +26491,7 @@ var LineControlPoint = class {
|
|
|
26429
26491
|
|
|
26430
26492
|
// src/model/renderable/PointTextModel.ts
|
|
26431
26493
|
var Y6 = __toESM(require("yjs"), 1);
|
|
26494
|
+
var import_forge_room2 = require("@netless/forge-room");
|
|
26432
26495
|
function _defineProperty10(e, r, t) {
|
|
26433
26496
|
return (r = _toPropertyKey10(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
26434
26497
|
}
|
|
@@ -26465,8 +26528,8 @@ var PointTextModel = class extends ElementModel {
|
|
|
26465
26528
|
set fontFamily(value) {
|
|
26466
26529
|
this.root.set("font-family", value);
|
|
26467
26530
|
}
|
|
26468
|
-
constructor(root, scope) {
|
|
26469
|
-
super(root, scope);
|
|
26531
|
+
constructor(root, scope, liveCursor) {
|
|
26532
|
+
super(root, scope, liveCursor);
|
|
26470
26533
|
_defineProperty10(this, "item", null);
|
|
26471
26534
|
_defineProperty10(this, "handleTextPropChange", (event) => {
|
|
26472
26535
|
if (!this.item) {
|
|
@@ -26498,7 +26561,16 @@ var PointTextModel = class extends ElementModel {
|
|
|
26498
26561
|
}
|
|
26499
26562
|
}
|
|
26500
26563
|
subDispose() {
|
|
26501
|
-
this.root
|
|
26564
|
+
(0, import_forge_room2.removeObserver)(this.root, this.handleTextPropChange);
|
|
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;
|
|
26502
26574
|
}
|
|
26503
26575
|
getInternalMeasurement() {
|
|
26504
26576
|
if (!this.item) {
|
|
@@ -26595,8 +26667,8 @@ function _toPrimitive11(t, r) {
|
|
|
26595
26667
|
return ("string" === r ? String : Number)(t);
|
|
26596
26668
|
}
|
|
26597
26669
|
var TriangleModel = class extends ElementModel {
|
|
26598
|
-
constructor(root, scope) {
|
|
26599
|
-
super(root, scope);
|
|
26670
|
+
constructor(root, scope, liveCursor) {
|
|
26671
|
+
super(root, scope, liveCursor);
|
|
26600
26672
|
_defineProperty11(this, "item", null);
|
|
26601
26673
|
if (!this.root.has("type")) {
|
|
26602
26674
|
this.root.set("type", "triangle");
|
|
@@ -26605,6 +26677,15 @@ var TriangleModel = class extends ElementModel {
|
|
|
26605
26677
|
this.root.set("points", new Y7.Array());
|
|
26606
26678
|
}
|
|
26607
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
|
+
}
|
|
26608
26689
|
subDispose() {
|
|
26609
26690
|
}
|
|
26610
26691
|
createPaperItem() {
|
|
@@ -26687,8 +26768,8 @@ function _toPrimitive12(t, r) {
|
|
|
26687
26768
|
return ("string" === r ? String : Number)(t);
|
|
26688
26769
|
}
|
|
26689
26770
|
var RectangleModel = class extends ElementModel {
|
|
26690
|
-
constructor(root, scope) {
|
|
26691
|
-
super(root, scope);
|
|
26771
|
+
constructor(root, scope, liveCursor) {
|
|
26772
|
+
super(root, scope, liveCursor);
|
|
26692
26773
|
_defineProperty12(this, "item", null);
|
|
26693
26774
|
if (!this.root.has("type")) {
|
|
26694
26775
|
this.root.set("type", "rectangle");
|
|
@@ -26704,6 +26785,14 @@ var RectangleModel = class extends ElementModel {
|
|
|
26704
26785
|
}
|
|
26705
26786
|
subDispose() {
|
|
26706
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
|
+
}
|
|
26707
26796
|
createSegments() {
|
|
26708
26797
|
const [a2, b2, c, d] = this.points;
|
|
26709
26798
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
@@ -26863,8 +26952,8 @@ function _toPrimitive13(t, r) {
|
|
|
26863
26952
|
return ("string" === r ? String : Number)(t);
|
|
26864
26953
|
}
|
|
26865
26954
|
var EraserModel = class extends ElementModel {
|
|
26866
|
-
constructor(root, scope) {
|
|
26867
|
-
super(root, scope);
|
|
26955
|
+
constructor(root, scope, liveCursor) {
|
|
26956
|
+
super(root, scope, liveCursor);
|
|
26868
26957
|
_defineProperty13(this, "item", null);
|
|
26869
26958
|
_defineProperty13(this, "sliceBegin", 0);
|
|
26870
26959
|
if (!this.root.has("type")) {
|
|
@@ -26903,41 +26992,42 @@ var EraserModel = class extends ElementModel {
|
|
|
26903
26992
|
return path;
|
|
26904
26993
|
}
|
|
26905
26994
|
parsePoints(points) {
|
|
26906
|
-
|
|
26995
|
+
const groupPoints = (0, import_lodash5.chunk)(points, 2);
|
|
26996
|
+
return ae(groupPoints, {
|
|
26907
26997
|
size: this.strokeWidth,
|
|
26908
|
-
smoothing: 0,
|
|
26909
|
-
thinning: 0.5,
|
|
26998
|
+
smoothing: 0.5,
|
|
26999
|
+
thinning: -0.5,
|
|
26910
27000
|
streamline: 0.5,
|
|
26911
27001
|
simulatePressure: true,
|
|
26912
27002
|
start: {
|
|
26913
|
-
taper:
|
|
27003
|
+
taper: this.strokeWidth * 10,
|
|
26914
27004
|
cap: true
|
|
26915
27005
|
},
|
|
26916
27006
|
end: {
|
|
26917
|
-
taper:
|
|
27007
|
+
taper: this.strokeWidth * 20,
|
|
26918
27008
|
cap: true
|
|
26919
27009
|
}
|
|
26920
27010
|
});
|
|
26921
27011
|
}
|
|
26922
27012
|
matrixedPoints() {
|
|
26923
|
-
const
|
|
26924
|
-
|
|
26925
|
-
return groupPoints.map((_ref) => {
|
|
27013
|
+
const currentPoints = (0, import_lodash5.chunk)(this.points, 2).slice(this.sliceBegin);
|
|
27014
|
+
return currentPoints.map((_ref) => {
|
|
26926
27015
|
let [x, y] = _ref;
|
|
26927
|
-
return
|
|
26928
|
-
}).map((p) =>
|
|
26929
|
-
|
|
26930
|
-
|
|
26931
|
-
|
|
26932
|
-
|
|
26933
|
-
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
|
+
}, []);
|
|
26934
27022
|
}
|
|
26935
27023
|
onVectorUpdate() {
|
|
26936
27024
|
if (!this.item) {
|
|
26937
27025
|
return;
|
|
26938
27026
|
}
|
|
27027
|
+
const points = this.parsePoints(this.matrixedPoints());
|
|
27028
|
+
const path = this.createPath(points);
|
|
26939
27029
|
this.item.removeSegments();
|
|
26940
|
-
this.item.addSegments(
|
|
27030
|
+
this.item.addSegments(path.segments);
|
|
26941
27031
|
}
|
|
26942
27032
|
createPaperItem() {
|
|
26943
27033
|
this.item = new this.scope.Path();
|
|
@@ -26946,21 +27036,13 @@ var EraserModel = class extends ElementModel {
|
|
|
26946
27036
|
this.item.strokeScaling = false;
|
|
26947
27037
|
this.item.strokeColor = new this.scope.Color(this.strokeColor);
|
|
26948
27038
|
this.item.fillColor = new this.scope.Color(this.strokeColor);
|
|
26949
|
-
this.
|
|
26950
|
-
let isBegin = false;
|
|
27039
|
+
this.onVectorUpdate();
|
|
26951
27040
|
this.item.onFrame = () => {
|
|
26952
27041
|
if (!this.points) {
|
|
26953
27042
|
return;
|
|
26954
27043
|
}
|
|
26955
|
-
if (this.points.length / 2
|
|
26956
|
-
|
|
26957
|
-
}
|
|
26958
|
-
if (this.points.length / 2 <= this.sliceBegin) {
|
|
26959
|
-
isBegin = false;
|
|
26960
|
-
}
|
|
26961
|
-
if (isBegin) {
|
|
26962
|
-
this.sliceBegin += 1;
|
|
26963
|
-
this.onVectorUpdate();
|
|
27044
|
+
if (this.points.length / 2 > 50) {
|
|
27045
|
+
this.sliceBegin = this.points.length / 2 - 50;
|
|
26964
27046
|
}
|
|
26965
27047
|
};
|
|
26966
27048
|
}
|
|
@@ -26981,6 +27063,15 @@ var EraserModel = class extends ElementModel {
|
|
|
26981
27063
|
}
|
|
26982
27064
|
subDispose() {
|
|
26983
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
|
+
}
|
|
26984
27075
|
};
|
|
26985
27076
|
|
|
26986
27077
|
// src/model/renderable/LaserPointerModel.ts
|
|
@@ -27004,8 +27095,8 @@ function _toPrimitive14(t, r) {
|
|
|
27004
27095
|
return ("string" === r ? String : Number)(t);
|
|
27005
27096
|
}
|
|
27006
27097
|
var LaserPointerModel = class extends ElementModel {
|
|
27007
|
-
constructor(clientId, root, scope, removeElement) {
|
|
27008
|
-
super(root, scope);
|
|
27098
|
+
constructor(clientId, root, scope, liveCursor, removeElement) {
|
|
27099
|
+
super(root, scope, liveCursor);
|
|
27009
27100
|
_defineProperty14(this, "item", null);
|
|
27010
27101
|
_defineProperty14(this, "clientId", void 0);
|
|
27011
27102
|
_defineProperty14(this, "sliceBegin", 0);
|
|
@@ -27142,27 +27233,19 @@ var LaserPointerModel = class extends ElementModel {
|
|
|
27142
27233
|
}
|
|
27143
27234
|
subDispose() {
|
|
27144
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
|
+
}
|
|
27145
27245
|
};
|
|
27146
27246
|
|
|
27147
27247
|
// src/WhitePermissions.ts
|
|
27148
|
-
var
|
|
27149
|
-
function _defineProperty15(e, r, t) {
|
|
27150
|
-
return (r = _toPropertyKey15(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
27151
|
-
}
|
|
27152
|
-
function _toPropertyKey15(t) {
|
|
27153
|
-
var i = _toPrimitive15(t, "string");
|
|
27154
|
-
return "symbol" == typeof i ? i : i + "";
|
|
27155
|
-
}
|
|
27156
|
-
function _toPrimitive15(t, r) {
|
|
27157
|
-
if ("object" != typeof t || !t) return t;
|
|
27158
|
-
var e = t[Symbol.toPrimitive];
|
|
27159
|
-
if (void 0 !== e) {
|
|
27160
|
-
var i = e.call(t, r || "default");
|
|
27161
|
-
if ("object" != typeof i) return i;
|
|
27162
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
27163
|
-
}
|
|
27164
|
-
return ("string" === r ? String : Number)(t);
|
|
27165
|
-
}
|
|
27248
|
+
var import_forge_room3 = require("@netless/forge-room");
|
|
27166
27249
|
var WhiteboardPermissionFlag = function(WhiteboardPermissionFlag2) {
|
|
27167
27250
|
WhiteboardPermissionFlag2[WhiteboardPermissionFlag2["none"] = 0] = "none";
|
|
27168
27251
|
WhiteboardPermissionFlag2[WhiteboardPermissionFlag2["draw"] = 1] = "draw";
|
|
@@ -27175,59 +27258,7 @@ var WhiteboardPermissionFlag = function(WhiteboardPermissionFlag2) {
|
|
|
27175
27258
|
WhiteboardPermissionFlag2[WhiteboardPermissionFlag2["all"] = WhiteboardPermissionFlag2.draw | WhiteboardPermissionFlag2.editSelf | WhiteboardPermissionFlag2.editOthers | WhiteboardPermissionFlag2.deleteSelf | WhiteboardPermissionFlag2.deleteOthers | WhiteboardPermissionFlag2.mainView | WhiteboardPermissionFlag2.setOthersView] = "all";
|
|
27176
27259
|
return WhiteboardPermissionFlag2;
|
|
27177
27260
|
}({});
|
|
27178
|
-
var WhiteboardPermissions = class extends
|
|
27179
|
-
constructor(userManager, requestUserMap) {
|
|
27180
|
-
super();
|
|
27181
|
-
_defineProperty15(this, "requestUserMap", void 0);
|
|
27182
|
-
_defineProperty15(this, "userManager", void 0);
|
|
27183
|
-
_defineProperty15(this, "observers", /* @__PURE__ */ new Map());
|
|
27184
|
-
_defineProperty15(this, "handleUserLeave", (user) => {
|
|
27185
|
-
const cb = this.observers.get(user.id);
|
|
27186
|
-
if (cb) {
|
|
27187
|
-
this.requestUserMap(user.id).unobserve(cb);
|
|
27188
|
-
}
|
|
27189
|
-
});
|
|
27190
|
-
_defineProperty15(this, "handleUserJoin", (user) => {
|
|
27191
|
-
this.addObserve(user.id);
|
|
27192
|
-
});
|
|
27193
|
-
this.userManager = userManager;
|
|
27194
|
-
this.requestUserMap = requestUserMap;
|
|
27195
|
-
this.createModel(this.userManager.selfId);
|
|
27196
|
-
this.userManager.userIdList().forEach((userId) => {
|
|
27197
|
-
this.addObserve(userId);
|
|
27198
|
-
});
|
|
27199
|
-
this.userManager.on("join", this.handleUserJoin);
|
|
27200
|
-
this.userManager.on("leave", this.handleUserLeave);
|
|
27201
|
-
}
|
|
27202
|
-
addObserve(userId) {
|
|
27203
|
-
if (this.observers.has(userId)) {
|
|
27204
|
-
return;
|
|
27205
|
-
}
|
|
27206
|
-
const observer = (evt) => {
|
|
27207
|
-
this.handleUserPermissionChange(userId, evt);
|
|
27208
|
-
};
|
|
27209
|
-
if (this.observers.has(userId)) {
|
|
27210
|
-
this.requestUserMap(userId).unobserve(this.observers.get(userId));
|
|
27211
|
-
}
|
|
27212
|
-
this.observers.set(userId, observer);
|
|
27213
|
-
this.requestUserMap(userId).observe(observer);
|
|
27214
|
-
}
|
|
27215
|
-
createModel(userId) {
|
|
27216
|
-
const userMap = this.requestUserMap(userId);
|
|
27217
|
-
if (!userMap.has("permission")) {
|
|
27218
|
-
userMap.set("permission", 0);
|
|
27219
|
-
}
|
|
27220
|
-
}
|
|
27221
|
-
handleUserPermissionChange(userId, evt) {
|
|
27222
|
-
for (const [key, value] of evt.changes.keys.entries()) {
|
|
27223
|
-
if (key === "permission") {
|
|
27224
|
-
if (value.action === "add" || value.action === "update") {
|
|
27225
|
-
const newValue = this.requestUserMap(userId).get("permission");
|
|
27226
|
-
this.emit("change", userId, this.resolveFlags(newValue), newValue);
|
|
27227
|
-
}
|
|
27228
|
-
}
|
|
27229
|
-
}
|
|
27230
|
-
}
|
|
27261
|
+
var WhiteboardPermissions = class extends import_forge_room3.AbstractApplicationPermissions {
|
|
27231
27262
|
/**
|
|
27232
27263
|
* 解析权限列表组合
|
|
27233
27264
|
* @param {number} value - 权限数字值
|
|
@@ -27236,70 +27267,19 @@ var WhiteboardPermissions = class extends import_eventemitter3.default {
|
|
|
27236
27267
|
resolveFlags(value) {
|
|
27237
27268
|
return [WhiteboardPermissionFlag.draw, WhiteboardPermissionFlag.editSelf, WhiteboardPermissionFlag.editOthers, WhiteboardPermissionFlag.deleteSelf, WhiteboardPermissionFlag.deleteOthers, WhiteboardPermissionFlag.mainView, WhiteboardPermissionFlag.setOthersView].filter((v) => (v & value) !== 0);
|
|
27238
27269
|
}
|
|
27239
|
-
/**
|
|
27240
|
-
* 获取权限列表组合对应的数值
|
|
27241
|
-
* @param { string } userId 不传表示获取自己
|
|
27242
|
-
*/
|
|
27243
|
-
getPermissionValue(userId) {
|
|
27244
|
-
return this.requestUserMap(userId ?? this.userManager.selfId).get("permission") ?? 0;
|
|
27245
|
-
}
|
|
27246
|
-
/**
|
|
27247
|
-
* 获取权限列表
|
|
27248
|
-
* @param {string=} userId 可选, 不传表示获取自己
|
|
27249
|
-
*/
|
|
27250
|
-
getPermissionFlags(userId) {
|
|
27251
|
-
const value = this.requestUserMap(userId ?? this.userManager.selfId).get("permission") ?? 0;
|
|
27252
|
-
return this.resolveFlags(value);
|
|
27253
|
-
}
|
|
27254
|
-
/**
|
|
27255
|
-
* 返回对应 userId 是否有相应权限
|
|
27256
|
-
* @param {string=} userId 可选, 不传表示返回自己是否有相应权限
|
|
27257
|
-
* @param {WhiteboardPermissionFlag} flag
|
|
27258
|
-
*/
|
|
27259
|
-
hasPermission(flag, userId) {
|
|
27260
|
-
return ((this.requestUserMap(userId ?? this.userManager.selfId).get("permission") ?? 0) & flag) !== 0;
|
|
27261
|
-
}
|
|
27262
|
-
/**
|
|
27263
|
-
* 添加权限
|
|
27264
|
-
* @param {WhiteboardPermissionFlag} flag 权限标记
|
|
27265
|
-
* @param {string=} userId 可选, 为 userId 添加权限, 不传表示为自己添加权限
|
|
27266
|
-
*/
|
|
27267
|
-
addPermission(flag, userId) {
|
|
27268
|
-
const userMap = this.requestUserMap(userId ?? this.userManager.selfId);
|
|
27269
|
-
const oldValue = userMap.get("permission") ?? 0;
|
|
27270
|
-
this.requestUserMap(userId ?? this.userManager.selfId).set("permission", oldValue | flag);
|
|
27271
|
-
}
|
|
27272
|
-
/**
|
|
27273
|
-
* 移除权限
|
|
27274
|
-
* @param {WhiteboardPermissionFlag} flag 权限标记
|
|
27275
|
-
* @param {string=} userId 可选, 为 userId 移除权限, 不传表示为自己移除权限
|
|
27276
|
-
*/
|
|
27277
|
-
removePermission(flag, userId) {
|
|
27278
|
-
const userMap = this.requestUserMap(userId ?? this.userManager.selfId);
|
|
27279
|
-
const oldValue = userMap.get("permission") ?? 0;
|
|
27280
|
-
this.requestUserMap(userId ?? this.userManager.selfId).set("permission", oldValue & ~flag);
|
|
27281
|
-
}
|
|
27282
|
-
dispose() {
|
|
27283
|
-
this.userManager.off("join", this.handleUserJoin);
|
|
27284
|
-
this.userManager.off("leave", this.handleUserLeave);
|
|
27285
|
-
this.observers.forEach((cb, userId) => {
|
|
27286
|
-
this.requestUserMap(userId).unobserve(cb);
|
|
27287
|
-
});
|
|
27288
|
-
this.observers.clear();
|
|
27289
|
-
}
|
|
27290
27270
|
};
|
|
27291
27271
|
|
|
27292
27272
|
// src/model/renderable/StraightLineModel.ts
|
|
27293
27273
|
var Y11 = __toESM(require("yjs"), 1);
|
|
27294
27274
|
var import_lodash7 = __toESM(require_lodash(), 1);
|
|
27295
|
-
function
|
|
27296
|
-
return (r =
|
|
27275
|
+
function _defineProperty15(e, r, t) {
|
|
27276
|
+
return (r = _toPropertyKey15(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
27297
27277
|
}
|
|
27298
|
-
function
|
|
27299
|
-
var i =
|
|
27278
|
+
function _toPropertyKey15(t) {
|
|
27279
|
+
var i = _toPrimitive15(t, "string");
|
|
27300
27280
|
return "symbol" == typeof i ? i : i + "";
|
|
27301
27281
|
}
|
|
27302
|
-
function
|
|
27282
|
+
function _toPrimitive15(t, r) {
|
|
27303
27283
|
if ("object" != typeof t || !t) return t;
|
|
27304
27284
|
var e = t[Symbol.toPrimitive];
|
|
27305
27285
|
if (void 0 !== e) {
|
|
@@ -27310,9 +27290,9 @@ function _toPrimitive16(t, r) {
|
|
|
27310
27290
|
return ("string" === r ? String : Number)(t);
|
|
27311
27291
|
}
|
|
27312
27292
|
var StraightLineModel = class extends ElementModel {
|
|
27313
|
-
constructor(root, scope) {
|
|
27314
|
-
super(root, scope);
|
|
27315
|
-
|
|
27293
|
+
constructor(root, scope, liveCursor) {
|
|
27294
|
+
super(root, scope, liveCursor);
|
|
27295
|
+
_defineProperty15(this, "item", null);
|
|
27316
27296
|
if (!this.root.has("type")) {
|
|
27317
27297
|
this.root.set("type", "line");
|
|
27318
27298
|
}
|
|
@@ -27320,6 +27300,15 @@ var StraightLineModel = class extends ElementModel {
|
|
|
27320
27300
|
this.root.set("points", new Y11.Array());
|
|
27321
27301
|
}
|
|
27322
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
|
+
}
|
|
27323
27312
|
subDispose() {
|
|
27324
27313
|
}
|
|
27325
27314
|
onVectorUpdate() {
|
|
@@ -27405,6 +27394,86 @@ var StraightLineModel = class extends ElementModel {
|
|
|
27405
27394
|
}
|
|
27406
27395
|
};
|
|
27407
27396
|
|
|
27397
|
+
// src/model/renderable/ImageModel.ts
|
|
27398
|
+
function _defineProperty16(e, r, t) {
|
|
27399
|
+
return (r = _toPropertyKey16(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
27400
|
+
}
|
|
27401
|
+
function _toPropertyKey16(t) {
|
|
27402
|
+
var i = _toPrimitive16(t, "string");
|
|
27403
|
+
return "symbol" == typeof i ? i : i + "";
|
|
27404
|
+
}
|
|
27405
|
+
function _toPrimitive16(t, r) {
|
|
27406
|
+
if ("object" != typeof t || !t) return t;
|
|
27407
|
+
var e = t[Symbol.toPrimitive];
|
|
27408
|
+
if (void 0 !== e) {
|
|
27409
|
+
var i = e.call(t, r || "default");
|
|
27410
|
+
if ("object" != typeof i) return i;
|
|
27411
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
27412
|
+
}
|
|
27413
|
+
return ("string" === r ? String : Number)(t);
|
|
27414
|
+
}
|
|
27415
|
+
var ImageModel = class extends ElementModel {
|
|
27416
|
+
get src() {
|
|
27417
|
+
return this.root.get("src");
|
|
27418
|
+
}
|
|
27419
|
+
constructor(root, scope, imageSets, liveCursor) {
|
|
27420
|
+
super(root, scope, liveCursor);
|
|
27421
|
+
_defineProperty16(this, "item", null);
|
|
27422
|
+
_defineProperty16(this, "imageSets", void 0);
|
|
27423
|
+
this.imageSets = imageSets;
|
|
27424
|
+
if (!this.root.has("type")) {
|
|
27425
|
+
this.root.set("type", "image");
|
|
27426
|
+
}
|
|
27427
|
+
this.root.set(ElementModel.KEYS.shadow, "");
|
|
27428
|
+
}
|
|
27429
|
+
subDispose() {
|
|
27430
|
+
const img = this.imageSets.querySelector(`[id='${this.uuid}']`);
|
|
27431
|
+
if (img) {
|
|
27432
|
+
img.remove();
|
|
27433
|
+
}
|
|
27434
|
+
}
|
|
27435
|
+
createPaperItem() {
|
|
27436
|
+
if (this.item) {
|
|
27437
|
+
return;
|
|
27438
|
+
}
|
|
27439
|
+
if (!this.imageSets.querySelector(`[id='${this.uuid}']`)) {
|
|
27440
|
+
const img = document.createElement("img");
|
|
27441
|
+
img.src = this.src;
|
|
27442
|
+
img.id = this.uuid;
|
|
27443
|
+
this.imageSets.appendChild(img);
|
|
27444
|
+
}
|
|
27445
|
+
this.item = new this.scope.Raster(this.uuid);
|
|
27446
|
+
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27447
|
+
this.item.matrix = matrix;
|
|
27448
|
+
}
|
|
27449
|
+
onVectorUpdate() {
|
|
27450
|
+
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27451
|
+
if (this.item) {
|
|
27452
|
+
this.item.matrix = matrix;
|
|
27453
|
+
}
|
|
27454
|
+
}
|
|
27455
|
+
vectorKeys() {
|
|
27456
|
+
return [];
|
|
27457
|
+
}
|
|
27458
|
+
styleKeys() {
|
|
27459
|
+
return {
|
|
27460
|
+
include: [],
|
|
27461
|
+
exclude: ["dashArray", "strokeColor", "fillColor", "strokeWidth"]
|
|
27462
|
+
};
|
|
27463
|
+
}
|
|
27464
|
+
onStyleKeyUpdate(_key) {
|
|
27465
|
+
}
|
|
27466
|
+
editorConfig() {
|
|
27467
|
+
const cfg = new EditorConfig();
|
|
27468
|
+
cfg.resizeModel = () => "four-corner";
|
|
27469
|
+
cfg.uniformScale = () => true;
|
|
27470
|
+
return cfg;
|
|
27471
|
+
}
|
|
27472
|
+
liveCursorPoint() {
|
|
27473
|
+
return null;
|
|
27474
|
+
}
|
|
27475
|
+
};
|
|
27476
|
+
|
|
27408
27477
|
// src/model/RenderableModel.ts
|
|
27409
27478
|
function _defineProperty17(e, r, t) {
|
|
27410
27479
|
return (r = _toPropertyKey17(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
@@ -27423,11 +27492,11 @@ function _toPrimitive17(t, r) {
|
|
|
27423
27492
|
}
|
|
27424
27493
|
return ("string" === r ? String : Number)(t);
|
|
27425
27494
|
}
|
|
27426
|
-
var RenderableModel = class extends
|
|
27495
|
+
var RenderableModel = class extends import_eventemitter3.default {
|
|
27427
27496
|
get uuid() {
|
|
27428
|
-
return (0, import_uuid.v4)();
|
|
27497
|
+
return (0, import_uuid.v4)().replace(/-/g, "");
|
|
27429
27498
|
}
|
|
27430
|
-
constructor(layerId, shadowEmitter, elements, scope, toolbarModel, userManager, hasPermission) {
|
|
27499
|
+
constructor(layerId, shadowEmitter, elements, scope, toolbarModel, userManager, imageSets, liveCursor, hasPermission) {
|
|
27431
27500
|
super();
|
|
27432
27501
|
_defineProperty17(this, "scope", void 0);
|
|
27433
27502
|
_defineProperty17(this, "toolbarModel", void 0);
|
|
@@ -27438,6 +27507,8 @@ var RenderableModel = class extends import_eventemitter32.default {
|
|
|
27438
27507
|
_defineProperty17(this, "maxIndex", -1);
|
|
27439
27508
|
_defineProperty17(this, "hasPermission", void 0);
|
|
27440
27509
|
_defineProperty17(this, "shadowEmitter", void 0);
|
|
27510
|
+
_defineProperty17(this, "imageSets", void 0);
|
|
27511
|
+
_defineProperty17(this, "liveCursor", void 0);
|
|
27441
27512
|
_defineProperty17(this, "onElementsChange", (event) => {
|
|
27442
27513
|
for (const [key, value] of event.changes.keys.entries()) {
|
|
27443
27514
|
if (value.action === "add") {
|
|
@@ -27445,7 +27516,9 @@ var RenderableModel = class extends import_eventemitter32.default {
|
|
|
27445
27516
|
if (root) {
|
|
27446
27517
|
const model = this.convertToModel(root);
|
|
27447
27518
|
if (model) {
|
|
27448
|
-
|
|
27519
|
+
setTimeout(() => {
|
|
27520
|
+
this.emit("elementInsert", [model]);
|
|
27521
|
+
});
|
|
27449
27522
|
}
|
|
27450
27523
|
}
|
|
27451
27524
|
} else if (value.action === "delete") {
|
|
@@ -27453,6 +27526,8 @@ var RenderableModel = class extends import_eventemitter32.default {
|
|
|
27453
27526
|
}
|
|
27454
27527
|
}
|
|
27455
27528
|
});
|
|
27529
|
+
this.liveCursor = liveCursor;
|
|
27530
|
+
this.imageSets = imageSets;
|
|
27456
27531
|
this.hasPermission = hasPermission;
|
|
27457
27532
|
this.shadowEmitter = shadowEmitter;
|
|
27458
27533
|
this.layerId = layerId;
|
|
@@ -27491,27 +27566,29 @@ var RenderableModel = class extends import_eventemitter32.default {
|
|
|
27491
27566
|
const type = yMap.get("type");
|
|
27492
27567
|
let model = null;
|
|
27493
27568
|
if (type === "curve") {
|
|
27494
|
-
model = new CurveModel(yMap, this.scope);
|
|
27569
|
+
model = new CurveModel(yMap, this.scope, this.liveCursor);
|
|
27495
27570
|
} else if (["ellipse"].indexOf(type) >= 0) {
|
|
27496
|
-
model = new SegmentsModel(yMap, this.scope, type);
|
|
27571
|
+
model = new SegmentsModel(yMap, this.scope, type, this.liveCursor);
|
|
27497
27572
|
} else if (type === "selector") {
|
|
27498
|
-
model = new SelectorModel(yMap, this.scope);
|
|
27573
|
+
model = new SelectorModel(yMap, this.scope, this.liveCursor);
|
|
27499
27574
|
} else if (type === "arrow") {
|
|
27500
|
-
model = new LineModel(yMap, this.scope);
|
|
27575
|
+
model = new LineModel(yMap, this.scope, this.liveCursor);
|
|
27501
27576
|
} else if (type === "line") {
|
|
27502
|
-
model = new StraightLineModel(yMap, this.scope);
|
|
27577
|
+
model = new StraightLineModel(yMap, this.scope, this.liveCursor);
|
|
27503
27578
|
} else if (type === "point-text") {
|
|
27504
|
-
model = new PointTextModel(yMap, this.scope);
|
|
27579
|
+
model = new PointTextModel(yMap, this.scope, this.liveCursor);
|
|
27505
27580
|
} else if (type === "triangle") {
|
|
27506
|
-
model = new TriangleModel(yMap, this.scope);
|
|
27581
|
+
model = new TriangleModel(yMap, this.scope, this.liveCursor);
|
|
27507
27582
|
} else if (type === "rectangle") {
|
|
27508
|
-
model = new RectangleModel(yMap, this.scope);
|
|
27583
|
+
model = new RectangleModel(yMap, this.scope, this.liveCursor);
|
|
27509
27584
|
} else if (type === "eraser") {
|
|
27510
|
-
model = new EraserModel(yMap, this.scope);
|
|
27585
|
+
model = new EraserModel(yMap, this.scope, this.liveCursor);
|
|
27511
27586
|
} else if (type === "laser") {
|
|
27512
|
-
model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, (uuid) => {
|
|
27587
|
+
model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid) => {
|
|
27513
27588
|
this.removeElementItem(uuid);
|
|
27514
27589
|
});
|
|
27590
|
+
} else if (type === "image") {
|
|
27591
|
+
model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor);
|
|
27515
27592
|
}
|
|
27516
27593
|
if (model) {
|
|
27517
27594
|
model.shadowEmitter = this.shadowEmitter;
|
|
@@ -27533,36 +27610,57 @@ var RenderableModel = class extends import_eventemitter32.default {
|
|
|
27533
27610
|
removeElementItem(uuid) {
|
|
27534
27611
|
this.elements.delete(uuid);
|
|
27535
27612
|
}
|
|
27536
|
-
addElementToDoc(map) {
|
|
27613
|
+
addElementToDoc(map, type) {
|
|
27537
27614
|
this.elements.doc?.transact(() => {
|
|
27538
27615
|
const uuid = this.uuid;
|
|
27539
27616
|
map.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
27540
27617
|
map.set(ElementModel.KEYS.uuid, uuid);
|
|
27618
|
+
map.set("type", type);
|
|
27541
27619
|
this.elements.set(uuid, map);
|
|
27542
27620
|
}, elementsUndoOrigin);
|
|
27543
27621
|
}
|
|
27544
27622
|
confirmPermission() {
|
|
27545
27623
|
const hasPermission = this.hasPermission(WhiteboardPermissionFlag.draw);
|
|
27546
27624
|
if (!hasPermission) {
|
|
27547
|
-
|
|
27625
|
+
(0, import_forge_room4.log)("[@netless/forge-whiteboard] no permission to draw", {}, "warning");
|
|
27548
27626
|
}
|
|
27549
27627
|
return hasPermission;
|
|
27550
27628
|
}
|
|
27629
|
+
createImage(src) {
|
|
27630
|
+
if (!this.confirmPermission()) {
|
|
27631
|
+
return;
|
|
27632
|
+
}
|
|
27633
|
+
const yMap = new Y12.Map();
|
|
27634
|
+
this.addElementToDoc(yMap, "image");
|
|
27635
|
+
const model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor);
|
|
27636
|
+
model.root.set("src", src);
|
|
27637
|
+
const initMatrix = new this.scope.Matrix();
|
|
27638
|
+
const center = this.scope.project.view.center;
|
|
27639
|
+
initMatrix.translate({
|
|
27640
|
+
x: center.x,
|
|
27641
|
+
y: center.y
|
|
27642
|
+
});
|
|
27643
|
+
model.appendPointsMatrix(initMatrix);
|
|
27644
|
+
model.ownerId = this.userManager.selfId;
|
|
27645
|
+
}
|
|
27551
27646
|
createCurve() {
|
|
27552
27647
|
let shadow = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
|
|
27553
27648
|
if (!this.confirmPermission()) {
|
|
27554
27649
|
return null;
|
|
27555
27650
|
}
|
|
27556
|
-
const
|
|
27651
|
+
const yMap = new Y12.Map();
|
|
27652
|
+
this.addElementToDoc(yMap, "curve");
|
|
27653
|
+
const curveModel = new CurveModel(yMap, this.scope, this.liveCursor);
|
|
27557
27654
|
this.initElement(curveModel, shadow);
|
|
27558
|
-
this.addElementToDoc(curveModel.root);
|
|
27559
27655
|
return curveModel;
|
|
27560
27656
|
}
|
|
27561
27657
|
createLaserPointer() {
|
|
27562
27658
|
if (!this.confirmPermission()) {
|
|
27563
27659
|
return null;
|
|
27564
27660
|
}
|
|
27565
|
-
const
|
|
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) => {
|
|
27566
27664
|
this.removeElementItem(uuid);
|
|
27567
27665
|
});
|
|
27568
27666
|
model.strokeWidth = 8;
|
|
@@ -27570,50 +27668,53 @@ var RenderableModel = class extends import_eventemitter32.default {
|
|
|
27570
27668
|
model.fillColor = "#F44336";
|
|
27571
27669
|
model.ownerId = this.userManager.selfId;
|
|
27572
27670
|
model.shadow = "layer";
|
|
27573
|
-
this.addElementToDoc(model.root);
|
|
27574
27671
|
return model;
|
|
27575
27672
|
}
|
|
27576
27673
|
createEraser() {
|
|
27577
27674
|
if (!this.hasPermission(WhiteboardPermissionFlag.deleteSelf) && !this.hasPermission(WhiteboardPermissionFlag.deleteOthers)) {
|
|
27578
27675
|
return null;
|
|
27579
27676
|
}
|
|
27580
|
-
const
|
|
27581
|
-
|
|
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;
|
|
27582
27681
|
model.strokeColor = "#9E9E9E";
|
|
27583
27682
|
model.fillColor = "#9E9E9E";
|
|
27584
27683
|
model.ownerId = this.userManager.selfId;
|
|
27585
27684
|
model.shadow = "layer";
|
|
27586
|
-
this.addElementToDoc(model.root);
|
|
27587
27685
|
return model;
|
|
27588
27686
|
}
|
|
27589
27687
|
createTriangle(shadow) {
|
|
27590
27688
|
if (!this.confirmPermission()) {
|
|
27591
27689
|
return null;
|
|
27592
27690
|
}
|
|
27593
|
-
const
|
|
27691
|
+
const yMap = new Y12.Map();
|
|
27692
|
+
this.addElementToDoc(yMap, "triangle");
|
|
27693
|
+
const triangle = new TriangleModel(yMap, this.scope, this.liveCursor);
|
|
27594
27694
|
this.initElement(triangle, shadow);
|
|
27595
27695
|
triangle.dashArray = this.toolbarModel.dashArray;
|
|
27596
|
-
this.addElementToDoc(triangle.root);
|
|
27597
27696
|
return triangle;
|
|
27598
27697
|
}
|
|
27599
27698
|
createRectangle(shadow) {
|
|
27600
27699
|
if (!this.confirmPermission()) {
|
|
27601
27700
|
return null;
|
|
27602
27701
|
}
|
|
27603
|
-
const
|
|
27702
|
+
const yMap = new Y12.Map();
|
|
27703
|
+
this.addElementToDoc(yMap, "rectangle");
|
|
27704
|
+
const rect = new RectangleModel(yMap, this.scope, this.liveCursor);
|
|
27604
27705
|
this.initElement(rect, shadow);
|
|
27605
27706
|
rect.dashArray = this.toolbarModel.dashArray;
|
|
27606
|
-
this.addElementToDoc(rect.root);
|
|
27607
27707
|
return rect;
|
|
27608
27708
|
}
|
|
27609
27709
|
createSegmentedPath(type, shadow) {
|
|
27610
27710
|
if (!this.confirmPermission()) {
|
|
27611
27711
|
return null;
|
|
27612
27712
|
}
|
|
27613
|
-
const
|
|
27713
|
+
const yMap = new Y12.Map();
|
|
27714
|
+
this.addElementToDoc(yMap, type);
|
|
27715
|
+
const segmentsModel = new SegmentsModel(yMap, this.scope, type, this.liveCursor);
|
|
27614
27716
|
this.initElement(segmentsModel, shadow);
|
|
27615
27717
|
segmentsModel.dashArray = this.toolbarModel.dashArray;
|
|
27616
|
-
this.addElementToDoc(segmentsModel.root);
|
|
27617
27718
|
return segmentsModel;
|
|
27618
27719
|
}
|
|
27619
27720
|
createSelector() {
|
|
@@ -27621,41 +27722,45 @@ var RenderableModel = class extends import_eventemitter32.default {
|
|
|
27621
27722
|
if (!this.hasPermission(WhiteboardPermissionFlag.editSelf) && !this.hasPermission(WhiteboardPermissionFlag.deleteOthers)) {
|
|
27622
27723
|
return null;
|
|
27623
27724
|
}
|
|
27624
|
-
const
|
|
27725
|
+
const yMap = new Y12.Map();
|
|
27726
|
+
this.addElementToDoc(yMap, "selector");
|
|
27727
|
+
const selectorModel = new SelectorModel(yMap, this.scope, this.liveCursor);
|
|
27625
27728
|
selectorModel.shadow = "layer";
|
|
27626
|
-
this.addElementToDoc(selectorModel.root);
|
|
27627
27729
|
return selectorModel;
|
|
27628
27730
|
}
|
|
27629
27731
|
createStraightLine(shadow) {
|
|
27630
27732
|
if (!this.confirmPermission()) {
|
|
27631
27733
|
return null;
|
|
27632
27734
|
}
|
|
27633
|
-
const
|
|
27735
|
+
const yMap = new Y12.Map();
|
|
27736
|
+
this.addElementToDoc(yMap, "line");
|
|
27737
|
+
const straightLineModel = new StraightLineModel(yMap, this.scope, this.liveCursor);
|
|
27634
27738
|
this.initElement(straightLineModel, shadow);
|
|
27635
27739
|
straightLineModel.dashArray = this.toolbarModel.dashArray;
|
|
27636
|
-
this.addElementToDoc(straightLineModel.root);
|
|
27637
27740
|
return straightLineModel;
|
|
27638
27741
|
}
|
|
27639
27742
|
createLinePath(shadow) {
|
|
27640
27743
|
if (!this.confirmPermission()) {
|
|
27641
27744
|
return null;
|
|
27642
27745
|
}
|
|
27643
|
-
const
|
|
27746
|
+
const yMap = new Y12.Map();
|
|
27747
|
+
this.addElementToDoc(yMap, "arrow");
|
|
27748
|
+
const lineModel = new LineModel(yMap, this.scope, this.liveCursor);
|
|
27644
27749
|
this.initElement(lineModel, shadow);
|
|
27645
27750
|
lineModel.dashArray = this.toolbarModel.dashArray;
|
|
27646
|
-
this.addElementToDoc(lineModel.root);
|
|
27647
27751
|
return lineModel;
|
|
27648
27752
|
}
|
|
27649
27753
|
createPointText(x, y, shadow) {
|
|
27650
27754
|
if (!this.confirmPermission()) {
|
|
27651
27755
|
return null;
|
|
27652
27756
|
}
|
|
27653
|
-
const
|
|
27757
|
+
const yMap = new Y12.Map();
|
|
27758
|
+
this.addElementToDoc(yMap, "point-text");
|
|
27759
|
+
const pointTextModel = new PointTextModel(yMap, this.scope, this.liveCursor);
|
|
27654
27760
|
pointTextModel.setPoints([x, y]);
|
|
27655
27761
|
pointTextModel.fontSize = this.toolbarModel.fontSize;
|
|
27656
27762
|
pointTextModel.fontFamily = this.toolbarModel.fontFamily;
|
|
27657
27763
|
this.initElement(pointTextModel, shadow);
|
|
27658
|
-
this.addElementToDoc(pointTextModel.root);
|
|
27659
27764
|
return pointTextModel;
|
|
27660
27765
|
}
|
|
27661
27766
|
clearElement() {
|
|
@@ -27674,7 +27779,7 @@ var RenderableModel = class extends import_eventemitter32.default {
|
|
|
27674
27779
|
});
|
|
27675
27780
|
}
|
|
27676
27781
|
dispose() {
|
|
27677
|
-
this.elements
|
|
27782
|
+
(0, import_forge_room4.removeObserver)(this.elements, this.onElementsChange);
|
|
27678
27783
|
this.elements.clear();
|
|
27679
27784
|
Array.from(this.elementModels.values()).forEach((model) => {
|
|
27680
27785
|
model.dispose();
|
|
@@ -27974,7 +28079,8 @@ var CurveTool = class extends WhiteboardTool {
|
|
|
27974
28079
|
_defineProperty19(this, "elementModel", null);
|
|
27975
28080
|
_defineProperty19(this, "recognizer", new Recognizer());
|
|
27976
28081
|
_defineProperty19(this, "pointCount", 0);
|
|
27977
|
-
this
|
|
28082
|
+
_defineProperty19(this, "showLiveCursor", true);
|
|
28083
|
+
this.tool.minDistance = 5;
|
|
27978
28084
|
}
|
|
27979
28085
|
onMouseDown(_event) {
|
|
27980
28086
|
this.pointCount = 0;
|
|
@@ -27987,9 +28093,24 @@ var CurveTool = class extends WhiteboardTool {
|
|
|
27987
28093
|
if (this.pointCount > 1024) {
|
|
27988
28094
|
return;
|
|
27989
28095
|
}
|
|
28096
|
+
const MIN_DISTANCE = 4;
|
|
27990
28097
|
if (this.elementModel) {
|
|
27991
|
-
this.
|
|
27992
|
-
|
|
28098
|
+
const len = this.elementModel.points.length;
|
|
28099
|
+
let last = {
|
|
28100
|
+
x: 0,
|
|
28101
|
+
y: 0
|
|
28102
|
+
};
|
|
28103
|
+
if (len >= 2) {
|
|
28104
|
+
last = {
|
|
28105
|
+
x: this.elementModel.points[len - 2],
|
|
28106
|
+
y: this.elementModel.points[len - 1]
|
|
28107
|
+
};
|
|
28108
|
+
}
|
|
28109
|
+
const dist = Math.max(Math.abs(last.x - event.point.x), Math.abs(last.y - event.point.y));
|
|
28110
|
+
if (dist >= MIN_DISTANCE) {
|
|
28111
|
+
this.pointCount += 1;
|
|
28112
|
+
this.elementModel.appendPoints([Math.round(event.point.x), Math.round(event.point.y)]);
|
|
28113
|
+
}
|
|
27993
28114
|
}
|
|
27994
28115
|
}
|
|
27995
28116
|
onMouseUp(event) {
|
|
@@ -28048,6 +28169,7 @@ var RectangleTool = class extends WhiteboardTool {
|
|
|
28048
28169
|
_defineProperty20(this, "elementModel", null);
|
|
28049
28170
|
_defineProperty20(this, "from", null);
|
|
28050
28171
|
_defineProperty20(this, "to", null);
|
|
28172
|
+
_defineProperty20(this, "showLiveCursor", true);
|
|
28051
28173
|
this.tool.minDistance = 1;
|
|
28052
28174
|
}
|
|
28053
28175
|
onMouseDown(event) {
|
|
@@ -28075,7 +28197,8 @@ var RectangleTool = class extends WhiteboardTool {
|
|
|
28075
28197
|
};
|
|
28076
28198
|
|
|
28077
28199
|
// src/model/ToolbarModel.ts
|
|
28078
|
-
var
|
|
28200
|
+
var import_eventemitter32 = __toESM(require("eventemitter3"), 1);
|
|
28201
|
+
var import_forge_room5 = require("@netless/forge-room");
|
|
28079
28202
|
function _defineProperty21(e, r, t) {
|
|
28080
28203
|
return (r = _toPropertyKey21(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
28081
28204
|
}
|
|
@@ -28102,7 +28225,7 @@ var TOOLBAR_KEYS = {
|
|
|
28102
28225
|
strokeWidth: "strokeWidth",
|
|
28103
28226
|
dashArray: "dashArray"
|
|
28104
28227
|
};
|
|
28105
|
-
var ToolbarModel = class extends
|
|
28228
|
+
var ToolbarModel = class extends import_eventemitter32.default {
|
|
28106
28229
|
get currentTool() {
|
|
28107
28230
|
return this.root.get(TOOLBAR_KEYS.tool);
|
|
28108
28231
|
}
|
|
@@ -28172,7 +28295,7 @@ var ToolbarModel = class extends import_eventemitter33.default {
|
|
|
28172
28295
|
});
|
|
28173
28296
|
}
|
|
28174
28297
|
dispose() {
|
|
28175
|
-
this.root
|
|
28298
|
+
(0, import_forge_room5.removeObserver)(this.root, this.handleRootUpdate);
|
|
28176
28299
|
this.removeAllListeners();
|
|
28177
28300
|
}
|
|
28178
28301
|
};
|
|
@@ -28203,6 +28326,7 @@ var SelectorTool = class extends WhiteboardTool {
|
|
|
28203
28326
|
_defineProperty22(this, "to", null);
|
|
28204
28327
|
_defineProperty22(this, "selectElementsModel", void 0);
|
|
28205
28328
|
_defineProperty22(this, "selectElements", /* @__PURE__ */ new Map());
|
|
28329
|
+
_defineProperty22(this, "showLiveCursor", false);
|
|
28206
28330
|
this.selectElementsModel = selectElementsModel;
|
|
28207
28331
|
}
|
|
28208
28332
|
onMouseDown(event) {
|
|
@@ -28260,7 +28384,8 @@ var SelectorTool = class extends WhiteboardTool {
|
|
|
28260
28384
|
|
|
28261
28385
|
// src/model/SelectElementsModel.ts
|
|
28262
28386
|
var Y13 = __toESM(require("yjs"), 1);
|
|
28263
|
-
var
|
|
28387
|
+
var import_eventemitter33 = __toESM(require("eventemitter3"), 1);
|
|
28388
|
+
var import_forge_room6 = require("@netless/forge-room");
|
|
28264
28389
|
|
|
28265
28390
|
// src/WhiteboardKeys.ts
|
|
28266
28391
|
var WhiteboardKeys = {
|
|
@@ -28291,7 +28416,7 @@ function _toPrimitive23(t, r) {
|
|
|
28291
28416
|
}
|
|
28292
28417
|
return ("string" === r ? String : Number)(t);
|
|
28293
28418
|
}
|
|
28294
|
-
var SelectElementsModel = class extends
|
|
28419
|
+
var SelectElementsModel = class extends import_eventemitter33.default {
|
|
28295
28420
|
get hasEditSelfPermission() {
|
|
28296
28421
|
return this.hasPermission(WhiteboardPermissionFlag.editSelf);
|
|
28297
28422
|
}
|
|
@@ -28307,7 +28432,7 @@ var SelectElementsModel = class extends import_eventemitter34.default {
|
|
|
28307
28432
|
_defineProperty23(this, "handleUserLeave", (user) => {
|
|
28308
28433
|
const cb = this.observers.get(user.id);
|
|
28309
28434
|
if (cb) {
|
|
28310
|
-
this.requestUserMap(user.id)
|
|
28435
|
+
(0, import_forge_room6.removeDeepObserver)(this.requestUserMap(user.id), cb);
|
|
28311
28436
|
this.observers.delete(user.id);
|
|
28312
28437
|
}
|
|
28313
28438
|
});
|
|
@@ -28316,7 +28441,7 @@ var SelectElementsModel = class extends import_eventemitter34.default {
|
|
|
28316
28441
|
this.handleUserSelectElementsChange(user.id, evts);
|
|
28317
28442
|
};
|
|
28318
28443
|
if (this.observers.has(user.id)) {
|
|
28319
|
-
this.requestUserMap(user.id)
|
|
28444
|
+
(0, import_forge_room6.removeDeepObserver)(this.requestUserMap(user.id), this.observers.get(user.id));
|
|
28320
28445
|
}
|
|
28321
28446
|
this.requestUserMap(user.id).observeDeep(observer);
|
|
28322
28447
|
this.observers.set(user.id, observer);
|
|
@@ -28338,7 +28463,7 @@ var SelectElementsModel = class extends import_eventemitter34.default {
|
|
|
28338
28463
|
this.handleUserSelectElementsChange(userId, evts);
|
|
28339
28464
|
};
|
|
28340
28465
|
if (this.observers.has(userId)) {
|
|
28341
|
-
this.requestUserMap(userId)
|
|
28466
|
+
(0, import_forge_room6.removeDeepObserver)(this.requestUserMap(userId), this.observers.get(userId));
|
|
28342
28467
|
}
|
|
28343
28468
|
this.requestUserMap(userId).observeDeep(observer);
|
|
28344
28469
|
this.observers.set(userId, observer);
|
|
@@ -28395,7 +28520,7 @@ var SelectElementsModel = class extends import_eventemitter34.default {
|
|
|
28395
28520
|
}
|
|
28396
28521
|
dispose() {
|
|
28397
28522
|
for (const [key, value] of this.observers.entries()) {
|
|
28398
|
-
this.requestUserMap(key)
|
|
28523
|
+
(0, import_forge_room6.removeDeepObserver)(this.requestUserMap(key), value);
|
|
28399
28524
|
}
|
|
28400
28525
|
this.observers.clear();
|
|
28401
28526
|
this.userManager.off("leave", this.handleUserLeave);
|
|
@@ -28404,10 +28529,10 @@ var SelectElementsModel = class extends import_eventemitter34.default {
|
|
|
28404
28529
|
};
|
|
28405
28530
|
|
|
28406
28531
|
// src/edit/Editor.ts
|
|
28407
|
-
var
|
|
28532
|
+
var import_eventemitter35 = __toESM(require("eventemitter3"), 1);
|
|
28408
28533
|
|
|
28409
28534
|
// src/edit/TextEditor.ts
|
|
28410
|
-
var
|
|
28535
|
+
var import_eventemitter34 = require("eventemitter3");
|
|
28411
28536
|
function _defineProperty24(e, r, t) {
|
|
28412
28537
|
return (r = _toPropertyKey24(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
28413
28538
|
}
|
|
@@ -28425,7 +28550,7 @@ function _toPrimitive24(t, r) {
|
|
|
28425
28550
|
}
|
|
28426
28551
|
return ("string" === r ? String : Number)(t);
|
|
28427
28552
|
}
|
|
28428
|
-
var TextEditor = class extends
|
|
28553
|
+
var TextEditor = class extends import_eventemitter34.EventEmitter {
|
|
28429
28554
|
constructor(camera) {
|
|
28430
28555
|
super();
|
|
28431
28556
|
_defineProperty24(this, "rootView", void 0);
|
|
@@ -28568,7 +28693,7 @@ var ANCHOR_STYLE = {
|
|
|
28568
28693
|
b: "cursor:s-resize;bottom:-3px;left:50%;translate:-50%;",
|
|
28569
28694
|
br: "cursor:se-resize;bottom:-3px;right:-3px"
|
|
28570
28695
|
};
|
|
28571
|
-
var Bounds = class extends
|
|
28696
|
+
var Bounds = class extends import_eventemitter35.default {
|
|
28572
28697
|
get width() {
|
|
28573
28698
|
return this.maxX - this.minX;
|
|
28574
28699
|
}
|
|
@@ -28707,7 +28832,7 @@ var Bounds = class extends import_eventemitter36.default {
|
|
|
28707
28832
|
this.maxY = maxY;
|
|
28708
28833
|
}
|
|
28709
28834
|
};
|
|
28710
|
-
var Editor = class extends
|
|
28835
|
+
var Editor = class extends import_eventemitter35.default {
|
|
28711
28836
|
constructor(scope, shadowScope, shadowEmitter, canvasElement, camera, initConfig) {
|
|
28712
28837
|
super();
|
|
28713
28838
|
_defineProperty25(this, "rootView", void 0);
|
|
@@ -28910,7 +29035,7 @@ var Editor = class extends import_eventemitter36.default {
|
|
|
28910
29035
|
this.ctrlId = initConfig.ctrlId;
|
|
28911
29036
|
this.ctrlNickName = initConfig.ctrlNickName;
|
|
28912
29037
|
this.rootView = document.createElement("div");
|
|
28913
|
-
this.rootView.style.cssText = "position:absolute;display:none;width:100%;height:100%;top:50%;left:50%;transform:translate(-50%,-50%);";
|
|
29038
|
+
this.rootView.style.cssText = "overflow:hidden;position:absolute;display:none;width:100%;height:100%;top:50%;left:50%;transform:translate(-50%,-50%);";
|
|
28914
29039
|
this.frame = document.createElement("div");
|
|
28915
29040
|
this.frame.style.position = "absolute";
|
|
28916
29041
|
this.frame.style.padding = "8px";
|
|
@@ -29156,6 +29281,7 @@ var TextTool = class extends WhiteboardTool {
|
|
|
29156
29281
|
_defineProperty26(this, "elementModel", null);
|
|
29157
29282
|
_defineProperty26(this, "toolbarModel", void 0);
|
|
29158
29283
|
_defineProperty26(this, "camera", void 0);
|
|
29284
|
+
_defineProperty26(this, "showLiveCursor", false);
|
|
29159
29285
|
this.rootView = rootView;
|
|
29160
29286
|
this.canvasElement = canvasElement;
|
|
29161
29287
|
this.toolbarModel = toolbarModel;
|
|
@@ -29219,10 +29345,10 @@ var TextTool = class extends WhiteboardTool {
|
|
|
29219
29345
|
};
|
|
29220
29346
|
|
|
29221
29347
|
// src/Camera.ts
|
|
29222
|
-
var
|
|
29348
|
+
var import_eventemitter37 = __toESM(require("eventemitter3"), 1);
|
|
29223
29349
|
|
|
29224
29350
|
// src/Gesture.ts
|
|
29225
|
-
var
|
|
29351
|
+
var import_eventemitter36 = __toESM(require("eventemitter3"), 1);
|
|
29226
29352
|
function _defineProperty27(e, r, t) {
|
|
29227
29353
|
return (r = _toPropertyKey27(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
29228
29354
|
}
|
|
@@ -29240,7 +29366,7 @@ function _toPrimitive27(t, r) {
|
|
|
29240
29366
|
}
|
|
29241
29367
|
return ("string" === r ? String : Number)(t);
|
|
29242
29368
|
}
|
|
29243
|
-
var Gesture = class extends
|
|
29369
|
+
var Gesture = class extends import_eventemitter36.default {
|
|
29244
29370
|
constructor(element, scope) {
|
|
29245
29371
|
super();
|
|
29246
29372
|
_defineProperty27(this, "element", void 0);
|
|
@@ -29304,6 +29430,7 @@ var Gesture = class extends import_eventemitter37.default {
|
|
|
29304
29430
|
};
|
|
29305
29431
|
|
|
29306
29432
|
// src/Camera.ts
|
|
29433
|
+
var import_forge_room7 = require("@netless/forge-room");
|
|
29307
29434
|
function _defineProperty28(e, r, t) {
|
|
29308
29435
|
return (r = _toPropertyKey28(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
29309
29436
|
}
|
|
@@ -29321,7 +29448,7 @@ function _toPrimitive28(t, r) {
|
|
|
29321
29448
|
}
|
|
29322
29449
|
return ("string" === r ? String : Number)(t);
|
|
29323
29450
|
}
|
|
29324
|
-
var Camera = class extends
|
|
29451
|
+
var Camera = class extends import_eventemitter37.default {
|
|
29325
29452
|
get inherentMatrix() {
|
|
29326
29453
|
const inherentMatrix = new this.scope.Matrix();
|
|
29327
29454
|
inherentMatrix.scale(this.inherentScale, [0, 0]);
|
|
@@ -29377,7 +29504,7 @@ var Camera = class extends import_eventemitter38.default {
|
|
|
29377
29504
|
_defineProperty28(this, "handleUserLeave", (user) => {
|
|
29378
29505
|
const cb = this.observers.get(user.id);
|
|
29379
29506
|
if (cb) {
|
|
29380
|
-
this.requestUserMap(user.id)
|
|
29507
|
+
(0, import_forge_room7.removeObserver)(this.requestUserMap(user.id), cb);
|
|
29381
29508
|
}
|
|
29382
29509
|
});
|
|
29383
29510
|
_defineProperty28(this, "handleUserJoin", (user) => {
|
|
@@ -29385,7 +29512,7 @@ var Camera = class extends import_eventemitter38.default {
|
|
|
29385
29512
|
this.handleViewMatrixUpdate(user.id, evt);
|
|
29386
29513
|
};
|
|
29387
29514
|
if (this.observers.has(user.id)) {
|
|
29388
|
-
this.requestUserMap(user.id)
|
|
29515
|
+
(0, import_forge_room7.removeObserver)(this.requestUserMap(user.id), observer);
|
|
29389
29516
|
}
|
|
29390
29517
|
this.requestUserMap(user.id).observe(observer);
|
|
29391
29518
|
this.observers.set(user.id, observer);
|
|
@@ -29492,7 +29619,7 @@ var Camera = class extends import_eventemitter38.default {
|
|
|
29492
29619
|
this.handleViewMatrixUpdate(userId, evt);
|
|
29493
29620
|
};
|
|
29494
29621
|
if (this.observers.has(userId)) {
|
|
29495
|
-
this.requestUserMap(userId)
|
|
29622
|
+
(0, import_forge_room7.removeObserver)(this.requestUserMap(userId), observer);
|
|
29496
29623
|
}
|
|
29497
29624
|
this.requestUserMap(userId).observe(observer);
|
|
29498
29625
|
this.observers.set(userId, observer);
|
|
@@ -29689,10 +29816,10 @@ var Camera = class extends import_eventemitter38.default {
|
|
|
29689
29816
|
Array.from(this.observers.keys()).forEach((userId) => {
|
|
29690
29817
|
const cb = this.observers.get(userId);
|
|
29691
29818
|
if (cb) {
|
|
29692
|
-
this.requestUserMap(userId)
|
|
29819
|
+
(0, import_forge_room7.removeObserver)(this.requestUserMap(userId), cb);
|
|
29693
29820
|
}
|
|
29694
29821
|
});
|
|
29695
|
-
this.whiteboardAttrsMap
|
|
29822
|
+
(0, import_forge_room7.removeObserver)(this.whiteboardAttrsMap, this.handleMainCameraChange);
|
|
29696
29823
|
this.userManager.off("join", this.handleUserJoin);
|
|
29697
29824
|
this.userManager.off("leave", this.handleUserLeave);
|
|
29698
29825
|
this.gesture.removeAllListeners();
|
|
@@ -29724,6 +29851,7 @@ var EllipseTool = class extends WhiteboardTool {
|
|
|
29724
29851
|
_defineProperty29(this, "elementModel", null);
|
|
29725
29852
|
_defineProperty29(this, "from", null);
|
|
29726
29853
|
_defineProperty29(this, "to", null);
|
|
29854
|
+
_defineProperty29(this, "showLiveCursor", true);
|
|
29727
29855
|
this.tool.minDistance = 1;
|
|
29728
29856
|
}
|
|
29729
29857
|
onMouseDown(event) {
|
|
@@ -29778,6 +29906,7 @@ var TriangleTool = class extends WhiteboardTool {
|
|
|
29778
29906
|
_defineProperty30(this, "elementModel", null);
|
|
29779
29907
|
_defineProperty30(this, "from", null);
|
|
29780
29908
|
_defineProperty30(this, "to", null);
|
|
29909
|
+
_defineProperty30(this, "showLiveCursor", true);
|
|
29781
29910
|
this.tool.minDistance = 1;
|
|
29782
29911
|
}
|
|
29783
29912
|
onMouseDown(event) {
|
|
@@ -29805,7 +29934,7 @@ var TriangleTool = class extends WhiteboardTool {
|
|
|
29805
29934
|
};
|
|
29806
29935
|
|
|
29807
29936
|
// src/Whiteboard.ts
|
|
29808
|
-
var
|
|
29937
|
+
var import_eventemitter38 = __toESM(require("eventemitter3"), 1);
|
|
29809
29938
|
function _defineProperty31(e, r, t) {
|
|
29810
29939
|
return (r = _toPropertyKey31(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
29811
29940
|
}
|
|
@@ -29823,8 +29952,7 @@ function _toPrimitive31(t, r) {
|
|
|
29823
29952
|
}
|
|
29824
29953
|
return ("string" === r ? String : Number)(t);
|
|
29825
29954
|
}
|
|
29826
|
-
var Whiteboard = class extends
|
|
29827
|
-
// public insertImage!: (src: string) => void;
|
|
29955
|
+
var Whiteboard = class extends import_eventemitter38.default {
|
|
29828
29956
|
constructor(view) {
|
|
29829
29957
|
super();
|
|
29830
29958
|
_defineProperty31(this, "view", void 0);
|
|
@@ -29843,6 +29971,7 @@ var Whiteboard = class extends import_eventemitter39.default {
|
|
|
29843
29971
|
_defineProperty31(this, "enableCameraBoundaryHighlight", void 0);
|
|
29844
29972
|
_defineProperty31(this, "getElementAttribute", void 0);
|
|
29845
29973
|
_defineProperty31(this, "setElementAttribute", void 0);
|
|
29974
|
+
_defineProperty31(this, "removeElement", void 0);
|
|
29846
29975
|
_defineProperty31(this, "getCurrentTool", void 0);
|
|
29847
29976
|
_defineProperty31(this, "setCurrentTool", void 0);
|
|
29848
29977
|
_defineProperty31(this, "setCanvasBackgroundColor", void 0);
|
|
@@ -29857,6 +29986,7 @@ var Whiteboard = class extends import_eventemitter39.default {
|
|
|
29857
29986
|
_defineProperty31(this, "translateCamera", void 0);
|
|
29858
29987
|
_defineProperty31(this, "scaleCamera", void 0);
|
|
29859
29988
|
_defineProperty31(this, "resetCamera", void 0);
|
|
29989
|
+
_defineProperty31(this, "showLiveCursor", void 0);
|
|
29860
29990
|
_defineProperty31(this, "setFreeModelUserPage", void 0);
|
|
29861
29991
|
_defineProperty31(this, "indexedNavigation", void 0);
|
|
29862
29992
|
_defineProperty31(this, "setViewModeToFree", void 0);
|
|
@@ -29869,6 +29999,7 @@ var Whiteboard = class extends import_eventemitter39.default {
|
|
|
29869
29999
|
_defineProperty31(this, "rasterizeElementsBounds", void 0);
|
|
29870
30000
|
_defineProperty31(this, "rasterizeMaxBounds", void 0);
|
|
29871
30001
|
_defineProperty31(this, "setInputType", void 0);
|
|
30002
|
+
_defineProperty31(this, "insertImage", void 0);
|
|
29872
30003
|
this.view = view;
|
|
29873
30004
|
}
|
|
29874
30005
|
};
|
|
@@ -29892,13 +30023,16 @@ function _toPrimitive32(t, r) {
|
|
|
29892
30023
|
return ("string" === r ? String : Number)(t);
|
|
29893
30024
|
}
|
|
29894
30025
|
var EraserTool = class extends WhiteboardTool {
|
|
29895
|
-
constructor(enableToolEvent, renderableModel, shadowEmitter, scope, trashedElementsModel) {
|
|
30026
|
+
constructor(enableToolEvent, renderableModel, shadowEmitter, scope, trashedElementsModel, shadowScope) {
|
|
29896
30027
|
super(enableToolEvent, renderableModel, shadowEmitter, scope);
|
|
29897
30028
|
_defineProperty32(this, "elementModel", null);
|
|
29898
30029
|
_defineProperty32(this, "trashedElementsModel", void 0);
|
|
29899
30030
|
_defineProperty32(this, "pointCount", 0);
|
|
30031
|
+
_defineProperty32(this, "showLiveCursor", true);
|
|
30032
|
+
_defineProperty32(this, "shadowScope", void 0);
|
|
29900
30033
|
this.trashedElementsModel = trashedElementsModel;
|
|
29901
|
-
this.tool.minDistance =
|
|
30034
|
+
this.tool.minDistance = 2;
|
|
30035
|
+
this.shadowScope = shadowScope;
|
|
29902
30036
|
}
|
|
29903
30037
|
onMouseDown(_event) {
|
|
29904
30038
|
this.pointCount = 0;
|
|
@@ -29925,6 +30059,16 @@ var EraserTool = class extends WhiteboardTool {
|
|
|
29925
30059
|
this.trashedElementsModel.addTrashedElementForSelf(item.data.uuid, item.data.ownerId);
|
|
29926
30060
|
}
|
|
29927
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
|
+
});
|
|
29928
30072
|
}
|
|
29929
30073
|
onMouseUp(_event) {
|
|
29930
30074
|
if (this.elementModel) {
|
|
@@ -29936,7 +30080,8 @@ var EraserTool = class extends WhiteboardTool {
|
|
|
29936
30080
|
|
|
29937
30081
|
// src/model/TrashedElementsModel.ts
|
|
29938
30082
|
var Y14 = __toESM(require("yjs"), 1);
|
|
29939
|
-
var
|
|
30083
|
+
var import_eventemitter39 = __toESM(require("eventemitter3"), 1);
|
|
30084
|
+
var import_forge_room8 = require("@netless/forge-room");
|
|
29940
30085
|
function _defineProperty33(e, r, t) {
|
|
29941
30086
|
return (r = _toPropertyKey33(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
29942
30087
|
}
|
|
@@ -29954,7 +30099,7 @@ function _toPrimitive33(t, r) {
|
|
|
29954
30099
|
}
|
|
29955
30100
|
return ("string" === r ? String : Number)(t);
|
|
29956
30101
|
}
|
|
29957
|
-
var TrashedElementsModel = class extends
|
|
30102
|
+
var TrashedElementsModel = class extends import_eventemitter39.default {
|
|
29958
30103
|
get hasDeleteSelfPermission() {
|
|
29959
30104
|
return this.hasPermission(WhiteboardPermissionFlag.deleteSelf);
|
|
29960
30105
|
}
|
|
@@ -29970,7 +30115,7 @@ var TrashedElementsModel = class extends import_eventemitter310.default {
|
|
|
29970
30115
|
_defineProperty33(this, "handleUserLeave", (user) => {
|
|
29971
30116
|
const cb = this.observers.get(user.id);
|
|
29972
30117
|
if (cb) {
|
|
29973
|
-
this.requestUserMap(user.id)
|
|
30118
|
+
(0, import_forge_room8.removeDeepObserver)(this.requestUserMap(user.id), cb);
|
|
29974
30119
|
}
|
|
29975
30120
|
});
|
|
29976
30121
|
_defineProperty33(this, "handleUserJoin", (user) => {
|
|
@@ -29978,7 +30123,7 @@ var TrashedElementsModel = class extends import_eventemitter310.default {
|
|
|
29978
30123
|
this.handleUserTrashElementsChange(user.id, evts);
|
|
29979
30124
|
};
|
|
29980
30125
|
if (this.observers.has(user.id)) {
|
|
29981
|
-
this.requestUserMap(user.id)
|
|
30126
|
+
(0, import_forge_room8.removeDeepObserver)(this.requestUserMap(user.id), this.observers.get(user.id));
|
|
29982
30127
|
}
|
|
29983
30128
|
this.requestUserMap(user.id).observeDeep(observer);
|
|
29984
30129
|
this.observers.set(user.id, observer);
|
|
@@ -29992,7 +30137,7 @@ var TrashedElementsModel = class extends import_eventemitter310.default {
|
|
|
29992
30137
|
this.handleUserTrashElementsChange(userId, evts);
|
|
29993
30138
|
};
|
|
29994
30139
|
if (this.observers.has(userId)) {
|
|
29995
|
-
|
|
30140
|
+
(0, import_forge_room8.removeDeepObserver)(this.requestUserMap(userId), userId);
|
|
29996
30141
|
}
|
|
29997
30142
|
this.requestUserMap(userId).observeDeep(observer);
|
|
29998
30143
|
this.observers.set(userId, observer);
|
|
@@ -30049,7 +30194,7 @@ var TrashedElementsModel = class extends import_eventemitter310.default {
|
|
|
30049
30194
|
}
|
|
30050
30195
|
dispose() {
|
|
30051
30196
|
for (const [key, value] of this.observers.entries()) {
|
|
30052
|
-
this.requestUserMap(key)
|
|
30197
|
+
(0, import_forge_room8.removeDeepObserver)(this.requestUserMap(key), value);
|
|
30053
30198
|
}
|
|
30054
30199
|
this.observers.clear();
|
|
30055
30200
|
this.userManager.off("leave", this.handleUserLeave);
|
|
@@ -30080,6 +30225,7 @@ var LaserPointerTool = class extends WhiteboardTool {
|
|
|
30080
30225
|
super(enableToolEvent, modelGetter, shadowEmitter, scope);
|
|
30081
30226
|
_defineProperty34(this, "elementModel", null);
|
|
30082
30227
|
_defineProperty34(this, "pointCount", 0);
|
|
30228
|
+
_defineProperty34(this, "showLiveCursor", true);
|
|
30083
30229
|
this.tool.minDistance = 5;
|
|
30084
30230
|
}
|
|
30085
30231
|
onMouseDown(_event) {
|
|
@@ -30106,8 +30252,8 @@ var LaserPointerTool = class extends WhiteboardTool {
|
|
|
30106
30252
|
};
|
|
30107
30253
|
|
|
30108
30254
|
// src/model/PageModel.ts
|
|
30109
|
-
var
|
|
30110
|
-
var
|
|
30255
|
+
var import_eventemitter310 = __toESM(require("eventemitter3"), 1);
|
|
30256
|
+
var import_forge_room9 = require("@netless/forge-room");
|
|
30111
30257
|
function _defineProperty35(e, r, t) {
|
|
30112
30258
|
return (r = _toPropertyKey35(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
30113
30259
|
}
|
|
@@ -30125,7 +30271,7 @@ function _toPrimitive35(t, r) {
|
|
|
30125
30271
|
}
|
|
30126
30272
|
return ("string" === r ? String : Number)(t);
|
|
30127
30273
|
}
|
|
30128
|
-
var PageModel = class extends
|
|
30274
|
+
var PageModel = class extends import_eventemitter310.default {
|
|
30129
30275
|
constructor(whiteboardAttrsMap, userManager, requestUserMap, pageMap, hasPermission) {
|
|
30130
30276
|
super();
|
|
30131
30277
|
_defineProperty35(this, "whiteboardAttrsMap", void 0);
|
|
@@ -30137,7 +30283,7 @@ var PageModel = class extends import_eventemitter311.default {
|
|
|
30137
30283
|
_defineProperty35(this, "handleUserLeave", (user) => {
|
|
30138
30284
|
const cb = this.observers.get(user.id);
|
|
30139
30285
|
if (cb) {
|
|
30140
|
-
this.requestUserMap(user.id)
|
|
30286
|
+
(0, import_forge_room9.removeObserver)(this.requestUserMap(user.id), cb);
|
|
30141
30287
|
}
|
|
30142
30288
|
});
|
|
30143
30289
|
_defineProperty35(this, "handleUserJoin", (user) => {
|
|
@@ -30151,7 +30297,7 @@ var PageModel = class extends import_eventemitter311.default {
|
|
|
30151
30297
|
if (cameraMode === "main") {
|
|
30152
30298
|
const targetPage = this.whiteboardAttrsMap.get(WhiteboardKeys.currentPage);
|
|
30153
30299
|
if (!this.pageMap.has(targetPage) && targetPage !== "_i_") {
|
|
30154
|
-
(0,
|
|
30300
|
+
(0, import_forge_room9.log)(`main page {${targetPage}} not found.`, {}, "error");
|
|
30155
30301
|
return;
|
|
30156
30302
|
}
|
|
30157
30303
|
this.requestUserMap(this.userManager.selfId).set(WhiteboardKeys.currentPage, targetPage);
|
|
@@ -30279,12 +30425,12 @@ var PageModel = class extends import_eventemitter311.default {
|
|
|
30279
30425
|
dispose() {
|
|
30280
30426
|
for (const entry of this.observers.entries()) {
|
|
30281
30427
|
const [userId, observer] = entry;
|
|
30282
|
-
this.requestUserMap(userId)
|
|
30428
|
+
(0, import_forge_room9.removeObserver)(this.requestUserMap(userId), observer);
|
|
30283
30429
|
}
|
|
30284
30430
|
this.userManager.off("join", this.handleUserJoin);
|
|
30285
30431
|
this.userManager.off("leave", this.handleUserLeave);
|
|
30286
|
-
this.whiteboardAttrsMap
|
|
30287
|
-
this.pageMap
|
|
30432
|
+
(0, import_forge_room9.removeObserver)(this.whiteboardAttrsMap, this.handleMainPageChange);
|
|
30433
|
+
(0, import_forge_room9.removeObserver)(this.pageMap, this.handlePageMapChange);
|
|
30288
30434
|
}
|
|
30289
30435
|
};
|
|
30290
30436
|
|
|
@@ -30298,8 +30444,9 @@ async function waitUntil(fn, timeout) {
|
|
|
30298
30444
|
}
|
|
30299
30445
|
|
|
30300
30446
|
// src/IndexedNavigation.ts
|
|
30301
|
-
var
|
|
30302
|
-
var
|
|
30447
|
+
var import_eventemitter311 = __toESM(require("eventemitter3"), 1);
|
|
30448
|
+
var import_forge_room10 = require("@netless/forge-room");
|
|
30449
|
+
var import_forge_room11 = require("@netless/forge-room");
|
|
30303
30450
|
function _defineProperty36(e, r, t) {
|
|
30304
30451
|
return (r = _toPropertyKey36(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
30305
30452
|
}
|
|
@@ -30317,7 +30464,7 @@ function _toPrimitive36(t, r) {
|
|
|
30317
30464
|
}
|
|
30318
30465
|
return ("string" === r ? String : Number)(t);
|
|
30319
30466
|
}
|
|
30320
|
-
var IndexedNavigation = class extends
|
|
30467
|
+
var IndexedNavigation = class extends import_eventemitter311.default {
|
|
30321
30468
|
get idList() {
|
|
30322
30469
|
return this.pageModel.pageList().filter((id) => /^_i_/.test(id));
|
|
30323
30470
|
}
|
|
@@ -30326,7 +30473,7 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
30326
30473
|
return this.list[key] && this.list[key].prev === "";
|
|
30327
30474
|
});
|
|
30328
30475
|
if (!headId) {
|
|
30329
|
-
(0,
|
|
30476
|
+
(0, import_forge_room10.log)("indexed navigation confusion", {
|
|
30330
30477
|
list: JSON.stringify(this.list)
|
|
30331
30478
|
}, "error");
|
|
30332
30479
|
throw new Error("indexed navigation confusion");
|
|
@@ -30428,6 +30575,9 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
30428
30575
|
const userPageId = this.userMap.get(WhiteboardKeys.currentPage);
|
|
30429
30576
|
return this.getPageIndex(userPageId);
|
|
30430
30577
|
}
|
|
30578
|
+
get currentPageId() {
|
|
30579
|
+
return this.userMap.get(WhiteboardKeys.currentPage);
|
|
30580
|
+
}
|
|
30431
30581
|
getPageIndex(pageId) {
|
|
30432
30582
|
let i = 0;
|
|
30433
30583
|
let currentId = this.head;
|
|
@@ -30598,9 +30748,7 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
30598
30748
|
if (this.pageCount <= 1) {
|
|
30599
30749
|
return this.pageCount;
|
|
30600
30750
|
}
|
|
30601
|
-
|
|
30602
|
-
if (cameraMode !== "main") {
|
|
30603
|
-
console.warn("cannot modify pages in non-main view mode.");
|
|
30751
|
+
if (!this.modifyDetect()) {
|
|
30604
30752
|
return this.pageCount;
|
|
30605
30753
|
}
|
|
30606
30754
|
const targetId = this.getPageId(index);
|
|
@@ -30641,14 +30789,14 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
30641
30789
|
}
|
|
30642
30790
|
}
|
|
30643
30791
|
dispose() {
|
|
30644
|
-
this.indexedPageMap
|
|
30792
|
+
(0, import_forge_room11.removeObserver)(this.indexedPageMap, this.handleIndexedPageMapUpdate);
|
|
30645
30793
|
this.pageModel.off("switchPage");
|
|
30646
30794
|
this.pageModel.off("pagesChange");
|
|
30647
30795
|
}
|
|
30648
30796
|
};
|
|
30649
30797
|
|
|
30650
30798
|
// src/utils/ShadowEmitter.ts
|
|
30651
|
-
var
|
|
30799
|
+
var import_eventemitter312 = __toESM(require("eventemitter3"), 1);
|
|
30652
30800
|
function _defineProperty37(e, r, t) {
|
|
30653
30801
|
return (r = _toPropertyKey37(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
30654
30802
|
}
|
|
@@ -30666,7 +30814,7 @@ function _toPrimitive37(t, r) {
|
|
|
30666
30814
|
}
|
|
30667
30815
|
return ("string" === r ? String : Number)(t);
|
|
30668
30816
|
}
|
|
30669
|
-
var ShadowEmitter = class extends
|
|
30817
|
+
var ShadowEmitter = class extends import_eventemitter312.default {
|
|
30670
30818
|
constructor(userMap) {
|
|
30671
30819
|
super();
|
|
30672
30820
|
_defineProperty37(this, "userMap", void 0);
|
|
@@ -30704,6 +30852,7 @@ var StraightLineTool = class extends WhiteboardTool {
|
|
|
30704
30852
|
_defineProperty38(this, "elementModel", null);
|
|
30705
30853
|
_defineProperty38(this, "from", null);
|
|
30706
30854
|
_defineProperty38(this, "to", null);
|
|
30855
|
+
_defineProperty38(this, "showLiveCursor", true);
|
|
30707
30856
|
this.tool.minDistance = 1;
|
|
30708
30857
|
}
|
|
30709
30858
|
onMouseDown(event) {
|
|
@@ -30753,6 +30902,7 @@ var GrabTool = class extends WhiteboardTool {
|
|
|
30753
30902
|
super(enableToolEvent, modelGetter, shadowEmitter, scope);
|
|
30754
30903
|
_defineProperty39(this, "camera", void 0);
|
|
30755
30904
|
_defineProperty39(this, "downPoint", null);
|
|
30905
|
+
_defineProperty39(this, "showLiveCursor", false);
|
|
30756
30906
|
this.camera = camera;
|
|
30757
30907
|
}
|
|
30758
30908
|
onMouseDown(event) {
|
|
@@ -30773,9 +30923,27 @@ var GrabTool = class extends WhiteboardTool {
|
|
|
30773
30923
|
};
|
|
30774
30924
|
|
|
30775
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
|
+
}
|
|
30776
30943
|
var PointerTool = class extends WhiteboardTool {
|
|
30777
30944
|
constructor(enableToolEvent, modelGetter, shadowEmitter, scope) {
|
|
30778
30945
|
super(enableToolEvent, modelGetter, shadowEmitter, scope);
|
|
30946
|
+
_defineProperty40(this, "showLiveCursor", false);
|
|
30779
30947
|
}
|
|
30780
30948
|
onMouseDown(_event) {
|
|
30781
30949
|
}
|
|
@@ -30786,14 +30954,14 @@ var PointerTool = class extends WhiteboardTool {
|
|
|
30786
30954
|
};
|
|
30787
30955
|
|
|
30788
30956
|
// src/SequenceExecutor.ts
|
|
30789
|
-
function
|
|
30790
|
-
return (r =
|
|
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;
|
|
30791
30959
|
}
|
|
30792
|
-
function
|
|
30793
|
-
var i =
|
|
30960
|
+
function _toPropertyKey41(t) {
|
|
30961
|
+
var i = _toPrimitive41(t, "string");
|
|
30794
30962
|
return "symbol" == typeof i ? i : i + "";
|
|
30795
30963
|
}
|
|
30796
|
-
function
|
|
30964
|
+
function _toPrimitive41(t, r) {
|
|
30797
30965
|
if ("object" != typeof t || !t) return t;
|
|
30798
30966
|
var e = t[Symbol.toPrimitive];
|
|
30799
30967
|
if (void 0 !== e) {
|
|
@@ -30805,8 +30973,8 @@ function _toPrimitive40(t, r) {
|
|
|
30805
30973
|
}
|
|
30806
30974
|
var SequenceExecutor = class {
|
|
30807
30975
|
constructor() {
|
|
30808
|
-
|
|
30809
|
-
|
|
30976
|
+
_defineProperty41(this, "tasks", []);
|
|
30977
|
+
_defineProperty41(this, "isRunning", false);
|
|
30810
30978
|
}
|
|
30811
30979
|
addTask(task) {
|
|
30812
30980
|
this.tasks.push(task);
|
|
@@ -30833,14 +31001,138 @@ var SequenceExecutor = class {
|
|
|
30833
31001
|
};
|
|
30834
31002
|
|
|
30835
31003
|
// src/WhiteboardApplication.ts
|
|
30836
|
-
|
|
30837
|
-
|
|
31004
|
+
var import_forge_room13 = require("@netless/forge-room");
|
|
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;
|
|
30838
31009
|
}
|
|
30839
|
-
function
|
|
30840
|
-
var i =
|
|
31010
|
+
function _toPropertyKey42(t) {
|
|
31011
|
+
var i = _toPrimitive42(t, "string");
|
|
30841
31012
|
return "symbol" == typeof i ? i : i + "";
|
|
30842
31013
|
}
|
|
30843
|
-
function
|
|
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) {
|
|
30844
31136
|
if ("object" != typeof t || !t) return t;
|
|
30845
31137
|
var e = t[Symbol.toPrimitive];
|
|
30846
31138
|
if (void 0 !== e) {
|
|
@@ -30851,7 +31143,7 @@ function _toPrimitive41(t, r) {
|
|
|
30851
31143
|
return ("string" === r ? String : Number)(t);
|
|
30852
31144
|
}
|
|
30853
31145
|
var WHITEBOARD_APP_NAME = "whiteboard";
|
|
30854
|
-
var WhiteboardApplication = class extends
|
|
31146
|
+
var WhiteboardApplication = class extends import_forge_room12.AbstractApplication {
|
|
30855
31147
|
get undoManager() {
|
|
30856
31148
|
const page = this.pageModel.getCurrentPage(this.userId);
|
|
30857
31149
|
if (page) {
|
|
@@ -30863,39 +31155,71 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30863
31155
|
var _this;
|
|
30864
31156
|
super();
|
|
30865
31157
|
_this = this;
|
|
30866
|
-
|
|
30867
|
-
|
|
30868
|
-
|
|
30869
|
-
|
|
30870
|
-
|
|
30871
|
-
|
|
30872
|
-
|
|
30873
|
-
|
|
30874
|
-
|
|
30875
|
-
|
|
30876
|
-
|
|
30877
|
-
|
|
30878
|
-
|
|
30879
|
-
|
|
30880
|
-
|
|
30881
|
-
|
|
30882
|
-
|
|
30883
|
-
|
|
30884
|
-
|
|
30885
|
-
|
|
30886
|
-
|
|
30887
|
-
|
|
30888
|
-
|
|
30889
|
-
|
|
30890
|
-
|
|
30891
|
-
|
|
30892
|
-
|
|
30893
|
-
|
|
30894
|
-
|
|
30895
|
-
|
|
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", () => {
|
|
30896
31191
|
return !(this.inputType === "pen" && !this.isPenEvent);
|
|
30897
31192
|
});
|
|
30898
|
-
|
|
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) => {
|
|
30899
31223
|
this.sequenceExecutor.addTask(async () => {
|
|
30900
31224
|
for (const editor of this.editors.values()) {
|
|
30901
31225
|
editor.hidden();
|
|
@@ -30925,7 +31249,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30925
31249
|
}
|
|
30926
31250
|
} else {
|
|
30927
31251
|
console.warn(`[@netless/forge-whiteboard] page ${pageId} not found`);
|
|
30928
|
-
(0,
|
|
31252
|
+
(0, import_forge_room12.log)(`[@netless/forge-whiteboard] page ${pageId} not found`, {}, "warning");
|
|
30929
31253
|
}
|
|
30930
31254
|
await waitUntil(() => this.undoManagers.has(pageId), 1e3);
|
|
30931
31255
|
if (this.undoManagers.has(pageId)) {
|
|
@@ -30937,30 +31261,30 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30937
31261
|
this.undoManagers.get(pageId).on("stack-item-popped", this.handleStackItemPopped);
|
|
30938
31262
|
} else {
|
|
30939
31263
|
console.warn(`[@netless/forge-whiteboard] undo manager for page ${pageId} not found`);
|
|
30940
|
-
(0,
|
|
31264
|
+
(0, import_forge_room12.log)(`[@netless/forge-whiteboard] undo manager for page ${pageId} not found`, {}, "warning");
|
|
30941
31265
|
}
|
|
30942
31266
|
this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
|
|
30943
31267
|
this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
|
|
30944
31268
|
});
|
|
30945
31269
|
});
|
|
30946
|
-
|
|
31270
|
+
_defineProperty43(this, "hasPermission", (flag) => {
|
|
30947
31271
|
return this.permissions.hasPermission(flag, this.userId);
|
|
30948
31272
|
});
|
|
30949
|
-
|
|
31273
|
+
_defineProperty43(this, "handleStackItemAdded", () => {
|
|
30950
31274
|
this.selectElementsModel.clearSelectElementForSelf();
|
|
30951
31275
|
this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
|
|
30952
31276
|
this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
|
|
30953
31277
|
});
|
|
30954
|
-
|
|
31278
|
+
_defineProperty43(this, "handleStackItemPopped", () => {
|
|
30955
31279
|
this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
|
|
30956
31280
|
this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
|
|
30957
31281
|
});
|
|
30958
|
-
|
|
31282
|
+
_defineProperty43(this, "handleLayersChange", (ids) => {
|
|
30959
31283
|
for (let i = 0, len = ids.length; i < len; i++) {
|
|
30960
31284
|
const id = ids[i];
|
|
30961
31285
|
if (!this.layers.has(id)) {
|
|
30962
31286
|
const elementsMap = this.getMap(`layer/${id}/elements`);
|
|
30963
|
-
const renderableModel = new RenderableModel(id, this.shadowEmitter, elementsMap, this.paperScope, this.toolbarModel, this.userManager, this.hasPermission);
|
|
31287
|
+
const renderableModel = new RenderableModel(id, this.shadowEmitter, elementsMap, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.liveCursor, this.hasPermission);
|
|
30964
31288
|
this.layers.set(id, renderableModel);
|
|
30965
31289
|
}
|
|
30966
31290
|
if (!this.undoManagers.has(id)) {
|
|
@@ -30987,17 +31311,17 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30987
31311
|
}
|
|
30988
31312
|
}
|
|
30989
31313
|
});
|
|
30990
|
-
|
|
31314
|
+
_defineProperty43(this, "getCurrentRenderableModel", () => {
|
|
30991
31315
|
const layerId = this.userMap(this.userId).get(WhiteboardKeys.currentPage);
|
|
30992
31316
|
if (!this.layers.has(layerId)) {
|
|
30993
31317
|
this.emitter.emit("error", 300002, `target page: ${layerId} not found`);
|
|
30994
31318
|
}
|
|
30995
31319
|
return this.layers.get(layerId);
|
|
30996
31320
|
});
|
|
30997
|
-
|
|
31321
|
+
_defineProperty43(this, "handleElementClear", () => {
|
|
30998
31322
|
this.paperScope.project.activeLayer.removeChildren();
|
|
30999
31323
|
});
|
|
31000
|
-
|
|
31324
|
+
_defineProperty43(this, "handleElementInsert", (elements) => {
|
|
31001
31325
|
for (const element of elements) {
|
|
31002
31326
|
element.createPaperElement();
|
|
31003
31327
|
const scope = element.shadow === "" ? this.paperScope : this.shadowScope;
|
|
@@ -31009,7 +31333,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31009
31333
|
this.insertElementToParent(element.item, scope.project.activeLayer);
|
|
31010
31334
|
}
|
|
31011
31335
|
});
|
|
31012
|
-
|
|
31336
|
+
_defineProperty43(this, "handleElementRemove", (elementId, layerId) => {
|
|
31013
31337
|
const layerModel = this.layers.get(layerId);
|
|
31014
31338
|
if (!layerModel) {
|
|
31015
31339
|
return;
|
|
@@ -31020,11 +31344,11 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31020
31344
|
}
|
|
31021
31345
|
layerModel.elementModels.delete(elementId);
|
|
31022
31346
|
});
|
|
31023
|
-
|
|
31347
|
+
_defineProperty43(this, "handleRemoveTrashedElementForSelf", (userId, elementId) => {
|
|
31024
31348
|
const selfLayerId = this.userMap(this.userId).get(WhiteboardKeys.currentPage);
|
|
31025
31349
|
this.layers.get(selfLayerId)?.removeElementItem(elementId);
|
|
31026
31350
|
});
|
|
31027
|
-
|
|
31351
|
+
_defineProperty43(this, "handleElementsTrash", (userId, elements) => {
|
|
31028
31352
|
const targetLayerId = this.userMap(userId).get(WhiteboardKeys.currentPage);
|
|
31029
31353
|
const selfLayerId = this.userMap(this.userId).get(WhiteboardKeys.currentPage);
|
|
31030
31354
|
if (targetLayerId !== selfLayerId || !this.layers.has(targetLayerId)) {
|
|
@@ -31037,7 +31361,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31037
31361
|
}
|
|
31038
31362
|
});
|
|
31039
31363
|
});
|
|
31040
|
-
|
|
31364
|
+
_defineProperty43(this, "handleElementsSelect", (userId, elements) => {
|
|
31041
31365
|
if (!this.editors.has(userId)) {
|
|
31042
31366
|
const ctrl = this.userManager.getUser(userId);
|
|
31043
31367
|
const editor2 = new Editor(this.paperScope, this.shadowScope, this.shadowEmitter, this.canvasElement, this.camera, {
|
|
@@ -31080,7 +31404,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31080
31404
|
this.emitter.emit("elementDeselected", userId);
|
|
31081
31405
|
}
|
|
31082
31406
|
});
|
|
31083
|
-
|
|
31407
|
+
_defineProperty43(this, "handleLinkedMapChange", (evt) => {
|
|
31084
31408
|
for (const [key, value] of evt.changes.keys.entries()) {
|
|
31085
31409
|
if (Object.keys(TOOLBAR_KEYS).indexOf(key) >= 0 && (value.action === "add" || value.action === "update")) {
|
|
31086
31410
|
this.toolbarModel.currentTool = evt.target.get(TOOLBAR_KEYS.tool);
|
|
@@ -31097,7 +31421,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31097
31421
|
}
|
|
31098
31422
|
}
|
|
31099
31423
|
});
|
|
31100
|
-
|
|
31424
|
+
_defineProperty43(this, "adjustByOutFrame", (frameWidth, frameHeight) => {
|
|
31101
31425
|
if (this.option.width > 0 && this.option.height > 0) {
|
|
31102
31426
|
const minWidth = Math.max(frameWidth, 10);
|
|
31103
31427
|
const minHeight = Math.max(frameHeight, 10);
|
|
@@ -31117,6 +31441,9 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31117
31441
|
requestAnimationFrameHook(this.shadowScope);
|
|
31118
31442
|
const that = this;
|
|
31119
31443
|
this.rootElement.setAttribute("data-forge-app", "whiteboard");
|
|
31444
|
+
this.imageSets.style.display = "none";
|
|
31445
|
+
this.imageSets.setAttribute("data-image-sets", "");
|
|
31446
|
+
this.rootElement.appendChild(this.imageSets);
|
|
31120
31447
|
document.body.addEventListener("pointerdown", (evt) => {
|
|
31121
31448
|
this.isPenEvent = evt.pointerType === "pen";
|
|
31122
31449
|
if (evt.pointerType === "pen" && this.hasPenInput === null) {
|
|
@@ -31178,7 +31505,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31178
31505
|
this.emitter.setViewModeToFree = (userId) => {
|
|
31179
31506
|
if (that.disableViewModelUpdate) {
|
|
31180
31507
|
console.warn("Operation failed. Perspective mode switching is disabled in the current environment.");
|
|
31181
|
-
(0,
|
|
31508
|
+
(0, import_forge_room12.log)("Operation failed. Perspective mode switching is disabled in the current environment.", {}, "warning");
|
|
31182
31509
|
return;
|
|
31183
31510
|
}
|
|
31184
31511
|
const targetId = userId ? this.hasPermission(WhiteboardPermissionFlag.setOthersView) ? userId : null : this.userId;
|
|
@@ -31189,7 +31516,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31189
31516
|
this.emitter.setViewModeToFlow = (flowId, userId) => {
|
|
31190
31517
|
if (that.disableViewModelUpdate) {
|
|
31191
31518
|
console.warn("Operation failed. Perspective mode switching is disabled in the current environment.");
|
|
31192
|
-
(0,
|
|
31519
|
+
(0, import_forge_room12.log)("Operation failed. Perspective mode switching is disabled in the current environment.", {}, "warning");
|
|
31193
31520
|
return;
|
|
31194
31521
|
}
|
|
31195
31522
|
const targetId = userId ? this.hasPermission(WhiteboardPermissionFlag.setOthersView) ? userId : null : this.userId;
|
|
@@ -31204,7 +31531,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31204
31531
|
this.emitter.setViewModeToMain = (userId) => {
|
|
31205
31532
|
if (that.disableViewModelUpdate) {
|
|
31206
31533
|
console.warn("Operation failed. Perspective mode switching is disabled in the current environment.");
|
|
31207
|
-
(0,
|
|
31534
|
+
(0, import_forge_room12.log)("Operation failed. Perspective mode switching is disabled in the current environment.", {}, "warning");
|
|
31208
31535
|
return;
|
|
31209
31536
|
}
|
|
31210
31537
|
const targetId = userId ? this.hasPermission(WhiteboardPermissionFlag.setOthersView) ? userId : null : this.userId;
|
|
@@ -31216,6 +31543,30 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31216
31543
|
this.camera.resetViewMatrixToMain();
|
|
31217
31544
|
}
|
|
31218
31545
|
};
|
|
31546
|
+
this.emitter.insertImage = (src, pageId) => {
|
|
31547
|
+
if (!/https/.test(src)) {
|
|
31548
|
+
(0, import_forge_room12.log)("[@netless/forge-whiteboard] invalid image url, src needs to be in the HTTPS protocol.", {
|
|
31549
|
+
src
|
|
31550
|
+
}, "warning");
|
|
31551
|
+
return;
|
|
31552
|
+
}
|
|
31553
|
+
let targetPageId = pageId;
|
|
31554
|
+
if (!targetPageId) {
|
|
31555
|
+
targetPageId = this.pageModel.getCurrentPage(this.userManager.selfId);
|
|
31556
|
+
}
|
|
31557
|
+
if (!targetPageId) {
|
|
31558
|
+
(0, import_forge_room12.log)("[@netless/forge-whiteboard] page not found", {}, "warning");
|
|
31559
|
+
return;
|
|
31560
|
+
}
|
|
31561
|
+
this.layers.get(targetPageId)?.createImage(src);
|
|
31562
|
+
};
|
|
31563
|
+
this.emitter.removeElement = (pageId, elementId) => {
|
|
31564
|
+
if (!this.layers.has(pageId)) {
|
|
31565
|
+
(0, import_forge_room12.log)("[@netless/forge-whiteboard] page not found", {}, "warning");
|
|
31566
|
+
return;
|
|
31567
|
+
}
|
|
31568
|
+
this.layers.get(pageId)?.removeElementItem(elementId);
|
|
31569
|
+
};
|
|
31219
31570
|
this.emitter.getViewModel = (userId) => {
|
|
31220
31571
|
const targetId = userId ? userId : this.userId;
|
|
31221
31572
|
return this.userMap(targetId).get(WhiteboardKeys.cameraMode);
|
|
@@ -31231,7 +31582,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31231
31582
|
const source = this.getMap(`layer/${sourceId}/elements`);
|
|
31232
31583
|
const target = this.getMap(`layer/${targetId}/elements`);
|
|
31233
31584
|
if (!this.layers.has(targetId)) {
|
|
31234
|
-
this.layers.set(targetId, new RenderableModel(targetId, this.shadowEmitter, target, this.paperScope, this.toolbarModel, this.userManager, 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));
|
|
31235
31586
|
}
|
|
31236
31587
|
if (!this.undoManagers.has(targetId)) {
|
|
31237
31588
|
const undoManager = new Y15.UndoManager(target, {
|
|
@@ -31281,12 +31632,23 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31281
31632
|
this.emitter.resetCamera = () => {
|
|
31282
31633
|
this.camera.reset();
|
|
31283
31634
|
};
|
|
31635
|
+
this.emitter.showLiveCursor = (value) => {
|
|
31636
|
+
this.liveCursor.showLiveCursor = value;
|
|
31637
|
+
};
|
|
31284
31638
|
this.emitter.on("error", (errorCode, errorMessage) => {
|
|
31285
|
-
(0,
|
|
31639
|
+
(0, import_forge_room12.log)("WhiteboardApplicationError", {
|
|
31286
31640
|
errorCode,
|
|
31287
31641
|
errorMessage
|
|
31288
31642
|
});
|
|
31289
31643
|
});
|
|
31644
|
+
Object.defineProperty(this.emitter, "__delayTranslateOut", {
|
|
31645
|
+
get() {
|
|
31646
|
+
return that.delayTranslateOut;
|
|
31647
|
+
},
|
|
31648
|
+
set(value) {
|
|
31649
|
+
that.delayTranslateOut = value;
|
|
31650
|
+
}
|
|
31651
|
+
});
|
|
31290
31652
|
Object.defineProperty(this.emitter, "tool", {
|
|
31291
31653
|
get() {
|
|
31292
31654
|
return that.toolbarModel.currentTool;
|
|
@@ -31383,9 +31745,14 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31383
31745
|
this.permissions = new WhiteboardPermissions(this.userManager, (userId) => {
|
|
31384
31746
|
return this.userMap(userId);
|
|
31385
31747
|
});
|
|
31748
|
+
this.permissions.setPermission(WhiteboardPermissionFlag.all);
|
|
31386
31749
|
this.emitter["permissions"] = this.permissions;
|
|
31387
31750
|
this.emitter["selfUserId"] = this.userId;
|
|
31388
31751
|
this.option = option;
|
|
31752
|
+
if (this.option.stretchToFill) {
|
|
31753
|
+
this.option.width = -1;
|
|
31754
|
+
this.option.height = -1;
|
|
31755
|
+
}
|
|
31389
31756
|
this.userMap(this.userId).set(WhiteboardKeys.themeColor, "#009688");
|
|
31390
31757
|
this.shadowEmitter = new ShadowEmitter(this.userMap(this.userId));
|
|
31391
31758
|
this.pageModel = new PageModel(this.getMap("attrs"), this.userManager, (userId) => {
|
|
@@ -31434,6 +31801,9 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31434
31801
|
this.selectElementsModel = new SelectElementsModel(this.userManager, (userId) => {
|
|
31435
31802
|
return this.userMap(userId);
|
|
31436
31803
|
}, this.hasPermission);
|
|
31804
|
+
this.liveCursor = new LiveCursor(this.canvasElement, this.paperScope, this.userManager, (userId) => {
|
|
31805
|
+
return this.userMap(userId);
|
|
31806
|
+
});
|
|
31437
31807
|
this.tools = {
|
|
31438
31808
|
pointer: new PointerTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
|
|
31439
31809
|
curve: new CurveTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
|
|
@@ -31444,7 +31814,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31444
31814
|
text: new TextTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope, this.rootElement, this.canvasElement, this.toolbarModel, this.camera),
|
|
31445
31815
|
ellipse: new EllipseTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
|
|
31446
31816
|
triangle: new TriangleTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
|
|
31447
|
-
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),
|
|
31448
31818
|
laser: new LaserPointerTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
|
|
31449
31819
|
grab: new GrabTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope, this.camera)
|
|
31450
31820
|
};
|
|
@@ -31465,7 +31835,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31465
31835
|
this.paperScope.tool = this.tools[this.toolbarModel.currentTool].tool;
|
|
31466
31836
|
} else {
|
|
31467
31837
|
this.paperScope.tool = this.tools["curve"].tool;
|
|
31468
|
-
(0,
|
|
31838
|
+
(0, import_forge_room12.log)(`${this.toolbarModel.currentTool} not supported, backup to curve`);
|
|
31469
31839
|
}
|
|
31470
31840
|
this.selectElementsModel.on("elementsChange", this.handleElementsSelect);
|
|
31471
31841
|
this.trashedElementsModel.on("elementsChange", this.handleElementsTrash);
|
|
@@ -31516,32 +31886,12 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31516
31886
|
}
|
|
31517
31887
|
});
|
|
31518
31888
|
this.shadowEmitter.on("translateOut", (ids, container) => {
|
|
31519
|
-
|
|
31520
|
-
|
|
31521
|
-
|
|
31522
|
-
|
|
31889
|
+
if (this.delayTranslateOut > 0) {
|
|
31890
|
+
setTimeout(() => {
|
|
31891
|
+
this.handleElementTranslateOut(ids, container);
|
|
31892
|
+
}, this.delayTranslateOut);
|
|
31523
31893
|
} else {
|
|
31524
|
-
|
|
31525
|
-
}
|
|
31526
|
-
if (parent) {
|
|
31527
|
-
ids.forEach((id) => {
|
|
31528
|
-
const target = parent.children.find((child) => child.data.uuid === id);
|
|
31529
|
-
if (target) {
|
|
31530
|
-
target.remove();
|
|
31531
|
-
this.insertElementToParent(target, this.paperScope.project.activeLayer);
|
|
31532
|
-
} else {
|
|
31533
|
-
const pageId = this.pageModel.getCurrentPage(this.userId);
|
|
31534
|
-
if (pageId) {
|
|
31535
|
-
const page = this.layers.get(pageId);
|
|
31536
|
-
if (page) {
|
|
31537
|
-
const model = page.elementModels.get(id);
|
|
31538
|
-
if (model && model.item) {
|
|
31539
|
-
this.insertElementToParent(model.item, this.paperScope.project.activeLayer);
|
|
31540
|
-
}
|
|
31541
|
-
}
|
|
31542
|
-
}
|
|
31543
|
-
}
|
|
31544
|
-
});
|
|
31894
|
+
this.handleElementTranslateOut(ids, container);
|
|
31545
31895
|
}
|
|
31546
31896
|
});
|
|
31547
31897
|
this.shadowEmitter.on("translateIn", (ids, container) => {
|
|
@@ -31568,6 +31918,14 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31568
31918
|
this.emitter.emit("grabUp");
|
|
31569
31919
|
});
|
|
31570
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);
|
|
31571
31929
|
}
|
|
31572
31930
|
clearElements() {
|
|
31573
31931
|
const userIds = this.userManager.userIdList();
|
|
@@ -31710,7 +32068,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31710
32068
|
}
|
|
31711
32069
|
unlink() {
|
|
31712
32070
|
if (this.linkTarget) {
|
|
31713
|
-
this.linkTarget
|
|
32071
|
+
(0, import_forge_room13.removeObserver)(this.linkTarget, this.handleLinkedMapChange);
|
|
31714
32072
|
}
|
|
31715
32073
|
}
|
|
31716
32074
|
setViewSize(width, height) {
|
|
@@ -31763,7 +32121,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31763
32121
|
this.permissions.dispose();
|
|
31764
32122
|
}
|
|
31765
32123
|
};
|
|
31766
|
-
|
|
32124
|
+
_defineProperty43(WhiteboardApplication, "applicationName", WHITEBOARD_APP_NAME);
|
|
31767
32125
|
/*! Bundled license information:
|
|
31768
32126
|
|
|
31769
32127
|
paper/dist/paper-full.js:
|