@netless/forge-whiteboard 0.1.14 → 0.1.16
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/changelog.md +11 -1
- package/dist/Camera.d.ts +7 -5
- package/dist/Camera.d.ts.map +1 -1
- package/dist/Gesture.d.ts +1 -1
- package/dist/Gesture.d.ts.map +1 -1
- package/dist/IndexedNavigation.d.ts +31 -29
- package/dist/IndexedNavigation.d.ts.map +1 -1
- package/dist/SequenceExecutor.d.ts +7 -0
- package/dist/SequenceExecutor.d.ts.map +1 -0
- package/dist/WhitePermissions.d.ts +7 -46
- package/dist/WhitePermissions.d.ts.map +1 -1
- package/dist/Whiteboard.d.ts +120 -108
- package/dist/Whiteboard.d.ts.map +1 -1
- package/dist/WhiteboardApplication.d.ts +7 -4
- package/dist/WhiteboardApplication.d.ts.map +1 -1
- package/dist/edit/Editor.d.ts +5 -5
- package/dist/edit/Editor.d.ts.map +1 -1
- package/dist/edit/EditorConfig.d.ts +1 -1
- package/dist/edit/EditorConfig.d.ts.map +1 -1
- package/dist/edit/TextEditor.d.ts +2 -2
- package/dist/edit/TextEditor.d.ts.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/model/PageModel.d.ts +5 -4
- package/dist/model/PageModel.d.ts.map +1 -1
- package/dist/model/RenderableModel.d.ts +22 -20
- package/dist/model/RenderableModel.d.ts.map +1 -1
- package/dist/model/SelectElementsModel.d.ts +4 -4
- package/dist/model/SelectElementsModel.d.ts.map +1 -1
- package/dist/model/ToolbarModel.d.ts +4 -3
- package/dist/model/ToolbarModel.d.ts.map +1 -1
- package/dist/model/TrashedElementsModel.d.ts +4 -4
- package/dist/model/TrashedElementsModel.d.ts.map +1 -1
- package/dist/model/renderable/CurveModel.d.ts +7 -4
- 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 +5 -3
- package/dist/model/renderable/ElementModel.d.ts.map +1 -1
- package/dist/model/renderable/EraserModel.d.ts +5 -4
- package/dist/model/renderable/EraserModel.d.ts.map +1 -1
- package/dist/model/renderable/ImageModel.d.ts +20 -0
- package/dist/model/renderable/ImageModel.d.ts.map +1 -0
- package/dist/model/renderable/LaserPointerModel.d.ts +5 -4
- package/dist/model/renderable/LaserPointerModel.d.ts.map +1 -1
- package/dist/model/renderable/LineModel.d.ts +9 -8
- package/dist/model/renderable/LineModel.d.ts.map +1 -1
- package/dist/model/renderable/PointTextModel.d.ts +4 -3
- package/dist/model/renderable/PointTextModel.d.ts.map +1 -1
- package/dist/model/renderable/RectangleModel.d.ts +5 -4
- package/dist/model/renderable/RectangleModel.d.ts.map +1 -1
- package/dist/model/renderable/SegmentsModel.d.ts +6 -5
- package/dist/model/renderable/SegmentsModel.d.ts.map +1 -1
- package/dist/model/renderable/SelectorModel.d.ts +5 -4
- package/dist/model/renderable/SelectorModel.d.ts.map +1 -1
- package/dist/model/renderable/StraightLineModel.d.ts +5 -4
- package/dist/model/renderable/StraightLineModel.d.ts.map +1 -1
- package/dist/model/renderable/TriangleModel.d.ts +5 -4
- package/dist/model/renderable/TriangleModel.d.ts.map +1 -1
- package/dist/tool/CurveTool.d.ts +4 -4
- package/dist/tool/CurveTool.d.ts.map +1 -1
- package/dist/tool/EllipseTool.d.ts +4 -4
- package/dist/tool/EllipseTool.d.ts.map +1 -1
- package/dist/tool/EraserTool.d.ts +6 -6
- package/dist/tool/EraserTool.d.ts.map +1 -1
- package/dist/tool/GrabTool.d.ts +4 -4
- package/dist/tool/GrabTool.d.ts.map +1 -1
- package/dist/tool/LaserPointerTool.d.ts +5 -5
- package/dist/tool/LaserPointerTool.d.ts.map +1 -1
- package/dist/tool/LineTool.d.ts +4 -4
- package/dist/tool/LineTool.d.ts.map +1 -1
- package/dist/tool/PointerTool.d.ts +10 -0
- package/dist/tool/PointerTool.d.ts.map +1 -0
- package/dist/tool/RectangleTool.d.ts +4 -4
- package/dist/tool/RectangleTool.d.ts.map +1 -1
- package/dist/tool/SelectorTool.d.ts +5 -5
- package/dist/tool/SelectorTool.d.ts.map +1 -1
- package/dist/tool/StraightLineTool.d.ts +4 -4
- package/dist/tool/StraightLineTool.d.ts.map +1 -1
- package/dist/tool/TextTool.d.ts +6 -6
- package/dist/tool/TextTool.d.ts.map +1 -1
- package/dist/tool/TriangleTool.d.ts +4 -4
- package/dist/tool/TriangleTool.d.ts.map +1 -1
- package/dist/tool/WhiteboardTool.d.ts +2 -2
- package/dist/tool/WhiteboardTool.d.ts.map +1 -1
- package/dist/utils/FPS.d.ts +15 -0
- package/dist/utils/FPS.d.ts.map +1 -0
- package/dist/utils/Recognizer.d.ts +1 -1
- package/dist/utils/Recognizer.d.ts.map +1 -1
- package/dist/utils/ShadowEmitter.d.ts +2 -2
- package/dist/utils/ShadowEmitter.d.ts.map +1 -1
- package/dist/utils/async.d.ts.map +1 -1
- package/dist/whiteboard.esm.js +599 -337
- package/dist/whiteboard.esm.js.map +4 -4
- package/dist/whiteboard.js +600 -338
- package/dist/whiteboard.js.map +4 -4
- package/package.json +4 -3
package/dist/whiteboard.js
CHANGED
|
@@ -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
|
}
|
|
@@ -25718,6 +25720,10 @@ var ElementModel = class _ElementModel {
|
|
|
25718
25720
|
const ext = this.styleKeys();
|
|
25719
25721
|
return Array.from(new Set(["dashArray", "strokeColor", "fillColor", "strokeWidth"].filter((v) => ext.exclude.indexOf(v) < 0).concat(ext.include)));
|
|
25720
25722
|
}
|
|
25723
|
+
dispose() {
|
|
25724
|
+
this.subDispose();
|
|
25725
|
+
(0, import_forge_room.removeDeepObserver)(this.root, this.handlePropChange);
|
|
25726
|
+
}
|
|
25721
25727
|
};
|
|
25722
25728
|
_defineProperty(ElementModel, "KEYS", {
|
|
25723
25729
|
index: "index",
|
|
@@ -25791,12 +25797,15 @@ var CurveModel = class extends ElementModel {
|
|
|
25791
25797
|
constructor(root, scope) {
|
|
25792
25798
|
super(root, scope);
|
|
25793
25799
|
_defineProperty3(this, "item", null);
|
|
25800
|
+
_defineProperty3(this, "debugPath", void 0);
|
|
25801
|
+
_defineProperty3(this, "debug", false);
|
|
25794
25802
|
if (!this.root.has("type")) {
|
|
25795
25803
|
this.root.set("type", "curve");
|
|
25796
25804
|
}
|
|
25797
25805
|
if (!this.root.has("points")) {
|
|
25798
25806
|
this.root.set("points", new Y2.Array());
|
|
25799
25807
|
}
|
|
25808
|
+
this.debugPath = new scope.Path();
|
|
25800
25809
|
}
|
|
25801
25810
|
average(a2, b2) {
|
|
25802
25811
|
return (a2 + b2) / 2;
|
|
@@ -25805,23 +25814,23 @@ var CurveModel = class extends ElementModel {
|
|
|
25805
25814
|
const groupPoints = (0, import_lodash.chunk)(points, 2);
|
|
25806
25815
|
return ae(groupPoints, {
|
|
25807
25816
|
size: this.strokeWidth,
|
|
25808
|
-
smoothing: 0,
|
|
25809
|
-
thinning: 0.5,
|
|
25817
|
+
smoothing: 0.5,
|
|
25818
|
+
thinning: -0.5,
|
|
25810
25819
|
streamline: 0.5,
|
|
25811
25820
|
simulatePressure: true,
|
|
25812
25821
|
start: {
|
|
25813
|
-
taper: 10,
|
|
25822
|
+
taper: this.strokeWidth * 10,
|
|
25814
25823
|
cap: true
|
|
25815
25824
|
},
|
|
25816
25825
|
end: {
|
|
25817
|
-
taper:
|
|
25826
|
+
taper: this.strokeWidth * 20,
|
|
25818
25827
|
cap: true
|
|
25819
25828
|
}
|
|
25820
25829
|
});
|
|
25821
25830
|
}
|
|
25822
25831
|
matrixedPoints() {
|
|
25823
|
-
const
|
|
25824
|
-
return
|
|
25832
|
+
const currentPoints = (0, import_lodash.chunk)(this.points, 2);
|
|
25833
|
+
return currentPoints.map((_ref) => {
|
|
25825
25834
|
let [x, y] = _ref;
|
|
25826
25835
|
return new this.scope.Point(x, y);
|
|
25827
25836
|
}).map((p) => p.transform(new this.scope.Matrix(this.pointsMatrix))).reduce((result, next) => {
|
|
@@ -25855,27 +25864,41 @@ var CurveModel = class extends ElementModel {
|
|
|
25855
25864
|
}
|
|
25856
25865
|
return path;
|
|
25857
25866
|
}
|
|
25858
|
-
|
|
25859
|
-
|
|
25860
|
-
const
|
|
25861
|
-
|
|
25867
|
+
updateDebugPath() {
|
|
25868
|
+
this.debugPath = new this.scope.Path();
|
|
25869
|
+
const points = (0, import_lodash.chunk)(this.points, 2);
|
|
25870
|
+
for (let i = 0, len = points.length; i < len; i++) {
|
|
25871
|
+
const point = new this.scope.Point(points[i][0], points[i][1]);
|
|
25872
|
+
if (i === 0) {
|
|
25873
|
+
this.debugPath.moveTo(point);
|
|
25874
|
+
} else {
|
|
25875
|
+
this.debugPath.lineTo(point);
|
|
25876
|
+
}
|
|
25877
|
+
this.debugPath.strokeWidth = 1;
|
|
25878
|
+
this.debugPath.strokeColor = new this.scope.Color(1, 0, 0, 1);
|
|
25879
|
+
}
|
|
25862
25880
|
}
|
|
25863
25881
|
onVectorUpdate() {
|
|
25864
25882
|
if (!this.item) {
|
|
25865
25883
|
return;
|
|
25866
25884
|
}
|
|
25885
|
+
if (this.debug) {
|
|
25886
|
+
this.debugPath.remove();
|
|
25887
|
+
this.updateDebugPath();
|
|
25888
|
+
}
|
|
25889
|
+
const points = this.parsePoints(this.matrixedPoints());
|
|
25890
|
+
const path = this.createPath(points);
|
|
25867
25891
|
this.item.removeSegments();
|
|
25868
|
-
this.item.addSegments(
|
|
25869
|
-
this.
|
|
25892
|
+
this.item.addSegments(path.segments);
|
|
25893
|
+
if (this.debug) {
|
|
25894
|
+
this.item.addChild(this.debugPath);
|
|
25895
|
+
}
|
|
25870
25896
|
}
|
|
25871
25897
|
createPaperItem() {
|
|
25872
25898
|
this.item = new this.scope.Path();
|
|
25873
|
-
this.item.strokeCap = "round";
|
|
25874
|
-
this.item.strokeJoin = "round";
|
|
25875
|
-
this.item.strokeScaling = false;
|
|
25876
25899
|
this.item.strokeColor = new this.scope.Color(this.strokeColor);
|
|
25877
25900
|
this.item.fillColor = new this.scope.Color(this.strokeColor);
|
|
25878
|
-
this.
|
|
25901
|
+
this.onVectorUpdate();
|
|
25879
25902
|
}
|
|
25880
25903
|
editorConfig() {
|
|
25881
25904
|
return new EditorConfig();
|
|
@@ -25885,8 +25908,8 @@ var CurveModel = class extends ElementModel {
|
|
|
25885
25908
|
}
|
|
25886
25909
|
styleKeys() {
|
|
25887
25910
|
return {
|
|
25888
|
-
include: ["strokeColor"],
|
|
25889
|
-
exclude: ["
|
|
25911
|
+
include: ["strokeColor", "strokeWidth"],
|
|
25912
|
+
exclude: ["dashArray", "fillColor"]
|
|
25890
25913
|
};
|
|
25891
25914
|
}
|
|
25892
25915
|
onStyleKeyUpdate(key) {
|
|
@@ -25896,8 +25919,12 @@ var CurveModel = class extends ElementModel {
|
|
|
25896
25919
|
if (key === "strokeColor") {
|
|
25897
25920
|
this.item.strokeColor = new this.scope.Color(this.strokeColor);
|
|
25898
25921
|
this.item.fillColor = new this.scope.Color(this.strokeColor);
|
|
25922
|
+
} else if (key === "strokeWidth") {
|
|
25923
|
+
this.onVectorUpdate();
|
|
25899
25924
|
}
|
|
25900
25925
|
}
|
|
25926
|
+
subDispose() {
|
|
25927
|
+
}
|
|
25901
25928
|
};
|
|
25902
25929
|
|
|
25903
25930
|
// src/model/renderable/SelectorModel.ts
|
|
@@ -25932,14 +25959,12 @@ var SelectorModel = class extends ElementModel {
|
|
|
25932
25959
|
this.root.set("points", initPoints);
|
|
25933
25960
|
}
|
|
25934
25961
|
}
|
|
25962
|
+
subDispose() {
|
|
25963
|
+
}
|
|
25935
25964
|
createPaperRect() {
|
|
25936
25965
|
const scope = this.scope;
|
|
25937
25966
|
const bounds = new scope.Rectangle(new scope.Point(this.points[0], this.points[1]), new scope.Size(this.points[2], this.points[3]));
|
|
25938
|
-
return new scope.Path.Rectangle(
|
|
25939
|
-
bounds,
|
|
25940
|
-
new scope.Point(this.points[4], this.points[4])
|
|
25941
|
-
// 圆角
|
|
25942
|
-
);
|
|
25967
|
+
return new scope.Path.Rectangle(bounds, new scope.Point(this.points[4], this.points[4]));
|
|
25943
25968
|
}
|
|
25944
25969
|
onVectorUpdate() {
|
|
25945
25970
|
if (!this.item) {
|
|
@@ -25965,7 +25990,7 @@ var SelectorModel = class extends ElementModel {
|
|
|
25965
25990
|
exclude: []
|
|
25966
25991
|
};
|
|
25967
25992
|
}
|
|
25968
|
-
onStyleKeyUpdate(
|
|
25993
|
+
onStyleKeyUpdate(_key) {
|
|
25969
25994
|
}
|
|
25970
25995
|
};
|
|
25971
25996
|
|
|
@@ -26017,7 +26042,7 @@ var AnimationFrame = class {
|
|
|
26017
26042
|
_defineProperty5(this, "lastTime", 0);
|
|
26018
26043
|
_defineProperty5(this, "fps", 45);
|
|
26019
26044
|
_defineProperty5(this, "handleCallbacks", () => {
|
|
26020
|
-
|
|
26045
|
+
const functions = this.callbacks;
|
|
26021
26046
|
this.callbacks = [];
|
|
26022
26047
|
for (let i = 0, l2 = functions.length; i < l2; i++) {
|
|
26023
26048
|
functions[i]();
|
|
@@ -26070,6 +26095,8 @@ var SegmentsModel = class extends ElementModel {
|
|
|
26070
26095
|
this.root.set("points", new Y4.Array());
|
|
26071
26096
|
}
|
|
26072
26097
|
}
|
|
26098
|
+
subDispose() {
|
|
26099
|
+
}
|
|
26073
26100
|
onVectorUpdate() {
|
|
26074
26101
|
if (!this.item) {
|
|
26075
26102
|
return;
|
|
@@ -26104,7 +26131,7 @@ var SegmentsModel = class extends ElementModel {
|
|
|
26104
26131
|
exclude: []
|
|
26105
26132
|
};
|
|
26106
26133
|
}
|
|
26107
|
-
onStyleKeyUpdate(
|
|
26134
|
+
onStyleKeyUpdate(_key) {
|
|
26108
26135
|
}
|
|
26109
26136
|
};
|
|
26110
26137
|
|
|
@@ -26198,6 +26225,9 @@ var LineTool = class extends WhiteboardTool {
|
|
|
26198
26225
|
this.tool.minDistance = 1;
|
|
26199
26226
|
}
|
|
26200
26227
|
onMouseDown(event) {
|
|
26228
|
+
if (this.elementModel) {
|
|
26229
|
+
this.elementModel.dispose();
|
|
26230
|
+
}
|
|
26201
26231
|
this.elementModel = this.modelGetter().createLinePath(true);
|
|
26202
26232
|
this.from = event.point.clone();
|
|
26203
26233
|
this.to = event.point.clone();
|
|
@@ -26273,6 +26303,8 @@ var LineModel = class extends ElementModel {
|
|
|
26273
26303
|
this.root.set("tailArrow", "normal");
|
|
26274
26304
|
}
|
|
26275
26305
|
}
|
|
26306
|
+
subDispose() {
|
|
26307
|
+
}
|
|
26276
26308
|
onVectorUpdate() {
|
|
26277
26309
|
if (!this.item) {
|
|
26278
26310
|
return;
|
|
@@ -26309,7 +26341,7 @@ var LineModel = class extends ElementModel {
|
|
|
26309
26341
|
this.item.addChildren(this.renderLine());
|
|
26310
26342
|
}
|
|
26311
26343
|
createArrow(path) {
|
|
26312
|
-
|
|
26344
|
+
const [headPath, tailPath] = [new this.scope.Path(), new this.scope.Path()];
|
|
26313
26345
|
if (!path) {
|
|
26314
26346
|
return [headPath, tailPath];
|
|
26315
26347
|
}
|
|
@@ -26363,7 +26395,7 @@ var LineModel = class extends ElementModel {
|
|
|
26363
26395
|
exclude: ["fillColor"]
|
|
26364
26396
|
};
|
|
26365
26397
|
}
|
|
26366
|
-
onStyleKeyUpdate(
|
|
26398
|
+
onStyleKeyUpdate(_key) {
|
|
26367
26399
|
this.onVectorUpdate();
|
|
26368
26400
|
}
|
|
26369
26401
|
};
|
|
@@ -26418,6 +26450,7 @@ var LineControlPoint = class {
|
|
|
26418
26450
|
|
|
26419
26451
|
// src/model/renderable/PointTextModel.ts
|
|
26420
26452
|
var Y6 = __toESM(require("yjs"), 1);
|
|
26453
|
+
var import_forge_room2 = require("@netless/forge-room");
|
|
26421
26454
|
function _defineProperty10(e, r, t) {
|
|
26422
26455
|
return (r = _toPropertyKey10(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
26423
26456
|
}
|
|
@@ -26486,6 +26519,9 @@ var PointTextModel = class extends ElementModel {
|
|
|
26486
26519
|
}, 60);
|
|
26487
26520
|
}
|
|
26488
26521
|
}
|
|
26522
|
+
subDispose() {
|
|
26523
|
+
(0, import_forge_room2.removeObserver)(this.root, this.handleTextPropChange);
|
|
26524
|
+
}
|
|
26489
26525
|
getInternalMeasurement() {
|
|
26490
26526
|
if (!this.item) {
|
|
26491
26527
|
return null;
|
|
@@ -26591,6 +26627,8 @@ var TriangleModel = class extends ElementModel {
|
|
|
26591
26627
|
this.root.set("points", new Y7.Array());
|
|
26592
26628
|
}
|
|
26593
26629
|
}
|
|
26630
|
+
subDispose() {
|
|
26631
|
+
}
|
|
26594
26632
|
createPaperItem() {
|
|
26595
26633
|
this.item = new this.scope.Path();
|
|
26596
26634
|
this.item.strokeCap = "butt";
|
|
@@ -26647,7 +26685,7 @@ var TriangleModel = class extends ElementModel {
|
|
|
26647
26685
|
exclude: []
|
|
26648
26686
|
};
|
|
26649
26687
|
}
|
|
26650
|
-
onStyleKeyUpdate(
|
|
26688
|
+
onStyleKeyUpdate(_key) {
|
|
26651
26689
|
}
|
|
26652
26690
|
};
|
|
26653
26691
|
|
|
@@ -26686,6 +26724,8 @@ var RectangleModel = class extends ElementModel {
|
|
|
26686
26724
|
this.root.set("radius", 0);
|
|
26687
26725
|
}
|
|
26688
26726
|
}
|
|
26727
|
+
subDispose() {
|
|
26728
|
+
}
|
|
26689
26729
|
createSegments() {
|
|
26690
26730
|
const [a2, b2, c, d] = this.points;
|
|
26691
26731
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
@@ -26817,7 +26857,7 @@ var RectangleModel = class extends ElementModel {
|
|
|
26817
26857
|
exclude: []
|
|
26818
26858
|
};
|
|
26819
26859
|
}
|
|
26820
|
-
onStyleKeyUpdate(
|
|
26860
|
+
onStyleKeyUpdate(_key) {
|
|
26821
26861
|
}
|
|
26822
26862
|
};
|
|
26823
26863
|
|
|
@@ -26958,9 +26998,11 @@ var EraserModel = class extends ElementModel {
|
|
|
26958
26998
|
exclude: []
|
|
26959
26999
|
};
|
|
26960
27000
|
}
|
|
26961
|
-
onStyleKeyUpdate(
|
|
27001
|
+
onStyleKeyUpdate(_key) {
|
|
26962
27002
|
return;
|
|
26963
27003
|
}
|
|
27004
|
+
subDispose() {
|
|
27005
|
+
}
|
|
26964
27006
|
};
|
|
26965
27007
|
|
|
26966
27008
|
// src/model/renderable/LaserPointerModel.ts
|
|
@@ -27117,30 +27159,15 @@ var LaserPointerModel = class extends ElementModel {
|
|
|
27117
27159
|
exclude: []
|
|
27118
27160
|
};
|
|
27119
27161
|
}
|
|
27120
|
-
onStyleKeyUpdate(
|
|
27162
|
+
onStyleKeyUpdate(_key) {
|
|
27121
27163
|
return;
|
|
27122
27164
|
}
|
|
27165
|
+
subDispose() {
|
|
27166
|
+
}
|
|
27123
27167
|
};
|
|
27124
27168
|
|
|
27125
27169
|
// src/WhitePermissions.ts
|
|
27126
|
-
var
|
|
27127
|
-
function _defineProperty15(e, r, t) {
|
|
27128
|
-
return (r = _toPropertyKey15(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
27129
|
-
}
|
|
27130
|
-
function _toPropertyKey15(t) {
|
|
27131
|
-
var i = _toPrimitive15(t, "string");
|
|
27132
|
-
return "symbol" == typeof i ? i : i + "";
|
|
27133
|
-
}
|
|
27134
|
-
function _toPrimitive15(t, r) {
|
|
27135
|
-
if ("object" != typeof t || !t) return t;
|
|
27136
|
-
var e = t[Symbol.toPrimitive];
|
|
27137
|
-
if (void 0 !== e) {
|
|
27138
|
-
var i = e.call(t, r || "default");
|
|
27139
|
-
if ("object" != typeof i) return i;
|
|
27140
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
27141
|
-
}
|
|
27142
|
-
return ("string" === r ? String : Number)(t);
|
|
27143
|
-
}
|
|
27170
|
+
var import_forge_room3 = require("@netless/forge-room");
|
|
27144
27171
|
var WhiteboardPermissionFlag = function(WhiteboardPermissionFlag2) {
|
|
27145
27172
|
WhiteboardPermissionFlag2[WhiteboardPermissionFlag2["none"] = 0] = "none";
|
|
27146
27173
|
WhiteboardPermissionFlag2[WhiteboardPermissionFlag2["draw"] = 1] = "draw";
|
|
@@ -27153,120 +27180,28 @@ var WhiteboardPermissionFlag = function(WhiteboardPermissionFlag2) {
|
|
|
27153
27180
|
WhiteboardPermissionFlag2[WhiteboardPermissionFlag2["all"] = WhiteboardPermissionFlag2.draw | WhiteboardPermissionFlag2.editSelf | WhiteboardPermissionFlag2.editOthers | WhiteboardPermissionFlag2.deleteSelf | WhiteboardPermissionFlag2.deleteOthers | WhiteboardPermissionFlag2.mainView | WhiteboardPermissionFlag2.setOthersView] = "all";
|
|
27154
27181
|
return WhiteboardPermissionFlag2;
|
|
27155
27182
|
}({});
|
|
27156
|
-
var WhiteboardPermissions = class extends
|
|
27157
|
-
constructor(userManager, requestUserMap) {
|
|
27158
|
-
super();
|
|
27159
|
-
_defineProperty15(this, "requestUserMap", void 0);
|
|
27160
|
-
_defineProperty15(this, "userManager", void 0);
|
|
27161
|
-
_defineProperty15(this, "observers", /* @__PURE__ */ new Map());
|
|
27162
|
-
_defineProperty15(this, "handleUserLeave", (user) => {
|
|
27163
|
-
const cb = this.observers.get(user.id);
|
|
27164
|
-
if (cb) {
|
|
27165
|
-
this.requestUserMap(user.id).unobserve(cb);
|
|
27166
|
-
}
|
|
27167
|
-
});
|
|
27168
|
-
_defineProperty15(this, "handleUserJoin", (user) => {
|
|
27169
|
-
this.addObserve(user.id);
|
|
27170
|
-
});
|
|
27171
|
-
this.userManager = userManager;
|
|
27172
|
-
this.requestUserMap = requestUserMap;
|
|
27173
|
-
this.createModel(this.userManager.selfId);
|
|
27174
|
-
this.userManager.userIdList().forEach((userId) => {
|
|
27175
|
-
this.addObserve(userId);
|
|
27176
|
-
});
|
|
27177
|
-
this.userManager.on("join", this.handleUserJoin);
|
|
27178
|
-
this.userManager.on("leave", this.handleUserLeave);
|
|
27179
|
-
}
|
|
27180
|
-
addObserve(userId) {
|
|
27181
|
-
if (this.observers.has(userId)) {
|
|
27182
|
-
return;
|
|
27183
|
-
}
|
|
27184
|
-
const observer = (evt) => {
|
|
27185
|
-
this.handleUserPermissionChange(userId, evt);
|
|
27186
|
-
};
|
|
27187
|
-
this.observers.set(userId, observer);
|
|
27188
|
-
this.requestUserMap(userId).observe(observer);
|
|
27189
|
-
}
|
|
27190
|
-
createModel(userId) {
|
|
27191
|
-
const userMap = this.requestUserMap(userId);
|
|
27192
|
-
if (!userMap.has("permission")) {
|
|
27193
|
-
userMap.set("permission", 0);
|
|
27194
|
-
}
|
|
27195
|
-
}
|
|
27196
|
-
handleUserPermissionChange(userId, evt) {
|
|
27197
|
-
for (const [key, value] of evt.changes.keys.entries()) {
|
|
27198
|
-
if (key === "permission") {
|
|
27199
|
-
if (value.action === "add" || value.action === "update") {
|
|
27200
|
-
const newValue = this.requestUserMap(userId).get("permission");
|
|
27201
|
-
this.emit("change", userId, this.resolveFlags(newValue), newValue);
|
|
27202
|
-
}
|
|
27203
|
-
}
|
|
27204
|
-
}
|
|
27205
|
-
}
|
|
27183
|
+
var WhiteboardPermissions = class extends import_forge_room3.AbstractApplicationPermissions {
|
|
27206
27184
|
/**
|
|
27207
|
-
|
|
27208
|
-
|
|
27209
|
-
|
|
27210
|
-
|
|
27185
|
+
* 解析权限列表组合
|
|
27186
|
+
* @param {number} value - 权限数字值
|
|
27187
|
+
* @return {WhiteboardPermissionFlag[]} - 权限列表
|
|
27188
|
+
*/
|
|
27211
27189
|
resolveFlags(value) {
|
|
27212
27190
|
return [WhiteboardPermissionFlag.draw, WhiteboardPermissionFlag.editSelf, WhiteboardPermissionFlag.editOthers, WhiteboardPermissionFlag.deleteSelf, WhiteboardPermissionFlag.deleteOthers, WhiteboardPermissionFlag.mainView, WhiteboardPermissionFlag.setOthersView].filter((v) => (v & value) !== 0);
|
|
27213
27191
|
}
|
|
27214
|
-
/**
|
|
27215
|
-
* 获取权限列表组合对应的数值
|
|
27216
|
-
* @param { string } userId 不传表示获取自己
|
|
27217
|
-
*/
|
|
27218
|
-
getPermissionValue(userId) {
|
|
27219
|
-
return this.requestUserMap(userId ?? this.userManager.selfId).get("permission") ?? 0;
|
|
27220
|
-
}
|
|
27221
|
-
/**
|
|
27222
|
-
* 获取权限列表
|
|
27223
|
-
* @param {string=} userId 可选, 不传表示获取自己
|
|
27224
|
-
*/
|
|
27225
|
-
getPermissionFlags(userId) {
|
|
27226
|
-
const value = this.requestUserMap(userId ?? this.userManager.selfId).get("permission") ?? 0;
|
|
27227
|
-
return this.resolveFlags(value);
|
|
27228
|
-
}
|
|
27229
|
-
/**
|
|
27230
|
-
* 返回对应 userId 是否有相应权限
|
|
27231
|
-
* @param {string=} userId 可选, 不传表示返回自己是否有相应权限
|
|
27232
|
-
* @param {WhiteboardPermissionFlag} flag
|
|
27233
|
-
*/
|
|
27234
|
-
hasPermission(flag, userId) {
|
|
27235
|
-
return ((this.requestUserMap(userId ?? this.userManager.selfId).get("permission") ?? 0) & flag) !== 0;
|
|
27236
|
-
}
|
|
27237
|
-
/**
|
|
27238
|
-
* 添加权限
|
|
27239
|
-
* @param {WhiteboardPermissionFlag} flag 权限标记
|
|
27240
|
-
* @param {string=} userId 可选, 为 userId 添加权限, 不传表示为自己添加权限
|
|
27241
|
-
*/
|
|
27242
|
-
addPermission(flag, userId) {
|
|
27243
|
-
const userMap = this.requestUserMap(userId ?? this.userManager.selfId);
|
|
27244
|
-
const oldValue = userMap.get("permission") ?? 0;
|
|
27245
|
-
this.requestUserMap(userId ?? this.userManager.selfId).set("permission", oldValue | flag);
|
|
27246
|
-
}
|
|
27247
|
-
/**
|
|
27248
|
-
* 移除权限
|
|
27249
|
-
* @param {WhiteboardPermissionFlag} flag 权限标记
|
|
27250
|
-
* @param {string=} userId 可选, 为 userId 移除权限, 不传表示为自己移除权限
|
|
27251
|
-
*/
|
|
27252
|
-
removePermission(flag, userId) {
|
|
27253
|
-
const userMap = this.requestUserMap(userId ?? this.userManager.selfId);
|
|
27254
|
-
const oldValue = userMap.get("permission") ?? 0;
|
|
27255
|
-
this.requestUserMap(userId ?? this.userManager.selfId).set("permission", oldValue & ~flag);
|
|
27256
|
-
}
|
|
27257
27192
|
};
|
|
27258
27193
|
|
|
27259
27194
|
// src/model/renderable/StraightLineModel.ts
|
|
27260
27195
|
var Y11 = __toESM(require("yjs"), 1);
|
|
27261
27196
|
var import_lodash7 = __toESM(require_lodash(), 1);
|
|
27262
|
-
function
|
|
27263
|
-
return (r =
|
|
27197
|
+
function _defineProperty15(e, r, t) {
|
|
27198
|
+
return (r = _toPropertyKey15(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
27264
27199
|
}
|
|
27265
|
-
function
|
|
27266
|
-
var i =
|
|
27200
|
+
function _toPropertyKey15(t) {
|
|
27201
|
+
var i = _toPrimitive15(t, "string");
|
|
27267
27202
|
return "symbol" == typeof i ? i : i + "";
|
|
27268
27203
|
}
|
|
27269
|
-
function
|
|
27204
|
+
function _toPrimitive15(t, r) {
|
|
27270
27205
|
if ("object" != typeof t || !t) return t;
|
|
27271
27206
|
var e = t[Symbol.toPrimitive];
|
|
27272
27207
|
if (void 0 !== e) {
|
|
@@ -27279,7 +27214,7 @@ function _toPrimitive16(t, r) {
|
|
|
27279
27214
|
var StraightLineModel = class extends ElementModel {
|
|
27280
27215
|
constructor(root, scope) {
|
|
27281
27216
|
super(root, scope);
|
|
27282
|
-
|
|
27217
|
+
_defineProperty15(this, "item", null);
|
|
27283
27218
|
if (!this.root.has("type")) {
|
|
27284
27219
|
this.root.set("type", "line");
|
|
27285
27220
|
}
|
|
@@ -27287,6 +27222,8 @@ var StraightLineModel = class extends ElementModel {
|
|
|
27287
27222
|
this.root.set("points", new Y11.Array());
|
|
27288
27223
|
}
|
|
27289
27224
|
}
|
|
27225
|
+
subDispose() {
|
|
27226
|
+
}
|
|
27290
27227
|
onVectorUpdate() {
|
|
27291
27228
|
if (!this.item) {
|
|
27292
27229
|
return;
|
|
@@ -27360,7 +27297,7 @@ var StraightLineModel = class extends ElementModel {
|
|
|
27360
27297
|
exclude: ["fillColor"]
|
|
27361
27298
|
};
|
|
27362
27299
|
}
|
|
27363
|
-
onStyleKeyUpdate(
|
|
27300
|
+
onStyleKeyUpdate(_key) {
|
|
27364
27301
|
if (!this.item) {
|
|
27365
27302
|
return;
|
|
27366
27303
|
}
|
|
@@ -27370,6 +27307,83 @@ var StraightLineModel = class extends ElementModel {
|
|
|
27370
27307
|
}
|
|
27371
27308
|
};
|
|
27372
27309
|
|
|
27310
|
+
// src/model/renderable/ImageModel.ts
|
|
27311
|
+
function _defineProperty16(e, r, t) {
|
|
27312
|
+
return (r = _toPropertyKey16(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
27313
|
+
}
|
|
27314
|
+
function _toPropertyKey16(t) {
|
|
27315
|
+
var i = _toPrimitive16(t, "string");
|
|
27316
|
+
return "symbol" == typeof i ? i : i + "";
|
|
27317
|
+
}
|
|
27318
|
+
function _toPrimitive16(t, r) {
|
|
27319
|
+
if ("object" != typeof t || !t) return t;
|
|
27320
|
+
var e = t[Symbol.toPrimitive];
|
|
27321
|
+
if (void 0 !== e) {
|
|
27322
|
+
var i = e.call(t, r || "default");
|
|
27323
|
+
if ("object" != typeof i) return i;
|
|
27324
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
27325
|
+
}
|
|
27326
|
+
return ("string" === r ? String : Number)(t);
|
|
27327
|
+
}
|
|
27328
|
+
var ImageModel = class extends ElementModel {
|
|
27329
|
+
get src() {
|
|
27330
|
+
return this.root.get("src");
|
|
27331
|
+
}
|
|
27332
|
+
constructor(root, scope, imageSets) {
|
|
27333
|
+
super(root, scope);
|
|
27334
|
+
_defineProperty16(this, "item", null);
|
|
27335
|
+
_defineProperty16(this, "imageSets", void 0);
|
|
27336
|
+
this.imageSets = imageSets;
|
|
27337
|
+
if (!this.root.has("type")) {
|
|
27338
|
+
this.root.set("type", "image");
|
|
27339
|
+
}
|
|
27340
|
+
this.root.set(ElementModel.KEYS.shadow, "");
|
|
27341
|
+
}
|
|
27342
|
+
subDispose() {
|
|
27343
|
+
const img = this.imageSets.querySelector(`[id='${this.uuid}']`);
|
|
27344
|
+
if (img) {
|
|
27345
|
+
img.remove();
|
|
27346
|
+
}
|
|
27347
|
+
}
|
|
27348
|
+
createPaperItem() {
|
|
27349
|
+
if (this.item) {
|
|
27350
|
+
return;
|
|
27351
|
+
}
|
|
27352
|
+
if (!this.imageSets.querySelector(`[id='${this.uuid}']`)) {
|
|
27353
|
+
const img = document.createElement("img");
|
|
27354
|
+
img.src = this.src;
|
|
27355
|
+
img.id = this.uuid;
|
|
27356
|
+
this.imageSets.appendChild(img);
|
|
27357
|
+
}
|
|
27358
|
+
this.item = new this.scope.Raster(this.uuid);
|
|
27359
|
+
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27360
|
+
this.item.matrix = matrix;
|
|
27361
|
+
}
|
|
27362
|
+
onVectorUpdate() {
|
|
27363
|
+
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27364
|
+
if (this.item) {
|
|
27365
|
+
this.item.matrix = matrix;
|
|
27366
|
+
}
|
|
27367
|
+
}
|
|
27368
|
+
vectorKeys() {
|
|
27369
|
+
return [];
|
|
27370
|
+
}
|
|
27371
|
+
styleKeys() {
|
|
27372
|
+
return {
|
|
27373
|
+
include: [],
|
|
27374
|
+
exclude: ["dashArray", "strokeColor", "fillColor", "strokeWidth"]
|
|
27375
|
+
};
|
|
27376
|
+
}
|
|
27377
|
+
onStyleKeyUpdate(_key) {
|
|
27378
|
+
}
|
|
27379
|
+
editorConfig() {
|
|
27380
|
+
const cfg = new EditorConfig();
|
|
27381
|
+
cfg.resizeModel = () => "four-corner";
|
|
27382
|
+
cfg.uniformScale = () => true;
|
|
27383
|
+
return cfg;
|
|
27384
|
+
}
|
|
27385
|
+
};
|
|
27386
|
+
|
|
27373
27387
|
// src/model/RenderableModel.ts
|
|
27374
27388
|
function _defineProperty17(e, r, t) {
|
|
27375
27389
|
return (r = _toPropertyKey17(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
@@ -27388,11 +27402,11 @@ function _toPrimitive17(t, r) {
|
|
|
27388
27402
|
}
|
|
27389
27403
|
return ("string" === r ? String : Number)(t);
|
|
27390
27404
|
}
|
|
27391
|
-
var RenderableModel = class extends
|
|
27405
|
+
var RenderableModel = class extends import_eventemitter3.default {
|
|
27392
27406
|
get uuid() {
|
|
27393
|
-
return (0, import_uuid.v4)();
|
|
27407
|
+
return (0, import_uuid.v4)().replace(/-/g, "");
|
|
27394
27408
|
}
|
|
27395
|
-
constructor(layerId, shadowEmitter, elements, scope, toolbarModel, userManager, hasPermission) {
|
|
27409
|
+
constructor(layerId, shadowEmitter, elements, scope, toolbarModel, userManager, imageSets, hasPermission) {
|
|
27396
27410
|
super();
|
|
27397
27411
|
_defineProperty17(this, "scope", void 0);
|
|
27398
27412
|
_defineProperty17(this, "toolbarModel", void 0);
|
|
@@ -27403,6 +27417,7 @@ var RenderableModel = class extends import_eventemitter32.default {
|
|
|
27403
27417
|
_defineProperty17(this, "maxIndex", -1);
|
|
27404
27418
|
_defineProperty17(this, "hasPermission", void 0);
|
|
27405
27419
|
_defineProperty17(this, "shadowEmitter", void 0);
|
|
27420
|
+
_defineProperty17(this, "imageSets", void 0);
|
|
27406
27421
|
_defineProperty17(this, "onElementsChange", (event) => {
|
|
27407
27422
|
for (const [key, value] of event.changes.keys.entries()) {
|
|
27408
27423
|
if (value.action === "add") {
|
|
@@ -27418,6 +27433,7 @@ var RenderableModel = class extends import_eventemitter32.default {
|
|
|
27418
27433
|
}
|
|
27419
27434
|
}
|
|
27420
27435
|
});
|
|
27436
|
+
this.imageSets = imageSets;
|
|
27421
27437
|
this.hasPermission = hasPermission;
|
|
27422
27438
|
this.shadowEmitter = shadowEmitter;
|
|
27423
27439
|
this.layerId = layerId;
|
|
@@ -27477,6 +27493,8 @@ var RenderableModel = class extends import_eventemitter32.default {
|
|
|
27477
27493
|
model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, (uuid) => {
|
|
27478
27494
|
this.removeElementItem(uuid);
|
|
27479
27495
|
});
|
|
27496
|
+
} else if (type === "image") {
|
|
27497
|
+
model = new ImageModel(yMap, this.scope, this.imageSets);
|
|
27480
27498
|
}
|
|
27481
27499
|
if (model) {
|
|
27482
27500
|
model.shadowEmitter = this.shadowEmitter;
|
|
@@ -27509,10 +27527,26 @@ var RenderableModel = class extends import_eventemitter32.default {
|
|
|
27509
27527
|
confirmPermission() {
|
|
27510
27528
|
const hasPermission = this.hasPermission(WhiteboardPermissionFlag.draw);
|
|
27511
27529
|
if (!hasPermission) {
|
|
27512
|
-
|
|
27530
|
+
(0, import_forge_room4.log)("[@netless/forge-whiteboard] no permission to draw", {}, "warning");
|
|
27513
27531
|
}
|
|
27514
27532
|
return hasPermission;
|
|
27515
27533
|
}
|
|
27534
|
+
createImage(src) {
|
|
27535
|
+
if (!this.confirmPermission()) {
|
|
27536
|
+
return;
|
|
27537
|
+
}
|
|
27538
|
+
const model = new ImageModel(new Y12.Map(), this.scope, this.imageSets);
|
|
27539
|
+
model.root.set("src", src);
|
|
27540
|
+
const initMatrix = new this.scope.Matrix();
|
|
27541
|
+
const center = this.scope.project.view.center;
|
|
27542
|
+
initMatrix.translate({
|
|
27543
|
+
x: center.x,
|
|
27544
|
+
y: center.y
|
|
27545
|
+
});
|
|
27546
|
+
model.appendPointsMatrix(initMatrix);
|
|
27547
|
+
model.ownerId = this.userManager.selfId;
|
|
27548
|
+
this.addElementToDoc(model.root);
|
|
27549
|
+
}
|
|
27516
27550
|
createCurve() {
|
|
27517
27551
|
let shadow = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
|
|
27518
27552
|
if (!this.confirmPermission()) {
|
|
@@ -27582,7 +27616,7 @@ var RenderableModel = class extends import_eventemitter32.default {
|
|
|
27582
27616
|
return segmentsModel;
|
|
27583
27617
|
}
|
|
27584
27618
|
createSelector() {
|
|
27585
|
-
let
|
|
27619
|
+
let _shadow = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
|
|
27586
27620
|
if (!this.hasPermission(WhiteboardPermissionFlag.editSelf) && !this.hasPermission(WhiteboardPermissionFlag.deleteOthers)) {
|
|
27587
27621
|
return null;
|
|
27588
27622
|
}
|
|
@@ -27639,7 +27673,11 @@ var RenderableModel = class extends import_eventemitter32.default {
|
|
|
27639
27673
|
});
|
|
27640
27674
|
}
|
|
27641
27675
|
dispose() {
|
|
27676
|
+
(0, import_forge_room4.removeObserver)(this.elements, this.onElementsChange);
|
|
27642
27677
|
this.elements.clear();
|
|
27678
|
+
Array.from(this.elementModels.values()).forEach((model) => {
|
|
27679
|
+
model.dispose();
|
|
27680
|
+
});
|
|
27643
27681
|
}
|
|
27644
27682
|
};
|
|
27645
27683
|
|
|
@@ -27682,10 +27720,10 @@ var AnglePrecision = Deg2Rad(2);
|
|
|
27682
27720
|
var Phi = 0.5 * (-1 + Math.sqrt(5));
|
|
27683
27721
|
function DollarRecognizer() {
|
|
27684
27722
|
this.Unistrokes = new Array(3);
|
|
27685
|
-
this.Unistrokes[0] = new Unistroke("triangle", new
|
|
27686
|
-
this.Unistrokes[1] = new Unistroke("rectangle", new
|
|
27687
|
-
this.Unistrokes[2] = new Unistroke("circle", new
|
|
27688
|
-
this.Unistrokes[3] = new Unistroke("arrow", new
|
|
27723
|
+
this.Unistrokes[0] = new Unistroke("triangle", [new Point(137, 139), new Point(135, 141), new Point(133, 144), new Point(132, 146), new Point(130, 149), new Point(128, 151), new Point(126, 155), new Point(123, 160), new Point(120, 166), new Point(116, 171), new Point(112, 177), new Point(107, 183), new Point(102, 188), new Point(100, 191), new Point(95, 195), new Point(90, 199), new Point(86, 203), new Point(82, 206), new Point(80, 209), new Point(75, 213), new Point(73, 213), new Point(70, 216), new Point(67, 219), new Point(64, 221), new Point(61, 223), new Point(60, 225), new Point(62, 226), new Point(65, 225), new Point(67, 226), new Point(74, 226), new Point(77, 227), new Point(85, 229), new Point(91, 230), new Point(99, 231), new Point(108, 232), new Point(116, 233), new Point(125, 233), new Point(134, 234), new Point(145, 233), new Point(153, 232), new Point(160, 233), new Point(170, 234), new Point(177, 235), new Point(179, 236), new Point(186, 237), new Point(193, 238), new Point(198, 239), new Point(200, 237), new Point(202, 239), new Point(204, 238), new Point(206, 234), new Point(205, 230), new Point(202, 222), new Point(197, 216), new Point(192, 207), new Point(186, 198), new Point(179, 189), new Point(174, 183), new Point(170, 178), new Point(164, 171), new Point(161, 168), new Point(154, 160), new Point(148, 155), new Point(143, 150), new Point(138, 148), new Point(136, 148)]);
|
|
27724
|
+
this.Unistrokes[1] = new Unistroke("rectangle", [new Point(78, 149), new Point(78, 153), new Point(78, 157), new Point(78, 160), new Point(79, 162), new Point(79, 164), new Point(79, 167), new Point(79, 169), new Point(79, 173), new Point(79, 178), new Point(79, 183), new Point(80, 189), new Point(80, 193), new Point(80, 198), new Point(80, 202), new Point(81, 208), new Point(81, 210), new Point(81, 216), new Point(82, 222), new Point(82, 224), new Point(82, 227), new Point(83, 229), new Point(83, 231), new Point(85, 230), new Point(88, 232), new Point(90, 233), new Point(92, 232), new Point(94, 233), new Point(99, 232), new Point(102, 233), new Point(106, 233), new Point(109, 234), new Point(117, 235), new Point(123, 236), new Point(126, 236), new Point(135, 237), new Point(142, 238), new Point(145, 238), new Point(152, 238), new Point(154, 239), new Point(165, 238), new Point(174, 237), new Point(179, 236), new Point(186, 235), new Point(191, 235), new Point(195, 233), new Point(197, 233), new Point(200, 233), new Point(201, 235), new Point(201, 233), new Point(199, 231), new Point(198, 226), new Point(198, 220), new Point(196, 207), new Point(195, 195), new Point(195, 181), new Point(195, 173), new Point(195, 163), new Point(194, 155), new Point(192, 145), new Point(192, 143), new Point(192, 138), new Point(191, 135), new Point(191, 133), new Point(191, 130), new Point(190, 128), new Point(188, 129), new Point(186, 129), new Point(181, 132), new Point(173, 131), new Point(162, 131), new Point(151, 132), new Point(149, 132), new Point(138, 132), new Point(136, 132), new Point(122, 131), new Point(120, 131), new Point(109, 130), new Point(107, 130), new Point(90, 132), new Point(81, 133), new Point(76, 133)]);
|
|
27725
|
+
this.Unistrokes[2] = new Unistroke("circle", [new Point(127, 141), new Point(124, 140), new Point(120, 139), new Point(118, 139), new Point(116, 139), new Point(111, 140), new Point(109, 141), new Point(104, 144), new Point(100, 147), new Point(96, 152), new Point(93, 157), new Point(90, 163), new Point(87, 169), new Point(85, 175), new Point(83, 181), new Point(82, 190), new Point(82, 195), new Point(83, 200), new Point(84, 205), new Point(88, 213), new Point(91, 216), new Point(96, 219), new Point(103, 222), new Point(108, 224), new Point(111, 224), new Point(120, 224), new Point(133, 223), new Point(142, 222), new Point(152, 218), new Point(160, 214), new Point(167, 210), new Point(173, 204), new Point(178, 198), new Point(179, 196), new Point(182, 188), new Point(182, 177), new Point(178, 167), new Point(170, 150), new Point(163, 138), new Point(152, 130), new Point(143, 129), new Point(140, 131), new Point(129, 136), new Point(126, 139)]);
|
|
27726
|
+
this.Unistrokes[3] = new Unistroke("arrow", [new Point(68, 222), new Point(70, 220), new Point(73, 218), new Point(75, 217), new Point(77, 215), new Point(80, 213), new Point(82, 212), new Point(84, 210), new Point(87, 209), new Point(89, 208), new Point(92, 206), new Point(95, 204), new Point(101, 201), new Point(106, 198), new Point(112, 194), new Point(118, 191), new Point(124, 187), new Point(127, 186), new Point(132, 183), new Point(138, 181), new Point(141, 180), new Point(146, 178), new Point(154, 173), new Point(159, 171), new Point(161, 170), new Point(166, 167), new Point(168, 167), new Point(171, 166), new Point(174, 164), new Point(177, 162), new Point(180, 160), new Point(182, 158), new Point(183, 156), new Point(181, 154), new Point(178, 153), new Point(171, 153), new Point(164, 153), new Point(160, 153), new Point(150, 154), new Point(147, 155), new Point(141, 157), new Point(137, 158), new Point(135, 158), new Point(137, 158), new Point(140, 157), new Point(143, 156), new Point(151, 154), new Point(160, 152), new Point(170, 149), new Point(179, 147), new Point(185, 145), new Point(192, 144), new Point(196, 144), new Point(198, 144), new Point(200, 144), new Point(201, 147), new Point(199, 149), new Point(194, 157), new Point(191, 160), new Point(186, 167), new Point(180, 176), new Point(177, 179), new Point(171, 187), new Point(169, 189), new Point(165, 194), new Point(164, 196)]);
|
|
27689
27727
|
this.Recognize = function(points, useProtractor) {
|
|
27690
27728
|
var t0 = Date.now();
|
|
27691
27729
|
var candidate = new Unistroke("", points);
|
|
@@ -27746,7 +27784,7 @@ function RotateBy(points, radians) {
|
|
|
27746
27784
|
var c = Centroid(points);
|
|
27747
27785
|
var cos = Math.cos(radians);
|
|
27748
27786
|
var sin = Math.sin(radians);
|
|
27749
|
-
var newpoints =
|
|
27787
|
+
var newpoints = [];
|
|
27750
27788
|
for (var i = 0; i < points.length; i++) {
|
|
27751
27789
|
var qx = (points[i].X - c.X) * cos - (points[i].Y - c.Y) * sin + c.X;
|
|
27752
27790
|
var qy = (points[i].X - c.X) * sin + (points[i].Y - c.Y) * cos + c.Y;
|
|
@@ -27756,7 +27794,7 @@ function RotateBy(points, radians) {
|
|
|
27756
27794
|
}
|
|
27757
27795
|
function ScaleTo(points, size) {
|
|
27758
27796
|
var B2 = BoundingBox(points);
|
|
27759
|
-
var newpoints =
|
|
27797
|
+
var newpoints = [];
|
|
27760
27798
|
for (var i = 0; i < points.length; i++) {
|
|
27761
27799
|
var qx = points[i].X * (size / B2.Width);
|
|
27762
27800
|
var qy = points[i].Y * (size / B2.Height);
|
|
@@ -27766,7 +27804,7 @@ function ScaleTo(points, size) {
|
|
|
27766
27804
|
}
|
|
27767
27805
|
function TranslateTo(points, pt) {
|
|
27768
27806
|
var c = Centroid(points);
|
|
27769
|
-
var newpoints =
|
|
27807
|
+
var newpoints = [];
|
|
27770
27808
|
for (var i = 0; i < points.length; i++) {
|
|
27771
27809
|
var qx = points[i].X + pt.X - c.X;
|
|
27772
27810
|
var qy = points[i].Y + pt.Y - c.Y;
|
|
@@ -27776,14 +27814,14 @@ function TranslateTo(points, pt) {
|
|
|
27776
27814
|
}
|
|
27777
27815
|
function Vectorize(points) {
|
|
27778
27816
|
var sum = 0;
|
|
27779
|
-
var vector =
|
|
27780
|
-
for (
|
|
27817
|
+
var vector = [];
|
|
27818
|
+
for (let i = 0; i < points.length; i++) {
|
|
27781
27819
|
vector[vector.length] = points[i].X;
|
|
27782
27820
|
vector[vector.length] = points[i].Y;
|
|
27783
27821
|
sum += points[i].X * points[i].X + points[i].Y * points[i].Y;
|
|
27784
27822
|
}
|
|
27785
27823
|
var magnitude = Math.sqrt(sum);
|
|
27786
|
-
for (
|
|
27824
|
+
for (let i = 0; i < vector.length; i++)
|
|
27787
27825
|
vector[i] /= magnitude;
|
|
27788
27826
|
return vector;
|
|
27789
27827
|
}
|
|
@@ -27937,17 +27975,35 @@ var CurveTool = class extends WhiteboardTool {
|
|
|
27937
27975
|
_defineProperty19(this, "pointCount", 0);
|
|
27938
27976
|
this.tool.minDistance = 1;
|
|
27939
27977
|
}
|
|
27940
|
-
onMouseDown(
|
|
27978
|
+
onMouseDown(_event) {
|
|
27941
27979
|
this.pointCount = 0;
|
|
27980
|
+
if (this.elementModel) {
|
|
27981
|
+
this.elementModel.dispose();
|
|
27982
|
+
}
|
|
27942
27983
|
this.elementModel = this.modelGetter().createCurve(true);
|
|
27943
27984
|
}
|
|
27944
27985
|
onMouseDrag(event) {
|
|
27945
27986
|
if (this.pointCount > 1024) {
|
|
27946
27987
|
return;
|
|
27947
27988
|
}
|
|
27989
|
+
const MIN_DISTANCE = 4;
|
|
27948
27990
|
if (this.elementModel) {
|
|
27949
|
-
this.
|
|
27950
|
-
|
|
27991
|
+
const len = this.elementModel.points.length;
|
|
27992
|
+
let last = {
|
|
27993
|
+
x: 0,
|
|
27994
|
+
y: 0
|
|
27995
|
+
};
|
|
27996
|
+
if (len >= 2) {
|
|
27997
|
+
last = {
|
|
27998
|
+
x: this.elementModel.points[len - 2],
|
|
27999
|
+
y: this.elementModel.points[len - 1]
|
|
28000
|
+
};
|
|
28001
|
+
}
|
|
28002
|
+
const dist = Math.max(Math.abs(last.x - event.point.x), Math.abs(last.y - event.point.y));
|
|
28003
|
+
if (dist >= MIN_DISTANCE) {
|
|
28004
|
+
this.pointCount += 1;
|
|
28005
|
+
this.elementModel.appendPoints([Math.round(event.point.x), Math.round(event.point.y)]);
|
|
28006
|
+
}
|
|
27951
28007
|
}
|
|
27952
28008
|
}
|
|
27953
28009
|
onMouseUp(event) {
|
|
@@ -28009,6 +28065,9 @@ var RectangleTool = class extends WhiteboardTool {
|
|
|
28009
28065
|
this.tool.minDistance = 1;
|
|
28010
28066
|
}
|
|
28011
28067
|
onMouseDown(event) {
|
|
28068
|
+
if (this.elementModel) {
|
|
28069
|
+
this.elementModel.dispose();
|
|
28070
|
+
}
|
|
28012
28071
|
this.elementModel = this.modelGetter().createRectangle(true);
|
|
28013
28072
|
this.from = event.point.clone();
|
|
28014
28073
|
this.to = event.point.clone();
|
|
@@ -28030,7 +28089,8 @@ var RectangleTool = class extends WhiteboardTool {
|
|
|
28030
28089
|
};
|
|
28031
28090
|
|
|
28032
28091
|
// src/model/ToolbarModel.ts
|
|
28033
|
-
var
|
|
28092
|
+
var import_eventemitter32 = __toESM(require("eventemitter3"), 1);
|
|
28093
|
+
var import_forge_room5 = require("@netless/forge-room");
|
|
28034
28094
|
function _defineProperty21(e, r, t) {
|
|
28035
28095
|
return (r = _toPropertyKey21(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
28036
28096
|
}
|
|
@@ -28057,7 +28117,7 @@ var TOOLBAR_KEYS = {
|
|
|
28057
28117
|
strokeWidth: "strokeWidth",
|
|
28058
28118
|
dashArray: "dashArray"
|
|
28059
28119
|
};
|
|
28060
|
-
var ToolbarModel = class extends
|
|
28120
|
+
var ToolbarModel = class extends import_eventemitter32.default {
|
|
28061
28121
|
get currentTool() {
|
|
28062
28122
|
return this.root.get(TOOLBAR_KEYS.tool);
|
|
28063
28123
|
}
|
|
@@ -28126,6 +28186,10 @@ var ToolbarModel = class extends import_eventemitter33.default {
|
|
|
28126
28186
|
}
|
|
28127
28187
|
});
|
|
28128
28188
|
}
|
|
28189
|
+
dispose() {
|
|
28190
|
+
(0, import_forge_room5.removeObserver)(this.root, this.handleRootUpdate);
|
|
28191
|
+
this.removeAllListeners();
|
|
28192
|
+
}
|
|
28129
28193
|
};
|
|
28130
28194
|
|
|
28131
28195
|
// src/tool/SelectorTool.ts
|
|
@@ -28159,6 +28223,9 @@ var SelectorTool = class extends WhiteboardTool {
|
|
|
28159
28223
|
onMouseDown(event) {
|
|
28160
28224
|
this.from = null;
|
|
28161
28225
|
this.to = null;
|
|
28226
|
+
if (this.elementModel) {
|
|
28227
|
+
this.elementModel.dispose();
|
|
28228
|
+
}
|
|
28162
28229
|
this.elementModel = this.modelGetter().createSelector();
|
|
28163
28230
|
this.from = event.point.clone();
|
|
28164
28231
|
this.to = event.point.clone();
|
|
@@ -28208,7 +28275,8 @@ var SelectorTool = class extends WhiteboardTool {
|
|
|
28208
28275
|
|
|
28209
28276
|
// src/model/SelectElementsModel.ts
|
|
28210
28277
|
var Y13 = __toESM(require("yjs"), 1);
|
|
28211
|
-
var
|
|
28278
|
+
var import_eventemitter33 = __toESM(require("eventemitter3"), 1);
|
|
28279
|
+
var import_forge_room6 = require("@netless/forge-room");
|
|
28212
28280
|
|
|
28213
28281
|
// src/WhiteboardKeys.ts
|
|
28214
28282
|
var WhiteboardKeys = {
|
|
@@ -28239,7 +28307,7 @@ function _toPrimitive23(t, r) {
|
|
|
28239
28307
|
}
|
|
28240
28308
|
return ("string" === r ? String : Number)(t);
|
|
28241
28309
|
}
|
|
28242
|
-
var SelectElementsModel = class extends
|
|
28310
|
+
var SelectElementsModel = class extends import_eventemitter33.default {
|
|
28243
28311
|
get hasEditSelfPermission() {
|
|
28244
28312
|
return this.hasPermission(WhiteboardPermissionFlag.editSelf);
|
|
28245
28313
|
}
|
|
@@ -28255,13 +28323,17 @@ var SelectElementsModel = class extends import_eventemitter34.default {
|
|
|
28255
28323
|
_defineProperty23(this, "handleUserLeave", (user) => {
|
|
28256
28324
|
const cb = this.observers.get(user.id);
|
|
28257
28325
|
if (cb) {
|
|
28258
|
-
this.requestUserMap(user.id)
|
|
28326
|
+
(0, import_forge_room6.removeDeepObserver)(this.requestUserMap(user.id), cb);
|
|
28327
|
+
this.observers.delete(user.id);
|
|
28259
28328
|
}
|
|
28260
28329
|
});
|
|
28261
28330
|
_defineProperty23(this, "handleUserJoin", (user) => {
|
|
28262
28331
|
const observer = (evts) => {
|
|
28263
28332
|
this.handleUserSelectElementsChange(user.id, evts);
|
|
28264
28333
|
};
|
|
28334
|
+
if (this.observers.has(user.id)) {
|
|
28335
|
+
(0, import_forge_room6.removeDeepObserver)(this.requestUserMap(user.id), this.observers.get(user.id));
|
|
28336
|
+
}
|
|
28265
28337
|
this.requestUserMap(user.id).observeDeep(observer);
|
|
28266
28338
|
this.observers.set(user.id, observer);
|
|
28267
28339
|
});
|
|
@@ -28281,6 +28353,9 @@ var SelectElementsModel = class extends import_eventemitter34.default {
|
|
|
28281
28353
|
const observer = (evts) => {
|
|
28282
28354
|
this.handleUserSelectElementsChange(userId, evts);
|
|
28283
28355
|
};
|
|
28356
|
+
if (this.observers.has(userId)) {
|
|
28357
|
+
(0, import_forge_room6.removeDeepObserver)(this.requestUserMap(userId), this.observers.get(userId));
|
|
28358
|
+
}
|
|
28284
28359
|
this.requestUserMap(userId).observeDeep(observer);
|
|
28285
28360
|
this.observers.set(userId, observer);
|
|
28286
28361
|
});
|
|
@@ -28335,12 +28410,9 @@ var SelectElementsModel = class extends import_eventemitter34.default {
|
|
|
28335
28410
|
});
|
|
28336
28411
|
}
|
|
28337
28412
|
dispose() {
|
|
28338
|
-
this.
|
|
28339
|
-
|
|
28340
|
-
|
|
28341
|
-
this.requestUserMap(userId).unobserveDeep(cb);
|
|
28342
|
-
}
|
|
28343
|
-
});
|
|
28413
|
+
for (const [key, value] of this.observers.entries()) {
|
|
28414
|
+
(0, import_forge_room6.removeDeepObserver)(this.requestUserMap(key), value);
|
|
28415
|
+
}
|
|
28344
28416
|
this.observers.clear();
|
|
28345
28417
|
this.userManager.off("leave", this.handleUserLeave);
|
|
28346
28418
|
this.userManager.off("join", this.handleUserJoin);
|
|
@@ -28348,10 +28420,10 @@ var SelectElementsModel = class extends import_eventemitter34.default {
|
|
|
28348
28420
|
};
|
|
28349
28421
|
|
|
28350
28422
|
// src/edit/Editor.ts
|
|
28351
|
-
var
|
|
28423
|
+
var import_eventemitter35 = __toESM(require("eventemitter3"), 1);
|
|
28352
28424
|
|
|
28353
28425
|
// src/edit/TextEditor.ts
|
|
28354
|
-
var
|
|
28426
|
+
var import_eventemitter34 = require("eventemitter3");
|
|
28355
28427
|
function _defineProperty24(e, r, t) {
|
|
28356
28428
|
return (r = _toPropertyKey24(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
28357
28429
|
}
|
|
@@ -28369,7 +28441,7 @@ function _toPrimitive24(t, r) {
|
|
|
28369
28441
|
}
|
|
28370
28442
|
return ("string" === r ? String : Number)(t);
|
|
28371
28443
|
}
|
|
28372
|
-
var TextEditor = class extends
|
|
28444
|
+
var TextEditor = class extends import_eventemitter34.EventEmitter {
|
|
28373
28445
|
constructor(camera) {
|
|
28374
28446
|
super();
|
|
28375
28447
|
_defineProperty24(this, "rootView", void 0);
|
|
@@ -28402,12 +28474,12 @@ var TextEditor = class extends import_eventemitter35.EventEmitter {
|
|
|
28402
28474
|
});
|
|
28403
28475
|
this.camera = camera;
|
|
28404
28476
|
this.rootView = document.createElement("div");
|
|
28405
|
-
this.rootView.style.cssText =
|
|
28477
|
+
this.rootView.style.cssText = "position:absolute;width:100%;height:100%;top:0;left:0;overflow:hidden;";
|
|
28406
28478
|
this.content = document.createElement("div");
|
|
28407
28479
|
this.content.setAttribute("spellcheck", "false");
|
|
28408
28480
|
this.content.textContent = "";
|
|
28409
28481
|
this.content.setAttribute("contenteditable", "plaintext-only");
|
|
28410
|
-
this.content.style.cssText =
|
|
28482
|
+
this.content.style.cssText = "white-space: nowrap;border:1px solid red;text-wrap:nowrap;caret-color:red;line-height:1.2em;position:absolute;z-index:2;color:transparent;outline:none;";
|
|
28411
28483
|
this.content.style.transformOrigin = "0 0";
|
|
28412
28484
|
this.rootView.appendChild(this.content);
|
|
28413
28485
|
this.content.addEventListener("input", this.handleContentInput);
|
|
@@ -28512,7 +28584,7 @@ var ANCHOR_STYLE = {
|
|
|
28512
28584
|
b: "cursor:s-resize;bottom:-3px;left:50%;translate:-50%;",
|
|
28513
28585
|
br: "cursor:se-resize;bottom:-3px;right:-3px"
|
|
28514
28586
|
};
|
|
28515
|
-
var Bounds = class extends
|
|
28587
|
+
var Bounds = class extends import_eventemitter35.default {
|
|
28516
28588
|
get width() {
|
|
28517
28589
|
return this.maxX - this.minX;
|
|
28518
28590
|
}
|
|
@@ -28651,7 +28723,7 @@ var Bounds = class extends import_eventemitter36.default {
|
|
|
28651
28723
|
this.maxY = maxY;
|
|
28652
28724
|
}
|
|
28653
28725
|
};
|
|
28654
|
-
var Editor = class extends
|
|
28726
|
+
var Editor = class extends import_eventemitter35.default {
|
|
28655
28727
|
constructor(scope, shadowScope, shadowEmitter, canvasElement, camera, initConfig) {
|
|
28656
28728
|
super();
|
|
28657
28729
|
_defineProperty25(this, "rootView", void 0);
|
|
@@ -28752,7 +28824,7 @@ var Editor = class extends import_eventemitter36.default {
|
|
|
28752
28824
|
}
|
|
28753
28825
|
if (this.editMode === "matrix" && this.editAnchor && this.lastEditPoint) {
|
|
28754
28826
|
const offsetX = evt.pageX - this.lastEditPoint.x;
|
|
28755
|
-
|
|
28827
|
+
const offsetY = evt.pageY - this.lastEditPoint.y;
|
|
28756
28828
|
this.bounds.offsetBy(this.editAnchor, offsetX, offsetY, this.uniformScale ? this.aspectRatio : -1);
|
|
28757
28829
|
this.lastEditPoint = {
|
|
28758
28830
|
x: evt.pageX,
|
|
@@ -28777,7 +28849,7 @@ var Editor = class extends import_eventemitter36.default {
|
|
|
28777
28849
|
}
|
|
28778
28850
|
if (this.editMode === "translate" && this.lastEditPoint) {
|
|
28779
28851
|
const offsetX = evt.pageX - this.lastEditPoint.x;
|
|
28780
|
-
|
|
28852
|
+
const offsetY = evt.pageY - this.lastEditPoint.y;
|
|
28781
28853
|
this.bounds.translate(offsetX, offsetY);
|
|
28782
28854
|
this.updateBoundsByShadow();
|
|
28783
28855
|
this.lastEditPoint = {
|
|
@@ -28854,7 +28926,7 @@ var Editor = class extends import_eventemitter36.default {
|
|
|
28854
28926
|
this.ctrlId = initConfig.ctrlId;
|
|
28855
28927
|
this.ctrlNickName = initConfig.ctrlNickName;
|
|
28856
28928
|
this.rootView = document.createElement("div");
|
|
28857
|
-
this.rootView.style.cssText =
|
|
28929
|
+
this.rootView.style.cssText = "overflow:hidden;position:absolute;display:none;width:100%;height:100%;top:50%;left:50%;transform:translate(-50%,-50%);";
|
|
28858
28930
|
this.frame = document.createElement("div");
|
|
28859
28931
|
this.frame.style.position = "absolute";
|
|
28860
28932
|
this.frame.style.padding = "8px";
|
|
@@ -28875,7 +28947,7 @@ var Editor = class extends import_eventemitter36.default {
|
|
|
28875
28947
|
} else {
|
|
28876
28948
|
this.title = document.createElement("div");
|
|
28877
28949
|
this.title.textContent = `${this.ctrlNickName}`;
|
|
28878
|
-
this.title.style.cssText =
|
|
28950
|
+
this.title.style.cssText = "color:#fff;font-size:12px;padding: 0.2em 0.4em;border-radius: 0.4em;position: absolute;top: 0%;left: 0;margin: -0.4em;transform: translate(-100%, -100%);";
|
|
28879
28951
|
this.frame.appendChild(this.title);
|
|
28880
28952
|
this.rootView.style.pointerEvents = "none";
|
|
28881
28953
|
}
|
|
@@ -29047,7 +29119,9 @@ var Editor = class extends import_eventemitter36.default {
|
|
|
29047
29119
|
this.targets = [];
|
|
29048
29120
|
this.editorConfig = null;
|
|
29049
29121
|
if (this.ctrlId !== this.viewerId) {
|
|
29050
|
-
this.scope.project.view
|
|
29122
|
+
if (this.scope.project.view) {
|
|
29123
|
+
this.scope.project.view.off("frame", this.updateBounds);
|
|
29124
|
+
}
|
|
29051
29125
|
}
|
|
29052
29126
|
}
|
|
29053
29127
|
show() {
|
|
@@ -29106,7 +29180,7 @@ var TextTool = class extends WhiteboardTool {
|
|
|
29106
29180
|
onMouseDown(event) {
|
|
29107
29181
|
this.from = event.point.clone();
|
|
29108
29182
|
}
|
|
29109
|
-
onMouseDrag(
|
|
29183
|
+
onMouseDrag(_event) {
|
|
29110
29184
|
}
|
|
29111
29185
|
onMouseUp(event) {
|
|
29112
29186
|
this.to = event.point.clone();
|
|
@@ -29118,6 +29192,9 @@ var TextTool = class extends WhiteboardTool {
|
|
|
29118
29192
|
}
|
|
29119
29193
|
}
|
|
29120
29194
|
createPointEditor(x, y) {
|
|
29195
|
+
if (this.elementModel) {
|
|
29196
|
+
this.elementModel.dispose();
|
|
29197
|
+
}
|
|
29121
29198
|
this.elementModel = this.modelGetter().createPointText(x, y, true);
|
|
29122
29199
|
if (this.elementModel === null) {
|
|
29123
29200
|
return;
|
|
@@ -29158,10 +29235,10 @@ var TextTool = class extends WhiteboardTool {
|
|
|
29158
29235
|
};
|
|
29159
29236
|
|
|
29160
29237
|
// src/Camera.ts
|
|
29161
|
-
var
|
|
29238
|
+
var import_eventemitter37 = __toESM(require("eventemitter3"), 1);
|
|
29162
29239
|
|
|
29163
29240
|
// src/Gesture.ts
|
|
29164
|
-
var
|
|
29241
|
+
var import_eventemitter36 = __toESM(require("eventemitter3"), 1);
|
|
29165
29242
|
function _defineProperty27(e, r, t) {
|
|
29166
29243
|
return (r = _toPropertyKey27(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
29167
29244
|
}
|
|
@@ -29179,7 +29256,7 @@ function _toPrimitive27(t, r) {
|
|
|
29179
29256
|
}
|
|
29180
29257
|
return ("string" === r ? String : Number)(t);
|
|
29181
29258
|
}
|
|
29182
|
-
var Gesture = class extends
|
|
29259
|
+
var Gesture = class extends import_eventemitter36.default {
|
|
29183
29260
|
constructor(element, scope) {
|
|
29184
29261
|
super();
|
|
29185
29262
|
_defineProperty27(this, "element", void 0);
|
|
@@ -29243,6 +29320,7 @@ var Gesture = class extends import_eventemitter37.default {
|
|
|
29243
29320
|
};
|
|
29244
29321
|
|
|
29245
29322
|
// src/Camera.ts
|
|
29323
|
+
var import_forge_room7 = require("@netless/forge-room");
|
|
29246
29324
|
function _defineProperty28(e, r, t) {
|
|
29247
29325
|
return (r = _toPropertyKey28(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
29248
29326
|
}
|
|
@@ -29260,7 +29338,7 @@ function _toPrimitive28(t, r) {
|
|
|
29260
29338
|
}
|
|
29261
29339
|
return ("string" === r ? String : Number)(t);
|
|
29262
29340
|
}
|
|
29263
|
-
var Camera = class extends
|
|
29341
|
+
var Camera = class extends import_eventemitter37.default {
|
|
29264
29342
|
get inherentMatrix() {
|
|
29265
29343
|
const inherentMatrix = new this.scope.Matrix();
|
|
29266
29344
|
inherentMatrix.scale(this.inherentScale, [0, 0]);
|
|
@@ -29316,13 +29394,16 @@ var Camera = class extends import_eventemitter38.default {
|
|
|
29316
29394
|
_defineProperty28(this, "handleUserLeave", (user) => {
|
|
29317
29395
|
const cb = this.observers.get(user.id);
|
|
29318
29396
|
if (cb) {
|
|
29319
|
-
this.requestUserMap(user.id)
|
|
29397
|
+
(0, import_forge_room7.removeObserver)(this.requestUserMap(user.id), cb);
|
|
29320
29398
|
}
|
|
29321
29399
|
});
|
|
29322
29400
|
_defineProperty28(this, "handleUserJoin", (user) => {
|
|
29323
29401
|
const observer = (evt) => {
|
|
29324
29402
|
this.handleViewMatrixUpdate(user.id, evt);
|
|
29325
29403
|
};
|
|
29404
|
+
if (this.observers.has(user.id)) {
|
|
29405
|
+
(0, import_forge_room7.removeObserver)(this.requestUserMap(user.id), observer);
|
|
29406
|
+
}
|
|
29326
29407
|
this.requestUserMap(user.id).observe(observer);
|
|
29327
29408
|
this.observers.set(user.id, observer);
|
|
29328
29409
|
});
|
|
@@ -29402,7 +29483,7 @@ var Camera = class extends import_eventemitter38.default {
|
|
|
29402
29483
|
});
|
|
29403
29484
|
this.maxScale = maxScale;
|
|
29404
29485
|
this.bound = window.document.createElement("div");
|
|
29405
|
-
this.bound.style.cssText =
|
|
29486
|
+
this.bound.style.cssText = "transition: box-shadow 100ms;pointer-events:none;z-index:99;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);";
|
|
29406
29487
|
this.initSize = initSize;
|
|
29407
29488
|
this.hasPermission = hasPermission;
|
|
29408
29489
|
this.paperSize = _paperSize;
|
|
@@ -29427,6 +29508,9 @@ var Camera = class extends import_eventemitter38.default {
|
|
|
29427
29508
|
const observer = (evt) => {
|
|
29428
29509
|
this.handleViewMatrixUpdate(userId, evt);
|
|
29429
29510
|
};
|
|
29511
|
+
if (this.observers.has(userId)) {
|
|
29512
|
+
(0, import_forge_room7.removeObserver)(this.requestUserMap(userId), observer);
|
|
29513
|
+
}
|
|
29430
29514
|
this.requestUserMap(userId).observe(observer);
|
|
29431
29515
|
this.observers.set(userId, observer);
|
|
29432
29516
|
});
|
|
@@ -29463,7 +29547,7 @@ var Camera = class extends import_eventemitter38.default {
|
|
|
29463
29547
|
this.bound.style.boxShadow = `inset 0px 0px 6px 2px ${this.boundaryColor}`;
|
|
29464
29548
|
window.clearTimeout(this.boundTiemoutId);
|
|
29465
29549
|
this.boundTiemoutId = window.setTimeout(() => {
|
|
29466
|
-
this.bound.style.boxShadow =
|
|
29550
|
+
this.bound.style.boxShadow = "none";
|
|
29467
29551
|
}, 100);
|
|
29468
29552
|
}
|
|
29469
29553
|
}
|
|
@@ -29473,6 +29557,9 @@ var Camera = class extends import_eventemitter38.default {
|
|
|
29473
29557
|
updateInherentScale(scale) {
|
|
29474
29558
|
this.inherentScale = scale;
|
|
29475
29559
|
}
|
|
29560
|
+
getInherentScale() {
|
|
29561
|
+
return this.inherentScale;
|
|
29562
|
+
}
|
|
29476
29563
|
getActiveMatrix() {
|
|
29477
29564
|
const cameraMode = this.requestUserMap(this.userManager.selfId).get(WhiteboardKeys.cameraMode);
|
|
29478
29565
|
let matrixValue;
|
|
@@ -29615,6 +29702,19 @@ var Camera = class extends import_eventemitter38.default {
|
|
|
29615
29702
|
y: 0
|
|
29616
29703
|
};
|
|
29617
29704
|
}
|
|
29705
|
+
dispose() {
|
|
29706
|
+
Array.from(this.observers.keys()).forEach((userId) => {
|
|
29707
|
+
const cb = this.observers.get(userId);
|
|
29708
|
+
if (cb) {
|
|
29709
|
+
(0, import_forge_room7.removeObserver)(this.requestUserMap(userId), cb);
|
|
29710
|
+
}
|
|
29711
|
+
});
|
|
29712
|
+
(0, import_forge_room7.removeObserver)(this.whiteboardAttrsMap, this.handleMainCameraChange);
|
|
29713
|
+
this.userManager.off("join", this.handleUserJoin);
|
|
29714
|
+
this.userManager.off("leave", this.handleUserLeave);
|
|
29715
|
+
this.gesture.removeAllListeners();
|
|
29716
|
+
this.removeAllListeners();
|
|
29717
|
+
}
|
|
29618
29718
|
};
|
|
29619
29719
|
|
|
29620
29720
|
// src/tool/EllipseTool.ts
|
|
@@ -29644,6 +29744,9 @@ var EllipseTool = class extends WhiteboardTool {
|
|
|
29644
29744
|
this.tool.minDistance = 1;
|
|
29645
29745
|
}
|
|
29646
29746
|
onMouseDown(event) {
|
|
29747
|
+
if (this.elementModel) {
|
|
29748
|
+
this.elementModel.dispose();
|
|
29749
|
+
}
|
|
29647
29750
|
this.elementModel = this.modelGetter().createSegmentedPath("ellipse", true);
|
|
29648
29751
|
this.from = event.point.clone();
|
|
29649
29752
|
this.to = event.point.clone();
|
|
@@ -29695,6 +29798,9 @@ var TriangleTool = class extends WhiteboardTool {
|
|
|
29695
29798
|
this.tool.minDistance = 1;
|
|
29696
29799
|
}
|
|
29697
29800
|
onMouseDown(event) {
|
|
29801
|
+
if (this.elementModel) {
|
|
29802
|
+
this.elementModel.dispose();
|
|
29803
|
+
}
|
|
29698
29804
|
this.elementModel = this.modelGetter().createTriangle(true);
|
|
29699
29805
|
this.from = event.point.clone();
|
|
29700
29806
|
this.to = event.point.clone();
|
|
@@ -29716,7 +29822,7 @@ var TriangleTool = class extends WhiteboardTool {
|
|
|
29716
29822
|
};
|
|
29717
29823
|
|
|
29718
29824
|
// src/Whiteboard.ts
|
|
29719
|
-
var
|
|
29825
|
+
var import_eventemitter38 = __toESM(require("eventemitter3"), 1);
|
|
29720
29826
|
function _defineProperty31(e, r, t) {
|
|
29721
29827
|
return (r = _toPropertyKey31(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
29722
29828
|
}
|
|
@@ -29734,8 +29840,7 @@ function _toPrimitive31(t, r) {
|
|
|
29734
29840
|
}
|
|
29735
29841
|
return ("string" === r ? String : Number)(t);
|
|
29736
29842
|
}
|
|
29737
|
-
var Whiteboard = class extends
|
|
29738
|
-
// public insertImage!: (src: string) => void;
|
|
29843
|
+
var Whiteboard = class extends import_eventemitter38.default {
|
|
29739
29844
|
constructor(view) {
|
|
29740
29845
|
super();
|
|
29741
29846
|
_defineProperty31(this, "view", void 0);
|
|
@@ -29754,6 +29859,7 @@ var Whiteboard = class extends import_eventemitter39.default {
|
|
|
29754
29859
|
_defineProperty31(this, "enableCameraBoundaryHighlight", void 0);
|
|
29755
29860
|
_defineProperty31(this, "getElementAttribute", void 0);
|
|
29756
29861
|
_defineProperty31(this, "setElementAttribute", void 0);
|
|
29862
|
+
_defineProperty31(this, "removeElement", void 0);
|
|
29757
29863
|
_defineProperty31(this, "getCurrentTool", void 0);
|
|
29758
29864
|
_defineProperty31(this, "setCurrentTool", void 0);
|
|
29759
29865
|
_defineProperty31(this, "setCanvasBackgroundColor", void 0);
|
|
@@ -29780,6 +29886,7 @@ var Whiteboard = class extends import_eventemitter39.default {
|
|
|
29780
29886
|
_defineProperty31(this, "rasterizeElementsBounds", void 0);
|
|
29781
29887
|
_defineProperty31(this, "rasterizeMaxBounds", void 0);
|
|
29782
29888
|
_defineProperty31(this, "setInputType", void 0);
|
|
29889
|
+
_defineProperty31(this, "insertImage", void 0);
|
|
29783
29890
|
this.view = view;
|
|
29784
29891
|
}
|
|
29785
29892
|
};
|
|
@@ -29811,8 +29918,11 @@ var EraserTool = class extends WhiteboardTool {
|
|
|
29811
29918
|
this.trashedElementsModel = trashedElementsModel;
|
|
29812
29919
|
this.tool.minDistance = 1;
|
|
29813
29920
|
}
|
|
29814
|
-
onMouseDown(
|
|
29921
|
+
onMouseDown(_event) {
|
|
29815
29922
|
this.pointCount = 0;
|
|
29923
|
+
if (this.elementModel) {
|
|
29924
|
+
this.elementModel.dispose();
|
|
29925
|
+
}
|
|
29816
29926
|
this.elementModel = this.modelGetter().createEraser();
|
|
29817
29927
|
}
|
|
29818
29928
|
onMouseDrag(event) {
|
|
@@ -29834,7 +29944,7 @@ var EraserTool = class extends WhiteboardTool {
|
|
|
29834
29944
|
}
|
|
29835
29945
|
});
|
|
29836
29946
|
}
|
|
29837
|
-
onMouseUp(
|
|
29947
|
+
onMouseUp(_event) {
|
|
29838
29948
|
if (this.elementModel) {
|
|
29839
29949
|
this.modelGetter().removeElementItem(this.elementModel.uuid);
|
|
29840
29950
|
}
|
|
@@ -29844,7 +29954,8 @@ var EraserTool = class extends WhiteboardTool {
|
|
|
29844
29954
|
|
|
29845
29955
|
// src/model/TrashedElementsModel.ts
|
|
29846
29956
|
var Y14 = __toESM(require("yjs"), 1);
|
|
29847
|
-
var
|
|
29957
|
+
var import_eventemitter39 = __toESM(require("eventemitter3"), 1);
|
|
29958
|
+
var import_forge_room8 = require("@netless/forge-room");
|
|
29848
29959
|
function _defineProperty33(e, r, t) {
|
|
29849
29960
|
return (r = _toPropertyKey33(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
29850
29961
|
}
|
|
@@ -29862,7 +29973,7 @@ function _toPrimitive33(t, r) {
|
|
|
29862
29973
|
}
|
|
29863
29974
|
return ("string" === r ? String : Number)(t);
|
|
29864
29975
|
}
|
|
29865
|
-
var TrashedElementsModel = class extends
|
|
29976
|
+
var TrashedElementsModel = class extends import_eventemitter39.default {
|
|
29866
29977
|
get hasDeleteSelfPermission() {
|
|
29867
29978
|
return this.hasPermission(WhiteboardPermissionFlag.deleteSelf);
|
|
29868
29979
|
}
|
|
@@ -29878,13 +29989,16 @@ var TrashedElementsModel = class extends import_eventemitter310.default {
|
|
|
29878
29989
|
_defineProperty33(this, "handleUserLeave", (user) => {
|
|
29879
29990
|
const cb = this.observers.get(user.id);
|
|
29880
29991
|
if (cb) {
|
|
29881
|
-
this.requestUserMap(user.id)
|
|
29992
|
+
(0, import_forge_room8.removeDeepObserver)(this.requestUserMap(user.id), cb);
|
|
29882
29993
|
}
|
|
29883
29994
|
});
|
|
29884
29995
|
_defineProperty33(this, "handleUserJoin", (user) => {
|
|
29885
29996
|
const observer = (evts) => {
|
|
29886
29997
|
this.handleUserTrashElementsChange(user.id, evts);
|
|
29887
29998
|
};
|
|
29999
|
+
if (this.observers.has(user.id)) {
|
|
30000
|
+
(0, import_forge_room8.removeDeepObserver)(this.requestUserMap(user.id), this.observers.get(user.id));
|
|
30001
|
+
}
|
|
29888
30002
|
this.requestUserMap(user.id).observeDeep(observer);
|
|
29889
30003
|
this.observers.set(user.id, observer);
|
|
29890
30004
|
});
|
|
@@ -29896,6 +30010,9 @@ var TrashedElementsModel = class extends import_eventemitter310.default {
|
|
|
29896
30010
|
const observer = (evts) => {
|
|
29897
30011
|
this.handleUserTrashElementsChange(userId, evts);
|
|
29898
30012
|
};
|
|
30013
|
+
if (this.observers.has(userId)) {
|
|
30014
|
+
(0, import_forge_room8.removeDeepObserver)(this.requestUserMap(userId), userId);
|
|
30015
|
+
}
|
|
29899
30016
|
this.requestUserMap(userId).observeDeep(observer);
|
|
29900
30017
|
this.observers.set(userId, observer);
|
|
29901
30018
|
});
|
|
@@ -29950,12 +30067,9 @@ var TrashedElementsModel = class extends import_eventemitter310.default {
|
|
|
29950
30067
|
});
|
|
29951
30068
|
}
|
|
29952
30069
|
dispose() {
|
|
29953
|
-
this.
|
|
29954
|
-
|
|
29955
|
-
|
|
29956
|
-
this.requestUserMap(userId).unobserveDeep(cb);
|
|
29957
|
-
}
|
|
29958
|
-
});
|
|
30070
|
+
for (const [key, value] of this.observers.entries()) {
|
|
30071
|
+
(0, import_forge_room8.removeDeepObserver)(this.requestUserMap(key), value);
|
|
30072
|
+
}
|
|
29959
30073
|
this.observers.clear();
|
|
29960
30074
|
this.userManager.off("leave", this.handleUserLeave);
|
|
29961
30075
|
this.userManager.off("join", this.handleUserJoin);
|
|
@@ -29987,8 +30101,11 @@ var LaserPointerTool = class extends WhiteboardTool {
|
|
|
29987
30101
|
_defineProperty34(this, "pointCount", 0);
|
|
29988
30102
|
this.tool.minDistance = 5;
|
|
29989
30103
|
}
|
|
29990
|
-
onMouseDown(
|
|
30104
|
+
onMouseDown(_event) {
|
|
29991
30105
|
this.pointCount = 0;
|
|
30106
|
+
if (this.elementModel) {
|
|
30107
|
+
this.elementModel.dispose();
|
|
30108
|
+
}
|
|
29992
30109
|
this.elementModel = this.modelGetter().createLaserPointer();
|
|
29993
30110
|
}
|
|
29994
30111
|
onMouseDrag(event) {
|
|
@@ -30000,7 +30117,7 @@ var LaserPointerTool = class extends WhiteboardTool {
|
|
|
30000
30117
|
this.elementModel.appendPoints([event.point.x, event.point.y]);
|
|
30001
30118
|
}
|
|
30002
30119
|
}
|
|
30003
|
-
onMouseUp(
|
|
30120
|
+
onMouseUp(_event) {
|
|
30004
30121
|
if (this.elementModel) {
|
|
30005
30122
|
this.elementModel.beginRemoveAnimate();
|
|
30006
30123
|
}
|
|
@@ -30008,8 +30125,8 @@ var LaserPointerTool = class extends WhiteboardTool {
|
|
|
30008
30125
|
};
|
|
30009
30126
|
|
|
30010
30127
|
// src/model/PageModel.ts
|
|
30011
|
-
var
|
|
30012
|
-
var
|
|
30128
|
+
var import_eventemitter310 = __toESM(require("eventemitter3"), 1);
|
|
30129
|
+
var import_forge_room9 = require("@netless/forge-room");
|
|
30013
30130
|
function _defineProperty35(e, r, t) {
|
|
30014
30131
|
return (r = _toPropertyKey35(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
30015
30132
|
}
|
|
@@ -30027,7 +30144,7 @@ function _toPrimitive35(t, r) {
|
|
|
30027
30144
|
}
|
|
30028
30145
|
return ("string" === r ? String : Number)(t);
|
|
30029
30146
|
}
|
|
30030
|
-
var PageModel = class extends
|
|
30147
|
+
var PageModel = class extends import_eventemitter310.default {
|
|
30031
30148
|
constructor(whiteboardAttrsMap, userManager, requestUserMap, pageMap, hasPermission) {
|
|
30032
30149
|
super();
|
|
30033
30150
|
_defineProperty35(this, "whiteboardAttrsMap", void 0);
|
|
@@ -30039,7 +30156,7 @@ var PageModel = class extends import_eventemitter311.default {
|
|
|
30039
30156
|
_defineProperty35(this, "handleUserLeave", (user) => {
|
|
30040
30157
|
const cb = this.observers.get(user.id);
|
|
30041
30158
|
if (cb) {
|
|
30042
|
-
this.requestUserMap(user.id)
|
|
30159
|
+
(0, import_forge_room9.removeObserver)(this.requestUserMap(user.id), cb);
|
|
30043
30160
|
}
|
|
30044
30161
|
});
|
|
30045
30162
|
_defineProperty35(this, "handleUserJoin", (user) => {
|
|
@@ -30053,7 +30170,7 @@ var PageModel = class extends import_eventemitter311.default {
|
|
|
30053
30170
|
if (cameraMode === "main") {
|
|
30054
30171
|
const targetPage = this.whiteboardAttrsMap.get(WhiteboardKeys.currentPage);
|
|
30055
30172
|
if (!this.pageMap.has(targetPage) && targetPage !== "_i_") {
|
|
30056
|
-
(0,
|
|
30173
|
+
(0, import_forge_room9.log)(`main page {${targetPage}} not found.`, {}, "error");
|
|
30057
30174
|
return;
|
|
30058
30175
|
}
|
|
30059
30176
|
this.requestUserMap(this.userManager.selfId).set(WhiteboardKeys.currentPage, targetPage);
|
|
@@ -30122,11 +30239,11 @@ var PageModel = class extends import_eventemitter311.default {
|
|
|
30122
30239
|
}
|
|
30123
30240
|
const cameraMode = this.requestUserMap(this.userManager.selfId).get(WhiteboardKeys.cameraMode);
|
|
30124
30241
|
if (cameraMode !== "main") {
|
|
30125
|
-
console.warn(
|
|
30242
|
+
console.warn("cannot modify pages in non-main view mode.");
|
|
30126
30243
|
return false;
|
|
30127
30244
|
}
|
|
30128
30245
|
if (!this.hasPermission(WhiteboardPermissionFlag.mainView)) {
|
|
30129
|
-
console.warn(
|
|
30246
|
+
console.warn("cannot modify pages without WhiteboardPermissionFlag.mainView.");
|
|
30130
30247
|
return false;
|
|
30131
30248
|
}
|
|
30132
30249
|
return true;
|
|
@@ -30178,21 +30295,31 @@ var PageModel = class extends import_eventemitter311.default {
|
|
|
30178
30295
|
}
|
|
30179
30296
|
}
|
|
30180
30297
|
}
|
|
30298
|
+
dispose() {
|
|
30299
|
+
for (const entry of this.observers.entries()) {
|
|
30300
|
+
const [userId, observer] = entry;
|
|
30301
|
+
(0, import_forge_room9.removeObserver)(this.requestUserMap(userId), observer);
|
|
30302
|
+
}
|
|
30303
|
+
this.userManager.off("join", this.handleUserJoin);
|
|
30304
|
+
this.userManager.off("leave", this.handleUserLeave);
|
|
30305
|
+
(0, import_forge_room9.removeObserver)(this.whiteboardAttrsMap, this.handleMainPageChange);
|
|
30306
|
+
(0, import_forge_room9.removeObserver)(this.pageMap, this.handlePageMapChange);
|
|
30307
|
+
}
|
|
30181
30308
|
};
|
|
30182
30309
|
|
|
30183
30310
|
// src/utils/async.ts
|
|
30184
30311
|
var delay = (value) => new Promise((resolve) => setTimeout(resolve, value));
|
|
30185
30312
|
async function waitUntil(fn, timeout) {
|
|
30186
|
-
|
|
30313
|
+
const start = Date.now();
|
|
30187
30314
|
while (!fn() && Date.now() - start < timeout) {
|
|
30188
30315
|
await delay(50);
|
|
30189
|
-
start = Date.now();
|
|
30190
30316
|
}
|
|
30191
30317
|
}
|
|
30192
30318
|
|
|
30193
30319
|
// src/IndexedNavigation.ts
|
|
30194
|
-
var
|
|
30195
|
-
var
|
|
30320
|
+
var import_eventemitter311 = __toESM(require("eventemitter3"), 1);
|
|
30321
|
+
var import_forge_room10 = require("@netless/forge-room");
|
|
30322
|
+
var import_forge_room11 = require("@netless/forge-room");
|
|
30196
30323
|
function _defineProperty36(e, r, t) {
|
|
30197
30324
|
return (r = _toPropertyKey36(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
30198
30325
|
}
|
|
@@ -30210,19 +30337,19 @@ function _toPrimitive36(t, r) {
|
|
|
30210
30337
|
}
|
|
30211
30338
|
return ("string" === r ? String : Number)(t);
|
|
30212
30339
|
}
|
|
30213
|
-
var IndexedNavigation = class extends
|
|
30340
|
+
var IndexedNavigation = class extends import_eventemitter311.default {
|
|
30214
30341
|
get idList() {
|
|
30215
30342
|
return this.pageModel.pageList().filter((id) => /^_i_/.test(id));
|
|
30216
30343
|
}
|
|
30217
30344
|
get head() {
|
|
30218
|
-
|
|
30345
|
+
const headId = Object.keys(this.list).find((key) => {
|
|
30219
30346
|
return this.list[key] && this.list[key].prev === "";
|
|
30220
30347
|
});
|
|
30221
30348
|
if (!headId) {
|
|
30222
|
-
(0,
|
|
30349
|
+
(0, import_forge_room10.log)("indexed navigation confusion", {
|
|
30223
30350
|
list: JSON.stringify(this.list)
|
|
30224
30351
|
}, "error");
|
|
30225
|
-
throw new Error(
|
|
30352
|
+
throw new Error("indexed navigation confusion");
|
|
30226
30353
|
}
|
|
30227
30354
|
return headId;
|
|
30228
30355
|
}
|
|
@@ -30243,7 +30370,7 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
30243
30370
|
_defineProperty36(this, "indexedPageMap", void 0);
|
|
30244
30371
|
_defineProperty36(this, "list", {});
|
|
30245
30372
|
_defineProperty36(this, "hasPermission", void 0);
|
|
30246
|
-
_defineProperty36(this, "handleIndexedPageMapUpdate", (
|
|
30373
|
+
_defineProperty36(this, "handleIndexedPageMapUpdate", (_evt) => {
|
|
30247
30374
|
this.list = this.indexedPageMap.get("list");
|
|
30248
30375
|
const needRemoveList = this.pageModel.pageList().filter((v) => /^_i_/.test(v) && Object.keys(this.list).indexOf(v) < 0);
|
|
30249
30376
|
const needAddList = Object.keys(this.list).filter((v) => this.pageModel.pageList().indexOf(v) < 0);
|
|
@@ -30298,8 +30425,8 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
30298
30425
|
initIndexed() {
|
|
30299
30426
|
return new Promise((resolve) => {
|
|
30300
30427
|
setTimeout(() => {
|
|
30428
|
+
this.pageModel.addPage("_i_");
|
|
30301
30429
|
if (this.pageModel.pageList().length === 0) {
|
|
30302
|
-
this.pageModel.addPage("_i_");
|
|
30303
30430
|
resolve(true);
|
|
30304
30431
|
} else {
|
|
30305
30432
|
resolve(false);
|
|
@@ -30308,19 +30435,22 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
30308
30435
|
});
|
|
30309
30436
|
}
|
|
30310
30437
|
/**
|
|
30311
|
-
|
|
30312
|
-
|
|
30313
|
-
|
|
30438
|
+
* 获取总页数
|
|
30439
|
+
* @returns {number}
|
|
30440
|
+
*/
|
|
30314
30441
|
get pageCount() {
|
|
30315
30442
|
return this.idList.length;
|
|
30316
30443
|
}
|
|
30317
30444
|
/**
|
|
30318
|
-
|
|
30319
|
-
|
|
30445
|
+
* 获取当前页索引
|
|
30446
|
+
*/
|
|
30320
30447
|
get currentPageIndex() {
|
|
30321
30448
|
const userPageId = this.userMap.get(WhiteboardKeys.currentPage);
|
|
30322
30449
|
return this.getPageIndex(userPageId);
|
|
30323
30450
|
}
|
|
30451
|
+
get currentPageId() {
|
|
30452
|
+
return this.userMap.get(WhiteboardKeys.currentPage);
|
|
30453
|
+
}
|
|
30324
30454
|
getPageIndex(pageId) {
|
|
30325
30455
|
let i = 0;
|
|
30326
30456
|
let currentId = this.head;
|
|
@@ -30336,9 +30466,9 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
30336
30466
|
return i;
|
|
30337
30467
|
}
|
|
30338
30468
|
/**
|
|
30339
|
-
|
|
30340
|
-
|
|
30341
|
-
|
|
30469
|
+
* 获取指定索引对应的 pageId
|
|
30470
|
+
* @param {number} index
|
|
30471
|
+
*/
|
|
30342
30472
|
getPageId(index) {
|
|
30343
30473
|
const firstKey = this.head;
|
|
30344
30474
|
if (firstKey) {
|
|
@@ -30360,20 +30490,20 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
30360
30490
|
modifyDetect() {
|
|
30361
30491
|
const cameraMode = this.userMap.get(WhiteboardKeys.cameraMode);
|
|
30362
30492
|
if (cameraMode !== "main") {
|
|
30363
|
-
console.warn(
|
|
30493
|
+
console.warn("cannot modify pages in non-main view mode.");
|
|
30364
30494
|
return false;
|
|
30365
30495
|
}
|
|
30366
30496
|
if (!this.hasPermission(WhiteboardPermissionFlag.mainView)) {
|
|
30367
|
-
console.warn(
|
|
30497
|
+
console.warn("cannot modify pages without WhiteboardPermissionFlag.mainView.");
|
|
30368
30498
|
return false;
|
|
30369
30499
|
}
|
|
30370
30500
|
return true;
|
|
30371
30501
|
}
|
|
30372
30502
|
/**
|
|
30373
|
-
|
|
30374
|
-
|
|
30375
|
-
|
|
30376
|
-
|
|
30503
|
+
* 在尾部插入新页面
|
|
30504
|
+
* @param {boolean=} goto 是否跳转到新页面, 默认 true
|
|
30505
|
+
* @return 总页数
|
|
30506
|
+
*/
|
|
30377
30507
|
pushPage() {
|
|
30378
30508
|
let goto = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
|
|
30379
30509
|
this.indexedPageMap.doc.transact(() => {
|
|
@@ -30402,11 +30532,11 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
30402
30532
|
return this.pageCount;
|
|
30403
30533
|
}
|
|
30404
30534
|
/**
|
|
30405
|
-
|
|
30406
|
-
|
|
30407
|
-
|
|
30408
|
-
|
|
30409
|
-
|
|
30535
|
+
* 在 after 之后插入新页面
|
|
30536
|
+
* @param {number} after 在此页之后插入
|
|
30537
|
+
* @param {boolean=} goto 是否跳转到新页面, 默认 true
|
|
30538
|
+
* @return 总页数
|
|
30539
|
+
*/
|
|
30410
30540
|
insertPage(after) {
|
|
30411
30541
|
let goto = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
30412
30542
|
const afterPageId = this.getPageId(after);
|
|
@@ -30415,7 +30545,7 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
30415
30545
|
}
|
|
30416
30546
|
const cameraMode = this.userMap.get(WhiteboardKeys.cameraMode);
|
|
30417
30547
|
if (cameraMode !== "main") {
|
|
30418
|
-
console.warn(
|
|
30548
|
+
console.warn("cannot modify pages in non-main view mode.");
|
|
30419
30549
|
return this.pageCount;
|
|
30420
30550
|
}
|
|
30421
30551
|
const prev = this.list[afterPageId];
|
|
@@ -30458,8 +30588,8 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
30458
30588
|
return this.pageCount;
|
|
30459
30589
|
}
|
|
30460
30590
|
/**
|
|
30461
|
-
|
|
30462
|
-
|
|
30591
|
+
* 跳转至上一页, 并返回跳转后的页面索引.
|
|
30592
|
+
*/
|
|
30463
30593
|
prevPage() {
|
|
30464
30594
|
const currentPageId = this.userMap.get(WhiteboardKeys.currentPage);
|
|
30465
30595
|
const data = this.list[currentPageId];
|
|
@@ -30471,8 +30601,8 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
30471
30601
|
return nextIndex;
|
|
30472
30602
|
}
|
|
30473
30603
|
/**
|
|
30474
|
-
|
|
30475
|
-
|
|
30604
|
+
* 跳转至下一页, 并返回跳转后的页面索引.
|
|
30605
|
+
*/
|
|
30476
30606
|
nextPage() {
|
|
30477
30607
|
const currentPageId = this.userMap.get(WhiteboardKeys.currentPage);
|
|
30478
30608
|
const data = this.list[currentPageId];
|
|
@@ -30484,16 +30614,14 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
30484
30614
|
return nextIndex;
|
|
30485
30615
|
}
|
|
30486
30616
|
/**
|
|
30487
|
-
|
|
30488
|
-
|
|
30489
|
-
|
|
30617
|
+
* 删除指定页面
|
|
30618
|
+
* @param {number} index
|
|
30619
|
+
*/
|
|
30490
30620
|
removePage(index) {
|
|
30491
30621
|
if (this.pageCount <= 1) {
|
|
30492
30622
|
return this.pageCount;
|
|
30493
30623
|
}
|
|
30494
|
-
|
|
30495
|
-
if (cameraMode !== "main") {
|
|
30496
|
-
console.warn(`cannot modify pages in non-main view mode.`);
|
|
30624
|
+
if (!this.modifyDetect()) {
|
|
30497
30625
|
return this.pageCount;
|
|
30498
30626
|
}
|
|
30499
30627
|
const targetId = this.getPageId(index);
|
|
@@ -30533,10 +30661,15 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
30533
30661
|
this.pageModel.gotoPage(targetId);
|
|
30534
30662
|
}
|
|
30535
30663
|
}
|
|
30664
|
+
dispose() {
|
|
30665
|
+
(0, import_forge_room11.removeObserver)(this.indexedPageMap, this.handleIndexedPageMapUpdate);
|
|
30666
|
+
this.pageModel.off("switchPage");
|
|
30667
|
+
this.pageModel.off("pagesChange");
|
|
30668
|
+
}
|
|
30536
30669
|
};
|
|
30537
30670
|
|
|
30538
30671
|
// src/utils/ShadowEmitter.ts
|
|
30539
|
-
var
|
|
30672
|
+
var import_eventemitter312 = __toESM(require("eventemitter3"), 1);
|
|
30540
30673
|
function _defineProperty37(e, r, t) {
|
|
30541
30674
|
return (r = _toPropertyKey37(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
30542
30675
|
}
|
|
@@ -30554,7 +30687,7 @@ function _toPrimitive37(t, r) {
|
|
|
30554
30687
|
}
|
|
30555
30688
|
return ("string" === r ? String : Number)(t);
|
|
30556
30689
|
}
|
|
30557
|
-
var ShadowEmitter = class extends
|
|
30690
|
+
var ShadowEmitter = class extends import_eventemitter312.default {
|
|
30558
30691
|
constructor(userMap) {
|
|
30559
30692
|
super();
|
|
30560
30693
|
_defineProperty37(this, "userMap", void 0);
|
|
@@ -30595,6 +30728,9 @@ var StraightLineTool = class extends WhiteboardTool {
|
|
|
30595
30728
|
this.tool.minDistance = 1;
|
|
30596
30729
|
}
|
|
30597
30730
|
onMouseDown(event) {
|
|
30731
|
+
if (this.elementModel) {
|
|
30732
|
+
this.elementModel.dispose();
|
|
30733
|
+
}
|
|
30598
30734
|
this.elementModel = this.modelGetter().createStraightLine(true);
|
|
30599
30735
|
this.from = event.point.clone();
|
|
30600
30736
|
this.to = event.point.clone();
|
|
@@ -30657,7 +30793,20 @@ var GrabTool = class extends WhiteboardTool {
|
|
|
30657
30793
|
}
|
|
30658
30794
|
};
|
|
30659
30795
|
|
|
30660
|
-
// src/
|
|
30796
|
+
// src/tool/PointerTool.ts
|
|
30797
|
+
var PointerTool = class extends WhiteboardTool {
|
|
30798
|
+
constructor(enableToolEvent, modelGetter, shadowEmitter, scope) {
|
|
30799
|
+
super(enableToolEvent, modelGetter, shadowEmitter, scope);
|
|
30800
|
+
}
|
|
30801
|
+
onMouseDown(_event) {
|
|
30802
|
+
}
|
|
30803
|
+
onMouseDrag(_event) {
|
|
30804
|
+
}
|
|
30805
|
+
onMouseUp() {
|
|
30806
|
+
}
|
|
30807
|
+
};
|
|
30808
|
+
|
|
30809
|
+
// src/SequenceExecutor.ts
|
|
30661
30810
|
function _defineProperty40(e, r, t) {
|
|
30662
30811
|
return (r = _toPropertyKey40(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
30663
30812
|
}
|
|
@@ -30675,8 +30824,56 @@ function _toPrimitive40(t, r) {
|
|
|
30675
30824
|
}
|
|
30676
30825
|
return ("string" === r ? String : Number)(t);
|
|
30677
30826
|
}
|
|
30827
|
+
var SequenceExecutor = class {
|
|
30828
|
+
constructor() {
|
|
30829
|
+
_defineProperty40(this, "tasks", []);
|
|
30830
|
+
_defineProperty40(this, "isRunning", false);
|
|
30831
|
+
}
|
|
30832
|
+
addTask(task) {
|
|
30833
|
+
this.tasks.push(task);
|
|
30834
|
+
if (!this.isRunning) {
|
|
30835
|
+
this.execute();
|
|
30836
|
+
}
|
|
30837
|
+
}
|
|
30838
|
+
async execute() {
|
|
30839
|
+
if (this.isRunning) {
|
|
30840
|
+
return;
|
|
30841
|
+
}
|
|
30842
|
+
this.isRunning = true;
|
|
30843
|
+
while (this.tasks.length > 0) {
|
|
30844
|
+
const task = this.tasks.shift();
|
|
30845
|
+
if (task) {
|
|
30846
|
+
try {
|
|
30847
|
+
await task();
|
|
30848
|
+
} catch (e) {
|
|
30849
|
+
}
|
|
30850
|
+
}
|
|
30851
|
+
}
|
|
30852
|
+
this.isRunning = false;
|
|
30853
|
+
}
|
|
30854
|
+
};
|
|
30855
|
+
|
|
30856
|
+
// src/WhiteboardApplication.ts
|
|
30857
|
+
var import_forge_room13 = require("@netless/forge-room");
|
|
30858
|
+
function _defineProperty41(e, r, t) {
|
|
30859
|
+
return (r = _toPropertyKey41(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
30860
|
+
}
|
|
30861
|
+
function _toPropertyKey41(t) {
|
|
30862
|
+
var i = _toPrimitive41(t, "string");
|
|
30863
|
+
return "symbol" == typeof i ? i : i + "";
|
|
30864
|
+
}
|
|
30865
|
+
function _toPrimitive41(t, r) {
|
|
30866
|
+
if ("object" != typeof t || !t) return t;
|
|
30867
|
+
var e = t[Symbol.toPrimitive];
|
|
30868
|
+
if (void 0 !== e) {
|
|
30869
|
+
var i = e.call(t, r || "default");
|
|
30870
|
+
if ("object" != typeof i) return i;
|
|
30871
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
30872
|
+
}
|
|
30873
|
+
return ("string" === r ? String : Number)(t);
|
|
30874
|
+
}
|
|
30678
30875
|
var WHITEBOARD_APP_NAME = "whiteboard";
|
|
30679
|
-
var WhiteboardApplication = class extends
|
|
30876
|
+
var WhiteboardApplication = class extends import_forge_room12.AbstractApplication {
|
|
30680
30877
|
get undoManager() {
|
|
30681
30878
|
const page = this.pageModel.getCurrentPage(this.userId);
|
|
30682
30879
|
if (page) {
|
|
@@ -30688,43 +30885,46 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30688
30885
|
var _this;
|
|
30689
30886
|
super();
|
|
30690
30887
|
_this = this;
|
|
30691
|
-
|
|
30692
|
-
|
|
30693
|
-
|
|
30694
|
-
|
|
30695
|
-
|
|
30696
|
-
|
|
30697
|
-
|
|
30698
|
-
|
|
30699
|
-
|
|
30700
|
-
|
|
30701
|
-
|
|
30702
|
-
|
|
30703
|
-
|
|
30704
|
-
|
|
30705
|
-
|
|
30706
|
-
|
|
30707
|
-
|
|
30708
|
-
|
|
30709
|
-
|
|
30710
|
-
|
|
30711
|
-
|
|
30712
|
-
|
|
30713
|
-
|
|
30714
|
-
|
|
30715
|
-
|
|
30716
|
-
|
|
30717
|
-
|
|
30718
|
-
|
|
30719
|
-
|
|
30888
|
+
_defineProperty41(this, "name", WHITEBOARD_APP_NAME);
|
|
30889
|
+
_defineProperty41(this, "emitter", void 0);
|
|
30890
|
+
_defineProperty41(this, "toolbarModel", void 0);
|
|
30891
|
+
_defineProperty41(this, "selectElementsModel", void 0);
|
|
30892
|
+
_defineProperty41(this, "trashedElementsModel", void 0);
|
|
30893
|
+
_defineProperty41(this, "pageModel", void 0);
|
|
30894
|
+
_defineProperty41(this, "layers", /* @__PURE__ */ new Map());
|
|
30895
|
+
_defineProperty41(this, "undoManagers", /* @__PURE__ */ new Map());
|
|
30896
|
+
_defineProperty41(this, "imageSets", document.createElement("div"));
|
|
30897
|
+
_defineProperty41(this, "rootElement", document.createElement("div"));
|
|
30898
|
+
_defineProperty41(this, "paperScope", new import_paper.default.PaperScope());
|
|
30899
|
+
_defineProperty41(this, "canvasElement", document.createElement("canvas"));
|
|
30900
|
+
_defineProperty41(this, "shadowScope", new import_paper.default.PaperScope());
|
|
30901
|
+
_defineProperty41(this, "snapshotCanvasElement", document.createElement("canvas"));
|
|
30902
|
+
_defineProperty41(this, "snapshotScope", new import_paper.default.PaperScope());
|
|
30903
|
+
_defineProperty41(this, "shadowCanvasElement", document.createElement("canvas"));
|
|
30904
|
+
_defineProperty41(this, "shadowEmitter", void 0);
|
|
30905
|
+
_defineProperty41(this, "tools", void 0);
|
|
30906
|
+
_defineProperty41(this, "editors", /* @__PURE__ */ new Map());
|
|
30907
|
+
_defineProperty41(this, "camera", void 0);
|
|
30908
|
+
_defineProperty41(this, "resizeObserver", void 0);
|
|
30909
|
+
_defineProperty41(this, "option", void 0);
|
|
30910
|
+
_defineProperty41(this, "permissions", void 0);
|
|
30911
|
+
_defineProperty41(this, "inputType", "any");
|
|
30912
|
+
_defineProperty41(this, "isPenEvent", false);
|
|
30913
|
+
_defineProperty41(this, "hasPenInput", null);
|
|
30914
|
+
_defineProperty41(this, "disableViewModelUpdate", false);
|
|
30915
|
+
_defineProperty41(this, "internalResizeObserver", true);
|
|
30916
|
+
_defineProperty41(this, "sequenceExecutor", new SequenceExecutor());
|
|
30917
|
+
_defineProperty41(this, "linkTarget", null);
|
|
30918
|
+
_defineProperty41(this, "enableToolEvent", () => {
|
|
30720
30919
|
return !(this.inputType === "pen" && !this.isPenEvent);
|
|
30721
30920
|
});
|
|
30722
|
-
|
|
30723
|
-
|
|
30724
|
-
editor.
|
|
30725
|
-
|
|
30726
|
-
|
|
30727
|
-
|
|
30921
|
+
_defineProperty41(this, "handlePageSwitch", (pageId) => {
|
|
30922
|
+
this.sequenceExecutor.addTask(async () => {
|
|
30923
|
+
for (const editor of this.editors.values()) {
|
|
30924
|
+
editor.hidden();
|
|
30925
|
+
}
|
|
30926
|
+
this.selectElementsModel.clearSelectElementForSelf();
|
|
30927
|
+
await waitUntil(() => this.layers.has(pageId), 1e3);
|
|
30728
30928
|
if (this.layers.has(pageId)) {
|
|
30729
30929
|
for (const entry of this.layers.entries()) {
|
|
30730
30930
|
entry[1].off("elementInsert", this.handleElementInsert);
|
|
@@ -30736,6 +30936,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30736
30936
|
renderableModel.on("elementRemove", this.handleElementRemove);
|
|
30737
30937
|
renderableModel.on("elementClear", this.handleElementClear);
|
|
30738
30938
|
renderableModel.flushRenderables();
|
|
30939
|
+
this.paperScope.project.activeLayer.data.pageId = pageId;
|
|
30739
30940
|
const others = this.userManager.userIdList().filter((v) => v !== this.userId);
|
|
30740
30941
|
for (const other of others) {
|
|
30741
30942
|
if (this.userMap(other).get(WhiteboardKeys.currentPage) === pageId) {
|
|
@@ -30745,9 +30946,11 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30745
30946
|
}
|
|
30746
30947
|
}
|
|
30747
30948
|
}
|
|
30949
|
+
} else {
|
|
30950
|
+
console.warn(`[@netless/forge-whiteboard] page ${pageId} not found`);
|
|
30951
|
+
(0, import_forge_room12.log)(`[@netless/forge-whiteboard] page ${pageId} not found`, {}, "warning");
|
|
30748
30952
|
}
|
|
30749
|
-
|
|
30750
|
-
waitUntil(() => this.undoManagers.has(pageId), 3e3).then(() => {
|
|
30953
|
+
await waitUntil(() => this.undoManagers.has(pageId), 1e3);
|
|
30751
30954
|
if (this.undoManagers.has(pageId)) {
|
|
30752
30955
|
for (const entry of this.undoManagers.entries()) {
|
|
30753
30956
|
entry[1].off("stack-item-added", this.handleStackItemAdded);
|
|
@@ -30755,29 +30958,32 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30755
30958
|
}
|
|
30756
30959
|
this.undoManagers.get(pageId).on("stack-item-added", this.handleStackItemAdded);
|
|
30757
30960
|
this.undoManagers.get(pageId).on("stack-item-popped", this.handleStackItemPopped);
|
|
30961
|
+
} else {
|
|
30962
|
+
console.warn(`[@netless/forge-whiteboard] undo manager for page ${pageId} not found`);
|
|
30963
|
+
(0, import_forge_room12.log)(`[@netless/forge-whiteboard] undo manager for page ${pageId} not found`, {}, "warning");
|
|
30758
30964
|
}
|
|
30965
|
+
this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
|
|
30966
|
+
this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
|
|
30759
30967
|
});
|
|
30760
|
-
this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
|
|
30761
|
-
this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
|
|
30762
30968
|
});
|
|
30763
|
-
|
|
30969
|
+
_defineProperty41(this, "hasPermission", (flag) => {
|
|
30764
30970
|
return this.permissions.hasPermission(flag, this.userId);
|
|
30765
30971
|
});
|
|
30766
|
-
|
|
30972
|
+
_defineProperty41(this, "handleStackItemAdded", () => {
|
|
30767
30973
|
this.selectElementsModel.clearSelectElementForSelf();
|
|
30768
30974
|
this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
|
|
30769
30975
|
this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
|
|
30770
30976
|
});
|
|
30771
|
-
|
|
30977
|
+
_defineProperty41(this, "handleStackItemPopped", () => {
|
|
30772
30978
|
this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
|
|
30773
30979
|
this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
|
|
30774
30980
|
});
|
|
30775
|
-
|
|
30981
|
+
_defineProperty41(this, "handleLayersChange", (ids) => {
|
|
30776
30982
|
for (let i = 0, len = ids.length; i < len; i++) {
|
|
30777
30983
|
const id = ids[i];
|
|
30778
30984
|
if (!this.layers.has(id)) {
|
|
30779
30985
|
const elementsMap = this.getMap(`layer/${id}/elements`);
|
|
30780
|
-
const renderableModel = new RenderableModel(id, this.shadowEmitter, elementsMap, this.paperScope, this.toolbarModel, this.userManager, this.hasPermission);
|
|
30986
|
+
const renderableModel = new RenderableModel(id, this.shadowEmitter, elementsMap, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.hasPermission);
|
|
30781
30987
|
this.layers.set(id, renderableModel);
|
|
30782
30988
|
}
|
|
30783
30989
|
if (!this.undoManagers.has(id)) {
|
|
@@ -30788,7 +30994,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30788
30994
|
this.undoManagers.set(id, undoManager);
|
|
30789
30995
|
}
|
|
30790
30996
|
}
|
|
30791
|
-
for (
|
|
30997
|
+
for (const entry of this.layers.entries()) {
|
|
30792
30998
|
if (ids.indexOf(entry[0]) < 0) {
|
|
30793
30999
|
const renderableModel = this.layers.get(entry[0]);
|
|
30794
31000
|
this.layers.delete(entry[0]);
|
|
@@ -30804,17 +31010,17 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30804
31010
|
}
|
|
30805
31011
|
}
|
|
30806
31012
|
});
|
|
30807
|
-
|
|
30808
|
-
|
|
31013
|
+
_defineProperty41(this, "getCurrentRenderableModel", () => {
|
|
31014
|
+
const layerId = this.userMap(this.userId).get(WhiteboardKeys.currentPage);
|
|
30809
31015
|
if (!this.layers.has(layerId)) {
|
|
30810
31016
|
this.emitter.emit("error", 300002, `target page: ${layerId} not found`);
|
|
30811
31017
|
}
|
|
30812
31018
|
return this.layers.get(layerId);
|
|
30813
31019
|
});
|
|
30814
|
-
|
|
31020
|
+
_defineProperty41(this, "handleElementClear", () => {
|
|
30815
31021
|
this.paperScope.project.activeLayer.removeChildren();
|
|
30816
31022
|
});
|
|
30817
|
-
|
|
31023
|
+
_defineProperty41(this, "handleElementInsert", (elements) => {
|
|
30818
31024
|
for (const element of elements) {
|
|
30819
31025
|
element.createPaperElement();
|
|
30820
31026
|
const scope = element.shadow === "" ? this.paperScope : this.shadowScope;
|
|
@@ -30826,7 +31032,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30826
31032
|
this.insertElementToParent(element.item, scope.project.activeLayer);
|
|
30827
31033
|
}
|
|
30828
31034
|
});
|
|
30829
|
-
|
|
31035
|
+
_defineProperty41(this, "handleElementRemove", (elementId, layerId) => {
|
|
30830
31036
|
const layerModel = this.layers.get(layerId);
|
|
30831
31037
|
if (!layerModel) {
|
|
30832
31038
|
return;
|
|
@@ -30837,11 +31043,11 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30837
31043
|
}
|
|
30838
31044
|
layerModel.elementModels.delete(elementId);
|
|
30839
31045
|
});
|
|
30840
|
-
|
|
31046
|
+
_defineProperty41(this, "handleRemoveTrashedElementForSelf", (userId, elementId) => {
|
|
30841
31047
|
const selfLayerId = this.userMap(this.userId).get(WhiteboardKeys.currentPage);
|
|
30842
31048
|
this.layers.get(selfLayerId)?.removeElementItem(elementId);
|
|
30843
31049
|
});
|
|
30844
|
-
|
|
31050
|
+
_defineProperty41(this, "handleElementsTrash", (userId, elements) => {
|
|
30845
31051
|
const targetLayerId = this.userMap(userId).get(WhiteboardKeys.currentPage);
|
|
30846
31052
|
const selfLayerId = this.userMap(this.userId).get(WhiteboardKeys.currentPage);
|
|
30847
31053
|
if (targetLayerId !== selfLayerId || !this.layers.has(targetLayerId)) {
|
|
@@ -30854,7 +31060,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30854
31060
|
}
|
|
30855
31061
|
});
|
|
30856
31062
|
});
|
|
30857
|
-
|
|
31063
|
+
_defineProperty41(this, "handleElementsSelect", (userId, elements) => {
|
|
30858
31064
|
if (!this.editors.has(userId)) {
|
|
30859
31065
|
const ctrl = this.userManager.getUser(userId);
|
|
30860
31066
|
const editor2 = new Editor(this.paperScope, this.shadowScope, this.shadowEmitter, this.canvasElement, this.camera, {
|
|
@@ -30886,7 +31092,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30886
31092
|
}).filter((v) => !!v);
|
|
30887
31093
|
editor.setTargets(elementModels);
|
|
30888
31094
|
if (elementModels.length === 1) {
|
|
30889
|
-
|
|
31095
|
+
const model = elementModels[0];
|
|
30890
31096
|
if (model.item) {
|
|
30891
31097
|
const topLeft = this.paperScope.project.view.projectToView(model.item.bounds.topLeft);
|
|
30892
31098
|
const bottomRight = this.paperScope.project.view.projectToView(model.item.bounds.bottomRight);
|
|
@@ -30897,7 +31103,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30897
31103
|
this.emitter.emit("elementDeselected", userId);
|
|
30898
31104
|
}
|
|
30899
31105
|
});
|
|
30900
|
-
|
|
31106
|
+
_defineProperty41(this, "handleLinkedMapChange", (evt) => {
|
|
30901
31107
|
for (const [key, value] of evt.changes.keys.entries()) {
|
|
30902
31108
|
if (Object.keys(TOOLBAR_KEYS).indexOf(key) >= 0 && (value.action === "add" || value.action === "update")) {
|
|
30903
31109
|
this.toolbarModel.currentTool = evt.target.get(TOOLBAR_KEYS.tool);
|
|
@@ -30914,7 +31120,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30914
31120
|
}
|
|
30915
31121
|
}
|
|
30916
31122
|
});
|
|
30917
|
-
|
|
31123
|
+
_defineProperty41(this, "adjustByOutFrame", (frameWidth, frameHeight) => {
|
|
30918
31124
|
if (this.option.width > 0 && this.option.height > 0) {
|
|
30919
31125
|
const minWidth = Math.max(frameWidth, 10);
|
|
30920
31126
|
const minHeight = Math.max(frameHeight, 10);
|
|
@@ -30930,9 +31136,14 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30930
31136
|
this.camera.triggerZoom();
|
|
30931
31137
|
}
|
|
30932
31138
|
});
|
|
31139
|
+
window.__wb = this;
|
|
30933
31140
|
requestAnimationFrameHook(this.paperScope);
|
|
30934
31141
|
requestAnimationFrameHook(this.shadowScope);
|
|
31142
|
+
const that = this;
|
|
30935
31143
|
this.rootElement.setAttribute("data-forge-app", "whiteboard");
|
|
31144
|
+
this.imageSets.style.display = "none";
|
|
31145
|
+
this.imageSets.setAttribute("data-image-sets", "");
|
|
31146
|
+
this.rootElement.appendChild(this.imageSets);
|
|
30936
31147
|
document.body.addEventListener("pointerdown", (evt) => {
|
|
30937
31148
|
this.isPenEvent = evt.pointerType === "pen";
|
|
30938
31149
|
if (evt.pointerType === "pen" && this.hasPenInput === null) {
|
|
@@ -30994,7 +31205,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30994
31205
|
this.emitter.setViewModeToFree = (userId) => {
|
|
30995
31206
|
if (that.disableViewModelUpdate) {
|
|
30996
31207
|
console.warn("Operation failed. Perspective mode switching is disabled in the current environment.");
|
|
30997
|
-
(0,
|
|
31208
|
+
(0, import_forge_room12.log)("Operation failed. Perspective mode switching is disabled in the current environment.", {}, "warning");
|
|
30998
31209
|
return;
|
|
30999
31210
|
}
|
|
31000
31211
|
const targetId = userId ? this.hasPermission(WhiteboardPermissionFlag.setOthersView) ? userId : null : this.userId;
|
|
@@ -31005,7 +31216,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31005
31216
|
this.emitter.setViewModeToFlow = (flowId, userId) => {
|
|
31006
31217
|
if (that.disableViewModelUpdate) {
|
|
31007
31218
|
console.warn("Operation failed. Perspective mode switching is disabled in the current environment.");
|
|
31008
|
-
(0,
|
|
31219
|
+
(0, import_forge_room12.log)("Operation failed. Perspective mode switching is disabled in the current environment.", {}, "warning");
|
|
31009
31220
|
return;
|
|
31010
31221
|
}
|
|
31011
31222
|
const targetId = userId ? this.hasPermission(WhiteboardPermissionFlag.setOthersView) ? userId : null : this.userId;
|
|
@@ -31020,7 +31231,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31020
31231
|
this.emitter.setViewModeToMain = (userId) => {
|
|
31021
31232
|
if (that.disableViewModelUpdate) {
|
|
31022
31233
|
console.warn("Operation failed. Perspective mode switching is disabled in the current environment.");
|
|
31023
|
-
(0,
|
|
31234
|
+
(0, import_forge_room12.log)("Operation failed. Perspective mode switching is disabled in the current environment.", {}, "warning");
|
|
31024
31235
|
return;
|
|
31025
31236
|
}
|
|
31026
31237
|
const targetId = userId ? this.hasPermission(WhiteboardPermissionFlag.setOthersView) ? userId : null : this.userId;
|
|
@@ -31032,6 +31243,30 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31032
31243
|
this.camera.resetViewMatrixToMain();
|
|
31033
31244
|
}
|
|
31034
31245
|
};
|
|
31246
|
+
this.emitter.insertImage = (src, pageId) => {
|
|
31247
|
+
if (!/https/.test(src)) {
|
|
31248
|
+
(0, import_forge_room12.log)("[@netless/forge-whiteboard] invalid image url, src needs to be in the HTTPS protocol.", {
|
|
31249
|
+
src
|
|
31250
|
+
}, "warning");
|
|
31251
|
+
return;
|
|
31252
|
+
}
|
|
31253
|
+
let targetPageId = pageId;
|
|
31254
|
+
if (!targetPageId) {
|
|
31255
|
+
targetPageId = this.pageModel.getCurrentPage(this.userManager.selfId);
|
|
31256
|
+
}
|
|
31257
|
+
if (!targetPageId) {
|
|
31258
|
+
(0, import_forge_room12.log)("[@netless/forge-whiteboard] page not found", {}, "warning");
|
|
31259
|
+
return;
|
|
31260
|
+
}
|
|
31261
|
+
this.layers.get(targetPageId)?.createImage(src);
|
|
31262
|
+
};
|
|
31263
|
+
this.emitter.removeElement = (pageId, elementId) => {
|
|
31264
|
+
if (!this.layers.has(pageId)) {
|
|
31265
|
+
(0, import_forge_room12.log)("[@netless/forge-whiteboard] page not found", {}, "warning");
|
|
31266
|
+
return;
|
|
31267
|
+
}
|
|
31268
|
+
this.layers.get(pageId)?.removeElementItem(elementId);
|
|
31269
|
+
};
|
|
31035
31270
|
this.emitter.getViewModel = (userId) => {
|
|
31036
31271
|
const targetId = userId ? userId : this.userId;
|
|
31037
31272
|
return this.userMap(targetId).get(WhiteboardKeys.cameraMode);
|
|
@@ -31047,7 +31282,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31047
31282
|
const source = this.getMap(`layer/${sourceId}/elements`);
|
|
31048
31283
|
const target = this.getMap(`layer/${targetId}/elements`);
|
|
31049
31284
|
if (!this.layers.has(targetId)) {
|
|
31050
|
-
this.layers.set(targetId, new RenderableModel(targetId, this.shadowEmitter, target, this.paperScope, this.toolbarModel, this.userManager, this.hasPermission));
|
|
31285
|
+
this.layers.set(targetId, new RenderableModel(targetId, this.shadowEmitter, target, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.hasPermission));
|
|
31051
31286
|
}
|
|
31052
31287
|
if (!this.undoManagers.has(targetId)) {
|
|
31053
31288
|
const undoManager = new Y15.UndoManager(target, {
|
|
@@ -31098,12 +31333,11 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31098
31333
|
this.camera.reset();
|
|
31099
31334
|
};
|
|
31100
31335
|
this.emitter.on("error", (errorCode, errorMessage) => {
|
|
31101
|
-
(0,
|
|
31336
|
+
(0, import_forge_room12.log)("WhiteboardApplicationError", {
|
|
31102
31337
|
errorCode,
|
|
31103
31338
|
errorMessage
|
|
31104
31339
|
});
|
|
31105
31340
|
});
|
|
31106
|
-
const that = this;
|
|
31107
31341
|
Object.defineProperty(this.emitter, "tool", {
|
|
31108
31342
|
get() {
|
|
31109
31343
|
return that.toolbarModel.currentTool;
|
|
@@ -31200,6 +31434,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31200
31434
|
this.permissions = new WhiteboardPermissions(this.userManager, (userId) => {
|
|
31201
31435
|
return this.userMap(userId);
|
|
31202
31436
|
});
|
|
31437
|
+
this.permissions.setPermission(WhiteboardPermissionFlag.all);
|
|
31203
31438
|
this.emitter["permissions"] = this.permissions;
|
|
31204
31439
|
this.emitter["selfUserId"] = this.userId;
|
|
31205
31440
|
this.option = option;
|
|
@@ -31252,6 +31487,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31252
31487
|
return this.userMap(userId);
|
|
31253
31488
|
}, this.hasPermission);
|
|
31254
31489
|
this.tools = {
|
|
31490
|
+
pointer: new PointerTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
|
|
31255
31491
|
curve: new CurveTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
|
|
31256
31492
|
rectangle: new RectangleTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
|
|
31257
31493
|
selector: new SelectorTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope, this.selectElementsModel),
|
|
@@ -31267,6 +31503,11 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31267
31503
|
this.toolbarModel.on("update", (style) => {
|
|
31268
31504
|
if (this.tools[style.tool]) {
|
|
31269
31505
|
this.paperScope.tool = this.tools[style.tool].tool;
|
|
31506
|
+
if (style.tool === "pointer") {
|
|
31507
|
+
this.rootElement.style.pointerEvents = "none";
|
|
31508
|
+
} else {
|
|
31509
|
+
this.rootElement.style.pointerEvents = "auto";
|
|
31510
|
+
}
|
|
31270
31511
|
} else {
|
|
31271
31512
|
this.emitter.emit("error", 300001, `${style.tool} not supported`);
|
|
31272
31513
|
}
|
|
@@ -31276,7 +31517,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31276
31517
|
this.paperScope.tool = this.tools[this.toolbarModel.currentTool].tool;
|
|
31277
31518
|
} else {
|
|
31278
31519
|
this.paperScope.tool = this.tools["curve"].tool;
|
|
31279
|
-
(0,
|
|
31520
|
+
(0, import_forge_room12.log)(`${this.toolbarModel.currentTool} not supported, backup to curve`);
|
|
31280
31521
|
}
|
|
31281
31522
|
this.selectElementsModel.on("elementsChange", this.handleElementsSelect);
|
|
31282
31523
|
this.trashedElementsModel.on("elementsChange", this.handleElementsTrash);
|
|
@@ -31445,7 +31686,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31445
31686
|
if (renderableModel.elementModels.has(key)) {
|
|
31446
31687
|
elementModel = renderableModel.elementModels.get(key) ?? null;
|
|
31447
31688
|
} else {
|
|
31448
|
-
|
|
31689
|
+
const elementMap = renderableModel.elements.get(key);
|
|
31449
31690
|
if (elementMap) {
|
|
31450
31691
|
elementModel = renderableModel.convertToModel(elementMap);
|
|
31451
31692
|
}
|
|
@@ -31521,7 +31762,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31521
31762
|
}
|
|
31522
31763
|
unlink() {
|
|
31523
31764
|
if (this.linkTarget) {
|
|
31524
|
-
this.linkTarget
|
|
31765
|
+
(0, import_forge_room13.removeObserver)(this.linkTarget, this.handleLinkedMapChange);
|
|
31525
31766
|
}
|
|
31526
31767
|
}
|
|
31527
31768
|
setViewSize(width, height) {
|
|
@@ -31532,6 +31773,9 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31532
31773
|
const size = this.paperScope.view.viewSize;
|
|
31533
31774
|
return [size.width, size.height];
|
|
31534
31775
|
}
|
|
31776
|
+
getInherentScale() {
|
|
31777
|
+
return this.camera.getInherentScale();
|
|
31778
|
+
}
|
|
31535
31779
|
updateInternalResizeObserverStatus(value) {
|
|
31536
31780
|
this.internalResizeObserver = value;
|
|
31537
31781
|
}
|
|
@@ -31551,9 +31795,27 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31551
31795
|
this.shadowScope.project.clear();
|
|
31552
31796
|
this.snapshotScope.project.clear();
|
|
31553
31797
|
this.resizeObserver.disconnect();
|
|
31798
|
+
this.unlink();
|
|
31799
|
+
for (const entry of this.undoManagers.entries()) {
|
|
31800
|
+
entry[1].off("stack-item-added", this.handleStackItemAdded);
|
|
31801
|
+
entry[1].off("stack-item-popped", this.handleStackItemPopped);
|
|
31802
|
+
}
|
|
31803
|
+
for (const entry of this.layers.entries()) {
|
|
31804
|
+
entry[1].dispose();
|
|
31805
|
+
entry[1].removeAllListeners();
|
|
31806
|
+
}
|
|
31807
|
+
this.camera.dispose();
|
|
31808
|
+
this.pageModel.dispose();
|
|
31809
|
+
this.pageModel.removeAllListeners();
|
|
31810
|
+
for (const entry of this.editors.entries()) {
|
|
31811
|
+
entry[1].dispose();
|
|
31812
|
+
}
|
|
31813
|
+
this.toolbarModel.dispose();
|
|
31814
|
+
this.emitter.indexedNavigation.dispose();
|
|
31815
|
+
this.permissions.dispose();
|
|
31554
31816
|
}
|
|
31555
31817
|
};
|
|
31556
|
-
|
|
31818
|
+
_defineProperty41(WhiteboardApplication, "applicationName", WHITEBOARD_APP_NAME);
|
|
31557
31819
|
/*! Bundled license information:
|
|
31558
31820
|
|
|
31559
31821
|
paper/dist/paper-full.js:
|