@atlaskit/renderer 115.0.4 → 115.0.6

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.
Files changed (68) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/actions/index.js +14 -8
  3. package/dist/cjs/react/nodes/media/index.js +5 -1
  4. package/dist/cjs/react/nodes/tableNew.js +9 -3
  5. package/dist/cjs/ui/Renderer/RendererStyleContainer.js +6 -1
  6. package/dist/cjs/ui/Renderer/index.js +4 -5
  7. package/dist/cjs/ui/annotations/context.js +14 -1
  8. package/dist/cjs/ui/annotations/contexts/AnnotationRangeContext.js +199 -35
  9. package/dist/cjs/ui/annotations/draft/component.js +6 -1
  10. package/dist/cjs/ui/annotations/element/useInlineAnnotationProps.js +5 -1
  11. package/dist/cjs/ui/annotations/hooks/user-selection.js +14 -9
  12. package/dist/cjs/ui/annotations/hover/mounter.js +31 -10
  13. package/dist/cjs/ui/annotations/hover/range-validator.js +2 -1
  14. package/dist/cjs/ui/annotations/index.js +2 -1
  15. package/dist/cjs/ui/annotations/selection/mounter.js +41 -12
  16. package/dist/cjs/ui/annotations/selection/range-validator.js +10 -7
  17. package/dist/cjs/ui/annotations/wrapper.js +48 -2
  18. package/dist/es2019/actions/index.js +12 -8
  19. package/dist/es2019/react/nodes/media/index.js +6 -1
  20. package/dist/es2019/react/nodes/tableNew.js +9 -3
  21. package/dist/es2019/ui/Renderer/RendererStyleContainer.js +8 -1
  22. package/dist/es2019/ui/Renderer/index.js +4 -5
  23. package/dist/es2019/ui/annotations/context.js +14 -1
  24. package/dist/es2019/ui/annotations/contexts/AnnotationRangeContext.js +207 -30
  25. package/dist/es2019/ui/annotations/draft/component.js +7 -1
  26. package/dist/es2019/ui/annotations/element/useInlineAnnotationProps.js +6 -1
  27. package/dist/es2019/ui/annotations/hooks/user-selection.js +14 -9
  28. package/dist/es2019/ui/annotations/hover/mounter.js +33 -10
  29. package/dist/es2019/ui/annotations/hover/range-validator.js +2 -1
  30. package/dist/es2019/ui/annotations/index.js +2 -1
  31. package/dist/es2019/ui/annotations/selection/mounter.js +43 -12
  32. package/dist/es2019/ui/annotations/selection/range-validator.js +6 -4
  33. package/dist/es2019/ui/annotations/wrapper.js +49 -1
  34. package/dist/esm/actions/index.js +14 -8
  35. package/dist/esm/react/nodes/media/index.js +5 -1
  36. package/dist/esm/react/nodes/tableNew.js +9 -3
  37. package/dist/esm/ui/Renderer/RendererStyleContainer.js +6 -1
  38. package/dist/esm/ui/Renderer/index.js +4 -5
  39. package/dist/esm/ui/annotations/context.js +14 -1
  40. package/dist/esm/ui/annotations/contexts/AnnotationRangeContext.js +198 -34
  41. package/dist/esm/ui/annotations/draft/component.js +6 -1
  42. package/dist/esm/ui/annotations/element/useInlineAnnotationProps.js +5 -1
  43. package/dist/esm/ui/annotations/hooks/user-selection.js +14 -9
  44. package/dist/esm/ui/annotations/hover/mounter.js +31 -10
  45. package/dist/esm/ui/annotations/hover/range-validator.js +2 -1
  46. package/dist/esm/ui/annotations/index.js +2 -1
  47. package/dist/esm/ui/annotations/selection/mounter.js +41 -12
  48. package/dist/esm/ui/annotations/selection/range-validator.js +10 -7
  49. package/dist/esm/ui/annotations/wrapper.js +47 -1
  50. package/dist/types/actions/index.d.ts +5 -0
  51. package/dist/types/ui/annotations/context.d.ts +13 -1
  52. package/dist/types/ui/annotations/contexts/AnnotationRangeContext.d.ts +46 -4
  53. package/dist/types/ui/annotations/hooks/user-selection.d.ts +2 -1
  54. package/dist/types/ui/annotations/hover/mounter.d.ts +10 -2
  55. package/dist/types/ui/annotations/hover/range-validator.d.ts +14 -3
  56. package/dist/types/ui/annotations/selection/mounter.d.ts +10 -2
  57. package/dist/types/ui/annotations/selection/range-validator.d.ts +14 -3
  58. package/dist/types/ui/annotations/wrapper.d.ts +2 -0
  59. package/dist/types-ts4.5/actions/index.d.ts +5 -0
  60. package/dist/types-ts4.5/ui/annotations/context.d.ts +13 -1
  61. package/dist/types-ts4.5/ui/annotations/contexts/AnnotationRangeContext.d.ts +46 -4
  62. package/dist/types-ts4.5/ui/annotations/hooks/user-selection.d.ts +2 -0
  63. package/dist/types-ts4.5/ui/annotations/hover/mounter.d.ts +10 -2
  64. package/dist/types-ts4.5/ui/annotations/hover/range-validator.d.ts +14 -3
  65. package/dist/types-ts4.5/ui/annotations/selection/mounter.d.ts +10 -2
  66. package/dist/types-ts4.5/ui/annotations/selection/range-validator.d.ts +14 -3
  67. package/dist/types-ts4.5/ui/annotations/wrapper.d.ts +2 -0
  68. package/package.json +8 -2
