@netless/forge-whiteboard 0.1.13 → 0.1.15
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 +9 -0
- 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 +30 -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 +26 -25
- package/dist/WhitePermissions.d.ts.map +1 -1
- package/dist/Whiteboard.d.ts +106 -106
- package/dist/Whiteboard.d.ts.map +1 -1
- package/dist/WhiteboardApplication.d.ts +6 -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 +19 -19
- 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 +4 -3
- package/dist/model/renderable/CurveModel.d.ts.map +1 -1
- 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/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/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 +383 -171
- package/dist/whiteboard.esm.js.map +4 -4
- package/dist/whiteboard.js +383 -171
- package/dist/whiteboard.js.map +4 -4
- package/package.json +4 -3
package/dist/whiteboard.js
CHANGED
|
@@ -25718,6 +25718,10 @@ var ElementModel = class _ElementModel {
|
|
|
25718
25718
|
const ext = this.styleKeys();
|
|
25719
25719
|
return Array.from(new Set(["dashArray", "strokeColor", "fillColor", "strokeWidth"].filter((v) => ext.exclude.indexOf(v) < 0).concat(ext.include)));
|
|
25720
25720
|
}
|
|
25721
|
+
dispose() {
|
|
25722
|
+
this.subDispose();
|
|
25723
|
+
this.root.unobserveDeep(this.handlePropChange);
|
|
25724
|
+
}
|
|
25721
25725
|
};
|
|
25722
25726
|
_defineProperty(ElementModel, "KEYS", {
|
|
25723
25727
|
index: "index",
|
|
@@ -25898,6 +25902,8 @@ var CurveModel = class extends ElementModel {
|
|
|
25898
25902
|
this.item.fillColor = new this.scope.Color(this.strokeColor);
|
|
25899
25903
|
}
|
|
25900
25904
|
}
|
|
25905
|
+
subDispose() {
|
|
25906
|
+
}
|
|
25901
25907
|
};
|
|
25902
25908
|
|
|
25903
25909
|
// src/model/renderable/SelectorModel.ts
|
|
@@ -25932,14 +25938,12 @@ var SelectorModel = class extends ElementModel {
|
|
|
25932
25938
|
this.root.set("points", initPoints);
|
|
25933
25939
|
}
|
|
25934
25940
|
}
|
|
25941
|
+
subDispose() {
|
|
25942
|
+
}
|
|
25935
25943
|
createPaperRect() {
|
|
25936
25944
|
const scope = this.scope;
|
|
25937
25945
|
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
|
-
);
|
|
25946
|
+
return new scope.Path.Rectangle(bounds, new scope.Point(this.points[4], this.points[4]));
|
|
25943
25947
|
}
|
|
25944
25948
|
onVectorUpdate() {
|
|
25945
25949
|
if (!this.item) {
|
|
@@ -25965,7 +25969,7 @@ var SelectorModel = class extends ElementModel {
|
|
|
25965
25969
|
exclude: []
|
|
25966
25970
|
};
|
|
25967
25971
|
}
|
|
25968
|
-
onStyleKeyUpdate(
|
|
25972
|
+
onStyleKeyUpdate(_key) {
|
|
25969
25973
|
}
|
|
25970
25974
|
};
|
|
25971
25975
|
|
|
@@ -26017,7 +26021,7 @@ var AnimationFrame = class {
|
|
|
26017
26021
|
_defineProperty5(this, "lastTime", 0);
|
|
26018
26022
|
_defineProperty5(this, "fps", 45);
|
|
26019
26023
|
_defineProperty5(this, "handleCallbacks", () => {
|
|
26020
|
-
|
|
26024
|
+
const functions = this.callbacks;
|
|
26021
26025
|
this.callbacks = [];
|
|
26022
26026
|
for (let i = 0, l2 = functions.length; i < l2; i++) {
|
|
26023
26027
|
functions[i]();
|
|
@@ -26070,6 +26074,8 @@ var SegmentsModel = class extends ElementModel {
|
|
|
26070
26074
|
this.root.set("points", new Y4.Array());
|
|
26071
26075
|
}
|
|
26072
26076
|
}
|
|
26077
|
+
subDispose() {
|
|
26078
|
+
}
|
|
26073
26079
|
onVectorUpdate() {
|
|
26074
26080
|
if (!this.item) {
|
|
26075
26081
|
return;
|
|
@@ -26104,7 +26110,7 @@ var SegmentsModel = class extends ElementModel {
|
|
|
26104
26110
|
exclude: []
|
|
26105
26111
|
};
|
|
26106
26112
|
}
|
|
26107
|
-
onStyleKeyUpdate(
|
|
26113
|
+
onStyleKeyUpdate(_key) {
|
|
26108
26114
|
}
|
|
26109
26115
|
};
|
|
26110
26116
|
|
|
@@ -26198,6 +26204,9 @@ var LineTool = class extends WhiteboardTool {
|
|
|
26198
26204
|
this.tool.minDistance = 1;
|
|
26199
26205
|
}
|
|
26200
26206
|
onMouseDown(event) {
|
|
26207
|
+
if (this.elementModel) {
|
|
26208
|
+
this.elementModel.dispose();
|
|
26209
|
+
}
|
|
26201
26210
|
this.elementModel = this.modelGetter().createLinePath(true);
|
|
26202
26211
|
this.from = event.point.clone();
|
|
26203
26212
|
this.to = event.point.clone();
|
|
@@ -26273,6 +26282,8 @@ var LineModel = class extends ElementModel {
|
|
|
26273
26282
|
this.root.set("tailArrow", "normal");
|
|
26274
26283
|
}
|
|
26275
26284
|
}
|
|
26285
|
+
subDispose() {
|
|
26286
|
+
}
|
|
26276
26287
|
onVectorUpdate() {
|
|
26277
26288
|
if (!this.item) {
|
|
26278
26289
|
return;
|
|
@@ -26309,7 +26320,7 @@ var LineModel = class extends ElementModel {
|
|
|
26309
26320
|
this.item.addChildren(this.renderLine());
|
|
26310
26321
|
}
|
|
26311
26322
|
createArrow(path) {
|
|
26312
|
-
|
|
26323
|
+
const [headPath, tailPath] = [new this.scope.Path(), new this.scope.Path()];
|
|
26313
26324
|
if (!path) {
|
|
26314
26325
|
return [headPath, tailPath];
|
|
26315
26326
|
}
|
|
@@ -26363,7 +26374,7 @@ var LineModel = class extends ElementModel {
|
|
|
26363
26374
|
exclude: ["fillColor"]
|
|
26364
26375
|
};
|
|
26365
26376
|
}
|
|
26366
|
-
onStyleKeyUpdate(
|
|
26377
|
+
onStyleKeyUpdate(_key) {
|
|
26367
26378
|
this.onVectorUpdate();
|
|
26368
26379
|
}
|
|
26369
26380
|
};
|
|
@@ -26486,6 +26497,9 @@ var PointTextModel = class extends ElementModel {
|
|
|
26486
26497
|
}, 60);
|
|
26487
26498
|
}
|
|
26488
26499
|
}
|
|
26500
|
+
subDispose() {
|
|
26501
|
+
this.root.unobserve(this.handleTextPropChange);
|
|
26502
|
+
}
|
|
26489
26503
|
getInternalMeasurement() {
|
|
26490
26504
|
if (!this.item) {
|
|
26491
26505
|
return null;
|
|
@@ -26591,6 +26605,8 @@ var TriangleModel = class extends ElementModel {
|
|
|
26591
26605
|
this.root.set("points", new Y7.Array());
|
|
26592
26606
|
}
|
|
26593
26607
|
}
|
|
26608
|
+
subDispose() {
|
|
26609
|
+
}
|
|
26594
26610
|
createPaperItem() {
|
|
26595
26611
|
this.item = new this.scope.Path();
|
|
26596
26612
|
this.item.strokeCap = "butt";
|
|
@@ -26647,7 +26663,7 @@ var TriangleModel = class extends ElementModel {
|
|
|
26647
26663
|
exclude: []
|
|
26648
26664
|
};
|
|
26649
26665
|
}
|
|
26650
|
-
onStyleKeyUpdate(
|
|
26666
|
+
onStyleKeyUpdate(_key) {
|
|
26651
26667
|
}
|
|
26652
26668
|
};
|
|
26653
26669
|
|
|
@@ -26686,6 +26702,8 @@ var RectangleModel = class extends ElementModel {
|
|
|
26686
26702
|
this.root.set("radius", 0);
|
|
26687
26703
|
}
|
|
26688
26704
|
}
|
|
26705
|
+
subDispose() {
|
|
26706
|
+
}
|
|
26689
26707
|
createSegments() {
|
|
26690
26708
|
const [a2, b2, c, d] = this.points;
|
|
26691
26709
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
@@ -26817,7 +26835,7 @@ var RectangleModel = class extends ElementModel {
|
|
|
26817
26835
|
exclude: []
|
|
26818
26836
|
};
|
|
26819
26837
|
}
|
|
26820
|
-
onStyleKeyUpdate(
|
|
26838
|
+
onStyleKeyUpdate(_key) {
|
|
26821
26839
|
}
|
|
26822
26840
|
};
|
|
26823
26841
|
|
|
@@ -26958,9 +26976,11 @@ var EraserModel = class extends ElementModel {
|
|
|
26958
26976
|
exclude: []
|
|
26959
26977
|
};
|
|
26960
26978
|
}
|
|
26961
|
-
onStyleKeyUpdate(
|
|
26979
|
+
onStyleKeyUpdate(_key) {
|
|
26962
26980
|
return;
|
|
26963
26981
|
}
|
|
26982
|
+
subDispose() {
|
|
26983
|
+
}
|
|
26964
26984
|
};
|
|
26965
26985
|
|
|
26966
26986
|
// src/model/renderable/LaserPointerModel.ts
|
|
@@ -27117,9 +27137,11 @@ var LaserPointerModel = class extends ElementModel {
|
|
|
27117
27137
|
exclude: []
|
|
27118
27138
|
};
|
|
27119
27139
|
}
|
|
27120
|
-
onStyleKeyUpdate(
|
|
27140
|
+
onStyleKeyUpdate(_key) {
|
|
27121
27141
|
return;
|
|
27122
27142
|
}
|
|
27143
|
+
subDispose() {
|
|
27144
|
+
}
|
|
27123
27145
|
};
|
|
27124
27146
|
|
|
27125
27147
|
// src/WhitePermissions.ts
|
|
@@ -27184,6 +27206,9 @@ var WhiteboardPermissions = class extends import_eventemitter3.default {
|
|
|
27184
27206
|
const observer = (evt) => {
|
|
27185
27207
|
this.handleUserPermissionChange(userId, evt);
|
|
27186
27208
|
};
|
|
27209
|
+
if (this.observers.has(userId)) {
|
|
27210
|
+
this.requestUserMap(userId).unobserve(this.observers.get(userId));
|
|
27211
|
+
}
|
|
27187
27212
|
this.observers.set(userId, observer);
|
|
27188
27213
|
this.requestUserMap(userId).observe(observer);
|
|
27189
27214
|
}
|
|
@@ -27204,56 +27229,64 @@ var WhiteboardPermissions = class extends import_eventemitter3.default {
|
|
|
27204
27229
|
}
|
|
27205
27230
|
}
|
|
27206
27231
|
/**
|
|
27207
|
-
|
|
27208
|
-
|
|
27209
|
-
|
|
27210
|
-
|
|
27232
|
+
* 解析权限列表组合
|
|
27233
|
+
* @param {number} value - 权限数字值
|
|
27234
|
+
* @return {WhiteboardPermissionFlag[]} - 权限列表
|
|
27235
|
+
*/
|
|
27211
27236
|
resolveFlags(value) {
|
|
27212
27237
|
return [WhiteboardPermissionFlag.draw, WhiteboardPermissionFlag.editSelf, WhiteboardPermissionFlag.editOthers, WhiteboardPermissionFlag.deleteSelf, WhiteboardPermissionFlag.deleteOthers, WhiteboardPermissionFlag.mainView, WhiteboardPermissionFlag.setOthersView].filter((v) => (v & value) !== 0);
|
|
27213
27238
|
}
|
|
27214
27239
|
/**
|
|
27215
|
-
|
|
27216
|
-
|
|
27217
|
-
|
|
27240
|
+
* 获取权限列表组合对应的数值
|
|
27241
|
+
* @param { string } userId 不传表示获取自己
|
|
27242
|
+
*/
|
|
27218
27243
|
getPermissionValue(userId) {
|
|
27219
27244
|
return this.requestUserMap(userId ?? this.userManager.selfId).get("permission") ?? 0;
|
|
27220
27245
|
}
|
|
27221
27246
|
/**
|
|
27222
|
-
|
|
27223
|
-
|
|
27224
|
-
|
|
27247
|
+
* 获取权限列表
|
|
27248
|
+
* @param {string=} userId 可选, 不传表示获取自己
|
|
27249
|
+
*/
|
|
27225
27250
|
getPermissionFlags(userId) {
|
|
27226
27251
|
const value = this.requestUserMap(userId ?? this.userManager.selfId).get("permission") ?? 0;
|
|
27227
27252
|
return this.resolveFlags(value);
|
|
27228
27253
|
}
|
|
27229
27254
|
/**
|
|
27230
|
-
|
|
27231
|
-
|
|
27232
|
-
|
|
27233
|
-
|
|
27255
|
+
* 返回对应 userId 是否有相应权限
|
|
27256
|
+
* @param {string=} userId 可选, 不传表示返回自己是否有相应权限
|
|
27257
|
+
* @param {WhiteboardPermissionFlag} flag
|
|
27258
|
+
*/
|
|
27234
27259
|
hasPermission(flag, userId) {
|
|
27235
27260
|
return ((this.requestUserMap(userId ?? this.userManager.selfId).get("permission") ?? 0) & flag) !== 0;
|
|
27236
27261
|
}
|
|
27237
27262
|
/**
|
|
27238
|
-
|
|
27239
|
-
|
|
27240
|
-
|
|
27241
|
-
|
|
27263
|
+
* 添加权限
|
|
27264
|
+
* @param {WhiteboardPermissionFlag} flag 权限标记
|
|
27265
|
+
* @param {string=} userId 可选, 为 userId 添加权限, 不传表示为自己添加权限
|
|
27266
|
+
*/
|
|
27242
27267
|
addPermission(flag, userId) {
|
|
27243
27268
|
const userMap = this.requestUserMap(userId ?? this.userManager.selfId);
|
|
27244
27269
|
const oldValue = userMap.get("permission") ?? 0;
|
|
27245
27270
|
this.requestUserMap(userId ?? this.userManager.selfId).set("permission", oldValue | flag);
|
|
27246
27271
|
}
|
|
27247
27272
|
/**
|
|
27248
|
-
|
|
27249
|
-
|
|
27250
|
-
|
|
27251
|
-
|
|
27273
|
+
* 移除权限
|
|
27274
|
+
* @param {WhiteboardPermissionFlag} flag 权限标记
|
|
27275
|
+
* @param {string=} userId 可选, 为 userId 移除权限, 不传表示为自己移除权限
|
|
27276
|
+
*/
|
|
27252
27277
|
removePermission(flag, userId) {
|
|
27253
27278
|
const userMap = this.requestUserMap(userId ?? this.userManager.selfId);
|
|
27254
27279
|
const oldValue = userMap.get("permission") ?? 0;
|
|
27255
27280
|
this.requestUserMap(userId ?? this.userManager.selfId).set("permission", oldValue & ~flag);
|
|
27256
27281
|
}
|
|
27282
|
+
dispose() {
|
|
27283
|
+
this.userManager.off("join", this.handleUserJoin);
|
|
27284
|
+
this.userManager.off("leave", this.handleUserLeave);
|
|
27285
|
+
this.observers.forEach((cb, userId) => {
|
|
27286
|
+
this.requestUserMap(userId).unobserve(cb);
|
|
27287
|
+
});
|
|
27288
|
+
this.observers.clear();
|
|
27289
|
+
}
|
|
27257
27290
|
};
|
|
27258
27291
|
|
|
27259
27292
|
// src/model/renderable/StraightLineModel.ts
|
|
@@ -27287,6 +27320,8 @@ var StraightLineModel = class extends ElementModel {
|
|
|
27287
27320
|
this.root.set("points", new Y11.Array());
|
|
27288
27321
|
}
|
|
27289
27322
|
}
|
|
27323
|
+
subDispose() {
|
|
27324
|
+
}
|
|
27290
27325
|
onVectorUpdate() {
|
|
27291
27326
|
if (!this.item) {
|
|
27292
27327
|
return;
|
|
@@ -27360,7 +27395,7 @@ var StraightLineModel = class extends ElementModel {
|
|
|
27360
27395
|
exclude: ["fillColor"]
|
|
27361
27396
|
};
|
|
27362
27397
|
}
|
|
27363
|
-
onStyleKeyUpdate(
|
|
27398
|
+
onStyleKeyUpdate(_key) {
|
|
27364
27399
|
if (!this.item) {
|
|
27365
27400
|
return;
|
|
27366
27401
|
}
|
|
@@ -27582,7 +27617,7 @@ var RenderableModel = class extends import_eventemitter32.default {
|
|
|
27582
27617
|
return segmentsModel;
|
|
27583
27618
|
}
|
|
27584
27619
|
createSelector() {
|
|
27585
|
-
let
|
|
27620
|
+
let _shadow = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
|
|
27586
27621
|
if (!this.hasPermission(WhiteboardPermissionFlag.editSelf) && !this.hasPermission(WhiteboardPermissionFlag.deleteOthers)) {
|
|
27587
27622
|
return null;
|
|
27588
27623
|
}
|
|
@@ -27639,7 +27674,11 @@ var RenderableModel = class extends import_eventemitter32.default {
|
|
|
27639
27674
|
});
|
|
27640
27675
|
}
|
|
27641
27676
|
dispose() {
|
|
27677
|
+
this.elements.unobserve(this.onElementsChange);
|
|
27642
27678
|
this.elements.clear();
|
|
27679
|
+
Array.from(this.elementModels.values()).forEach((model) => {
|
|
27680
|
+
model.dispose();
|
|
27681
|
+
});
|
|
27643
27682
|
}
|
|
27644
27683
|
};
|
|
27645
27684
|
|
|
@@ -27682,10 +27721,10 @@ var AnglePrecision = Deg2Rad(2);
|
|
|
27682
27721
|
var Phi = 0.5 * (-1 + Math.sqrt(5));
|
|
27683
27722
|
function DollarRecognizer() {
|
|
27684
27723
|
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
|
|
27724
|
+
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)]);
|
|
27725
|
+
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)]);
|
|
27726
|
+
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)]);
|
|
27727
|
+
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
27728
|
this.Recognize = function(points, useProtractor) {
|
|
27690
27729
|
var t0 = Date.now();
|
|
27691
27730
|
var candidate = new Unistroke("", points);
|
|
@@ -27746,7 +27785,7 @@ function RotateBy(points, radians) {
|
|
|
27746
27785
|
var c = Centroid(points);
|
|
27747
27786
|
var cos = Math.cos(radians);
|
|
27748
27787
|
var sin = Math.sin(radians);
|
|
27749
|
-
var newpoints =
|
|
27788
|
+
var newpoints = [];
|
|
27750
27789
|
for (var i = 0; i < points.length; i++) {
|
|
27751
27790
|
var qx = (points[i].X - c.X) * cos - (points[i].Y - c.Y) * sin + c.X;
|
|
27752
27791
|
var qy = (points[i].X - c.X) * sin + (points[i].Y - c.Y) * cos + c.Y;
|
|
@@ -27756,7 +27795,7 @@ function RotateBy(points, radians) {
|
|
|
27756
27795
|
}
|
|
27757
27796
|
function ScaleTo(points, size) {
|
|
27758
27797
|
var B2 = BoundingBox(points);
|
|
27759
|
-
var newpoints =
|
|
27798
|
+
var newpoints = [];
|
|
27760
27799
|
for (var i = 0; i < points.length; i++) {
|
|
27761
27800
|
var qx = points[i].X * (size / B2.Width);
|
|
27762
27801
|
var qy = points[i].Y * (size / B2.Height);
|
|
@@ -27766,7 +27805,7 @@ function ScaleTo(points, size) {
|
|
|
27766
27805
|
}
|
|
27767
27806
|
function TranslateTo(points, pt) {
|
|
27768
27807
|
var c = Centroid(points);
|
|
27769
|
-
var newpoints =
|
|
27808
|
+
var newpoints = [];
|
|
27770
27809
|
for (var i = 0; i < points.length; i++) {
|
|
27771
27810
|
var qx = points[i].X + pt.X - c.X;
|
|
27772
27811
|
var qy = points[i].Y + pt.Y - c.Y;
|
|
@@ -27776,14 +27815,14 @@ function TranslateTo(points, pt) {
|
|
|
27776
27815
|
}
|
|
27777
27816
|
function Vectorize(points) {
|
|
27778
27817
|
var sum = 0;
|
|
27779
|
-
var vector =
|
|
27780
|
-
for (
|
|
27818
|
+
var vector = [];
|
|
27819
|
+
for (let i = 0; i < points.length; i++) {
|
|
27781
27820
|
vector[vector.length] = points[i].X;
|
|
27782
27821
|
vector[vector.length] = points[i].Y;
|
|
27783
27822
|
sum += points[i].X * points[i].X + points[i].Y * points[i].Y;
|
|
27784
27823
|
}
|
|
27785
27824
|
var magnitude = Math.sqrt(sum);
|
|
27786
|
-
for (
|
|
27825
|
+
for (let i = 0; i < vector.length; i++)
|
|
27787
27826
|
vector[i] /= magnitude;
|
|
27788
27827
|
return vector;
|
|
27789
27828
|
}
|
|
@@ -27937,8 +27976,11 @@ var CurveTool = class extends WhiteboardTool {
|
|
|
27937
27976
|
_defineProperty19(this, "pointCount", 0);
|
|
27938
27977
|
this.tool.minDistance = 1;
|
|
27939
27978
|
}
|
|
27940
|
-
onMouseDown(
|
|
27979
|
+
onMouseDown(_event) {
|
|
27941
27980
|
this.pointCount = 0;
|
|
27981
|
+
if (this.elementModel) {
|
|
27982
|
+
this.elementModel.dispose();
|
|
27983
|
+
}
|
|
27942
27984
|
this.elementModel = this.modelGetter().createCurve(true);
|
|
27943
27985
|
}
|
|
27944
27986
|
onMouseDrag(event) {
|
|
@@ -28009,6 +28051,9 @@ var RectangleTool = class extends WhiteboardTool {
|
|
|
28009
28051
|
this.tool.minDistance = 1;
|
|
28010
28052
|
}
|
|
28011
28053
|
onMouseDown(event) {
|
|
28054
|
+
if (this.elementModel) {
|
|
28055
|
+
this.elementModel.dispose();
|
|
28056
|
+
}
|
|
28012
28057
|
this.elementModel = this.modelGetter().createRectangle(true);
|
|
28013
28058
|
this.from = event.point.clone();
|
|
28014
28059
|
this.to = event.point.clone();
|
|
@@ -28126,6 +28171,10 @@ var ToolbarModel = class extends import_eventemitter33.default {
|
|
|
28126
28171
|
}
|
|
28127
28172
|
});
|
|
28128
28173
|
}
|
|
28174
|
+
dispose() {
|
|
28175
|
+
this.root.unobserve(this.handleRootUpdate);
|
|
28176
|
+
this.removeAllListeners();
|
|
28177
|
+
}
|
|
28129
28178
|
};
|
|
28130
28179
|
|
|
28131
28180
|
// src/tool/SelectorTool.ts
|
|
@@ -28159,6 +28208,9 @@ var SelectorTool = class extends WhiteboardTool {
|
|
|
28159
28208
|
onMouseDown(event) {
|
|
28160
28209
|
this.from = null;
|
|
28161
28210
|
this.to = null;
|
|
28211
|
+
if (this.elementModel) {
|
|
28212
|
+
this.elementModel.dispose();
|
|
28213
|
+
}
|
|
28162
28214
|
this.elementModel = this.modelGetter().createSelector();
|
|
28163
28215
|
this.from = event.point.clone();
|
|
28164
28216
|
this.to = event.point.clone();
|
|
@@ -28256,12 +28308,16 @@ var SelectElementsModel = class extends import_eventemitter34.default {
|
|
|
28256
28308
|
const cb = this.observers.get(user.id);
|
|
28257
28309
|
if (cb) {
|
|
28258
28310
|
this.requestUserMap(user.id).unobserveDeep(cb);
|
|
28311
|
+
this.observers.delete(user.id);
|
|
28259
28312
|
}
|
|
28260
28313
|
});
|
|
28261
28314
|
_defineProperty23(this, "handleUserJoin", (user) => {
|
|
28262
28315
|
const observer = (evts) => {
|
|
28263
28316
|
this.handleUserSelectElementsChange(user.id, evts);
|
|
28264
28317
|
};
|
|
28318
|
+
if (this.observers.has(user.id)) {
|
|
28319
|
+
this.requestUserMap(user.id).unobserveDeep(this.observers.get(user.id));
|
|
28320
|
+
}
|
|
28265
28321
|
this.requestUserMap(user.id).observeDeep(observer);
|
|
28266
28322
|
this.observers.set(user.id, observer);
|
|
28267
28323
|
});
|
|
@@ -28281,6 +28337,9 @@ var SelectElementsModel = class extends import_eventemitter34.default {
|
|
|
28281
28337
|
const observer = (evts) => {
|
|
28282
28338
|
this.handleUserSelectElementsChange(userId, evts);
|
|
28283
28339
|
};
|
|
28340
|
+
if (this.observers.has(userId)) {
|
|
28341
|
+
this.requestUserMap(userId).unobserveDeep(this.observers.get(userId));
|
|
28342
|
+
}
|
|
28284
28343
|
this.requestUserMap(userId).observeDeep(observer);
|
|
28285
28344
|
this.observers.set(userId, observer);
|
|
28286
28345
|
});
|
|
@@ -28335,12 +28394,9 @@ var SelectElementsModel = class extends import_eventemitter34.default {
|
|
|
28335
28394
|
});
|
|
28336
28395
|
}
|
|
28337
28396
|
dispose() {
|
|
28338
|
-
this.
|
|
28339
|
-
|
|
28340
|
-
|
|
28341
|
-
this.requestUserMap(userId).unobserveDeep(cb);
|
|
28342
|
-
}
|
|
28343
|
-
});
|
|
28397
|
+
for (const [key, value] of this.observers.entries()) {
|
|
28398
|
+
this.requestUserMap(key).unobserveDeep(value);
|
|
28399
|
+
}
|
|
28344
28400
|
this.observers.clear();
|
|
28345
28401
|
this.userManager.off("leave", this.handleUserLeave);
|
|
28346
28402
|
this.userManager.off("join", this.handleUserJoin);
|
|
@@ -28402,12 +28458,12 @@ var TextEditor = class extends import_eventemitter35.EventEmitter {
|
|
|
28402
28458
|
});
|
|
28403
28459
|
this.camera = camera;
|
|
28404
28460
|
this.rootView = document.createElement("div");
|
|
28405
|
-
this.rootView.style.cssText =
|
|
28461
|
+
this.rootView.style.cssText = "position:absolute;width:100%;height:100%;top:0;left:0;overflow:hidden;";
|
|
28406
28462
|
this.content = document.createElement("div");
|
|
28407
28463
|
this.content.setAttribute("spellcheck", "false");
|
|
28408
28464
|
this.content.textContent = "";
|
|
28409
28465
|
this.content.setAttribute("contenteditable", "plaintext-only");
|
|
28410
|
-
this.content.style.cssText =
|
|
28466
|
+
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
28467
|
this.content.style.transformOrigin = "0 0";
|
|
28412
28468
|
this.rootView.appendChild(this.content);
|
|
28413
28469
|
this.content.addEventListener("input", this.handleContentInput);
|
|
@@ -28752,7 +28808,7 @@ var Editor = class extends import_eventemitter36.default {
|
|
|
28752
28808
|
}
|
|
28753
28809
|
if (this.editMode === "matrix" && this.editAnchor && this.lastEditPoint) {
|
|
28754
28810
|
const offsetX = evt.pageX - this.lastEditPoint.x;
|
|
28755
|
-
|
|
28811
|
+
const offsetY = evt.pageY - this.lastEditPoint.y;
|
|
28756
28812
|
this.bounds.offsetBy(this.editAnchor, offsetX, offsetY, this.uniformScale ? this.aspectRatio : -1);
|
|
28757
28813
|
this.lastEditPoint = {
|
|
28758
28814
|
x: evt.pageX,
|
|
@@ -28777,7 +28833,7 @@ var Editor = class extends import_eventemitter36.default {
|
|
|
28777
28833
|
}
|
|
28778
28834
|
if (this.editMode === "translate" && this.lastEditPoint) {
|
|
28779
28835
|
const offsetX = evt.pageX - this.lastEditPoint.x;
|
|
28780
|
-
|
|
28836
|
+
const offsetY = evt.pageY - this.lastEditPoint.y;
|
|
28781
28837
|
this.bounds.translate(offsetX, offsetY);
|
|
28782
28838
|
this.updateBoundsByShadow();
|
|
28783
28839
|
this.lastEditPoint = {
|
|
@@ -28854,7 +28910,7 @@ var Editor = class extends import_eventemitter36.default {
|
|
|
28854
28910
|
this.ctrlId = initConfig.ctrlId;
|
|
28855
28911
|
this.ctrlNickName = initConfig.ctrlNickName;
|
|
28856
28912
|
this.rootView = document.createElement("div");
|
|
28857
|
-
this.rootView.style.cssText =
|
|
28913
|
+
this.rootView.style.cssText = "position:absolute;display:none;width:100%;height:100%;top:50%;left:50%;transform:translate(-50%,-50%);";
|
|
28858
28914
|
this.frame = document.createElement("div");
|
|
28859
28915
|
this.frame.style.position = "absolute";
|
|
28860
28916
|
this.frame.style.padding = "8px";
|
|
@@ -28875,7 +28931,7 @@ var Editor = class extends import_eventemitter36.default {
|
|
|
28875
28931
|
} else {
|
|
28876
28932
|
this.title = document.createElement("div");
|
|
28877
28933
|
this.title.textContent = `${this.ctrlNickName}`;
|
|
28878
|
-
this.title.style.cssText =
|
|
28934
|
+
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
28935
|
this.frame.appendChild(this.title);
|
|
28880
28936
|
this.rootView.style.pointerEvents = "none";
|
|
28881
28937
|
}
|
|
@@ -29047,7 +29103,9 @@ var Editor = class extends import_eventemitter36.default {
|
|
|
29047
29103
|
this.targets = [];
|
|
29048
29104
|
this.editorConfig = null;
|
|
29049
29105
|
if (this.ctrlId !== this.viewerId) {
|
|
29050
|
-
this.scope.project.view
|
|
29106
|
+
if (this.scope.project.view) {
|
|
29107
|
+
this.scope.project.view.off("frame", this.updateBounds);
|
|
29108
|
+
}
|
|
29051
29109
|
}
|
|
29052
29110
|
}
|
|
29053
29111
|
show() {
|
|
@@ -29106,7 +29164,7 @@ var TextTool = class extends WhiteboardTool {
|
|
|
29106
29164
|
onMouseDown(event) {
|
|
29107
29165
|
this.from = event.point.clone();
|
|
29108
29166
|
}
|
|
29109
|
-
onMouseDrag(
|
|
29167
|
+
onMouseDrag(_event) {
|
|
29110
29168
|
}
|
|
29111
29169
|
onMouseUp(event) {
|
|
29112
29170
|
this.to = event.point.clone();
|
|
@@ -29118,6 +29176,9 @@ var TextTool = class extends WhiteboardTool {
|
|
|
29118
29176
|
}
|
|
29119
29177
|
}
|
|
29120
29178
|
createPointEditor(x, y) {
|
|
29179
|
+
if (this.elementModel) {
|
|
29180
|
+
this.elementModel.dispose();
|
|
29181
|
+
}
|
|
29121
29182
|
this.elementModel = this.modelGetter().createPointText(x, y, true);
|
|
29122
29183
|
if (this.elementModel === null) {
|
|
29123
29184
|
return;
|
|
@@ -29323,6 +29384,9 @@ var Camera = class extends import_eventemitter38.default {
|
|
|
29323
29384
|
const observer = (evt) => {
|
|
29324
29385
|
this.handleViewMatrixUpdate(user.id, evt);
|
|
29325
29386
|
};
|
|
29387
|
+
if (this.observers.has(user.id)) {
|
|
29388
|
+
this.requestUserMap(user.id).unobserve(observer);
|
|
29389
|
+
}
|
|
29326
29390
|
this.requestUserMap(user.id).observe(observer);
|
|
29327
29391
|
this.observers.set(user.id, observer);
|
|
29328
29392
|
});
|
|
@@ -29402,7 +29466,7 @@ var Camera = class extends import_eventemitter38.default {
|
|
|
29402
29466
|
});
|
|
29403
29467
|
this.maxScale = maxScale;
|
|
29404
29468
|
this.bound = window.document.createElement("div");
|
|
29405
|
-
this.bound.style.cssText =
|
|
29469
|
+
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
29470
|
this.initSize = initSize;
|
|
29407
29471
|
this.hasPermission = hasPermission;
|
|
29408
29472
|
this.paperSize = _paperSize;
|
|
@@ -29427,6 +29491,9 @@ var Camera = class extends import_eventemitter38.default {
|
|
|
29427
29491
|
const observer = (evt) => {
|
|
29428
29492
|
this.handleViewMatrixUpdate(userId, evt);
|
|
29429
29493
|
};
|
|
29494
|
+
if (this.observers.has(userId)) {
|
|
29495
|
+
this.requestUserMap(userId).unobserve(observer);
|
|
29496
|
+
}
|
|
29430
29497
|
this.requestUserMap(userId).observe(observer);
|
|
29431
29498
|
this.observers.set(userId, observer);
|
|
29432
29499
|
});
|
|
@@ -29463,7 +29530,7 @@ var Camera = class extends import_eventemitter38.default {
|
|
|
29463
29530
|
this.bound.style.boxShadow = `inset 0px 0px 6px 2px ${this.boundaryColor}`;
|
|
29464
29531
|
window.clearTimeout(this.boundTiemoutId);
|
|
29465
29532
|
this.boundTiemoutId = window.setTimeout(() => {
|
|
29466
|
-
this.bound.style.boxShadow =
|
|
29533
|
+
this.bound.style.boxShadow = "none";
|
|
29467
29534
|
}, 100);
|
|
29468
29535
|
}
|
|
29469
29536
|
}
|
|
@@ -29473,6 +29540,9 @@ var Camera = class extends import_eventemitter38.default {
|
|
|
29473
29540
|
updateInherentScale(scale) {
|
|
29474
29541
|
this.inherentScale = scale;
|
|
29475
29542
|
}
|
|
29543
|
+
getInherentScale() {
|
|
29544
|
+
return this.inherentScale;
|
|
29545
|
+
}
|
|
29476
29546
|
getActiveMatrix() {
|
|
29477
29547
|
const cameraMode = this.requestUserMap(this.userManager.selfId).get(WhiteboardKeys.cameraMode);
|
|
29478
29548
|
let matrixValue;
|
|
@@ -29615,6 +29685,19 @@ var Camera = class extends import_eventemitter38.default {
|
|
|
29615
29685
|
y: 0
|
|
29616
29686
|
};
|
|
29617
29687
|
}
|
|
29688
|
+
dispose() {
|
|
29689
|
+
Array.from(this.observers.keys()).forEach((userId) => {
|
|
29690
|
+
const cb = this.observers.get(userId);
|
|
29691
|
+
if (cb) {
|
|
29692
|
+
this.requestUserMap(userId).unobserve(cb);
|
|
29693
|
+
}
|
|
29694
|
+
});
|
|
29695
|
+
this.whiteboardAttrsMap.unobserve(this.handleMainCameraChange);
|
|
29696
|
+
this.userManager.off("join", this.handleUserJoin);
|
|
29697
|
+
this.userManager.off("leave", this.handleUserLeave);
|
|
29698
|
+
this.gesture.removeAllListeners();
|
|
29699
|
+
this.removeAllListeners();
|
|
29700
|
+
}
|
|
29618
29701
|
};
|
|
29619
29702
|
|
|
29620
29703
|
// src/tool/EllipseTool.ts
|
|
@@ -29644,6 +29727,9 @@ var EllipseTool = class extends WhiteboardTool {
|
|
|
29644
29727
|
this.tool.minDistance = 1;
|
|
29645
29728
|
}
|
|
29646
29729
|
onMouseDown(event) {
|
|
29730
|
+
if (this.elementModel) {
|
|
29731
|
+
this.elementModel.dispose();
|
|
29732
|
+
}
|
|
29647
29733
|
this.elementModel = this.modelGetter().createSegmentedPath("ellipse", true);
|
|
29648
29734
|
this.from = event.point.clone();
|
|
29649
29735
|
this.to = event.point.clone();
|
|
@@ -29695,6 +29781,9 @@ var TriangleTool = class extends WhiteboardTool {
|
|
|
29695
29781
|
this.tool.minDistance = 1;
|
|
29696
29782
|
}
|
|
29697
29783
|
onMouseDown(event) {
|
|
29784
|
+
if (this.elementModel) {
|
|
29785
|
+
this.elementModel.dispose();
|
|
29786
|
+
}
|
|
29698
29787
|
this.elementModel = this.modelGetter().createTriangle(true);
|
|
29699
29788
|
this.from = event.point.clone();
|
|
29700
29789
|
this.to = event.point.clone();
|
|
@@ -29811,8 +29900,11 @@ var EraserTool = class extends WhiteboardTool {
|
|
|
29811
29900
|
this.trashedElementsModel = trashedElementsModel;
|
|
29812
29901
|
this.tool.minDistance = 1;
|
|
29813
29902
|
}
|
|
29814
|
-
onMouseDown(
|
|
29903
|
+
onMouseDown(_event) {
|
|
29815
29904
|
this.pointCount = 0;
|
|
29905
|
+
if (this.elementModel) {
|
|
29906
|
+
this.elementModel.dispose();
|
|
29907
|
+
}
|
|
29816
29908
|
this.elementModel = this.modelGetter().createEraser();
|
|
29817
29909
|
}
|
|
29818
29910
|
onMouseDrag(event) {
|
|
@@ -29834,7 +29926,7 @@ var EraserTool = class extends WhiteboardTool {
|
|
|
29834
29926
|
}
|
|
29835
29927
|
});
|
|
29836
29928
|
}
|
|
29837
|
-
onMouseUp(
|
|
29929
|
+
onMouseUp(_event) {
|
|
29838
29930
|
if (this.elementModel) {
|
|
29839
29931
|
this.modelGetter().removeElementItem(this.elementModel.uuid);
|
|
29840
29932
|
}
|
|
@@ -29885,6 +29977,9 @@ var TrashedElementsModel = class extends import_eventemitter310.default {
|
|
|
29885
29977
|
const observer = (evts) => {
|
|
29886
29978
|
this.handleUserTrashElementsChange(user.id, evts);
|
|
29887
29979
|
};
|
|
29980
|
+
if (this.observers.has(user.id)) {
|
|
29981
|
+
this.requestUserMap(user.id).unobserveDeep(this.observers.get(user.id));
|
|
29982
|
+
}
|
|
29888
29983
|
this.requestUserMap(user.id).observeDeep(observer);
|
|
29889
29984
|
this.observers.set(user.id, observer);
|
|
29890
29985
|
});
|
|
@@ -29896,6 +29991,9 @@ var TrashedElementsModel = class extends import_eventemitter310.default {
|
|
|
29896
29991
|
const observer = (evts) => {
|
|
29897
29992
|
this.handleUserTrashElementsChange(userId, evts);
|
|
29898
29993
|
};
|
|
29994
|
+
if (this.observers.has(userId)) {
|
|
29995
|
+
this.requestUserMap(userId).unobserveDeep(this.observers.get(userId));
|
|
29996
|
+
}
|
|
29899
29997
|
this.requestUserMap(userId).observeDeep(observer);
|
|
29900
29998
|
this.observers.set(userId, observer);
|
|
29901
29999
|
});
|
|
@@ -29950,12 +30048,9 @@ var TrashedElementsModel = class extends import_eventemitter310.default {
|
|
|
29950
30048
|
});
|
|
29951
30049
|
}
|
|
29952
30050
|
dispose() {
|
|
29953
|
-
this.
|
|
29954
|
-
|
|
29955
|
-
|
|
29956
|
-
this.requestUserMap(userId).unobserveDeep(cb);
|
|
29957
|
-
}
|
|
29958
|
-
});
|
|
30051
|
+
for (const [key, value] of this.observers.entries()) {
|
|
30052
|
+
this.requestUserMap(key).unobserveDeep(value);
|
|
30053
|
+
}
|
|
29959
30054
|
this.observers.clear();
|
|
29960
30055
|
this.userManager.off("leave", this.handleUserLeave);
|
|
29961
30056
|
this.userManager.off("join", this.handleUserJoin);
|
|
@@ -29987,8 +30082,11 @@ var LaserPointerTool = class extends WhiteboardTool {
|
|
|
29987
30082
|
_defineProperty34(this, "pointCount", 0);
|
|
29988
30083
|
this.tool.minDistance = 5;
|
|
29989
30084
|
}
|
|
29990
|
-
onMouseDown(
|
|
30085
|
+
onMouseDown(_event) {
|
|
29991
30086
|
this.pointCount = 0;
|
|
30087
|
+
if (this.elementModel) {
|
|
30088
|
+
this.elementModel.dispose();
|
|
30089
|
+
}
|
|
29992
30090
|
this.elementModel = this.modelGetter().createLaserPointer();
|
|
29993
30091
|
}
|
|
29994
30092
|
onMouseDrag(event) {
|
|
@@ -30000,7 +30098,7 @@ var LaserPointerTool = class extends WhiteboardTool {
|
|
|
30000
30098
|
this.elementModel.appendPoints([event.point.x, event.point.y]);
|
|
30001
30099
|
}
|
|
30002
30100
|
}
|
|
30003
|
-
onMouseUp(
|
|
30101
|
+
onMouseUp(_event) {
|
|
30004
30102
|
if (this.elementModel) {
|
|
30005
30103
|
this.elementModel.beginRemoveAnimate();
|
|
30006
30104
|
}
|
|
@@ -30122,11 +30220,11 @@ var PageModel = class extends import_eventemitter311.default {
|
|
|
30122
30220
|
}
|
|
30123
30221
|
const cameraMode = this.requestUserMap(this.userManager.selfId).get(WhiteboardKeys.cameraMode);
|
|
30124
30222
|
if (cameraMode !== "main") {
|
|
30125
|
-
console.warn(
|
|
30223
|
+
console.warn("cannot modify pages in non-main view mode.");
|
|
30126
30224
|
return false;
|
|
30127
30225
|
}
|
|
30128
30226
|
if (!this.hasPermission(WhiteboardPermissionFlag.mainView)) {
|
|
30129
|
-
console.warn(
|
|
30227
|
+
console.warn("cannot modify pages without WhiteboardPermissionFlag.mainView.");
|
|
30130
30228
|
return false;
|
|
30131
30229
|
}
|
|
30132
30230
|
return true;
|
|
@@ -30178,15 +30276,24 @@ var PageModel = class extends import_eventemitter311.default {
|
|
|
30178
30276
|
}
|
|
30179
30277
|
}
|
|
30180
30278
|
}
|
|
30279
|
+
dispose() {
|
|
30280
|
+
for (const entry of this.observers.entries()) {
|
|
30281
|
+
const [userId, observer] = entry;
|
|
30282
|
+
this.requestUserMap(userId).unobserve(observer);
|
|
30283
|
+
}
|
|
30284
|
+
this.userManager.off("join", this.handleUserJoin);
|
|
30285
|
+
this.userManager.off("leave", this.handleUserLeave);
|
|
30286
|
+
this.whiteboardAttrsMap.unobserve(this.handleMainPageChange);
|
|
30287
|
+
this.pageMap.unobserve(this.handlePageMapChange);
|
|
30288
|
+
}
|
|
30181
30289
|
};
|
|
30182
30290
|
|
|
30183
30291
|
// src/utils/async.ts
|
|
30184
30292
|
var delay = (value) => new Promise((resolve) => setTimeout(resolve, value));
|
|
30185
30293
|
async function waitUntil(fn, timeout) {
|
|
30186
|
-
|
|
30294
|
+
const start = Date.now();
|
|
30187
30295
|
while (!fn() && Date.now() - start < timeout) {
|
|
30188
30296
|
await delay(50);
|
|
30189
|
-
start = Date.now();
|
|
30190
30297
|
}
|
|
30191
30298
|
}
|
|
30192
30299
|
|
|
@@ -30215,14 +30322,14 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
30215
30322
|
return this.pageModel.pageList().filter((id) => /^_i_/.test(id));
|
|
30216
30323
|
}
|
|
30217
30324
|
get head() {
|
|
30218
|
-
|
|
30325
|
+
const headId = Object.keys(this.list).find((key) => {
|
|
30219
30326
|
return this.list[key] && this.list[key].prev === "";
|
|
30220
30327
|
});
|
|
30221
30328
|
if (!headId) {
|
|
30222
|
-
(0, import_forge_room2.log)(
|
|
30329
|
+
(0, import_forge_room2.log)("indexed navigation confusion", {
|
|
30223
30330
|
list: JSON.stringify(this.list)
|
|
30224
30331
|
}, "error");
|
|
30225
|
-
throw new Error(
|
|
30332
|
+
throw new Error("indexed navigation confusion");
|
|
30226
30333
|
}
|
|
30227
30334
|
return headId;
|
|
30228
30335
|
}
|
|
@@ -30243,7 +30350,7 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
30243
30350
|
_defineProperty36(this, "indexedPageMap", void 0);
|
|
30244
30351
|
_defineProperty36(this, "list", {});
|
|
30245
30352
|
_defineProperty36(this, "hasPermission", void 0);
|
|
30246
|
-
_defineProperty36(this, "handleIndexedPageMapUpdate", (
|
|
30353
|
+
_defineProperty36(this, "handleIndexedPageMapUpdate", (_evt) => {
|
|
30247
30354
|
this.list = this.indexedPageMap.get("list");
|
|
30248
30355
|
const needRemoveList = this.pageModel.pageList().filter((v) => /^_i_/.test(v) && Object.keys(this.list).indexOf(v) < 0);
|
|
30249
30356
|
const needAddList = Object.keys(this.list).filter((v) => this.pageModel.pageList().indexOf(v) < 0);
|
|
@@ -30298,8 +30405,8 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
30298
30405
|
initIndexed() {
|
|
30299
30406
|
return new Promise((resolve) => {
|
|
30300
30407
|
setTimeout(() => {
|
|
30408
|
+
this.pageModel.addPage("_i_");
|
|
30301
30409
|
if (this.pageModel.pageList().length === 0) {
|
|
30302
|
-
this.pageModel.addPage("_i_");
|
|
30303
30410
|
resolve(true);
|
|
30304
30411
|
} else {
|
|
30305
30412
|
resolve(false);
|
|
@@ -30308,15 +30415,15 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
30308
30415
|
});
|
|
30309
30416
|
}
|
|
30310
30417
|
/**
|
|
30311
|
-
|
|
30312
|
-
|
|
30313
|
-
|
|
30418
|
+
* 获取总页数
|
|
30419
|
+
* @returns {number}
|
|
30420
|
+
*/
|
|
30314
30421
|
get pageCount() {
|
|
30315
30422
|
return this.idList.length;
|
|
30316
30423
|
}
|
|
30317
30424
|
/**
|
|
30318
|
-
|
|
30319
|
-
|
|
30425
|
+
* 获取当前页索引
|
|
30426
|
+
*/
|
|
30320
30427
|
get currentPageIndex() {
|
|
30321
30428
|
const userPageId = this.userMap.get(WhiteboardKeys.currentPage);
|
|
30322
30429
|
return this.getPageIndex(userPageId);
|
|
@@ -30336,9 +30443,9 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
30336
30443
|
return i;
|
|
30337
30444
|
}
|
|
30338
30445
|
/**
|
|
30339
|
-
|
|
30340
|
-
|
|
30341
|
-
|
|
30446
|
+
* 获取指定索引对应的 pageId
|
|
30447
|
+
* @param {number} index
|
|
30448
|
+
*/
|
|
30342
30449
|
getPageId(index) {
|
|
30343
30450
|
const firstKey = this.head;
|
|
30344
30451
|
if (firstKey) {
|
|
@@ -30360,20 +30467,20 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
30360
30467
|
modifyDetect() {
|
|
30361
30468
|
const cameraMode = this.userMap.get(WhiteboardKeys.cameraMode);
|
|
30362
30469
|
if (cameraMode !== "main") {
|
|
30363
|
-
console.warn(
|
|
30470
|
+
console.warn("cannot modify pages in non-main view mode.");
|
|
30364
30471
|
return false;
|
|
30365
30472
|
}
|
|
30366
30473
|
if (!this.hasPermission(WhiteboardPermissionFlag.mainView)) {
|
|
30367
|
-
console.warn(
|
|
30474
|
+
console.warn("cannot modify pages without WhiteboardPermissionFlag.mainView.");
|
|
30368
30475
|
return false;
|
|
30369
30476
|
}
|
|
30370
30477
|
return true;
|
|
30371
30478
|
}
|
|
30372
30479
|
/**
|
|
30373
|
-
|
|
30374
|
-
|
|
30375
|
-
|
|
30376
|
-
|
|
30480
|
+
* 在尾部插入新页面
|
|
30481
|
+
* @param {boolean=} goto 是否跳转到新页面, 默认 true
|
|
30482
|
+
* @return 总页数
|
|
30483
|
+
*/
|
|
30377
30484
|
pushPage() {
|
|
30378
30485
|
let goto = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
|
|
30379
30486
|
this.indexedPageMap.doc.transact(() => {
|
|
@@ -30402,11 +30509,11 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
30402
30509
|
return this.pageCount;
|
|
30403
30510
|
}
|
|
30404
30511
|
/**
|
|
30405
|
-
|
|
30406
|
-
|
|
30407
|
-
|
|
30408
|
-
|
|
30409
|
-
|
|
30512
|
+
* 在 after 之后插入新页面
|
|
30513
|
+
* @param {number} after 在此页之后插入
|
|
30514
|
+
* @param {boolean=} goto 是否跳转到新页面, 默认 true
|
|
30515
|
+
* @return 总页数
|
|
30516
|
+
*/
|
|
30410
30517
|
insertPage(after) {
|
|
30411
30518
|
let goto = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
30412
30519
|
const afterPageId = this.getPageId(after);
|
|
@@ -30415,7 +30522,7 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
30415
30522
|
}
|
|
30416
30523
|
const cameraMode = this.userMap.get(WhiteboardKeys.cameraMode);
|
|
30417
30524
|
if (cameraMode !== "main") {
|
|
30418
|
-
console.warn(
|
|
30525
|
+
console.warn("cannot modify pages in non-main view mode.");
|
|
30419
30526
|
return this.pageCount;
|
|
30420
30527
|
}
|
|
30421
30528
|
const prev = this.list[afterPageId];
|
|
@@ -30458,8 +30565,8 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
30458
30565
|
return this.pageCount;
|
|
30459
30566
|
}
|
|
30460
30567
|
/**
|
|
30461
|
-
|
|
30462
|
-
|
|
30568
|
+
* 跳转至上一页, 并返回跳转后的页面索引.
|
|
30569
|
+
*/
|
|
30463
30570
|
prevPage() {
|
|
30464
30571
|
const currentPageId = this.userMap.get(WhiteboardKeys.currentPage);
|
|
30465
30572
|
const data = this.list[currentPageId];
|
|
@@ -30471,8 +30578,8 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
30471
30578
|
return nextIndex;
|
|
30472
30579
|
}
|
|
30473
30580
|
/**
|
|
30474
|
-
|
|
30475
|
-
|
|
30581
|
+
* 跳转至下一页, 并返回跳转后的页面索引.
|
|
30582
|
+
*/
|
|
30476
30583
|
nextPage() {
|
|
30477
30584
|
const currentPageId = this.userMap.get(WhiteboardKeys.currentPage);
|
|
30478
30585
|
const data = this.list[currentPageId];
|
|
@@ -30484,16 +30591,16 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
30484
30591
|
return nextIndex;
|
|
30485
30592
|
}
|
|
30486
30593
|
/**
|
|
30487
|
-
|
|
30488
|
-
|
|
30489
|
-
|
|
30594
|
+
* 删除指定页面
|
|
30595
|
+
* @param {number} index
|
|
30596
|
+
*/
|
|
30490
30597
|
removePage(index) {
|
|
30491
30598
|
if (this.pageCount <= 1) {
|
|
30492
30599
|
return this.pageCount;
|
|
30493
30600
|
}
|
|
30494
30601
|
const cameraMode = this.userMap.get(WhiteboardKeys.cameraMode);
|
|
30495
30602
|
if (cameraMode !== "main") {
|
|
30496
|
-
console.warn(
|
|
30603
|
+
console.warn("cannot modify pages in non-main view mode.");
|
|
30497
30604
|
return this.pageCount;
|
|
30498
30605
|
}
|
|
30499
30606
|
const targetId = this.getPageId(index);
|
|
@@ -30533,6 +30640,11 @@ var IndexedNavigation = class extends import_eventemitter312.default {
|
|
|
30533
30640
|
this.pageModel.gotoPage(targetId);
|
|
30534
30641
|
}
|
|
30535
30642
|
}
|
|
30643
|
+
dispose() {
|
|
30644
|
+
this.indexedPageMap.unobserve(this.handleIndexedPageMapUpdate);
|
|
30645
|
+
this.pageModel.off("switchPage");
|
|
30646
|
+
this.pageModel.off("pagesChange");
|
|
30647
|
+
}
|
|
30536
30648
|
};
|
|
30537
30649
|
|
|
30538
30650
|
// src/utils/ShadowEmitter.ts
|
|
@@ -30595,6 +30707,9 @@ var StraightLineTool = class extends WhiteboardTool {
|
|
|
30595
30707
|
this.tool.minDistance = 1;
|
|
30596
30708
|
}
|
|
30597
30709
|
onMouseDown(event) {
|
|
30710
|
+
if (this.elementModel) {
|
|
30711
|
+
this.elementModel.dispose();
|
|
30712
|
+
}
|
|
30598
30713
|
this.elementModel = this.modelGetter().createStraightLine(true);
|
|
30599
30714
|
this.from = event.point.clone();
|
|
30600
30715
|
this.to = event.point.clone();
|
|
@@ -30657,7 +30772,20 @@ var GrabTool = class extends WhiteboardTool {
|
|
|
30657
30772
|
}
|
|
30658
30773
|
};
|
|
30659
30774
|
|
|
30660
|
-
// src/
|
|
30775
|
+
// src/tool/PointerTool.ts
|
|
30776
|
+
var PointerTool = class extends WhiteboardTool {
|
|
30777
|
+
constructor(enableToolEvent, modelGetter, shadowEmitter, scope) {
|
|
30778
|
+
super(enableToolEvent, modelGetter, shadowEmitter, scope);
|
|
30779
|
+
}
|
|
30780
|
+
onMouseDown(_event) {
|
|
30781
|
+
}
|
|
30782
|
+
onMouseDrag(_event) {
|
|
30783
|
+
}
|
|
30784
|
+
onMouseUp() {
|
|
30785
|
+
}
|
|
30786
|
+
};
|
|
30787
|
+
|
|
30788
|
+
// src/SequenceExecutor.ts
|
|
30661
30789
|
function _defineProperty40(e, r, t) {
|
|
30662
30790
|
return (r = _toPropertyKey40(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
30663
30791
|
}
|
|
@@ -30675,6 +30803,53 @@ function _toPrimitive40(t, r) {
|
|
|
30675
30803
|
}
|
|
30676
30804
|
return ("string" === r ? String : Number)(t);
|
|
30677
30805
|
}
|
|
30806
|
+
var SequenceExecutor = class {
|
|
30807
|
+
constructor() {
|
|
30808
|
+
_defineProperty40(this, "tasks", []);
|
|
30809
|
+
_defineProperty40(this, "isRunning", false);
|
|
30810
|
+
}
|
|
30811
|
+
addTask(task) {
|
|
30812
|
+
this.tasks.push(task);
|
|
30813
|
+
if (!this.isRunning) {
|
|
30814
|
+
this.execute();
|
|
30815
|
+
}
|
|
30816
|
+
}
|
|
30817
|
+
async execute() {
|
|
30818
|
+
if (this.isRunning) {
|
|
30819
|
+
return;
|
|
30820
|
+
}
|
|
30821
|
+
this.isRunning = true;
|
|
30822
|
+
while (this.tasks.length > 0) {
|
|
30823
|
+
const task = this.tasks.shift();
|
|
30824
|
+
if (task) {
|
|
30825
|
+
try {
|
|
30826
|
+
await task();
|
|
30827
|
+
} catch (e) {
|
|
30828
|
+
}
|
|
30829
|
+
}
|
|
30830
|
+
}
|
|
30831
|
+
this.isRunning = false;
|
|
30832
|
+
}
|
|
30833
|
+
};
|
|
30834
|
+
|
|
30835
|
+
// src/WhiteboardApplication.ts
|
|
30836
|
+
function _defineProperty41(e, r, t) {
|
|
30837
|
+
return (r = _toPropertyKey41(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
30838
|
+
}
|
|
30839
|
+
function _toPropertyKey41(t) {
|
|
30840
|
+
var i = _toPrimitive41(t, "string");
|
|
30841
|
+
return "symbol" == typeof i ? i : i + "";
|
|
30842
|
+
}
|
|
30843
|
+
function _toPrimitive41(t, r) {
|
|
30844
|
+
if ("object" != typeof t || !t) return t;
|
|
30845
|
+
var e = t[Symbol.toPrimitive];
|
|
30846
|
+
if (void 0 !== e) {
|
|
30847
|
+
var i = e.call(t, r || "default");
|
|
30848
|
+
if ("object" != typeof i) return i;
|
|
30849
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
30850
|
+
}
|
|
30851
|
+
return ("string" === r ? String : Number)(t);
|
|
30852
|
+
}
|
|
30678
30853
|
var WHITEBOARD_APP_NAME = "whiteboard";
|
|
30679
30854
|
var WhiteboardApplication = class extends import_forge_room3.AbstractApplication {
|
|
30680
30855
|
get undoManager() {
|
|
@@ -30688,43 +30863,45 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30688
30863
|
var _this;
|
|
30689
30864
|
super();
|
|
30690
30865
|
_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
|
-
|
|
30866
|
+
_defineProperty41(this, "name", WHITEBOARD_APP_NAME);
|
|
30867
|
+
_defineProperty41(this, "emitter", void 0);
|
|
30868
|
+
_defineProperty41(this, "toolbarModel", void 0);
|
|
30869
|
+
_defineProperty41(this, "selectElementsModel", void 0);
|
|
30870
|
+
_defineProperty41(this, "trashedElementsModel", void 0);
|
|
30871
|
+
_defineProperty41(this, "pageModel", void 0);
|
|
30872
|
+
_defineProperty41(this, "layers", /* @__PURE__ */ new Map());
|
|
30873
|
+
_defineProperty41(this, "undoManagers", /* @__PURE__ */ new Map());
|
|
30874
|
+
_defineProperty41(this, "rootElement", document.createElement("div"));
|
|
30875
|
+
_defineProperty41(this, "paperScope", new import_paper.default.PaperScope());
|
|
30876
|
+
_defineProperty41(this, "canvasElement", document.createElement("canvas"));
|
|
30877
|
+
_defineProperty41(this, "shadowScope", new import_paper.default.PaperScope());
|
|
30878
|
+
_defineProperty41(this, "snapshotCanvasElement", document.createElement("canvas"));
|
|
30879
|
+
_defineProperty41(this, "snapshotScope", new import_paper.default.PaperScope());
|
|
30880
|
+
_defineProperty41(this, "shadowCanvasElement", document.createElement("canvas"));
|
|
30881
|
+
_defineProperty41(this, "shadowEmitter", void 0);
|
|
30882
|
+
_defineProperty41(this, "tools", void 0);
|
|
30883
|
+
_defineProperty41(this, "editors", /* @__PURE__ */ new Map());
|
|
30884
|
+
_defineProperty41(this, "camera", void 0);
|
|
30885
|
+
_defineProperty41(this, "resizeObserver", void 0);
|
|
30886
|
+
_defineProperty41(this, "option", void 0);
|
|
30887
|
+
_defineProperty41(this, "permissions", void 0);
|
|
30888
|
+
_defineProperty41(this, "inputType", "any");
|
|
30889
|
+
_defineProperty41(this, "isPenEvent", false);
|
|
30890
|
+
_defineProperty41(this, "hasPenInput", null);
|
|
30891
|
+
_defineProperty41(this, "disableViewModelUpdate", false);
|
|
30892
|
+
_defineProperty41(this, "internalResizeObserver", true);
|
|
30893
|
+
_defineProperty41(this, "sequenceExecutor", new SequenceExecutor());
|
|
30894
|
+
_defineProperty41(this, "linkTarget", null);
|
|
30895
|
+
_defineProperty41(this, "enableToolEvent", () => {
|
|
30720
30896
|
return !(this.inputType === "pen" && !this.isPenEvent);
|
|
30721
30897
|
});
|
|
30722
|
-
|
|
30723
|
-
|
|
30724
|
-
editor.
|
|
30725
|
-
|
|
30726
|
-
|
|
30727
|
-
|
|
30898
|
+
_defineProperty41(this, "handlePageSwitch", (pageId) => {
|
|
30899
|
+
this.sequenceExecutor.addTask(async () => {
|
|
30900
|
+
for (const editor of this.editors.values()) {
|
|
30901
|
+
editor.hidden();
|
|
30902
|
+
}
|
|
30903
|
+
this.selectElementsModel.clearSelectElementForSelf();
|
|
30904
|
+
await waitUntil(() => this.layers.has(pageId), 1e3);
|
|
30728
30905
|
if (this.layers.has(pageId)) {
|
|
30729
30906
|
for (const entry of this.layers.entries()) {
|
|
30730
30907
|
entry[1].off("elementInsert", this.handleElementInsert);
|
|
@@ -30736,6 +30913,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30736
30913
|
renderableModel.on("elementRemove", this.handleElementRemove);
|
|
30737
30914
|
renderableModel.on("elementClear", this.handleElementClear);
|
|
30738
30915
|
renderableModel.flushRenderables();
|
|
30916
|
+
this.paperScope.project.activeLayer.data.pageId = pageId;
|
|
30739
30917
|
const others = this.userManager.userIdList().filter((v) => v !== this.userId);
|
|
30740
30918
|
for (const other of others) {
|
|
30741
30919
|
if (this.userMap(other).get(WhiteboardKeys.currentPage) === pageId) {
|
|
@@ -30745,9 +30923,11 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30745
30923
|
}
|
|
30746
30924
|
}
|
|
30747
30925
|
}
|
|
30926
|
+
} else {
|
|
30927
|
+
console.warn(`[@netless/forge-whiteboard] page ${pageId} not found`);
|
|
30928
|
+
(0, import_forge_room3.log)(`[@netless/forge-whiteboard] page ${pageId} not found`, {}, "warning");
|
|
30748
30929
|
}
|
|
30749
|
-
|
|
30750
|
-
waitUntil(() => this.undoManagers.has(pageId), 3e3).then(() => {
|
|
30930
|
+
await waitUntil(() => this.undoManagers.has(pageId), 1e3);
|
|
30751
30931
|
if (this.undoManagers.has(pageId)) {
|
|
30752
30932
|
for (const entry of this.undoManagers.entries()) {
|
|
30753
30933
|
entry[1].off("stack-item-added", this.handleStackItemAdded);
|
|
@@ -30755,24 +30935,27 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30755
30935
|
}
|
|
30756
30936
|
this.undoManagers.get(pageId).on("stack-item-added", this.handleStackItemAdded);
|
|
30757
30937
|
this.undoManagers.get(pageId).on("stack-item-popped", this.handleStackItemPopped);
|
|
30938
|
+
} else {
|
|
30939
|
+
console.warn(`[@netless/forge-whiteboard] undo manager for page ${pageId} not found`);
|
|
30940
|
+
(0, import_forge_room3.log)(`[@netless/forge-whiteboard] undo manager for page ${pageId} not found`, {}, "warning");
|
|
30758
30941
|
}
|
|
30942
|
+
this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
|
|
30943
|
+
this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
|
|
30759
30944
|
});
|
|
30760
|
-
this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
|
|
30761
|
-
this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
|
|
30762
30945
|
});
|
|
30763
|
-
|
|
30946
|
+
_defineProperty41(this, "hasPermission", (flag) => {
|
|
30764
30947
|
return this.permissions.hasPermission(flag, this.userId);
|
|
30765
30948
|
});
|
|
30766
|
-
|
|
30949
|
+
_defineProperty41(this, "handleStackItemAdded", () => {
|
|
30767
30950
|
this.selectElementsModel.clearSelectElementForSelf();
|
|
30768
30951
|
this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
|
|
30769
30952
|
this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
|
|
30770
30953
|
});
|
|
30771
|
-
|
|
30954
|
+
_defineProperty41(this, "handleStackItemPopped", () => {
|
|
30772
30955
|
this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
|
|
30773
30956
|
this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
|
|
30774
30957
|
});
|
|
30775
|
-
|
|
30958
|
+
_defineProperty41(this, "handleLayersChange", (ids) => {
|
|
30776
30959
|
for (let i = 0, len = ids.length; i < len; i++) {
|
|
30777
30960
|
const id = ids[i];
|
|
30778
30961
|
if (!this.layers.has(id)) {
|
|
@@ -30788,7 +30971,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30788
30971
|
this.undoManagers.set(id, undoManager);
|
|
30789
30972
|
}
|
|
30790
30973
|
}
|
|
30791
|
-
for (
|
|
30974
|
+
for (const entry of this.layers.entries()) {
|
|
30792
30975
|
if (ids.indexOf(entry[0]) < 0) {
|
|
30793
30976
|
const renderableModel = this.layers.get(entry[0]);
|
|
30794
30977
|
this.layers.delete(entry[0]);
|
|
@@ -30804,17 +30987,17 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30804
30987
|
}
|
|
30805
30988
|
}
|
|
30806
30989
|
});
|
|
30807
|
-
|
|
30808
|
-
|
|
30990
|
+
_defineProperty41(this, "getCurrentRenderableModel", () => {
|
|
30991
|
+
const layerId = this.userMap(this.userId).get(WhiteboardKeys.currentPage);
|
|
30809
30992
|
if (!this.layers.has(layerId)) {
|
|
30810
30993
|
this.emitter.emit("error", 300002, `target page: ${layerId} not found`);
|
|
30811
30994
|
}
|
|
30812
30995
|
return this.layers.get(layerId);
|
|
30813
30996
|
});
|
|
30814
|
-
|
|
30997
|
+
_defineProperty41(this, "handleElementClear", () => {
|
|
30815
30998
|
this.paperScope.project.activeLayer.removeChildren();
|
|
30816
30999
|
});
|
|
30817
|
-
|
|
31000
|
+
_defineProperty41(this, "handleElementInsert", (elements) => {
|
|
30818
31001
|
for (const element of elements) {
|
|
30819
31002
|
element.createPaperElement();
|
|
30820
31003
|
const scope = element.shadow === "" ? this.paperScope : this.shadowScope;
|
|
@@ -30826,7 +31009,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30826
31009
|
this.insertElementToParent(element.item, scope.project.activeLayer);
|
|
30827
31010
|
}
|
|
30828
31011
|
});
|
|
30829
|
-
|
|
31012
|
+
_defineProperty41(this, "handleElementRemove", (elementId, layerId) => {
|
|
30830
31013
|
const layerModel = this.layers.get(layerId);
|
|
30831
31014
|
if (!layerModel) {
|
|
30832
31015
|
return;
|
|
@@ -30837,11 +31020,11 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30837
31020
|
}
|
|
30838
31021
|
layerModel.elementModels.delete(elementId);
|
|
30839
31022
|
});
|
|
30840
|
-
|
|
31023
|
+
_defineProperty41(this, "handleRemoveTrashedElementForSelf", (userId, elementId) => {
|
|
30841
31024
|
const selfLayerId = this.userMap(this.userId).get(WhiteboardKeys.currentPage);
|
|
30842
31025
|
this.layers.get(selfLayerId)?.removeElementItem(elementId);
|
|
30843
31026
|
});
|
|
30844
|
-
|
|
31027
|
+
_defineProperty41(this, "handleElementsTrash", (userId, elements) => {
|
|
30845
31028
|
const targetLayerId = this.userMap(userId).get(WhiteboardKeys.currentPage);
|
|
30846
31029
|
const selfLayerId = this.userMap(this.userId).get(WhiteboardKeys.currentPage);
|
|
30847
31030
|
if (targetLayerId !== selfLayerId || !this.layers.has(targetLayerId)) {
|
|
@@ -30854,7 +31037,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30854
31037
|
}
|
|
30855
31038
|
});
|
|
30856
31039
|
});
|
|
30857
|
-
|
|
31040
|
+
_defineProperty41(this, "handleElementsSelect", (userId, elements) => {
|
|
30858
31041
|
if (!this.editors.has(userId)) {
|
|
30859
31042
|
const ctrl = this.userManager.getUser(userId);
|
|
30860
31043
|
const editor2 = new Editor(this.paperScope, this.shadowScope, this.shadowEmitter, this.canvasElement, this.camera, {
|
|
@@ -30886,7 +31069,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30886
31069
|
}).filter((v) => !!v);
|
|
30887
31070
|
editor.setTargets(elementModels);
|
|
30888
31071
|
if (elementModels.length === 1) {
|
|
30889
|
-
|
|
31072
|
+
const model = elementModels[0];
|
|
30890
31073
|
if (model.item) {
|
|
30891
31074
|
const topLeft = this.paperScope.project.view.projectToView(model.item.bounds.topLeft);
|
|
30892
31075
|
const bottomRight = this.paperScope.project.view.projectToView(model.item.bounds.bottomRight);
|
|
@@ -30897,7 +31080,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30897
31080
|
this.emitter.emit("elementDeselected", userId);
|
|
30898
31081
|
}
|
|
30899
31082
|
});
|
|
30900
|
-
|
|
31083
|
+
_defineProperty41(this, "handleLinkedMapChange", (evt) => {
|
|
30901
31084
|
for (const [key, value] of evt.changes.keys.entries()) {
|
|
30902
31085
|
if (Object.keys(TOOLBAR_KEYS).indexOf(key) >= 0 && (value.action === "add" || value.action === "update")) {
|
|
30903
31086
|
this.toolbarModel.currentTool = evt.target.get(TOOLBAR_KEYS.tool);
|
|
@@ -30909,11 +31092,12 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30909
31092
|
this.toolbarModel.dashArray = evt.target.get(TOOLBAR_KEYS.dashArray);
|
|
30910
31093
|
}
|
|
30911
31094
|
if (key === "permission" && (value.action === "add" || value.action === "update")) {
|
|
31095
|
+
this.permissions.removePermission(WhiteboardPermissionFlag.all);
|
|
30912
31096
|
this.permissions.addPermission(evt.target.get("permission"), this.userId);
|
|
30913
31097
|
}
|
|
30914
31098
|
}
|
|
30915
31099
|
});
|
|
30916
|
-
|
|
31100
|
+
_defineProperty41(this, "adjustByOutFrame", (frameWidth, frameHeight) => {
|
|
30917
31101
|
if (this.option.width > 0 && this.option.height > 0) {
|
|
30918
31102
|
const minWidth = Math.max(frameWidth, 10);
|
|
30919
31103
|
const minHeight = Math.max(frameHeight, 10);
|
|
@@ -30931,6 +31115,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
30931
31115
|
});
|
|
30932
31116
|
requestAnimationFrameHook(this.paperScope);
|
|
30933
31117
|
requestAnimationFrameHook(this.shadowScope);
|
|
31118
|
+
const that = this;
|
|
30934
31119
|
this.rootElement.setAttribute("data-forge-app", "whiteboard");
|
|
30935
31120
|
document.body.addEventListener("pointerdown", (evt) => {
|
|
30936
31121
|
this.isPenEvent = evt.pointerType === "pen";
|
|
@@ -31102,7 +31287,6 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31102
31287
|
errorMessage
|
|
31103
31288
|
});
|
|
31104
31289
|
});
|
|
31105
|
-
const that = this;
|
|
31106
31290
|
Object.defineProperty(this.emitter, "tool", {
|
|
31107
31291
|
get() {
|
|
31108
31292
|
return that.toolbarModel.currentTool;
|
|
@@ -31251,6 +31435,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31251
31435
|
return this.userMap(userId);
|
|
31252
31436
|
}, this.hasPermission);
|
|
31253
31437
|
this.tools = {
|
|
31438
|
+
pointer: new PointerTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
|
|
31254
31439
|
curve: new CurveTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
|
|
31255
31440
|
rectangle: new RectangleTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
|
|
31256
31441
|
selector: new SelectorTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope, this.selectElementsModel),
|
|
@@ -31266,6 +31451,11 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31266
31451
|
this.toolbarModel.on("update", (style) => {
|
|
31267
31452
|
if (this.tools[style.tool]) {
|
|
31268
31453
|
this.paperScope.tool = this.tools[style.tool].tool;
|
|
31454
|
+
if (style.tool === "pointer") {
|
|
31455
|
+
this.rootElement.style.pointerEvents = "none";
|
|
31456
|
+
} else {
|
|
31457
|
+
this.rootElement.style.pointerEvents = "auto";
|
|
31458
|
+
}
|
|
31269
31459
|
} else {
|
|
31270
31460
|
this.emitter.emit("error", 300001, `${style.tool} not supported`);
|
|
31271
31461
|
}
|
|
@@ -31444,7 +31634,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31444
31634
|
if (renderableModel.elementModels.has(key)) {
|
|
31445
31635
|
elementModel = renderableModel.elementModels.get(key) ?? null;
|
|
31446
31636
|
} else {
|
|
31447
|
-
|
|
31637
|
+
const elementMap = renderableModel.elements.get(key);
|
|
31448
31638
|
if (elementMap) {
|
|
31449
31639
|
elementModel = renderableModel.convertToModel(elementMap);
|
|
31450
31640
|
}
|
|
@@ -31513,6 +31703,7 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31513
31703
|
this.toolbarModel.fontFamily = this.linkTarget.get(TOOLBAR_KEYS.fontFamily);
|
|
31514
31704
|
this.toolbarModel.strokeWidth = this.linkTarget.get(TOOLBAR_KEYS.strokeWidth);
|
|
31515
31705
|
this.toolbarModel.dashArray = this.linkTarget.get(TOOLBAR_KEYS.dashArray);
|
|
31706
|
+
this.permissions.removePermission(WhiteboardPermissionFlag.all);
|
|
31516
31707
|
this.permissions.addPermission(this.linkTarget.get("permission"), this.userId);
|
|
31517
31708
|
this.linkTarget.observe(this.handleLinkedMapChange);
|
|
31518
31709
|
}
|
|
@@ -31530,6 +31721,9 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31530
31721
|
const size = this.paperScope.view.viewSize;
|
|
31531
31722
|
return [size.width, size.height];
|
|
31532
31723
|
}
|
|
31724
|
+
getInherentScale() {
|
|
31725
|
+
return this.camera.getInherentScale();
|
|
31726
|
+
}
|
|
31533
31727
|
updateInternalResizeObserverStatus(value) {
|
|
31534
31728
|
this.internalResizeObserver = value;
|
|
31535
31729
|
}
|
|
@@ -31549,9 +31743,27 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
|
|
|
31549
31743
|
this.shadowScope.project.clear();
|
|
31550
31744
|
this.snapshotScope.project.clear();
|
|
31551
31745
|
this.resizeObserver.disconnect();
|
|
31746
|
+
this.unlink();
|
|
31747
|
+
for (const entry of this.undoManagers.entries()) {
|
|
31748
|
+
entry[1].off("stack-item-added", this.handleStackItemAdded);
|
|
31749
|
+
entry[1].off("stack-item-popped", this.handleStackItemPopped);
|
|
31750
|
+
}
|
|
31751
|
+
for (const entry of this.layers.entries()) {
|
|
31752
|
+
entry[1].dispose();
|
|
31753
|
+
entry[1].removeAllListeners();
|
|
31754
|
+
}
|
|
31755
|
+
this.camera.dispose();
|
|
31756
|
+
this.pageModel.dispose();
|
|
31757
|
+
this.pageModel.removeAllListeners();
|
|
31758
|
+
for (const entry of this.editors.entries()) {
|
|
31759
|
+
entry[1].dispose();
|
|
31760
|
+
}
|
|
31761
|
+
this.toolbarModel.dispose();
|
|
31762
|
+
this.emitter.indexedNavigation.dispose();
|
|
31763
|
+
this.permissions.dispose();
|
|
31552
31764
|
}
|
|
31553
31765
|
};
|
|
31554
|
-
|
|
31766
|
+
_defineProperty41(WhiteboardApplication, "applicationName", WHITEBOARD_APP_NAME);
|
|
31555
31767
|
/*! Bundled license information:
|
|
31556
31768
|
|
|
31557
31769
|
paper/dist/paper-full.js:
|