box-annotations 5.2.1-beta.11 → 5.2.1-beta.12

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": "box-annotations",
3
- "version": "5.2.1-beta.11",
3
+ "version": "5.2.1-beta.12",
4
4
  "description": "Box Annotations",
5
5
  "author": "Box (https://www.box.com/)",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -28,3 +28,14 @@
28
28
  .ba-Layer--popup {
29
29
  z-index: 4;
30
30
  }
31
+
32
+ .ba-PopupPortal {
33
+ position: relative;
34
+ z-index: 10;
35
+ pointer-events: none;
36
+
37
+ .ba-Popup {
38
+ z-index: 150;
39
+ pointer-events: auto;
40
+ }
41
+ }
@@ -8,7 +8,7 @@ export default function DeselectListener(): null {
8
8
  React.useEffect(() => {
9
9
  const handleMouseDown = (event: MouseEvent): void => {
10
10
  // Popup is portaled outside .ba-Layer; native mousedown still bubbles here.
11
- if ((event.target as Element | null)?.closest?.('.ba-PopupV2')) return;
11
+ if ((event.target as Element | null)?.closest?.('.ba-PopupV2, .ba-Popup')) return;
12
12
  dispatch(setActiveAnnotationIdAction(null));
13
13
  };
14
14
 
@@ -33,12 +33,6 @@ export type Props = {
33
33
 
34
34
  const options: Partial<Options> = {
35
35
  modifiers: [
36
- {
37
- name: 'eventListeners',
38
- options: {
39
- scroll: false,
40
- },
41
- },
42
36
  {
43
37
  name: 'offset',
44
38
  options: {
@@ -48,7 +42,6 @@ const options: Partial<Options> = {
48
42
  {
49
43
  name: 'preventOverflow',
50
44
  options: {
51
- altAxis: true,
52
45
  padding: 50,
53
46
  },
54
47
  },
@@ -103,7 +103,7 @@ export default class DocumentAnnotator extends BaseAnnotator {
103
103
 
104
104
  // Annotations mode
105
105
  managers.add(new PopupManager({ location: pageNumber, popupPortalEl: this.popupPortalEl, referenceEl: pageReferenceEl, resinTags }));
106
- managers.add(new DrawingManager({ location: pageNumber, referenceEl: pageReferenceEl, resinTags }));
106
+ managers.add(new DrawingManager({ location: pageNumber, popupPortalEl: this.popupPortalEl, referenceEl: pageReferenceEl, resinTags }));
107
107
 
108
108
  const textLayer = pageEl.querySelector('.textLayer') as HTMLElement;
109
109
 
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import ReactDOM from 'react-dom';
2
3
  import classNames from 'classnames';
3
4
  import DecoratedDrawingPath from './DecoratedDrawingPath';
4
5
  import DrawingList from './DrawingList';
@@ -22,6 +23,7 @@ export type Props = {
22
23
  drawnPathGroups: Array<PathGroup>;
23
24
  isCreating: boolean;
24
25
  location: number;
26
+ popupPortalEl?: HTMLElement | null;
25
27
  redoDrawingPathGroup: () => void;
26
28
  resetDrawing: () => void;
27
29
  rotation: number;
@@ -46,6 +48,7 @@ const DrawingAnnotations = (props: Props): JSX.Element => {
46
48
  drawnPathGroups,
47
49
  isCreating,
48
50
  location,
51
+ popupPortalEl,
49
52
  redoDrawingPathGroup,
50
53
  resetDrawing,
51
54
  rotation,
@@ -176,20 +179,22 @@ const DrawingAnnotations = (props: Props): JSX.Element => {
176
179
  />
177
180
  )}
178
181
 
179
- {isCreating && hasPathGroups && drawingSVGGroup && canShowPopupToolbar && (
180
- <PopupDrawingToolbar
181
- ref={popupDrawingToolbarRef}
182
- canComment={hasDrawnPathGroups}
183
- canRedo={hasStashedPathGroups}
184
- canUndo={hasDrawnPathGroups}
185
- className={classNames('ba-DrawingAnnotations-toolbar', { 'ba-is-drawing': isDrawing })}
186
- onDelete={handleDelete}
187
- onRedo={handleRedo}
188
- onReply={handleReply}
189
- onUndo={handleUndo}
190
- reference={drawingSVGGroup}
191
- />
192
- )}
182
+ {isCreating && hasPathGroups && drawingSVGGroup && canShowPopupToolbar && popupPortalEl &&
183
+ ReactDOM.createPortal(
184
+ <PopupDrawingToolbar
185
+ ref={popupDrawingToolbarRef}
186
+ canComment={hasDrawnPathGroups}
187
+ canRedo={hasStashedPathGroups}
188
+ canUndo={hasDrawnPathGroups}
189
+ className={classNames('ba-DrawingAnnotations-toolbar', { 'ba-is-drawing': isDrawing })}
190
+ onDelete={handleDelete}
191
+ onRedo={handleRedo}
192
+ onReply={handleReply}
193
+ onUndo={handleUndo}
194
+ reference={drawingSVGGroup}
195
+ />,
196
+ popupPortalEl,
197
+ )}
193
198
  </>
194
199
  );
195
200
  };
@@ -1,9 +1,20 @@
1
1
  import * as React from 'react';
2
2
  import * as ReactDOM from 'react-dom/client';
3
- import BaseManager, { Props } from '../common/BaseManager';
3
+ import BaseManager, { Options as BaseOptions, Props } from '../common/BaseManager';
4
4
  import DrawingAnnotationsContainer from './DrawingAnnotationsContainer';
5
5
 
6
+ export type Options = BaseOptions & {
7
+ popupPortalEl?: HTMLElement | null;
8
+ };
9
+
6
10
  export default class DrawingListManager extends BaseManager {
11
+ popupPortalEl?: HTMLElement | null;
12
+
13
+ constructor({ popupPortalEl, ...options }: Options) {
14
+ super(options);
15
+ this.popupPortalEl = popupPortalEl;
16
+ }
17
+
7
18
  decorate(): void {
8
19
  this.reactEl.classList.add('ba-Layer--drawing');
9
20
  this.reactEl.dataset.testid = 'ba-Layer--drawing';
@@ -14,6 +25,6 @@ export default class DrawingListManager extends BaseManager {
14
25
  this.root = ReactDOM.createRoot(this.reactEl);
15
26
  }
16
27
 
17
- this.root.render(<DrawingAnnotationsContainer referenceEl={this.referenceEl} targetType={this.targetType} location={this.location} {...props} />);
28
+ this.root.render(<DrawingAnnotationsContainer referenceEl={this.referenceEl} targetType={this.targetType} location={this.location} popupPortalEl={this.popupPortalEl} {...props} />);
18
29
  }
19
30
  }
@@ -74,7 +74,7 @@ export default class ImageAnnotator extends BaseAnnotator {
74
74
  }
75
75
 
76
76
  this.managers.add(new PopupManager({ popupPortalEl: this.popupPortalEl, referenceEl, resinTags }));
77
- this.managers.add(new DrawingManager({ referenceEl, resinTags }));
77
+ this.managers.add(new DrawingManager({ popupPortalEl: this.popupPortalEl, referenceEl, resinTags }));
78
78
  this.managers.add(new RegionManager({ referenceEl, resinTags }));
79
79
  this.managers.add(new RegionCreationManager({ referenceEl, resinTags }));
80
80
  }
@@ -1,4 +1,5 @@
1
1
  import * as React from 'react';
2
+ import * as ReactDOM from 'react-dom';
2
3
  import noop from 'lodash/noop';
3
4
  import PopupReply from '../components/Popups/PopupReply';
4
5
  import PopupV2 from '../components/Popups/PopupV2';
@@ -121,7 +122,8 @@ const PopupLayer = (props: Props): JSX.Element | null => {
121
122
  }
122
123
 
123
124
  if (showCreator) {
124
- return (
125
+ if (!popupPortalEl) return null;
126
+ return ReactDOM.createPortal(
125
127
  <div className="ba-PopupLayer-popup">
126
128
  <PopupReply
127
129
  isPending={isPending}
@@ -131,7 +133,8 @@ const PopupLayer = (props: Props): JSX.Element | null => {
131
133
  reference={reference}
132
134
  value={message}
133
135
  />
134
- </div>
136
+ </div>,
137
+ popupPortalEl,
135
138
  );
136
139
  }
137
140