@atlaskit/renderer 118.2.1 → 118.2.2

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,14 @@
1
1
  # @atlaskit/renderer
2
2
 
3
+ ## 118.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#160385](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/160385)
8
+ [`48d95956a007a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/48d95956a007a) -
9
+ EDITOR-788 - Renderer comment creation process is broken
10
+ - Updated dependencies
11
+
3
12
  ## 118.2.1
4
13
 
5
14
  ### Patch Changes
@@ -59,6 +59,9 @@
59
59
  {
60
60
  "path": "../../../design-system/icon/afm-jira/tsconfig.json"
61
61
  },
62
+ {
63
+ "path": "../../../design-system/link/afm-jira/tsconfig.json"
64
+ },
62
65
  {
63
66
  "path": "../../../linking-platform/link-datasource/afm-jira/tsconfig.json"
64
67
  },
@@ -63,7 +63,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
63
63
  var NORMAL_SEVERITY_THRESHOLD = exports.NORMAL_SEVERITY_THRESHOLD = 2000;
64
64
  var DEGRADED_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = 3000;
65
65
  var packageName = "@atlaskit/renderer";
66
- var packageVersion = "118.2.1";
66
+ var packageVersion = "118.2.2";
67
67
  var setAsQueryContainerStyles = (0, _react2.css)({
68
68
  containerName: 'ak-renderer-wrapper',
69
69
  containerType: 'inline-size'
@@ -13,6 +13,7 @@ var _adfSchema = require("@atlaskit/adf-schema");
13
13
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
14
14
  var _reactIntlNext = require("react-intl-next");
15
15
  var _messages = require("../../../messages");
16
+ var _AnnotationManagerContext = require("../contexts/AnnotationManagerContext");
16
17
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
18
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /**
18
19
  * @jsxRuntime classic
@@ -126,6 +127,22 @@ var MarkComponent = exports.MarkComponent = function MarkComponent(_ref) {
126
127
  var annotationIds = (0, _react.useMemo)(function () {
127
128
  return (0, _toConsumableArray2.default)(new Set([].concat((0, _toConsumableArray2.default)(annotationParentIds), [id])));
128
129
  }, [id, annotationParentIds]);
130
+ var _useAnnotationManager = (0, _AnnotationManagerContext.useAnnotationManagerDispatch)(),
131
+ dispatch = _useAnnotationManager.dispatch;
132
+ var _useAnnotationManager2 = (0, _AnnotationManagerContext.useAnnotationManagerState)(),
133
+ currentSelectedAnnotationId = _useAnnotationManager2.currentSelectedAnnotationId;
134
+
135
+ // after creating a new annotation, we need to set the markRef to the new mark
136
+ var markRef = (0, _react.useCallback)(function (node) {
137
+ if (id === currentSelectedAnnotationId && node) {
138
+ dispatch({
139
+ type: 'setSelectedMarkRef',
140
+ data: {
141
+ markRef: node
142
+ }
143
+ });
144
+ }
145
+ }, [dispatch, id, currentSelectedAnnotationId]);
129
146
  var onMarkClick = (0, _react.useCallback)(function (event) {
130
147
  // prevent inline mark logic for media block marks
131
148
  if (event.currentTarget instanceof HTMLElement && event.currentTarget.getAttribute('data-block-mark')) {
@@ -193,6 +210,7 @@ var MarkComponent = exports.MarkComponent = function MarkComponent(_ref) {
193
210
  'aria-details': annotationIds.join(', ')
194
211
  }, desktopAccessibilityAttributes);
195
212
  return (0, _react2.jsx)(useBlockLevel ? 'div' : 'mark', _objectSpread(_objectSpread(_objectSpread((0, _defineProperty2.default)({
213
+ ref: id === currentSelectedAnnotationId ? markRef : undefined,
196
214
  id: id
197
215
  }, (0, _platformFeatureFlags.fg)('editor_inline_comments_on_inline_nodes') ? 'onClickCapture' : 'onClick', onMarkClick), accessibility), overriddenData), !useBlockLevel && {
198
216
  css: [markStyles, (0, _platformFeatureFlags.fg)('platform_renderer_nested_annotation_styling') && markStylesLayeringFix, (0, _platformFeatureFlags.fg)('editor_inline_comments_on_inline_nodes') && markStylesWithInlineComments, (0, _platformFeatureFlags.fg)('confluence-frontend-comments-panel') && markStylesWithCommentsPanel, !isMobile() && accessibilityStyles, markStylesWithUpdatedShadow],
@@ -124,6 +124,10 @@ var useHasFocusEvent = exports.useHasFocusEvent = function useHasFocusEvent(_ref
124
124
  };
125
125
  }
126
126
  };
127
+ var NO_ANNOTATION_SELECTED = {
128
+ annotations: [],
129
+ clickElementTarget: undefined
130
+ };
127
131
  var useAnnotationClickEvent = exports.useAnnotationClickEvent = function useAnnotationClickEvent(props) {
128
132
  var _useState7 = (0, _react.useState)(null),
129
133
  _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
@@ -142,10 +146,11 @@ var useAnnotationClickEvent = exports.useAnnotationClickEvent = function useAnno
142
146
  type: _adfSchema.AnnotationTypes.INLINE_COMMENT
143
147
  }],
144
148
  clickElementTarget: currentSelectedMarkRef
145
- } : {
146
- annotations: [],
147
- clickElementTarget: undefined
148
- };
149
+ } :
150
+ // This is a constant to represent the case when no annotation is selected.
151
+ // When creating a new annotation, currentSelectedAnnotationId and currentSelectedMarkRef will be set one after another,
152
+ // if this isn't a const, it will cause useMemo to return two different "empty" objects and causes infinite re-renders.
153
+ NO_ANNOTATION_SELECTED;
149
154
  }, [currentSelectedAnnotationId, currentSelectedMarkRef]);
150
155
  (0, _react.useLayoutEffect)(function () {
151
156
  if (!updateSubscriber || isNestedRender) {
@@ -48,7 +48,7 @@ import { PortalContext } from './PortalContext';
48
48
  export const NORMAL_SEVERITY_THRESHOLD = 2000;
49
49
  export const DEGRADED_SEVERITY_THRESHOLD = 3000;
50
50
  const packageName = "@atlaskit/renderer";
51
- const packageVersion = "118.2.1";
51
+ const packageVersion = "118.2.2";
52
52
  const setAsQueryContainerStyles = css({
53
53
  containerName: 'ak-renderer-wrapper',
54
54
  containerType: 'inline-size'
@@ -10,6 +10,7 @@ import { AnnotationMarkStates } from '@atlaskit/adf-schema';
10
10
  import { fg } from '@atlaskit/platform-feature-flags';
11
11
  import { useIntl } from 'react-intl-next';
12
12
  import { inlineCommentMessages } from '../../../messages';
13
+ import { useAnnotationManagerDispatch, useAnnotationManagerState } from '../contexts/AnnotationManagerContext';
13
14
  const markStyles = css({
14
15
  color: 'inherit',
15
16
  backgroundColor: 'unset',
@@ -131,6 +132,24 @@ export const MarkComponent = ({
131
132
  }) => {
132
133
  const intl = useIntl();
133
134
  const annotationIds = useMemo(() => [...new Set([...annotationParentIds, id])], [id, annotationParentIds]);
135
+ const {
136
+ dispatch
137
+ } = useAnnotationManagerDispatch();
138
+ const {
139
+ currentSelectedAnnotationId
140
+ } = useAnnotationManagerState();
141
+
142
+ // after creating a new annotation, we need to set the markRef to the new mark
143
+ const markRef = useCallback(node => {
144
+ if (id === currentSelectedAnnotationId && node) {
145
+ dispatch({
146
+ type: 'setSelectedMarkRef',
147
+ data: {
148
+ markRef: node
149
+ }
150
+ });
151
+ }
152
+ }, [dispatch, id, currentSelectedAnnotationId]);
134
153
  const onMarkClick = useCallback(event => {
135
154
  // prevent inline mark logic for media block marks
136
155
  if (event.currentTarget instanceof HTMLElement && event.currentTarget.getAttribute('data-block-mark')) {
@@ -200,6 +219,7 @@ export const MarkComponent = ({
200
219
  ...desktopAccessibilityAttributes
201
220
  };
202
221
  return jsx(useBlockLevel ? 'div' : 'mark', {
222
+ ref: id === currentSelectedAnnotationId ? markRef : undefined,
203
223
  id,
204
224
  [fg('editor_inline_comments_on_inline_nodes') ? 'onClickCapture' : 'onClick']: onMarkClick,
205
225
  ...accessibility,
@@ -118,6 +118,10 @@ export const useHasFocusEvent = ({
118
118
  };
119
119
  }
120
120
  };
121
+ const NO_ANNOTATION_SELECTED = {
122
+ annotations: [],
123
+ clickElementTarget: undefined
124
+ };
121
125
  export const useAnnotationClickEvent = props => {
122
126
  const [annotationClickEvent, setAnnotationClickEvent] = useState(null);
123
127
  const {
@@ -136,10 +140,11 @@ export const useAnnotationClickEvent = props => {
136
140
  type: AnnotationTypes.INLINE_COMMENT
137
141
  }],
138
142
  clickElementTarget: currentSelectedMarkRef
139
- } : {
140
- annotations: [],
141
- clickElementTarget: undefined
142
- };
143
+ } :
144
+ // This is a constant to represent the case when no annotation is selected.
145
+ // When creating a new annotation, currentSelectedAnnotationId and currentSelectedMarkRef will be set one after another,
146
+ // if this isn't a const, it will cause useMemo to return two different "empty" objects and causes infinite re-renders.
147
+ NO_ANNOTATION_SELECTED;
143
148
  }, [currentSelectedAnnotationId, currentSelectedMarkRef]);
144
149
  useLayoutEffect(() => {
145
150
  if (!updateSubscriber || isNestedRender) {
@@ -53,7 +53,7 @@ import { PortalContext } from './PortalContext';
53
53
  export var NORMAL_SEVERITY_THRESHOLD = 2000;
54
54
  export var DEGRADED_SEVERITY_THRESHOLD = 3000;
55
55
  var packageName = "@atlaskit/renderer";
56
- var packageVersion = "118.2.1";
56
+ var packageVersion = "118.2.2";
57
57
  var setAsQueryContainerStyles = css({
58
58
  containerName: 'ak-renderer-wrapper',
59
59
  containerType: 'inline-size'
@@ -14,6 +14,7 @@ import { AnnotationMarkStates } from '@atlaskit/adf-schema';
14
14
  import { fg } from '@atlaskit/platform-feature-flags';
15
15
  import { useIntl } from 'react-intl-next';
16
16
  import { inlineCommentMessages } from '../../../messages';
17
+ import { useAnnotationManagerDispatch, useAnnotationManagerState } from '../contexts/AnnotationManagerContext';
17
18
  var markStyles = css(_defineProperty({
18
19
  color: 'inherit',
19
20
  backgroundColor: 'unset',
@@ -122,6 +123,22 @@ export var MarkComponent = function MarkComponent(_ref) {
122
123
  var annotationIds = useMemo(function () {
123
124
  return _toConsumableArray(new Set([].concat(_toConsumableArray(annotationParentIds), [id])));
124
125
  }, [id, annotationParentIds]);
126
+ var _useAnnotationManager = useAnnotationManagerDispatch(),
127
+ dispatch = _useAnnotationManager.dispatch;
128
+ var _useAnnotationManager2 = useAnnotationManagerState(),
129
+ currentSelectedAnnotationId = _useAnnotationManager2.currentSelectedAnnotationId;
130
+
131
+ // after creating a new annotation, we need to set the markRef to the new mark
132
+ var markRef = useCallback(function (node) {
133
+ if (id === currentSelectedAnnotationId && node) {
134
+ dispatch({
135
+ type: 'setSelectedMarkRef',
136
+ data: {
137
+ markRef: node
138
+ }
139
+ });
140
+ }
141
+ }, [dispatch, id, currentSelectedAnnotationId]);
125
142
  var onMarkClick = useCallback(function (event) {
126
143
  // prevent inline mark logic for media block marks
127
144
  if (event.currentTarget instanceof HTMLElement && event.currentTarget.getAttribute('data-block-mark')) {
@@ -189,6 +206,7 @@ export var MarkComponent = function MarkComponent(_ref) {
189
206
  'aria-details': annotationIds.join(', ')
190
207
  }, desktopAccessibilityAttributes);
191
208
  return jsx(useBlockLevel ? 'div' : 'mark', _objectSpread(_objectSpread(_objectSpread(_defineProperty({
209
+ ref: id === currentSelectedAnnotationId ? markRef : undefined,
192
210
  id: id
193
211
  }, fg('editor_inline_comments_on_inline_nodes') ? 'onClickCapture' : 'onClick', onMarkClick), accessibility), overriddenData), !useBlockLevel && {
194
212
  css: [markStyles, fg('platform_renderer_nested_annotation_styling') && markStylesLayeringFix, fg('editor_inline_comments_on_inline_nodes') && markStylesWithInlineComments, fg('confluence-frontend-comments-panel') && markStylesWithCommentsPanel, !isMobile() && accessibilityStyles, markStylesWithUpdatedShadow],
@@ -117,6 +117,10 @@ export var useHasFocusEvent = function useHasFocusEvent(_ref2) {
117
117
  };
118
118
  }
119
119
  };
120
+ var NO_ANNOTATION_SELECTED = {
121
+ annotations: [],
122
+ clickElementTarget: undefined
123
+ };
120
124
  export var useAnnotationClickEvent = function useAnnotationClickEvent(props) {
121
125
  var _useState7 = useState(null),
122
126
  _useState8 = _slicedToArray(_useState7, 2),
@@ -135,10 +139,11 @@ export var useAnnotationClickEvent = function useAnnotationClickEvent(props) {
135
139
  type: AnnotationTypes.INLINE_COMMENT
136
140
  }],
137
141
  clickElementTarget: currentSelectedMarkRef
138
- } : {
139
- annotations: [],
140
- clickElementTarget: undefined
141
- };
142
+ } :
143
+ // This is a constant to represent the case when no annotation is selected.
144
+ // When creating a new annotation, currentSelectedAnnotationId and currentSelectedMarkRef will be set one after another,
145
+ // if this isn't a const, it will cause useMemo to return two different "empty" objects and causes infinite re-renders.
146
+ NO_ANNOTATION_SELECTED;
142
147
  }, [currentSelectedAnnotationId, currentSelectedMarkRef]);
143
148
  useLayoutEffect(function () {
144
149
  if (!updateSubscriber || isNestedRender) {
@@ -27,6 +27,7 @@ export declare const MarkComponent: ({ annotationParentIds, children, dataAttrib
27
27
  'data-id': string;
28
28
  'data-mark-annotation-state'?: AnnotationMarkStates | undefined;
29
29
  'aria-disabled': boolean;
30
+ ref: ((node: HTMLElement | null) => void) | undefined;
30
31
  id: string;
31
32
  } | {
32
33
  css?: (false | import("@emotion/react").SerializedStyles)[] | undefined;
@@ -41,6 +42,7 @@ export declare const MarkComponent: ({ annotationParentIds, children, dataAttrib
41
42
  'data-mark-annotation-type': import("@atlaskit/adf-schema").AnnotationTypes;
42
43
  'data-id': string;
43
44
  'aria-disabled': boolean;
45
+ ref: ((node: HTMLElement | null) => void) | undefined;
44
46
  id: string;
45
47
  } | {
46
48
  css?: (false | import("@emotion/react").SerializedStyles)[] | undefined;
@@ -58,6 +60,7 @@ export declare const MarkComponent: ({ annotationParentIds, children, dataAttrib
58
60
  'aria-expanded'?: undefined;
59
61
  'aria-details': string;
60
62
  'aria-disabled'?: undefined;
63
+ ref: ((node: HTMLElement | null) => void) | undefined;
61
64
  id: string;
62
65
  } | {
63
66
  css?: (false | import("@emotion/react").SerializedStyles)[] | undefined;
@@ -77,6 +80,7 @@ export declare const MarkComponent: ({ annotationParentIds, children, dataAttrib
77
80
  'aria-expanded'?: undefined;
78
81
  'aria-details': string;
79
82
  'aria-disabled'?: undefined;
83
+ ref: ((node: HTMLElement | null) => void) | undefined;
80
84
  id: string;
81
85
  } | {
82
86
  css?: (false | import("@emotion/react").SerializedStyles)[] | undefined;
@@ -94,6 +98,7 @@ export declare const MarkComponent: ({ annotationParentIds, children, dataAttrib
94
98
  'aria-expanded': boolean;
95
99
  'aria-details': string;
96
100
  'aria-disabled'?: undefined;
101
+ ref: ((node: HTMLElement | null) => void) | undefined;
97
102
  id: string;
98
103
  } | {
99
104
  css?: (false | import("@emotion/react").SerializedStyles)[] | undefined;
@@ -113,6 +118,7 @@ export declare const MarkComponent: ({ annotationParentIds, children, dataAttrib
113
118
  'aria-expanded': boolean;
114
119
  'aria-details': string;
115
120
  'aria-disabled'?: undefined;
121
+ ref: ((node: HTMLElement | null) => void) | undefined;
116
122
  id: string;
117
123
  }, string | React.JSXElementConstructor<any>>;
118
124
  export {};
@@ -27,6 +27,7 @@ export declare const MarkComponent: ({ annotationParentIds, children, dataAttrib
27
27
  'data-id': string;
28
28
  'data-mark-annotation-state'?: AnnotationMarkStates | undefined;
29
29
  'aria-disabled': boolean;
30
+ ref: ((node: HTMLElement | null) => void) | undefined;
30
31
  id: string;
31
32
  } | {
32
33
  css?: (false | import("@emotion/react").SerializedStyles)[] | undefined;
@@ -41,6 +42,7 @@ export declare const MarkComponent: ({ annotationParentIds, children, dataAttrib
41
42
  'data-mark-annotation-type': import("@atlaskit/adf-schema").AnnotationTypes;
42
43
  'data-id': string;
43
44
  'aria-disabled': boolean;
45
+ ref: ((node: HTMLElement | null) => void) | undefined;
44
46
  id: string;
45
47
  } | {
46
48
  css?: (false | import("@emotion/react").SerializedStyles)[] | undefined;
@@ -58,6 +60,7 @@ export declare const MarkComponent: ({ annotationParentIds, children, dataAttrib
58
60
  'aria-expanded'?: undefined;
59
61
  'aria-details': string;
60
62
  'aria-disabled'?: undefined;
63
+ ref: ((node: HTMLElement | null) => void) | undefined;
61
64
  id: string;
62
65
  } | {
63
66
  css?: (false | import("@emotion/react").SerializedStyles)[] | undefined;
@@ -77,6 +80,7 @@ export declare const MarkComponent: ({ annotationParentIds, children, dataAttrib
77
80
  'aria-expanded'?: undefined;
78
81
  'aria-details': string;
79
82
  'aria-disabled'?: undefined;
83
+ ref: ((node: HTMLElement | null) => void) | undefined;
80
84
  id: string;
81
85
  } | {
82
86
  css?: (false | import("@emotion/react").SerializedStyles)[] | undefined;
@@ -94,6 +98,7 @@ export declare const MarkComponent: ({ annotationParentIds, children, dataAttrib
94
98
  'aria-expanded': boolean;
95
99
  'aria-details': string;
96
100
  'aria-disabled'?: undefined;
101
+ ref: ((node: HTMLElement | null) => void) | undefined;
97
102
  id: string;
98
103
  } | {
99
104
  css?: (false | import("@emotion/react").SerializedStyles)[] | undefined;
@@ -113,6 +118,7 @@ export declare const MarkComponent: ({ annotationParentIds, children, dataAttrib
113
118
  'aria-expanded': boolean;
114
119
  'aria-details': string;
115
120
  'aria-disabled'?: undefined;
121
+ ref: ((node: HTMLElement | null) => void) | undefined;
116
122
  id: string;
117
123
  }, string | React.JSXElementConstructor<any>>;
118
124
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/renderer",
3
- "version": "118.2.1",
3
+ "version": "118.2.2",
4
4
  "description": "Renderer component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -48,15 +48,15 @@
48
48
  "@atlaskit/media-common": "^12.1.0",
49
49
  "@atlaskit/media-filmstrip": "^50.1.0",
50
50
  "@atlaskit/media-ui": "^28.2.0",
51
- "@atlaskit/media-viewer": "^52.1.0",
51
+ "@atlaskit/media-viewer": "^52.2.0",
52
52
  "@atlaskit/platform-feature-flags": "^1.1.0",
53
53
  "@atlaskit/platform-feature-flags-react": "^0.2.0",
54
54
  "@atlaskit/react-ufo": "^3.13.0",
55
- "@atlaskit/smart-card": "^38.4.0",
55
+ "@atlaskit/smart-card": "^38.5.0",
56
56
  "@atlaskit/status": "^3.0.0",
57
57
  "@atlaskit/task-decision": "^19.2.0",
58
58
  "@atlaskit/theme": "^18.0.0",
59
- "@atlaskit/tmp-editor-statsig": "^4.23.0",
59
+ "@atlaskit/tmp-editor-statsig": "^4.25.0",
60
60
  "@atlaskit/tokens": "^4.9.0",
61
61
  "@atlaskit/tooltip": "^20.0.0",
62
62
  "@atlaskit/visually-hidden": "^3.0.0",
@@ -70,7 +70,7 @@
70
70
  "uuid": "^3.1.0"
71
71
  },
72
72
  "peerDependencies": {
73
- "@atlaskit/link-provider": "^3.0.0",
73
+ "@atlaskit/link-provider": "^3.1.0",
74
74
  "@atlaskit/media-core": "^36.1.0",
75
75
  "react": "^18.2.0",
76
76
  "react-dom": "^18.2.0"
@@ -81,7 +81,7 @@
81
81
  "@atlaskit/analytics-gas-types": "^5.1.0",
82
82
  "@atlaskit/checkbox": "^17.1.0",
83
83
  "@atlaskit/css-reset": "^7.3.0",
84
- "@atlaskit/link-provider": "^3.0.0",
84
+ "@atlaskit/link-provider": "^3.1.0",
85
85
  "@atlaskit/link-test-helpers": "^8.0.0",
86
86
  "@atlaskit/linking-common": "^9.0.0",
87
87
  "@atlaskit/media-core": "^36.1.0",