box-annotations 4.0.0-beta.8 → 4.0.1-beta.1
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/README.md +7 -57
- package/dist/annotations.css +1 -1
- package/dist/annotations.js +1 -1
- package/i18n/bn-IN.js +6 -0
- package/i18n/bn-IN.properties +12 -0
- package/i18n/da-DK.js +6 -0
- package/i18n/da-DK.properties +12 -0
- package/i18n/de-DE.js +6 -0
- package/i18n/de-DE.properties +12 -0
- package/i18n/en-AU.js +6 -0
- package/i18n/en-AU.properties +12 -0
- package/i18n/en-CA.js +6 -0
- package/i18n/en-CA.properties +12 -0
- package/i18n/en-GB.js +6 -0
- package/i18n/en-GB.properties +12 -0
- package/i18n/en-US.js +6 -0
- package/i18n/en-US.properties +12 -0
- package/i18n/en-x-pseudo.js +16 -9
- package/i18n/en-x-pseudo.properties +23 -9
- package/i18n/es-419.js +6 -0
- package/i18n/es-419.properties +12 -0
- package/i18n/es-ES.js +6 -0
- package/i18n/es-ES.properties +12 -0
- package/i18n/fi-FI.js +6 -0
- package/i18n/fi-FI.properties +12 -0
- package/i18n/fr-CA.js +6 -0
- package/i18n/fr-CA.properties +12 -0
- package/i18n/fr-FR.js +6 -0
- package/i18n/fr-FR.properties +12 -0
- package/i18n/hi-IN.js +6 -0
- package/i18n/hi-IN.properties +12 -0
- package/i18n/it-IT.js +6 -0
- package/i18n/it-IT.properties +12 -0
- package/i18n/ja-JP.js +6 -0
- package/i18n/ja-JP.properties +12 -0
- package/i18n/json/src/components/Popups/messages.json +1 -1
- package/i18n/ko-KR.js +6 -0
- package/i18n/ko-KR.properties +12 -0
- package/i18n/nb-NO.js +6 -0
- package/i18n/nb-NO.properties +12 -0
- package/i18n/nl-NL.js +6 -0
- package/i18n/nl-NL.properties +12 -0
- package/i18n/pl-PL.js +6 -0
- package/i18n/pl-PL.properties +12 -0
- package/i18n/pt-BR.js +6 -0
- package/i18n/pt-BR.properties +12 -0
- package/i18n/ru-RU.js +6 -0
- package/i18n/ru-RU.properties +12 -0
- package/i18n/sv-SE.js +6 -0
- package/i18n/sv-SE.properties +12 -0
- package/i18n/tr-TR.js +6 -0
- package/i18n/tr-TR.properties +12 -0
- package/i18n/zh-CN.js +6 -0
- package/i18n/zh-CN.properties +12 -0
- package/i18n/zh-TW.js +6 -0
- package/i18n/zh-TW.properties +12 -0
- package/package.json +29 -29
- package/src/@types/events.ts +8 -2
- package/src/@types/global.ts +1 -0
- package/src/@types/model.ts +20 -7
- package/src/BoxAnnotations.ts +16 -2
- package/src/common/BaseAnnotator.scss +0 -1
- package/src/common/BaseAnnotator.ts +125 -19
- package/src/common/BaseManager.ts +67 -4
- package/src/common/DeselectListener.tsx +21 -0
- package/src/common/DeselectManager.tsx +30 -0
- package/src/common/useIsListInteractive.ts +10 -0
- package/src/common/useMountId.ts +14 -0
- package/src/common/useOutsideEvent.ts +9 -4
- package/src/common/usePrevious.ts +13 -0
- package/src/components/ItemList/ItemList.scss +7 -2
- package/src/components/ItemList/ItemList.tsx +45 -26
- package/src/components/ItemList/ItemRow.scss +19 -7
- package/src/components/ItemList/ItemRow.tsx +33 -12
- package/src/components/PointerCapture/PointerCapture.tsx +116 -0
- package/src/components/PointerCapture/index.ts +2 -0
- package/src/components/Popups/Popper.ts +1 -0
- package/src/components/Popups/PopupArrow.scss +91 -0
- package/src/components/Popups/PopupBase.scss +12 -81
- package/src/components/Popups/PopupBase.tsx +0 -1
- package/src/components/Popups/PopupCursor.tsx +1 -1
- package/src/components/Popups/PopupDrawingToolbar.scss +76 -0
- package/src/components/Popups/PopupDrawingToolbar.tsx +109 -0
- package/src/components/Popups/PopupHighlight.scss +39 -0
- package/src/components/Popups/PopupHighlight.tsx +97 -0
- package/src/components/Popups/PopupHighlightError.scss +23 -0
- package/src/components/Popups/PopupHighlightError.tsx +74 -0
- package/src/components/Popups/PopupList.scss +1 -4
- package/src/components/Popups/PopupList.tsx +2 -2
- package/src/components/Popups/PopupReply.tsx +51 -6
- package/src/components/Popups/messages.ts +30 -0
- package/src/components/ReplyField/ReplyField.scss +6 -1
- package/src/components/ReplyField/ReplyField.tsx +43 -42
- package/src/components/ReplyField/ReplyFieldContainer.tsx +2 -1
- package/src/components/ReplyForm/ReplyButton.tsx +38 -0
- package/src/components/ReplyForm/ReplyForm.scss +3 -0
- package/src/components/ReplyForm/ReplyForm.tsx +49 -12
- package/src/components/ReplyForm/ReplyFormContainer.tsx +6 -4
- package/src/constants.js +1 -8
- package/src/document/DocumentAnnotator.scss +15 -0
- package/src/document/DocumentAnnotator.ts +110 -53
- package/src/document/docUtil.ts +61 -0
- package/src/drawing/DecoratedDrawingPath.scss +9 -0
- package/src/drawing/DecoratedDrawingPath.tsx +43 -0
- package/src/drawing/DrawingAnnotations.scss +39 -0
- package/src/drawing/DrawingAnnotations.tsx +157 -0
- package/src/drawing/DrawingAnnotationsContainer.tsx +66 -0
- package/src/drawing/DrawingCreator.scss +9 -0
- package/src/drawing/DrawingCreator.tsx +183 -0
- package/src/drawing/DrawingCursor.ts +23 -0
- package/src/drawing/DrawingList.tsx +60 -0
- package/src/drawing/DrawingManager.tsx +15 -0
- package/src/drawing/DrawingPath.tsx +17 -0
- package/src/drawing/DrawingPathGroup.tsx +52 -0
- package/src/drawing/DrawingSVG.tsx +34 -0
- package/src/drawing/DrawingSVGGroup.tsx +23 -0
- package/src/drawing/DrawingTarget.scss +11 -0
- package/src/drawing/DrawingTarget.tsx +100 -0
- package/src/drawing/SVGFilterContext.js +5 -0
- package/src/drawing/actions.ts +48 -0
- package/src/drawing/drawingUtil.ts +106 -0
- package/src/drawing/index.ts +2 -0
- package/src/highlight/HighlightAnnotations.scss +12 -0
- package/src/highlight/HighlightAnnotations.tsx +144 -0
- package/src/highlight/HighlightCanvas.scss +9 -0
- package/src/highlight/HighlightCanvas.tsx +109 -0
- package/src/highlight/HighlightContainer.tsx +64 -0
- package/src/highlight/HighlightCreator.scss +12 -0
- package/src/highlight/HighlightCreatorManager.ts +79 -0
- package/src/highlight/HighlightList.scss +13 -0
- package/src/highlight/HighlightList.tsx +92 -0
- package/src/highlight/HighlightListener.ts +37 -0
- package/src/highlight/HighlightManager.tsx +15 -0
- package/src/highlight/HighlightSvg.scss +7 -0
- package/src/highlight/HighlightSvg.tsx +18 -0
- package/src/highlight/HighlightTarget.scss +5 -0
- package/src/highlight/HighlightTarget.tsx +106 -0
- package/src/highlight/actions.ts +36 -0
- package/src/highlight/highlightUtil.ts +143 -0
- package/src/highlight/index.ts +4 -0
- package/src/image/ImageAnnotator.scss +20 -0
- package/src/image/ImageAnnotator.ts +137 -0
- package/src/polyfill.ts +19 -0
- package/src/popup/PopupContainer.tsx +50 -0
- package/src/popup/PopupLayer.scss +3 -0
- package/src/popup/PopupLayer.tsx +103 -0
- package/src/popup/PopupManager.tsx +15 -0
- package/src/region/RegionAnnotation.scss +4 -0
- package/src/region/RegionAnnotation.tsx +15 -16
- package/src/region/RegionAnnotations.scss +1 -15
- package/src/region/RegionAnnotations.tsx +14 -115
- package/src/region/RegionAnnotationsContainer.tsx +24 -0
- package/src/region/RegionCreation.scss +17 -0
- package/src/region/RegionCreation.tsx +79 -0
- package/src/region/RegionCreationContainer.tsx +43 -0
- package/src/region/RegionCreationManager.tsx +15 -0
- package/src/region/RegionCreator.scss +9 -2
- package/src/region/RegionCreator.tsx +50 -71
- package/src/region/RegionList.tsx +8 -12
- package/src/region/RegionManager.tsx +7 -39
- package/src/region/RegionRect.scss +41 -9
- package/src/region/RegionRect.tsx +9 -3
- package/src/region/index.ts +1 -0
- package/src/region/regionUtil.ts +1 -8
- package/src/region/transformUtil.ts +28 -0
- package/src/store/annotations/actions.ts +1 -0
- package/src/store/annotations/reducer.ts +9 -2
- package/src/store/annotations/selectors.ts +1 -0
- package/src/store/annotations/types.ts +1 -0
- package/src/store/common/actions.ts +1 -0
- package/src/store/common/reducer.ts +16 -10
- package/src/store/common/selectors.ts +1 -0
- package/src/store/common/types.ts +3 -0
- package/src/store/createRootReducer.ts +4 -0
- package/src/store/creator/actions.ts +2 -0
- package/src/store/creator/reducer.ts +22 -3
- package/src/store/creator/selectors.ts +9 -1
- package/src/store/creator/types.ts +18 -3
- package/src/store/drawing/actions.ts +10 -0
- package/src/store/drawing/index.ts +4 -0
- package/src/store/drawing/reducer.ts +50 -0
- package/src/store/drawing/selectors.ts +9 -0
- package/src/store/drawing/types.ts +7 -0
- package/src/store/eventing/active.ts +4 -2
- package/src/store/eventing/fetch.ts +8 -0
- package/src/store/eventing/init.ts +14 -0
- package/src/store/eventing/middleware.ts +21 -3
- package/src/store/eventing/mode.ts +7 -0
- package/src/store/eventing/staged.ts +56 -0
- package/src/store/eventing/status.ts +19 -0
- package/src/store/highlight/actions.ts +106 -0
- package/src/store/highlight/index.ts +4 -0
- package/src/store/highlight/reducer.ts +37 -0
- package/src/store/highlight/selectors.ts +12 -0
- package/src/store/highlight/types.ts +14 -0
- package/src/store/index.ts +2 -0
- package/src/store/options/actions.ts +2 -0
- package/src/store/options/reducer.ts +17 -1
- package/src/store/options/selectors.ts +8 -0
- package/src/store/options/types.ts +5 -0
- package/src/store/types.ts +5 -1
- package/src/store/users/actions.ts +3 -2
- package/src/utils/resin.ts +22 -0
- package/src/utils/rotate.ts +131 -0
- package/src/utils/scroll.ts +45 -0
- package/src/utils/util.ts +3 -0
- package/src/region/RegionContainer.tsx +0 -49
- package/src/utils/polyfill.js +0 -161
|
@@ -1,31 +1,52 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { Collaborator } from '../../@types';
|
|
4
4
|
import './ItemRow.scss';
|
|
5
5
|
|
|
6
6
|
export type Props = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
className?: string;
|
|
8
|
+
isActive?: boolean;
|
|
9
|
+
item: Collaborator;
|
|
10
|
+
onClick?: (event: React.SyntheticEvent) => void;
|
|
11
|
+
onMouseDown?: (event: React.SyntheticEvent) => void;
|
|
12
|
+
onMouseEnter?: (event: React.SyntheticEvent) => void;
|
|
10
13
|
};
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
export type ItemRowRef = HTMLLIElement;
|
|
16
|
+
|
|
17
|
+
const ItemRow = (props: Props, ref: React.Ref<ItemRowRef>): JSX.Element | null => {
|
|
18
|
+
const { className, isActive, item: collaborator, onClick, onMouseDown, onMouseEnter } = props;
|
|
19
|
+
|
|
20
|
+
if (!collaborator || !collaborator.item || !collaborator.item.name) {
|
|
14
21
|
return null;
|
|
15
22
|
}
|
|
16
23
|
|
|
24
|
+
const { item } = collaborator; // Nested item has id, name, and email (if a user type)
|
|
25
|
+
|
|
17
26
|
return (
|
|
18
|
-
|
|
27
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
|
|
28
|
+
<li
|
|
29
|
+
ref={ref}
|
|
30
|
+
aria-selected={isActive}
|
|
31
|
+
className={classNames(className, 'ba-ItemRow', { 'is-active': isActive })}
|
|
32
|
+
data-resin-target="atMention"
|
|
33
|
+
data-testid="ba-ItemRow"
|
|
34
|
+
onClick={onClick}
|
|
35
|
+
onMouseDown={onMouseDown}
|
|
36
|
+
onMouseEnter={onMouseEnter}
|
|
37
|
+
role="option"
|
|
38
|
+
>
|
|
19
39
|
<div className="ba-ItemRow-name" data-testid="ba-ItemRow-name">
|
|
20
40
|
{item.name}
|
|
21
41
|
</div>
|
|
22
|
-
|
|
42
|
+
|
|
43
|
+
{item.type === 'user' && item.email && (
|
|
23
44
|
<div className="ba-ItemRow-email" data-testid="ba-ItemRow-email">
|
|
24
45
|
{item.email}
|
|
25
46
|
</div>
|
|
26
47
|
)}
|
|
27
|
-
</
|
|
48
|
+
</li>
|
|
28
49
|
);
|
|
29
50
|
};
|
|
30
51
|
|
|
31
|
-
export default ItemRow;
|
|
52
|
+
export default React.forwardRef(ItemRow);
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import noop from 'lodash/noop';
|
|
3
|
+
import { MOUSE_PRIMARY } from '../../constants';
|
|
4
|
+
|
|
5
|
+
export enum Status {
|
|
6
|
+
dragging = 'dragging',
|
|
7
|
+
drawing = 'drawing',
|
|
8
|
+
init = 'init',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type PointerCaptureRef = HTMLDivElement;
|
|
12
|
+
|
|
13
|
+
export type Props = {
|
|
14
|
+
children?: React.ReactNode;
|
|
15
|
+
className?: string;
|
|
16
|
+
onDrawStart: (x: number, y: number) => void;
|
|
17
|
+
onDrawStop: () => void;
|
|
18
|
+
onDrawUpdate: (x: number, y: number) => void;
|
|
19
|
+
onMouseOut?: () => void;
|
|
20
|
+
onMouseOver?: () => void;
|
|
21
|
+
status: Status;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
function PointerCapture(props: Props, ref: React.Ref<PointerCaptureRef>): JSX.Element {
|
|
25
|
+
const {
|
|
26
|
+
children,
|
|
27
|
+
className,
|
|
28
|
+
onDrawStart,
|
|
29
|
+
onDrawStop,
|
|
30
|
+
onDrawUpdate,
|
|
31
|
+
onMouseOut = noop,
|
|
32
|
+
onMouseOver = noop,
|
|
33
|
+
status,
|
|
34
|
+
...rest
|
|
35
|
+
} = props;
|
|
36
|
+
|
|
37
|
+
// Event Handlers
|
|
38
|
+
const handleClick = (event: React.MouseEvent): void => {
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
event.stopPropagation();
|
|
41
|
+
};
|
|
42
|
+
const handleMouseDown = ({ buttons, clientX, clientY }: React.MouseEvent): void => {
|
|
43
|
+
if (buttons !== MOUSE_PRIMARY) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
onDrawStart(clientX, clientY);
|
|
48
|
+
};
|
|
49
|
+
const handleMouseOut = (): void => {
|
|
50
|
+
onMouseOut();
|
|
51
|
+
};
|
|
52
|
+
const handleMouseOver = (): void => {
|
|
53
|
+
onMouseOver();
|
|
54
|
+
};
|
|
55
|
+
const handleTouchCancel = (): void => {
|
|
56
|
+
onDrawStop();
|
|
57
|
+
};
|
|
58
|
+
const handleTouchEnd = (): void => {
|
|
59
|
+
onDrawStop();
|
|
60
|
+
};
|
|
61
|
+
const handleTouchMove = ({ targetTouches }: React.TouchEvent): void => {
|
|
62
|
+
onDrawUpdate(targetTouches[0].clientX, targetTouches[0].clientY);
|
|
63
|
+
};
|
|
64
|
+
const handleTouchStart = ({ targetTouches }: React.TouchEvent): void => {
|
|
65
|
+
onDrawStart(targetTouches[0].clientX, targetTouches[0].clientY);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
React.useEffect(() => {
|
|
69
|
+
const handleMouseMove = ({ buttons, clientX, clientY }: MouseEvent): void => {
|
|
70
|
+
if (buttons !== MOUSE_PRIMARY || status === Status.init) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
onDrawUpdate(clientX, clientY);
|
|
75
|
+
};
|
|
76
|
+
const handleMouseUp = (): void => {
|
|
77
|
+
onDrawStop();
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// Document-level mousemove and mouseup event listeners allow the creator component to respond even if
|
|
81
|
+
// the cursor leaves the drawing area before the mouse button is released, which finishes the shape
|
|
82
|
+
if (status !== Status.init) {
|
|
83
|
+
document.addEventListener('mousemove', handleMouseMove);
|
|
84
|
+
document.addEventListener('mouseup', handleMouseUp);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return () => {
|
|
88
|
+
document.removeEventListener('mousemove', handleMouseMove);
|
|
89
|
+
document.removeEventListener('mouseup', handleMouseUp);
|
|
90
|
+
};
|
|
91
|
+
}, [onDrawStop, onDrawUpdate, status]);
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
// eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
|
|
95
|
+
<div
|
|
96
|
+
ref={ref}
|
|
97
|
+
className={className}
|
|
98
|
+
onClick={handleClick}
|
|
99
|
+
onMouseDown={handleMouseDown}
|
|
100
|
+
onMouseOut={handleMouseOut}
|
|
101
|
+
onMouseOver={handleMouseOver}
|
|
102
|
+
onTouchCancel={handleTouchCancel}
|
|
103
|
+
onTouchEnd={handleTouchEnd}
|
|
104
|
+
onTouchMove={handleTouchMove}
|
|
105
|
+
onTouchStart={handleTouchStart}
|
|
106
|
+
role="presentation"
|
|
107
|
+
{...rest}
|
|
108
|
+
>
|
|
109
|
+
{children}
|
|
110
|
+
</div>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export { PointerCapture as PointerCaptureBase };
|
|
115
|
+
|
|
116
|
+
export default React.forwardRef(PointerCapture);
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
@mixin ba-PopupArrow($size, $top-bg, $right-bg, $bottom-bg, $left-bg, $border-color) {
|
|
2
|
+
// Top-facing arrows
|
|
3
|
+
&[data-popper-placement*='bottom'] {
|
|
4
|
+
.ba-Popup-arrow {
|
|
5
|
+
top: -#{$size - 1};
|
|
6
|
+
|
|
7
|
+
&::before,
|
|
8
|
+
&::after {
|
|
9
|
+
transform: rotate(180deg) translateX(50%);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&::after {
|
|
13
|
+
top: 1px;
|
|
14
|
+
border-top-color: $top-bg;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Right-facing arrows
|
|
20
|
+
&[data-popper-placement*='left'] {
|
|
21
|
+
.ba-Popup-arrow {
|
|
22
|
+
right: 0;
|
|
23
|
+
|
|
24
|
+
&::before,
|
|
25
|
+
&::after {
|
|
26
|
+
transform: rotate(-90deg) translateY(-100%);
|
|
27
|
+
transform-origin: center top;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&::after {
|
|
31
|
+
left: -1px;
|
|
32
|
+
border-top-color: $right-bg;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Left-facing arrows
|
|
38
|
+
&[data-popper-placement*='right'] {
|
|
39
|
+
.ba-Popup-arrow {
|
|
40
|
+
left: -#{$size - 1};
|
|
41
|
+
|
|
42
|
+
&::before,
|
|
43
|
+
&::after {
|
|
44
|
+
transform: rotate(90deg);
|
|
45
|
+
transform-origin: center top;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&::after {
|
|
49
|
+
left: 1px;
|
|
50
|
+
border-top-color: $left-bg;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Bottom-facing arrows
|
|
56
|
+
&[data-popper-placement*='top'] {
|
|
57
|
+
.ba-Popup-arrow {
|
|
58
|
+
top: auto;
|
|
59
|
+
bottom: 0;
|
|
60
|
+
|
|
61
|
+
&::before,
|
|
62
|
+
&::after {
|
|
63
|
+
transform: rotate(0) translateX(-50%);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&::after {
|
|
67
|
+
top: -1px;
|
|
68
|
+
border-top-color: $bottom-bg;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.ba-Popup-arrow {
|
|
74
|
+
&::before,
|
|
75
|
+
&::after {
|
|
76
|
+
position: absolute;
|
|
77
|
+
display: block;
|
|
78
|
+
border-right: $size solid transparent;
|
|
79
|
+
border-left: $size solid transparent;
|
|
80
|
+
content: '';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
&::before {
|
|
84
|
+
border-top: $size solid $border-color;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&::after {
|
|
88
|
+
border-top: $size solid;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -1,100 +1,31 @@
|
|
|
1
1
|
@import '~box-ui-elements/es/styles/variables';
|
|
2
|
+
@import './PopupArrow';
|
|
2
3
|
|
|
3
4
|
.ba {
|
|
4
|
-
$popup-arrow-size: 12px;
|
|
5
5
|
$popup-content-bg: $white;
|
|
6
6
|
$popup-border-color: $bdl-gray-20;
|
|
7
7
|
$popup-footer-bg: $bdl-gray-02;
|
|
8
8
|
|
|
9
9
|
.ba-Popup {
|
|
10
10
|
@include common-typography;
|
|
11
|
+
@include ba-PopupArrow(12px, $popup-content-bg, $popup-content-bg, $popup-footer-bg, $popup-content-bg, $popup-border-color);
|
|
11
12
|
|
|
12
|
-
z-index: 1;
|
|
13
|
-
|
|
14
|
-
// Top-facing arrows
|
|
15
|
-
&[data-popper-placement*='bottom'] {
|
|
16
|
-
.ba-Popup-arrow {
|
|
17
|
-
top: -#{$popup-arrow-size - 1};
|
|
18
|
-
|
|
19
|
-
&::before,
|
|
20
|
-
&::after {
|
|
21
|
-
transform: rotate(180deg) translateX(50%);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
&::after {
|
|
25
|
-
top: 1px;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Right-facing arrows
|
|
31
|
-
&[data-popper-placement*='left'] {
|
|
32
|
-
.ba-Popup-arrow {
|
|
33
|
-
right: 0;
|
|
34
|
-
|
|
35
|
-
&::before,
|
|
36
|
-
&::after {
|
|
37
|
-
transform: rotate(-90deg) translateY(-100%);
|
|
38
|
-
transform-origin: center top;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
&::after {
|
|
42
|
-
left: -1px;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Left-facing arrows
|
|
48
|
-
&[data-popper-placement*='right'] {
|
|
49
|
-
.ba-Popup-arrow {
|
|
50
|
-
left: -#{$popup-arrow-size - 1};
|
|
51
|
-
|
|
52
|
-
&::before,
|
|
53
|
-
&::after {
|
|
54
|
-
transform: rotate(90deg);
|
|
55
|
-
transform-origin: center top;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
&::after {
|
|
59
|
-
left: 1px;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Bottom-facing arrows
|
|
65
|
-
&[data-popper-placement*='top'] {
|
|
66
|
-
.ba-Popup-arrow {
|
|
67
|
-
top: auto;
|
|
68
|
-
bottom: 0;
|
|
69
|
-
|
|
70
|
-
&::before,
|
|
71
|
-
&::after {
|
|
72
|
-
transform: rotate(0) translateX(-50%);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
&::after {
|
|
76
|
-
top: -1px;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
13
|
+
z-index: 1; // Make sure popup is showing above Preview controls and left/right arrows
|
|
80
14
|
}
|
|
81
15
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
display: block;
|
|
87
|
-
border-right: $popup-arrow-size solid transparent;
|
|
88
|
-
border-left: $popup-arrow-size solid transparent;
|
|
89
|
-
content: '';
|
|
16
|
+
// The following media query is specific to IE10+
|
|
17
|
+
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
|
|
18
|
+
.ba-Popup {
|
|
19
|
+
z-index: 0; // Changing z-index causes page to flicker in IE11
|
|
90
20
|
}
|
|
91
21
|
|
|
92
|
-
|
|
93
|
-
|
|
22
|
+
.ba-ItemList {
|
|
23
|
+
// stylelint-disable-next-line declaration-no-important
|
|
24
|
+
max-height: 140px !important; // Prevent list overflow onto subsequent pages in IE11
|
|
94
25
|
}
|
|
95
26
|
|
|
96
|
-
|
|
97
|
-
|
|
27
|
+
.ba-ReplyForm {
|
|
28
|
+
opacity: .99; // Creates a new stacking context so that the collaborators list shows on top of the ba-Popup-footer
|
|
98
29
|
}
|
|
99
30
|
}
|
|
100
31
|
|
|
@@ -50,7 +50,7 @@ export default function PopupCursor(): JSX.Element {
|
|
|
50
50
|
return () => {
|
|
51
51
|
document.removeEventListener('mousemove', handleMouseMove);
|
|
52
52
|
};
|
|
53
|
-
});
|
|
53
|
+
}, []);
|
|
54
54
|
|
|
55
55
|
return (
|
|
56
56
|
<PopupBase ref={popupRef} className="ba-PopupCursor" options={options} reference={virtualElementRef.current}>
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
@import '~box-ui-elements/es/styles/variables';
|
|
2
|
+
|
|
3
|
+
@mixin ba-PopupDrawingToolbarButton($width: 32px, $height: 32px) {
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
justify-content: center;
|
|
7
|
+
width: $width;
|
|
8
|
+
height: $height;
|
|
9
|
+
padding: 0;
|
|
10
|
+
color: $white;
|
|
11
|
+
background: transparent;
|
|
12
|
+
border: none;
|
|
13
|
+
border-radius: $bdl-border-radius-size;
|
|
14
|
+
outline: none;
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
opacity: .7;
|
|
17
|
+
transition: opacity 200ms ease;
|
|
18
|
+
|
|
19
|
+
&:focus,
|
|
20
|
+
&:hover {
|
|
21
|
+
opacity: 1;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&[disabled] {
|
|
25
|
+
cursor: default;
|
|
26
|
+
opacity: .2;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.ba-PopupDrawingToolbar {
|
|
31
|
+
background-color: $bdl-gray;
|
|
32
|
+
border-radius: $bdl-border-radius-size;
|
|
33
|
+
|
|
34
|
+
.ba-Popup-arrow {
|
|
35
|
+
display: none;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.ba-Popup-content {
|
|
39
|
+
display: flex;
|
|
40
|
+
background-color: $bdl-gray;
|
|
41
|
+
border: none;
|
|
42
|
+
border-radius: $bdl-border-radius-size;
|
|
43
|
+
box-shadow: none;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.ba-PopupDrawingToolbar-group {
|
|
48
|
+
position: relative;
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
justify-content: center;
|
|
52
|
+
|
|
53
|
+
& + & {
|
|
54
|
+
border-left: 1px solid #000;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.ba-PopupDrawingToolbar-delete,
|
|
59
|
+
.ba-PopupDrawingToolbar-redo,
|
|
60
|
+
.ba-PopupDrawingToolbar-undo {
|
|
61
|
+
@include ba-PopupDrawingToolbarButton;
|
|
62
|
+
|
|
63
|
+
path {
|
|
64
|
+
fill: #fff;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.ba-PopupDrawingToolbar-comment {
|
|
69
|
+
@include ba-PopupDrawingToolbarButton($width: max-content);
|
|
70
|
+
@include common-typography;
|
|
71
|
+
|
|
72
|
+
padding-right: 18px;
|
|
73
|
+
padding-left: 18px;
|
|
74
|
+
color: $white;
|
|
75
|
+
font-weight: bold;
|
|
76
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { FormattedMessage, useIntl } from 'react-intl';
|
|
4
|
+
import IconRedo from 'box-ui-elements/es/icon/line/Redo16';
|
|
5
|
+
import IconTrash from 'box-ui-elements/es/icon/line/Trash16';
|
|
6
|
+
import IconUndo from 'box-ui-elements/es/icon/line/Undo16';
|
|
7
|
+
import messages from './messages';
|
|
8
|
+
import PopupBase from './PopupBase';
|
|
9
|
+
import { Options, PopupReference, Rect } from './Popper';
|
|
10
|
+
import './PopupDrawingToolbar.scss';
|
|
11
|
+
|
|
12
|
+
export type PopupBaseRef = PopupBase;
|
|
13
|
+
|
|
14
|
+
export type Props = {
|
|
15
|
+
canComment: boolean;
|
|
16
|
+
canRedo: boolean;
|
|
17
|
+
canUndo: boolean;
|
|
18
|
+
className?: string;
|
|
19
|
+
onDelete: () => void;
|
|
20
|
+
onRedo: () => void;
|
|
21
|
+
onReply: () => void;
|
|
22
|
+
onUndo: () => void;
|
|
23
|
+
reference: PopupReference;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const options: Partial<Options> = {
|
|
27
|
+
modifiers: [
|
|
28
|
+
{
|
|
29
|
+
name: 'eventListeners',
|
|
30
|
+
options: {
|
|
31
|
+
scroll: false,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'offset',
|
|
36
|
+
options: {
|
|
37
|
+
offset: ({ popper }: { popper: Rect }) => [-popper.width / 2, 8],
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'preventOverflow',
|
|
42
|
+
options: {
|
|
43
|
+
altAxis: true,
|
|
44
|
+
padding: 50,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
placement: 'top',
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const PopupDrawingToolbar = (props: Props, ref: React.Ref<PopupBaseRef>): JSX.Element => {
|
|
52
|
+
const { canComment, canRedo, canUndo, className, onDelete, onRedo, onReply, onUndo, reference } = props;
|
|
53
|
+
const intl = useIntl();
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<PopupBase
|
|
57
|
+
ref={ref}
|
|
58
|
+
className={classNames(className, 'ba-PopupDrawingToolbar')}
|
|
59
|
+
data-resin-component="popupDrawingToolbar"
|
|
60
|
+
options={options}
|
|
61
|
+
reference={reference}
|
|
62
|
+
>
|
|
63
|
+
<div className="ba-PopupDrawingToolbar-group">
|
|
64
|
+
<button
|
|
65
|
+
className="ba-PopupDrawingToolbar-undo"
|
|
66
|
+
data-testid="ba-PopupDrawingToolbar-undo"
|
|
67
|
+
disabled={!canUndo}
|
|
68
|
+
onClick={() => onUndo()}
|
|
69
|
+
title={intl.formatMessage(messages.drawingButtonUndo)}
|
|
70
|
+
type="button"
|
|
71
|
+
>
|
|
72
|
+
<IconUndo />
|
|
73
|
+
</button>
|
|
74
|
+
<button
|
|
75
|
+
className="ba-PopupDrawingToolbar-redo"
|
|
76
|
+
data-testid="ba-PopupDrawingToolbar-redo"
|
|
77
|
+
disabled={!canRedo}
|
|
78
|
+
onClick={() => onRedo()}
|
|
79
|
+
title={intl.formatMessage(messages.drawingButtonRedo)}
|
|
80
|
+
type="button"
|
|
81
|
+
>
|
|
82
|
+
<IconRedo />
|
|
83
|
+
</button>
|
|
84
|
+
<button
|
|
85
|
+
className="ba-PopupDrawingToolbar-delete"
|
|
86
|
+
data-testid="ba-PopupDrawingToolbar-delete"
|
|
87
|
+
onClick={() => onDelete()}
|
|
88
|
+
title={intl.formatMessage(messages.drawingButtonDelete)}
|
|
89
|
+
type="button"
|
|
90
|
+
>
|
|
91
|
+
<IconTrash />
|
|
92
|
+
</button>
|
|
93
|
+
</div>
|
|
94
|
+
<div className="ba-PopupDrawingToolbar-group">
|
|
95
|
+
<button
|
|
96
|
+
className="ba-PopupDrawingToolbar-comment"
|
|
97
|
+
data-testid="ba-PopupDrawingToolbar-comment"
|
|
98
|
+
disabled={!canComment}
|
|
99
|
+
onClick={() => onReply()}
|
|
100
|
+
type="button"
|
|
101
|
+
>
|
|
102
|
+
<FormattedMessage {...messages.drawingButtonAddComment} />
|
|
103
|
+
</button>
|
|
104
|
+
</div>
|
|
105
|
+
</PopupBase>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export default React.forwardRef(PopupDrawingToolbar);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
@import '~box-ui-elements/es/styles/variables';
|
|
2
|
+
@import './PopupArrow';
|
|
3
|
+
|
|
4
|
+
.ba {
|
|
5
|
+
$popup-content-bg: $bdl-gray;
|
|
6
|
+
|
|
7
|
+
.ba-PopupHighlight {
|
|
8
|
+
@include ba-PopupArrow(4px, $popup-content-bg, $popup-content-bg, $popup-content-bg, $popup-content-bg, $popup-content-bg);
|
|
9
|
+
|
|
10
|
+
.ba-Popup-content {
|
|
11
|
+
background-color: $popup-content-bg;
|
|
12
|
+
border: none;
|
|
13
|
+
border-radius: $bdl-border-radius-size;
|
|
14
|
+
box-shadow: none;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.ba-PopupHighlight-button {
|
|
19
|
+
@include common-typography;
|
|
20
|
+
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: row;
|
|
23
|
+
align-items: center;
|
|
24
|
+
padding: 5px 10px;
|
|
25
|
+
color: $white;
|
|
26
|
+
background: transparent;
|
|
27
|
+
border: none;
|
|
28
|
+
border-radius: $bdl-border-radius-size;
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.ba-PopupHighlight-icon {
|
|
33
|
+
margin-right: 8px;
|
|
34
|
+
|
|
35
|
+
path {
|
|
36
|
+
fill: $white;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|