@netless/telebox-insider 0.3.1 → 0.3.2-beta.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/telebox-insider",
3
- "version": "0.3.1",
3
+ "version": "0.3.2-beta.0",
4
4
  "private": false,
5
5
  "description": "Window widget for Whiteboard",
6
6
  "author": "CRIMX <straybugs@gmail.com> (https://github.com/crimx/)",
@@ -473,6 +473,10 @@ export class TeleBoxManager {
473
473
  break;
474
474
  }
475
475
  case TELE_BOX_EVENT.Close: {
476
+ const targetBox = this.hasBoxesStatus()
477
+ ? this.maxTitleBar.focusedBox || this.getMaximizedTopBox()
478
+ : this.topBox;
479
+ if (targetBox && this.closeRequestHandler?.(targetBox.id)) break;
476
480
  if (this.hasBoxesStatus()) {
477
481
  let targetBox = this.maxTitleBar.focusedBox;
478
482
  if (!targetBox) {
@@ -1149,6 +1153,7 @@ export class TeleBoxManager {
1149
1153
  }
1150
1154
  });
1151
1155
  box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Close, () => {
1156
+ if (this.closeRequestHandler?.(box.id)) return;
1152
1157
  if (this.useBoxesStatus && box.focus) {
1153
1158
  this.blurBox(box);
1154
1159
  }
@@ -1355,12 +1360,17 @@ export class TeleBoxManager {
1355
1360
  }
1356
1361
 
1357
1362
  private lazyFocusRequestHandler?: (boxId: string) => boolean;
1363
+ private closeRequestHandler?: (boxId: string) => boolean;
1358
1364
  private committedFocusDepth = 0;
1359
1365
 
1360
1366
  public setLazyFocusRequestHandler(handler?: (boxId: string) => boolean): void {
1361
1367
  this.lazyFocusRequestHandler = handler;
1362
1368
  }
1363
1369
 
1370
+ public setCloseRequestHandler(handler?: (boxId: string) => boolean): void {
1371
+ this.closeRequestHandler = handler;
1372
+ }
1373
+
1364
1374
  public focusBox(boxOrID: string | TeleBox, skipUpdate = false): void {
1365
1375
  const targetBox = this.getBox(boxOrID);
1366
1376
  if (targetBox) {