@netless/forge-whiteboard 1.0.6 → 1.0.8

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.
@@ -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", {}, "warning");
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`, {}, "warning");
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`, {}, "warning");
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.", {}, "warning");
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.", {}, "warning");
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.", {}, "warning");
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
- }, "warning");
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", {}, "warning");
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", {}, "warning");
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.permissions = new WhiteboardPermissions(this.userManager, (userId) => {
32306
- return this.userMap(userId);
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
- this.camera.on("userPageChange", (userId, pageId) => {
32350
- this.emitter.emit("activePageChange", userId, pageId);
32351
- });
32352
- this.camera.on("userViewModeChange", (userId, mode, oldMode) => {
32353
- if (oldMode !== "main" && mode === "main") {
32354
- this.emitter.setViewModeToMain(userId);
32355
- }
32356
- this.emitter.emit("userViewModeChange", userId, mode);
32357
- });
32358
- this.rootElement.style.position = "relative";
32359
- this.rootElement.appendChild(this.canvasElement);
32360
- this.toolbarModel = new ToolbarModel(this.userMap(this.userId), Object.assign({
32361
- tool: "grab",
32362
- strokeColor: "#009688",
32363
- fillColor: null,
32364
- fontSize: 24,
32365
- fontFamily: "Courier New",
32366
- strokeWidth: 4,
32367
- dashArray: []
32368
- }, option.defaultToolbarStyle ?? {}));
32369
- this.trashedElementsModel = new TrashedElementsModel(this.userManager, (userId) => {
32370
- return this.userMap(userId);
32371
- }, this.hasPermission);
32372
- this.selectElementsModel = new SelectElementsModel(this.userManager, (userId) => {
32373
- return this.userMap(userId);
32374
- }, this.hasPermission);
32375
- this.liveCursor = new LiveCursor(this.canvasElement, this.paperScope, this.userManager, (userId) => {
32376
- return this.userMap(userId);
32377
- });
32378
- this.tools = {
32379
- pointer: new PointerTool(this.enableToolEvent, this.getCurrentRendererModel, this.shadowEmitter, this.paperScope),
32380
- curve: new CurveTool(this.enableToolEvent, this.getCurrentRendererModel, this.shadowEmitter, this.paperScope),
32381
- rectangle: new RectangleTool(this.enableToolEvent, this.getCurrentRendererModel, this.shadowEmitter, this.paperScope),
32382
- selector: new SelectorTool(this.enableToolEvent, this.getCurrentRendererModel, this.shadowEmitter, this.paperScope, this.selectElementsModel),
32383
- arrow: new LineTool(this.enableToolEvent, this.getCurrentRendererModel, this.shadowEmitter, this.paperScope),
32384
- line: new StraightLineTool(this.enableToolEvent, this.getCurrentRendererModel, this.shadowEmitter, this.paperScope),
32385
- text: new TextTool(this.enableToolEvent, this.getCurrentRendererModel, this.shadowEmitter, this.paperScope, this.rootElement, this.canvasElement, this.toolbarModel, this.camera),
32386
- ellipse: new EllipseTool(this.enableToolEvent, this.getCurrentRendererModel, this.shadowEmitter, this.paperScope),
32387
- triangle: new TriangleTool(this.enableToolEvent, this.getCurrentRendererModel, this.shadowEmitter, this.paperScope),
32388
- eraser: new EraserTool(this.enableToolEvent, this.getCurrentRendererModel, this.shadowEmitter, this.paperScope, this.trashedElementsModel, this.shadowScope),
32389
- laser: new LaserPointerTool(this.enableToolEvent, this.getCurrentRendererModel, this.shadowEmitter, this.paperScope),
32390
- grab: new GrabTool(this.enableToolEvent, this.getCurrentRendererModel, this.shadowEmitter, this.paperScope, this.camera)
32391
- };
32392
- this.toolbarModel.on("update", (style) => {
32393
- if (this.tools[style.tool]) {
32394
- this.paperScope.tool = this.tools[style.tool].tool;
32395
- if (style.tool === "pointer") {
32396
- this.rootElement.style.pointerEvents = "none";
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.rootElement.style.pointerEvents = "auto";
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.emitter.emit("error", 300001, `${style.tool} not supported`);
32402
- }
32403
- this.emitter.emit("toolbarStyleChange", style);
32404
- });
32405
- if (this.tools[this.toolbarModel.currentTool]) {
32406
- this.paperScope.tool = this.tools[this.toolbarModel.currentTool].tool;
32407
- } else {
32408
- this.paperScope.tool = this.tools["curve"].tool;
32409
- (0, import_forge_room12.log)(`${this.toolbarModel.currentTool} not supported, backup to curve`);
32410
- }
32411
- this.selectElementsModel.on("elementsChange", this.handleElementsSelect);
32412
- this.trashedElementsModel.on("elementsChange", this.handleElementsTrash);
32413
- this.trashedElementsModel.on("removeElementForSelf", this.handleRemoveTrashedElementForSelf);
32414
- this.canvasElement.style.background = "#FFEB3B";
32415
- this.canvasElement.style.position = "absolute";
32416
- this.canvasElement.style.top = "50%";
32417
- this.canvasElement.style.left = "50%";
32418
- this.canvasElement.style.transform = "translate(-50%, -50%)";
32419
- this.canvasElement.setAttribute("id", `${this.appId}-main`);
32420
- this.paperScope.setup(this.canvasElement);
32421
- this.paperScope.settings.insertItems = false;
32422
- this.shadowCanvasElement.style.position = "absolute";
32423
- this.shadowCanvasElement.style.top = "50%";
32424
- this.shadowCanvasElement.style.left = "50%";
32425
- this.shadowCanvasElement.style.transform = "translate(-50%, -50%)";
32426
- this.shadowCanvasElement.style.pointerEvents = "none";
32427
- this.shadowCanvasElement.setAttribute("id", `${this.appId}-shadow`);
32428
- this.rootElement.appendChild(this.shadowCanvasElement);
32429
- this.shadowScope.setup(this.shadowCanvasElement);
32430
- this.shadowScope.settings.insertItems = false;
32431
- this.snapshotCanvasElement.setAttribute("id", `${this.appId}-snapshot`);
32432
- this.snapshotScope.setup(this.snapshotCanvasElement);
32433
- this.resizeObserver = new ResizeObserver(() => {
32434
- if (this.internalResizeObserver) {
32435
- const rootBounds = this.rootElement.getBoundingClientRect();
32436
- this.adjustByOutFrame(rootBounds.width, rootBounds.height);
32437
- }
32438
- });
32439
- this.resizeObserver.observe(this.rootElement);
32440
- if (!this.getMap("attrs").has(WhiteboardKeys.currentPage)) {
32441
- this.getMap("attrs").set(WhiteboardKeys.currentPage, "_i_");
32442
- }
32443
- this.emitter.indexedNavigation = new IndexedNavigation(this.pageModel, this.userMap(this.userId), this.getMap("indexedNavigation"), this.hasPermission);
32444
- this.emitter.indexedNavigation.initIndexed().then((inited) => {
32445
- if (!inited) {
32446
- this.handleLayersChange(this.pageModel.pageList());
32447
- const currentPage = this.pageModel.getCurrentPage(this.userId);
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
- } else {
32456
- this.userMap(this.userId).set(WhiteboardKeys.currentPage, "_i_");
32457
- }
32458
- });
32459
- this.shadowEmitter.on("translateOut", (ids, container) => {
32460
- if (this.delayTranslateOut > 0) {
32461
- setTimeout(() => {
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
- }, this.delayTranslateOut);
32464
- } else {
32465
- this.handleElementTranslateOut(ids, container);
32466
- }
32467
- });
32468
- this.shadowEmitter.on("translateIn", (ids, container) => {
32469
- let parent = null;
32470
- if (container === "layer") {
32471
- parent = this.shadowScope.project.activeLayer;
32472
- } else {
32473
- parent = this.shadowScope.project.activeLayer.children.find((child) => child.data.uuid === container) ?? null;
32474
- }
32475
- if (parent) {
32476
- ids.forEach((id) => {
32477
- const target = this.paperScope.project.activeLayer.children.find((child) => child.data.uuid === id);
32478
- if (target) {
32479
- target.remove();
32480
- this.insertElementToParent(target, parent);
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
- this.shadowEmitter.on("grabDown", () => {
32486
- this.emitter.emit("grabDown");
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();