@@ -9,10 +9,12 @@ exports.Mounter = void 0;
9
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
10
  var _react = _interopRequireWildcard(require("react"));
11
11
  var _adfSchema = require("@atlaskit/adf-schema");
12
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
13
  var _dom = require("../draft/dom");
13
14
  var _types = require("@atlaskit/analytics-listeners/types");
14
15
  var _analytics = require("@atlaskit/editor-common/analytics");
15
16
  var _RendererActionsContext = require("../../RendererActionsContext");
17
+ var _AnnotationRangeContext = require("../contexts/AnnotationRangeContext");
16
18
  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); }
17
19
  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 && {}.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; }
18
20
  var Mounter = exports.Mounter = /*#__PURE__*/_react.default.memo(function (props) {
@@ -28,13 +30,24 @@ var Mounter = exports.Mounter = /*#__PURE__*/_react.default.memo(function (props
28
30
  applyAnnotation = props.applyAnnotation,
29
31
  createAnalyticsEvent = props.createAnalyticsEvent,
30
32
  generateIndexMatch = props.generateIndexMatch;
33
+
34
+ // if platform_renderer_annotation_draft_position_fix is enabled; then
35
+ var _useAnnotationRangeDi = (0, _AnnotationRangeContext.useAnnotationRangeDispatch)(),
36
+ promoteHoverToDraft = _useAnnotationRangeDi.promoteHoverToDraft,
37
+ clearHoverDraft = _useAnnotationRangeDi.clearHoverDraft;
38
+ var _useAnnotationRangeSt = (0, _AnnotationRangeContext.useAnnotationRangeState)(),
39
+ hoverDraftDocumentPosition = _useAnnotationRangeSt.hoverDraftDocumentPosition;
40
+ // else;
31
41
  var _useState = (0, _react.useState)(),
32
42
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
33
43
  draftDocumentPosition = _useState2[0],
34
44
  setDraftDocumentPosition = _useState2[1];
45
+ // end-if
46
+
35
47
  var actions = (0, _react.useContext)(_RendererActionsContext.RendererContext);
36
48
  var onCreateCallback = (0, _react.useCallback)(function (annotationId) {
37
- if (!isAnnotationAllowed || !documentPosition || !applyAnnotation) {
49
+ var positionToAnnotate = (0, _platformFeatureFlags.fg)('platform_renderer_annotation_draft_position_fix') ? hoverDraftDocumentPosition || documentPosition : draftDocumentPosition || documentPosition;
50
+ if (!isAnnotationAllowed || !positionToAnnotate || !applyAnnotation) {
38
51
  return false;
39
52
  }
40
53
  var annotation = {
@@ -50,8 +63,8 @@ var Mounter = exports.Mounter = /*#__PURE__*/_react.default.memo(function (props
50
63
  eventType: _analytics.EVENT_TYPE.TRACK
51
64
  }).fire(_types.FabricChannel.editor);
52
65
  }
53
- return applyAnnotation(draftDocumentPosition || documentPosition, annotation);
54
- }, [isAnnotationAllowed, documentPosition, applyAnnotation, draftDocumentPosition, createAnalyticsEvent]);
66
+ return applyAnnotation(positionToAnnotate, annotation);
67
+ }, [isAnnotationAllowed, documentPosition, applyAnnotation, draftDocumentPosition, createAnalyticsEvent, hoverDraftDocumentPosition]);
55
68
  var createIndexCallback = (0, _react.useCallback)(function () {
56
69
  if (!documentPosition || !generateIndexMatch) {
57
70
  return false;
@@ -75,8 +88,12 @@ var Mounter = exports.Mounter = /*#__PURE__*/_react.default.memo(function (props
75
88
  }
76
89
  return false;
77
90
  }
78
- setDraftDocumentPosition(documentPosition);
79
- applyAnnotationDraftAt(documentPosition);
91
+ if ((0, _platformFeatureFlags.fg)('platform_renderer_annotation_draft_position_fix')) {
92
+ promoteHoverToDraft(documentPosition);
93
+ } else {
94
+ setDraftDocumentPosition(documentPosition);
95
+ applyAnnotationDraftAt && applyAnnotationDraftAt(documentPosition);
96
+ }
80
97
  if (createAnalyticsEvent) {
81
98
  var uniqueAnnotationsInRange = actions.getAnnotationsByPosition(range);
82
99
  createAnalyticsEvent({
@@ -99,7 +116,7 @@ var Mounter = exports.Mounter = /*#__PURE__*/_react.default.memo(function (props
99
116
  }
100
117
  }
101
118
  });
102
- var positionToAnnotate = draftDocumentPosition || documentPosition;
119
+ var positionToAnnotate = (0, _platformFeatureFlags.fg)('platform_renderer_annotation_draft_position_fix') ? hoverDraftDocumentPosition || documentPosition : draftDocumentPosition || documentPosition;
103
120
  if (!positionToAnnotate || !applyAnnotation || !options.annotationId) {
104
121
  return false;
105
122
  }
@@ -108,15 +125,19 @@ var Mounter = exports.Mounter = /*#__PURE__*/_react.default.memo(function (props
108
125
  annotationType: _adfSchema.AnnotationTypes.INLINE_COMMENT
109
126
  };
110
127
  return applyAnnotation(positionToAnnotate, annotation);
111
- }, [documentPosition, isAnnotationAllowed, applyAnnotationDraftAt, createAnalyticsEvent, applyAnnotation, draftDocumentPosition, actions, range]);
128
+ }, [documentPosition, isAnnotationAllowed, applyAnnotationDraftAt, createAnalyticsEvent, applyAnnotation, draftDocumentPosition, actions, range, promoteHoverToDraft, hoverDraftDocumentPosition]);
112
129
  var removeDraftModeCallback = (0, _react.useCallback)(function () {
113
- clearAnnotationDraft();
114
- setDraftDocumentPosition(null);
130
+ if ((0, _platformFeatureFlags.fg)('platform_renderer_annotation_draft_position_fix')) {
131
+ clearHoverDraft();
132
+ } else {
133
+ clearAnnotationDraft && clearAnnotationDraft();
134
+ setDraftDocumentPosition(null);
135
+ }
115
136
  var sel = window.getSelection();
116
137
  if (sel) {
117
138
  sel.removeAllRanges();
118
139
  }
119
- }, [clearAnnotationDraft]);
140
+ }, [clearAnnotationDraft, clearHoverDraft]);
120
141
  var onCloseCallback = (0, _react.useCallback)(function () {
121
142
  if (createAnalyticsEvent) {
122
143
  createAnalyticsEvent({
@@ -44,4 +44,5 @@ var RangeValidator = exports.RangeValidator = function RangeValidator(props) {
44
44
  clearAnnotationDraft: clearAnnotationDraft,
45
45
  createAnalyticsEvent: createAnalyticsEvent
46
46
  });
47
- };
47
+ };
48
+ RangeValidator.displayName = 'HoverRangeValidator';
@@ -56,7 +56,8 @@ var AnnotationsWrapperInner = exports.AnnotationsWrapperInner = function Annotat
56
56
  return /*#__PURE__*/_react.default.createElement(_context.InlineCommentsStateContext.Provider, {
57
57
  value: inlineCommentAnnotationsState
58
58
  }, /*#__PURE__*/_react.default.createElement(_AnnotationRangeContext.AnnotationRangeProvider, {
59
- allowCommentsOnMedia: (_providers$inlineComm = providers === null || providers === void 0 || (_providers$inlineComm2 = providers.inlineComment) === null || _providers$inlineComm2 === void 0 ? void 0 : _providers$inlineComm2.allowCommentsOnMedia) !== null && _providers$inlineComm !== void 0 ? _providers$inlineComm : false
59
+ allowCommentsOnMedia: (_providers$inlineComm = providers === null || providers === void 0 || (_providers$inlineComm2 = providers.inlineComment) === null || _providers$inlineComm2 === void 0 ? void 0 : _providers$inlineComm2.allowCommentsOnMedia) !== null && _providers$inlineComm !== void 0 ? _providers$inlineComm : false,
60
+ isNestedRender: isNestedRender
60
61
  }, /*#__PURE__*/_react.default.createElement(_AnnotationHoverContext.AnnotationHoverContext, null, /*#__PURE__*/_react.default.createElement(_wrapper.AnnotationsContextWrapper, {
61
62
  createAnalyticsEvent: createAnalyticsEvent,
62
63
  rendererRef: rendererRef,
@@ -17,6 +17,7 @@ var _analytics = require("@atlaskit/editor-common/analytics");
17
17
  var _getRendererRangeInlineNodeNames = require("../../../actions/get-renderer-range-inline-node-names");
18
18
  var _RendererActionsContext = require("../../RendererActionsContext");
19
19
  var _AnnotationManagerContext = require("../contexts/AnnotationManagerContext");
20
+ var _AnnotationRangeContext = require("../contexts/AnnotationRangeContext");
20
21
  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); }
21
22
  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 && {}.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; }
22
23
  var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#__PURE__*/_react.default.memo(function (props) {
@@ -32,10 +33,20 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
32
33
  applyAnnotation = props.applyAnnotation,
33
34
  createAnalyticsEvent = props.createAnalyticsEvent,
34
35
  generateIndexMatch = props.generateIndexMatch;
36
+
37
+ // if platform_renderer_annotation_draft_position_fix is enabled; then
38
+ var _useAnnotationRangeDi = (0, _AnnotationRangeContext.useAnnotationRangeDispatch)(),
39
+ promoteSelectionToDraft = _useAnnotationRangeDi.promoteSelectionToDraft,
40
+ clearSelectionDraft = _useAnnotationRangeDi.clearSelectionDraft;
41
+ var _useAnnotationRangeSt = (0, _AnnotationRangeContext.useAnnotationRangeState)(),
42
+ selectionDraftDocumentPosition = _useAnnotationRangeSt.selectionDraftDocumentPosition;
43
+ // else;
35
44
  var _useState = (0, _react.useState)(),
36
45
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
37
46
  draftDocumentPosition = _useState2[0],
38
47
  setDraftDocumentPosition = _useState2[1];
48
+ // end-if
49
+
39
50
  var actions = (0, _react.useContext)(_RendererActionsContext.RendererContext);
40
51
  var _useAnnotationManager = (0, _AnnotationManagerContext.useAnnotationManagerState)(),
41
52
  isDrafting = _useAnnotationManager.isDrafting,
@@ -69,7 +80,7 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
69
80
  var onCreateCallback = (0, _react.useCallback)(function (annotationId) {
70
81
  // We want to support creation on a documentPosition if the user is only using ranges
71
82
  // but we want to prioritize draft positions if they are being used by consumers
72
- var positionToAnnotate = draftDocumentPosition || documentPosition;
83
+ var positionToAnnotate = (0, _platformFeatureFlags.fg)('platform_renderer_annotation_draft_position_fix') ? selectionDraftDocumentPosition || documentPosition : draftDocumentPosition || documentPosition;
73
84
  if (!positionToAnnotate || !applyAnnotation) {
74
85
  // TODO: EDITOR-595 - This analytic event is temporary and should be removed once the following issue
75
86
  // has been identified and fixed: https://atlassian.slack.com/archives/C08JK0WSCH5/p1745902609966999
@@ -80,15 +91,19 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
80
91
  actionSubjectId: 'inlineCommentFailureReason',
81
92
  attributes: {
82
93
  reason: 'Annotation Position invalid',
83
- draftDocumentPosition: draftDocumentPosition,
94
+ draftDocumentPosition: (0, _platformFeatureFlags.fg)('platform_renderer_annotation_draft_position_fix') ? selectionDraftDocumentPosition : draftDocumentPosition,
84
95
  documentPosition: documentPosition,
85
- applyAnnotation: !!applyAnnotation
96
+ applyAnnotation: !!applyAnnotation,
97
+ isDraftPositionFixEnabled: (0, _platformFeatureFlags.fg)('platform_renderer_annotation_draft_position_fix')
86
98
  },
87
99
  eventType: _analytics.EVENT_TYPE.OPERATIONAL
88
100
  }).fire(_types.FabricChannel.editor);
89
101
  }
90
102
  return false;
91
103
  }
104
+ if ((0, _platformFeatureFlags.fg)('platform_renderer_annotations_create_debug_logging')) {
105
+ actions._setDebugLogging(true);
106
+ }
92
107
 
93
108
  // Evaluate position validity when the user commits the position to be annotated
94
109
  var isCreateAllowedOnPosition = actions.isValidAnnotationPosition(positionToAnnotate);
@@ -110,8 +125,14 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
110
125
  eventType: _analytics.EVENT_TYPE.TRACK
111
126
  }).fire(_types.FabricChannel.editor);
112
127
  }
113
- return applyAnnotation(positionToAnnotate, annotation);
114
- }, [actions, documentPosition, applyAnnotation, draftDocumentPosition, createAnalyticsEvent, inlineNodeTypes]);
128
+ if ((0, _platformFeatureFlags.fg)('platform_renderer_annotations_create_debug_logging')) {
129
+ var result = applyAnnotation(positionToAnnotate, annotation);
130
+ actions._setDebugLogging(false);
131
+ return result;
132
+ } else {
133
+ return applyAnnotation(positionToAnnotate, annotation);
134
+ }
135
+ }, [actions, documentPosition, applyAnnotation, draftDocumentPosition, createAnalyticsEvent, inlineNodeTypes, selectionDraftDocumentPosition]);
115
136
  var createIndexCallback = (0, _react.useCallback)(function () {
116
137
  if (!documentPosition || !generateIndexMatch) {
117
138
  return false;
@@ -137,8 +158,12 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
137
158
  }
138
159
  return false;
139
160
  }
140
- setDraftDocumentPosition(documentPosition);
141
- applyAnnotationDraftAt(documentPosition);
161
+ if ((0, _platformFeatureFlags.fg)('platform_renderer_annotation_draft_position_fix')) {
162
+ promoteSelectionToDraft(documentPosition);
163
+ } else {
164
+ setDraftDocumentPosition(documentPosition);
165
+ applyAnnotationDraftAt && applyAnnotationDraftAt(documentPosition);
166
+ }
142
167
  if (createAnalyticsEvent) {
143
168
  var uniqueAnnotationsInRange = range ? actions.getAnnotationsByPosition(range) : [];
144
169
  createAnalyticsEvent({
@@ -162,7 +187,7 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
162
187
  }
163
188
  }
164
189
  });
