@atlaskit/renderer 109.36.0 → 109.37.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.37.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#115232](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/115232)
8
+ [`67c2dc683387a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/67c2dc683387a) -
9
+ [ux] adding keyboard support for inline comments in renderer
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
15
+ ## 109.36.1
16
+
17
+ ### Patch Changes
18
+
19
+ - [#112336](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/112336)
20
+ [`a1733f8d7c4cc`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a1733f8d7c4cc) -
21
+ [ux] ED-23648 tweak editor and renderer inline comment sizing to fit inline nodes
22
+ - Updated dependencies
23
+
3
24
  ## 109.36.0
4
25
 
5
26
  ### Minor Changes
@@ -51,6 +51,9 @@
51
51
  {
52
52
  "path": "../../../elements/emoji/afm-cc/tsconfig.json"
53
53
  },
54
+ {
55
+ "path": "../../../measurement/feature-gate-js-client/afm-cc/tsconfig.json"
56
+ },
54
57
  {
55
58
  "path": "../../../design-system/icon/afm-cc/tsconfig.json"
56
59
  },
@@ -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.36.0";
59
+ var packageVersion = "109.37.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);
@@ -112,6 +112,9 @@ function getAnnotationStyles(_ref6) {
112
112
  if (!(0, _platformFeatureFlags.getBooleanFF)('platform.editor.allow-inline-comments-for-inline-nodes')) {
113
113
  return '';
114
114
  }
115
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
116
+ return '';
117
+ }
115
118
  return (0, _react.css)({
116
119
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
117
120
  "& [data-mark-type='annotation'][data-mark-annotation-state='active'] [data-annotation-mark], & [data-annotation-draft-mark][data-annotation-inline-node]": {
@@ -10,6 +10,7 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
10
10
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
11
11
  var _react = require("react");
12
12
  var _react2 = require("@emotion/react");
13
+ var _featureGateJsClient = _interopRequireDefault(require("@atlaskit/feature-gate-js-client"));
13
14
  var _styles = require("@atlaskit/editor-common/styles");
14
15
  var _adfSchema = require("@atlaskit/adf-schema");
15
16
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
@@ -20,7 +21,10 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
20
21
  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; }
21
22
  // eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- `AnnotationSharedCSSByState` is not object-safe
22
23
  var markStyles = function markStyles() {
23
- return (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n\tcolor: inherit;\n\tbackground-color: unset;\n\t-webkit-tap-highlight-color: transparent;\n\n\t&[data-mark-annotation-state='", "'] {\n\t\t", ";\n\n\t\t&:focus,\n\t\t&[data-has-focus='true'] {\n\t\t\t", ";\n\t\t}\n\t}\n"])), _adfSchema.AnnotationMarkStates.ACTIVE, (0, _styles.AnnotationSharedCSSByState)().blur, (0, _styles.AnnotationSharedCSSByState)().focus);
24
+ return (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n\tcolor: inherit;\n\tbackground-color: unset;\n\t-webkit-tap-highlight-color: transparent;\n\n\t&[data-mark-annotation-state='", "'] {\n\t\t", ";\n\t\t", ";\n\n\t\t&:focus,\n\t\t&[data-has-focus='true'] {\n\t\t\t", ";\n\t\t}\n\t}\n"])), _adfSchema.AnnotationMarkStates.ACTIVE, (0, _styles.AnnotationSharedCSSByState)().common, (0, _styles.AnnotationSharedCSSByState)().blur, (0, _styles.AnnotationSharedCSSByState)().focus);
25
+ };
26
+ var isMobile = function isMobile() {
27
+ return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
24
28
  };
25
29
  var MarkComponent = exports.MarkComponent = function MarkComponent(_ref) {
26
30
  var annotationParentIds = _ref.annotationParentIds,
@@ -31,12 +35,13 @@ var MarkComponent = exports.MarkComponent = function MarkComponent(_ref) {
31
35
  hasFocus = _ref.hasFocus,
32
36
  onClick = _ref.onClick,
33
37
  useBlockLevel = _ref.useBlockLevel;
38
+ var isInlineCommentsKbAccessible = _featureGateJsClient.default.checkGate('inline_comments_keyboard_accessible_renderer');
34
39
  var annotationIds = (0, _react.useMemo)(function () {
35
40
  return (0, _toConsumableArray2.default)(new Set([].concat((0, _toConsumableArray2.default)(annotationParentIds), [id])));
36
41
  }, [id, annotationParentIds]);
37
42
  var onMarkClick = (0, _react.useCallback)(function (event) {
38
43
  // prevent inline mark logic for media block marks
39
- if (event.currentTarget.getAttribute('data-block-mark')) {
44
+ if (event.currentTarget instanceof HTMLElement && event.currentTarget.getAttribute('data-block-mark')) {
40
45
  return;
41
46
  }
42
47
 
@@ -65,15 +70,28 @@ var MarkComponent = exports.MarkComponent = function MarkComponent(_ref) {
65
70
  annotationIds: annotationIds
66
71
  });
67
72
  }, [annotationIds, onClick, state]);
73
+ var onMarkEnter = function onMarkEnter(evt) {
74
+ var _document$activeEleme;
75
+ var focusedElementTag = (_document$activeEleme = document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.tagName;
76
+ if (focusedElementTag === 'MARK' && evt.key === 'Enter') {
77
+ onMarkClick(evt);
78
+ }
79
+ };
68
80
  var overriddenData = !state ? dataAttributes : _objectSpread(_objectSpread({}, dataAttributes), {}, {
69
81
  'data-mark-annotation-state': state,
70
82
  'data-has-focus': hasFocus
71
83
  });
84
+ var desktopAccessibilityAttributes = isInlineCommentsKbAccessible ? isMobile() ? {} : {
85
+ role: 'button',
86
+ tabIndex: 0,
87
+ onKeyDown: onMarkEnter,
88
+ 'aria-expanded': hasFocus
89
+ } : {};
72
90
  var accessibility = state !== _adfSchema.AnnotationMarkStates.ACTIVE ? {
73
91
  'aria-disabled': true
74
- } : {
92
+ } : _objectSpread({
75
93
  'aria-details': annotationIds.join(', ')
76
- };
94
+ }, desktopAccessibilityAttributes);
77
95
  return (0, _react2.jsx)(useBlockLevel ? 'div' : 'mark', _objectSpread(_objectSpread(_objectSpread((0, _defineProperty2.default)({
78
96
  id: id
79
97
  }, (0, _platformFeatureFlags.getBooleanFF)('platform.editor.allow-inline-comments-for-inline-nodes') ? 'onClickCapture' : 'onClick', onMarkClick), accessibility), overriddenData), !useBlockLevel && {
@@ -9,6 +9,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
9
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
10
  var _react = require("react");
11
11
  var _types = require("@atlaskit/editor-common/types");
12
+ var _featureGateJsClient = _interopRequireDefault(require("@atlaskit/feature-gate-js-client"));
12
13
  var _adfSchema = require("@atlaskit/adf-schema");
13
14
  var _analytics = require("@atlaskit/editor-common/analytics");
14
15
  var _analyticsListeners = require("@atlaskit/analytics-listeners");
@@ -53,6 +54,7 @@ var useHasFocusEvent = exports.useHasFocusEvent = function useHasFocusEvent(_ref
53
54
  _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
54
55
  hasFocus = _useState4[0],
55
56
  setHasFocus = _useState4[1];
57
+ var isInlineCommentsKbAccessible = _featureGateJsClient.default.checkGate('inline_comments_keyboard_accessible_renderer');
56
58
  (0, _react.useLayoutEffect)(function () {
57
59
  if (!updateSubscriber) {
58
60
  return;
@@ -62,6 +64,9 @@ var useHasFocusEvent = exports.useHasFocusEvent = function useHasFocusEvent(_ref
62
64
  };
63
65
  var removeFocus = function removeFocus() {
64
66
  setHasFocus(false);
67
+ if (isInlineCommentsKbAccessible && document.activeElement instanceof HTMLElement) {
68
+ document.activeElement.blur();
69
+ }
65
70
  };
66
71
  updateSubscriber.on(_types.AnnotationUpdateEvent.SET_ANNOTATION_FOCUS, cb);
67
72
  updateSubscriber.on(_types.AnnotationUpdateEvent.REMOVE_ANNOTATION_FOCUS, removeFocus);
@@ -69,7 +74,7 @@ var useHasFocusEvent = exports.useHasFocusEvent = function useHasFocusEvent(_ref
69
74
  updateSubscriber.off(_types.AnnotationUpdateEvent.SET_ANNOTATION_FOCUS, cb);
70
75
  updateSubscriber.off(_types.AnnotationUpdateEvent.REMOVE_ANNOTATION_FOCUS, removeFocus);
71
76
  };
72
- }, [id, updateSubscriber]);
77
+ }, [id, updateSubscriber, isInlineCommentsKbAccessible]);
73
78
  return hasFocus;
74
79
  };
75
80
  var useAnnotationClickEvent = exports.useAnnotationClickEvent = function useAnnotationClickEvent(props) {
@@ -80,6 +85,7 @@ var useAnnotationClickEvent = exports.useAnnotationClickEvent = function useAnno
80
85
  var updateSubscriber = props.updateSubscriber,
81
86
  createAnalyticsEvent = props.createAnalyticsEvent,
82
87
  isCommentsOnMediaAnalyticsEnabled = props.isCommentsOnMediaAnalyticsEnabled;
88
+ var isInlineCommentsKbAccessible = _featureGateJsClient.default.checkGate('inline_comments_keyboard_accessible_renderer');
83
89
  (0, _react.useLayoutEffect)(function () {
84
90
  if (!updateSubscriber) {
85
91
  return;
@@ -121,6 +127,9 @@ var useAnnotationClickEvent = exports.useAnnotationClickEvent = function useAnno
121
127
  annotations: [],
122
128
  clickElementTarget: undefined
123
129
  });
130
+ if (isInlineCommentsKbAccessible && document.activeElement instanceof HTMLElement) {
131
+ document.activeElement.blur();
132
+ }
124
133
  };
125
134
  updateSubscriber.on(_types.AnnotationUpdateEvent.ON_ANNOTATION_CLICK, clickCb);
126
135
  updateSubscriber.on(_types.AnnotationUpdateEvent.DESELECT_ANNOTATIONS, deselectCb);
@@ -128,6 +137,6 @@ var useAnnotationClickEvent = exports.useAnnotationClickEvent = function useAnno
128
137
  updateSubscriber.off(_types.AnnotationUpdateEvent.ON_ANNOTATION_CLICK, clickCb);
129
138
  updateSubscriber.off(_types.AnnotationUpdateEvent.DESELECT_ANNOTATIONS, deselectCb);
130
139
  };
131
- }, [updateSubscriber, createAnalyticsEvent, isCommentsOnMediaAnalyticsEnabled]);
140
+ }, [updateSubscriber, createAnalyticsEvent, isCommentsOnMediaAnalyticsEnabled, isInlineCommentsKbAccessible]);
132
141
  return annotationClickEvent;
133
142
  };
@@ -38,7 +38,7 @@ import { nodeToReact } from '../../react/nodes';
38
38
  export const NORMAL_SEVERITY_THRESHOLD = 2000;
39
39
  export const DEGRADED_SEVERITY_THRESHOLD = 3000;
40
40
  const packageName = "@atlaskit/renderer";
41
- const packageVersion = "109.36.0";
41
+ const packageVersion = "109.37.0";
42
42
  export const defaultNodeComponents = nodeToReact;
43
43
  export class Renderer extends PureComponent {
44
44
  constructor(props) {
@@ -371,6 +371,9 @@ function getAnnotationStyles({
371
371
  if (!getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes')) {
372
372
  return '';
373
373
  }
374
+ if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
375
+ return '';
376
+ }
374
377
  return css({
375
378
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
376
379
  "& [data-mark-type='annotation'][data-mark-annotation-state='active'] [data-annotation-mark], & [data-annotation-draft-mark][data-annotation-inline-node]": {
@@ -3,6 +3,7 @@
3
3
  import { useMemo, useCallback } from 'react';
4
4
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
5
5
  import { css, jsx } from '@emotion/react';
6
+ import FeatureGates from '@atlaskit/feature-gate-js-client';
6
7
  import { AnnotationSharedCSSByState } from '@atlaskit/editor-common/styles';
7
8
  import { AnnotationMarkStates } from '@atlaskit/adf-schema';
8
9
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
@@ -14,6 +15,7 @@ const markStyles = () => css`
14
15
  -webkit-tap-highlight-color: transparent;
15
16
 
16
17
  &[data-mark-annotation-state='${AnnotationMarkStates.ACTIVE}'] {
18
+ ${AnnotationSharedCSSByState().common};
17
19
  ${AnnotationSharedCSSByState().blur};
18
20
 
19
21
  &:focus,
@@ -22,6 +24,9 @@ const markStyles = () => css`
22
24
  }
23
25
  }
24
26
  `;
27
+ const isMobile = () => {
28
+ return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
29
+ };
25
30
  export const MarkComponent = ({
26
31
  annotationParentIds,
27
32
  children,
@@ -32,10 +37,11 @@ export const MarkComponent = ({
32
37
  onClick,
33
38
  useBlockLevel
34
39
  }) => {
40
+ const isInlineCommentsKbAccessible = FeatureGates.checkGate('inline_comments_keyboard_accessible_renderer');
35
41
  const annotationIds = useMemo(() => [...new Set([...annotationParentIds, id])], [id, annotationParentIds]);
36
42
  const onMarkClick = useCallback(event => {
37
43
  // prevent inline mark logic for media block marks
38
- if (event.currentTarget.getAttribute('data-block-mark')) {
44
+ if (event.currentTarget instanceof HTMLElement && event.currentTarget.getAttribute('data-block-mark')) {
39
45
  return;
40
46
  }
41
47
 
@@ -64,15 +70,29 @@ export const MarkComponent = ({
64
70
  annotationIds
65
71
  });
66
72
  }, [annotationIds, onClick, state]);
73
+ const onMarkEnter = evt => {
74
+ var _document$activeEleme;
75
+ const focusedElementTag = (_document$activeEleme = document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.tagName;
76
+ if (focusedElementTag === 'MARK' && evt.key === 'Enter') {
77
+ onMarkClick(evt);
78
+ }
79
+ };
67
80
  const overriddenData = !state ? dataAttributes : {
68
81
  ...dataAttributes,
69
82
  'data-mark-annotation-state': state,
70
83
  'data-has-focus': hasFocus
71
84
  };
85
+ const desktopAccessibilityAttributes = isInlineCommentsKbAccessible ? isMobile() ? {} : {
86
+ role: 'button',
87
+ tabIndex: 0,
88
+ onKeyDown: onMarkEnter,
89
+ 'aria-expanded': hasFocus
90
+ } : {};
72
91
  const accessibility = state !== AnnotationMarkStates.ACTIVE ? {
73
92
  'aria-disabled': true
74
93
  } : {
75
- 'aria-details': annotationIds.join(', ')
94
+ 'aria-details': annotationIds.join(', '),
95
+ ...desktopAccessibilityAttributes
76
96
  };
77
97
  return jsx(useBlockLevel ? 'div' : 'mark', {
78
98
  id,
@@ -1,5 +1,6 @@
1
1
  import { useLayoutEffect, useState } from 'react';
2
2
  import { AnnotationUpdateEvent } from '@atlaskit/editor-common/types';
3
+ import FeatureGates from '@atlaskit/feature-gate-js-client';
3
4
  import { AnnotationTypes } from '@atlaskit/adf-schema';
4
5
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
5
6
  import { FabricChannel } from '@atlaskit/analytics-listeners';
@@ -44,6 +45,7 @@ export const useHasFocusEvent = ({
44
45
  updateSubscriber
45
46
  }) => {
46
47
  const [hasFocus, setHasFocus] = useState(false);
48
+ const isInlineCommentsKbAccessible = FeatureGates.checkGate('inline_comments_keyboard_accessible_renderer');
47
49
  useLayoutEffect(() => {
48
50
  if (!updateSubscriber) {
49
51
  return;
@@ -53,6 +55,9 @@ export const useHasFocusEvent = ({
53
55
  };
54
56
  const removeFocus = () => {
55
57
  setHasFocus(false);
58
+ if (isInlineCommentsKbAccessible && document.activeElement instanceof HTMLElement) {
59
+ document.activeElement.blur();
60
+ }
56
61
  };
57
62
  updateSubscriber.on(AnnotationUpdateEvent.SET_ANNOTATION_FOCUS, cb);
58
63
  updateSubscriber.on(AnnotationUpdateEvent.REMOVE_ANNOTATION_FOCUS, removeFocus);
@@ -60,7 +65,7 @@ export const useHasFocusEvent = ({
60
65
  updateSubscriber.off(AnnotationUpdateEvent.SET_ANNOTATION_FOCUS, cb);
61
66
  updateSubscriber.off(AnnotationUpdateEvent.REMOVE_ANNOTATION_FOCUS, removeFocus);
62
67
  };
63
- }, [id, updateSubscriber]);
68
+ }, [id, updateSubscriber, isInlineCommentsKbAccessible]);
64
69
  return hasFocus;
65
70
  };
66
71
  export const useAnnotationClickEvent = props => {
@@ -70,6 +75,7 @@ export const useAnnotationClickEvent = props => {
70
75
  createAnalyticsEvent,
71
76
  isCommentsOnMediaAnalyticsEnabled
72
77
  } = props;
78
+ const isInlineCommentsKbAccessible = FeatureGates.checkGate('inline_comments_keyboard_accessible_renderer');
73
79
  useLayoutEffect(() => {
74
80
  if (!updateSubscriber) {
75
81
  return;
@@ -109,6 +115,9 @@ export const useAnnotationClickEvent = props => {
109
115
  annotations: [],
110
116
  clickElementTarget: undefined
111
117
  });
118
+ if (isInlineCommentsKbAccessible && document.activeElement instanceof HTMLElement) {
119
+ document.activeElement.blur();
120
+ }
112
121
  };
113
122
  updateSubscriber.on(AnnotationUpdateEvent.ON_ANNOTATION_CLICK, clickCb);
114
123
  updateSubscriber.on(AnnotationUpdateEvent.DESELECT_ANNOTATIONS, deselectCb);
@@ -116,6 +125,6 @@ export const useAnnotationClickEvent = props => {
116
125
  updateSubscriber.off(AnnotationUpdateEvent.ON_ANNOTATION_CLICK, clickCb);
117
126
  updateSubscriber.off(AnnotationUpdateEvent.DESELECT_ANNOTATIONS, deselectCb);
118
127
  };
119
- }, [updateSubscriber, createAnalyticsEvent, isCommentsOnMediaAnalyticsEnabled]);
128
+ }, [updateSubscriber, createAnalyticsEvent, isCommentsOnMediaAnalyticsEnabled, isInlineCommentsKbAccessible]);
120
129
  return annotationClickEvent;
121
130
  };
@@ -48,7 +48,7 @@ import { nodeToReact } from '../../react/nodes';
48
48
  export var NORMAL_SEVERITY_THRESHOLD = 2000;
49
49
  export var DEGRADED_SEVERITY_THRESHOLD = 3000;
50
50
  var packageName = "@atlaskit/renderer";
51
- var packageVersion = "109.36.0";
51
+ var packageVersion = "109.37.0";
52
52
  export var defaultNodeComponents = nodeToReact;
53
53
  export var Renderer = /*#__PURE__*/function (_PureComponent) {
54
54
  _inherits(Renderer, _PureComponent);
@@ -104,6 +104,9 @@ function getAnnotationStyles(_ref6) {
104
104
  if (!getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes')) {
105
105
  return '';
106
106
  }
107
+ if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
108
+ return '';
109
+ }
107
110
  return css({
108
111
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
109
112
  "& [data-mark-type='annotation'][data-mark-annotation-state='active'] [data-annotation-mark], & [data-annotation-draft-mark][data-annotation-inline-node]": {
@@ -9,13 +9,17 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
9
9
  import { useMemo, useCallback } from 'react';
10
10
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
11
11
  import { css, jsx } from '@emotion/react';
12
+ import FeatureGates from '@atlaskit/feature-gate-js-client';
12
13
  import { AnnotationSharedCSSByState } from '@atlaskit/editor-common/styles';
13
14
  import { AnnotationMarkStates } from '@atlaskit/adf-schema';
14
15
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
15
16
 
16
17
  // eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- `AnnotationSharedCSSByState` is not object-safe
17
18
  var markStyles = function markStyles() {
18
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\tcolor: inherit;\n\tbackground-color: unset;\n\t-webkit-tap-highlight-color: transparent;\n\n\t&[data-mark-annotation-state='", "'] {\n\t\t", ";\n\n\t\t&:focus,\n\t\t&[data-has-focus='true'] {\n\t\t\t", ";\n\t\t}\n\t}\n"])), AnnotationMarkStates.ACTIVE, AnnotationSharedCSSByState().blur, AnnotationSharedCSSByState().focus);
19
+ return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\tcolor: inherit;\n\tbackground-color: unset;\n\t-webkit-tap-highlight-color: transparent;\n\n\t&[data-mark-annotation-state='", "'] {\n\t\t", ";\n\t\t", ";\n\n\t\t&:focus,\n\t\t&[data-has-focus='true'] {\n\t\t\t", ";\n\t\t}\n\t}\n"])), AnnotationMarkStates.ACTIVE, AnnotationSharedCSSByState().common, AnnotationSharedCSSByState().blur, AnnotationSharedCSSByState().focus);
20
+ };
21
+ var isMobile = function isMobile() {
22
+ return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
19
23
  };
20
24
  export var MarkComponent = function MarkComponent(_ref) {
21
25
  var annotationParentIds = _ref.annotationParentIds,
@@ -26,12 +30,13 @@ export var MarkComponent = function MarkComponent(_ref) {
26
30
  hasFocus = _ref.hasFocus,
27
31
  onClick = _ref.onClick,
28
32
  useBlockLevel = _ref.useBlockLevel;
33
+ var isInlineCommentsKbAccessible = FeatureGates.checkGate('inline_comments_keyboard_accessible_renderer');
29
34
  var annotationIds = useMemo(function () {
30
35
  return _toConsumableArray(new Set([].concat(_toConsumableArray(annotationParentIds), [id])));
31
36
  }, [id, annotationParentIds]);
32
37
  var onMarkClick = useCallback(function (event) {
33
38
  // prevent inline mark logic for media block marks
34
- if (event.currentTarget.getAttribute('data-block-mark')) {
39
+ if (event.currentTarget instanceof HTMLElement && event.currentTarget.getAttribute('data-block-mark')) {
35
40
  return;
36
41
  }
37
42
 
@@ -60,15 +65,28 @@ export var MarkComponent = function MarkComponent(_ref) {
60
65
  annotationIds: annotationIds
61
66
  });
62
67
  }, [annotationIds, onClick, state]);
68
+ var onMarkEnter = function onMarkEnter(evt) {
69
+ var _document$activeEleme;
70
+ var focusedElementTag = (_document$activeEleme = document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.tagName;
71
+ if (focusedElementTag === 'MARK' && evt.key === 'Enter') {
72
+ onMarkClick(evt);
73
+ }
74
+ };
63
75
  var overriddenData = !state ? dataAttributes : _objectSpread(_objectSpread({}, dataAttributes), {}, {
64
76
  'data-mark-annotation-state': state,
65
77
  'data-has-focus': hasFocus
66
78
  });
79
+ var desktopAccessibilityAttributes = isInlineCommentsKbAccessible ? isMobile() ? {} : {
80
+ role: 'button',
81
+ tabIndex: 0,
82
+ onKeyDown: onMarkEnter,
83
+ 'aria-expanded': hasFocus
84
+ } : {};
67
85
  var accessibility = state !== AnnotationMarkStates.ACTIVE ? {
68
86
  'aria-disabled': true
69
- } : {
87
+ } : _objectSpread({
70
88
  'aria-details': annotationIds.join(', ')
71
- };
89
+ }, desktopAccessibilityAttributes);
72
90
  return jsx(useBlockLevel ? 'div' : 'mark', _objectSpread(_objectSpread(_objectSpread(_defineProperty({
73
91
  id: id
74
92
  }, getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes') ? 'onClickCapture' : 'onClick', onMarkClick), accessibility), overriddenData), !useBlockLevel && {
@@ -4,6 +4,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
4
4
  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) { _defineProperty(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; }
5
5
  import { useLayoutEffect, useState } from 'react';
6
6
  import { AnnotationUpdateEvent } from '@atlaskit/editor-common/types';
7
+ import FeatureGates from '@atlaskit/feature-gate-js-client';
7
8
  import { AnnotationTypes } from '@atlaskit/adf-schema';
8
9
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
9
10
  import { FabricChannel } from '@atlaskit/analytics-listeners';
@@ -46,6 +47,7 @@ export var useHasFocusEvent = function useHasFocusEvent(_ref2) {
46
47
  _useState4 = _slicedToArray(_useState3, 2),
47
48
  hasFocus = _useState4[0],
48
49
  setHasFocus = _useState4[1];
50
+ var isInlineCommentsKbAccessible = FeatureGates.checkGate('inline_comments_keyboard_accessible_renderer');
49
51
  useLayoutEffect(function () {
50
52
  if (!updateSubscriber) {
51
53
  return;
@@ -55,6 +57,9 @@ export var useHasFocusEvent = function useHasFocusEvent(_ref2) {
55
57
  };
56
58
  var removeFocus = function removeFocus() {
57
59
  setHasFocus(false);
60
+ if (isInlineCommentsKbAccessible && document.activeElement instanceof HTMLElement) {
61
+ document.activeElement.blur();
62
+ }
58
63
  };
59
64
  updateSubscriber.on(AnnotationUpdateEvent.SET_ANNOTATION_FOCUS, cb);
60
65
  updateSubscriber.on(AnnotationUpdateEvent.REMOVE_ANNOTATION_FOCUS, removeFocus);
@@ -62,7 +67,7 @@ export var useHasFocusEvent = function useHasFocusEvent(_ref2) {
62
67
  updateSubscriber.off(AnnotationUpdateEvent.SET_ANNOTATION_FOCUS, cb);
63
68
  updateSubscriber.off(AnnotationUpdateEvent.REMOVE_ANNOTATION_FOCUS, removeFocus);
64
69
  };
65
- }, [id, updateSubscriber]);
70
+ }, [id, updateSubscriber, isInlineCommentsKbAccessible]);
66
71
  return hasFocus;
67
72
  };
68
73
  export var useAnnotationClickEvent = function useAnnotationClickEvent(props) {
@@ -73,6 +78,7 @@ export var useAnnotationClickEvent = function useAnnotationClickEvent(props) {
73
78
  var updateSubscriber = props.updateSubscriber,
74
79
  createAnalyticsEvent = props.createAnalyticsEvent,
75
80
  isCommentsOnMediaAnalyticsEnabled = props.isCommentsOnMediaAnalyticsEnabled;
81
+ var isInlineCommentsKbAccessible = FeatureGates.checkGate('inline_comments_keyboard_accessible_renderer');
76
82
  useLayoutEffect(function () {
77
83
  if (!updateSubscriber) {
78
84
  return;
@@ -114,6 +120,9 @@ export var useAnnotationClickEvent = function useAnnotationClickEvent(props) {
114
120
  annotations: [],
115
121
  clickElementTarget: undefined
116
122
  });
123
+ if (isInlineCommentsKbAccessible && document.activeElement instanceof HTMLElement) {
124
+ document.activeElement.blur();
125
+ }
117
126
  };
118
127
  updateSubscriber.on(AnnotationUpdateEvent.ON_ANNOTATION_CLICK, clickCb);
119
128
  updateSubscriber.on(AnnotationUpdateEvent.DESELECT_ANNOTATIONS, deselectCb);
@@ -121,6 +130,6 @@ export var useAnnotationClickEvent = function useAnnotationClickEvent(props) {
121
130
  updateSubscriber.off(AnnotationUpdateEvent.ON_ANNOTATION_CLICK, clickCb);
122
131
  updateSubscriber.off(AnnotationUpdateEvent.DESELECT_ANNOTATIONS, deselectCb);
123
132
  };
124
- }, [updateSubscriber, createAnalyticsEvent, isCommentsOnMediaAnalyticsEnabled]);
133
+ }, [updateSubscriber, createAnalyticsEvent, isCommentsOnMediaAnalyticsEnabled, isInlineCommentsKbAccessible]);
125
134
  return annotationClickEvent;
126
135
  };
@@ -1,3 +1,4 @@
1
+ /** @jsx jsx */
1
2
  import type React from 'react';
2
3
  import type { OnAnnotationClickPayload } from '@atlaskit/editor-common/types';
3
4
  import type { AnnotationId, AnnotationDataAttributes } from '@atlaskit/adf-schema';
@@ -11,14 +12,13 @@ type MarkComponentProps = {
11
12
  onClick: (props: OnAnnotationClickPayload) => void;
12
13
  useBlockLevel?: boolean;
13
14
  };
14
- export declare const MarkComponent: ({ annotationParentIds, children, dataAttributes, id, state, hasFocus, onClick, useBlockLevel, }: React.PropsWithChildren<MarkComponentProps>) => React.DetailedReactHTMLElement<{
15
+ export declare const MarkComponent: ({ annotationParentIds, children, dataAttributes, id, state, hasFocus, onClick, useBlockLevel, }: React.PropsWithChildren<MarkComponentProps>) => React.ReactElement<{
15
16
  css?: (() => import("@emotion/react").SerializedStyles)[] | undefined;
16
17
  'data-mark-type': string;
17
18
  'data-mark-annotation-type': import("@atlaskit/adf-schema").AnnotationTypes;
18
19
  'data-id': string;
19
20
  'data-mark-annotation-state'?: AnnotationMarkStates | undefined;
20
21
  'aria-disabled': boolean;
21
- 'aria-details'?: undefined;
22
22
  id: string;
23
23
  } | {
24
24
  css?: (() => import("@emotion/react").SerializedStyles)[] | undefined;
@@ -28,7 +28,6 @@ export declare const MarkComponent: ({ annotationParentIds, children, dataAttrib
28
28
  'data-mark-annotation-type': import("@atlaskit/adf-schema").AnnotationTypes;
29
29
  'data-id': string;
30
30
  'aria-disabled': boolean;
31
- 'aria-details'?: undefined;
32
31
  id: string;
33
32
  } | {
34
33
  css?: (() => import("@emotion/react").SerializedStyles)[] | undefined;
@@ -36,6 +35,10 @@ export declare const MarkComponent: ({ annotationParentIds, children, dataAttrib
36
35
  'data-mark-annotation-type': import("@atlaskit/adf-schema").AnnotationTypes;
37
36
  'data-id': string;
38
37
  'data-mark-annotation-state'?: AnnotationMarkStates | undefined;
38
+ role?: undefined;
39
+ tabIndex?: undefined;
40
+ onKeyDown?: undefined;
41
+ 'aria-expanded'?: undefined;
39
42
  'aria-details': string;
40
43
  'aria-disabled'?: undefined;
41
44
  id: string;
@@ -46,8 +49,39 @@ export declare const MarkComponent: ({ annotationParentIds, children, dataAttrib
46
49
  'data-mark-type': string;
47
50
  'data-mark-annotation-type': import("@atlaskit/adf-schema").AnnotationTypes;
48
51
  'data-id': string;
52
+ role?: undefined;
53
+ tabIndex?: undefined;
54
+ onKeyDown?: undefined;
55
+ 'aria-expanded'?: undefined;
49
56
  'aria-details': string;
50
57
  'aria-disabled'?: undefined;
51
58
  id: string;
52
- }, HTMLElement>;
59
+ } | {
60
+ css?: (() => import("@emotion/react").SerializedStyles)[] | undefined;
61
+ 'data-mark-type': string;
62
+ 'data-mark-annotation-type': import("@atlaskit/adf-schema").AnnotationTypes;
63
+ 'data-id': string;
64
+ 'data-mark-annotation-state'?: AnnotationMarkStates | undefined;
65
+ role: string;
66
+ tabIndex: number;
67
+ onKeyDown: (evt: KeyboardEvent) => void;
68
+ 'aria-expanded': boolean;
69
+ 'aria-details': string;
70
+ 'aria-disabled'?: undefined;
71
+ id: string;
72
+ } | {
73
+ css?: (() => import("@emotion/react").SerializedStyles)[] | undefined;
74
+ 'data-mark-annotation-state': AnnotationMarkStates;
75
+ 'data-has-focus': boolean;
76
+ 'data-mark-type': string;
77
+ 'data-mark-annotation-type': import("@atlaskit/adf-schema").AnnotationTypes;
78
+ 'data-id': string;
79
+ role: string;
80
+ tabIndex: number;
81
+ onKeyDown: (evt: KeyboardEvent) => void;
82
+ 'aria-expanded': boolean;
83
+ 'aria-details': string;
84
+ 'aria-disabled'?: undefined;
85
+ id: string;
86
+ }, string | React.JSXElementConstructor<any>>;
53
87
  export {};
@@ -1,3 +1,4 @@
1
+ /** @jsx jsx */
1
2
  import type React from 'react';
2
3
  import type { OnAnnotationClickPayload } from '@atlaskit/editor-common/types';
3
4
  import type { AnnotationId, AnnotationDataAttributes } from '@atlaskit/adf-schema';
@@ -11,14 +12,13 @@ type MarkComponentProps = {
11
12
  onClick: (props: OnAnnotationClickPayload) => void;
12
13
  useBlockLevel?: boolean;
13
14
  };
14
- export declare const MarkComponent: ({ annotationParentIds, children, dataAttributes, id, state, hasFocus, onClick, useBlockLevel, }: React.PropsWithChildren<MarkComponentProps>) => React.DetailedReactHTMLElement<{
15
+ export declare const MarkComponent: ({ annotationParentIds, children, dataAttributes, id, state, hasFocus, onClick, useBlockLevel, }: React.PropsWithChildren<MarkComponentProps>) => React.ReactElement<{
15
16
  css?: (() => import("@emotion/react").SerializedStyles)[] | undefined;
16
17
  'data-mark-type': string;
17
18
  'data-mark-annotation-type': import("@atlaskit/adf-schema").AnnotationTypes;
18
19
  'data-id': string;
19
20
  'data-mark-annotation-state'?: AnnotationMarkStates | undefined;
20
21
  'aria-disabled': boolean;
21
- 'aria-details'?: undefined;
22
22
  id: string;
23
23
  } | {
24
24
  css?: (() => import("@emotion/react").SerializedStyles)[] | undefined;
@@ -28,7 +28,6 @@ export declare const MarkComponent: ({ annotationParentIds, children, dataAttrib
28
28
  'data-mark-annotation-type': import("@atlaskit/adf-schema").AnnotationTypes;
29
29
  'data-id': string;
30
30
  'aria-disabled': boolean;
31
- 'aria-details'?: undefined;
32
31
  id: string;
33
32
  } | {
34
33
  css?: (() => import("@emotion/react").SerializedStyles)[] | undefined;
@@ -36,6 +35,10 @@ export declare const MarkComponent: ({ annotationParentIds, children, dataAttrib
36
35
  'data-mark-annotation-type': import("@atlaskit/adf-schema").AnnotationTypes;
37
36
  'data-id': string;
38
37
  'data-mark-annotation-state'?: AnnotationMarkStates | undefined;
38
+ role?: undefined;
39
+ tabIndex?: undefined;
40
+ onKeyDown?: undefined;
41
+ 'aria-expanded'?: undefined;
39
42
  'aria-details': string;
40
43
  'aria-disabled'?: undefined;
41
44
  id: string;
@@ -46,8 +49,39 @@ export declare const MarkComponent: ({ annotationParentIds, children, dataAttrib
46
49
  'data-mark-type': string;
47
50
  'data-mark-annotation-type': import("@atlaskit/adf-schema").AnnotationTypes;
48
51
  'data-id': string;
52
+ role?: undefined;
53
+ tabIndex?: undefined;
54
+ onKeyDown?: undefined;
55
+ 'aria-expanded'?: undefined;
49
56
  'aria-details': string;
50
57
  'aria-disabled'?: undefined;
51
58
  id: string;
52
- }, HTMLElement>;
59
+ } | {
60
+ css?: (() => import("@emotion/react").SerializedStyles)[] | undefined;
61
+ 'data-mark-type': string;
62
+ 'data-mark-annotation-type': import("@atlaskit/adf-schema").AnnotationTypes;
63
+ 'data-id': string;
64
+ 'data-mark-annotation-state'?: AnnotationMarkStates | undefined;
65
+ role: string;
66
+ tabIndex: number;
67
+ onKeyDown: (evt: KeyboardEvent) => void;
68
+ 'aria-expanded': boolean;
69
+ 'aria-details': string;
70
+ 'aria-disabled'?: undefined;
71
+ id: string;
72
+ } | {
73
+ css?: (() => import("@emotion/react").SerializedStyles)[] | undefined;
74
+ 'data-mark-annotation-state': AnnotationMarkStates;
75
+ 'data-has-focus': boolean;
76
+ 'data-mark-type': string;
77
+ 'data-mark-annotation-type': import("@atlaskit/adf-schema").AnnotationTypes;
78
+ 'data-id': string;
79
+ role: string;
80
+ tabIndex: number;
81
+ onKeyDown: (evt: KeyboardEvent) => void;
82
+ 'aria-expanded': boolean;
83
+ 'aria-details': string;
84
+ 'aria-disabled'?: undefined;
85
+ id: string;
86
+ }, string | React.JSXElementConstructor<any>>;
53
87
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/renderer",
3
- "version": "109.36.0",
3
+ "version": "109.37.0",
4
4
  "description": "Renderer component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -31,13 +31,14 @@
31
31
  "@atlaskit/analytics-next": "^9.3.0",
32
32
  "@atlaskit/button": "^18.0.0",
33
33
  "@atlaskit/code": "^15.3.0",
34
- "@atlaskit/editor-common": "^82.14.0",
34
+ "@atlaskit/editor-common": "^83.1.0",
35
35
  "@atlaskit/editor-json-transformer": "^8.14.0",
36
36
  "@atlaskit/editor-palette": "1.6.0",
37
37
  "@atlaskit/editor-prosemirror": "4.0.1",
38
38
  "@atlaskit/editor-shared-styles": "^2.12.0",
39
39
  "@atlaskit/emoji": "^67.6.0",
40
- "@atlaskit/icon": "^22.4.0",
40
+ "@atlaskit/feature-gate-js-client": "^4.18.0",
41
+ "@atlaskit/icon": "^22.5.0",
41
42
  "@atlaskit/link-datasource": "^2.4.0",
42
43
  "@atlaskit/media-card": "^77.12.0",
43
44
  "@atlaskit/media-client": "^27.3.0",