@manuscripts/body-editor 3.20.0 → 3.20.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.
@@ -53,6 +53,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
53
53
  Object.defineProperty(exports, "__esModule", { value: true });
54
54
  exports.DraggableAuthor = void 0;
55
55
  const style_guide_1 = require("@manuscripts/style-guide");
56
+ const mui_1 = require("@manuscripts/style-guide/mui");
56
57
  const react_1 = __importStar(require("react"));
57
58
  const react_dnd_1 = require("react-dnd");
58
59
  const styled_components_1 = __importDefault(require("styled-components"));
@@ -192,7 +193,7 @@ exports.DraggableAuthor = react_1.default.memo(({ author, isSelected, onClick, o
192
193
  isSelected && react_1.default.createElement(DragHandle, null),
193
194
  react_1.default.createElement(Box, null,
194
195
  showSuccessIcon && react_1.default.createElement(StyledCrclTickAnimation, { size: 36 }),
195
- react_1.default.createElement(style_guide_1.Avatar, { size: 36, color: '#6e6e6e', opacity: showSuccessIcon ? 0.05 : 1 })),
196
+ react_1.default.createElement(mui_1.Avatar, { size: 36, color: '#6e6e6e', opacity: showSuccessIcon ? 0.05 : 1 })),
196
197
  react_1.default.createElement(AuthorNotes, { "data-cy": "author-notes" }, author.isCorresponding && (react_1.default.createElement(AuthorBadge, null,
197
198
  react_1.default.createElement(style_guide_1.CorrespondingAuthorIcon, null))))),
198
199
  react_1.default.createElement(AuthorName, { "data-cy": "author-name" }, (0, authors_1.authorLabel)(author)),
@@ -45,6 +45,27 @@ const buildExpandButtonDecorations = (doc) => {
45
45
  });
46
46
  return decorations;
47
47
  };