165
- var positionToAnnotate = draftDocumentPosition || documentPosition;
190
+ var positionToAnnotate = (0, _platformFeatureFlags.fg)('platform_renderer_annotation_draft_position_fix') ? selectionDraftDocumentPosition || documentPosition : draftDocumentPosition || documentPosition;
166
191
  if (!positionToAnnotate || !applyAnnotation || !options.annotationId) {
167
192
  return false;
168
193
  }
@@ -171,15 +196,19 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
171
196
  annotationType: _adfSchema.AnnotationTypes.INLINE_COMMENT
172
197
  };
173
198
  return applyAnnotation(positionToAnnotate, annotation);
174
- }, [documentPosition, isAnnotationAllowed, applyAnnotationDraftAt, createAnalyticsEvent, applyAnnotation, draftDocumentPosition, actions, range, inlineNodeTypes]);
199
+ }, [documentPosition, isAnnotationAllowed, applyAnnotationDraftAt, createAnalyticsEvent, applyAnnotation, draftDocumentPosition, actions, range, inlineNodeTypes, promoteSelectionToDraft, selectionDraftDocumentPosition]);
175
200
  var removeDraftModeCallback = (0, _react.useCallback)(function () {
176
- clearAnnotationDraft();
177
- setDraftDocumentPosition(null);
201
+ if ((0, _platformFeatureFlags.fg)('platform_renderer_annotation_draft_position_fix')) {
202
+ clearSelectionDraft();
203
+ } else {
204
+ clearAnnotationDraft && clearAnnotationDraft();
205
+ setDraftDocumentPosition(null);
206
+ }
178
207
  var sel = window.getSelection();
179
208
  if (sel) {
180
209
  sel.removeAllRanges();
181
210
  }
182
- }, [clearAnnotationDraft]);
211
+ }, [clearAnnotationDraft, clearSelectionDraft]);
183
212
  var onCloseCallback = (0, _react.useCallback)(function () {
184
213
  if (createAnalyticsEvent) {
185
214
  createAnalyticsEvent({
@@ -23,11 +23,13 @@ var SelectionRangeValidator = exports.SelectionRangeValidator = function Selecti
23
23
  var _useUserSelectionRang = (0, _userSelection.useUserSelectionRange)({
24
24
  rendererRef: rendererRef
25
25
  }),
26
- _useUserSelectionRang2 = (0, _slicedToArray2.default)(_useUserSelectionRang, 3),
27
- range = _useUserSelectionRang2[0],
28
- draftRange = _useUserSelectionRang2[1],
29
- clearRange = _useUserSelectionRang2[2];
30
- if (!range && !draftRange) {
26
+ _useUserSelectionRang2 = (0, _slicedToArray2.default)(_useUserSelectionRang, 4),
27
+ type = _useUserSelectionRang2[0],
28
+ range = _useUserSelectionRang2[1],
29
+ draftRange = _useUserSelectionRang2[2],
30
+ clearRange = _useUserSelectionRang2[3];
31
+ var selectionRange = type === 'selection' ? range : null;
32
+ if (!selectionRange && !draftRange) {
31
33
  return null;
32
34
  }
33
35
  var documentPosition = actions.getPositionFromRange(range);
@@ -40,7 +42,7 @@ var SelectionRangeValidator = exports.SelectionRangeValidator = function Selecti
40
42
  isAnnotationAllowedOnRange = false;
41
43
  }
42
44
  return /*#__PURE__*/_react.default.createElement(_mounter.SelectionInlineCommentMounter, {
43
- range: range,
45
+ range: selectionRange,
44
46
  draftRange: draftRange,
45
47
  wrapperDOM: rendererRef,
46
48
  component: selectionComponent,
@@ -53,4 +55,5 @@ var SelectionRangeValidator = exports.SelectionRangeValidator = function Selecti
53
55
  clearAnnotationDraft: clearAnnotationDraft,
54
56
  createAnalyticsEvent: createAnalyticsEvent
55
57
  });
56
- };
58
+ };
59
+ SelectionRangeValidator.displayName = 'SelectionRangeValidator';
@@ -4,15 +4,16 @@ var _typeof = require("@babel/runtime/helpers/typeof");
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.AnnotationsContextWrapper = void 0;
7
+ exports.AnnotationsContextWrapperOld = exports.AnnotationsContextWrapperNew = exports.AnnotationsContextWrapper = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var _context = require("./context");
10
10
  var _rangeValidator = require("./hover/range-validator");
11
11
  var _rangeValidator2 = require("./selection/range-validator");
12
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
13
  var _AnnotationRangeContext = require("./contexts/AnnotationRangeContext");
13
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); }
14
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 && {}.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; }
15
- var AnnotationsContextWrapper = exports.AnnotationsContextWrapper = function AnnotationsContextWrapper(props) {
16
+ var AnnotationsContextWrapperOld = exports.AnnotationsContextWrapperOld = function AnnotationsContextWrapperOld(props) {
16
17
  var providers = (0, _react.useContext)(_context.ProvidersContext);
17
18
  var _useAnnotationRangeSt = (0, _AnnotationRangeContext.useAnnotationRangeState)(),
18
19
  range = _useAnnotationRangeSt.range,
@@ -66,4 +67,49 @@ var AnnotationsContextWrapper = exports.AnnotationsContextWrapper = function Ann
66
67
  clearDraftRange: clearRangeForDraft,
67
68
  isNestedRender: isNestedRender
68
69
  }, render);
