@atlaskit/renderer 109.25.4 → 109.26.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 CHANGED
@@ -1,5 +1,26 @@
1
1
  # @atlaskit/renderer
2
2
 
3
+ ## 109.26.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#98890](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/98890)
8
+ [`9a61210caecb`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9a61210caecb) -
9
+ Updating parameters of the applyDraftMode() function to return a step if an annotationId is
10
+ passed in
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies
15
+
16
+ ## 109.25.5
17
+
18
+ ### Patch Changes
19
+
20
+ - [#98978](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/98978)
21
+ [`b0e975e054e4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b0e975e054e4) -
22
+ FF to fix comments on video
23
+
3
24
  ## 109.25.4
4
25
 
5
26
  ### Patch Changes
@@ -171,11 +171,11 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
171
171
  }
172
172
  }, {
173
173
  key: "getPositionFromRange",
174
- value: function getPositionFromRange(range, isCommentsOnMediaBugFixEnabled) {
174
+ value: function getPositionFromRange(range, isCommentsOnMediaBugFixEnabled, isCommentsOnMediaBugVideoComment) {
175
175
  if (!this.doc || !this.schema || !range) {
176
176
  return false;
177
177
  }
178
- return (0, _steps.getPosFromRange)(range, isCommentsOnMediaBugFixEnabled);
178
+ return (0, _steps.getPosFromRange)(range, isCommentsOnMediaBugFixEnabled, isCommentsOnMediaBugVideoComment);
179
179
  }
180
180
  }, {
181
181
  key: "getAnnotationMarks",
@@ -220,7 +220,7 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
220
220
  }
221
221
  }, {
222
222
  key: "applyAnnotation",
223
- value: function applyAnnotation(pos, annotation, isCommentsOnMediaBugFixEnabled) {
223
+ value: function applyAnnotation(pos, annotation, isCommentsOnMediaBugFixEnabled, isCommentsOnMediaBugVideoCommentEnabled) {
224
224
  if (!this.doc || !pos || !this.schema) {
225
225
  return false;
226
226
  }
@@ -173,27 +173,45 @@ function resolvePos(node, offset) {
173
173
  }
174
174
  return resolvedPos + offset;
175
175
  }
176
- function getPosFromRange(range, isCommentsOnMediaBugFixEnabled) {
176
+ function getPosFromRange(range, isCommentsOnMediaBugFixEnabled, isCommentsOnMediaBugVideoCommentEnabled) {
177
177
  var startContainer = range.startContainer,
178
178
  startOffset = range.startOffset,
179
179
  endContainer = range.endContainer,
180
180
  endOffset = range.endOffset;
181
- var possibleMediaElement = findParent(startContainer);
182
- if (possibleMediaElement && getNodeType(possibleMediaElement) === 'media') {
183
- var pos;
184
- if (isCommentsOnMediaBugFixEnabled) {
185
- var mediaSingleElement = findMediaParent(possibleMediaElement);
181
+ var possibleMediaOrMediaSingleElement = findParent(startContainer);
182
+ if (isCommentsOnMediaBugVideoCommentEnabled) {
183
+ // Video hover targets return media single, not media, thus, the extra check in condition.
184
+ var isMediaOrMediaSingle = possibleMediaOrMediaSingleElement && /media|mediaSingle/.test(getNodeType(possibleMediaOrMediaSingleElement) || '');
185
+ if (isMediaOrMediaSingle) {
186
+ var pos;
187
+ var mediaSingleElement = getNodeType(possibleMediaOrMediaSingleElement) === 'mediaSingle' ? possibleMediaOrMediaSingleElement : findMediaParent(possibleMediaOrMediaSingleElement);
186
188
  if (mediaSingleElement) {
187
189
  pos = getStartPos(mediaSingleElement);
188
190
  }
189
- } else {
190
- pos = getStartPos(possibleMediaElement);
191
+ if (pos !== undefined) {
192
+ return {
193
+ from: pos,
194
+ to: pos
195
+ };
196
+ }
191
197
  }
192
- if (pos !== undefined) {
193
- return {
194
- from: pos,
195
- to: pos
196
- };
198
+ } else {
199
+ if (possibleMediaOrMediaSingleElement && getNodeType(possibleMediaOrMediaSingleElement) === 'media') {
200
+ var _pos;
201
+ if (isCommentsOnMediaBugFixEnabled) {
202
+ var _mediaSingleElement = findMediaParent(possibleMediaOrMediaSingleElement);
203
+ if (_mediaSingleElement) {
204
+ _pos = getStartPos(_mediaSingleElement);
205
+ }
206
+ } else {
207
+ _pos = getStartPos(possibleMediaOrMediaSingleElement);
208
+ }
209
+ if (_pos !== undefined) {
210
+ return {
211
+ from: _pos,
212
+ to: _pos
213
+ };
214
+ }
197
215
  }
198
216
  }
199
217
  var from = resolvePos(startContainer, startOffset);
@@ -56,7 +56,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
56
56
  var NORMAL_SEVERITY_THRESHOLD = exports.NORMAL_SEVERITY_THRESHOLD = 2000;
57
57
  var DEGRADED_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = 3000;
58
58
  var packageName = "@atlaskit/renderer";
59
- var packageVersion = "109.25.4";
59
+ var packageVersion = "109.26.0";
60
60
  var defaultNodeComponents = exports.defaultNodeComponents = _nodes.nodeToReact;
61
61
  var Renderer = exports.Renderer = /*#__PURE__*/function (_PureComponent) {
62
62
  (0, _inherits2.default)(Renderer, _PureComponent);
@@ -65,8 +65,7 @@ var Mounter = exports.Mounter = /*#__PURE__*/_react.default.memo(function (props
65
65
  }
66
66
  return result;
67
67
  }, [documentPosition, generateIndexMatch]);
68
- var applyDraftModeCallback = (0, _react.useCallback)(function () {
69
- var keepNativeSelection = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
68
+ var applyDraftModeCallback = (0, _react.useCallback)(function (options) {
70
69
  if (!documentPosition || !isAnnotationAllowed) {
71
70
  if (createAnalyticsEvent) {
72
71
  createAnalyticsEvent({
@@ -77,7 +76,7 @@ var Mounter = exports.Mounter = /*#__PURE__*/_react.default.memo(function (props
77
76
  eventType: _analytics.EVENT_TYPE.TRACK
78
77
  }).fire(_analyticsListeners.FabricChannel.editor);
79
78
  }
80
- return;
79
+ return false;
81
80
  }
82
81
  setDraftDocumentPosition(documentPosition);
83
82
  applyAnnotationDraftAt(documentPosition);
@@ -94,7 +93,7 @@ var Mounter = exports.Mounter = /*#__PURE__*/_react.default.memo(function (props
94
93
  }).fire(_analyticsListeners.FabricChannel.editor);
95
94
  }
96
95
  window.requestAnimationFrame(function () {
97
- if (keepNativeSelection) {
96
+ if (options.keepNativeSelection) {
98
97
  (0, _draft.updateWindowSelectionAroundDraft)(documentPosition);
99
98
  } else {
100
99
  var sel = window.getSelection();
@@ -103,7 +102,16 @@ var Mounter = exports.Mounter = /*#__PURE__*/_react.default.memo(function (props
103
102
  }
104
103
  }
105
104
  });
106
- }, [documentPosition, isAnnotationAllowed, applyAnnotationDraftAt, createAnalyticsEvent, actions, range]);
105
+ var positionToAnnotate = draftDocumentPosition || documentPosition;
106
+ if (!positionToAnnotate || !applyAnnotation || !options.annotationId) {
107
+ return false;
108
+ }
109
+ var annotation = {
110
+ annotationId: options.annotationId,
111
+ annotationType: _adfSchema.AnnotationTypes.INLINE_COMMENT
112
+ };
113
+ return applyAnnotation(positionToAnnotate, annotation, isCommentsOnMediaBugFixEnabled);
114
+ }, [documentPosition, isAnnotationAllowed, applyAnnotationDraftAt, createAnalyticsEvent, applyAnnotation, draftDocumentPosition, isCommentsOnMediaBugFixEnabled, actions, range]);
107
115
  var removeDraftModeCallback = (0, _react.useCallback)(function () {
108
116
  clearAnnotationDraft();
109
117
  setDraftDocumentPosition(null);
@@ -14,7 +14,7 @@ var _context = require("../context");
14
14
  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); }
15
15
  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; }
16
16
  var RangeValidator = exports.RangeValidator = function RangeValidator(props) {
17
- var _providers$inlineComm;
17
+ var _providers$inlineComm, _providers$inlineComm2;
18
18
  var component = props.component,
19
19
  rendererRef = props.rendererRef,
20
20
  applyAnnotationDraftAt = props.applyAnnotationDraftAt,
@@ -30,10 +30,11 @@ var RangeValidator = exports.RangeValidator = function RangeValidator(props) {
30
30
  isWithinRange = _useAnnotationHoverCo.isWithinRange;
31
31
  var providers = (0, _react.useContext)(_context.ProvidersContext);
32
32
  var isCommentsOnMediaBugFixEnabled = (_providers$inlineComm = providers === null || providers === void 0 ? void 0 : providers.inlineComment.isCommentsOnMediaBugFixEnabled) !== null && _providers$inlineComm !== void 0 ? _providers$inlineComm : false;
33
+ var isCommentsOnMediaBugVideoCommentEnabled = (_providers$inlineComm2 = providers === null || providers === void 0 ? void 0 : providers.inlineComment.isCommentsOnMediaBugVideoCommentEnabled) !== null && _providers$inlineComm2 !== void 0 ? _providers$inlineComm2 : false;
33
34
  if (!range || type !== 'hover') {
34
35
  return null;
35
36
  }
36
- var documentPosition = actions.getPositionFromRange(range, isCommentsOnMediaBugFixEnabled);
37
+ var documentPosition = actions.getPositionFromRange(range, isCommentsOnMediaBugFixEnabled, isCommentsOnMediaBugVideoCommentEnabled);
37
38
  return /*#__PURE__*/_react.default.createElement(_mounter.Mounter, {
38
39
  isWithinRange: isWithinRange,
39
40
  range: range,
@@ -74,8 +74,7 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
74
74
  }
75
75
  return result;
76
76
  }, [documentPosition, generateIndexMatch]);
77
- var applyDraftModeCallback = (0, _react.useCallback)(function () {
78
- var keepNativeSelection = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
77
+ var applyDraftModeCallback = (0, _react.useCallback)(function (options) {
79
78
  if (!documentPosition || !isAnnotationAllowed) {
80
79
  if (createAnalyticsEvent) {
81
80
  createAnalyticsEvent({
@@ -86,7 +85,7 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
86
85
  eventType: _analytics.EVENT_TYPE.TRACK
87
86
  }).fire(_analyticsListeners.FabricChannel.editor);
88
87
  }
89
- return;
88
+ return false;
90
89
  }
91
90
  setDraftDocumentPosition(documentPosition);
92
91
  applyAnnotationDraftAt(documentPosition);
@@ -103,7 +102,7 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
103
102
  }).fire(_analyticsListeners.FabricChannel.editor);
104
103
  }
105
104
  window.requestAnimationFrame(function () {
106
- if (keepNativeSelection) {
105
+ if (options.keepNativeSelection) {
107
106
  (0, _draft.updateWindowSelectionAroundDraft)(documentPosition);
108
107
  } else {
109
108
  var sel = window.getSelection();
@@ -112,7 +111,16 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
112
111
  }
113
112
  }
114
113
  });
115
- }, [documentPosition, isAnnotationAllowed, applyAnnotationDraftAt, createAnalyticsEvent, actions, range]);
114
+ var positionToAnnotate = draftDocumentPosition || documentPosition;
115
+ if (!positionToAnnotate || !applyAnnotation || !options.annotationId) {
116
+ return false;
117
+ }
118
+ var annotation = {
119
+ annotationId: options.annotationId,
120
+ annotationType: _adfSchema.AnnotationTypes.INLINE_COMMENT
121
+ };
122
+ return applyAnnotation(positionToAnnotate, annotation, isCommentsOnMediaBugFixEnabled);
123
+ }, [documentPosition, isAnnotationAllowed, applyAnnotationDraftAt, createAnalyticsEvent, applyAnnotation, draftDocumentPosition, isCommentsOnMediaBugFixEnabled, actions, range]);
116
124
  var removeDraftModeCallback = (0, _react.useCallback)(function () {
117
125
  clearAnnotationDraft();
118
126
  setDraftDocumentPosition(null);
@@ -145,11 +145,11 @@ export default class RendererActions {
145
145
  }
146
146
  return this._privateValidatePositionsForAnnotation(pos.from, pos.to);
147
147
  }
148
- getPositionFromRange(range, isCommentsOnMediaBugFixEnabled) {
148
+ getPositionFromRange(range, isCommentsOnMediaBugFixEnabled, isCommentsOnMediaBugVideoComment) {
149
149
  if (!this.doc || !this.schema || !range) {
150
150
  return false;
151
151
  }
152
- return getPosFromRange(range, isCommentsOnMediaBugFixEnabled);
152
+ return getPosFromRange(range, isCommentsOnMediaBugFixEnabled, isCommentsOnMediaBugVideoComment);
153
153
  }
154
154
  getAnnotationMarks() {
155
155
  const {
@@ -192,7 +192,7 @@ export default class RendererActions {
192
192
  }
193
193
  return getAnnotationIdsFromRange(pos, this.doc, this.schema);
194
194
  }
195
- applyAnnotation(pos, annotation, isCommentsOnMediaBugFixEnabled) {
195
+ applyAnnotation(pos, annotation, isCommentsOnMediaBugFixEnabled, isCommentsOnMediaBugVideoCommentEnabled) {
196
196
  if (!this.doc || !pos || !this.schema) {
197
197
  return false;
198
198
  }
@@ -169,29 +169,47 @@ export function resolvePos(node, offset) {
169
169
  }
170
170
  return resolvedPos + offset;
171
171
  }
172
- export function getPosFromRange(range, isCommentsOnMediaBugFixEnabled) {
172
+ export function getPosFromRange(range, isCommentsOnMediaBugFixEnabled, isCommentsOnMediaBugVideoCommentEnabled) {
173
173
  const {
174
174
  startContainer,
175
175
  startOffset,
176
176
  endContainer,
177
177
  endOffset
178
178
  } = range;
179
- const possibleMediaElement = findParent(startContainer);
180
- if (possibleMediaElement && getNodeType(possibleMediaElement) === 'media') {
181
- let pos;
182
- if (isCommentsOnMediaBugFixEnabled) {
183
- const mediaSingleElement = findMediaParent(possibleMediaElement);
179
+ const possibleMediaOrMediaSingleElement = findParent(startContainer);
180
+ if (isCommentsOnMediaBugVideoCommentEnabled) {
181
+ // Video hover targets return media single, not media, thus, the extra check in condition.
182
+ const isMediaOrMediaSingle = possibleMediaOrMediaSingleElement && /media|mediaSingle/.test(getNodeType(possibleMediaOrMediaSingleElement) || '');
183
+ if (isMediaOrMediaSingle) {
184
+ let pos;
185
+ const mediaSingleElement = getNodeType(possibleMediaOrMediaSingleElement) === 'mediaSingle' ? possibleMediaOrMediaSingleElement : findMediaParent(possibleMediaOrMediaSingleElement);
184
186
  if (mediaSingleElement) {
185
187
  pos = getStartPos(mediaSingleElement);
186
188
  }
187
- } else {
188
- pos = getStartPos(possibleMediaElement);
189
+ if (pos !== undefined) {
190
+ return {
191
+ from: pos,
192
+ to: pos
193
+ };
194
+ }
189
195
  }
190
- if (pos !== undefined) {
191
- return {
192
- from: pos,
193
- to: pos
194
- };
196
+ } else {
197
+ if (possibleMediaOrMediaSingleElement && getNodeType(possibleMediaOrMediaSingleElement) === 'media') {
198
+ let pos;
199
+ if (isCommentsOnMediaBugFixEnabled) {
200
+ const mediaSingleElement = findMediaParent(possibleMediaOrMediaSingleElement);
201
+ if (mediaSingleElement) {
202
+ pos = getStartPos(mediaSingleElement);
203
+ }
204
+ } else {
205
+ pos = getStartPos(possibleMediaOrMediaSingleElement);
206
+ }
207
+ if (pos !== undefined) {
208
+ return {
209
+ from: pos,
210
+ to: pos
211
+ };
212
+ }
195
213
  }
196
214
  }
197
215
  const from = resolvePos(startContainer, startOffset);
@@ -37,7 +37,7 @@ import { nodeToReact } from '../../react/nodes';
37
37
  export const NORMAL_SEVERITY_THRESHOLD = 2000;
38
38
  export const DEGRADED_SEVERITY_THRESHOLD = 3000;
39
39
  const packageName = "@atlaskit/renderer";
40
- const packageVersion = "109.25.4";
40
+ const packageVersion = "109.26.0";
41
41
  export const defaultNodeComponents = nodeToReact;
42
42
  export class Renderer extends PureComponent {
43
43
  constructor(props) {
@@ -53,7 +53,7 @@ export const Mounter = /*#__PURE__*/React.memo(props => {
53
53
  }
54
54
  return result;
55
55
  }, [documentPosition, generateIndexMatch]);
56
- const applyDraftModeCallback = useCallback((keepNativeSelection = true) => {
56
+ const applyDraftModeCallback = useCallback(options => {
57
57
  if (!documentPosition || !isAnnotationAllowed) {
58
58
  if (createAnalyticsEvent) {
59
59
  createAnalyticsEvent({
@@ -64,7 +64,7 @@ export const Mounter = /*#__PURE__*/React.memo(props => {
64
64
  eventType: EVENT_TYPE.TRACK
65
65
  }).fire(FabricChannel.editor);
66
66
  }
67
- return;
67
+ return false;
68
68
  }
69
69
  setDraftDocumentPosition(documentPosition);
70
70
  applyAnnotationDraftAt(documentPosition);
@@ -81,7 +81,7 @@ export const Mounter = /*#__PURE__*/React.memo(props => {
81
81
  }).fire(FabricChannel.editor);
82
82
  }
83
83
  window.requestAnimationFrame(() => {
84
- if (keepNativeSelection) {
84
+ if (options.keepNativeSelection) {
85
85
  updateWindowSelectionAroundDraft(documentPosition);
86
86
  } else {
87
87
  const sel = window.getSelection();
@@ -90,7 +90,16 @@ export const Mounter = /*#__PURE__*/React.memo(props => {
90
90
  }
91
91
  }
92
92
  });
93
- }, [documentPosition, isAnnotationAllowed, applyAnnotationDraftAt, createAnalyticsEvent, actions, range]);
93
+ const positionToAnnotate = draftDocumentPosition || documentPosition;
94
+ if (!positionToAnnotate || !applyAnnotation || !options.annotationId) {
95
+ return false;
96
+ }
97
+ const annotation = {
98
+ annotationId: options.annotationId,
99
+ annotationType: AnnotationTypes.INLINE_COMMENT
100
+ };
101
+ return applyAnnotation(positionToAnnotate, annotation, isCommentsOnMediaBugFixEnabled);
102
+ }, [documentPosition, isAnnotationAllowed, applyAnnotationDraftAt, createAnalyticsEvent, applyAnnotation, draftDocumentPosition, isCommentsOnMediaBugFixEnabled, actions, range]);
94
103
  const removeDraftModeCallback = useCallback(() => {
95
104
  clearAnnotationDraft();
96
105
  setDraftDocumentPosition(null);
@@ -5,7 +5,7 @@ import { useAnnotationRangeDispatch, useAnnotationRangeState } from '../contexts
5
5
  import { useAnnotationHoverContext } from '../contexts/AnnotationHoverContext';
6
6
  import { ProvidersContext } from '../context';
7
7
  export const RangeValidator = props => {
8
- var _providers$inlineComm;
8
+ var _providers$inlineComm, _providers$inlineComm2;
9
9
  const {
10
10
  component,
11
11
  rendererRef,
@@ -26,10 +26,11 @@ export const RangeValidator = props => {
26
26
  } = useAnnotationHoverContext();
27
27
  const providers = useContext(ProvidersContext);
28
28
  const isCommentsOnMediaBugFixEnabled = (_providers$inlineComm = providers === null || providers === void 0 ? void 0 : providers.inlineComment.isCommentsOnMediaBugFixEnabled) !== null && _providers$inlineComm !== void 0 ? _providers$inlineComm : false;
29
+ const isCommentsOnMediaBugVideoCommentEnabled = (_providers$inlineComm2 = providers === null || providers === void 0 ? void 0 : providers.inlineComment.isCommentsOnMediaBugVideoCommentEnabled) !== null && _providers$inlineComm2 !== void 0 ? _providers$inlineComm2 : false;
29
30
  if (!range || type !== 'hover') {
30
31
  return null;
31
32
  }
32
- const documentPosition = actions.getPositionFromRange(range, isCommentsOnMediaBugFixEnabled);
33
+ const documentPosition = actions.getPositionFromRange(range, isCommentsOnMediaBugFixEnabled, isCommentsOnMediaBugVideoCommentEnabled);
33
34
  return /*#__PURE__*/React.createElement(Mounter, {
34
35
  isWithinRange: isWithinRange,
35
36
  range: range,
@@ -62,7 +62,7 @@ export const SelectionInlineCommentMounter = /*#__PURE__*/React.memo(props => {
62
62
  }
63
63
  return result;
64
64
  }, [documentPosition, generateIndexMatch]);
65
- const applyDraftModeCallback = useCallback((keepNativeSelection = true) => {
65
+ const applyDraftModeCallback = useCallback(options => {
66
66
  if (!documentPosition || !isAnnotationAllowed) {
67
67
  if (createAnalyticsEvent) {
68
68
  createAnalyticsEvent({
@@ -73,7 +73,7 @@ export const SelectionInlineCommentMounter = /*#__PURE__*/React.memo(props => {
73
73
  eventType: EVENT_TYPE.TRACK
74
74
  }).fire(FabricChannel.editor);
75
75
  }
76
- return;
76
+ return false;
77
77
  }
78
78
  setDraftDocumentPosition(documentPosition);
79
79
  applyAnnotationDraftAt(documentPosition);
@@ -90,7 +90,7 @@ export const SelectionInlineCommentMounter = /*#__PURE__*/React.memo(props => {
90
90
  }).fire(FabricChannel.editor);
91
91
  }
92
92
  window.requestAnimationFrame(() => {
93
- if (keepNativeSelection) {
93
+ if (options.keepNativeSelection) {
94
94
  updateWindowSelectionAroundDraft(documentPosition);
95
95
  } else {
96
96
  const sel = window.getSelection();
@@ -99,7 +99,16 @@ export const SelectionInlineCommentMounter = /*#__PURE__*/React.memo(props => {
99
99
  }
100
100
  }
101
101
  });
102
- }, [documentPosition, isAnnotationAllowed, applyAnnotationDraftAt, createAnalyticsEvent, actions, range]);
102
+ const positionToAnnotate = draftDocumentPosition || documentPosition;
103
+ if (!positionToAnnotate || !applyAnnotation || !options.annotationId) {
104
+ return false;
105
+ }
106
+ const annotation = {
107
+ annotationId: options.annotationId,
108
+ annotationType: AnnotationTypes.INLINE_COMMENT
109
+ };
110
+ return applyAnnotation(positionToAnnotate, annotation, isCommentsOnMediaBugFixEnabled);
111
+ }, [documentPosition, isAnnotationAllowed, applyAnnotationDraftAt, createAnalyticsEvent, applyAnnotation, draftDocumentPosition, isCommentsOnMediaBugFixEnabled, actions, range]);
103
112
  const removeDraftModeCallback = useCallback(() => {
104
113
  clearAnnotationDraft();
105
114
  setDraftDocumentPosition(null);
@@ -164,11 +164,11 @@ var RendererActions = /*#__PURE__*/function () {
164
164
  }
165
165
  }, {
166
166
  key: "getPositionFromRange",
167
- value: function getPositionFromRange(range, isCommentsOnMediaBugFixEnabled) {
167
+ value: function getPositionFromRange(range, isCommentsOnMediaBugFixEnabled, isCommentsOnMediaBugVideoComment) {
168
168
  if (!this.doc || !this.schema || !range) {
169
169
  return false;
170
170
  }
171
- return getPosFromRange(range, isCommentsOnMediaBugFixEnabled);
171
+ return getPosFromRange(range, isCommentsOnMediaBugFixEnabled, isCommentsOnMediaBugVideoComment);
172
172
  }
173
173
  }, {
174
174
  key: "getAnnotationMarks",
@@ -213,7 +213,7 @@ var RendererActions = /*#__PURE__*/function () {
213
213
  }
214
214
  }, {
215
215
  key: "applyAnnotation",
216
- value: function applyAnnotation(pos, annotation, isCommentsOnMediaBugFixEnabled) {
216
+ value: function applyAnnotation(pos, annotation, isCommentsOnMediaBugFixEnabled, isCommentsOnMediaBugVideoCommentEnabled) {
217
217
  if (!this.doc || !pos || !this.schema) {
218
218
  return false;
219
219
  }
@@ -165,27 +165,45 @@ export function resolvePos(node, offset) {
165
165
  }
166
166
  return resolvedPos + offset;
167
167
  }
168
- export function getPosFromRange(range, isCommentsOnMediaBugFixEnabled) {
168
+ export function getPosFromRange(range, isCommentsOnMediaBugFixEnabled, isCommentsOnMediaBugVideoCommentEnabled) {
169
169
  var startContainer = range.startContainer,
170
170
  startOffset = range.startOffset,
171
171
  endContainer = range.endContainer,
172
172
  endOffset = range.endOffset;
173
- var possibleMediaElement = findParent(startContainer);
174
- if (possibleMediaElement && getNodeType(possibleMediaElement) === 'media') {
175
- var pos;
176
- if (isCommentsOnMediaBugFixEnabled) {
177
- var mediaSingleElement = findMediaParent(possibleMediaElement);
173
+ var possibleMediaOrMediaSingleElement = findParent(startContainer);
174
+ if (isCommentsOnMediaBugVideoCommentEnabled) {
175
+ // Video hover targets return media single, not media, thus, the extra check in condition.
176
+ var isMediaOrMediaSingle = possibleMediaOrMediaSingleElement && /media|mediaSingle/.test(getNodeType(possibleMediaOrMediaSingleElement) || '');
177
+ if (isMediaOrMediaSingle) {
178
+ var pos;
179
+ var mediaSingleElement = getNodeType(possibleMediaOrMediaSingleElement) === 'mediaSingle' ? possibleMediaOrMediaSingleElement : findMediaParent(possibleMediaOrMediaSingleElement);
178
180
  if (mediaSingleElement) {
179
181
  pos = getStartPos(mediaSingleElement);
180
182
  }
181
- } else {
182
- pos = getStartPos(possibleMediaElement);
183
+ if (pos !== undefined) {
184
+ return {
185
+ from: pos,
186
+ to: pos
187
+ };
188
+ }
183
189
  }
184
- if (pos !== undefined) {
185
- return {
186
- from: pos,
187
- to: pos
188
- };
190
+ } else {
191
+ if (possibleMediaOrMediaSingleElement && getNodeType(possibleMediaOrMediaSingleElement) === 'media') {
192
+ var _pos;
193
+ if (isCommentsOnMediaBugFixEnabled) {
194
+ var _mediaSingleElement = findMediaParent(possibleMediaOrMediaSingleElement);
195
+ if (_mediaSingleElement) {
196
+ _pos = getStartPos(_mediaSingleElement);
197
+ }
198
+ } else {
199
+ _pos = getStartPos(possibleMediaOrMediaSingleElement);
200
+ }
201
+ if (_pos !== undefined) {
202
+ return {
203
+ from: _pos,
204
+ to: _pos
205
+ };
206
+ }
189
207
  }
190
208
  }
191
209
  var from = resolvePos(startContainer, startOffset);
@@ -47,7 +47,7 @@ import { nodeToReact } from '../../react/nodes';
47
47
  export var NORMAL_SEVERITY_THRESHOLD = 2000;
48
48
  export var DEGRADED_SEVERITY_THRESHOLD = 3000;
49
49
  var packageName = "@atlaskit/renderer";
50
- var packageVersion = "109.25.4";
50
+ var packageVersion = "109.26.0";
51
51
  export var defaultNodeComponents = nodeToReact;
52
52
  export var Renderer = /*#__PURE__*/function (_PureComponent) {
53
53
  _inherits(Renderer, _PureComponent);
@@ -55,8 +55,7 @@ export var Mounter = /*#__PURE__*/React.memo(function (props) {
55
55
  }
56
56
  return result;
57
57
  }, [documentPosition, generateIndexMatch]);
58
- var applyDraftModeCallback = useCallback(function () {
59
- var keepNativeSelection = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
58
+ var applyDraftModeCallback = useCallback(function (options) {
60
59
  if (!documentPosition || !isAnnotationAllowed) {
61
60
  if (createAnalyticsEvent) {
62
61
  createAnalyticsEvent({
@@ -67,7 +66,7 @@ export var Mounter = /*#__PURE__*/React.memo(function (props) {
67
66
  eventType: EVENT_TYPE.TRACK
68
67
  }).fire(FabricChannel.editor);
69
68
  }
70
- return;
69
+ return false;
71
70
  }
72
71
  setDraftDocumentPosition(documentPosition);
73
72
  applyAnnotationDraftAt(documentPosition);
@@ -84,7 +83,7 @@ export var Mounter = /*#__PURE__*/React.memo(function (props) {
84
83
  }).fire(FabricChannel.editor);
85
84
  }
86
85
  window.requestAnimationFrame(function () {
87
- if (keepNativeSelection) {
86
+ if (options.keepNativeSelection) {
88
87
  updateWindowSelectionAroundDraft(documentPosition);
89
88
  } else {
90
89
  var sel = window.getSelection();
@@ -93,7 +92,16 @@ export var Mounter = /*#__PURE__*/React.memo(function (props) {
93
92
  }
94
93
  }
95
94
  });
96
- }, [documentPosition, isAnnotationAllowed, applyAnnotationDraftAt, createAnalyticsEvent, actions, range]);
95
+ var positionToAnnotate = draftDocumentPosition || documentPosition;
96
+ if (!positionToAnnotate || !applyAnnotation || !options.annotationId) {
97
+ return false;
98
+ }
99
+ var annotation = {
100
+ annotationId: options.annotationId,
101
+ annotationType: AnnotationTypes.INLINE_COMMENT
102
+ };
103
+ return applyAnnotation(positionToAnnotate, annotation, isCommentsOnMediaBugFixEnabled);
104
+ }, [documentPosition, isAnnotationAllowed, applyAnnotationDraftAt, createAnalyticsEvent, applyAnnotation, draftDocumentPosition, isCommentsOnMediaBugFixEnabled, actions, range]);
97
105
  var removeDraftModeCallback = useCallback(function () {
98
106
  clearAnnotationDraft();
99
107
  setDraftDocumentPosition(null);
@@ -5,7 +5,7 @@ import { useAnnotationRangeDispatch, useAnnotationRangeState } from '../contexts
5
5
  import { useAnnotationHoverContext } from '../contexts/AnnotationHoverContext';
6
6
  import { ProvidersContext } from '../context';
7
7
  export var RangeValidator = function RangeValidator(props) {
8
- var _providers$inlineComm;
8
+ var _providers$inlineComm, _providers$inlineComm2;
9
9
  var component = props.component,
10
10
  rendererRef = props.rendererRef,
11
11
  applyAnnotationDraftAt = props.applyAnnotationDraftAt,
@@ -21,10 +21,11 @@ export var RangeValidator = function RangeValidator(props) {
21
21
  isWithinRange = _useAnnotationHoverCo.isWithinRange;
22
22
  var providers = useContext(ProvidersContext);
23
23
  var isCommentsOnMediaBugFixEnabled = (_providers$inlineComm = providers === null || providers === void 0 ? void 0 : providers.inlineComment.isCommentsOnMediaBugFixEnabled) !== null && _providers$inlineComm !== void 0 ? _providers$inlineComm : false;
24
+ var isCommentsOnMediaBugVideoCommentEnabled = (_providers$inlineComm2 = providers === null || providers === void 0 ? void 0 : providers.inlineComment.isCommentsOnMediaBugVideoCommentEnabled) !== null && _providers$inlineComm2 !== void 0 ? _providers$inlineComm2 : false;
24
25
  if (!range || type !== 'hover') {
25
26
  return null;
26
27
  }
27
- var documentPosition = actions.getPositionFromRange(range, isCommentsOnMediaBugFixEnabled);
28
+ var documentPosition = actions.getPositionFromRange(range, isCommentsOnMediaBugFixEnabled, isCommentsOnMediaBugVideoCommentEnabled);
28
29
  return /*#__PURE__*/React.createElement(Mounter, {
29
30
  isWithinRange: isWithinRange,
30
31
  range: range,
@@ -64,8 +64,7 @@ export var SelectionInlineCommentMounter = /*#__PURE__*/React.memo(function (pro
64
64
  }
65
65
  return result;
66
66
  }, [documentPosition, generateIndexMatch]);
67
- var applyDraftModeCallback = useCallback(function () {
68
- var keepNativeSelection = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
67
+ var applyDraftModeCallback = useCallback(function (options) {
69
68
  if (!documentPosition || !isAnnotationAllowed) {
70
69
  if (createAnalyticsEvent) {
71
70
  createAnalyticsEvent({
@@ -76,7 +75,7 @@ export var SelectionInlineCommentMounter = /*#__PURE__*/React.memo(function (pro
76
75
  eventType: EVENT_TYPE.TRACK
77
76
  }).fire(FabricChannel.editor);
78
77
  }
79
- return;
78
+ return false;
80
79
  }
81
80
  setDraftDocumentPosition(documentPosition);
82
81
  applyAnnotationDraftAt(documentPosition);
@@ -93,7 +92,7 @@ export var SelectionInlineCommentMounter = /*#__PURE__*/React.memo(function (pro
93
92
  }).fire(FabricChannel.editor);
94
93
  }
95
94
  window.requestAnimationFrame(function () {
96
- if (keepNativeSelection) {
95
+ if (options.keepNativeSelection) {
97
96
  updateWindowSelectionAroundDraft(documentPosition);
98
97
  } else {
99
98
  var sel = window.getSelection();
@@ -102,7 +101,16 @@ export var SelectionInlineCommentMounter = /*#__PURE__*/React.memo(function (pro
102
101
  }
103
102
  }
104
103
  });
105
- }, [documentPosition, isAnnotationAllowed, applyAnnotationDraftAt, createAnalyticsEvent, actions, range]);
104
+ var positionToAnnotate = draftDocumentPosition || documentPosition;
105
+ if (!positionToAnnotate || !applyAnnotation || !options.annotationId) {
106
+ return false;
107
+ }
108
+ var annotation = {
109
+ annotationId: options.annotationId,
110
+ annotationType: AnnotationTypes.INLINE_COMMENT
111
+ };
112
+ return applyAnnotation(positionToAnnotate, annotation, isCommentsOnMediaBugFixEnabled);
113
+ }, [documentPosition, isAnnotationAllowed, applyAnnotationDraftAt, createAnalyticsEvent, applyAnnotation, draftDocumentPosition, isCommentsOnMediaBugFixEnabled, actions, range]);
106
114
  var removeDraftModeCallback = useCallback(function () {
107
115
  clearAnnotationDraft();
108
116
  setDraftDocumentPosition(null);
@@ -52,10 +52,10 @@ export default class RendererActions implements RendererActionsOptions, Annotati
52
52
  annotate(range: Range, annotationId: string, annotationType: 'inlineComment'): AnnotationActionResult;
53
53
  isValidAnnotationRange(range: Range | null): boolean;
54
54
  isValidAnnotationPosition(pos: Position): boolean;
55
- getPositionFromRange(range: Range | null, isCommentsOnMediaBugFixEnabled?: boolean): Position | false;
55
+ getPositionFromRange(range: Range | null, isCommentsOnMediaBugFixEnabled?: boolean, isCommentsOnMediaBugVideoComment?: boolean): Position | false;
56
56
  getAnnotationMarks(): Mark[];
57
57
  getAnnotationsByPosition(range: Range): string[];
58
- applyAnnotation(pos: Position, annotation: Annotation, isCommentsOnMediaBugFixEnabled?: boolean): AnnotationActionResult;
58
+ applyAnnotation(pos: Position, annotation: Annotation, isCommentsOnMediaBugFixEnabled?: boolean, isCommentsOnMediaBugVideoCommentEnabled?: boolean): AnnotationActionResult;
59
59
  generateAnnotationIndexMatch(pos: Position): AnnotationByMatches | false;
60
60
  }
61
61
  export {};
@@ -6,7 +6,7 @@ interface AnnotationStepOptions {
6
6
  annotationId: string;
7
7
  annotationType: 'inlineComment';
8
8
  }
9
- export declare function getPosFromRange(range: Range, isCommentsOnMediaBugFixEnabled?: boolean): {
9
+ export declare function getPosFromRange(range: Range, isCommentsOnMediaBugFixEnabled?: boolean, isCommentsOnMediaBugVideoCommentEnabled?: boolean): {
10
10
  from: number;
11
11
  to: number;
12
12
  } | false;
@@ -52,10 +52,10 @@ export default class RendererActions implements RendererActionsOptions, Annotati
52
52
  annotate(range: Range, annotationId: string, annotationType: 'inlineComment'): AnnotationActionResult;
53
53
  isValidAnnotationRange(range: Range | null): boolean;
54
54
  isValidAnnotationPosition(pos: Position): boolean;
55
- getPositionFromRange(range: Range | null, isCommentsOnMediaBugFixEnabled?: boolean): Position | false;
55
+ getPositionFromRange(range: Range | null, isCommentsOnMediaBugFixEnabled?: boolean, isCommentsOnMediaBugVideoComment?: boolean): Position | false;
56
56
  getAnnotationMarks(): Mark[];
57
57
  getAnnotationsByPosition(range: Range): string[];
58
- applyAnnotation(pos: Position, annotation: Annotation, isCommentsOnMediaBugFixEnabled?: boolean): AnnotationActionResult;
58
+ applyAnnotation(pos: Position, annotation: Annotation, isCommentsOnMediaBugFixEnabled?: boolean, isCommentsOnMediaBugVideoCommentEnabled?: boolean): AnnotationActionResult;
59
59
  generateAnnotationIndexMatch(pos: Position): AnnotationByMatches | false;
60
60
  }
61
61
  export {};
@@ -6,7 +6,7 @@ interface AnnotationStepOptions {
6
6
  annotationId: string;
7
7
  annotationType: 'inlineComment';
8
8
  }
9
- export declare function getPosFromRange(range: Range, isCommentsOnMediaBugFixEnabled?: boolean): {
9
+ export declare function getPosFromRange(range: Range, isCommentsOnMediaBugFixEnabled?: boolean, isCommentsOnMediaBugVideoCommentEnabled?: boolean): {
10
10
  from: number;
11
11
  to: number;
12
12
  } | false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/renderer",
3
- "version": "109.25.4",
3
+ "version": "109.26.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.3.0",
32
32
  "@atlaskit/button": "^17.14.0",
33
33
  "@atlaskit/code": "^15.2.0",
34
- "@atlaskit/editor-common": "^79.2.0",
34
+ "@atlaskit/editor-common": "^80.0.0",
35
35
  "@atlaskit/editor-json-transformer": "^8.12.0",
36
36
  "@atlaskit/editor-palette": "1.6.0",
37
37
  "@atlaskit/editor-prosemirror": "4.0.1",
@@ -47,11 +47,11 @@
47
47
  "@atlaskit/media-ui": "^25.10.0",
48
48
  "@atlaskit/media-viewer": "^48.5.0",
49
49
  "@atlaskit/platform-feature-flags": "^0.2.0",
50
- "@atlaskit/smart-card": "^26.63.0",
50
+ "@atlaskit/smart-card": "^26.66.0",
51
51
  "@atlaskit/status": "^1.4.0",
52
52
  "@atlaskit/task-decision": "^17.10.0",
53
53
  "@atlaskit/theme": "^12.8.0",
54
- "@atlaskit/tokens": "^1.46.0",
54
+ "@atlaskit/tokens": "^1.48.0",
55
55
  "@atlaskit/tooltip": "^18.3.0",
56
56
  "@babel/runtime": "^7.0.0",
57
57
  "@emotion/react": "^11.7.1",