@atlaskit/renderer 109.15.1 → 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 +24 -0
- package/dist/cjs/react/nodes/media/index.js +71 -7
- package/dist/cjs/react/nodes/mediaSingle/index.js +2 -1
- 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 +66 -6
- package/dist/es2019/react/nodes/mediaSingle/index.js +2 -1
- 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 +69 -6
- package/dist/esm/react/nodes/mediaSingle/index.js +2 -1
- 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/react/nodes/media/index.d.ts +3 -0
- package/dist/types/ui/annotations/contexts/AnnotationRangeContext.d.ts +4 -3
- package/dist/types-ts4.5/react/nodes/media/index.d.ts +3 -0
- package/dist/types-ts4.5/ui/annotations/contexts/AnnotationRangeContext.d.ts +4 -3
- package/package.json +9 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
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
|
+
|
|
14
|
+
## 109.15.3
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#88742](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/88742) [`6771cedeadd3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6771cedeadd3) - Add UI for comment badge in Renderer, clean up props
|
|
19
|
+
|
|
20
|
+
## 109.15.2
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- [#88323](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/88323) [`b56b60b50087`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b56b60b50087) - Support nested annotation marks for media nodes in renderer
|
|
25
|
+
- Updated dependencies
|
|
26
|
+
|
|
3
27
|
## 109.15.1
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
11
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
@@ -14,6 +13,8 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
|
|
|
14
13
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
15
14
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
16
15
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
17
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
17
18
|
var _react = _interopRequireWildcard(require("react"));
|
|
18
19
|
var _react2 = require("@emotion/react");
|
|
19
20
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
@@ -21,16 +22,23 @@ var _analyticsNamespacedContext = require("@atlaskit/analytics-namespaced-contex
|
|
|
21
22
|
var _providerFactory = require("@atlaskit/editor-common/provider-factory");
|
|
22
23
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
23
24
|
var _MediaCard = require("../../../ui/MediaCard");
|
|
25
|
+
var _adfSchema = require("@atlaskit/adf-schema");
|
|
24
26
|
var _editorPalette = require("@atlaskit/editor-palette");
|
|
25
27
|
var _utils = require("../../../utils");
|
|
26
28
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
27
29
|
var _events = require("../../../analytics/events");
|
|
28
30
|
var _annotation = _interopRequireDefault(require("../../marks/annotation"));
|
|
29
31
|
var _styles = require("./styles");
|
|
32
|
+
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
33
|
+
var _reactIntlNext = require("react-intl-next");
|
|
34
|
+
var _hooks = require("../../../ui/annotations/hooks");
|
|
35
|
+
var _types = require("@atlaskit/editor-common/types");
|
|
36
|
+
var _excluded = ["marks"];
|
|
37
|
+
/** @jsx jsx */
|
|
30
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); }
|
|
31
39
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
32
40
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
33
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
41
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
34
42
|
var MediaBorder = function MediaBorder(_ref) {
|
|
35
43
|
var _mark$attrs$color, _mark$attrs$size;
|
|
36
44
|
var mark = _ref.mark,
|
|
@@ -85,6 +93,54 @@ var MediaAnnotation = function MediaAnnotation(_ref3) {
|
|
|
85
93
|
useBlockLevel: true
|
|
86
94
|
}, children);
|
|
87
95
|
};
|
|
96
|
+
var MediaAnnotations = function MediaAnnotations(_ref4) {
|
|
97
|
+
var _ref4$marks = _ref4.marks,
|
|
98
|
+
marks = _ref4$marks === void 0 ? [] : _ref4$marks,
|
|
99
|
+
children = _ref4.children;
|
|
100
|
+
// Early Exit
|
|
101
|
+
if (marks.length === 0) {
|
|
102
|
+
return (0, _react2.jsx)(_react.Fragment, null, children);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Recursive marks
|
|
106
|
+
var currentMark = marks[0];
|
|
107
|
+
var otherMarks = marks.slice(1);
|
|
108
|
+
return (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(MediaAnnotation, {
|
|
109
|
+
key: currentMark.attrs.id,
|
|
110
|
+
mark: currentMark
|
|
111
|
+
}, otherMarks.length ? (0, _react2.jsx)(MediaAnnotations, {
|
|
112
|
+
marks: otherMarks
|
|
113
|
+
}, children) : (0, _react2.jsx)(_react.Fragment, null, children)));
|
|
114
|
+
};
|
|
115
|
+
var CommentBadge = (0, _reactIntlNext.injectIntl)(_mediaSingle.CommentBadge);
|
|
116
|
+
var CommentBadgeWrapper = function CommentBadgeWrapper(_ref5) {
|
|
117
|
+
var _marks$map;
|
|
118
|
+
var marks = _ref5.marks,
|
|
119
|
+
rest = (0, _objectWithoutProperties2.default)(_ref5, _excluded);
|
|
120
|
+
var updateSubscriber = (0, _hooks.useInlineCommentSubscriberContext)();
|
|
121
|
+
var activeParentIds = (0, _hooks.useInlineCommentsFilter)({
|
|
122
|
+
annotationIds: (_marks$map = marks === null || marks === void 0 ? void 0 : marks.map(function (mark) {
|
|
123
|
+
return mark.attrs.id;
|
|
124
|
+
})) !== null && _marks$map !== void 0 ? _marks$map : [''],
|
|
125
|
+
filter: {
|
|
126
|
+
state: _adfSchema.AnnotationMarkStates.ACTIVE
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
if (!activeParentIds.length) {
|
|
130
|
+
return null;
|
|
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
|
+
};
|
|
140
|
+
return (0, _react2.jsx)(CommentBadge, (0, _extends2.default)({
|
|
141
|
+
onClick: onClick
|
|
142
|
+
}, rest));
|
|
143
|
+
};
|
|
88
144
|
var Media = exports.default = /*#__PURE__*/function (_PureComponent) {
|
|
89
145
|
(0, _inherits2.default)(Media, _PureComponent);
|
|
90
146
|
var _super = _createSuper(Media);
|
|
@@ -101,8 +157,11 @@ var Media = exports.default = /*#__PURE__*/function (_PureComponent) {
|
|
|
101
157
|
featureFlags = _this$props.featureFlags,
|
|
102
158
|
allowMediaViewer = _this$props.shouldOpenMediaViewer,
|
|
103
159
|
enableDownloadButton = _this$props.enableDownloadButton,
|
|
104
|
-
ssr = _this$props.ssr
|
|
105
|
-
|
|
160
|
+
ssr = _this$props.ssr,
|
|
161
|
+
width = _this$props.width,
|
|
162
|
+
height = _this$props.height,
|
|
163
|
+
mediaSingleElement = _this$props.mediaSingleElement;
|
|
164
|
+
var annotationMarks = _this.props.isAnnotationMark ? _this.props.marks.filter(_this.props.isAnnotationMark) : undefined;
|
|
106
165
|
var borderMark = _this.props.marks.find(_this.props.isBorderMark);
|
|
107
166
|
var linkMark = _this.props.marks.find(_this.props.isLinkMark);
|
|
108
167
|
var linkHref = linkMark === null || linkMark === void 0 ? void 0 : linkMark.attrs.href;
|
|
@@ -111,15 +170,20 @@ var Media = exports.default = /*#__PURE__*/function (_PureComponent) {
|
|
|
111
170
|
return (0, _react2.jsx)(MediaLink, {
|
|
112
171
|
mark: linkMark,
|
|
113
172
|
onClick: _this.handleMediaLinkClickFn
|
|
114
|
-
}, (0, _react2.jsx)(
|
|
115
|
-
|
|
173
|
+
}, (0, _react2.jsx)(MediaAnnotations, {
|
|
174
|
+
marks: annotationMarks
|
|
116
175
|
}, (0, _react2.jsx)(MediaBorder, {
|
|
117
176
|
mark: borderMark
|
|
118
177
|
}, (0, _react2.jsx)(_analyticsNext.AnalyticsContext, {
|
|
119
178
|
data: (0, _defineProperty2.default)({}, _analyticsNamespacedContext.MEDIA_CONTEXT, {
|
|
120
179
|
border: !!borderMark
|
|
121
180
|
})
|
|
122
|
-
}, (0, _react2.jsx)(
|
|
181
|
+
}, !!annotationMarks && (0, _react2.jsx)(CommentBadgeWrapper, {
|
|
182
|
+
marks: annotationMarks,
|
|
183
|
+
mediaElement: mediaSingleElement,
|
|
184
|
+
width: width,
|
|
185
|
+
height: height
|
|
186
|
+
}), (0, _react2.jsx)(_MediaCard.MediaCard, (0, _extends2.default)({
|
|
123
187
|
contextIdentifierProvider: contextIdentifierProvider
|
|
124
188
|
}, _this.props, {
|
|
125
189
|
shouldOpenMediaViewer: shouldOpenMediaViewer,
|
|
@@ -165,7 +165,8 @@ var MediaSingle = function MediaSingle(props) {
|
|
|
165
165
|
originalDimensions: originalDimensions,
|
|
166
166
|
onExternalImageLoaded: onExternalImageLoaded,
|
|
167
167
|
disableOverlay: true,
|
|
168
|
-
featureFlags: featureFlags
|
|
168
|
+
featureFlags: featureFlags,
|
|
169
|
+
mediaSingleElement: ref.current
|
|
169
170
|
});
|
|
170
171
|
var uiMediaSingleStyles = layout === 'full-width' || layout === 'wide' ? [_styles.uiMediaSingleBaseStyles, _styles.uiMediaSingleLayoutStyles] : [_styles.uiMediaSingleBaseStyles];
|
|
171
172
|
return (0, _react2.jsx)(_ui.MediaSingle, {
|
|
@@ -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
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
|
|
5
5
|
import React, { PureComponent, Fragment } from 'react';
|
|
@@ -9,12 +9,17 @@ import { MEDIA_CONTEXT } from '@atlaskit/analytics-namespaced-context';
|
|
|
9
9
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
10
10
|
import { MediaBorderGapFiller } from '@atlaskit/editor-common/ui';
|
|
11
11
|
import { MediaCard } from '../../../ui/MediaCard';
|
|
12
|
+
import { AnnotationMarkStates } from '@atlaskit/adf-schema';
|
|
12
13
|
import { hexToEditorBorderPaletteColor } from '@atlaskit/editor-palette';
|
|
13
14
|
import { getEventHandler } from '../../../utils';
|
|
14
15
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
15
16
|
import { MODE, PLATFORM } from '../../../analytics/events';
|
|
16
17
|
import AnnotationComponent from '../../marks/annotation';
|
|
17
18
|
import { linkStyle, borderStyle } from './styles';
|
|
19
|
+
import { CommentBadge as CommentBadgeComponent } from '@atlaskit/editor-common/media-single';
|
|
20
|
+
import { injectIntl } from 'react-intl-next';
|
|
21
|
+
import { useInlineCommentSubscriberContext, useInlineCommentsFilter } from '../../../ui/annotations/hooks';
|
|
22
|
+
import { AnnotationUpdateEvent } from '@atlaskit/editor-common/types';
|
|
18
23
|
const MediaBorder = ({
|
|
19
24
|
mark,
|
|
20
25
|
children
|
|
@@ -72,6 +77,53 @@ const MediaAnnotation = ({
|
|
|
72
77
|
useBlockLevel: true
|
|
73
78
|
}, children);
|
|
74
79
|
};
|
|
80
|
+
const MediaAnnotations = ({
|
|
81
|
+
marks = [],
|
|
82
|
+
children
|
|
83
|
+
}) => {
|
|
84
|
+
// Early Exit
|
|
85
|
+
if (marks.length === 0) {
|
|
86
|
+
return jsx(Fragment, null, children);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Recursive marks
|
|
90
|
+
const currentMark = marks[0];
|
|
91
|
+
const otherMarks = marks.slice(1);
|
|
92
|
+
return jsx(Fragment, null, jsx(MediaAnnotation, {
|
|
93
|
+
key: currentMark.attrs.id,
|
|
94
|
+
mark: currentMark
|
|
95
|
+
}, otherMarks.length ? jsx(MediaAnnotations, {
|
|
96
|
+
marks: otherMarks
|
|
97
|
+
}, children) : jsx(Fragment, null, children)));
|
|
98
|
+
};
|
|
99
|
+
const CommentBadge = injectIntl(CommentBadgeComponent);
|
|
100
|
+
const CommentBadgeWrapper = ({
|
|
101
|
+
marks,
|
|
102
|
+
...rest
|
|
103
|
+
}) => {
|
|
104
|
+
var _marks$map;
|
|
105
|
+
const updateSubscriber = useInlineCommentSubscriberContext();
|
|
106
|
+
const activeParentIds = useInlineCommentsFilter({
|
|
107
|
+
annotationIds: (_marks$map = marks === null || marks === void 0 ? void 0 : marks.map(mark => mark.attrs.id)) !== null && _marks$map !== void 0 ? _marks$map : [''],
|
|
108
|
+
filter: {
|
|
109
|
+
state: AnnotationMarkStates.ACTIVE
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
if (!activeParentIds.length) {
|
|
113
|
+
return null;
|
|
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
|
+
};
|
|
123
|
+
return jsx(CommentBadge, _extends({
|
|
124
|
+
onClick: onClick
|
|
125
|
+
}, rest));
|
|
126
|
+
};
|
|
75
127
|
export default class Media extends PureComponent {
|
|
76
128
|
constructor(props) {
|
|
77
129
|
super(props);
|
|
@@ -85,9 +137,12 @@ export default class Media extends PureComponent {
|
|
|
85
137
|
featureFlags,
|
|
86
138
|
shouldOpenMediaViewer: allowMediaViewer,
|
|
87
139
|
enableDownloadButton,
|
|
88
|
-
ssr
|
|
140
|
+
ssr,
|
|
141
|
+
width,
|
|
142
|
+
height,
|
|
143
|
+
mediaSingleElement
|
|
89
144
|
} = this.props;
|
|
90
|
-
const
|
|
145
|
+
const annotationMarks = this.props.isAnnotationMark ? this.props.marks.filter(this.props.isAnnotationMark) : undefined;
|
|
91
146
|
const borderMark = this.props.marks.find(this.props.isBorderMark);
|
|
92
147
|
const linkMark = this.props.marks.find(this.props.isLinkMark);
|
|
93
148
|
const linkHref = linkMark === null || linkMark === void 0 ? void 0 : linkMark.attrs.href;
|
|
@@ -96,8 +151,8 @@ export default class Media extends PureComponent {
|
|
|
96
151
|
return jsx(MediaLink, {
|
|
97
152
|
mark: linkMark,
|
|
98
153
|
onClick: this.handleMediaLinkClickFn
|
|
99
|
-
}, jsx(
|
|
100
|
-
|
|
154
|
+
}, jsx(MediaAnnotations, {
|
|
155
|
+
marks: annotationMarks
|
|
101
156
|
}, jsx(MediaBorder, {
|
|
102
157
|
mark: borderMark
|
|
103
158
|
}, jsx(AnalyticsContext, {
|
|
@@ -106,7 +161,12 @@ export default class Media extends PureComponent {
|
|
|
106
161
|
border: !!borderMark
|
|
107
162
|
}
|
|
108
163
|
}
|
|
109
|
-
}, jsx(
|
|
164
|
+
}, !!annotationMarks && jsx(CommentBadgeWrapper, {
|
|
165
|
+
marks: annotationMarks,
|
|
166
|
+
mediaElement: mediaSingleElement,
|
|
167
|
+
width: width,
|
|
168
|
+
height: height
|
|
169
|
+
}), jsx(MediaCard, _extends({
|
|
110
170
|
contextIdentifierProvider: contextIdentifierProvider
|
|
111
171
|
}, this.props, {
|
|
112
172
|
shouldOpenMediaViewer: shouldOpenMediaViewer,
|
|
@@ -150,7 +150,8 @@ const MediaSingle = props => {
|
|
|
150
150
|
originalDimensions,
|
|
151
151
|
onExternalImageLoaded,
|
|
152
152
|
disableOverlay: true,
|
|
153
|
-
featureFlags
|
|
153
|
+
featureFlags,
|
|
154
|
+
mediaSingleElement: ref.current
|
|
154
155
|
});
|
|
155
156
|
const uiMediaSingleStyles = layout === 'full-width' || layout === 'wide' ? [uiMediaSingleBaseStyles, uiMediaSingleLayoutStyles] : [uiMediaSingleBaseStyles];
|
|
156
157
|
return jsx(UIMediaSingle, {
|
|
@@ -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
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
3
|
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
@@ -6,6 +5,9 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
6
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
9
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
10
|
+
var _excluded = ["marks"];
|
|
9
11
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
12
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
11
13
|
/** @jsx jsx */
|
|
@@ -17,12 +19,17 @@ import { MEDIA_CONTEXT } from '@atlaskit/analytics-namespaced-context';
|
|
|
17
19
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
18
20
|
import { MediaBorderGapFiller } from '@atlaskit/editor-common/ui';
|
|
19
21
|
import { MediaCard } from '../../../ui/MediaCard';
|
|
22
|
+
import { AnnotationMarkStates } from '@atlaskit/adf-schema';
|
|
20
23
|
import { hexToEditorBorderPaletteColor } from '@atlaskit/editor-palette';
|
|
21
24
|
import { getEventHandler } from '../../../utils';
|
|
22
25
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
23
26
|
import { MODE, PLATFORM } from '../../../analytics/events';
|
|
24
27
|
import AnnotationComponent from '../../marks/annotation';
|
|
25
28
|
import { linkStyle, borderStyle } from './styles';
|
|
29
|
+
import { CommentBadge as CommentBadgeComponent } from '@atlaskit/editor-common/media-single';
|
|
30
|
+
import { injectIntl } from 'react-intl-next';
|
|
31
|
+
import { useInlineCommentSubscriberContext, useInlineCommentsFilter } from '../../../ui/annotations/hooks';
|
|
32
|
+
import { AnnotationUpdateEvent } from '@atlaskit/editor-common/types';
|
|
26
33
|
var MediaBorder = function MediaBorder(_ref) {
|
|
27
34
|
var _mark$attrs$color, _mark$attrs$size;
|
|
28
35
|
var mark = _ref.mark,
|
|
@@ -77,6 +84,54 @@ var MediaAnnotation = function MediaAnnotation(_ref3) {
|
|
|
77
84
|
useBlockLevel: true
|
|
78
85
|
}, children);
|
|
79
86
|
};
|
|
87
|
+
var MediaAnnotations = function MediaAnnotations(_ref4) {
|
|
88
|
+
var _ref4$marks = _ref4.marks,
|
|
89
|
+
marks = _ref4$marks === void 0 ? [] : _ref4$marks,
|
|
90
|
+
children = _ref4.children;
|
|
91
|
+
// Early Exit
|
|
92
|
+
if (marks.length === 0) {
|
|
93
|
+
return jsx(Fragment, null, children);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Recursive marks
|
|
97
|
+
var currentMark = marks[0];
|
|
98
|
+
var otherMarks = marks.slice(1);
|
|
99
|
+
return jsx(Fragment, null, jsx(MediaAnnotation, {
|
|
100
|
+
key: currentMark.attrs.id,
|
|
101
|
+
mark: currentMark
|
|
102
|
+
}, otherMarks.length ? jsx(MediaAnnotations, {
|
|
103
|
+
marks: otherMarks
|
|
104
|
+
}, children) : jsx(Fragment, null, children)));
|
|
105
|
+
};
|
|
106
|
+
var CommentBadge = injectIntl(CommentBadgeComponent);
|
|
107
|
+
var CommentBadgeWrapper = function CommentBadgeWrapper(_ref5) {
|
|
108
|
+
var _marks$map;
|
|
109
|
+
var marks = _ref5.marks,
|
|
110
|
+
rest = _objectWithoutProperties(_ref5, _excluded);
|
|
111
|
+
var updateSubscriber = useInlineCommentSubscriberContext();
|
|
112
|
+
var activeParentIds = useInlineCommentsFilter({
|
|
113
|
+
annotationIds: (_marks$map = marks === null || marks === void 0 ? void 0 : marks.map(function (mark) {
|
|
114
|
+
return mark.attrs.id;
|
|
115
|
+
})) !== null && _marks$map !== void 0 ? _marks$map : [''],
|
|
116
|
+
filter: {
|
|
117
|
+
state: AnnotationMarkStates.ACTIVE
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
if (!activeParentIds.length) {
|
|
121
|
+
return null;
|
|
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
|
+
};
|
|
131
|
+
return jsx(CommentBadge, _extends({
|
|
132
|
+
onClick: onClick
|
|
133
|
+
}, rest));
|
|
134
|
+
};
|
|
80
135
|
var Media = /*#__PURE__*/function (_PureComponent) {
|
|
81
136
|
_inherits(Media, _PureComponent);
|
|
82
137
|
var _super = _createSuper(Media);
|
|
@@ -93,8 +148,11 @@ var Media = /*#__PURE__*/function (_PureComponent) {
|
|
|
93
148
|
featureFlags = _this$props.featureFlags,
|
|
94
149
|
allowMediaViewer = _this$props.shouldOpenMediaViewer,
|
|
95
150
|
enableDownloadButton = _this$props.enableDownloadButton,
|
|
96
|
-
ssr = _this$props.ssr
|
|
97
|
-
|
|
151
|
+
ssr = _this$props.ssr,
|
|
152
|
+
width = _this$props.width,
|
|
153
|
+
height = _this$props.height,
|
|
154
|
+
mediaSingleElement = _this$props.mediaSingleElement;
|
|
155
|
+
var annotationMarks = _this.props.isAnnotationMark ? _this.props.marks.filter(_this.props.isAnnotationMark) : undefined;
|
|
98
156
|
var borderMark = _this.props.marks.find(_this.props.isBorderMark);
|
|
99
157
|
var linkMark = _this.props.marks.find(_this.props.isLinkMark);
|
|
100
158
|
var linkHref = linkMark === null || linkMark === void 0 ? void 0 : linkMark.attrs.href;
|
|
@@ -103,15 +161,20 @@ var Media = /*#__PURE__*/function (_PureComponent) {
|
|
|
103
161
|
return jsx(MediaLink, {
|
|
104
162
|
mark: linkMark,
|
|
105
163
|
onClick: _this.handleMediaLinkClickFn
|
|
106
|
-
}, jsx(
|
|
107
|
-
|
|
164
|
+
}, jsx(MediaAnnotations, {
|
|
165
|
+
marks: annotationMarks
|
|
108
166
|
}, jsx(MediaBorder, {
|
|
109
167
|
mark: borderMark
|
|
110
168
|
}, jsx(AnalyticsContext, {
|
|
111
169
|
data: _defineProperty({}, MEDIA_CONTEXT, {
|
|
112
170
|
border: !!borderMark
|
|
113
171
|
})
|
|
114
|
-
}, jsx(
|
|
172
|
+
}, !!annotationMarks && jsx(CommentBadgeWrapper, {
|
|
173
|
+
marks: annotationMarks,
|
|
174
|
+
mediaElement: mediaSingleElement,
|
|
175
|
+
width: width,
|
|
176
|
+
height: height
|
|
177
|
+
}), jsx(MediaCard, _extends({
|
|
115
178
|
contextIdentifierProvider: contextIdentifierProvider
|
|
116
179
|
}, _this.props, {
|
|
117
180
|
shouldOpenMediaViewer: shouldOpenMediaViewer,
|
|
@@ -155,7 +155,8 @@ var MediaSingle = function MediaSingle(props) {
|
|
|
155
155
|
originalDimensions: originalDimensions,
|
|
156
156
|
onExternalImageLoaded: onExternalImageLoaded,
|
|
157
157
|
disableOverlay: true,
|
|
158
|
-
featureFlags: featureFlags
|
|
158
|
+
featureFlags: featureFlags,
|
|
159
|
+
mediaSingleElement: ref.current
|
|
159
160
|
});
|
|
160
161
|
var uiMediaSingleStyles = layout === 'full-width' || layout === 'wide' ? [uiMediaSingleBaseStyles, uiMediaSingleLayoutStyles] : [uiMediaSingleBaseStyles];
|
|
161
162
|
return jsx(UIMediaSingle, {
|
|
@@ -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
|
};
|
|
@@ -19,6 +19,9 @@ export type MediaProps = MediaCardProps & {
|
|
|
19
19
|
featureFlags?: MediaFeatureFlags;
|
|
20
20
|
eventHandlers?: EventHandlers;
|
|
21
21
|
enableDownloadButton?: boolean;
|
|
22
|
+
mediaSingleElement?: HTMLElement | null;
|
|
23
|
+
width?: number;
|
|
24
|
+
height?: number;
|
|
22
25
|
};
|
|
23
26
|
export default class Media extends PureComponent<MediaProps, {}> {
|
|
24
27
|
constructor(props: MediaProps);
|
|
@@ -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>;
|
|
@@ -19,6 +19,9 @@ export type MediaProps = MediaCardProps & {
|
|
|
19
19
|
featureFlags?: MediaFeatureFlags;
|
|
20
20
|
eventHandlers?: EventHandlers;
|
|
21
21
|
enableDownloadButton?: boolean;
|
|
22
|
+
mediaSingleElement?: HTMLElement | null;
|
|
23
|
+
width?: number;
|
|
24
|
+
height?: number;
|
|
22
25
|
};
|
|
23
26
|
export default class Media extends PureComponent<MediaProps, {}> {
|
|
24
27
|
constructor(props: MediaProps);
|
|
@@ -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/"
|
|
@@ -29,22 +29,22 @@
|
|
|
29
29
|
"@atlaskit/analytics-listeners": "^8.9.0",
|
|
30
30
|
"@atlaskit/analytics-namespaced-context": "^6.9.0",
|
|
31
31
|
"@atlaskit/analytics-next": "^9.2.0",
|
|
32
|
-
"@atlaskit/button": "^17.
|
|
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",
|
|
38
38
|
"@atlaskit/editor-shared-styles": "^2.9.0",
|
|
39
39
|
"@atlaskit/emoji": "^67.6.0",
|
|
40
40
|
"@atlaskit/icon": "^22.1.0",
|
|
41
|
-
"@atlaskit/link-datasource": "^1.
|
|
42
|
-
"@atlaskit/media-card": "^77.
|
|
43
|
-
"@atlaskit/media-client": "^26.
|
|
41
|
+
"@atlaskit/link-datasource": "^1.26.0",
|
|
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",
|
|
47
|
-
"@atlaskit/media-ui": "^25.
|
|
47
|
+
"@atlaskit/media-ui": "^25.6.0",
|
|
48
48
|
"@atlaskit/media-viewer": "^48.4.0",
|
|
49
49
|
"@atlaskit/platform-feature-flags": "^0.2.0",
|
|
50
50
|
"@atlaskit/smart-card": "^26.52.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",
|
|
@@ -98,6 +98,7 @@
|
|
|
98
98
|
"react": "^16.8.0",
|
|
99
99
|
"react-dom": "^16.8.0",
|
|
100
100
|
"react-live-clock": "^5.0.0",
|
|
101
|
+
"react-magnetic-di": "^2.2.6",
|
|
101
102
|
"react-moment": "^1.1.2",
|
|
102
103
|
"react-test-renderer": "^16.8.0",
|
|
103
104
|
"rxjs": "^5.5.0",
|