@atlaskit/editor-plugin-expand 20.0.1 → 20.0.3

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.
@@ -7,6 +7,7 @@ import React from 'react';
7
7
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
8
8
  import { v4 as uuid } from 'uuid';
9
9
  import { keyName } from 'w3c-keyname';
10
+ import { BLOCK_CONTROLS_DRAG_HANDLE } from '@atlaskit/editor-common/block-controls/surface-keys';
10
11
  import { GapCursorSelection, RelativeSelectionPos, Side } from '@atlaskit/editor-common/selection';
11
12
  import { expandClassNames } from '@atlaskit/editor-common/styles';
12
13
  import { expandMessages } from '@atlaskit/editor-common/ui';
@@ -25,7 +26,14 @@ import { ExpandIconButton } from '../ui/ExpandIconButton';
25
26
  function buildExpandClassName(type, expanded) {
26
27
  return "".concat(expandClassNames.prefix, " ").concat(expandClassNames.type(type), " ").concat(expanded ? expandClassNames.expanded : '');
27
28
  }
29
+ export function getExpandBodyAriaLabel(title, intl) {
30
+ var safeTitle = title.trim() || (intl === null || intl === void 0 ? void 0 : intl.formatMessage(expandMessages.expandBodyAriaLabelUntitled)) || expandMessages.expandBodyAriaLabelUntitled.defaultMessage;
31
+ return (intl === null || intl === void 0 ? void 0 : intl.formatMessage(expandMessages.expandBodyAriaLabel, {
32
+ title: safeTitle
33
+ })) || expandMessages.expandBodyAriaLabel.defaultMessage.replace('{title}', safeTitle);
34
+ }
28
35
  var toDOM = function toDOM(node, __livePage, intl, titleReadOnly, contentEditable) {
36
+ var _node$attrs$title, _intl$formatMessage;
29
37
  return ['div', _objectSpread({
30
38
  // prettier-ignore
31
39
  'class': buildExpandClassName(node.type.name, __livePage ? !node.attrs.__expanded : node.attrs.__expanded),
@@ -57,14 +65,19 @@ var toDOM = function toDOM(node, __livePage, intl, titleReadOnly, contentEditabl
57
65
  placeholder: intl && intl.formatMessage(expandMessages.expandPlaceholderText) || expandMessages.expandPlaceholderText.defaultMessage,
58
66
  type: 'text',
59
67
  readonly: titleReadOnly ? 'true' : undefined
60
- }]]], ['div', {
68
+ }]]], [isExperimentEnabled('platform_editor_expand_content_a11y_2') ? 'section' : 'div', _objectSpread(_objectSpread({
61
69
  // prettier-ignore
62
70
  class: "".concat(expandClassNames.content, " ").concat((__livePage ? !node.attrs.__expanded : node.attrs.__expanded) ? '' : expandClassNames.contentCollapsed),
63
- contenteditable: contentEditable !== undefined ? contentEditable ? 'true' : 'false' : undefined,
71
+ contenteditable: contentEditable !== undefined ? contentEditable ? 'true' : 'false' : undefined
72
+ }, !isExperimentEnabled('platform_editor_expand_content_a11y_2') && {
64
73
  role: 'textbox',
65
74
  'aria-multiline': 'true',
66
- 'aria-label': intl && intl.formatMessage(expandMessages.expandBodyAriaLabel) || expandMessages.expandBodyAriaLabel.defaultMessage
67
- }, 0]];
75
+ 'aria-label': intl && intl.formatMessage(expandMessages.expandBodyAriaLabelOriginal) || expandMessages.expandBodyAriaLabelOriginal.defaultMessage
76
+ }), isExperimentEnabled('platform_editor_expand_content_a11y_2') && {
77
+ 'aria-label': getExpandBodyAriaLabel((_node$attrs$title = node.attrs.title) !== null && _node$attrs$title !== void 0 ? _node$attrs$title : '', intl),
78
+ 'aria-description': (intl === null || intl === void 0 ? void 0 : intl.formatMessage(expandMessages.expandBodyAriaDescription)) || expandMessages.expandBodyAriaDescription.defaultMessage,
79
+ 'aria-roledescription': (_intl$formatMessage = intl === null || intl === void 0 ? void 0 : intl.formatMessage(expandMessages.expandBodyRoleDescription)) !== null && _intl$formatMessage !== void 0 ? _intl$formatMessage : expandMessages.expandBodyRoleDescription.defaultMessage
80
+ }), 0]];
68
81
  };
