@netless/forge-whiteboard 1.0.6 → 1.0.7
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/dist/WhiteboardApplication.d.ts.map +1 -1
- package/dist/whiteboard.esm.js +197 -195
- package/dist/whiteboard.esm.js.map +2 -2
- package/dist/whiteboard.js +197 -195
- package/dist/whiteboard.js.map +2 -2
- package/package.json +2 -2
package/dist/whiteboard.js
CHANGED
|
@@ -27881,7 +27881,7 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
27881
27881
|
confirmPermission() {
|
|
27882
27882
|
const hasPermission = this.hasPermission(WhiteboardPermissionFlag.draw);
|
|
27883
27883
|
if (!hasPermission) {
|
|
27884
|
-
(0, import_forge_room4.log)("[@netless/forge-whiteboard] no permission to draw", {}, "
|
|
27884
|
+
(0, import_forge_room4.log)("[@netless/forge-whiteboard] no permission to draw", {}, "warn");
|
|
27885
27885
|
}
|
|
27886
27886
|
return hasPermission;
|
|
27887
27887
|
}
|
|
@@ -31768,7 +31768,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
31768
31768
|
}
|
|
31769
31769
|
} else {
|
|
31770
31770
|
console.warn(`[@netless/forge-whiteboard] page ${pageId} not found`);
|
|
31771
|
-
(0, import_forge_room12.log)(`[@netless/forge-whiteboard] page ${pageId} not found`, {}, "
|
|
31771
|
+
(0, import_forge_room12.log)(`[@netless/forge-whiteboard] page ${pageId} not found`, {}, "warn");
|
|
31772
31772
|
}
|
|
31773
31773
|
await waitUntil(() => this.undoManagers.has(pageId), 1e3);
|
|
31774
31774
|
if (this.undoManagers.has(pageId)) {
|
|
@@ -31780,7 +31780,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
31780
31780
|
this.undoManagers.get(pageId).on("stack-item-popped", this.handleStackItemPopped);
|
|
31781
31781
|
} else {
|
|
31782
31782
|
console.warn(`[@netless/forge-whiteboard] undo manager for page ${pageId} not found`);
|
|
31783
|
-
(0, import_forge_room12.log)(`[@netless/forge-whiteboard] undo manager for page ${pageId} not found`, {}, "
|
|
31783
|
+
(0, import_forge_room12.log)(`[@netless/forge-whiteboard] undo manager for page ${pageId} not found`, {}, "warn");
|
|
31784
31784
|
}
|
|
31785
31785
|
this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
|
|
31786
31786
|
this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
|
|
@@ -32047,7 +32047,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32047
32047
|
this.emitter.setViewModeToFree = (userId) => {
|
|
32048
32048
|
if (that.disableViewModelUpdate) {
|
|
32049
32049
|
console.warn("Operation failed. Perspective mode switching is disabled in the current environment.");
|
|
32050
|
-
(0, import_forge_room12.log)("Operation failed. Perspective mode switching is disabled in the current environment.", {}, "
|
|
32050
|
+
(0, import_forge_room12.log)("Operation failed. Perspective mode switching is disabled in the current environment.", {}, "warn");
|
|
32051
32051
|
return;
|
|
32052
32052
|
}
|
|
32053
32053
|
const targetId = userId ? this.hasPermission(WhiteboardPermissionFlag.setOthersView) ? userId : null : this.userId;
|
|
@@ -32058,7 +32058,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32058
32058
|
this.emitter.setViewModeToFlow = (flowId, userId) => {
|
|
32059
32059
|
if (that.disableViewModelUpdate) {
|
|
32060
32060
|
console.warn("Operation failed. Perspective mode switching is disabled in the current environment.");
|
|
32061
|
-
(0, import_forge_room12.log)("Operation failed. Perspective mode switching is disabled in the current environment.", {}, "
|
|
32061
|
+
(0, import_forge_room12.log)("Operation failed. Perspective mode switching is disabled in the current environment.", {}, "warn");
|
|
32062
32062
|
return;
|
|
32063
32063
|
}
|
|
32064
32064
|
const targetId = userId ? this.hasPermission(WhiteboardPermissionFlag.setOthersView) ? userId : null : this.userId;
|
|
@@ -32073,7 +32073,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32073
32073
|
this.emitter.setViewModeToMain = (userId) => {
|
|
32074
32074
|
if (that.disableViewModelUpdate) {
|
|
32075
32075
|
console.warn("Operation failed. Perspective mode switching is disabled in the current environment.");
|
|
32076
|
-
(0, import_forge_room12.log)("Operation failed. Perspective mode switching is disabled in the current environment.", {}, "
|
|
32076
|
+
(0, import_forge_room12.log)("Operation failed. Perspective mode switching is disabled in the current environment.", {}, "warn");
|
|
32077
32077
|
return;
|
|
32078
32078
|
}
|
|
32079
32079
|
const targetId = userId ? this.hasPermission(WhiteboardPermissionFlag.setOthersView) ? userId : null : this.userId;
|
|
@@ -32089,7 +32089,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32089
32089
|
if (!/https/.test(src)) {
|
|
32090
32090
|
(0, import_forge_room12.log)("[@netless/forge-whiteboard] invalid image url, src needs to be in the HTTPS protocol.", {
|
|
32091
32091
|
src
|
|
32092
|
-
}, "
|
|
32092
|
+
}, "warn");
|
|
32093
32093
|
return;
|
|
32094
32094
|
}
|
|
32095
32095
|
let targetPageId = pageId;
|
|
@@ -32097,14 +32097,14 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32097
32097
|
targetPageId = this.pageModel.getCurrentPage(this.userManager.selfId);
|
|
32098
32098
|
}
|
|
32099
32099
|
if (!targetPageId) {
|
|
32100
|
-
(0, import_forge_room12.log)("[@netless/forge-whiteboard] page not found", {}, "
|
|
32100
|
+
(0, import_forge_room12.log)("[@netless/forge-whiteboard] page not found", {}, "warn");
|
|
32101
32101
|
return;
|
|
32102
32102
|
}
|
|
32103
32103
|
this.layers.get(targetPageId)?.createImage(src);
|
|
32104
32104
|
};
|
|
32105
32105
|
this.emitter.removeElement = (pageId, elementId) => {
|
|
32106
32106
|
if (!this.layers.has(pageId)) {
|
|
32107
|
-
(0, import_forge_room12.log)("[@netless/forge-whiteboard] page not found", {}, "
|
|
32107
|
+
(0, import_forge_room12.log)("[@netless/forge-whiteboard] page not found", {}, "warn");
|
|
32108
32108
|
return;
|
|
32109
32109
|
}
|
|
32110
32110
|
this.layers.get(pageId)?.removeElementItem(elementId);
|
|
@@ -32302,202 +32302,204 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32302
32302
|
async initialize(option) {
|
|
32303
32303
|
_WhiteboardApplication.instanceCount.set(this.appId, (_WhiteboardApplication.instanceCount.get(this.appId) ?? 0) + 1);
|
|
32304
32304
|
(0, import_forge_room12.log)(`whiteboard ${this.appId} initialize. instance count: ${_WhiteboardApplication.instanceCount.get(this.appId) ?? 0}`, {}, "info");
|
|
32305
|
-
this.
|
|
32306
|
-
|
|
32307
|
-
|
|
32308
|
-
this.permissions.setPermission(WhiteboardPermissionFlag.all);
|
|
32309
|
-
this.emitter["permissions"] = this.permissions;
|
|
32310
|
-
this.emitter["selfUserId"] = this.userId;
|
|
32311
|
-
this.option = option;
|
|
32312
|
-
if (this.option.stretchToFill) {
|
|
32313
|
-
this.getMap("attrs").set("viewportWidth", -1);
|
|
32314
|
-
this.getMap("attrs").set("viewportHeight", -1);
|
|
32315
|
-
} else {
|
|
32316
|
-
if (!this.getMap("attrs").has("viewportWidth")) {
|
|
32317
|
-
this.getMap("attrs").set("viewportWidth", option.width);
|
|
32318
|
-
}
|
|
32319
|
-
if (!this.getMap("attrs").has("viewportHeight")) {
|
|
32320
|
-
this.getMap("attrs").set("viewportHeight", option.height);
|
|
32321
|
-
}
|
|
32322
|
-
}
|
|
32323
|
-
this.userMap(this.userId).set(WhiteboardKeys.themeColor, "#009688");
|
|
32324
|
-
this.userMap(this.userId).observe(this.handleSyncedWhiteboardStatusChange);
|
|
32325
|
-
this.shadowEmitter = new ShadowEmitter(this.userMap(this.userId));
|
|
32326
|
-
this.pageModel = new PageModel(this.getMap("attrs"), this.userManager, (userId) => {
|
|
32327
|
-
return this.userMap(userId);
|
|
32328
|
-
}, this.getMap("pages"), this.hasPermission);
|
|
32329
|
-
this.pageModel.on("pagesChange", this.handleLayersChange);
|
|
32330
|
-
this.pageModel.on("switchPage", this.handlePageSwitch);
|
|
32331
|
-
if (option.maxScaleRatio && option.maxScaleRatio < 1 && option.maxScaleRatio !== -1) {
|
|
32332
|
-
throw new Error(`[@netless/forge-whiteboard] invalid maxScaleRatio ${option.maxScaleRatio}`);
|
|
32333
|
-
}
|
|
32334
|
-
this.camera = new Camera(new this.paperScope.Size(option.width, option.height), option.maxScaleRatio ?? -1, this.rootElement, this.userManager, this.paperScope, this.getMap("attrs"), this.hasPermission, (userId) => {
|
|
32335
|
-
return this.userMap(userId);
|
|
32336
|
-
}, () => {
|
|
32337
|
-
return [this.paperScope.project.view.size.width, this.paperScope.project.view.size.height];
|
|
32338
|
-
}, () => {
|
|
32339
|
-
const rect = this.canvasElement.getBoundingClientRect();
|
|
32340
|
-
return [rect.width, rect.height];
|
|
32341
|
-
});
|
|
32342
|
-
this.camera.on("zoom", (matrix) => {
|
|
32343
|
-
this.paperScope.project.view.matrix = matrix;
|
|
32344
|
-
this.shadowScope.project.view.matrix = matrix;
|
|
32345
|
-
this.editors.forEach((editor) => {
|
|
32346
|
-
editor.updateBounds();
|
|
32305
|
+
this.appDoc.transact(() => {
|
|
32306
|
+
this.permissions = new WhiteboardPermissions(this.userManager, (userId) => {
|
|
32307
|
+
return this.userMap(userId);
|
|
32347
32308
|
});
|
|
32348
|
-
|
|
32349
|
-
|
|
32350
|
-
this.emitter
|
|
32351
|
-
|
|
32352
|
-
|
|
32353
|
-
|
|
32354
|
-
this.
|
|
32355
|
-
}
|
|
32356
|
-
|
|
32357
|
-
|
|
32358
|
-
|
|
32359
|
-
|
|
32360
|
-
|
|
32361
|
-
|
|
32362
|
-
|
|
32363
|
-
|
|
32364
|
-
|
|
32365
|
-
|
|
32366
|
-
|
|
32367
|
-
|
|
32368
|
-
|
|
32369
|
-
|
|
32370
|
-
|
|
32371
|
-
|
|
32372
|
-
|
|
32373
|
-
|
|
32374
|
-
|
|
32375
|
-
|
|
32376
|
-
|
|
32377
|
-
|
|
32378
|
-
|
|
32379
|
-
|
|
32380
|
-
|
|
32381
|
-
|
|
32382
|
-
|
|
32383
|
-
|
|
32384
|
-
|
|
32385
|
-
|
|
32386
|
-
|
|
32387
|
-
|
|
32388
|
-
|
|
32389
|
-
|
|
32390
|
-
|
|
32391
|
-
|
|
32392
|
-
|
|
32393
|
-
|
|
32394
|
-
|
|
32395
|
-
|
|
32396
|
-
|
|
32309
|
+
this.permissions.setPermission(WhiteboardPermissionFlag.all);
|
|
32310
|
+
this.emitter["permissions"] = this.permissions;
|
|
32311
|
+
this.emitter["selfUserId"] = this.userId;
|
|
32312
|
+
this.option = option;
|
|
32313
|
+
if (this.option.stretchToFill) {
|
|
32314
|
+
this.getMap("attrs").set("viewportWidth", -1);
|
|
32315
|
+
this.getMap("attrs").set("viewportHeight", -1);
|
|
32316
|
+
} else {
|
|
32317
|
+
if (!this.getMap("attrs").has("viewportWidth")) {
|
|
32318
|
+
this.getMap("attrs").set("viewportWidth", option.width);
|
|
32319
|
+
}
|
|
32320
|
+
if (!this.getMap("attrs").has("viewportHeight")) {
|
|
32321
|
+
this.getMap("attrs").set("viewportHeight", option.height);
|
|
32322
|
+
}
|
|
32323
|
+
}
|
|
32324
|
+
this.userMap(this.userId).set(WhiteboardKeys.themeColor, "#009688");
|
|
32325
|
+
this.userMap(this.userId).observe(this.handleSyncedWhiteboardStatusChange);
|
|
32326
|
+
this.shadowEmitter = new ShadowEmitter(this.userMap(this.userId));
|
|
32327
|
+
this.pageModel = new PageModel(this.getMap("attrs"), this.userManager, (userId) => {
|
|
32328
|
+
return this.userMap(userId);
|
|
32329
|
+
}, this.getMap("pages"), this.hasPermission);
|
|
32330
|
+
this.pageModel.on("pagesChange", this.handleLayersChange);
|
|
32331
|
+
this.pageModel.on("switchPage", this.handlePageSwitch);
|
|
32332
|
+
if (option.maxScaleRatio && option.maxScaleRatio < 1 && option.maxScaleRatio !== -1) {
|
|
32333
|
+
throw new Error(`[@netless/forge-whiteboard] invalid maxScaleRatio ${option.maxScaleRatio}`);
|
|
32334
|
+
}
|
|
32335
|
+
this.camera = new Camera(new this.paperScope.Size(option.width, option.height), option.maxScaleRatio ?? -1, this.rootElement, this.userManager, this.paperScope, this.getMap("attrs"), this.hasPermission, (userId) => {
|
|
32336
|
+
return this.userMap(userId);
|
|
32337
|
+
}, () => {
|
|
32338
|
+
return [this.paperScope.project.view.size.width, this.paperScope.project.view.size.height];
|
|
32339
|
+
}, () => {
|
|
32340
|
+
const rect = this.canvasElement.getBoundingClientRect();
|
|
32341
|
+
return [rect.width, rect.height];
|
|
32342
|
+
});
|
|
32343
|
+
this.camera.on("zoom", (matrix) => {
|
|
32344
|
+
this.paperScope.project.view.matrix = matrix;
|
|
32345
|
+
this.shadowScope.project.view.matrix = matrix;
|
|
32346
|
+
this.editors.forEach((editor) => {
|
|
32347
|
+
editor.updateBounds();
|
|
32348
|
+
});
|
|
32349
|
+
});
|
|
32350
|
+
this.camera.on("userPageChange", (userId, pageId) => {
|
|
32351
|
+
this.emitter.emit("activePageChange", userId, pageId);
|
|
32352
|
+
});
|
|
32353
|
+
this.camera.on("userViewModeChange", (userId, mode, oldMode) => {
|
|
32354
|
+
if (oldMode !== "main" && mode === "main") {
|
|
32355
|
+
this.emitter.setViewModeToMain(userId);
|
|
32356
|
+
}
|
|
32357
|
+
this.emitter.emit("userViewModeChange", userId, mode);
|
|
32358
|
+
});
|
|
32359
|
+
this.rootElement.style.position = "relative";
|
|
32360
|
+
this.rootElement.appendChild(this.canvasElement);
|
|
32361
|
+
this.toolbarModel = new ToolbarModel(this.userMap(this.userId), Object.assign({
|
|
32362
|
+
tool: "grab",
|
|
32363
|
+
strokeColor: "#009688",
|
|
32364
|
+
fillColor: null,
|
|
32365
|
+
fontSize: 24,
|
|
32366
|
+
fontFamily: "Courier New",
|
|
32367
|
+
strokeWidth: 4,
|
|
32368
|
+
dashArray: []
|
|
32369
|
+
}, option.defaultToolbarStyle ?? {}));
|
|
32370
|
+
this.trashedElementsModel = new TrashedElementsModel(this.userManager, (userId) => {
|
|
32371
|
+
return this.userMap(userId);
|
|
32372
|
+
}, this.hasPermission);
|
|
32373
|
+
this.selectElementsModel = new SelectElementsModel(this.userManager, (userId) => {
|
|
32374
|
+
return this.userMap(userId);
|
|
32375
|
+
}, this.hasPermission);
|
|
32376
|
+
this.liveCursor = new LiveCursor(this.canvasElement, this.paperScope, this.userManager, (userId) => {
|
|
32377
|
+
return this.userMap(userId);
|
|
32378
|
+
});
|
|
32379
|
+
this.tools = {
|
|
32380
|
+
pointer: new PointerTool(this.enableToolEvent, this.getCurrentRendererModel, this.shadowEmitter, this.paperScope),
|
|
32381
|
+
curve: new CurveTool(this.enableToolEvent, this.getCurrentRendererModel, this.shadowEmitter, this.paperScope),
|
|
32382
|
+
rectangle: new RectangleTool(this.enableToolEvent, this.getCurrentRendererModel, this.shadowEmitter, this.paperScope),
|
|
32383
|
+
selector: new SelectorTool(this.enableToolEvent, this.getCurrentRendererModel, this.shadowEmitter, this.paperScope, this.selectElementsModel),
|
|
32384
|
+
arrow: new LineTool(this.enableToolEvent, this.getCurrentRendererModel, this.shadowEmitter, this.paperScope),
|
|
32385
|
+
line: new StraightLineTool(this.enableToolEvent, this.getCurrentRendererModel, this.shadowEmitter, this.paperScope),
|
|
32386
|
+
text: new TextTool(this.enableToolEvent, this.getCurrentRendererModel, this.shadowEmitter, this.paperScope, this.rootElement, this.canvasElement, this.toolbarModel, this.camera),
|
|
32387
|
+
ellipse: new EllipseTool(this.enableToolEvent, this.getCurrentRendererModel, this.shadowEmitter, this.paperScope),
|
|
32388
|
+
triangle: new TriangleTool(this.enableToolEvent, this.getCurrentRendererModel, this.shadowEmitter, this.paperScope),
|
|
32389
|
+
eraser: new EraserTool(this.enableToolEvent, this.getCurrentRendererModel, this.shadowEmitter, this.paperScope, this.trashedElementsModel, this.shadowScope),
|
|
32390
|
+
laser: new LaserPointerTool(this.enableToolEvent, this.getCurrentRendererModel, this.shadowEmitter, this.paperScope),
|
|
32391
|
+
grab: new GrabTool(this.enableToolEvent, this.getCurrentRendererModel, this.shadowEmitter, this.paperScope, this.camera)
|
|
32392
|
+
};
|
|
32393
|
+
this.toolbarModel.on("update", (style) => {
|
|
32394
|
+
if (this.tools[style.tool]) {
|
|
32395
|
+
this.paperScope.tool = this.tools[style.tool].tool;
|
|
32396
|
+
if (style.tool === "pointer") {
|
|
32397
|
+
this.rootElement.style.pointerEvents = "none";
|
|
32398
|
+
} else {
|
|
32399
|
+
this.rootElement.style.pointerEvents = "auto";
|
|
32400
|
+
}
|
|
32397
32401
|
} else {
|
|
32398
|
-
this.
|
|
32402
|
+
this.emitter.emit("error", 300001, `${style.tool} not supported`);
|
|
32399
32403
|
}
|
|
32404
|
+
this.emitter.emit("toolbarStyleChange", style);
|
|
32405
|
+
});
|
|
32406
|
+
if (this.tools[this.toolbarModel.currentTool]) {
|
|
32407
|
+
this.paperScope.tool = this.tools[this.toolbarModel.currentTool].tool;
|
|
32400
32408
|
} else {
|
|
32401
|
-
this.
|
|
32402
|
-
|
|
32403
|
-
|
|
32404
|
-
|
|
32405
|
-
|
|
32406
|
-
this.
|
|
32407
|
-
|
|
32408
|
-
this.
|
|
32409
|
-
|
|
32410
|
-
|
|
32411
|
-
|
|
32412
|
-
|
|
32413
|
-
|
|
32414
|
-
|
|
32415
|
-
|
|
32416
|
-
|
|
32417
|
-
|
|
32418
|
-
|
|
32419
|
-
|
|
32420
|
-
|
|
32421
|
-
|
|
32422
|
-
|
|
32423
|
-
|
|
32424
|
-
|
|
32425
|
-
|
|
32426
|
-
|
|
32427
|
-
|
|
32428
|
-
|
|
32429
|
-
|
|
32430
|
-
|
|
32431
|
-
|
|
32432
|
-
|
|
32433
|
-
|
|
32434
|
-
|
|
32435
|
-
|
|
32436
|
-
|
|
32437
|
-
|
|
32438
|
-
|
|
32439
|
-
|
|
32440
|
-
|
|
32441
|
-
|
|
32442
|
-
|
|
32443
|
-
|
|
32444
|
-
|
|
32445
|
-
|
|
32446
|
-
|
|
32447
|
-
|
|
32448
|
-
if (currentPage) {
|
|
32449
|
-
this.userMap(this.userId).set(WhiteboardKeys.currentPage, currentPage);
|
|
32450
|
-
this.handlePageSwitch(currentPage);
|
|
32409
|
+
this.paperScope.tool = this.tools["curve"].tool;
|
|
32410
|
+
(0, import_forge_room12.log)(`${this.toolbarModel.currentTool} not supported, backup to curve`);
|
|
32411
|
+
}
|
|
32412
|
+
this.selectElementsModel.on("elementsChange", this.handleElementsSelect);
|
|
32413
|
+
this.trashedElementsModel.on("elementsChange", this.handleElementsTrash);
|
|
32414
|
+
this.trashedElementsModel.on("removeElementForSelf", this.handleRemoveTrashedElementForSelf);
|
|
32415
|
+
this.canvasElement.style.background = "#FFEB3B";
|
|
32416
|
+
this.canvasElement.style.position = "absolute";
|
|
32417
|
+
this.canvasElement.style.top = "50%";
|
|
32418
|
+
this.canvasElement.style.left = "50%";
|
|
32419
|
+
this.canvasElement.style.transform = "translate(-50%, -50%)";
|
|
32420
|
+
this.canvasElement.setAttribute("id", `${this.appId}-main`);
|
|
32421
|
+
this.paperScope.setup(this.canvasElement);
|
|
32422
|
+
this.paperScope.settings.insertItems = false;
|
|
32423
|
+
this.shadowCanvasElement.style.position = "absolute";
|
|
32424
|
+
this.shadowCanvasElement.style.top = "50%";
|
|
32425
|
+
this.shadowCanvasElement.style.left = "50%";
|
|
32426
|
+
this.shadowCanvasElement.style.transform = "translate(-50%, -50%)";
|
|
32427
|
+
this.shadowCanvasElement.style.pointerEvents = "none";
|
|
32428
|
+
this.shadowCanvasElement.setAttribute("id", `${this.appId}-shadow`);
|
|
32429
|
+
this.rootElement.appendChild(this.shadowCanvasElement);
|
|
32430
|
+
this.shadowScope.setup(this.shadowCanvasElement);
|
|
32431
|
+
this.shadowScope.settings.insertItems = false;
|
|
32432
|
+
this.snapshotCanvasElement.setAttribute("id", `${this.appId}-snapshot`);
|
|
32433
|
+
this.snapshotScope.setup(this.snapshotCanvasElement);
|
|
32434
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
32435
|
+
if (this.internalResizeObserver) {
|
|
32436
|
+
const rootBounds = this.rootElement.getBoundingClientRect();
|
|
32437
|
+
this.adjustByOutFrame(rootBounds.width, rootBounds.height);
|
|
32438
|
+
}
|
|
32439
|
+
});
|
|
32440
|
+
this.resizeObserver.observe(this.rootElement);
|
|
32441
|
+
if (!this.getMap("attrs").has(WhiteboardKeys.currentPage)) {
|
|
32442
|
+
this.getMap("attrs").set(WhiteboardKeys.currentPage, "_i_");
|
|
32443
|
+
}
|
|
32444
|
+
this.emitter.indexedNavigation = new IndexedNavigation(this.pageModel, this.userMap(this.userId), this.getMap("indexedNavigation"), this.hasPermission);
|
|
32445
|
+
this.emitter.indexedNavigation.initIndexed().then((inited) => {
|
|
32446
|
+
if (!inited) {
|
|
32447
|
+
this.handleLayersChange(this.pageModel.pageList());
|
|
32448
|
+
const currentPage = this.pageModel.getCurrentPage(this.userId);
|
|
32449
|
+
if (currentPage) {
|
|
32450
|
+
this.userMap(this.userId).set(WhiteboardKeys.currentPage, currentPage);
|
|
32451
|
+
this.handlePageSwitch(currentPage);
|
|
32452
|
+
} else {
|
|
32453
|
+
this.userMap(this.userId).set(WhiteboardKeys.currentPage, "_i_");
|
|
32454
|
+
this.handlePageSwitch("_i_");
|
|
32455
|
+
}
|
|
32451
32456
|
} else {
|
|
32452
32457
|
this.userMap(this.userId).set(WhiteboardKeys.currentPage, "_i_");
|
|
32453
|
-
this.handlePageSwitch("_i_");
|
|
32454
32458
|
}
|
|
32455
|
-
}
|
|
32456
|
-
|
|
32457
|
-
|
|
32458
|
-
|
|
32459
|
-
|
|
32460
|
-
|
|
32461
|
-
|
|
32459
|
+
});
|
|
32460
|
+
this.shadowEmitter.on("translateOut", (ids, container) => {
|
|
32461
|
+
if (this.delayTranslateOut > 0) {
|
|
32462
|
+
setTimeout(() => {
|
|
32463
|
+
this.handleElementTranslateOut(ids, container);
|
|
32464
|
+
}, this.delayTranslateOut);
|
|
32465
|
+
} else {
|
|
32462
32466
|
this.handleElementTranslateOut(ids, container);
|
|
32463
|
-
}
|
|
32464
|
-
}
|
|
32465
|
-
|
|
32466
|
-
|
|
32467
|
-
|
|
32468
|
-
|
|
32469
|
-
|
|
32470
|
-
|
|
32471
|
-
|
|
32472
|
-
|
|
32473
|
-
|
|
32474
|
-
|
|
32475
|
-
|
|
32476
|
-
|
|
32477
|
-
|
|
32478
|
-
|
|
32479
|
-
|
|
32480
|
-
|
|
32481
|
-
|
|
32467
|
+
}
|
|
32468
|
+
});
|
|
32469
|
+
this.shadowEmitter.on("translateIn", (ids, container) => {
|
|
32470
|
+
let parent = null;
|
|
32471
|
+
if (container === "layer") {
|
|
32472
|
+
parent = this.shadowScope.project.activeLayer;
|
|
32473
|
+
} else {
|
|
32474
|
+
parent = this.shadowScope.project.activeLayer.children.find((child) => child.data.uuid === container) ?? null;
|
|
32475
|
+
}
|
|
32476
|
+
if (parent) {
|
|
32477
|
+
ids.forEach((id) => {
|
|
32478
|
+
const target = this.paperScope.project.activeLayer.children.find((child) => child.data.uuid === id);
|
|
32479
|
+
if (target) {
|
|
32480
|
+
target.remove();
|
|
32481
|
+
this.insertElementToParent(target, parent);
|
|
32482
|
+
}
|
|
32483
|
+
});
|
|
32484
|
+
}
|
|
32485
|
+
});
|
|
32486
|
+
this.shadowEmitter.on("grabDown", () => {
|
|
32487
|
+
this.emitter.emit("grabDown");
|
|
32488
|
+
});
|
|
32489
|
+
this.shadowEmitter.on("grabUp", () => {
|
|
32490
|
+
this.emitter.emit("grabUp");
|
|
32491
|
+
});
|
|
32492
|
+
this.clearElements();
|
|
32493
|
+
if (this.option.stretchToFill) {
|
|
32494
|
+
window.addEventListener("resize", () => {
|
|
32495
|
+
const bounds = this.rootElement.getBoundingClientRect();
|
|
32496
|
+
this.updateOptionSize(bounds.width, bounds.height);
|
|
32497
|
+
this.adjustByOutFrame(bounds.width, bounds.height);
|
|
32482
32498
|
});
|
|
32483
32499
|
}
|
|
32484
|
-
|
|
32485
|
-
|
|
32486
|
-
|
|
32487
|
-
});
|
|
32488
|
-
this.shadowEmitter.on("grabUp", () => {
|
|
32489
|
-
this.emitter.emit("grabUp");
|
|
32490
|
-
});
|
|
32491
|
-
this.clearElements();
|
|
32492
|
-
if (this.option.stretchToFill) {
|
|
32493
|
-
window.addEventListener("resize", () => {
|
|
32494
|
-
const bounds = this.rootElement.getBoundingClientRect();
|
|
32495
|
-
this.updateOptionSize(bounds.width, bounds.height);
|
|
32496
|
-
this.adjustByOutFrame(bounds.width, bounds.height);
|
|
32497
|
-
});
|
|
32498
|
-
}
|
|
32499
|
-
this.rootElement.appendChild(this.liveCursor.container);
|
|
32500
|
-
this.getMap("attrs").observe(this.handleViewportUpdate);
|
|
32500
|
+
this.rootElement.appendChild(this.liveCursor.container);
|
|
32501
|
+
this.getMap("attrs").observe(this.handleViewportUpdate);
|
|
32502
|
+
}, "whiteboard-initialize");
|
|
32501
32503
|
}
|
|
32502
32504
|
clearElements() {
|
|
32503
32505
|
const userIds = this.userManager.userIdList();
|