48
+ const ariaLabels = new Map([
49
+ [
50
+ transform_1.schema.nodes.headshot_element,
51
+ { caption: 'Headshot Summary', caption_title: 'Headshot Name' },
52
+ ],
53
+ ]);
54
+ const isCaptionNode = (node) => node.type === transform_1.schema.nodes.caption_title || node.type === transform_1.schema.nodes.caption;
55
+ const buildAriaLabelsDecorations = (doc) => {
56
+ const decorations = [];
57
+ doc.descendants((node, pos, parent) => {
58
+ if (isCaptionNode(node) && parent && ariaLabels.has(parent.type)) {
59
+ const arialLabel = ariaLabels.get(parent.type);
60
+ if (arialLabel) {
61
+ decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {
62
+ 'aria-label': arialLabel[node.type.name],
63
+ }));
64
+ }
65
+ }
66
+ });
67
+ return decorations;
68
+ };
48
69
  const buildExpandedElementsDecorations = (doc, expandedElementIDs, selection) => {
49
70
  const decorations = [];
50
71
  doc.descendants((node, pos) => {
@@ -64,6 +85,7 @@ exports.default = () => {
64
85
  init(config, instance) {
65
86
  return {
66
87
  expandButtonDecorations: buildExpandButtonDecorations(instance.doc),
88
+ ariaLabelsDecorations: buildAriaLabelsDecorations(instance.doc),
67
89
  expandedElementDecorations: [],
68
90
  expandedElementIDs: new Set(),
69
91
  };
@@ -71,11 +93,13 @@ exports.default = () => {
71
93
  apply(tr, value, oldState, newState) {
72
94
  const s = {
73
95
  expandButtonDecorations: value.expandButtonDecorations,
96
+ ariaLabelsDecorations: value.ariaLabelsDecorations,
74
97
  expandedElementDecorations: value.expandedElementDecorations,
75
98
  expandedElementIDs: new Set(value.expandedElementIDs),
76
99
  };
77
100
  if (tr.docChanged) {
78
101
  s.expandButtonDecorations = buildExpandButtonDecorations(newState.doc);
102
+ s.ariaLabelsDecorations = buildAriaLabelsDecorations(newState.doc);
79
103
  }
80
104
  let expandedElementIDsChanged = false;
81
105
  const meta = tr.getMeta(exports.accessibilityElementKey);
@@ -115,6 +139,7 @@ exports.default = () => {
115
139
  if (pluginState) {
116
140
  return prosemirror_view_1.DecorationSet.create(state.doc, [
117
141
  ...pluginState.expandButtonDecorations,
142
+ ...pluginState.ariaLabelsDecorations,
118
143
  ...pluginState.expandedElementDecorations,
119
144
  ]);
120
145
  }
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MATHJAX_VERSION = exports.VERSION = void 0;
4
- exports.VERSION = '3.20.0';
4
+ exports.VERSION = '3.20.2';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -13,7 +13,8 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { Avatar, CorrespondingAuthorIcon, CrclTickAnimation, DeleteIcon, DraggableIcon, withNavigableListItem, } from '@manuscripts/style-guide';
16
+ import { CorrespondingAuthorIcon, CrclTickAnimation, DeleteIcon, DraggableIcon, withNavigableListItem, } from '@manuscripts/style-guide';
17
+ import { Avatar } from '@manuscripts/style-guide/mui';
17
18
  import React, { useRef, useState } from 'react';
18
19
  import { useDrag, useDrop } from 'react-dnd';
19
20
  import styled from 'styled-components';
@@ -42,6 +42,27 @@ const buildExpandButtonDecorations = (doc) => {
42
42
  });
43
43
  return decorations;
44
44
  };
45
+ const ariaLabels = new Map([
46
+ [
47
+ schema.nodes.headshot_element,
48
+ { caption: 'Headshot Summary', caption_title: 'Headshot Name' },
49
+ ],
50
+ ]);
51
+ const isCaptionNode = (node) => node.type === schema.nodes.caption_title || node.type === schema.nodes.caption;
52
+ const buildAriaLabelsDecorations = (doc) => {
53
+ const decorations = [];
54
+ doc.descendants((node, pos, parent) => {
55
+ if (isCaptionNode(node) && parent && ariaLabels.has(parent.type)) {
56
+ const arialLabel = ariaLabels.get(parent.type);
57
+ if (arialLabel) {
58
+ decorations.push(Decoration.node(pos, pos + node.nodeSize, {
59
+ 'aria-label': arialLabel[node.type.name],
60
+ }));
61
+ }
62
+ }
63
+ });
64
+ return decorations;
65
+ };
45
66
  const buildExpandedElementsDecorations = (doc, expandedElementIDs, selection) => {
46
67
  const decorations = [];
47
68
  doc.descendants((node, pos) => {
@@ -61,6 +82,7 @@ export default () => {
61
82
  init(config, instance) {
62
83
  return {
63
84
  expandButtonDecorations: buildExpandButtonDecorations(instance.doc),
85
+ ariaLabelsDecorations: buildAriaLabelsDecorations(instance.doc),
64
86
  expandedElementDecorations: [],
65
87
  expandedElementIDs: new Set(),
66
88
  };
@@ -68,11 +90,13 @@ export default () => {
68
90
  apply(tr, value, oldState, newState) {
69
91
  const s = {
70
92
  expandButtonDecorations: value.expandButtonDecorations,
93
+ ariaLabelsDecorations: value.ariaLabelsDecorations,
71
94
  expandedElementDecorations: value.expandedElementDecorations,
72
95
  expandedElementIDs: new Set(value.expandedElementIDs),
73
96
  };
74
97
  if (tr.docChanged) {
75
98
  s.expandButtonDecorations = buildExpandButtonDecorations(newState.doc);
99
+ s.ariaLabelsDecorations = buildAriaLabelsDecorations(newState.doc);
76
100
  }
77
101
  let expandedElementIDsChanged = false;
78
102
  const meta = tr.getMeta(accessibilityElementKey);
@@ -112,6 +136,7 @@ export default () => {
112
136
  if (pluginState) {
113
137
  return DecorationSet.create(state.doc, [
114
138
  ...pluginState.expandButtonDecorations,
139
+ ...pluginState.ariaLabelsDecorations,
115
140
  ...pluginState.expandedElementDecorations,
116
141
  ]);
117
142
  }
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.20.0';
1
+ export const VERSION = '3.20.2';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -3,6 +3,7 @@ import { Plugin, PluginKey } from 'prosemirror-state';
3
3
  import { Decoration } from 'prosemirror-view';
4
4
  export interface PluginState {
5
5
  expandButtonDecorations: Decoration[];
6
+ ariaLabelsDecorations: Decoration[];
6
7
  expandedElementDecorations: Decoration[];
7
8
  expandedElementIDs: Set<string>;
8
9
  }
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.20.0";
1
+ export declare const VERSION = "3.20.2";
2
2
  export declare const MATHJAX_VERSION = "3.2.2";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/body-editor",
3
3
  "description": "Prosemirror components for editing and viewing manuscripts",
4
- "version": "3.20.0",
4
+ "version": "3.20.2",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -41,7 +41,7 @@
41
41
  "@citation-js/plugin-pubmed": "0.3.0",
42
42
  "@citation-js/plugin-ris": "0.7.18",
43
43
  "@iarna/word-count": "1.1.2",
44
- "@manuscripts/style-guide": "3.8.2",
44
+ "@manuscripts/style-guide": "3.8.3",
45
45
  "@manuscripts/track-changes-plugin": "2.4.0",
46
46
  "@manuscripts/transform": "4.6.0",
47
47
  "@popperjs/core": "2.11.8",
@@ -15,13 +15,13 @@
15
15
  */
16
16
 
17
17
  import {
18
- Avatar,
19
18
  CorrespondingAuthorIcon,
20
19
  CrclTickAnimation,
21
20
  DeleteIcon,
22
21
  DraggableIcon,
23
22
  withNavigableListItem,
24
23
  } from '@manuscripts/style-guide'
24
+ import { Avatar } from '@manuscripts/style-guide/mui'
25
25
  import React, { useRef, useState } from 'react'
26
26
  import { useDrag, useDrop } from 'react-dnd'
27
27
  import styled from 'styled-components'
@@ -15,6 +15,7 @@
15
15
  */
16
16
  import {
17
17
  ManuscriptNode,
18
+ ManuscriptNodeType,
18
19
  ManuscriptTransaction,
19
20
  schema,
20
21
  } from '@manuscripts/transform'
@@ -25,6 +26,7 @@ import { createToggleButton } from '../lib/utils'
25
26
 
26
27
  export interface PluginState {
27
28
  expandButtonDecorations: Decoration[]
29
+ ariaLabelsDecorations: Decoration[]
28
30
  expandedElementDecorations: Decoration[]
29
31
  expandedElementIDs: Set<string>
30
32
  }
@@ -101,6 +103,33 @@ const buildExpandButtonDecorations = (doc: ManuscriptNode) => {
101
103
  return decorations
102
104
  }
103
105
 
106
+ const ariaLabels: Map<ManuscriptNodeType, Record<string, string>> = new Map([
107
+ [
108
+ schema.nodes.headshot_element,
109
+ { caption: 'Headshot Summary', caption_title: 'Headshot Name' },
110
+ ],
111
+ ])
112
+
113
+ const isCaptionNode = (node: ManuscriptNode) =>
114
+ node.type === schema.nodes.caption_title || node.type === schema.nodes.caption
115
+
116
+ const buildAriaLabelsDecorations = (doc: ManuscriptNode) => {
117
+ const decorations: Decoration[] = []
118
+ doc.descendants((node, pos, parent) => {
119
+ if (isCaptionNode(node) && parent && ariaLabels.has(parent.type)) {
120
+ const arialLabel = ariaLabels.get(parent.type)
121
+ if (arialLabel) {
122
+ decorations.push(
123
+ Decoration.node(pos, pos + node.nodeSize, {
124
+ 'aria-label': arialLabel[node.type.name],
125
+ })
126
+ )
127
+ }
128
+ }
129
+ })
130
+ return decorations
131
+ }
132
+
104
133
  const buildExpandedElementsDecorations = (
105
134
  doc: ManuscriptNode,
106
135
  expandedElementIDs: Set<string>,
@@ -130,6 +159,7 @@ export default () => {
130
159
  init(config, instance) {
131
160
  return {
132
161
  expandButtonDecorations: buildExpandButtonDecorations(instance.doc),
162
+ ariaLabelsDecorations: buildAriaLabelsDecorations(instance.doc),
133
163
  expandedElementDecorations: [],
134
164
  expandedElementIDs: new Set(),
135
165
  }
@@ -137,12 +167,14 @@ export default () => {
137
167
  apply(tr, value, oldState, newState) {
138
168
  const s = {
139
169
  expandButtonDecorations: value.expandButtonDecorations,
170
+ ariaLabelsDecorations: value.ariaLabelsDecorations,
140
171
  expandedElementDecorations: value.expandedElementDecorations,
141
172
  expandedElementIDs: new Set(value.expandedElementIDs),
142
173
  }
143
174
 
144
175
  if (tr.docChanged) {
145
176
  s.expandButtonDecorations = buildExpandButtonDecorations(newState.doc)
177
+ s.ariaLabelsDecorations = buildAriaLabelsDecorations(newState.doc)
146
178
  }
147
179
 
148
180
  let expandedElementIDsChanged = false
@@ -191,6 +223,7 @@ export default () => {
191
223
  if (pluginState) {
192
224
  return DecorationSet.create(state.doc, [
193
225
  ...pluginState.expandButtonDecorations,
226
+ ...pluginState.ariaLabelsDecorations,
194
227
  ...pluginState.expandedElementDecorations,
195
228
  ])
196
229
  }
package/src/versions.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  //THIS FILE WAS GENERATED BY versions.mjs
2
- export const VERSION = '3.20.0';
2
+ export const VERSION = '3.20.2';
3
3
  export const MATHJAX_VERSION = '3.2.2';