69
82
  export var ExpandNodeView = /*#__PURE__*/function () {
70
83
  function ExpandNodeView(_node, view, getPos, getIntl, isMobile, selectNearNode, api, nodeViewPortalProviderAPI) {
@@ -195,21 +208,30 @@ export var ExpandNodeView = /*#__PURE__*/function () {
195
208
  (_this$api3 = _this.api) === null || _this$api3 === void 0 || _this$api3.core.actions.execute(function (_ref) {
196
209
  var tr = _ref.tr;
197
210
  tr.setSelection(NodeSelection.create(state.doc, pos));
198
- // Show the drag handle on the selected expand node
211
+ if (isExperimentEnabled('platform_editor_block_control_migration')) {
212
+ var _this$api4;
213
+ var command = (_this$api4 = _this.api) === null || _this$api4 === void 0 || (_this$api4 = _this$api4.blockControls) === null || _this$api4 === void 0 ? void 0 : _this$api4.commands.showControlAtPosition(pos, BLOCK_CONTROLS_DRAG_HANDLE, {
214
+ isFocused: true
215
+ });
216
+ if (command) {
217
+ return command({
218
+ tr: tr
219
+ });
220
+ }
221
+ return null;
222
+ }
199
223
  var node = state.doc.nodeAt(pos);
200
224
  if (node) {
201
- // Find the anchor name from the DOM
202
225
  var dom = _this.view.nodeDOM(pos);
203
226
  if (dom instanceof HTMLElement) {
204
227
  var anchorName = dom.getAttribute('data-node-anchor');
205
- // Only proceed if we found a valid anchor name
206
228
  if (anchorName) {
207
- var _this$api4;
208
- var command = (_this$api4 = _this.api) === null || _this$api4 === void 0 || (_this$api4 = _this$api4.blockControls) === null || _this$api4 === void 0 ? void 0 : _this$api4.commands.showDragHandleAt(pos, anchorName, node.type.name, {
229
+ var _this$api5;
230
+ var _command = (_this$api5 = _this.api) === null || _this$api5 === void 0 || (_this$api5 = _this$api5.blockControls) === null || _this$api5 === void 0 ? void 0 : _this$api5.commands.showDragHandleAt(pos, anchorName, node.type.name, {
209
231
  isFocused: true
210
232
  });
211
- if (command) {
212
- return command({
233
+ if (_command) {
234
+ return _command({
213
235
  tr: tr
214
236
  });
215
237
  }
@@ -287,8 +309,8 @@ export var ExpandNodeView = /*#__PURE__*/function () {
287
309
  var state = _this.view.state;
288
310
  var expandNode = _this.node;
289
311
  if (expandNode && isEmptyNode(state.schema)(expandNode)) {
290
- var _this$api5;
291
- deleteExpandAtPos((_this$api5 = _this.api) === null || _this$api5 === void 0 || (_this$api5 = _this$api5.analytics) === null || _this$api5 === void 0 ? void 0 : _this$api5.actions)(pos, expandNode)(state, _this.view.dispatch);
312
+ var _this$api6;
313
+ deleteExpandAtPos((_this$api6 = _this.api) === null || _this$api6 === void 0 || (_this$api6 = _this$api6.analytics) === null || _this$api6 === void 0 ? void 0 : _this$api6.actions)(pos, expandNode)(state, _this.view.dispatch);
292
314
  }
293
315
  });
294
316
  _defineProperty(this, "toggleExpand", function () {
@@ -297,12 +319,12 @@ export var ExpandNodeView = /*#__PURE__*/function () {
297
319
  return;
298
320
  }
299
321
  if (_this.allowInteractiveExpand) {
300
- var _this$api6;
322
+ var _this$api7;
301
323
  var _this$view4 = _this.view,
302
324
  state = _this$view4.state,
303
325
  dispatch = _this$view4.dispatch;
304
326
  toggleExpandExpanded({
305
- editorAnalyticsAPI: (_this$api6 = _this.api) === null || _this$api6 === void 0 || (_this$api6 = _this$api6.analytics) === null || _this$api6 === void 0 ? void 0 : _this$api6.actions,
327
+ editorAnalyticsAPI: (_this$api7 = _this.api) === null || _this$api7 === void 0 || (_this$api7 = _this$api7.analytics) === null || _this$api7 === void 0 ? void 0 : _this$api7.actions,
306
328
  pos: pos,
307
329
  nodeType: _this.node.type,
308
330
  __livePage: _this.__livePage
@@ -454,13 +476,13 @@ export var ExpandNodeView = /*#__PURE__*/function () {
454
476
  selectionStart = _this$input6.selectionStart,
455
477
  selectionEnd = _this$input6.selectionEnd;
456
478
  if (selectionStart === selectionEnd && selectionStart === 0) {
457
- var _this$api7;
479
+ var _this$api8;
458
480
  event.preventDefault();
459
481
  var _this$view0 = _this.view,
460
482
  state = _this$view0.state,
461
483
  dispatch = _this$view0.dispatch;
462
484
  _this.view.focus();
463
- var selectionSharedState = ((_this$api7 = _this.api) === null || _this$api7 === void 0 || (_this$api7 = _this$api7.selection) === null || _this$api7 === void 0 ? void 0 : _this$api7.sharedState.currentState()) || {};
485
+ var selectionSharedState = ((_this$api8 = _this.api) === null || _this$api8 === void 0 || (_this$api8 = _this$api8.selection) === null || _this$api8 === void 0 ? void 0 : _this$api8.sharedState.currentState()) || {};
464
486
  // selectionRelativeToNode is undefined when user clicked to select node, then hit left to get focus in title
465
487
  // This is a special case where we want to bypass node selection and jump straight to gap cursor
466
488
  if ((selectionSharedState === null || selectionSharedState === void 0 ? void 0 : selectionSharedState.selectionRelativeToNode) === undefined) {
@@ -547,7 +569,7 @@ export var ExpandNodeView = /*#__PURE__*/function () {
547
569
  return _createClass(ExpandNodeView, [{
548
570
  key: "initHandlers",
549
571
  value: function initHandlers() {
550
- var _this$api8,
572
+ var _this$api9,
551
573
  _this2 = this;
552
574
  if (this.dom) {
553
575
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
@@ -573,7 +595,7 @@ export var ExpandNodeView = /*#__PURE__*/function () {
573
595
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
574
596
  this.icon.addEventListener('keydown', this.handleIconKeyDown);
575
597
  }
576
- if ((_this$api8 = this.api) !== null && _this$api8 !== void 0 && _this$api8.editorDisabled) {
598
+ if ((_this$api9 = this.api) !== null && _this$api9 !== void 0 && _this$api9.editorDisabled) {
577
599
  this.cleanUpEditorDisabledOnChange = this.api.editorDisabled.sharedState.onChange(function (sharedState) {
578
600
  var editorDisabled = sharedState.nextSharedState.editorDisabled;
579
601
  if (_this2.input) {
@@ -643,13 +665,13 @@ export var ExpandNodeView = /*#__PURE__*/function () {
643
665
  }, {
644
666
  key: "isLimitedModeEnabled",
645
667
  value: function isLimitedModeEnabled() {
646
- var _this$api9;
668
+ var _this$api0;
647
669
  // Read from `this.view.state` via the exposed plugin key rather than the shared state's
648
670
  // `enabled`, which reads a stale `false` during initial EditorView construction (the injection
649
671
  // API's editor state isn't wired up yet).
650
672
  //
651
673
  // Reads the plugin's derived `enabled`, so this covers every reason limited mode can be on.
652
- return Boolean((_this$api9 = this.api) === null || _this$api9 === void 0 || (_this$api9 = _this$api9.limitedMode) === null || _this$api9 === void 0 || (_this$api9 = _this$api9.sharedState.currentState()) === null || _this$api9 === void 0 || (_this$api9 = _this$api9.limitedModePluginKey) === null || _this$api9 === void 0 || (_this$api9 = _this$api9.getState(this.view.state)) === null || _this$api9 === void 0 ? void 0 : _this$api9.enabled);
674
+ return Boolean((_this$api0 = this.api) === null || _this$api0 === void 0 || (_this$api0 = _this$api0.limitedMode) === null || _this$api0 === void 0 || (_this$api0 = _this$api0.sharedState.currentState()) === null || _this$api0 === void 0 || (_this$api0 = _this$api0.limitedModePluginKey) === null || _this$api0 === void 0 || (_this$api0 = _this$api0.getState(this.view.state)) === null || _this$api0 === void 0 ? void 0 : _this$api0.enabled);
653
675
  }
654
676
  }, {
655
677
  key: "stopEvent",
@@ -711,6 +733,12 @@ export var ExpandNodeView = /*#__PURE__*/function () {
711
733
  _this4.input.value = _this4.node.attrs.title;
712
734
  }
713
735
  });
736
+ if (isExperimentEnabled('platform_editor_expand_content_a11y_2')) {
737
+ if (this.node.attrs.title !== node.attrs.title && this.content) {
738
+ var _node$attrs$title2;
739
+ this.content.setAttribute('aria-label', getExpandBodyAriaLabel((_node$attrs$title2 = node.attrs.title) !== null && _node$attrs$title2 !== void 0 ? _node$attrs$title2 : '', this.intl));
740
+ }
741
+ }
714
742
  this.node = node;
715
743
  return true;
716
744
  }
@@ -5,11 +5,11 @@ import React from 'react';
5
5
  import { expandWithNestedExpand } from '@atlaskit/adf-schema/expand';
6
6
  import { nestedExpand } from '@atlaskit/adf-schema/nested-expand';
7
7
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
8
+ import { IconExpand } from '@atlaskit/editor-common/assets';
8
9
  import { TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM, TRANSFORM_STRUCTURE_MENU_SECTION, TRANSFORM_STRUCTURE_MENU_SECTION_RANK } from '@atlaskit/editor-common/block-menu';
9
10
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
10
- import { IconExpand } from '@atlaskit/editor-common/assets';
11
- import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
12
11
  import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
12
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
13
13
  import { toggleExpandRange } from '../editor-commands/toggleExpandRange';
14
14
  import { createExpandBlockMenuItem } from '../ui/ExpandBlockMenuItem';
15
15
  import { getExpandQuickInsertComponents } from '../ui/quick-insert/getExpandQuickInsertComponents';
@@ -5,6 +5,7 @@ import React from 'react';
5
5
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
6
6
  import { v4 as uuid } from 'uuid';
7
7
  import { keyName } from 'w3c-keyname';
8
+ import { BLOCK_CONTROLS_DRAG_HANDLE } from '@atlaskit/editor-common/block-controls/surface-keys';
8
9
  import { expandedState, isExpandCollapsed } from '@atlaskit/editor-common/expand';
9
10
  import { GapCursorSelection, RelativeSelectionPos, Side } from '@atlaskit/editor-common/selection';
10
11
  import { expandClassNames } from '@atlaskit/editor-common/styles';
@@ -19,14 +20,14 @@ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
19
20
  import { renderExpandButton } from '../../ui/renderExpandButton';
20
21
  import { deleteExpand, setSelectionInsideExpand, toggleExpandExpanded, updateExpandTitle } from '../commands';
21
22
  import { ExpandButton } from '../ui/ExpandButton';
22
- import { buildExpandClassName, toDOM } from '../ui/NodeView';
23
+ import { buildExpandClassName, getExpandBodyAriaLabel, toDOM } from '../ui/NodeView';
23
24
  import { findReplaceExpandDecorations } from '../utils';
24
25
  export var ExpandNodeView = /*#__PURE__*/function () {
25
26
  function ExpandNodeView(_node, view, getPos, getIntl, isMobile, selectNearNode, api, nodeViewPortalProviderAPI) {
26
27
  var _this = this,
27
28
  _expandedState$get,
28
29
  _api$editorDisabled,
29
- _this$api8;
30
+ _this$api9;
30
31
  var allowInteractiveExpand = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : true;
31
32
  var __livePage = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : false;
32
33
  var cleanUpEditorDisabledOnChange = arguments.length > 10 ? arguments[10] : undefined;
@@ -152,21 +153,30 @@ export var ExpandNodeView = /*#__PURE__*/function () {
152
153
  (_this$api3 = _this.api) === null || _this$api3 === void 0 || _this$api3.core.actions.execute(function (_ref) {
153
154
  var tr = _ref.tr;
154
155
  tr.setSelection(NodeSelection.create(state.doc, pos));
155
- // Show the drag handle on the selected expand node
156
+ if (isExperimentEnabled('platform_editor_block_control_migration')) {
157
+ var _this$api4;
158
+ var command = (_this$api4 = _this.api) === null || _this$api4 === void 0 || (_this$api4 = _this$api4.blockControls) === null || _this$api4 === void 0 ? void 0 : _this$api4.commands.showControlAtPosition(pos, BLOCK_CONTROLS_DRAG_HANDLE, {
159
+ isFocused: true
160
+ });
161
+ if (command) {
162
+ return command({
163
+ tr: tr
164
+ });
165
+ }
166
+ return null;
167
+ }
156
168
  var node = state.doc.nodeAt(pos);
157
169
  if (node) {
158
- // Find the anchor name from the DOM
159
170
  var dom = _this.view.nodeDOM(pos);
160
171
  if (dom instanceof HTMLElement) {
161
172
  var anchorName = expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? dom.getAttribute('data-node-anchor') : dom.getAttribute('data-drag-handler-anchor-name');
162
- // Only proceed if we found a valid anchor name
163
173
  if (anchorName) {
164
- var _this$api4;
165
- var command = (_this$api4 = _this.api) === null || _this$api4 === void 0 || (_this$api4 = _this$api4.blockControls) === null || _this$api4 === void 0 ? void 0 : _this$api4.commands.showDragHandleAt(pos, anchorName, node.type.name, {
174
+ var _this$api5;
175
+ var _command = (_this$api5 = _this.api) === null || _this$api5 === void 0 || (_this$api5 = _this$api5.blockControls) === null || _this$api5 === void 0 ? void 0 : _this$api5.commands.showDragHandleAt(pos, anchorName, node.type.name, {
166
176
  isFocused: true
167
177
  });
168
- if (command) {
169
- return command({
178
+ if (_command) {
179
+ return _command({
170
180
  tr: tr
171
181
  });
172
182
  }
@@ -239,8 +249,8 @@ export var ExpandNodeView = /*#__PURE__*/function () {
239
249
  return;
240
250
  }
241
251
  if (expandNode && isEmptyNode(state.schema)(expandNode)) {
242
- var _this$api5;
243
- deleteExpand((_this$api5 = _this.api) === null || _this$api5 === void 0 || (_this$api5 = _this$api5.analytics) === null || _this$api5 === void 0 ? void 0 : _this$api5.actions)(state, _this.view.dispatch);
252
+ var _this$api6;
253
+ deleteExpand((_this$api6 = _this.api) === null || _this$api6 === void 0 || (_this$api6 = _this$api6.analytics) === null || _this$api6 === void 0 ? void 0 : _this$api6.actions)(state, _this.view.dispatch);
244
254
  }
245
255
  });
246
256
  _defineProperty(this, "toggleExpand", function () {
@@ -249,12 +259,12 @@ export var ExpandNodeView = /*#__PURE__*/function () {
249
259
  return;
250
260
  }
251
261
  if (_this.allowInteractiveExpand) {
252
- var _this$api6;
262
+ var _this$api7;
253
263
  var _this$view3 = _this.view,
254
264
  state = _this$view3.state,
255
265
  dispatch = _this$view3.dispatch;
256
266
  toggleExpandExpanded({
257
- editorAnalyticsAPI: (_this$api6 = _this.api) === null || _this$api6 === void 0 || (_this$api6 = _this$api6.analytics) === null || _this$api6 === void 0 ? void 0 : _this$api6.actions,
267
+ editorAnalyticsAPI: (_this$api7 = _this.api) === null || _this$api7 === void 0 || (_this$api7 = _this$api7.analytics) === null || _this$api7 === void 0 ? void 0 : _this$api7.actions,
258
268
  pos: pos,
259
269
  node: _this.node
260
270
  })(state, dispatch);
@@ -408,13 +418,13 @@ export var ExpandNodeView = /*#__PURE__*/function () {
408
418
  selectionStart = _this$input6.selectionStart,
409
419
  selectionEnd = _this$input6.selectionEnd;
410
420
  if (selectionStart === selectionEnd && selectionStart === 0) {
411
- var _this$api7;
421
+ var _this$api8;
412
422
  event.preventDefault();
413
423
  var _this$view9 = _this.view,
414
424
  state = _this$view9.state,
415
425
  dispatch = _this$view9.dispatch;
416
426
  _this.view.focus();
417
- var selectionSharedState = ((_this$api7 = _this.api) === null || _this$api7 === void 0 || (_this$api7 = _this$api7.selection) === null || _this$api7 === void 0 ? void 0 : _this$api7.sharedState.currentState()) || {};
427
+ var selectionSharedState = ((_this$api8 = _this.api) === null || _this$api8 === void 0 || (_this$api8 = _this$api8.selection) === null || _this$api8 === void 0 ? void 0 : _this$api8.sharedState.currentState()) || {};
418
428
  // selectionRelativeToNode is undefined when user clicked to select node, then hit left to get focus in title
419
429
  // This is a special case where we want to bypass node selection and jump straight to gap cursor
420
430
  if ((selectionSharedState === null || selectionSharedState === void 0 ? void 0 : selectionSharedState.selectionRelativeToNode) === undefined) {
@@ -530,7 +540,7 @@ export var ExpandNodeView = /*#__PURE__*/function () {
530
540
  // Prevent ProseMirror from getting a focus event (causes weird selection issues).
531
541
  this.titleContainer.addEventListener('focus', this.handleFocus);
532
542
  this.icon.addEventListener('keydown', this.handleIconKeyDown);
533
- if ((_this$api8 = this.api) !== null && _this$api8 !== void 0 && _this$api8.editorDisabled) {
543
+ if ((_this$api9 = this.api) !== null && _this$api9 !== void 0 && _this$api9.editorDisabled) {
534
544
  if (isExperimentEnabled('cc_editor_limited_mode_perf_improvements')) {
535
545
  if (this.content) {
536
546
  this.content.setAttribute('contenteditable', this.getContentEditable(this.node) ? 'true' : 'false');
@@ -602,6 +612,12 @@ export var ExpandNodeView = /*#__PURE__*/function () {
602
612
  }
603
613
  });
604
614
 
615
+ // Sync up the aria-label with the current expand title.
616
+ if (isExperimentEnabled('platform_editor_expand_content_a11y_2') && this.node.attrs.title !== node.attrs.title && this.content) {
617
+ var _node$attrs$title;
618
+ this.content.setAttribute('aria-label', getExpandBodyAriaLabel((_node$attrs$title = node.attrs.title) !== null && _node$attrs$title !== void 0 ? _node$attrs$title : '', this.intl));
619
+ }
620
+
605
621
  // This checks if the node has been replaced with a different version
606
622
  // and updates the state of the new node to match the old one
607
623
  // Eg. typing in a node changes it to a new node so it must be updated
@@ -658,13 +674,13 @@ export var ExpandNodeView = /*#__PURE__*/function () {
658
674
  }, {
659
675
  key: "isLimitedModeEnabled",
660
676
  value: function isLimitedModeEnabled() {
661
- var _this$api9;
677
+ var _this$api0;
662
678
  // Read from `this.view.state` via the exposed plugin key rather than the shared state's
663
679
  // `enabled`, which reads a stale `false` during initial EditorView construction (the injection
664
680
  // API's editor state isn't wired up yet).
665
681
  //
666
682
  // Reads the plugin's derived `enabled`, so this covers every reason limited mode can be on.
667
- return Boolean((_this$api9 = this.api) === null || _this$api9 === void 0 || (_this$api9 = _this$api9.limitedMode) === null || _this$api9 === void 0 || (_this$api9 = _this$api9.sharedState.currentState()) === null || _this$api9 === void 0 || (_this$api9 = _this$api9.limitedModePluginKey) === null || _this$api9 === void 0 || (_this$api9 = _this$api9.getState(this.view.state)) === null || _this$api9 === void 0 ? void 0 : _this$api9.enabled);
683
+ return Boolean((_this$api0 = this.api) === null || _this$api0 === void 0 || (_this$api0 = _this$api0.limitedMode) === null || _this$api0 === void 0 || (_this$api0 = _this$api0.sharedState.currentState()) === null || _this$api0 === void 0 || (_this$api0 = _this$api0.limitedModePluginKey) === null || _this$api0 === void 0 || (_this$api0 = _this$api0.getState(this.view.state)) === null || _this$api0 === void 0 ? void 0 : _this$api0.enabled);
668
684
  }
669
685
  }, {
670
686
  key: "updateDisplayStyle",
@@ -5,9 +5,9 @@ import React from 'react';
5
5
  import { expandWithNestedExpand, expandWithNestedExpandLocalId } from '@atlaskit/adf-schema/expand';
6
6
  import { nestedExpand, nestedExpandWithLocalId } from '@atlaskit/adf-schema/nested-expand';
7
7
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
8
+ import { IconExpand } from '@atlaskit/editor-common/assets';
8
9
  import { TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM, TRANSFORM_STRUCTURE_MENU_SECTION, TRANSFORM_STRUCTURE_MENU_SECTION_RANK } from '@atlaskit/editor-common/block-menu';
9
10
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
10
- import { IconExpand } from '@atlaskit/editor-common/assets';
11
11
  import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
12
12
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
13
13
  import { fg } from '@atlaskit/platform-feature-flags/fg';
@@ -4,12 +4,19 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  import { expandedState } from '@atlaskit/editor-common/expand';
5
5
  import { expandClassNames } from '@atlaskit/editor-common/styles';
6
6
  import { expandMessages } from '@atlaskit/editor-common/ui';
7
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
7
8
  import { fg } from '@atlaskit/platform-feature-flags/fg';
8
9
  export var buildExpandClassName = function buildExpandClassName(type, expanded) {
9
10
  return "".concat(expandClassNames.prefix, " ").concat(expandClassNames.type(type), " ").concat(expanded ? expandClassNames.expanded : '');
10
11
  };
12
+ export var getExpandBodyAriaLabel = function getExpandBodyAriaLabel(title, intl) {
13
+ var safeTitle = title.trim() || (intl === null || intl === void 0 ? void 0 : intl.formatMessage(expandMessages.expandBodyAriaLabelUntitled)) || expandMessages.expandBodyAriaLabelUntitled.defaultMessage;
14
+ return (intl === null || intl === void 0 ? void 0 : intl.formatMessage(expandMessages.expandBodyAriaLabel, {
15
+ title: safeTitle
16
+ })) || expandMessages.expandBodyAriaLabel.defaultMessage.replace('{title}', safeTitle);
17
+ };
11
18
  export var toDOM = function toDOM(node, __livePage, intl, titleReadOnly, contentEditable) {
12
- var _expandedState$get;
19
+ var _expandedState$get, _node$attrs$title, _intl$formatMessage;
13
20
  return ['div', _objectSpread({
14
21
  // prettier-ignore
15
22
  'class': buildExpandClassName(node.type.name, (_expandedState$get = expandedState.get(node)) !== null && _expandedState$get !== void 0 ? _expandedState$get : false),
@@ -41,12 +48,17 @@ export var toDOM = function toDOM(node, __livePage, intl, titleReadOnly, content
41
48
  placeholder: intl && typeof intl.formatMessage === 'function' && intl.formatMessage(expandMessages.expandPlaceholderText) || expandMessages.expandPlaceholderText.defaultMessage,
42
49
  type: 'text',
43
50
  readonly: titleReadOnly ? 'true' : undefined
44
- }]]], ['div', {
51
+ }]]], [isExperimentEnabled('platform_editor_expand_content_a11y_2') ? 'section' : 'div', _objectSpread(_objectSpread({
45
52
  // prettier-ignore
46
53
  class: "".concat(expandClassNames.content, " ").concat(expandedState.get(node) ? '' : expandClassNames.contentCollapsed),
47
- contenteditable: contentEditable !== undefined ? contentEditable ? 'true' : 'false' : undefined,
54
+ contenteditable: contentEditable !== undefined ? contentEditable ? 'true' : 'false' : undefined
55
+ }, !isExperimentEnabled('platform_editor_expand_content_a11y_2') && {
48
56
  role: 'textbox',
49
57
  'aria-multiline': 'true',
50
- 'aria-label': intl && intl.formatMessage(expandMessages.expandBodyAriaLabel) || expandMessages.expandBodyAriaLabel.defaultMessage
51
- }, 0]];
58
+ 'aria-label': intl && intl.formatMessage(expandMessages.expandBodyAriaLabelOriginal) || expandMessages.expandBodyAriaLabelOriginal.defaultMessage
59
+ }), isExperimentEnabled('platform_editor_expand_content_a11y_2') && {
60
+ 'aria-label': getExpandBodyAriaLabel((_node$attrs$title = node.attrs.title) !== null && _node$attrs$title !== void 0 ? _node$attrs$title : '', intl),
61
+ 'aria-description': (intl === null || intl === void 0 ? void 0 : intl.formatMessage(expandMessages.expandBodyAriaDescription)) || expandMessages.expandBodyAriaDescription.defaultMessage,
62
+ 'aria-roledescription': (_intl$formatMessage = intl === null || intl === void 0 ? void 0 : intl.formatMessage(expandMessages.expandBodyRoleDescription)) !== null && _intl$formatMessage !== void 0 ? _intl$formatMessage : expandMessages.expandBodyRoleDescription.defaultMessage
63
+ }), 0]];
52
64
  };
@@ -5,8 +5,8 @@ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks'
5
5
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
6
6
  import { QuickInsertMenuItem } from '@atlaskit/editor-common/quick-insert/menu-item';
7
7
  import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
8
- import { fg } from '@atlaskit/platform-feature-flags/fg';
9
8
  import ExpandElementIcon from '@atlaskit/icon-lab/core/expand-element';
9
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
10
10
  import { createExpandNode as createLegacyExpandNode } from '../../legacyExpand/commands';
11
11
  import { createExpandNode as createSinglePlayerExpandNode, wrapSelectionAndSetExpandedState } from '../../singlePlayerExpand/commands';
12
12
  export var ExpandQuickInsertMenuItem = function ExpandQuickInsertMenuItem(_ref) {
@@ -5,6 +5,7 @@ import type { ExtractInjectionAPI, getPosHandler, getPosHandlerNode } from '@atl
5
5
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
6
6
  import type { Decoration, EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
7
7
  import type { ExpandPlugin } from '../../types';
8
+ export declare function getExpandBodyAriaLabel(title: string, intl?: IntlShape): string;
8
9
  export declare class ExpandNodeView implements NodeView {
9
10
  private selectNearNode;
10
11
  private __livePage;
@@ -1,4 +1,5 @@
1
1
  import type { IntlShape } from 'react-intl';
2
2
  import type { DOMOutputSpec, Node as PmNode } from '@atlaskit/editor-prosemirror/model';
3
3
  export declare const buildExpandClassName: (type: string, expanded: boolean) => string;
4
+ export declare const getExpandBodyAriaLabel: (title: string, intl?: IntlShape) => string;
4
5
  export declare const toDOM: (node: PmNode, __livePage: boolean, intl?: IntlShape, titleReadOnly?: boolean, contentEditable?: boolean) => DOMOutputSpec;
@@ -9,9 +9,9 @@ import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmo
9
9
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
10
10
  import type { LimitedModePlugin } from '@atlaskit/editor-plugin-limited-mode/limited-mode-plugin-type';
11
11
  import type { LocalIdPlugin } from '@atlaskit/editor-plugin-local-id';
12
- import type { UiControlRegistryPlugin } from '@atlaskit/editor-plugin-ui-control-registry';
13
12
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
14
13
  import type { SelectionMarkerPlugin } from '@atlaskit/editor-plugin-selection-marker';
14
+ import type { UiControlRegistryPlugin } from '@atlaskit/editor-plugin-ui-control-registry';
15
15
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
16
16
  import type { insertExpand, insertExpandWithInputMethod } from './legacyExpand/commands';
17
17
  export interface ExpandPluginState {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-expand",
3
- "version": "20.0.1",
3
+ "version": "20.0.3",
4
4
  "description": "Expand plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -22,9 +22,9 @@
22
22
  "atlaskit:src": "src/index.ts",
23
23
  "dependencies": {
24
24
  "@atlaskit/adf-schema": "^57.5.0",
25
- "@atlaskit/button": "^25.3.0",
25
+ "@atlaskit/button": "^25.4.0",
26
26
  "@atlaskit/editor-plugin-analytics": "^19.0.0",
27
- "@atlaskit/editor-plugin-block-controls": "^20.0.0",
27
+ "@atlaskit/editor-plugin-block-controls": "^20.1.0",
28
28
  "@atlaskit/editor-plugin-block-menu": "^18.0.0",
29
29
  "@atlaskit/editor-plugin-decorations": "^19.0.0",
30
30
  "@atlaskit/editor-plugin-editor-disabled": "^19.0.0",
@@ -36,14 +36,14 @@
36
36
  "@atlaskit/editor-prosemirror": "^9.0.0",
37
37
  "@atlaskit/editor-shared-styles": "^4.3.0",
38
38
  "@atlaskit/editor-tables": "^3.2.0",
39
- "@atlaskit/editor-toolbar": "^2.6.0",
40
- "@atlaskit/editor-ui-control-model": "^2.9.0",
39
+ "@atlaskit/editor-toolbar": "^2.7.0",
40
+ "@atlaskit/editor-ui-control-model": "^2.10.0",
41
41
  "@atlaskit/icon": "^37.7.0",
42
42
  "@atlaskit/icon-lab": "^7.9.0",
43
43
  "@atlaskit/platform-feature-experiments": "^0.3.0",
44
44
  "@atlaskit/platform-feature-flags": "^2.2.0",
45
45
  "@atlaskit/prosemirror-history": "^1.2.0",
46
- "@atlaskit/tmp-editor-statsig": "^200.0.0",
46
+ "@atlaskit/tmp-editor-statsig": "^201.0.0",
47
47
  "@atlaskit/tokens": "^18.2.0",
48
48
  "@atlaskit/tooltip": "^24.3.0",
49
49
  "@babel/runtime": "^7.0.0",
@@ -52,7 +52,7 @@
52
52
  "w3c-keyname": "^2.1.8"
53
53
  },
54
54
  "peerDependencies": {
55
- "@atlaskit/editor-common": "^123.0.0",
55
+ "@atlaskit/editor-common": "^123.3.0",
56
56
  "react": "^18.2.0 || ^19.2.0",
57
57
  "react-dom": "^18.2.0 || ^19.2.0",
58
58
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"