@netless/telebox-insider 0.3.0-beta.8 → 0.3.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.0-beta.8",
3
+ "version": "0.3.0",
4
4
  "private": false,
5
5
  "description": "Window widget for Whiteboard",
6
6
  "author": "CRIMX <straybugs@gmail.com> (https://github.com/crimx/)",
@@ -111,7 +111,6 @@ export class AppMenu {
111
111
  private createMinimizedItem(appId: AppId){
112
112
  const appItem = document.createElement('div');
113
113
  appItem.classList.add(this.c('app-menu-item'));
114
- console.log("appId=====>", appId);
115
114
  appItem.setAttribute(`data-${this.c('app-id')}`, appId);
116
115
  const titleDiv = document.createElement('div');
117
116
  titleDiv.classList.add(this.c('app-menu-item-title'));
@@ -29,6 +29,8 @@ export enum TELE_BOX_EVENT {
29
29
  Destroyed = "destroyed",
30
30
  BoxStatus = "box_status",
31
31
  LastNotMinimizedBoxStatus = "last_not_minimized_box_status",
32
+ ForceTop = "force_top",
33
+ ForceNormal = "force_normal",
32
34
  }
33
35
 
34
36
  export enum TELE_BOX_DELEGATE_EVENT {
@@ -72,6 +72,12 @@ type ValConfig = {
72
72
  $userContent: Val<HTMLElement | undefined>;
73
73
  $userFooter: Val<HTMLElement | undefined>;
74
74
  $userStyles: Val<HTMLStyleElement | undefined>;
75
+ /** Force top. */
76
+ forceTop: Val<boolean, boolean>;
77
+ /** Force normal. */
78
+ forceNormal: Val<boolean, boolean>;
79
+ /** Drag content. */
80
+ isDragContent: Val<boolean, boolean>;
75
81
  };
76
82
  export interface TeleBox extends ValEnhancedResult<ValConfig> {}
77
83
 
@@ -110,7 +116,10 @@ export class TeleBox {
110
116
  },
111
117
  collectorRect,
112
118
  boxStatus,
113
- lastNotMinimizedBoxStatus
119
+ lastNotMinimizedBoxStatus,
120
+ forceTop = false,
121
+ forceNormal = false,
122
+ isDragContent = false,
114
123
  }: TeleBoxConfig = {}) {
115
124
  this._sideEffect = new SideEffectManager();
116
125
  this._valSideEffectBinder = createSideEffectBinder(this._sideEffect);
@@ -182,6 +191,21 @@ export class TeleBox {
182
191
  const containerRect$ = createVal(containerRect, shallowequal);
183
192
  const collectorRect$ = createVal(collectorRect, shallowequal);
184
193
 
194
+ const forceTop$ = createVal(forceTop);
195
+ forceTop$.reaction((forceTop, _, skipUpdate) => {
196
+ if (!skipUpdate) {
197
+ this.events.emit(TELE_BOX_EVENT.ForceTop, forceTop || false);
198
+ }
199
+ });
200
+
201
+ const forceNormal$ = createVal(forceNormal);
202
+ forceNormal$.reaction((forceNormal, _, skipUpdate) => {
203
+ if (!skipUpdate) {
204
+ this.events.emit(TELE_BOX_EVENT.ForceNormal, forceNormal || false);
205
+ }
206
+ });
207
+ const isDragContent$ = createVal(isDragContent);
208
+
185
209
  const title$ = createVal(title);
186
210
  title$.reaction((title, _, skipUpdate) => {
187
211
  if (!skipUpdate) {
@@ -400,6 +424,8 @@ export class TeleBox {
400
424
  title: title$.value,
401
425
  namespace: this.namespace,
402
426
  boxStatus: boxStatus$.value,
427
+ forceTop: forceTop$.value,
428
+ forceNormal: forceNormal$.value,
403
429
  onDragStart: (event) => this._handleTrackStart?.(event),
404
430
  onEvent: (event): void => {
405
431
  if (this._delegateEvents.listeners.length > 0) {
@@ -463,6 +489,9 @@ export class TeleBox {
463
489
  $userContent: $userContent$,
464
490
  $userFooter: $userFooter$,
465
491
  $userStyles: $userStyles$,
492
+ forceTop: forceTop$,
493
+ forceNormal: forceNormal$,
494
+ isDragContent: isDragContent$,
466
495
  };
467
496
 
468
497
  withValueEnhancer(this, valConfig);
@@ -989,6 +1018,7 @@ export class TeleBox {
989
1018
  $titleBar.appendChild(this.titleBar.render());
990
1019
  this.$titleBar = $titleBar;
991
1020
 
1021
+
992
1022
  const $contentWrap = document.createElement("div");
993
1023
  $contentWrap.className = this.wrapClassName("content-wrap");
994
1024
 
@@ -996,6 +1026,9 @@ export class TeleBox {
996
1026
  $content.className =
997
1027
  this.wrapClassName("content") + " tele-fancy-scrollbar";
998
1028
  this.$content = $content;
1029
+ if (this.isDragContent) {
1030
+ this.$content.appendChild(this.titleBar.$dragArea);
1031
+ }
999
1032
 
1000
1033
  this._renderSideEffect.add(() => {
1001
1034
  let last$userStyles: HTMLStyleElement | undefined;
@@ -87,6 +87,12 @@ export interface TeleBoxConfig {
87
87
  readonly boxStatus?: TeleBoxState;
88
88
  /** Last not minimized box status. */
89
89
  readonly lastNotMinimizedBoxStatus?: NotMinimizedBoxState;
90
+ /** Force top. */
91
+ readonly forceTop?: boolean;
92
+ /** Force normal. */
93
+ readonly forceNormal?: boolean;
94
+ /** Is drag content. */
95
+ readonly isDragContent?: boolean;
90
96
  }
91
97
 
92
98
  type CheckTeleBoxConfig<T extends Record<`${TELE_BOX_EVENT}`, any>> = T;
@@ -110,6 +116,8 @@ export type TeleBoxEventConfig = CheckTeleBoxConfig<{
110
116
  destroyed: void;
111
117
  box_status: { id: string; boxStatus: TeleBoxState };
112
118
  last_not_minimized_box_status: { id: string; lastNotMinimizedBoxStatus?: NotMinimizedBoxState };
119
+ force_normal: boolean;
120
+ force_top: boolean;
113
121
  }>;
114
122
 
115
123
  export type TeleBoxEvent = keyof TeleBoxEventConfig;
@@ -15,6 +15,7 @@ export interface TeleBoxCollectorConfig {
15
15
  }
16
16
 
17
17
  export class TeleBoxCollector {
18
+ static readonly kind = "TeleBoxCollector";
18
19
  public getBoxesStatus?: () => Map<string, TeleBoxState>;
19
20
  public constructor({
20
21
  visible = true,
@@ -79,7 +80,7 @@ export class TeleBoxCollector {
79
80
  return this;
80
81
  }
81
82
 
82
- private hasMinimizedBox(): boolean {
83
+ protected hasMinimizedBox(): boolean {
83
84
  const boxesStatus = this.boxesStatus;
84
85
  if (boxesStatus) {
85
86
  for (const status of boxesStatus.values()) {
@@ -5,7 +5,7 @@ import { DefaultTitleBar, DefaultTitleBarConfig } from "../../TeleTitleBar";
5
5
  import { TELE_BOX_STATE } from "../../TeleBox/constants";
6
6
  import { TeleBoxRect, TeleBoxState } from "../../TeleBox/typings";
7
7
 
8
- export type MaxTitleBarTeleBox = Pick<TeleBox, "id" | "title" | "readonly" | "zIndex" | "$box">;
8
+ export type MaxTitleBarTeleBox = Pick<TeleBox, "id" | "title" | "readonly" | "zIndex" | "$box" | "forceTop" | "forceNormal">;
9
9
 
10
10
  export interface MaxTitleBarConfig extends DefaultTitleBarConfig {
11
11
  darkMode: boolean;
@@ -45,7 +45,7 @@ export class MaxTitleBar extends DefaultTitleBar {
45
45
  if (this.getBoxesStatus) {
46
46
  const boxesStatus = this.getBoxesStatus();
47
47
  if (boxesStatus) {
48
- return this.boxes.filter((box) => boxesStatus && boxesStatus.get(box.id) === TELE_BOX_STATE.Maximized);
48
+ return this.boxes.filter((box) => boxesStatus && boxesStatus.get(box.id) === TELE_BOX_STATE.Maximized && !box.forceTop);
49
49
  }
50
50
  }
51
51
  return [];
@@ -16,7 +16,7 @@ $scrollbar-color-active: rgba(238, 238, 247, 1);
16
16
  position: absolute;
17
17
  top: 0;
18
18
  left: 0;
19
- z-index: $base-z-index * 10;
19
+ z-index: $base-z-index * 3 - 1;
20
20
 
21
21
  .#{$namespace}-title {
22
22
  display: none;
@@ -48,16 +48,17 @@ type ValConfig = {
48
48
  export interface TeleBoxManager extends ValEnhancedResult<ValConfig> {}
49
49
 
50
50
  export class TeleBoxManager {
51
- private boxesStatus$: Map<string, TeleBoxState>;
52
- private lastNotMinimizedBoxesStatus$: Map<string, NotMinimizedBoxState>;
53
- private appMenu: AppMenu | undefined;
54
- private useBoxesStatus: boolean;
55
- private effectBoxesStatusTimer?: {
51
+ static readonly kind = "TeleBoxManager";
52
+ protected boxesStatus$: Map<string, TeleBoxState>;
53
+ protected lastNotMinimizedBoxesStatus$: Map<string, NotMinimizedBoxState>;
54
+ protected appMenu: AppMenu | undefined;
55
+ protected useBoxesStatus: boolean;
56
+ protected effectBoxesStatusTimer?: {
56
57
  skipUpdate: boolean;
57
58
  timer: number | undefined;
58
59
  resolve?: (skipUpdate: boolean) => void;
59
60
  }
60
- private effectLastNotMinimizedBoxStatusTimer?: {
61
+ protected effectLastNotMinimizedBoxStatusTimer?: {
61
62
  skipUpdate: boolean;
62
63
  timer: number | undefined;
63
64
  resolve?: (skipUpdate: boolean) => void;
@@ -90,9 +91,11 @@ export class TeleBoxManager {
90
91
  this.boxes$ = createVal<TeleBox[]>([]);
91
92
  this.topBox$ = this.boxes$.derive((boxes) => {
92
93
  if (boxes.length > 0) {
93
- console.log("topBox===>topBox$===>000");
94
94
  let currentTopBox: TeleBox | undefined = undefined;
95
95
  const topBox = boxes.reduce((topBox, box) => {
96
+ if (box.forceTop) {
97
+ return topBox;
98
+ }
96
99
  if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized) {
97
100
  return topBox;
98
101
  }
@@ -102,7 +105,6 @@ export class TeleBoxManager {
102
105
  }
103
106
  return topBox.zIndex > box.zIndex ? topBox : box;
104
107
  }, currentTopBox as (TeleBox | undefined));
105
- console.log("topBox===>topBox$===>end", topBox?.id);
106
108
  return topBox;
107
109
  }
108
110
  return;
@@ -331,7 +333,6 @@ export class TeleBoxManager {
331
333
  this.makeMaximizedTopBoxFocus();
332
334
  }
333
335
  }
334
- console.log("checkFocusBox===>", box.id);
335
336
  this.focusBox(box);
336
337
  return;
337
338
  }
@@ -396,7 +397,7 @@ export class TeleBoxManager {
396
397
  const box = this.getBox(targetBox.id);
397
398
  if (box) {
398
399
  let isFocusChanged = false;
399
- if (this.topBox === box) {
400
+ if (box.focus) {
400
401
  this.blurBox(box);
401
402
  isFocusChanged = true;
402
403
  }
@@ -426,7 +427,7 @@ export class TeleBoxManager {
426
427
  const box = this.getBox(targetBox.id);
427
428
  if (box) {
428
429
  let isFocusChanged = false;
429
- if (this.topBox === box) {
430
+ if (box.focus) {
430
431
  this.blurBox(box);
431
432
  isFocusChanged = true;
432
433
  }
@@ -490,6 +491,23 @@ export class TeleBoxManager {
490
491
  return this.topBox$.value;
491
492
  }
492
493
 
494
+ public get forceTopBoxes(): TeleBox | undefined {
495
+ return this.boxes.find((box) => box.forceTop);
496
+ }
497
+
498
+ public get maxForceTopBox(): TeleBox | undefined {
499
+ return this.boxes.reduce<TeleBox | undefined>((maxTopBox, box) => {
500
+ if (box.forceTop && box.zIndex > (maxTopBox?.zIndex ?? 0)) {
501
+ return box;
502
+ }
503
+ return maxTopBox;
504
+ }, undefined);
505
+ }
506
+
507
+ public get forceNormalBoxes(): TeleBox | undefined {
508
+ return this.boxes.find((box) => box.forceNormal);
509
+ }
510
+
493
511
  public readonly events = new EventEmitter() as TeleBoxManagerEvents;
494
512
 
495
513
  protected _sideEffect: SideEffectManager;
@@ -575,7 +593,7 @@ export class TeleBoxManager {
575
593
  return this.boxesStatus$;
576
594
  }
577
595
 
578
- private effectBoxStatusChange(){
596
+ protected effectBoxStatusChange(){
579
597
  if (!this.useBoxesStatus) {
580
598
  return;
581
599
  }
@@ -593,7 +611,7 @@ export class TeleBoxManager {
593
611
  }
594
612
  }
595
613
 
596
- private effectBoxesStatusTimerFunc(skipUpdate: boolean){
614
+ protected effectBoxesStatusTimerFunc(skipUpdate: boolean){
597
615
  if (!this.useBoxesStatus) {
598
616
  return;
599
617
  }
@@ -602,7 +620,7 @@ export class TeleBoxManager {
602
620
  this.boxes.forEach((box) => {
603
621
  const boxStatus = this.boxesStatus$.get(box.id);
604
622
  if (boxStatus) {
605
- if (boxStatus !== TELE_BOX_STATE.Minimized && box.zIndex > (newTopBox?.zIndex ?? 0)) {
623
+ if (boxStatus !== TELE_BOX_STATE.Minimized && !this.isForceTop(box) && box.zIndex > (newTopBox?.zIndex ?? 0)) {
606
624
  newTopBox = box;
607
625
  }
608
626
  box.setBoxStatus(boxStatus, skipUpdate);
@@ -611,11 +629,9 @@ export class TeleBoxManager {
611
629
  this.effectBoxStatusChange();
612
630
  if (newTopBox && curTopBox !== newTopBox) {
613
631
  this.topBox$.setValue(newTopBox);
614
- this.focusBox(newTopBox, skipUpdate);
615
632
  }
616
633
  if (!newTopBox && curTopBox) {
617
634
  this.topBox$.setValue(undefined);
618
- this.blurBox(curTopBox, skipUpdate);
619
635
  }
620
636
  }
621
637
 
@@ -634,11 +650,9 @@ export class TeleBoxManager {
634
650
  if (this.effectBoxesStatusTimer.skipUpdate !== skipUpdate) {
635
651
  clearTimeout(this.effectBoxesStatusTimer.timer);
636
652
  if (this.effectBoxesStatusTimer.resolve) {
637
- console.log("effectBoxStatusTimerFunc===>1111", skipUpdate);
638
653
  this.effectBoxesStatusTimer.resolve(!!this.effectBoxesStatusTimer?.skipUpdate);
639
654
  }
640
655
  this.effectBoxesStatusTimer.skipUpdate = skipUpdate;
641
- console.log("effectBoxStatusTimerFunc===>2222", skipUpdate);
642
656
  } else {
643
657
  return;
644
658
  }
@@ -658,15 +672,12 @@ export class TeleBoxManager {
658
672
  this.effectBoxesStatusTimer!.resolve = resolve;
659
673
  this.effectBoxesStatusTimer!.timer = setTimeout(()=>{
660
674
  if (this.effectBoxesStatusTimer && this.effectBoxesStatusTimer.resolve) {
661
- console.log("effectBoxStatusTimerFunc===>000", skipUpdate, {id:this.topBox$.value?.id, zIndex:this.topBox$.value?.zIndex}, this.boxes$.value.map((b)=>({id:b.id,focus:b.focus, boxStatus:b.boxStatus,zIndex:b.zIndex})));
662
675
  this.effectBoxesStatusTimer.resolve(this.effectBoxesStatusTimer!.skipUpdate);
663
676
  }
664
677
  }, 100) as unknown as number;
665
678
  })
666
- console.log("effectBoxStatusTimerFunc===>000==>00", skipUpdate, {id:this.topBox$.value?.id, zIndex:this.topBox$.value?.zIndex}, this.boxes$.value.map((b)=>({id:b.id,focus:b.focus, boxStatus:b.boxStatus,zIndex:b.zIndex})));
667
679
  this.effectBoxesStatusTimerFunc(_skipUpdate)
668
680
  this.effectBoxesStatusTimer = undefined;
669
- console.log("effectBoxStatusTimerFunc===>000==>11", skipUpdate, {id:this.topBox$.value?.id, zIndex:this.topBox$.value?.zIndex}, this.boxes$.value.map((b)=>({id:b.id,focus:b.focus, boxStatus:b.boxStatus,zIndex:b.zIndex})));
670
681
  }
671
682
  }
672
683
 
@@ -744,7 +755,7 @@ export class TeleBoxManager {
744
755
  this.effectLastNotMinimizedBoxStatusChange(skipUpdate);
745
756
  }
746
757
 
747
- private async effectLastNotMinimizedBoxStatusChange(skipUpdate = false): Promise<void> {
758
+ protected async effectLastNotMinimizedBoxStatusChange(skipUpdate = false): Promise<void> {
748
759
  if (!this.useBoxesStatus) {
749
760
  if (this.effectLastNotMinimizedBoxStatusTimer && this.effectLastNotMinimizedBoxStatusTimer.timer) {
750
761
  clearTimeout(this.effectLastNotMinimizedBoxStatusTimer.timer);
@@ -760,11 +771,9 @@ export class TeleBoxManager {
760
771
  if (this.effectLastNotMinimizedBoxStatusTimer.skipUpdate !== skipUpdate) {
761
772
  // this.effectLastNotMinimizedBoxStatusFunc(this.effectLastNotMinimizedBoxStatusTimer.skipUpdate)
762
773
  if (this.effectLastNotMinimizedBoxStatusTimer.resolve) {
763
- console.log("effectLastNotMinimizedBoxStatusFunc===>1111", skipUpdate);
764
774
  this.effectLastNotMinimizedBoxStatusTimer.resolve(!!this.effectLastNotMinimizedBoxStatusTimer?.skipUpdate);
765
775
  }
766
776
  this.effectLastNotMinimizedBoxStatusTimer.skipUpdate = skipUpdate;
767
- console.log("effectLastNotMinimizedBoxStatusFunc===>2222", skipUpdate);
768
777
  } else {
769
778
  return;
770
779
  }
@@ -784,23 +793,19 @@ export class TeleBoxManager {
784
793
  this.effectLastNotMinimizedBoxStatusTimer!.resolve = resolve;
785
794
  this.effectLastNotMinimizedBoxStatusTimer!.timer = setTimeout(()=>{
786
795
  if (this.effectLastNotMinimizedBoxStatusTimer && this.effectLastNotMinimizedBoxStatusTimer.resolve) {
787
- console.log("effectLastNotMinimizedBoxStatusTimer===>000", skipUpdate);
788
796
  this.effectLastNotMinimizedBoxStatusTimer.resolve(this.effectLastNotMinimizedBoxStatusTimer!.skipUpdate);
789
797
  }
790
798
  }, 100) as unknown as number;
791
799
  })
792
- console.log("effectLastNotMinimizedBoxStatusFunc===>000==>00", skipUpdate, this.boxes$.value.map((b)=>({id:b.id,focus:b.focus, boxStatus:b.boxStatus,zIndex:b.zIndex, lastNotMinimizedBoxStatus:b._lastNotMinimizedBoxStatus$.value})));
793
800
  this.effectLastNotMinimizedBoxStatusFunc(_skipUpdate)
794
801
  this.effectLastNotMinimizedBoxStatusTimer = undefined;
795
- console.log("effectLastNotMinimizedBoxStatusFunc===>000==>11", skipUpdate, this.boxes$.value.map((b)=>({id:b.id,focus:b.focus, boxStatus:b.boxStatus,zIndex:b.zIndex, lastNotMinimizedBoxStatus:b._lastNotMinimizedBoxStatus$.value})));
796
802
  }
797
803
  }
798
804
 
799
- private effectLastNotMinimizedBoxStatusFunc(skipUpdate = false){
805
+ protected effectLastNotMinimizedBoxStatusFunc(skipUpdate = false){
800
806
  if (!this.useBoxesStatus) {
801
807
  return;
802
808
  }
803
- console.log("effectLastNotMinimizedBoxStatusFunc===>end", skipUpdate);
804
809
  this.boxes.forEach((box) => {
805
810
  const boxStatus = this.lastNotMinimizedBoxesStatus$.get(box.id);
806
811
  if(boxStatus){
@@ -809,26 +814,17 @@ export class TeleBoxManager {
809
814
  });
810
815
  }
811
816
 
812
- private getUnabledBoxesStatusZIndex(): number {
817
+ protected getUnabledBoxesStatusZIndex(): number {
813
818
  return this.topBox ? this.topBox.zIndex : 99;
814
819
  }
815
820
 
816
- // private getTopBoxZIndex(): number {
817
- // if (!this.useBoxesStatus) {
818
- // return this.getUnabledBoxesStatusZIndex();
819
- // }
820
- // return [...this.boxes].filter((box) => box.boxStatus !== TELE_BOX_STATE.Minimized).reduce((maxZIndex, box) => {
821
- // return Math.max(maxZIndex, box.zIndex);
822
- // }, 100);
823
- // }
824
-
825
821
  /** Maximized box zIndex range: 100-299 */
826
822
  public getMaxMaximizedBoxZIndex(): number {
827
823
  if (!this.useBoxesStatus) {
828
824
  return this.getUnabledBoxesStatusZIndex();
829
825
  }
830
826
  return this.boxes.reduce((maxZIndex, box) => {
831
- if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Maximized) {
827
+ if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Maximized && !this.isForceTop(box)) {
832
828
  return Math.max(maxZIndex, box.zIndex);
833
829
  }
834
830
  return maxZIndex;
@@ -841,20 +837,39 @@ export class TeleBoxManager {
841
837
  return this.getUnabledBoxesStatusZIndex();
842
838
  }
843
839
  return this.boxes.reduce((maxZIndex, box) => {
844
- if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Normal) {
840
+ if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Normal && !this.isForceTop(box)) {
845
841
  return Math.max(maxZIndex, box.zIndex);
846
842
  }
847
843
  return maxZIndex;
848
844
  }, 299);
849
845
  }
850
846
 
847
+ public getMaxForceTopBoxZIndex(): number {
848
+ if (!this.useBoxesStatus) {
849
+ return this.getUnabledBoxesStatusZIndex();
850
+ }
851
+ return this.boxes.reduce((maxZIndex, box) => {
852
+ if (box.boxStatus && this.isForceTop(box)) {
853
+ return Math.max(maxZIndex, box.zIndex);
854
+ }
855
+ return maxZIndex;
856
+ }, 699);
857
+ }
858
+
859
+ public isForceNormal(box: TeleBox): boolean {
860
+ return box._forceNormal$.value;
861
+ }
862
+
863
+ public isForceTop(box: TeleBox): boolean {
864
+ return box._forceTop$.value;
865
+ }
866
+
851
867
  public create(
852
868
  config: TeleBoxManagerCreateConfig = {},
853
869
  smartPosition = true
854
870
  ): ReadonlyTeleBox {
855
- console.log("create===>", config, this.topBox?.zIndex);
856
871
  const box = new TeleBox({
857
- zIndex: this.getMaxNormalBoxZIndex() + 1,
872
+ zIndex: config.forceTop ? this.getMaxForceTopBoxZIndex() + 1 : this.getMaxNormalBoxZIndex() + 1,
858
873
  ...(smartPosition ? this.smartPosition(config) : config),
859
874
  darkMode: this.darkMode,
860
875
  prefersColorScheme: this.prefersColorScheme,
@@ -887,6 +902,9 @@ export class TeleBoxManager {
887
902
 
888
903
  box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Maximize, () => {
889
904
  if (this.useBoxesStatus && box.boxStatus) {
905
+ if (box._forceNormal$.value) {
906
+ return;
907
+ }
890
908
  if (box.boxStatus === TELE_BOX_STATE.Maximized) {
891
909
  this.setBox(box.id, {
892
910
  status: TELE_BOX_STATE.Normal,
@@ -894,9 +912,8 @@ export class TeleBoxManager {
894
912
  }, false);
895
913
  } else {
896
914
  // 所有normal box都最大化
897
- [...this.boxes].filter((box) => box.boxStatus === TELE_BOX_STATE.Normal).sort((a, b) => a.zIndex - b.zIndex).forEach((box) => {
915
+ [...this.boxes].filter((box) => box.boxStatus === TELE_BOX_STATE.Normal && !this.isForceNormal(box)).sort((a, b) => a.zIndex - b.zIndex).forEach((box) => {
898
916
  if (box.boxStatus === TELE_BOX_STATE.Normal) {
899
- console.log("maximized===>", box.id);
900
917
  this.setBox(box.id, {
901
918
  status: TELE_BOX_STATE.Maximized,
902
919
  zIndex: this.getMaxMaximizedBoxZIndex() + 1
@@ -912,10 +929,11 @@ export class TeleBoxManager {
912
929
  });
913
930
  box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Minimize, () => {
914
931
  if (box.boxStatus && this.useBoxesStatus) {
915
- if (this.topBox === box) {
916
- if (this.topBox?.focus) {
917
- this.blurBox(this.topBox);
918
- }
932
+ if (box._forceNormal$.value) {
933
+ return;
934
+ }
935
+ if(box.focus) {
936
+ this.blurBox(box);
919
937
  }
920
938
  this.setBox(box, {
921
939
  status: TELE_BOX_STATE.Minimized,
@@ -929,6 +947,9 @@ export class TeleBoxManager {
929
947
  }
930
948
  });
931
949
  box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Close, () => {
950
+ if (this.useBoxesStatus && box.focus) {
951
+ this.blurBox(box);
952
+ }
932
953
  this.remove(box);
933
954
  this.focusTopBox();
934
955
  });
@@ -959,9 +980,11 @@ export class TeleBoxManager {
959
980
  });
960
981
  box._zIndex$.reaction((_, __, skipUpdate) => {
961
982
  if (this.boxes.length > 0) {
962
- console.log("topBox===>_zIndex", this.boxes.map((box) => ({id: box.id, zIndex: box.zIndex, boxStatus: box.boxStatus})));
963
983
  let currentTopBox: TeleBox | undefined = undefined;
964
984
  const topBox = this.boxes.reduce((topBox, box) => {
985
+ if (this.isForceTop(box)) {
986
+ return topBox;
987
+ }
965
988
  if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized) {
966
989
  return topBox;
967
990
  }
@@ -971,7 +994,6 @@ export class TeleBoxManager {
971
994
  }
972
995
  return topBox.zIndex > box.zIndex ? topBox : box;
973
996
  }, currentTopBox as (TeleBox | undefined));
974
- console.log("topBox===>_zIndex===>end", topBox?.id);
975
997
  this.topBox$.setValue(topBox);
976
998
  }
977
999
  if (!skipUpdate) {
@@ -1246,6 +1268,12 @@ export class TeleBoxManager {
1246
1268
  lastNotMinimizedBoxStatus: config.lastNotMinimizedBoxStatus
1247
1269
  }, skipUpdate);
1248
1270
  }
1271
+ if (config.forceTop != null) {
1272
+ box.setForceTop(config.forceTop, skipUpdate);
1273
+ }
1274
+ if (config.forceNormal != null) {
1275
+ box.setForceNormal(config.forceNormal, skipUpdate);
1276
+ }
1249
1277
  }
1250
1278
 
1251
1279
  protected smartPosition(config: TeleBoxConfig = {}): TeleBoxConfig {
@@ -1254,7 +1282,18 @@ export class TeleBoxManager {
1254
1282
 
1255
1283
  if (x == null) {
1256
1284
  let vx = 20;
1257
- if (this.topBox) {
1285
+ if (config.forceTop) {
1286
+ const forceTopBox = this.maxForceTopBox || this.topBox;
1287
+ if (forceTopBox) {
1288
+ vx = forceTopBox.intrinsicX * this.containerRect.width + 20;
1289
+ if (
1290
+ vx >
1291
+ this.containerRect.width - width * this.containerRect.width
1292
+ ) {
1293
+ vx = 20;
1294
+ }
1295
+ }
1296
+ } else if (this.topBox) {
1258
1297
  vx = this.topBox.intrinsicX * this.containerRect.width + 20;
1259
1298
  if (
1260
1299
  vx >
@@ -1273,8 +1312,20 @@ export class TeleBoxManager {
1273
1312
 
1274
1313
  if (y == null) {
1275
1314
  let vy = 20;
1276
-
1277
- if (this.topBox) {
1315
+ if (config.forceTop) {
1316
+ const forceTopBox = this.maxForceTopBox || this.topBox;
1317
+ if (forceTopBox) {
1318
+ vy = forceTopBox.intrinsicY * this.containerRect.height + 20;
1319
+
1320
+ if (
1321
+ vy >
1322
+ this.containerRect.height -
1323
+ height * this.containerRect.height
1324
+ ) {
1325
+ vy = 20;
1326
+ }
1327
+ }
1328
+ } else if (this.topBox) {
1278
1329
  vy = this.topBox.intrinsicY * this.containerRect.height + 20;
1279
1330
 
1280
1331
  if (
@@ -1307,7 +1358,7 @@ export class TeleBoxManager {
1307
1358
  }
1308
1359
  }
1309
1360
 
1310
- private getMaximizedTopBox(): MaxTitleBarTeleBox | undefined {
1361
+ protected getMaximizedTopBox(): MaxTitleBarTeleBox | undefined {
1311
1362
  if (!this.useBoxesStatus) {
1312
1363
  return undefined;
1313
1364
  }
@@ -1328,9 +1379,7 @@ export class TeleBoxManager {
1328
1379
  return;
1329
1380
  }
1330
1381
  const maximizedBox: MaxTitleBarTeleBox | undefined = this.getMaximizedTopBox();
1331
- console.log("makeMaximizedTopBoxFocus===>", maximizedBox?.id);
1332
1382
  this.maxTitleBar.focusBox(maximizedBox);
1333
- console.log("makeMaximizedTopBoxFocus===>end", maximizedBox?.id);
1334
1383
  }
1335
1384
 
1336
1385
  protected getBoxIndex(boxOrID: TeleBox | string): number {
@@ -38,7 +38,10 @@ type TeleBoxManagerBoxConfigBaseProps =
38
38
  | "fixRatio"
39
39
  | "zIndex"
40
40
  | "boxStatus"
41
- | "lastNotMinimizedBoxStatus";
41
+ | "lastNotMinimizedBoxStatus"
42
+ | "forceTop"
43
+ | "forceNormal"
44
+ | "isDragContent";
42
45
 
43
46
  export type TeleBoxManagerCreateConfig = Pick<
44
47
  TeleBoxConfig,