@atlaskit/renderer 109.15.3 → 109.16.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/CHANGELOG.md +11 -0
- package/dist/cjs/react/nodes/media/index.js +11 -3
- package/dist/cjs/ui/Renderer/index.js +1 -1
- package/dist/cjs/ui/annotations/contexts/AnnotationRangeContext.js +34 -8
- package/dist/cjs/ui/annotations/wrapper.js +8 -4
- package/dist/es2019/react/nodes/media/index.js +12 -4
- package/dist/es2019/ui/Renderer/index.js +1 -1
- package/dist/es2019/ui/annotations/contexts/AnnotationRangeContext.js +39 -9
- package/dist/es2019/ui/annotations/wrapper.js +8 -4
- package/dist/esm/react/nodes/media/index.js +12 -4
- package/dist/esm/ui/Renderer/index.js +1 -1
- package/dist/esm/ui/annotations/contexts/AnnotationRangeContext.js +34 -8
- package/dist/esm/ui/annotations/wrapper.js +8 -4
- package/dist/types/ui/annotations/contexts/AnnotationRangeContext.d.ts +4 -3
- package/dist/types-ts4.5/ui/annotations/contexts/AnnotationRangeContext.d.ts +4 -3
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @atlaskit/renderer
|
|
2
2
|
|
|
3
|
+
## 109.16.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#89299](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/89299) [`b462593ddae0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b462593ddae0) - [ED-22909] Update AnnotationRangeDispatchContext with actions to set and clear draft range for hover component
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#89269](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/89269) [`78ee8b68398b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/78ee8b68398b) - Add onClick functionality to comment badge renderer
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
3
14
|
## 109.15.3
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -32,6 +32,7 @@ var _styles = require("./styles");
|
|
|
32
32
|
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
33
33
|
var _reactIntlNext = require("react-intl-next");
|
|
34
34
|
var _hooks = require("../../../ui/annotations/hooks");
|
|
35
|
+
var _types = require("@atlaskit/editor-common/types");
|
|
35
36
|
var _excluded = ["marks"];
|
|
36
37
|
/** @jsx jsx */
|
|
37
38
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
@@ -116,6 +117,7 @@ var CommentBadgeWrapper = function CommentBadgeWrapper(_ref5) {
|
|
|
116
117
|
var _marks$map;
|
|
117
118
|
var marks = _ref5.marks,
|
|
118
119
|
rest = (0, _objectWithoutProperties2.default)(_ref5, _excluded);
|
|
120
|
+
var updateSubscriber = (0, _hooks.useInlineCommentSubscriberContext)();
|
|
119
121
|
var activeParentIds = (0, _hooks.useInlineCommentsFilter)({
|
|
120
122
|
annotationIds: (_marks$map = marks === null || marks === void 0 ? void 0 : marks.map(function (mark) {
|
|
121
123
|
return mark.attrs.id;
|
|
@@ -127,10 +129,16 @@ var CommentBadgeWrapper = function CommentBadgeWrapper(_ref5) {
|
|
|
127
129
|
if (!activeParentIds.length) {
|
|
128
130
|
return null;
|
|
129
131
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
+
var onClick = function onClick(e) {
|
|
133
|
+
if (updateSubscriber) {
|
|
134
|
+
updateSubscriber.emit(_types.AnnotationUpdateEvent.ON_ANNOTATION_CLICK, {
|
|
135
|
+
annotationIds: activeParentIds,
|
|
136
|
+
eventTarget: e.target
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
};
|
|
132
140
|
return (0, _react2.jsx)(CommentBadge, (0, _extends2.default)({
|
|
133
|
-
onClick:
|
|
141
|
+
onClick: onClick
|
|
134
142
|
}, rest));
|
|
135
143
|
};
|
|
136
144
|
var Media = exports.default = /*#__PURE__*/function (_PureComponent) {
|
|
@@ -55,7 +55,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
55
55
|
var NORMAL_SEVERITY_THRESHOLD = exports.NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
56
56
|
var DEGRADED_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
57
57
|
var packageName = "@atlaskit/renderer";
|
|
58
|
-
var packageVersion = "109.
|
|
58
|
+
var packageVersion = "109.16.0";
|
|
59
59
|
var Renderer = exports.Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
60
60
|
(0, _inherits2.default)(Renderer, _PureComponent);
|
|
61
61
|
var _super = _createSuper(Renderer);
|
|
@@ -39,6 +39,13 @@ function reducer(state, action) {
|
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
return state;
|
|
42
|
+
case 'clearDraftHover':
|
|
43
|
+
if (state.type === 'hover') {
|
|
44
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
45
|
+
draftRange: null
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return state;
|
|
42
49
|
case 'clearHover':
|
|
43
50
|
if (state.type === 'hover') {
|
|
44
51
|
return {
|
|
@@ -56,6 +63,14 @@ function reducer(state, action) {
|
|
|
56
63
|
});
|
|
57
64
|
}
|
|
58
65
|
return state;
|
|
66
|
+
case 'setHover':
|
|
67
|
+
if (state.range !== action.range || state.type !== 'hover') {
|
|
68
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
69
|
+
range: action.range,
|
|
70
|
+
type: 'hover'
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return state;
|
|
59
74
|
case 'setDraftSelection':
|
|
60
75
|
if (state.draftRange !== action.draftRange || state.type !== 'selection') {
|
|
61
76
|
return {
|
|
@@ -65,16 +80,14 @@ function reducer(state, action) {
|
|
|
65
80
|
};
|
|
66
81
|
}
|
|
67
82
|
return state;
|
|
68
|
-
case '
|
|
69
|
-
if (state.
|
|
83
|
+
case 'setDraftHover':
|
|
84
|
+
if (state.draftRange !== action.draftRange || state.type !== 'hover') {
|
|
70
85
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
71
|
-
|
|
72
|
-
type: 'hover'
|
|
86
|
+
draftRange: action.draftRange
|
|
73
87
|
});
|
|
74
88
|
}
|
|
75
89
|
return state;
|
|
76
90
|
}
|
|
77
|
-
return state;
|
|
78
91
|
}
|
|
79
92
|
var AnnotationRangeStateContext = exports.AnnotationRangeStateContext = /*#__PURE__*/(0, _react.createContext)({
|
|
80
93
|
range: null,
|
|
@@ -113,8 +126,14 @@ var AnnotationRangeProvider = exports.AnnotationRangeProvider = function Annotat
|
|
|
113
126
|
type: 'clearSelection'
|
|
114
127
|
});
|
|
115
128
|
}, []);
|
|
116
|
-
var clearDraftRange = (0, _react.useCallback)(function () {
|
|
117
|
-
|
|
129
|
+
var clearDraftRange = (0, _react.useCallback)(function (type) {
|
|
130
|
+
if (type === 'hover') {
|
|
131
|
+
dispatch({
|
|
132
|
+
type: 'clearDraftHover'
|
|
133
|
+
});
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
dispatch({
|
|
118
137
|
type: 'clearDraftSelection'
|
|
119
138
|
});
|
|
120
139
|
}, []);
|
|
@@ -129,7 +148,14 @@ var AnnotationRangeProvider = exports.AnnotationRangeProvider = function Annotat
|
|
|
129
148
|
range: range
|
|
130
149
|
});
|
|
131
150
|
}, []);
|
|
132
|
-
var setDraftRange = (0, _react.useCallback)(function (range) {
|
|
151
|
+
var setDraftRange = (0, _react.useCallback)(function (range, type) {
|
|
152
|
+
if (type === 'hover') {
|
|
153
|
+
dispatch({
|
|
154
|
+
type: 'setDraftHover',
|
|
155
|
+
draftRange: range
|
|
156
|
+
});
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
133
159
|
dispatch({
|
|
134
160
|
type: 'setDraftSelection',
|
|
135
161
|
draftRange: range
|
|
@@ -15,7 +15,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
15
15
|
var AnnotationsContextWrapper = exports.AnnotationsContextWrapper = function AnnotationsContextWrapper(props) {
|
|
16
16
|
var providers = (0, _react.useContext)(_context.ProvidersContext);
|
|
17
17
|
var _useAnnotationRangeSt = (0, _AnnotationRangeContext.useAnnotationRangeState)(),
|
|
18
|
-
range = _useAnnotationRangeSt.range
|
|
18
|
+
range = _useAnnotationRangeSt.range,
|
|
19
|
+
type = _useAnnotationRangeSt.type;
|
|
19
20
|
var _useAnnotationRangeDi = (0, _AnnotationRangeContext.useAnnotationRangeDispatch)(),
|
|
20
21
|
setDraftRange = _useAnnotationRangeDi.setDraftRange,
|
|
21
22
|
clearDraftRange = _useAnnotationRangeDi.clearDraftRange;
|
|
@@ -28,8 +29,11 @@ var AnnotationsContextWrapper = exports.AnnotationsContextWrapper = function Ann
|
|
|
28
29
|
|
|
29
30
|
// We want to set the draft to the range the user highlighted
|
|
30
31
|
var setRangeForDraft = (0, _react.useCallback)(function () {
|
|
31
|
-
setDraftRange(range);
|
|
32
|
-
}, [range, setDraftRange]);
|
|
32
|
+
setDraftRange(range, type);
|
|
33
|
+
}, [range, setDraftRange, type]);
|
|
34
|
+
var clearRangeForDraft = (0, _react.useCallback)(function () {
|
|
35
|
+
clearDraftRange(type);
|
|
36
|
+
}, [type, clearDraftRange]);
|
|
33
37
|
var render = (0, _react.useCallback)(function (_ref) {
|
|
34
38
|
var applyAnnotationDraftAt = _ref.applyAnnotationDraftAt,
|
|
35
39
|
clearAnnotationDraft = _ref.clearAnnotationDraft;
|
|
@@ -52,6 +56,6 @@ var AnnotationsContextWrapper = exports.AnnotationsContextWrapper = function Ann
|
|
|
52
56
|
}
|
|
53
57
|
return /*#__PURE__*/_react.default.createElement(_context.AnnotationsDraftContextWrapper, {
|
|
54
58
|
setDraftRange: setRangeForDraft,
|
|
55
|
-
clearDraftRange:
|
|
59
|
+
clearDraftRange: clearRangeForDraft
|
|
56
60
|
}, render);
|
|
57
61
|
};
|
|
@@ -18,7 +18,8 @@ import AnnotationComponent from '../../marks/annotation';
|
|
|
18
18
|
import { linkStyle, borderStyle } from './styles';
|
|
19
19
|
import { CommentBadge as CommentBadgeComponent } from '@atlaskit/editor-common/media-single';
|
|
20
20
|
import { injectIntl } from 'react-intl-next';
|
|
21
|
-
import { useInlineCommentsFilter } from '../../../ui/annotations/hooks';
|
|
21
|
+
import { useInlineCommentSubscriberContext, useInlineCommentsFilter } from '../../../ui/annotations/hooks';
|
|
22
|
+
import { AnnotationUpdateEvent } from '@atlaskit/editor-common/types';
|
|
22
23
|
const MediaBorder = ({
|
|
23
24
|
mark,
|
|
24
25
|
children
|
|
@@ -101,6 +102,7 @@ const CommentBadgeWrapper = ({
|
|
|
101
102
|
...rest
|
|
102
103
|
}) => {
|
|
103
104
|
var _marks$map;
|
|
105
|
+
const updateSubscriber = useInlineCommentSubscriberContext();
|
|
104
106
|
const activeParentIds = useInlineCommentsFilter({
|
|
105
107
|
annotationIds: (_marks$map = marks === null || marks === void 0 ? void 0 : marks.map(mark => mark.attrs.id)) !== null && _marks$map !== void 0 ? _marks$map : [''],
|
|
106
108
|
filter: {
|
|
@@ -110,10 +112,16 @@ const CommentBadgeWrapper = ({
|
|
|
110
112
|
if (!activeParentIds.length) {
|
|
111
113
|
return null;
|
|
112
114
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
+
const onClick = e => {
|
|
116
|
+
if (updateSubscriber) {
|
|
117
|
+
updateSubscriber.emit(AnnotationUpdateEvent.ON_ANNOTATION_CLICK, {
|
|
118
|
+
annotationIds: activeParentIds,
|
|
119
|
+
eventTarget: e.target
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
};
|
|
115
123
|
return jsx(CommentBadge, _extends({
|
|
116
|
-
onClick:
|
|
124
|
+
onClick: onClick
|
|
117
125
|
}, rest));
|
|
118
126
|
};
|
|
119
127
|
export default class Media extends PureComponent {
|
|
@@ -36,7 +36,7 @@ import { EditorMediaClientProvider } from '../../react/utils/EditorMediaClientPr
|
|
|
36
36
|
export const NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
37
37
|
export const DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
38
38
|
const packageName = "@atlaskit/renderer";
|
|
39
|
-
const packageVersion = "109.
|
|
39
|
+
const packageVersion = "109.16.0";
|
|
40
40
|
export class Renderer extends PureComponent {
|
|
41
41
|
constructor(props) {
|
|
42
42
|
super(props);
|
|
@@ -27,6 +27,14 @@ function reducer(state, action) {
|
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
return state;
|
|
30
|
+
case 'clearDraftHover':
|
|
31
|
+
if (state.type === 'hover') {
|
|
32
|
+
return {
|
|
33
|
+
...state,
|
|
34
|
+
draftRange: null
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return state;
|
|
30
38
|
case 'clearHover':
|
|
31
39
|
if (state.type === 'hover') {
|
|
32
40
|
return {
|
|
@@ -45,6 +53,15 @@ function reducer(state, action) {
|
|
|
45
53
|
};
|
|
46
54
|
}
|
|
47
55
|
return state;
|
|
56
|
+
case 'setHover':
|
|
57
|
+
if (state.range !== action.range || state.type !== 'hover') {
|
|
58
|
+
return {
|
|
59
|
+
...state,
|
|
60
|
+
range: action.range,
|
|
61
|
+
type: 'hover'
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return state;
|
|
48
65
|
case 'setDraftSelection':
|
|
49
66
|
if (state.draftRange !== action.draftRange || state.type !== 'selection') {
|
|
50
67
|
return {
|
|
@@ -54,17 +71,15 @@ function reducer(state, action) {
|
|
|
54
71
|
};
|
|
55
72
|
}
|
|
56
73
|
return state;
|
|
57
|
-
case '
|
|
58
|
-
if (state.
|
|
74
|
+
case 'setDraftHover':
|
|
75
|
+
if (state.draftRange !== action.draftRange || state.type !== 'hover') {
|
|
59
76
|
return {
|
|
60
77
|
...state,
|
|
61
|
-
|
|
62
|
-
type: 'hover'
|
|
78
|
+
draftRange: action.draftRange
|
|
63
79
|
};
|
|
64
80
|
}
|
|
65
81
|
return state;
|
|
66
82
|
}
|
|
67
|
-
return state;
|
|
68
83
|
}
|
|
69
84
|
export const AnnotationRangeStateContext = /*#__PURE__*/createContext({
|
|
70
85
|
range: null,
|
|
@@ -98,9 +113,17 @@ export const AnnotationRangeProvider = ({
|
|
|
98
113
|
const clearSelectionRange = useCallback(() => dispatch({
|
|
99
114
|
type: 'clearSelection'
|
|
100
115
|
}), []);
|
|
101
|
-
const clearDraftRange = useCallback(
|
|
102
|
-
type
|
|
103
|
-
|
|
116
|
+
const clearDraftRange = useCallback(type => {
|
|
117
|
+
if (type === 'hover') {
|
|
118
|
+
dispatch({
|
|
119
|
+
type: 'clearDraftHover'
|
|
120
|
+
});
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
dispatch({
|
|
124
|
+
type: 'clearDraftSelection'
|
|
125
|
+
});
|
|
126
|
+
}, []);
|
|
104
127
|
const clearHoverRange = useCallback(() => dispatch({
|
|
105
128
|
type: 'clearHover'
|
|
106
129
|
}), []);
|
|
@@ -108,7 +131,14 @@ export const AnnotationRangeProvider = ({
|
|
|
108
131
|
type: 'setSelection',
|
|
109
132
|
range
|
|
110
133
|
}), []);
|
|
111
|
-
const setDraftRange = useCallback(range => {
|
|
134
|
+
const setDraftRange = useCallback((range, type) => {
|
|
135
|
+
if (type === 'hover') {
|
|
136
|
+
dispatch({
|
|
137
|
+
type: 'setDraftHover',
|
|
138
|
+
draftRange: range
|
|
139
|
+
});
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
112
142
|
dispatch({
|
|
113
143
|
type: 'setDraftSelection',
|
|
114
144
|
draftRange: range
|
|
@@ -6,7 +6,8 @@ import { useAnnotationRangeDispatch, useAnnotationRangeState } from './contexts/
|
|
|
6
6
|
export const AnnotationsContextWrapper = props => {
|
|
7
7
|
const providers = useContext(ProvidersContext);
|
|
8
8
|
const {
|
|
9
|
-
range
|
|
9
|
+
range,
|
|
10
|
+
type
|
|
10
11
|
} = useAnnotationRangeState();
|
|
11
12
|
const {
|
|
12
13
|
setDraftRange,
|
|
@@ -23,8 +24,11 @@ export const AnnotationsContextWrapper = props => {
|
|
|
23
24
|
|
|
24
25
|
// We want to set the draft to the range the user highlighted
|
|
25
26
|
const setRangeForDraft = useCallback(() => {
|
|
26
|
-
setDraftRange(range);
|
|
27
|
-
}, [range, setDraftRange]);
|
|
27
|
+
setDraftRange(range, type);
|
|
28
|
+
}, [range, setDraftRange, type]);
|
|
29
|
+
const clearRangeForDraft = useCallback(() => {
|
|
30
|
+
clearDraftRange(type);
|
|
31
|
+
}, [type, clearDraftRange]);
|
|
28
32
|
const render = useCallback(({
|
|
29
33
|
applyAnnotationDraftAt,
|
|
30
34
|
clearAnnotationDraft
|
|
@@ -48,6 +52,6 @@ export const AnnotationsContextWrapper = props => {
|
|
|
48
52
|
}
|
|
49
53
|
return /*#__PURE__*/React.createElement(AnnotationsDraftContextWrapper, {
|
|
50
54
|
setDraftRange: setRangeForDraft,
|
|
51
|
-
clearDraftRange:
|
|
55
|
+
clearDraftRange: clearRangeForDraft
|
|
52
56
|
}, render);
|
|
53
57
|
};
|
|
@@ -28,7 +28,8 @@ import AnnotationComponent from '../../marks/annotation';
|
|
|
28
28
|
import { linkStyle, borderStyle } from './styles';
|
|
29
29
|
import { CommentBadge as CommentBadgeComponent } from '@atlaskit/editor-common/media-single';
|
|
30
30
|
import { injectIntl } from 'react-intl-next';
|
|
31
|
-
import { useInlineCommentsFilter } from '../../../ui/annotations/hooks';
|
|
31
|
+
import { useInlineCommentSubscriberContext, useInlineCommentsFilter } from '../../../ui/annotations/hooks';
|
|
32
|
+
import { AnnotationUpdateEvent } from '@atlaskit/editor-common/types';
|
|
32
33
|
var MediaBorder = function MediaBorder(_ref) {
|
|
33
34
|
var _mark$attrs$color, _mark$attrs$size;
|
|
34
35
|
var mark = _ref.mark,
|
|
@@ -107,6 +108,7 @@ var CommentBadgeWrapper = function CommentBadgeWrapper(_ref5) {
|
|
|
107
108
|
var _marks$map;
|
|
108
109
|
var marks = _ref5.marks,
|
|
109
110
|
rest = _objectWithoutProperties(_ref5, _excluded);
|
|
111
|
+
var updateSubscriber = useInlineCommentSubscriberContext();
|
|
110
112
|
var activeParentIds = useInlineCommentsFilter({
|
|
111
113
|
annotationIds: (_marks$map = marks === null || marks === void 0 ? void 0 : marks.map(function (mark) {
|
|
112
114
|
return mark.attrs.id;
|
|
@@ -118,10 +120,16 @@ var CommentBadgeWrapper = function CommentBadgeWrapper(_ref5) {
|
|
|
118
120
|
if (!activeParentIds.length) {
|
|
119
121
|
return null;
|
|
120
122
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
+
var onClick = function onClick(e) {
|
|
124
|
+
if (updateSubscriber) {
|
|
125
|
+
updateSubscriber.emit(AnnotationUpdateEvent.ON_ANNOTATION_CLICK, {
|
|
126
|
+
annotationIds: activeParentIds,
|
|
127
|
+
eventTarget: e.target
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
};
|
|
123
131
|
return jsx(CommentBadge, _extends({
|
|
124
|
-
onClick:
|
|
132
|
+
onClick: onClick
|
|
125
133
|
}, rest));
|
|
126
134
|
};
|
|
127
135
|
var Media = /*#__PURE__*/function (_PureComponent) {
|
|
@@ -46,7 +46,7 @@ import { EditorMediaClientProvider } from '../../react/utils/EditorMediaClientPr
|
|
|
46
46
|
export var NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
47
47
|
export var DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
48
48
|
var packageName = "@atlaskit/renderer";
|
|
49
|
-
var packageVersion = "109.
|
|
49
|
+
var packageVersion = "109.16.0";
|
|
50
50
|
export var Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
51
51
|
_inherits(Renderer, _PureComponent);
|
|
52
52
|
var _super = _createSuper(Renderer);
|
|
@@ -29,6 +29,13 @@ function reducer(state, action) {
|
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
return state;
|
|
32
|
+
case 'clearDraftHover':
|
|
33
|
+
if (state.type === 'hover') {
|
|
34
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
35
|
+
draftRange: null
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return state;
|
|
32
39
|
case 'clearHover':
|
|
33
40
|
if (state.type === 'hover') {
|
|
34
41
|
return {
|
|
@@ -46,6 +53,14 @@ function reducer(state, action) {
|
|
|
46
53
|
});
|
|
47
54
|
}
|
|
48
55
|
return state;
|
|
56
|
+
case 'setHover':
|
|
57
|
+
if (state.range !== action.range || state.type !== 'hover') {
|
|
58
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
59
|
+
range: action.range,
|
|
60
|
+
type: 'hover'
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return state;
|
|
49
64
|
case 'setDraftSelection':
|
|
50
65
|
if (state.draftRange !== action.draftRange || state.type !== 'selection') {
|
|
51
66
|
return {
|
|
@@ -55,16 +70,14 @@ function reducer(state, action) {
|
|
|
55
70
|
};
|
|
56
71
|
}
|
|
57
72
|
return state;
|
|
58
|
-
case '
|
|
59
|
-
if (state.
|
|
73
|
+
case 'setDraftHover':
|
|
74
|
+
if (state.draftRange !== action.draftRange || state.type !== 'hover') {
|
|
60
75
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
61
|
-
|
|
62
|
-
type: 'hover'
|
|
76
|
+
draftRange: action.draftRange
|
|
63
77
|
});
|
|
64
78
|
}
|
|
65
79
|
return state;
|
|
66
80
|
}
|
|
67
|
-
return state;
|
|
68
81
|
}
|
|
69
82
|
export var AnnotationRangeStateContext = /*#__PURE__*/createContext({
|
|
70
83
|
range: null,
|
|
@@ -103,8 +116,14 @@ export var AnnotationRangeProvider = function AnnotationRangeProvider(_ref) {
|
|
|
103
116
|
type: 'clearSelection'
|
|
104
117
|
});
|
|
105
118
|
}, []);
|
|
106
|
-
var clearDraftRange = useCallback(function () {
|
|
107
|
-
|
|
119
|
+
var clearDraftRange = useCallback(function (type) {
|
|
120
|
+
if (type === 'hover') {
|
|
121
|
+
dispatch({
|
|
122
|
+
type: 'clearDraftHover'
|
|
123
|
+
});
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
dispatch({
|
|
108
127
|
type: 'clearDraftSelection'
|
|
109
128
|
});
|
|
110
129
|
}, []);
|
|
@@ -119,7 +138,14 @@ export var AnnotationRangeProvider = function AnnotationRangeProvider(_ref) {
|
|
|
119
138
|
range: range
|
|
120
139
|
});
|
|
121
140
|
}, []);
|
|
122
|
-
var setDraftRange = useCallback(function (range) {
|
|
141
|
+
var setDraftRange = useCallback(function (range, type) {
|
|
142
|
+
if (type === 'hover') {
|
|
143
|
+
dispatch({
|
|
144
|
+
type: 'setDraftHover',
|
|
145
|
+
draftRange: range
|
|
146
|
+
});
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
123
149
|
dispatch({
|
|
124
150
|
type: 'setDraftSelection',
|
|
125
151
|
draftRange: range
|
|
@@ -6,7 +6,8 @@ import { useAnnotationRangeDispatch, useAnnotationRangeState } from './contexts/
|
|
|
6
6
|
export var AnnotationsContextWrapper = function AnnotationsContextWrapper(props) {
|
|
7
7
|
var providers = useContext(ProvidersContext);
|
|
8
8
|
var _useAnnotationRangeSt = useAnnotationRangeState(),
|
|
9
|
-
range = _useAnnotationRangeSt.range
|
|
9
|
+
range = _useAnnotationRangeSt.range,
|
|
10
|
+
type = _useAnnotationRangeSt.type;
|
|
10
11
|
var _useAnnotationRangeDi = useAnnotationRangeDispatch(),
|
|
11
12
|
setDraftRange = _useAnnotationRangeDi.setDraftRange,
|
|
12
13
|
clearDraftRange = _useAnnotationRangeDi.clearDraftRange;
|
|
@@ -19,8 +20,11 @@ export var AnnotationsContextWrapper = function AnnotationsContextWrapper(props)
|
|
|
19
20
|
|
|
20
21
|
// We want to set the draft to the range the user highlighted
|
|
21
22
|
var setRangeForDraft = useCallback(function () {
|
|
22
|
-
setDraftRange(range);
|
|
23
|
-
}, [range, setDraftRange]);
|
|
23
|
+
setDraftRange(range, type);
|
|
24
|
+
}, [range, setDraftRange, type]);
|
|
25
|
+
var clearRangeForDraft = useCallback(function () {
|
|
26
|
+
clearDraftRange(type);
|
|
27
|
+
}, [type, clearDraftRange]);
|
|
24
28
|
var render = useCallback(function (_ref) {
|
|
25
29
|
var applyAnnotationDraftAt = _ref.applyAnnotationDraftAt,
|
|
26
30
|
clearAnnotationDraft = _ref.clearAnnotationDraft;
|
|
@@ -43,6 +47,6 @@ export var AnnotationsContextWrapper = function AnnotationsContextWrapper(props)
|
|
|
43
47
|
}
|
|
44
48
|
return /*#__PURE__*/React.createElement(AnnotationsDraftContextWrapper, {
|
|
45
49
|
setDraftRange: setRangeForDraft,
|
|
46
|
-
clearDraftRange:
|
|
50
|
+
clearDraftRange: clearRangeForDraft
|
|
47
51
|
}, render);
|
|
48
52
|
};
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
type RangeType = 'selection' | 'hover' | null;
|
|
3
4
|
interface AnnotationRangeStateContext {
|
|
4
5
|
range: Range | null;
|
|
5
6
|
draftRange: Range | null;
|
|
6
|
-
type:
|
|
7
|
+
type: RangeType;
|
|
7
8
|
}
|
|
8
9
|
interface AnnotationRangeDispatchContext {
|
|
9
10
|
clearRange: () => void;
|
|
10
11
|
clearSelectionRange: () => void;
|
|
11
|
-
clearDraftRange: () => void;
|
|
12
|
+
clearDraftRange: (type: RangeType) => void;
|
|
12
13
|
clearHoverRange: () => void;
|
|
13
14
|
setRange: (range: Range) => void;
|
|
14
|
-
setDraftRange: (draftRange: Range | null) => void;
|
|
15
|
+
setDraftRange: (draftRange: Range | null, type: RangeType) => void;
|
|
15
16
|
setHoverTarget?: (target: HTMLElement) => void;
|
|
16
17
|
}
|
|
17
18
|
export declare const AnnotationRangeStateContext: React.Context<AnnotationRangeStateContext>;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
type RangeType = 'selection' | 'hover' | null;
|
|
3
4
|
interface AnnotationRangeStateContext {
|
|
4
5
|
range: Range | null;
|
|
5
6
|
draftRange: Range | null;
|
|
6
|
-
type:
|
|
7
|
+
type: RangeType;
|
|
7
8
|
}
|
|
8
9
|
interface AnnotationRangeDispatchContext {
|
|
9
10
|
clearRange: () => void;
|
|
10
11
|
clearSelectionRange: () => void;
|
|
11
|
-
clearDraftRange: () => void;
|
|
12
|
+
clearDraftRange: (type: RangeType) => void;
|
|
12
13
|
clearHoverRange: () => void;
|
|
13
14
|
setRange: (range: Range) => void;
|
|
14
|
-
setDraftRange: (draftRange: Range | null) => void;
|
|
15
|
+
setDraftRange: (draftRange: Range | null, type: RangeType) => void;
|
|
15
16
|
setHoverTarget?: (target: HTMLElement) => void;
|
|
16
17
|
}
|
|
17
18
|
export declare const AnnotationRangeStateContext: React.Context<AnnotationRangeStateContext>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/renderer",
|
|
3
|
-
"version": "109.
|
|
3
|
+
"version": "109.16.0",
|
|
4
4
|
"description": "Renderer component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@atlaskit/analytics-next": "^9.2.0",
|
|
32
32
|
"@atlaskit/button": "^17.11.0",
|
|
33
33
|
"@atlaskit/code": "^15.1.0",
|
|
34
|
-
"@atlaskit/editor-common": "^78.
|
|
34
|
+
"@atlaskit/editor-common": "^78.25.0",
|
|
35
35
|
"@atlaskit/editor-json-transformer": "^8.10.0",
|
|
36
36
|
"@atlaskit/editor-palette": "1.5.3",
|
|
37
37
|
"@atlaskit/editor-prosemirror": "3.0.0",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"@atlaskit/emoji": "^67.6.0",
|
|
40
40
|
"@atlaskit/icon": "^22.1.0",
|
|
41
41
|
"@atlaskit/link-datasource": "^1.26.0",
|
|
42
|
-
"@atlaskit/media-card": "^77.
|
|
43
|
-
"@atlaskit/media-client": "^26.
|
|
42
|
+
"@atlaskit/media-card": "^77.11.0",
|
|
43
|
+
"@atlaskit/media-client": "^26.3.0",
|
|
44
44
|
"@atlaskit/media-client-react": "^2.0.0",
|
|
45
45
|
"@atlaskit/media-common": "^11.1.0",
|
|
46
46
|
"@atlaskit/media-filmstrip": "^47.0.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@atlaskit/task-decision": "^17.9.0",
|
|
53
53
|
"@atlaskit/theme": "^12.7.0",
|
|
54
54
|
"@atlaskit/tokens": "^1.43.0",
|
|
55
|
-
"@atlaskit/tooltip": "^18.
|
|
55
|
+
"@atlaskit/tooltip": "^18.2.0",
|
|
56
56
|
"@babel/runtime": "^7.0.0",
|
|
57
57
|
"@emotion/react": "^11.7.1",
|
|
58
58
|
"lodash": "^4.17.21",
|