70
+ };
71
+ var AnnotationsContextWrapperNew = exports.AnnotationsContextWrapperNew = function AnnotationsContextWrapperNew(props) {
72
+ var providers = (0, _react.useContext)(_context.ProvidersContext);
73
+ var rendererRef = props.rendererRef,
74
+ createAnalyticsEvent = props.createAnalyticsEvent,
75
+ children = props.children;
76
+ var inlineCommentProvider = providers && providers.inlineComment;
77
+ var selectionComponent = inlineCommentProvider && inlineCommentProvider.selectionComponent;
78
+ var hoverComponent = inlineCommentProvider && inlineCommentProvider.hoverComponent;
79
+ if (!selectionComponent && !hoverComponent) {
80
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
81
+ }
82
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children, !!hoverComponent && /*#__PURE__*/_react.default.createElement(_rangeValidator.RangeValidator, {
83
+ createAnalyticsEvent: createAnalyticsEvent,
84
+ rendererRef: rendererRef
85
+ // Ignored via go/ees005
86
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
87
+ ,
88
+ component: hoverComponent
89
+ }), !!selectionComponent && /*#__PURE__*/_react.default.createElement(_rangeValidator2.SelectionRangeValidator, {
90
+ createAnalyticsEvent: createAnalyticsEvent,
91
+ rendererRef: rendererRef
92
+ // Ignored via go/ees005
93
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
94
+ ,
95
+ selectionComponent: selectionComponent
96
+ }));
97
+ };
98
+ var AnnotationsContextWrapper = exports.AnnotationsContextWrapper = function AnnotationsContextWrapper(props) {
99
+ if ((0, _platformFeatureFlags.fg)('platform_renderer_annotation_draft_position_fix')) {
100
+ // IMPORTANT: Please make sure the AnnotationsDraftContextWrapper is not used anc cleaned up correctly.
101
+ // This code path completely removes all reliance on that wrapper. Also the applyAnnotationDraftAt & clearAnnotationDraft
102
+ // properties have been made optional and not used. This means when we cleanup we can also remove those properties.
103
+ return /*#__PURE__*/_react.default.createElement(AnnotationsContextWrapperNew, {
104
+ rendererRef: props.rendererRef,
105
+ createAnalyticsEvent: props.createAnalyticsEvent,
106
+ isNestedRender: props.isNestedRender
107
+ }, props.children);
108
+ } else {
109
+ return /*#__PURE__*/_react.default.createElement(AnnotationsContextWrapperOld, {
110
+ rendererRef: props.rendererRef,
111
+ createAnalyticsEvent: props.createAnalyticsEvent,
112
+ isNestedRender: props.isNestedRender
113
+ }, props.children);
114
+ }
69
115
  };
