box-annotations 4.1.1-beta.1 → 4.1.1-beta.3
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/dist/annotations.js +1 -1
- package/i18n/en-US.js +1 -0
- package/i18n/en-US.properties +2 -0
- package/i18n/json/src/components/Popups/messages.json +1 -1
- package/package.json +2 -1
- package/src/components/Popups/PopupHighlight.tsx +1 -0
- package/src/components/Popups/PopupReply.tsx +22 -9
- package/src/components/Popups/messages.ts +5 -0
- package/src/components/ReplyField/ReplyField.tsx +2 -0
- package/src/document/DocumentAnnotator.ts +9 -3
- package/src/document/docUtil.ts +4 -0
package/i18n/en-US.js
CHANGED
|
@@ -4,6 +4,7 @@ export default {
|
|
|
4
4
|
"ba.annotationsLoadError": "We’re sorry, the annotations failed to load for this file.",
|
|
5
5
|
"ba.annotationsPost": "Post",
|
|
6
6
|
"ba.annotationsSave": "Save",
|
|
7
|
+
"ba.popup.reply.comment": "Comment",
|
|
7
8
|
"ba.popups.cancel": "Cancel",
|
|
8
9
|
"ba.popups.drawing.addComment": "Add Comment",
|
|
9
10
|
"ba.popups.drawing.delete": "Delete",
|
package/i18n/en-US.properties
CHANGED
|
@@ -8,6 +8,8 @@ ba.annotationsLoadError = We’re sorry, the annotations failed to load for this
|
|
|
8
8
|
ba.annotationsPost = Post
|
|
9
9
|
# Label for the save button
|
|
10
10
|
ba.annotationsSave = Save
|
|
11
|
+
# Aria label description for reply popup
|
|
12
|
+
ba.popup.reply.comment = Comment
|
|
11
13
|
# Button label for cancelling the creation of a description, comment, or reply
|
|
12
14
|
ba.popups.cancel = Cancel
|
|
13
15
|
# Button label for adding a comment in the drawing toolbar
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"id":"ba.popups.cancel","description":"Button label for cancelling the creation of a description, comment, or reply","defaultMessage":"Cancel"},{"id":"ba.popups.post","description":"Button label for creating a description, comment, or reply","defaultMessage":"Post"},{"id":"ba.popups.drawing.addComment","description":"Button label for adding a comment in the drawing toolbar","defaultMessage":"Add Comment"},{"id":"ba.popups.drawing.delete","description":"Button title for deleting a staged drawing","defaultMessage":"Delete"},{"id":"ba.popups.drawing.redo","description":"Button title for redoing a staged drawing","defaultMessage":"Redo"},{"id":"ba.popups.drawing.undo","description":"Button title for undoing a staged drawing","defaultMessage":"Undo"},{"id":"ba.popups.replyField.placeholder","description":"Placeholder for reply field editor","defaultMessage":"Type a comment..."},{"id":"ba.popups.popupHighlight.promoter","description":"Popup message for highlight promoter","defaultMessage":"Highlight and Comment"},{"id":"ba.popups.popupHighlight.restrictedPrompt","description":"Prompt message when selection crosses multiple pages","defaultMessage":"Comments restricted to single page"},{"id":"ba.popups.popupList.prompt","description":"Prompt message for empty popup list","defaultMessage":"Mention someone to notify them"},{"id":"ba.popups.popupCursor.regionPrompt","description":"Prompt message following cursor in region annotations mode","defaultMessage":"Draw a box to comment"}]
|
|
1
|
+
[{"id":"ba.popup.reply.comment","description":"Aria label description for reply popup","defaultMessage":"Comment"},{"id":"ba.popups.cancel","description":"Button label for cancelling the creation of a description, comment, or reply","defaultMessage":"Cancel"},{"id":"ba.popups.post","description":"Button label for creating a description, comment, or reply","defaultMessage":"Post"},{"id":"ba.popups.drawing.addComment","description":"Button label for adding a comment in the drawing toolbar","defaultMessage":"Add Comment"},{"id":"ba.popups.drawing.delete","description":"Button title for deleting a staged drawing","defaultMessage":"Delete"},{"id":"ba.popups.drawing.redo","description":"Button title for redoing a staged drawing","defaultMessage":"Redo"},{"id":"ba.popups.drawing.undo","description":"Button title for undoing a staged drawing","defaultMessage":"Undo"},{"id":"ba.popups.replyField.placeholder","description":"Placeholder for reply field editor","defaultMessage":"Type a comment..."},{"id":"ba.popups.popupHighlight.promoter","description":"Popup message for highlight promoter","defaultMessage":"Highlight and Comment"},{"id":"ba.popups.popupHighlight.restrictedPrompt","description":"Prompt message when selection crosses multiple pages","defaultMessage":"Comments restricted to single page"},{"id":"ba.popups.popupList.prompt","description":"Prompt message for empty popup list","defaultMessage":"Mention someone to notify them"},{"id":"ba.popups.popupCursor.regionPrompt","description":"Prompt message following cursor in region annotations mode","defaultMessage":"Draw a box to comment"}]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "box-annotations",
|
|
3
|
-
"version": "4.1.1-beta.
|
|
3
|
+
"version": "4.1.1-beta.3",
|
|
4
4
|
"description": "Box Annotations",
|
|
5
5
|
"author": "Box (https://www.box.com/)",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -107,6 +107,7 @@
|
|
|
107
107
|
"stylelint-config-rational-order": "^0.1.2",
|
|
108
108
|
"stylelint-config-standard": "^19.0.0",
|
|
109
109
|
"stylelint-order": "^3.1.1",
|
|
110
|
+
"tabbable": "^1.1.3",
|
|
110
111
|
"typescript": "^3.8.3",
|
|
111
112
|
"uglifyjs-webpack-plugin": "^2.2.0",
|
|
112
113
|
"uuid": "^8.3.1",
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import * as Popper from '@popperjs/core';
|
|
3
3
|
import * as ReactRedux from 'react-redux';
|
|
4
|
+
import { useIntl } from 'react-intl';
|
|
5
|
+
import FocusTrap from 'box-ui-elements/es/components/focus-trap/FocusTrap';
|
|
6
|
+
import messages from './messages';
|
|
4
7
|
import PopupBase from './PopupBase';
|
|
5
8
|
import ReplyForm from '../ReplyForm';
|
|
6
9
|
import usePrevious from '../../common/usePrevious';
|
|
@@ -83,6 +86,7 @@ export default function PopupReply({
|
|
|
83
86
|
value = '',
|
|
84
87
|
...rest
|
|
85
88
|
}: Props): JSX.Element {
|
|
89
|
+
const intl = useIntl();
|
|
86
90
|
const popupRef = React.useRef<PopupBase>(null);
|
|
87
91
|
const popupOptions = React.useRef<Partial<Popper.Options>>(getOptions()); // Keep the options reference the same between renders
|
|
88
92
|
const rotation = ReactRedux.useSelector(getRotation);
|
|
@@ -99,14 +103,23 @@ export default function PopupReply({
|
|
|
99
103
|
}, [popupRef, prevRotation, prevScale, rotation, scale]);
|
|
100
104
|
|
|
101
105
|
return (
|
|
102
|
-
<
|
|
103
|
-
<
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
<FocusTrap>
|
|
107
|
+
<PopupBase
|
|
108
|
+
ref={popupRef}
|
|
109
|
+
aria-label={intl.formatMessage(messages.ariaLabelComment)}
|
|
110
|
+
data-resin-component="popupReply"
|
|
111
|
+
options={popupOptions.current}
|
|
112
|
+
role="dialog"
|
|
113
|
+
{...rest}
|
|
114
|
+
>
|
|
115
|
+
<ReplyForm
|
|
116
|
+
isPending={isPending}
|
|
117
|
+
onCancel={onCancel}
|
|
118
|
+
onChange={onChange}
|
|
119
|
+
onSubmit={onSubmit}
|
|
120
|
+
value={value}
|
|
121
|
+
/>
|
|
122
|
+
</PopupBase>
|
|
123
|
+
</FocusTrap>
|
|
111
124
|
);
|
|
112
125
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { defineMessages } from 'react-intl';
|
|
2
2
|
|
|
3
3
|
export default defineMessages({
|
|
4
|
+
ariaLabelComment: {
|
|
5
|
+
id: 'ba.popup.reply.comment',
|
|
6
|
+
description: 'Aria label description for reply popup',
|
|
7
|
+
defaultMessage: 'Comment',
|
|
8
|
+
},
|
|
4
9
|
buttonCancel: {
|
|
5
10
|
id: 'ba.popups.cancel',
|
|
6
11
|
description: 'Button label for cancelling the creation of a description, comment, or reply',
|
|
@@ -204,6 +204,7 @@ export default class ReplyField extends React.Component<Props, State> {
|
|
|
204
204
|
<div className={classnames(className, 'ba-ReplyField')}>
|
|
205
205
|
<Editor
|
|
206
206
|
{...rest}
|
|
207
|
+
ariaMultiline
|
|
207
208
|
editorState={editorState}
|
|
208
209
|
handleReturn={this.handleReturn}
|
|
209
210
|
onChange={this.handleChange}
|
|
@@ -212,6 +213,7 @@ export default class ReplyField extends React.Component<Props, State> {
|
|
|
212
213
|
placeholder={placeholder}
|
|
213
214
|
readOnly={isDisabled}
|
|
214
215
|
stripPastedStyles
|
|
216
|
+
tabIndex={0}
|
|
215
217
|
webDriverTestID="ba-ReplyField-editor"
|
|
216
218
|
/>
|
|
217
219
|
|
|
@@ -60,14 +60,20 @@ export default class DocumentAnnotator extends BaseAnnotator {
|
|
|
60
60
|
const pageReferenceEl = this.getPageReference(pageEl);
|
|
61
61
|
const managers = this.managers.get(pageNumber) || new Set();
|
|
62
62
|
const resinTags = { fileid: fileId, iscurrent: isCurrentFileVersion };
|
|
63
|
+
let destroyManagers = false;
|
|
63
64
|
|
|
64
|
-
//
|
|
65
|
+
// If a referenced page element doesn't exist, destroy all managers to keep them in sync
|
|
65
66
|
managers.forEach(manager => {
|
|
66
67
|
if (!manager.exists(pageEl)) {
|
|
67
|
-
|
|
68
|
-
managers.delete(manager);
|
|
68
|
+
destroyManagers = true;
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
|
+
if (destroyManagers) {
|
|
72
|
+
managers.forEach(manager => {
|
|
73
|
+
manager.destroy();
|
|
74
|
+
});
|
|
75
|
+
managers.clear();
|
|
76
|
+
}
|
|
71
77
|
|
|
72
78
|
// Lazily instantiate managers as pages are added or re-rendered
|
|
73
79
|
if (managers.size === 0) {
|
package/src/document/docUtil.ts
CHANGED
|
@@ -39,6 +39,10 @@ export function getSelection(): Selection | null {
|
|
|
39
39
|
// We only care about the last range
|
|
40
40
|
let range = selection.getRangeAt(selection.rangeCount - 1);
|
|
41
41
|
|
|
42
|
+
// Changes to the text layer in PDFjs v2.14.305 require the start range to be set manually for correct highlighting behavior
|
|
43
|
+
const startRange = selection.getRangeAt(0);
|
|
44
|
+
range.setStart(startRange.startContainer, startRange.startOffset);
|
|
45
|
+
|
|
42
46
|
const containerEl = findClosestElWithClass(range.endContainer as Element, 'textLayer');
|
|
43
47
|
const startPage = getPageNumber(range.startContainer as Element);
|
|
44
48
|
const endPage = getPageNumber(range.endContainer as Element);
|