@atlaskit/editor-plugin-accessibility-utils 1.0.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 ADDED
@@ -0,0 +1 @@
1
+ # @atlaskit/editor-plugin-accessibility-utils
package/LICENSE.md ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2023 Atlassian Pty Ltd
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # Editor plugin accessibility utils
2
+
3
+ Accessibility utils for @atlaskit/editor-core
4
+
5
+ **Note:** This component is designed for internal Atlassian development.
6
+ External contributors will be able to use this component but will not be able to submit issues.
7
+
8
+ ## Install
9
+ ---
10
+ - **Install** - *yarn add @atlaskit/editor-plugin-accesibility-utils*
11
+ - **npm** - [@atlaskit/editor-plugin-accesibility-utils](https://www.npmjs.com/package/@atlaskit/editor-plugin-accesibility-utils)
12
+ - **Source** - [Bitbucket](https://bitbucket.org/atlassian/atlassian-frontend/src/master/packages/editor/editor-plugin-accesibility-utils)
13
+ - **Bundle** - [unpkg.com](https://unpkg.com/@atlaskit/editor-plugin-accesibility-utils/dist/)
14
+
15
+ ## Usage
16
+ ---
17
+ **Internal use only**
18
+
19
+ @atlaskit/editor-plugin-accesibility-utils is intended for internal use by the @atlaskit/editor-core and as a plugin dependency of the Editor within your product.
20
+
21
+ Direct use of this component is not supported.
22
+
23
+ Please see [Atlaskit - Editor plugin annotation](https://atlaskit.atlassian.com/packages/editor/editor-plugin-accesibility-utils) for documentation and examples for this package.
24
+
25
+ ## Support
26
+ ---
27
+ For internal Atlassian, visit the slack channel [#help-editor](https://atlassian.slack.com/archives/CFG3PSQ9E) for support or visit [go/editor-help](https://go/editor-help) to submit a bug.
28
+ ## License
29
+ ---
30
+ Please see [Atlassian Frontend - License](https://hello.atlassian.net/wiki/spaces/AF/pages/2589099144/Documentation#License) for more licensing information.
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "accessibilityUtilsPlugin", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _plugin.accessibilityUtilsPlugin;
10
+ }
11
+ });
12
+ var _plugin = require("./plugin");
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.accessibilityUtilsPluginKey = exports.accessibilityUtilsPlugin = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _hooks = require("@atlaskit/editor-common/hooks");
10
+ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
11
+ var _state = require("@atlaskit/editor-prosemirror/state");
12
+ var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
13
+ var accessibilityUtilsPluginKey = exports.accessibilityUtilsPluginKey = new _state.PluginKey('accessibilityUtilsPlugin');
14
+ var accessibilityUtilsPlugin = exports.accessibilityUtilsPlugin = function accessibilityUtilsPlugin(_ref) {
15
+ var api = _ref.api;
16
+ var editorView;
17
+ var setEditorView = function setEditorView(newEditorView) {
18
+ editorView = newEditorView;
19
+ };
20
+ return {
21
+ name: 'accessibilityUtils',
22
+ actions: {
23
+ ariaNotify: function ariaNotify(message) {
24
+ if (!editorView) {
25
+ // at time of writing, this should never happen
26
+ return;
27
+ }
28
+ var tr = editorView.state.tr;
29
+ tr.setMeta(accessibilityUtilsPluginKey, {
30
+ message: message
31
+ });
32
+ editorView.dispatch(tr);
33
+ return;
34
+ }
35
+ },
36
+ contentComponent: function contentComponent() {
37
+ return /*#__PURE__*/_react.default.createElement(ContentComponent, {
38
+ api: api
39
+ });
40
+ },
41
+ getSharedState: function getSharedState(editorState) {
42
+ if (!editorState) {
43
+ return null;
44
+ }
45
+ return accessibilityUtilsPluginKey.getState(editorState);
46
+ },
47
+ pmPlugins: function pmPlugins() {
48
+ return [{
49
+ name: 'get-editor-view',
50
+ plugin: function plugin() {
51
+ return new _safePlugin.SafePlugin({
52
+ key: accessibilityUtilsPluginKey,
53
+ state: {
54
+ init: function init() {
55
+ return {
56
+ message: ''
57
+ };
58
+ },
59
+ apply: function apply(tr, prevState) {
60
+ var meta = tr.getMeta(accessibilityUtilsPluginKey);
61
+ if (meta && 'message' in meta) {
62
+ return {
63
+ message: meta.message
64
+ };
65
+ }
66
+ return prevState;
67
+ }
68
+ },
69
+ view: function view(editorView) {
70
+ setEditorView(editorView);
71
+ return {};
72
+ }
73
+ });
74
+ }
75
+ }];
76
+ }
77
+ };
78
+ };
79
+ function ContentComponent(_ref2) {
80
+ var api = _ref2.api;
81
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['accessibilityUtils']),
82
+ accessibilityUtilsState = _useSharedPluginState.accessibilityUtilsState;
83
+ return /*#__PURE__*/_react.default.createElement(_visuallyHidden.default, {
84
+ role: "alert"
85
+ }, accessibilityUtilsState === null || accessibilityUtilsState === void 0 ? void 0 : accessibilityUtilsState.message);
86
+ }
@@ -0,0 +1 @@
1
+ export { accessibilityUtilsPlugin } from './plugin';
@@ -0,0 +1,80 @@
1
+ import React from 'react';
2
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
5
+ import VisuallyHidden from '@atlaskit/visually-hidden';
6
+ export const accessibilityUtilsPluginKey = new PluginKey('accessibilityUtilsPlugin');
7
+ export const accessibilityUtilsPlugin = ({
8
+ api
9
+ }) => {
10
+ let editorView;
11
+ const setEditorView = newEditorView => {
12
+ editorView = newEditorView;
13
+ };
14
+ return {
15
+ name: 'accessibilityUtils',
16
+ actions: {
17
+ ariaNotify: message => {
18
+ if (!editorView) {
19
+ // at time of writing, this should never happen
20
+ return;
21
+ }
22
+ const tr = editorView.state.tr;
23
+ tr.setMeta(accessibilityUtilsPluginKey, {
24
+ message
25
+ });
26
+ editorView.dispatch(tr);
27
+ return;
28
+ }
29
+ },
30
+ contentComponent: () => {
31
+ return /*#__PURE__*/React.createElement(ContentComponent, {
32
+ api: api
33
+ });
34
+ },
35
+ getSharedState(editorState) {
36
+ if (!editorState) {
37
+ return null;
38
+ }
39
+ return accessibilityUtilsPluginKey.getState(editorState);
40
+ },
41
+ pmPlugins() {
42
+ return [{
43
+ name: 'get-editor-view',
44
+ plugin: () => {
45
+ return new SafePlugin({
46
+ key: accessibilityUtilsPluginKey,
47
+ state: {
48
+ init: () => ({
49
+ message: ''
50
+ }),
51
+ apply: (tr, prevState) => {
52
+ const meta = tr.getMeta(accessibilityUtilsPluginKey);
53
+ if (meta && 'message' in meta) {
54
+ return {
55
+ message: meta.message
56
+ };
57
+ }
58
+ return prevState;
59
+ }
60
+ },
61
+ view(editorView) {
62
+ setEditorView(editorView);
63
+ return {};
64
+ }
65
+ });
66
+ }
67
+ }];
68
+ }
69
+ };
70
+ };
71
+ function ContentComponent({
72
+ api
73
+ }) {
74
+ const {
75
+ accessibilityUtilsState
76
+ } = useSharedPluginState(api, ['accessibilityUtils']);
77
+ return /*#__PURE__*/React.createElement(VisuallyHidden, {
78
+ role: "alert"
79
+ }, accessibilityUtilsState === null || accessibilityUtilsState === void 0 ? void 0 : accessibilityUtilsState.message);
80
+ }
@@ -0,0 +1 @@
1
+ export { accessibilityUtilsPlugin } from './plugin';
@@ -0,0 +1,79 @@
1
+ import React from 'react';
2
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
5
+ import VisuallyHidden from '@atlaskit/visually-hidden';
6
+ export var accessibilityUtilsPluginKey = new PluginKey('accessibilityUtilsPlugin');
7
+ export var accessibilityUtilsPlugin = function accessibilityUtilsPlugin(_ref) {
8
+ var api = _ref.api;
9
+ var editorView;
10
+ var setEditorView = function setEditorView(newEditorView) {
11
+ editorView = newEditorView;
12
+ };
13
+ return {
14
+ name: 'accessibilityUtils',
15
+ actions: {
16
+ ariaNotify: function ariaNotify(message) {
17
+ if (!editorView) {
18
+ // at time of writing, this should never happen
19
+ return;
20
+ }
21
+ var tr = editorView.state.tr;
22
+ tr.setMeta(accessibilityUtilsPluginKey, {
23
+ message: message
24
+ });
25
+ editorView.dispatch(tr);
26
+ return;
27
+ }
28
+ },
29
+ contentComponent: function contentComponent() {
30
+ return /*#__PURE__*/React.createElement(ContentComponent, {
31
+ api: api
32
+ });
33
+ },
34
+ getSharedState: function getSharedState(editorState) {
35
+ if (!editorState) {
36
+ return null;
37
+ }
38
+ return accessibilityUtilsPluginKey.getState(editorState);
39
+ },
40
+ pmPlugins: function pmPlugins() {
41
+ return [{
42
+ name: 'get-editor-view',
43
+ plugin: function plugin() {
44
+ return new SafePlugin({
45
+ key: accessibilityUtilsPluginKey,
46
+ state: {
47
+ init: function init() {
48
+ return {
49
+ message: ''
50
+ };
51
+ },
52
+ apply: function apply(tr, prevState) {
53
+ var meta = tr.getMeta(accessibilityUtilsPluginKey);
54
+ if (meta && 'message' in meta) {
55
+ return {
56
+ message: meta.message
57
+ };
58
+ }
59
+ return prevState;
60
+ }
61
+ },
62
+ view: function view(editorView) {
63
+ setEditorView(editorView);
64
+ return {};
65
+ }
66
+ });
67
+ }
68
+ }];
69
+ }
70
+ };
71
+ };
72
+ function ContentComponent(_ref2) {
73
+ var api = _ref2.api;
74
+ var _useSharedPluginState = useSharedPluginState(api, ['accessibilityUtils']),
75
+ accessibilityUtilsState = _useSharedPluginState.accessibilityUtilsState;
76
+ return /*#__PURE__*/React.createElement(VisuallyHidden, {
77
+ role: "alert"
78
+ }, accessibilityUtilsState === null || accessibilityUtilsState === void 0 ? void 0 : accessibilityUtilsState.message);
79
+ }
@@ -0,0 +1,2 @@
1
+ export { accessibilityUtilsPlugin } from './plugin';
2
+ export type { AccessibilityUtilsPlugin } from './plugin';
@@ -0,0 +1,21 @@
1
+ import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
2
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
+ export type AccessibilityUtilsPlugin = NextEditorPlugin<'accessibilityUtils', {
4
+ dependencies: [];
5
+ actions: {
6
+ /**
7
+ *
8
+ * @param {string} message - Message to be announced to screen readers. This should be internationalized.
9
+ *
10
+ * These are currently announced via assertive live regions to screen readers.
11
+ *
12
+ * *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
+ */
14
+ ariaNotify: (message: string) => void;
15
+ };
16
+ sharedState: {
17
+ message: string;
18
+ };
19
+ }>;
20
+ export declare const accessibilityUtilsPluginKey: PluginKey<any>;
21
+ export declare const accessibilityUtilsPlugin: AccessibilityUtilsPlugin;
@@ -0,0 +1,2 @@
1
+ export { accessibilityUtilsPlugin } from './plugin';
2
+ export type { AccessibilityUtilsPlugin } from './plugin';
@@ -0,0 +1,22 @@
1
+ import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
2
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
+ export type AccessibilityUtilsPlugin = NextEditorPlugin<'accessibilityUtils', {
4
+ dependencies: [
5
+ ];
6
+ actions: {
7
+ /**
8
+ *
9
+ * @param {string} message - Message to be announced to screen readers. This should be internationalized.
10
+ *
11
+ * These are currently announced via assertive live regions to screen readers.
12
+ *
13
+ * *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
+ */
15
+ ariaNotify: (message: string) => void;
16
+ };
17
+ sharedState: {
18
+ message: string;
19
+ };
20
+ }>;
21
+ export declare const accessibilityUtilsPluginKey: PluginKey<any>;
22
+ export declare const accessibilityUtilsPlugin: AccessibilityUtilsPlugin;
package/package.json ADDED
@@ -0,0 +1,89 @@
1
+ {
2
+ "name": "@atlaskit/editor-plugin-accessibility-utils",
3
+ "version": "1.0.0",
4
+ "description": "Accessibility utils for @atlaskit/editor-core",
5
+ "author": "Atlassian Pty Ltd",
6
+ "license": "Apache-2.0",
7
+ "publishConfig": {
8
+ "registry": "https://registry.npmjs.org/"
9
+ },
10
+ "atlassian": {
11
+ "team": "Editor: Scarlet",
12
+ "singleton": true,
13
+ "releaseModel": "continuous",
14
+ "runReact18": false
15
+ },
16
+ "repository": "https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo",
17
+ "main": "dist/cjs/index.js",
18
+ "module": "dist/esm/index.js",
19
+ "module:es2019": "dist/es2019/index.js",
20
+ "types": "dist/types/index.d.ts",
21
+ "typesVersions": {
22
+ ">=4.5 <4.9": {
23
+ "*": [
24
+ "dist/types-ts4.5/*",
25
+ "dist/types-ts4.5/index.d.ts"
26
+ ]
27
+ }
28
+ },
29
+ "sideEffects": false,
30
+ "atlaskit:src": "src/index.ts",
31
+ "af:exports": {
32
+ ".": "./src/index.ts"
33
+ },
34
+ "dependencies": {
35
+ "@atlaskit/editor-common": "^78.16.0",
36
+ "@atlaskit/editor-prosemirror": "3.0.0",
37
+ "@atlaskit/visually-hidden": "^1.2.2",
38
+ "@babel/runtime": "^7.0.0"
39
+ },
40
+ "peerDependencies": {
41
+ "react": "^16.8.0"
42
+ },
43
+ "devDependencies": {
44
+ "@af/integration-testing": "*",
45
+ "@af/visual-regression": "*",
46
+ "@atlaskit/ssr": "*",
47
+ "@atlaskit/visual-regression": "*",
48
+ "@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
49
+ "@testing-library/react": "^12.1.5",
50
+ "react-dom": "^16.8.0",
51
+ "typescript": "~4.9.5",
52
+ "wait-for-expect": "^1.2.0"
53
+ },
54
+ "techstack": {
55
+ "@atlassian/frontend": {
56
+ "import-structure": [
57
+ "atlassian-conventions"
58
+ ],
59
+ "circular-dependencies": [
60
+ "file-and-folder-level"
61
+ ]
62
+ },
63
+ "@repo/internal": {
64
+ "dom-events": "use-bind-event-listener",
65
+ "analytics": [
66
+ "analytics-next"
67
+ ],
68
+ "design-tokens": [
69
+ "color"
70
+ ],
71
+ "theming": [
72
+ "react-context"
73
+ ],
74
+ "ui-components": [
75
+ "lite-mode"
76
+ ],
77
+ "deprecation": "no-deprecated-imports",
78
+ "styling": [
79
+ "emotion",
80
+ "emotion"
81
+ ],
82
+ "imports": [
83
+ "import-no-extraneous-disable-for-examples-and-docs"
84
+ ]
85
+ }
86
+ },
87
+ "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0",
88
+ "platform-feature-flags": {}
89
+ }