@atlaskit/editor-plugin-accessibility-utils 1.0.1 → 1.1.1

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,21 @@
1
1
  # @atlaskit/editor-plugin-accessibility-utils
2
2
 
3
+ ## 1.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#85498](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/85498) [`07b576a5241d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/07b576a5241d) - [ux] [ECA11Y-17] Added the ability to pass additional props to aria live region
8
+
9
+ ## 1.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#91934](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/91934) [`b76a78c6a199`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b76a78c6a199) - bumped editor-prosemirror version to 4.0.0
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies
18
+
3
19
  ## 1.0.1
4
20
 
5
21
  ### Patch Changes
@@ -5,11 +5,15 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.accessibilityUtilsPluginKey = exports.accessibilityUtilsPlugin = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
8
10
  var _react = _interopRequireDefault(require("react"));
9
11
  var _hooks = require("@atlaskit/editor-common/hooks");
10
12
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
11
13
  var _state = require("@atlaskit/editor-prosemirror/state");
12
14
  var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
15
+ 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; }
16
+ 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; }
13
17
  var accessibilityUtilsPluginKey = exports.accessibilityUtilsPluginKey = new _state.PluginKey('accessibilityUtilsPlugin');
14
18
  var accessibilityUtilsPlugin = exports.accessibilityUtilsPlugin = function accessibilityUtilsPlugin(_ref) {
15
19
  var api = _ref.api;
@@ -20,14 +24,16 @@ var accessibilityUtilsPlugin = exports.accessibilityUtilsPlugin = function acces
20
24
  return {
21
25
  name: 'accessibilityUtils',
22
26
  actions: {
23
- ariaNotify: function ariaNotify(message) {
27
+ ariaNotify: function ariaNotify(message, ariaLiveElementAttributes) {
24
28
  if (!editorView) {
25
29
  // at time of writing, this should never happen
26
30
  return;
27
31
  }
28
32
  var tr = editorView.state.tr;
29
33
  tr.setMeta(accessibilityUtilsPluginKey, {
30
- message: message
34
+ message: message,
35
+ ariaLiveElementAttributes: ariaLiveElementAttributes,
36
+ key: Date.now().toString()
31
37
  });
32
38
  editorView.dispatch(tr);
33
39
  return;
@@ -53,15 +59,14 @@ var accessibilityUtilsPlugin = exports.accessibilityUtilsPlugin = function acces
53
59
  state: {
54
60
  init: function init() {
55
61
  return {
56
- message: ''
62
+ message: '',
63
+ ariaLiveElementAttributes: {}
57
64
  };
58
65
  },
59
66
  apply: function apply(tr, prevState) {
60
67
  var meta = tr.getMeta(accessibilityUtilsPluginKey);
61
- if (meta && 'message' in meta) {
62
- return {
63
- message: meta.message
64
- };
68
+ if (meta) {
69
+ return _objectSpread(_objectSpread({}, prevState), meta);
65
70
  }
66
71
  return prevState;
67
72
  }
@@ -77,10 +82,15 @@ var accessibilityUtilsPlugin = exports.accessibilityUtilsPlugin = function acces
77
82
  };
78
83
  };
79
84
  function ContentComponent(_ref2) {
85
+ var _accessibilityUtilsSt;
80
86
  var api = _ref2.api;
81
87
  var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['accessibilityUtils']),
82
88
  accessibilityUtilsState = _useSharedPluginState.accessibilityUtilsState;
83
- return /*#__PURE__*/_react.default.createElement(_visuallyHidden.default, {
84
- role: "alert"
85
- }, accessibilityUtilsState === null || accessibilityUtilsState === void 0 ? void 0 : accessibilityUtilsState.message);
89
+ var role = (accessibilityUtilsState === null || accessibilityUtilsState === void 0 || (_accessibilityUtilsSt = accessibilityUtilsState.ariaLiveElementAttributes) === null || _accessibilityUtilsSt === void 0 ? void 0 : _accessibilityUtilsSt.priority) === 'important' ? 'alert' : 'status';
90
+ var key = accessibilityUtilsState === null || accessibilityUtilsState === void 0 ? void 0 : accessibilityUtilsState.key;
91
+ return /*#__PURE__*/_react.default.createElement(_visuallyHidden.default, (0, _extends2.default)({
92
+ role: role
93
+ }, role === 'alert' && {
94
+ key: key
95
+ }), accessibilityUtilsState === null || accessibilityUtilsState === void 0 ? void 0 : accessibilityUtilsState.message);
86
96
  }
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import React from 'react';
2
3
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
4
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
@@ -14,14 +15,16 @@ export const accessibilityUtilsPlugin = ({
14
15
  return {
15
16
  name: 'accessibilityUtils',
16
17
  actions: {
17
- ariaNotify: message => {
18
+ ariaNotify: (message, ariaLiveElementAttributes) => {
18
19
  if (!editorView) {
19
20
  // at time of writing, this should never happen
20
21
  return;
21
22
  }
22
23
  const tr = editorView.state.tr;
23
24
  tr.setMeta(accessibilityUtilsPluginKey, {
24
- message
25
+ message,
26
+ ariaLiveElementAttributes,
27
+ key: Date.now().toString()
25
28
  });
26
29
  editorView.dispatch(tr);
27
30
  return;
@@ -46,13 +49,15 @@ export const accessibilityUtilsPlugin = ({
46
49
  key: accessibilityUtilsPluginKey,
47
50
  state: {
48
51
  init: () => ({
49
- message: ''
52
+ message: '',
53
+ ariaLiveElementAttributes: {}
50
54
  }),
51
55
  apply: (tr, prevState) => {
52
56
  const meta = tr.getMeta(accessibilityUtilsPluginKey);
53
- if (meta && 'message' in meta) {
57
+ if (meta) {
54
58
  return {
55
- message: meta.message
59
+ ...prevState,
60
+ ...meta
56
61
  };
57
62
  }
58
63
  return prevState;
@@ -71,10 +76,15 @@ export const accessibilityUtilsPlugin = ({
71
76
  function ContentComponent({
72
77
  api
73
78
  }) {
79
+ var _accessibilityUtilsSt;
74
80
  const {
75
81
  accessibilityUtilsState
76
82
  } = useSharedPluginState(api, ['accessibilityUtils']);
77
- return /*#__PURE__*/React.createElement(VisuallyHidden, {
78
- role: "alert"
79
- }, accessibilityUtilsState === null || accessibilityUtilsState === void 0 ? void 0 : accessibilityUtilsState.message);
83
+ const role = (accessibilityUtilsState === null || accessibilityUtilsState === void 0 ? void 0 : (_accessibilityUtilsSt = accessibilityUtilsState.ariaLiveElementAttributes) === null || _accessibilityUtilsSt === void 0 ? void 0 : _accessibilityUtilsSt.priority) === 'important' ? 'alert' : 'status';
84
+ const key = accessibilityUtilsState === null || accessibilityUtilsState === void 0 ? void 0 : accessibilityUtilsState.key;
85
+ return /*#__PURE__*/React.createElement(VisuallyHidden, _extends({
86
+ role: role
87
+ }, role === 'alert' && {
88
+ key
89
+ }), accessibilityUtilsState === null || accessibilityUtilsState === void 0 ? void 0 : accessibilityUtilsState.message);
80
90
  }
@@ -1,3 +1,7 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ 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; }
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; }
1
5
  import React from 'react';
2
6
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
7
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
@@ -13,14 +17,16 @@ export var accessibilityUtilsPlugin = function accessibilityUtilsPlugin(_ref) {
13
17
  return {
14
18
  name: 'accessibilityUtils',
15
19
  actions: {
16
- ariaNotify: function ariaNotify(message) {
20
+ ariaNotify: function ariaNotify(message, ariaLiveElementAttributes) {
17
21
  if (!editorView) {
18
22
  // at time of writing, this should never happen
19
23
  return;
20
24
  }
21
25
  var tr = editorView.state.tr;
22
26
  tr.setMeta(accessibilityUtilsPluginKey, {
23
- message: message
27
+ message: message,
28
+ ariaLiveElementAttributes: ariaLiveElementAttributes,
29
+ key: Date.now().toString()
24
30
  });
25
31
  editorView.dispatch(tr);
26
32
  return;
@@ -46,15 +52,14 @@ export var accessibilityUtilsPlugin = function accessibilityUtilsPlugin(_ref) {
46
52
  state: {
47
53
  init: function init() {
48
54
  return {
49
- message: ''
55
+ message: '',
56
+ ariaLiveElementAttributes: {}
50
57
  };
51
58
  },
52
59
  apply: function apply(tr, prevState) {
53
60
  var meta = tr.getMeta(accessibilityUtilsPluginKey);
54
- if (meta && 'message' in meta) {
55
- return {
56
- message: meta.message
57
- };
61
+ if (meta) {
62
+ return _objectSpread(_objectSpread({}, prevState), meta);
58
63
  }
59
64
  return prevState;
60
65
  }
@@ -70,10 +75,15 @@ export var accessibilityUtilsPlugin = function accessibilityUtilsPlugin(_ref) {
70
75
  };
71
76
  };
72
77
  function ContentComponent(_ref2) {
78
+ var _accessibilityUtilsSt;
73
79
  var api = _ref2.api;
74
80
  var _useSharedPluginState = useSharedPluginState(api, ['accessibilityUtils']),
75
81
  accessibilityUtilsState = _useSharedPluginState.accessibilityUtilsState;
76
- return /*#__PURE__*/React.createElement(VisuallyHidden, {
77
- role: "alert"
78
- }, accessibilityUtilsState === null || accessibilityUtilsState === void 0 ? void 0 : accessibilityUtilsState.message);
82
+ var role = (accessibilityUtilsState === null || accessibilityUtilsState === void 0 || (_accessibilityUtilsSt = accessibilityUtilsState.ariaLiveElementAttributes) === null || _accessibilityUtilsSt === void 0 ? void 0 : _accessibilityUtilsSt.priority) === 'important' ? 'alert' : 'status';
83
+ var key = accessibilityUtilsState === null || accessibilityUtilsState === void 0 ? void 0 : accessibilityUtilsState.key;
84
+ return /*#__PURE__*/React.createElement(VisuallyHidden, _extends({
85
+ role: role
86
+ }, role === 'alert' && {
87
+ key: key
88
+ }), accessibilityUtilsState === null || accessibilityUtilsState === void 0 ? void 0 : accessibilityUtilsState.message);
79
89
  }
@@ -1,2 +1,2 @@
1
1
  export { accessibilityUtilsPlugin } from './plugin';
2
- export type { AccessibilityUtilsPlugin } from './plugin';
2
+ export type { AccessibilityUtilsPlugin, AccessibilityUtilsPluginState, AriaLiveElementAttributes, } from './plugin';
@@ -1,5 +1,13 @@
1
1
  import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
2
2
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
+ export interface AriaLiveElementAttributes {
4
+ priority?: 'important' | 'none';
5
+ }
6
+ export interface AccessibilityUtilsPluginState {
7
+ message: string;
8
+ ariaLiveElementAttributes?: AriaLiveElementAttributes;
9
+ key?: string;
10
+ }
3
11
  export type AccessibilityUtilsPlugin = NextEditorPlugin<'accessibilityUtils', {
4
12
  dependencies: [];
5
13
  actions: {
@@ -11,11 +19,9 @@ export type AccessibilityUtilsPlugin = NextEditorPlugin<'accessibilityUtils', {
11
19
  *
12
20
  * *In future, the ariaNotify proposal looks like a good fit for this use case. The naming has been selected to align with this proposal.
13
21
  */
14
- ariaNotify: (message: string) => void;
15
- };
16
- sharedState: {
17
- message: string;
22
+ ariaNotify: (message: string, ariaLiveElementAttributes?: AriaLiveElementAttributes) => void;
18
23
  };
24
+ sharedState: AccessibilityUtilsPluginState;
19
25
  }>;
20
26
  export declare const accessibilityUtilsPluginKey: PluginKey<any>;
21
27
  export declare const accessibilityUtilsPlugin: AccessibilityUtilsPlugin;
@@ -1,2 +1,2 @@
1
1
  export { accessibilityUtilsPlugin } from './plugin';
2
- export type { AccessibilityUtilsPlugin } from './plugin';
2
+ export type { AccessibilityUtilsPlugin, AccessibilityUtilsPluginState, AriaLiveElementAttributes, } from './plugin';
@@ -1,5 +1,13 @@
1
1
  import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
2
2
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
+ export interface AriaLiveElementAttributes {
4
+ priority?: 'important' | 'none';
5
+ }
6
+ export interface AccessibilityUtilsPluginState {
7
+ message: string;
8
+ ariaLiveElementAttributes?: AriaLiveElementAttributes;
9
+ key?: string;
10
+ }
3
11
  export type AccessibilityUtilsPlugin = NextEditorPlugin<'accessibilityUtils', {
4
12
  dependencies: [
5
13
  ];
@@ -12,11 +20,9 @@ export type AccessibilityUtilsPlugin = NextEditorPlugin<'accessibilityUtils', {
12
20
  *
13
21
  * *In future, the ariaNotify proposal looks like a good fit for this use case. The naming has been selected to align with this proposal.
14
22
  */
15
- ariaNotify: (message: string) => void;
16
- };
17
- sharedState: {
18
- message: string;
23
+ ariaNotify: (message: string, ariaLiveElementAttributes?: AriaLiveElementAttributes) => void;
19
24
  };
25
+ sharedState: AccessibilityUtilsPluginState;
20
26
  }>;
21
27
  export declare const accessibilityUtilsPluginKey: PluginKey<any>;
22
28
  export declare const accessibilityUtilsPlugin: AccessibilityUtilsPlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-accessibility-utils",
3
- "version": "1.0.1",
3
+ "version": "1.1.1",
4
4
  "description": "Accessibility utils for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,8 +32,8 @@
32
32
  ".": "./src/index.ts"
33
33
  },
34
34
  "dependencies": {
35
- "@atlaskit/editor-common": "^78.17.0",
36
- "@atlaskit/editor-prosemirror": "3.0.0",
35
+ "@atlaskit/editor-common": "^78.33.0",
36
+ "@atlaskit/editor-prosemirror": "4.0.0",
37
37
  "@atlaskit/visually-hidden": "^1.2.2",
38
38
  "@babel/runtime": "^7.0.0"
39
39
  },