box-annotations 4.0.0 → 4.1.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/README.md +7 -56
- package/dist/annotations.css +1 -1
- package/dist/annotations.js +1 -1
- package/i18n/ja-JP.js +1 -1
- package/i18n/ja-JP.properties +1 -1
- package/package.json +20 -22
- package/src/common/useOutsideEvent.ts +3 -3
- package/src/components/Popups/PopupHighlight.tsx +20 -6
- package/src/highlight/HighlightAnnotations.tsx +5 -6
package/i18n/ja-JP.js
CHANGED
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
"ba.popups.cancel": "キャンセル",
|
|
8
8
|
"ba.popups.drawing.addComment": "コメントを追加",
|
|
9
9
|
"ba.popups.drawing.delete": "削除",
|
|
10
|
-
"ba.popups.drawing.redo": "
|
|
10
|
+
"ba.popups.drawing.redo": "やり直す",
|
|
11
11
|
"ba.popups.drawing.undo": "元に戻す",
|
|
12
12
|
"ba.popups.popupCursor.regionPrompt": "四角を描いてコメント",
|
|
13
13
|
"ba.popups.popupHighlight.promoter": "ハイライトとコメント",
|
package/i18n/ja-JP.properties
CHANGED
|
@@ -15,7 +15,7 @@ ba.popups.drawing.addComment = コメントを追加
|
|
|
15
15
|
# Button title for deleting a staged drawing
|
|
16
16
|
ba.popups.drawing.delete = 削除
|
|
17
17
|
# Button title for redoing a staged drawing
|
|
18
|
-
ba.popups.drawing.redo =
|
|
18
|
+
ba.popups.drawing.redo = やり直す
|
|
19
19
|
# Button title for undoing a staged drawing
|
|
20
20
|
ba.popups.drawing.undo = 元に戻す
|
|
21
21
|
# Prompt message following cursor in region annotations mode
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "box-annotations",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Box Annotations",
|
|
5
5
|
"author": "Box (https://www.box.com/)",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -15,27 +15,6 @@
|
|
|
15
15
|
"node": ">=10.x",
|
|
16
16
|
"yarn": ">=1.10.x"
|
|
17
17
|
},
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"@formatjs/intl-pluralrules": "^1.5.5",
|
|
20
|
-
"@formatjs/intl-relativetimeformat": "^4.5.12",
|
|
21
|
-
"@popperjs/core": "^2.4.0",
|
|
22
|
-
"@reduxjs/toolkit": "^1.3.5",
|
|
23
|
-
"axios": "^0.19.2",
|
|
24
|
-
"box-ui-elements": "^12.1.0-beta.42",
|
|
25
|
-
"classnames": "^2.2.5",
|
|
26
|
-
"draft-js": "0.10.5",
|
|
27
|
-
"formik": "^2.1.4",
|
|
28
|
-
"lodash": "^4.17.15",
|
|
29
|
-
"react": "^17.0.1",
|
|
30
|
-
"react-dom": "^17.0.1",
|
|
31
|
-
"react-intl": "^3.12.0",
|
|
32
|
-
"react-redux": "^7.2.2",
|
|
33
|
-
"react-tether": "1.0.5",
|
|
34
|
-
"react-textarea-autosize": "^7.1.2",
|
|
35
|
-
"redux": "^4.0.5",
|
|
36
|
-
"scroll-into-view-if-needed": "^2.2.24",
|
|
37
|
-
"uuid": "^8.3.1"
|
|
38
|
-
},
|
|
39
18
|
"devDependencies": {
|
|
40
19
|
"@babel/cli": "^7.8.4",
|
|
41
20
|
"@babel/core": "^7.9.0",
|
|
@@ -51,6 +30,10 @@
|
|
|
51
30
|
"@box/languages": "^1.1.0",
|
|
52
31
|
"@commitlint/cli": "^8.3.5",
|
|
53
32
|
"@commitlint/config-conventional": "^8.2.0",
|
|
33
|
+
"@formatjs/intl-pluralrules": "^1.5.5",
|
|
34
|
+
"@formatjs/intl-relativetimeformat": "^4.5.12",
|
|
35
|
+
"@popperjs/core": "^2.4.0",
|
|
36
|
+
"@reduxjs/toolkit": "^1.3.5",
|
|
54
37
|
"@types/classnames": "^2.2.10",
|
|
55
38
|
"@types/draft-js": "^0.10.40",
|
|
56
39
|
"@types/enzyme": "^3.10.5",
|
|
@@ -64,6 +47,7 @@
|
|
|
64
47
|
"@typescript-eslint/parser": "^2.29.0",
|
|
65
48
|
"@wojtekmaj/enzyme-adapter-react-17": "^0.4.1",
|
|
66
49
|
"autoprefixer": "^9.7.6",
|
|
50
|
+
"axios": "^0.24.0",
|
|
67
51
|
"babel-eslint": "^10.1.0",
|
|
68
52
|
"babel-jest": "^24.9.0",
|
|
69
53
|
"babel-loader": "^8.1.0",
|
|
@@ -71,11 +55,14 @@
|
|
|
71
55
|
"babel-plugin-react-intl": "^7.5.1",
|
|
72
56
|
"babel-plugin-transform-require-ignore": "^0.1.1",
|
|
73
57
|
"box-node-sdk": "^1.33.0",
|
|
58
|
+
"box-ui-elements": "^15.0.0-beta.6",
|
|
74
59
|
"circular-dependency-plugin": "^5.2.0",
|
|
60
|
+
"classnames": "^2.2.5",
|
|
75
61
|
"conventional-github-releaser": "^3.1.3",
|
|
76
62
|
"core-js": "^3.6.5",
|
|
77
63
|
"css-loader": "^3.5.2",
|
|
78
64
|
"cypress": "^4.4.1",
|
|
65
|
+
"draft-js": "0.10.5",
|
|
79
66
|
"enzyme": "^3.11.0",
|
|
80
67
|
"enzyme-to-json": "^3.4.4",
|
|
81
68
|
"eslint": "^6.7.2",
|
|
@@ -92,11 +79,13 @@
|
|
|
92
79
|
"eslint-plugin-prettier": "^3.1.3",
|
|
93
80
|
"eslint-plugin-react": "^7.19.0",
|
|
94
81
|
"eslint-plugin-react-hooks": "^1.7.0",
|
|
82
|
+
"formik": "^2.1.4",
|
|
95
83
|
"husky": "^3.1.0",
|
|
96
84
|
"jest": "^24.9.0",
|
|
97
85
|
"jest-canvas-mock": "^2.2.0",
|
|
98
86
|
"jest-environment-jsdom-sixteen": "^1.0.3",
|
|
99
87
|
"lint-staged": "^9.5.0",
|
|
88
|
+
"lodash": "^4.17.15",
|
|
100
89
|
"mini-css-extract-plugin": "^0.9.0",
|
|
101
90
|
"node-sass": "^4.13.1",
|
|
102
91
|
"npm-run-all": "^4.1.5",
|
|
@@ -104,7 +93,15 @@
|
|
|
104
93
|
"postcss-loader": "^3.0.0",
|
|
105
94
|
"prettier": "^1.19.1",
|
|
106
95
|
"raw-loader": "^4.0.1",
|
|
96
|
+
"react": "^17.0.1",
|
|
97
|
+
"react-dom": "^17.0.1",
|
|
98
|
+
"react-intl": "^3.12.0",
|
|
99
|
+
"react-redux": "^7.2.2",
|
|
100
|
+
"react-tether": "1.0.5",
|
|
101
|
+
"react-textarea-autosize": "^7.1.2",
|
|
102
|
+
"redux": "^4.0.5",
|
|
107
103
|
"sass-loader": "^8.0.2",
|
|
104
|
+
"scroll-into-view-if-needed": "^2.2.24",
|
|
108
105
|
"style-loader": "^1.1.4",
|
|
109
106
|
"stylelint": "^12.0.0",
|
|
110
107
|
"stylelint-config-rational-order": "^0.1.2",
|
|
@@ -112,6 +109,7 @@
|
|
|
112
109
|
"stylelint-order": "^3.1.1",
|
|
113
110
|
"typescript": "^3.8.3",
|
|
114
111
|
"uglifyjs-webpack-plugin": "^2.2.0",
|
|
112
|
+
"uuid": "^8.3.1",
|
|
115
113
|
"wait-on": "^4.0.2",
|
|
116
114
|
"webpack": "^4.43.0",
|
|
117
115
|
"webpack-cli": "^3.3.11",
|
|
@@ -4,15 +4,15 @@ import * as React from 'react';
|
|
|
4
4
|
export default function useOutsideEvent(
|
|
5
5
|
type: string,
|
|
6
6
|
ref?: React.RefObject<Element> | Element | null,
|
|
7
|
-
callback?:
|
|
7
|
+
callback?: EventListener,
|
|
8
8
|
): void {
|
|
9
9
|
React.useEffect(() => {
|
|
10
|
-
function handleEvent(event:
|
|
10
|
+
function handleEvent<T extends Event>(event: T): void {
|
|
11
11
|
const element = ref instanceof Element ? ref : ref?.current;
|
|
12
12
|
const containsEventTarget = !!element?.contains(event.target as Node);
|
|
13
13
|
|
|
14
14
|
if (callback && !containsEventTarget) {
|
|
15
|
-
callback();
|
|
15
|
+
callback(event);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -11,7 +11,7 @@ import './PopupHighlight.scss';
|
|
|
11
11
|
|
|
12
12
|
export type Props = {
|
|
13
13
|
onCancel?: () => void;
|
|
14
|
-
|
|
14
|
+
onSubmit?: () => void;
|
|
15
15
|
shape: Shape;
|
|
16
16
|
};
|
|
17
17
|
|
|
@@ -45,7 +45,7 @@ const options: Partial<Options> = {
|
|
|
45
45
|
placement: 'bottom',
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
export default function PopupHighlight({ onCancel = noop,
|
|
48
|
+
export default function PopupHighlight({ onCancel = noop, onSubmit = noop, shape }: Props): JSX.Element {
|
|
49
49
|
const buttonRef = React.useRef<HTMLButtonElement>(null);
|
|
50
50
|
const { height, width, x, y } = shape;
|
|
51
51
|
|
|
@@ -60,19 +60,33 @@ export default function PopupHighlight({ onCancel = noop, onClick = noop, shape
|
|
|
60
60
|
}),
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
const
|
|
64
|
-
|
|
63
|
+
const handleKeydownOutside = (event: Event): void => {
|
|
64
|
+
if (!(event instanceof KeyboardEvent) || event.key !== 'Enter' || event.ctrlKey || event.metaKey) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
event.preventDefault(); // Consume any enter keydown event if the promoter is open
|
|
69
|
+
event.stopPropagation(); // Prevent the enter keydown event from adding a new line to the textarea
|
|
70
|
+
|
|
71
|
+
onSubmit();
|
|
65
72
|
};
|
|
66
73
|
|
|
74
|
+
useOutsideEvent('keydown', buttonRef, handleKeydownOutside);
|
|
67
75
|
useOutsideEvent('mousedown', buttonRef, onCancel);
|
|
68
76
|
|
|
69
77
|
return (
|
|
70
|
-
<PopupBase
|
|
78
|
+
<PopupBase
|
|
79
|
+
aria-live="polite"
|
|
80
|
+
className="ba-PopupHighlight"
|
|
81
|
+
options={options}
|
|
82
|
+
reference={reference}
|
|
83
|
+
role="dialog"
|
|
84
|
+
>
|
|
71
85
|
<button
|
|
72
86
|
ref={buttonRef}
|
|
73
87
|
className="ba-PopupHighlight-button"
|
|
74
88
|
data-testid="ba-PopupHighlight-button"
|
|
75
|
-
onClick={
|
|
89
|
+
onClick={onSubmit}
|
|
76
90
|
type="button"
|
|
77
91
|
>
|
|
78
92
|
<IconHighlightTextAnnotation className="ba-PopupHighlight-icon" />
|
|
@@ -70,16 +70,15 @@ const HighlightAnnotations = (props: Props): JSX.Element => {
|
|
|
70
70
|
setStatus(CreatorStatus.staged);
|
|
71
71
|
}, [selection, setStaged, setStatus]);
|
|
72
72
|
|
|
73
|
+
const handleCancel = (): void => {
|
|
74
|
+
setSelection(null);
|
|
75
|
+
};
|
|
76
|
+
|
|
73
77
|
const handlePromote = (): void => {
|
|
74
78
|
stageSelection();
|
|
75
|
-
|
|
76
79
|
setIsPromoting(true);
|
|
77
80
|
};
|
|
78
81
|
|
|
79
|
-
const handleCancel = (): void => {
|
|
80
|
-
setSelection(null);
|
|
81
|
-
};
|
|
82
|
-
|
|
83
82
|
const handleStagedMount = (uuid: string): void => {
|
|
84
83
|
setReferenceId(uuid);
|
|
85
84
|
};
|
|
@@ -126,7 +125,7 @@ const HighlightAnnotations = (props: Props): JSX.Element => {
|
|
|
126
125
|
<div className="ba-HighlightAnnotations-popup">
|
|
127
126
|
<PopupHighlight
|
|
128
127
|
onCancel={handleCancel}
|
|
129
|
-
|
|
128
|
+
onSubmit={handlePromote}
|
|
130
129
|
shape={getBoundingRect(selection.rects)}
|
|
131
130
|
/>
|
|
132
131
|
</div>
|