@@ -10,15 +10,12 @@ import { createAnnotationStep, getPosFromRange } from '../steps';
10
10
  import { getRendererRangeInlineNodeNames } from './get-renderer-range-inline-node-names';
11
11
  import { getIndexMatch } from './matches-utils';
12
12
  export default class RendererActions {
13
- // Any kind of refence is allowed
14
- // Ignored via go/ees005
15
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
-
17
13
  constructor(initFromContext = false) {
18
14
  // This is our psuedo feature flag for now
19
15
  // This module can only be used when wrapped with
20
16
  // the <RendererContext> component for now.
21
17
  _defineProperty(this, "initFromContext", false);
18
+ _defineProperty(this, "debugAnalyticLoggingEnabled", false);
22
19
  // TODO: EDITOR-595 - This method is temporary and should be removed once the following issue
23
20
  // has been identified and fixed: https://atlassian.slack.com/archives/C08JK0WSCH5/p1745902609966999
24
21
  // This is a copy of the original canApplyAnnotationOnRange. If that returns false this is run to figure out exactly why
@@ -97,7 +94,7 @@ export default class RendererActions {
97
94
  */
98
95
  _privateValidatePositionsForAnnotation(from, to) {
99
96
  if (!this.doc || !this.schema) {
100
- if (this.onAnalyticsEvent && fg('platform_renderer_annotations_create_debug_logging')) {
97
+ if (this.debugAnalyticLoggingEnabled && this.onAnalyticsEvent && fg('platform_renderer_annotations_create_debug_logging')) {
101
98
  this.onAnalyticsEvent({
102
99
  // @ts-ignore
103
100
  action: 'failed',
@@ -119,7 +116,7 @@ export default class RendererActions {
119
116
  }
120
117
  const currentSelection = TextSelection.create(this.doc, from, to);
121
118
  if (isEmptyTextSelection(currentSelection, this.schema)) {
122
- if (this.onAnalyticsEvent && fg('platform_renderer_annotations_create_debug_logging')) {
119
+ if (this.debugAnalyticLoggingEnabled && this.onAnalyticsEvent && fg('platform_renderer_annotations_create_debug_logging')) {
123
120
  this.onAnalyticsEvent({
124
121
  // @ts-ignore
125
122
  action: 'failed',
@@ -143,7 +140,7 @@ export default class RendererActions {
143
140
  from,
144
141
  to
145
142
  }, this.doc, this.schema);
146
- if (!result && this.onAnalyticsEvent && fg('platform_renderer_annotations_create_debug_logging')) {
143
+ if (this.debugAnalyticLoggingEnabled && !result && this.onAnalyticsEvent && fg('platform_renderer_annotations_create_debug_logging')) {
147
144
  this.onAnalyticsEvent({
148
145
  // @ts-ignore
149
146
  action: 'failed',
@@ -317,7 +314,7 @@ export default class RendererActions {
317
314
  }
318
315
  isValidAnnotationPosition(pos) {
319
316
  if (!pos || !this.doc) {
320
- if (this.onAnalyticsEvent && fg('platform_renderer_annotations_create_debug_logging')) {
317
+ if (this.debugAnalyticLoggingEnabled && this.onAnalyticsEvent && fg('platform_renderer_annotations_create_debug_logging')) {
321
318
  this.onAnalyticsEvent({
322
319
  // @ts-ignore
323
320
  action: 'failed',
@@ -526,4 +523,11 @@ export default class RendererActions {
526
523
  schema: this.schema
527
524
  }, annotationId);
528
525
  }
526
+
527
+ /**
528
+ * This is a temporary method used for controlling when extra analytics shoulw be logged.
529
+ */
530
+ _setDebugLogging(enabled) {
531
+ this.debugAnalyticLoggingEnabled = enabled;
532
+ }
529
533
  }
@@ -27,6 +27,7 @@ import { injectIntl } from 'react-intl-next';
27
27
  import { useInlineCommentsFilter } from '../../../ui/annotations/hooks/use-inline-comments-filter';
28
28
  import { useInlineCommentSubscriberContext } from '../../../ui/annotations/hooks/use-inline-comment-subscriber';
29
29
  import { AnnotationUpdateEvent } from '@atlaskit/editor-common/types';
30
+ import { useAnnotationRangeState } from '../../../ui/annotations/contexts/AnnotationRangeContext';
30
31
  const linkStyle = css({
31
32
  position: 'absolute',
32
33
  background: 'transparent',
@@ -385,7 +386,11 @@ class Media extends PureComponent {
385
386
  }
386
387
  }
387
388
  const MediaWithDraftAnnotation = props => {
388
- const draftPosition = React.useContext(AnnotationsDraftContext);
389
+ const draftPositionOld = React.useContext(AnnotationsDraftContext);
390
+ const {
391
+ hoverDraftDocumentPosition
392
+ } = useAnnotationRangeState();
393
+ const draftPosition = fg('platform_renderer_annotation_draft_position_fix') ? hoverDraftDocumentPosition : draftPositionOld;
389
394
  const {
390
395
  dataAttributes
391
396
  } = props;
@@ -334,11 +334,17 @@ export class TableContainer extends React.Component {
334
334
  this.updatedLayout = layout;
335
335
  }
336
336
 
337
+ // defined in colgroup.tsx:
338
+ // appearance == comment && allowTableResizing && means it is a comment
339
+ // appearance == comment && !allowTableResizing && means it is a inline comment
340
+ // for inline comments, the table should inherit the width of the parent component rather than maintain its own size
341
+ const isInsideInlineComment = rendererAppearance === 'comment' && !allowTableResizing;
342
+
337
343
  // These styling removes extra padding for `comment` rendererAppearance.
338
344
  // This is especially relevant for Jira which only uses `comment` appearance and does not need padding.
339
345
  const resizerContainerPadding = rendererAppearance === 'comment' ? 0 : gutterPadding;
340
- const resizerItemMaxWidth = rendererAppearance === 'comment' ? `min(100cqw, var(--ak-editor-table-max-width))` : `min(calc(100cqw - var(--ak-editor-table-gutter-padding)), var(--ak-editor-table-max-width))`;
341
- const resizerItemWidth = rendererAppearance === 'comment' ? `min(100cqw, ${tableWidthAttribute})` : `min(calc(100cqw - var(--ak-editor-table-gutter-padding)), ${tableWidthAttribute})`;
346
+ const resizerItemMaxWidth = rendererAppearance === 'comment' ? isInsideInlineComment ? 'inherit' : `min(100cqw, var(--ak-editor-table-max-width))` : `min(calc(100cqw - var(--ak-editor-table-gutter-padding)), var(--ak-editor-table-max-width))`;
347
+ const resizerItemWidth = rendererAppearance === 'comment' ? isInsideInlineComment ? 'inherit' : `min(100cqw, ${tableWidthAttribute})` : `min(calc(100cqw - var(--ak-editor-table-gutter-padding)), ${tableWidthAttribute})`;
342
348
 
343
349
  // full width tables can have either left-aligned or centered layout despite looking centered in the renderer.
344
350
  // in these cases, keep the alignment unset
@@ -360,7 +366,7 @@ export class TableContainer extends React.Component {
360
366
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
361
367
  ,
362
368
  style: {
363
- width: `min(calc(100cqw - ${resizerContainerPadding}px), ${tableWidthAttribute})`
369
+ width: isInsideInlineComment ? '100%' : `min(calc(100cqw - ${resizerContainerPadding}px), ${tableWidthAttribute})`
364
370
  }
365
371
  }, /*#__PURE__*/React.createElement("div", {
366
372
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
@@ -849,6 +849,13 @@ const smartCardStylesAvatarFix = css({
849
849
  /* EDM-11991: Fix list plugin add padding to ADS AvatarGroup end */
850
850
  }
851
851
  });
852
+ const smartCardStylesAvatarMarginFix = css({
853
+ [`.${SmartCardSharedCssClassName.LOADER_WRAPPER}`]: {
854
+ 'ul, ol': {
855
+ marginRight: 'inherit'
856
+ }
857
+ }
858
+ });
852
859
  const baseOtherStyles = css({
853
860
  '& .UnknownBlock': {
854
861
  fontFamily: "var(--ds-font-family-body, ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
@@ -1777,7 +1784,7 @@ export const RendererStyleContainer = props => {
1777
1784
  '--ak-renderer-editor-font-heading-h6': `${editorUGCToken('editor.font.heading.h6')}`,
1778
1785
  '--ak-renderer-editor-font-normal-text': `${editorUGCToken('editor.font.body')}`
1779
1786
  },
1780
- css: [baseStyles, fg('platform_hide_heading_anchor_wrapper_before_hover') && hideHeadingCopyLinkWrapperStyles, appearance === 'full-page' && rendererFullPageStyles, appearance === 'full-width' && rendererFullWidthStyles, appearance === 'full-width' && !isTableResizingEnabled(appearance) && rendererFullWidthStylesForTableResizing, telepointerStyles, whitespaceSharedStyles, blockquoteSharedStyles, fg('platform_editor_typography_ugc') ? headingsSharedStylesWithEditorUGC : headingsSharedStyles, headingWithAlignmentStyles, ruleSharedStyles, fg('platform_editor_typography_ugc') ? paragraphSharedStylesWithEditorUGC : paragraphSharedStyles, listsSharedStyles, browser.gecko && listsSharedStylesForGekko, indentationSharedStyles, blockMarksSharedStyles, codeMarkSharedStyles, shadowSharedStyle, dateSharedStyle, textColorStyles, backgroundColorStyles, tasksAndDecisionsStyles, smartCardStyles, fg('platform-linking-visual-refresh-v1') && smartCardStylesAvatarFix,
1787
+ css: [baseStyles, fg('platform_hide_heading_anchor_wrapper_before_hover') && hideHeadingCopyLinkWrapperStyles, appearance === 'full-page' && rendererFullPageStyles, appearance === 'full-width' && rendererFullWidthStyles, appearance === 'full-width' && !isTableResizingEnabled(appearance) && rendererFullWidthStylesForTableResizing, telepointerStyles, whitespaceSharedStyles, blockquoteSharedStyles, fg('platform_editor_typography_ugc') ? headingsSharedStylesWithEditorUGC : headingsSharedStyles, headingWithAlignmentStyles, ruleSharedStyles, fg('platform_editor_typography_ugc') ? paragraphSharedStylesWithEditorUGC : paragraphSharedStyles, listsSharedStyles, browser.gecko && listsSharedStylesForGekko, indentationSharedStyles, blockMarksSharedStyles, codeMarkSharedStyles, shadowSharedStyle, dateSharedStyle, textColorStyles, backgroundColorStyles, tasksAndDecisionsStyles, smartCardStyles, fg('platform-linking-visual-refresh-v1') && smartCardStylesAvatarFix, fg('smartcard_avatar_margin_fix') && smartCardStylesAvatarMarginFix,
1781
1788
  // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
1782
1789
  fg('editor_inline_comments_on_inline_nodes') && rendererAnnotationStyles,
1783
1790
  // eslint-disable-next-line @atlaskit/platform/no-preconditioning, @atlaskit/platform/ensure-feature-flag-prefix
@@ -47,11 +47,10 @@ import { useMemoFromPropsDerivative } from './useMemoFromPropsDerivative';
47
47
  export const NORMAL_SEVERITY_THRESHOLD = 2000;
48
48
  export const DEGRADED_SEVERITY_THRESHOLD = 3000;
49
49
  const packageName = "@atlaskit/renderer";
50
- const packageVersion = "115.0.4";
50
+ const packageVersion = "115.0.6";
51
51
  const setAsQueryContainerStyles = css({
52
52
  containerName: 'ak-renderer-wrapper',
53
- containerType: 'inline-size',
54
- contain: 'layout style inline-size'
53
+ containerType: 'inline-size'
55
54
  });
56
55
  const handleMouseTripleClickInTables = event => {
57
56
  var _parentElement, _parentElement2;
@@ -588,10 +587,10 @@ const RendererWrapper = /*#__PURE__*/React.memo(props => {
588
587
  // Only apply container-type = inline-size when having a known width in full-page/full-width/comment mode.
589
588
  // Otherwise when appearance is unspecified the renderer size is decided by the content.
590
589
  // In this case we can't set the container-type = inline-size as it will collapse width to 0.
591
- return (appearance === 'full-page' || appearance === 'full-width' || appearance === 'comment') &&
590
+ return appearance === 'comment' &&
592
591
  // In case of having excerpt-include on page there are multiple renderers nested.
593
592
  // Make sure only the root renderer is set to be query container.
594
- isTopLevelRenderer && fg('platform-fix-table-ssr-resizing') ? jsx("div", {
593
+ isTopLevelRenderer && fg('platform-ssr-table-resize') ? jsx("div", {
595
594
  css: setAsQueryContainerStyles
596
595
  }, renderer) : renderer;
597
596
  });
@@ -1,10 +1,23 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React, { createContext } from 'react';
3
3
  import { fg } from '@atlaskit/platform-feature-flags';
4
- export const AnnotationsDraftContext = /*#__PURE__*/createContext(null);
5
4
  export const ProvidersContext = /*#__PURE__*/createContext(null);
6
5
  export const InlineCommentsStateContext = /*#__PURE__*/createContext({});
7
6
 
7
+ /**
8
+ * @private
9
+ * @deprecated The FG platform_renderer_annotation_draft_position_fix will make this context redundant as the draft position
10
+ * has been moved to the AnnotationRangeProvider in order to be more consistent with the hover and selection ranges.
11
+ * Once the FG is rolled out this context will be removed. Please ensure any changes are duplicated to the AnnotationRangeProvider.
12
+ */
13
+ export const AnnotationsDraftContext = /*#__PURE__*/createContext(null);
14
+
15
+ /**
16
+ * @private
17
+ * @deprecated The FG platform_renderer_annotation_draft_position_fix will make this context redundant as the draft position
18
+ * has been moved to the AnnotationRangeProvider in order to be more consistent with the hover and selection ranges.
19
+ * Once the FG is rolled out this context will be removed. Please ensure any changes are duplicated to the AnnotationRangeProvider.
20
+ */
8
21
  // Ignored via go/ees005
9
22
  // eslint-disable-next-line @repo/internal/react/no-class-components
10
23
  export class AnnotationsDraftContextWrapper extends React.Component {