@netless/forge-whiteboard 0.1.12 → 0.1.14

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.
@@ -30710,12 +30710,12 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
30710
30710
  _defineProperty40(this, "resizeObserver", void 0);
30711
30711
  _defineProperty40(this, "option", void 0);
30712
30712
  _defineProperty40(this, "permissions", void 0);
30713
- _defineProperty40(this, "linkTarget", null);
30714
30713
  _defineProperty40(this, "inputType", "any");
30715
30714
  _defineProperty40(this, "isPenEvent", false);
30716
30715
  _defineProperty40(this, "hasPenInput", null);
30717
30716
  _defineProperty40(this, "disableViewModelUpdate", false);
30718
30717
  _defineProperty40(this, "internalResizeObserver", true);
30718
+ _defineProperty40(this, "linkTarget", null);
30719
30719
  _defineProperty40(this, "enableToolEvent", () => {
30720
30720
  return !(this.inputType === "pen" && !this.isPenEvent);
30721
30721
  });
@@ -30897,20 +30897,21 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
30897
30897
  this.emitter.emit("elementDeselected", userId);
30898
30898
  }
30899
30899
  });
30900
- _defineProperty40(this, "onLinkTargetToolbarChange", (style) => {
30901
- this.toolbarModel.currentTool = style.tool;
30902
- this.toolbarModel.strokeColor = style.strokeColor;
30903
- this.toolbarModel.fillColor = style.fillColor;
30904
- this.toolbarModel.fontSize = style.fontSize;
30905
- this.toolbarModel.fontFamily = style.fontFamily;
30906
- this.toolbarModel.strokeWidth = style.strokeWidth;
30907
- this.toolbarModel.dashArray = style.dashArray;
30908
- });
30909
- _defineProperty40(this, "onLinkTargetPermissionChange", (userId, flags) => {
30910
- if (userId == this.userId) {
30911
- flags.forEach((flag) => {
30912
- this.permissions.addPermission(flag, this.userId);
30913
- });
30900
+ _defineProperty40(this, "handleLinkedMapChange", (evt) => {
30901
+ for (const [key, value] of evt.changes.keys.entries()) {
30902
+ if (Object.keys(TOOLBAR_KEYS).indexOf(key) >= 0 && (value.action === "add" || value.action === "update")) {
30903
+ this.toolbarModel.currentTool = evt.target.get(TOOLBAR_KEYS.tool);
30904
+ this.toolbarModel.strokeColor = evt.target.get(TOOLBAR_KEYS.strokeColor);
30905
+ this.toolbarModel.fillColor = evt.target.get(TOOLBAR_KEYS.fillColor);
30906
+ this.toolbarModel.fontSize = evt.target.get(TOOLBAR_KEYS.fontSize);
30907
+ this.toolbarModel.fontFamily = evt.target.get(TOOLBAR_KEYS.fontFamily);
30908
+ this.toolbarModel.strokeWidth = evt.target.get(TOOLBAR_KEYS.strokeWidth);
30909
+ this.toolbarModel.dashArray = evt.target.get(TOOLBAR_KEYS.dashArray);
30910
+ }
30911
+ if (key === "permission" && (value.action === "add" || value.action === "update")) {
30912
+ this.permissions.removePermission(WhiteboardPermissionFlag.all);
30913
+ this.permissions.addPermission(evt.target.get("permission"), this.userId);
30914
+ }
30914
30915
  }
30915
30916
  });
30916
30917
  _defineProperty40(this, "adjustByOutFrame", (frameWidth, frameHeight) => {
@@ -31500,22 +31501,27 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
31500
31501
  this.disableViewModelUpdate = true;
31501
31502
  }
31502
31503
  linkToWhiteboard(targetId) {
31503
- console.log("linkToWhiteboard, linkToWhiteboard, linkToWhiteboard");
31504
31504
  if (this.linkTarget) {
31505
31505
  this.unlink();
31506
31506
  }
31507
- this.linkTarget = this.applicationManager.getInstances(targetId);
31507
+ this.userMap(this.userId);
31508
+ this.linkTarget = this.roomDoc.getMap(`@app/${this.name}/${targetId}/user/${this.userId}`);
31508
31509
  if (this.linkTarget) {
31509
- this.linkTarget.toolbarModel.on("update", this.onLinkTargetToolbarChange);
31510
- this.linkTarget.permissions.on("change", this.onLinkTargetPermissionChange);
31511
- } else {
31512
- throw new Error(`[@netless/forge-whiteboard] link target ${targetId} not found`);
31510
+ this.toolbarModel.currentTool = this.linkTarget.get(TOOLBAR_KEYS.tool);
31511
+ this.toolbarModel.strokeColor = this.linkTarget.get(TOOLBAR_KEYS.strokeColor);
31512
+ this.toolbarModel.fillColor = this.linkTarget.get(TOOLBAR_KEYS.fillColor);
31513
+ this.toolbarModel.fontSize = this.linkTarget.get(TOOLBAR_KEYS.fontSize);
31514
+ this.toolbarModel.fontFamily = this.linkTarget.get(TOOLBAR_KEYS.fontFamily);
31515
+ this.toolbarModel.strokeWidth = this.linkTarget.get(TOOLBAR_KEYS.strokeWidth);
31516
+ this.toolbarModel.dashArray = this.linkTarget.get(TOOLBAR_KEYS.dashArray);
31517
+ this.permissions.removePermission(WhiteboardPermissionFlag.all);
31518
+ this.permissions.addPermission(this.linkTarget.get("permission"), this.userId);
31519
+ this.linkTarget.observe(this.handleLinkedMapChange);
31513
31520
  }
31514
31521
  }
31515
31522
  unlink() {
31516
31523
  if (this.linkTarget) {
31517
- this.linkTarget.toolbarModel.off("update", this.onLinkTargetToolbarChange);
31518
- this.linkTarget.permissions.off("change", this.onLinkTargetPermissionChange);
31524
+ this.linkTarget.unobserve(this.handleLinkedMapChange);
31519
31525
  }
31520
31526
  }
31521
31527
  setViewSize(width, height) {
@@ -31537,9 +31543,6 @@ var WhiteboardApplication = class extends import_forge_room3.AbstractApplication
31537
31543
  async dispose() {
31538
31544
  this.selectElementsModel.dispose();
31539
31545
  this.trashedElementsModel.dispose();
31540
- for (const key of this.layers.keys()) {
31541
- this.layers.get(key)?.dispose();
31542
- }
31543
31546
  this.paperScope.view.remove();
31544
31547
  this.shadowScope.view.remove();
31545
31548
  this.rootElement.removeChild(this.canvasElement);