@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.
- package/CHANGELOG.md +25 -0
- package/dist/cjs/legacyExpand/nodeviews/index.js +50 -21
- package/dist/cjs/legacyExpand/plugin.js +2 -2
- package/dist/cjs/singlePlayerExpand/node-views/index.js +33 -17
- package/dist/cjs/singlePlayerExpand/plugin.js +1 -1
- package/dist/cjs/singlePlayerExpand/ui/NodeView.js +18 -6
- package/dist/cjs/ui/quick-insert/ExpandQuickInsertMenuItem.js +1 -1
- package/dist/es2019/entry-points/plugin.js +1 -0
- package/dist/es2019/legacyExpand/nodeviews/index.js +86 -54
- package/dist/es2019/legacyExpand/plugin.js +2 -2
- package/dist/es2019/singlePlayerExpand/node-views/index.js +32 -16
- package/dist/es2019/singlePlayerExpand/plugin.js +1 -1
- package/dist/es2019/singlePlayerExpand/ui/NodeView.js +19 -5
- package/dist/es2019/ui/quick-insert/ExpandQuickInsertMenuItem.js +1 -1
- package/dist/esm/entry-points/plugin.js +1 -0
- package/dist/esm/legacyExpand/nodeviews/index.js +49 -21
- package/dist/esm/legacyExpand/plugin.js +2 -2
- package/dist/esm/singlePlayerExpand/node-views/index.js +34 -18
- package/dist/esm/singlePlayerExpand/plugin.js +1 -1
- package/dist/esm/singlePlayerExpand/ui/NodeView.js +17 -5
- package/dist/esm/ui/quick-insert/ExpandQuickInsertMenuItem.js +1 -1
- package/dist/types/legacyExpand/nodeviews/index.d.ts +1 -0
- package/dist/types/singlePlayerExpand/ui/NodeView.d.ts +1 -0
- package/dist/types/types.d.ts +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-expand
|
|
2
2
|
|
|
3
|
+
## 20.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`ad905e52e6f1b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ad905e52e6f1b) -
|
|
8
|
+
CONFCLOUD-84260: Include the expand title in body accessible names, localize the macro role
|
|
9
|
+
description, and keep them updated behind `platform_editor_expand_content_a11y_2`.
|
|
10
|
+
- [`fc26bfc51dd5c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/fc26bfc51dd5c) -
|
|
11
|
+
Add sparse block-control surface anchors, intersection-driven candidates, and explicit visibility
|
|
12
|
+
invalidation for registry-backed block controls. Expose registration change subscriptions from the
|
|
13
|
+
UI control registry model, and refresh cached visibility from suggestion and collapse transaction
|
|
14
|
+
metadata. Under `platform_editor_block_control_migration`, use native node-anchor identity across
|
|
15
|
+
Editor and Block Controls, and route expand keyboard focus through the shared Block Controls
|
|
16
|
+
command. Preserve Show Diff visibility checks in both migration cohorts so block controls stay
|
|
17
|
+
hidden while a diff is displayed. Keep the block menu closed when a migrated layout-column handle
|
|
18
|
+
opens the layout menu, and close the layout menu when the selection moves away from its selected
|
|
19
|
+
columns.
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
22
|
+
## 20.0.2
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Updated dependencies
|
|
27
|
+
|
|
3
28
|
## 20.0.1
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
|
@@ -6,12 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.ExpandNodeView = void 0;
|
|
8
8
|
exports.default = _default;
|
|
9
|
+
exports.getExpandBodyAriaLabel = getExpandBodyAriaLabel;
|
|
9
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
13
|
var _react = _interopRequireDefault(require("react"));
|
|
13
14
|
var _uuid = require("uuid");
|
|
14
15
|
var _w3cKeyname = require("w3c-keyname");
|
|
16
|
+
var _surfaceKeys = require("@atlaskit/editor-common/block-controls/surface-keys");
|
|
15
17
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
16
18
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
17
19
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
@@ -32,7 +34,14 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
32
34
|
function buildExpandClassName(type, expanded) {
|
|
33
35
|
return "".concat(_styles.expandClassNames.prefix, " ").concat(_styles.expandClassNames.type(type), " ").concat(expanded ? _styles.expandClassNames.expanded : '');
|
|
34
36
|
}
|
|
37
|
+
function getExpandBodyAriaLabel(title, intl) {
|
|
38
|
+
var safeTitle = title.trim() || (intl === null || intl === void 0 ? void 0 : intl.formatMessage(_ui.expandMessages.expandBodyAriaLabelUntitled)) || _ui.expandMessages.expandBodyAriaLabelUntitled.defaultMessage;
|
|
39
|
+
return (intl === null || intl === void 0 ? void 0 : intl.formatMessage(_ui.expandMessages.expandBodyAriaLabel, {
|
|
40
|
+
title: safeTitle
|
|
41
|
+
})) || _ui.expandMessages.expandBodyAriaLabel.defaultMessage.replace('{title}', safeTitle);
|
|
42
|
+
}
|
|
35
43
|
var toDOM = function toDOM(node, __livePage, intl, titleReadOnly, contentEditable) {
|
|
44
|
+
var _node$attrs$title, _intl$formatMessage;
|
|
36
45
|
return ['div', _objectSpread({
|
|
37
46
|
// prettier-ignore
|
|
38
47
|
'class': buildExpandClassName(node.type.name, __livePage ? !node.attrs.__expanded : node.attrs.__expanded),
|
|
@@ -64,14 +73,19 @@ var toDOM = function toDOM(node, __livePage, intl, titleReadOnly, contentEditabl
|
|
|
64
73
|
placeholder: intl && intl.formatMessage(_ui.expandMessages.expandPlaceholderText) || _ui.expandMessages.expandPlaceholderText.defaultMessage,
|
|
65
74
|
type: 'text',
|
|
66
75
|
readonly: titleReadOnly ? 'true' : undefined
|
|
67
|
-
}]]], ['div', {
|
|
76
|
+
}]]], [(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_expand_content_a11y_2') ? 'section' : 'div', _objectSpread(_objectSpread({
|
|
68
77
|
// prettier-ignore
|
|
69
78
|
class: "".concat(_styles.expandClassNames.content, " ").concat((__livePage ? !node.attrs.__expanded : node.attrs.__expanded) ? '' : _styles.expandClassNames.contentCollapsed),
|
|
70
|
-
contenteditable: contentEditable !== undefined ? contentEditable ? 'true' : 'false' : undefined
|
|
79
|
+
contenteditable: contentEditable !== undefined ? contentEditable ? 'true' : 'false' : undefined
|
|
80
|
+
}, !(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_expand_content_a11y_2') && {
|
|
71
81
|
role: 'textbox',
|
|
72
82
|
'aria-multiline': 'true',
|
|
73
|
-
'aria-label': intl && intl.formatMessage(_ui.expandMessages.
|
|
74
|
-
}, 0
|
|
83
|
+
'aria-label': intl && intl.formatMessage(_ui.expandMessages.expandBodyAriaLabelOriginal) || _ui.expandMessages.expandBodyAriaLabelOriginal.defaultMessage
|
|
84
|
+
}), (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_expand_content_a11y_2') && {
|
|
85
|
+
'aria-label': getExpandBodyAriaLabel((_node$attrs$title = node.attrs.title) !== null && _node$attrs$title !== void 0 ? _node$attrs$title : '', intl),
|
|
86
|
+
'aria-description': (intl === null || intl === void 0 ? void 0 : intl.formatMessage(_ui.expandMessages.expandBodyAriaDescription)) || _ui.expandMessages.expandBodyAriaDescription.defaultMessage,
|
|
87
|
+
'aria-roledescription': (_intl$formatMessage = intl === null || intl === void 0 ? void 0 : intl.formatMessage(_ui.expandMessages.expandBodyRoleDescription)) !== null && _intl$formatMessage !== void 0 ? _intl$formatMessage : _ui.expandMessages.expandBodyRoleDescription.defaultMessage
|
|
88
|
+
}), 0]];
|
|
75
89
|
};
|
|
76
90
|
var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
77
91
|
function ExpandNodeView(_node, view, getPos, getIntl, isMobile, selectNearNode, api, nodeViewPortalProviderAPI) {
|
|
@@ -202,21 +216,30 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
202
216
|
(_this$api3 = _this.api) === null || _this$api3 === void 0 || _this$api3.core.actions.execute(function (_ref) {
|
|
203
217
|
var tr = _ref.tr;
|
|
204
218
|
tr.setSelection(_state.NodeSelection.create(state.doc, pos));
|
|
205
|
-
|
|
219
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration')) {
|
|
220
|
+
var _this$api4;
|
|
221
|
+
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, _surfaceKeys.BLOCK_CONTROLS_DRAG_HANDLE, {
|
|
222
|
+
isFocused: true
|
|
223
|
+
});
|
|
224
|
+
if (command) {
|
|
225
|
+
return command({
|
|
226
|
+
tr: tr
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
206
231
|
var node = state.doc.nodeAt(pos);
|
|
207
232
|
if (node) {
|
|
208
|
-
// Find the anchor name from the DOM
|
|
209
233
|
var dom = _this.view.nodeDOM(pos);
|
|
210
234
|
if (dom instanceof HTMLElement) {
|
|
211
235
|
var anchorName = dom.getAttribute('data-node-anchor');
|
|
212
|
-
// Only proceed if we found a valid anchor name
|
|
213
236
|
if (anchorName) {
|
|
214
|
-
var _this$
|
|
215
|
-
var
|
|
237
|
+
var _this$api5;
|
|
238
|
+
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, {
|
|
216
239
|
isFocused: true
|
|
217
240
|
});
|
|
218
|
-
if (
|
|
219
|
-
return
|
|
241
|
+
if (_command) {
|
|
242
|
+
return _command({
|
|
220
243
|
tr: tr
|
|
221
244
|
});
|
|
222
245
|
}
|
|
@@ -294,8 +317,8 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
294
317
|
var state = _this.view.state;
|
|
295
318
|
var expandNode = _this.node;
|
|
296
319
|
if (expandNode && (0, _utils.isEmptyNode)(state.schema)(expandNode)) {
|
|
297
|
-
var _this$
|
|
298
|
-
(0, _commands.deleteExpandAtPos)((_this$
|
|
320
|
+
var _this$api6;
|
|
321
|
+
(0, _commands.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);
|
|
299
322
|
}
|
|
300
323
|
});
|
|
301
324
|
(0, _defineProperty2.default)(this, "toggleExpand", function () {
|
|
@@ -304,12 +327,12 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
304
327
|
return;
|
|
305
328
|
}
|
|
306
329
|
if (_this.allowInteractiveExpand) {
|
|
307
|
-
var _this$
|
|
330
|
+
var _this$api7;
|
|
308
331
|
var _this$view4 = _this.view,
|
|
309
332
|
state = _this$view4.state,
|
|
310
333
|
dispatch = _this$view4.dispatch;
|
|
311
334
|
(0, _commands.toggleExpandExpanded)({
|
|
312
|
-
editorAnalyticsAPI: (_this$
|
|
335
|
+
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,
|
|
313
336
|
pos: pos,
|
|
314
337
|
nodeType: _this.node.type,
|
|
315
338
|
__livePage: _this.__livePage
|
|
@@ -461,13 +484,13 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
461
484
|
selectionStart = _this$input6.selectionStart,
|
|
462
485
|
selectionEnd = _this$input6.selectionEnd;
|
|
463
486
|
if (selectionStart === selectionEnd && selectionStart === 0) {
|
|
464
|
-
var _this$
|
|
487
|
+
var _this$api8;
|
|
465
488
|
event.preventDefault();
|
|
466
489
|
var _this$view0 = _this.view,
|
|
467
490
|
state = _this$view0.state,
|
|
468
491
|
dispatch = _this$view0.dispatch;
|
|
469
492
|
_this.view.focus();
|
|
470
|
-
var selectionSharedState = ((_this$
|
|
493
|
+
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()) || {};
|
|
471
494
|
// selectionRelativeToNode is undefined when user clicked to select node, then hit left to get focus in title
|
|
472
495
|
// This is a special case where we want to bypass node selection and jump straight to gap cursor
|
|
473
496
|
if ((selectionSharedState === null || selectionSharedState === void 0 ? void 0 : selectionSharedState.selectionRelativeToNode) === undefined) {
|
|
@@ -554,7 +577,7 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
554
577
|
return (0, _createClass2.default)(ExpandNodeView, [{
|
|
555
578
|
key: "initHandlers",
|
|
556
579
|
value: function initHandlers() {
|
|
557
|
-
var _this$
|
|
580
|
+
var _this$api9,
|
|
558
581
|
_this2 = this;
|
|
559
582
|
if (this.dom) {
|
|
560
583
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
@@ -580,7 +603,7 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
580
603
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
581
604
|
this.icon.addEventListener('keydown', this.handleIconKeyDown);
|
|
582
605
|
}
|
|
583
|
-
if ((_this$
|
|
606
|
+
if ((_this$api9 = this.api) !== null && _this$api9 !== void 0 && _this$api9.editorDisabled) {
|
|
584
607
|
this.cleanUpEditorDisabledOnChange = this.api.editorDisabled.sharedState.onChange(function (sharedState) {
|
|
585
608
|
var editorDisabled = sharedState.nextSharedState.editorDisabled;
|
|
586
609
|
if (_this2.input) {
|
|
@@ -650,13 +673,13 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
650
673
|
}, {
|
|
651
674
|
key: "isLimitedModeEnabled",
|
|
652
675
|
value: function isLimitedModeEnabled() {
|
|
653
|
-
var _this$
|
|
676
|
+
var _this$api0;
|
|
654
677
|
// Read from `this.view.state` via the exposed plugin key rather than the shared state's
|
|
655
678
|
// `enabled`, which reads a stale `false` during initial EditorView construction (the injection
|
|
656
679
|
// API's editor state isn't wired up yet).
|
|
657
680
|
//
|
|
658
681
|
// Reads the plugin's derived `enabled`, so this covers every reason limited mode can be on.
|
|
659
|
-
return Boolean((_this$
|
|
682
|
+
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);
|
|
660
683
|
}
|
|
661
684
|
}, {
|
|
662
685
|
key: "stopEvent",
|
|
@@ -718,6 +741,12 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
718
741
|
_this4.input.value = _this4.node.attrs.title;
|
|
719
742
|
}
|
|
720
743
|
});
|
|
744
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_expand_content_a11y_2')) {
|
|
745
|
+
if (this.node.attrs.title !== node.attrs.title && this.content) {
|
|
746
|
+
var _node$attrs$title2;
|
|
747
|
+
this.content.setAttribute('aria-label', getExpandBodyAriaLabel((_node$attrs$title2 = node.attrs.title) !== null && _node$attrs$title2 !== void 0 ? _node$attrs$title2 : '', this.intl));
|
|
748
|
+
}
|
|
749
|
+
}
|
|
721
750
|
this.node = node;
|
|
722
751
|
return true;
|
|
723
752
|
}
|
|
@@ -10,11 +10,11 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
10
10
|
var _expand = require("@atlaskit/adf-schema/expand");
|
|
11
11
|
var _nestedExpand = require("@atlaskit/adf-schema/nested-expand");
|
|
12
12
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
|
+
var _assets = require("@atlaskit/editor-common/assets");
|
|
13
14
|
var _blockMenu = require("@atlaskit/editor-common/block-menu");
|
|
14
15
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
15
|
-
var _assets = require("@atlaskit/editor-common/assets");
|
|
16
|
-
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
17
16
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
17
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
18
18
|
var _toggleExpandRange = require("../editor-commands/toggleExpandRange");
|
|
19
19
|
var _ExpandBlockMenuItem = require("../ui/ExpandBlockMenuItem");
|
|
20
20
|
var _getExpandQuickInsertComponents = require("../ui/quick-insert/getExpandQuickInsertComponents");
|
|
@@ -12,6 +12,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
12
12
|
var _react = _interopRequireDefault(require("react"));
|
|
13
13
|
var _uuid = require("uuid");
|
|
14
14
|
var _w3cKeyname = require("w3c-keyname");
|
|
15
|
+
var _surfaceKeys = require("@atlaskit/editor-common/block-controls/surface-keys");
|
|
15
16
|
var _expand = require("@atlaskit/editor-common/expand");
|
|
16
17
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
17
18
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
@@ -34,7 +35,7 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
34
35
|
var _this = this,
|
|
35
36
|
_expandedState$get,
|
|
36
37
|
_api$editorDisabled,
|
|
37
|
-
_this$
|
|
38
|
+
_this$api9;
|
|
38
39
|
var allowInteractiveExpand = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : true;
|
|
39
40
|
var __livePage = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : false;
|
|
40
41
|
var cleanUpEditorDisabledOnChange = arguments.length > 10 ? arguments[10] : undefined;
|
|
@@ -160,21 +161,30 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
160
161
|
(_this$api3 = _this.api) === null || _this$api3 === void 0 || _this$api3.core.actions.execute(function (_ref) {
|
|
161
162
|
var tr = _ref.tr;
|
|
162
163
|
tr.setSelection(_state.NodeSelection.create(state.doc, pos));
|
|
163
|
-
|
|
164
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration')) {
|
|
165
|
+
var _this$api4;
|
|
166
|
+
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, _surfaceKeys.BLOCK_CONTROLS_DRAG_HANDLE, {
|
|
167
|
+
isFocused: true
|
|
168
|
+
});
|
|
169
|
+
if (command) {
|
|
170
|
+
return command({
|
|
171
|
+
tr: tr
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
164
176
|
var node = state.doc.nodeAt(pos);
|
|
165
177
|
if (node) {
|
|
166
|
-
// Find the anchor name from the DOM
|
|
167
178
|
var dom = _this.view.nodeDOM(pos);
|
|
168
179
|
if (dom instanceof HTMLElement) {
|
|
169
180
|
var anchorName = (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? dom.getAttribute('data-node-anchor') : dom.getAttribute('data-drag-handler-anchor-name');
|
|
170
|
-
// Only proceed if we found a valid anchor name
|
|
171
181
|
if (anchorName) {
|
|
172
|
-
var _this$
|
|
173
|
-
var
|
|
182
|
+
var _this$api5;
|
|
183
|
+
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, {
|
|
174
184
|
isFocused: true
|
|
175
185
|
});
|
|
176
|
-
if (
|
|
177
|
-
return
|
|
186
|
+
if (_command) {
|
|
187
|
+
return _command({
|
|
178
188
|
tr: tr
|
|
179
189
|
});
|
|
180
190
|
}
|
|
@@ -247,8 +257,8 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
247
257
|
return;
|
|
248
258
|
}
|
|
249
259
|
if (expandNode && (0, _utils.isEmptyNode)(state.schema)(expandNode)) {
|
|
250
|
-
var _this$
|
|
251
|
-
(0, _commands.deleteExpand)((_this$
|
|
260
|
+
var _this$api6;
|
|
261
|
+
(0, _commands.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);
|
|
252
262
|
}
|
|
253
263
|
});
|
|
254
264
|
(0, _defineProperty2.default)(this, "toggleExpand", function () {
|
|
@@ -257,12 +267,12 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
257
267
|
return;
|
|
258
268
|
}
|
|
259
269
|
if (_this.allowInteractiveExpand) {
|
|
260
|
-
var _this$
|
|
270
|
+
var _this$api7;
|
|
261
271
|
var _this$view3 = _this.view,
|
|
262
272
|
state = _this$view3.state,
|
|
263
273
|
dispatch = _this$view3.dispatch;
|
|
264
274
|
(0, _commands.toggleExpandExpanded)({
|
|
265
|
-
editorAnalyticsAPI: (_this$
|
|
275
|
+
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,
|
|
266
276
|
pos: pos,
|
|
267
277
|
node: _this.node
|
|
268
278
|
})(state, dispatch);
|
|
@@ -416,13 +426,13 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
416
426
|
selectionStart = _this$input6.selectionStart,
|
|
417
427
|
selectionEnd = _this$input6.selectionEnd;
|
|
418
428
|
if (selectionStart === selectionEnd && selectionStart === 0) {
|
|
419
|
-
var _this$
|
|
429
|
+
var _this$api8;
|
|
420
430
|
event.preventDefault();
|
|
421
431
|
var _this$view9 = _this.view,
|
|
422
432
|
state = _this$view9.state,
|
|
423
433
|
dispatch = _this$view9.dispatch;
|
|
424
434
|
_this.view.focus();
|
|
425
|
-
var selectionSharedState = ((_this$
|
|
435
|
+
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()) || {};
|
|
426
436
|
// selectionRelativeToNode is undefined when user clicked to select node, then hit left to get focus in title
|
|
427
437
|
// This is a special case where we want to bypass node selection and jump straight to gap cursor
|
|
428
438
|
if ((selectionSharedState === null || selectionSharedState === void 0 ? void 0 : selectionSharedState.selectionRelativeToNode) === undefined) {
|
|
@@ -538,7 +548,7 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
538
548
|
// Prevent ProseMirror from getting a focus event (causes weird selection issues).
|
|
539
549
|
this.titleContainer.addEventListener('focus', this.handleFocus);
|
|
540
550
|
this.icon.addEventListener('keydown', this.handleIconKeyDown);
|
|
541
|
-
if ((_this$
|
|
551
|
+
if ((_this$api9 = this.api) !== null && _this$api9 !== void 0 && _this$api9.editorDisabled) {
|
|
542
552
|
if ((0, _isExperimentEnabled.isExperimentEnabled)('cc_editor_limited_mode_perf_improvements')) {
|
|
543
553
|
if (this.content) {
|
|
544
554
|
this.content.setAttribute('contenteditable', this.getContentEditable(this.node) ? 'true' : 'false');
|
|
@@ -610,6 +620,12 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
610
620
|
}
|
|
611
621
|
});
|
|
612
622
|
|
|
623
|
+
// Sync up the aria-label with the current expand title.
|
|
624
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_expand_content_a11y_2') && this.node.attrs.title !== node.attrs.title && this.content) {
|
|
625
|
+
var _node$attrs$title;
|
|
626
|
+
this.content.setAttribute('aria-label', (0, _NodeView.getExpandBodyAriaLabel)((_node$attrs$title = node.attrs.title) !== null && _node$attrs$title !== void 0 ? _node$attrs$title : '', this.intl));
|
|
627
|
+
}
|
|
628
|
+
|
|
613
629
|
// This checks if the node has been replaced with a different version
|
|
614
630
|
// and updates the state of the new node to match the old one
|
|
615
631
|
// Eg. typing in a node changes it to a new node so it must be updated
|
|
@@ -666,13 +682,13 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
666
682
|
}, {
|
|
667
683
|
key: "isLimitedModeEnabled",
|
|
668
684
|
value: function isLimitedModeEnabled() {
|
|
669
|
-
var _this$
|
|
685
|
+
var _this$api0;
|
|
670
686
|
// Read from `this.view.state` via the exposed plugin key rather than the shared state's
|
|
671
687
|
// `enabled`, which reads a stale `false` during initial EditorView construction (the injection
|
|
672
688
|
// API's editor state isn't wired up yet).
|
|
673
689
|
//
|
|
674
690
|
// Reads the plugin's derived `enabled`, so this covers every reason limited mode can be on.
|
|
675
|
-
return Boolean((_this$
|
|
691
|
+
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);
|
|
676
692
|
}
|
|
677
693
|
}, {
|
|
678
694
|
key: "updateDisplayStyle",
|
|
@@ -10,9 +10,9 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
10
10
|
var _expand = require("@atlaskit/adf-schema/expand");
|
|
11
11
|
var _nestedExpand = require("@atlaskit/adf-schema/nested-expand");
|
|
12
12
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
|
+
var _assets = require("@atlaskit/editor-common/assets");
|
|
13
14
|
var _blockMenu = require("@atlaskit/editor-common/block-menu");
|
|
14
15
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
15
|
-
var _assets = require("@atlaskit/editor-common/assets");
|
|
16
16
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
17
17
|
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
18
18
|
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
@@ -4,19 +4,26 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.toDOM = exports.buildExpandClassName = void 0;
|
|
7
|
+
exports.toDOM = exports.getExpandBodyAriaLabel = exports.buildExpandClassName = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _expand = require("@atlaskit/editor-common/expand");
|
|
10
10
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
11
11
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
12
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
12
13
|
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
13
14
|
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; }
|
|
14
15
|
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; }
|
|
15
16
|
var buildExpandClassName = exports.buildExpandClassName = function buildExpandClassName(type, expanded) {
|
|
16
17
|
return "".concat(_styles.expandClassNames.prefix, " ").concat(_styles.expandClassNames.type(type), " ").concat(expanded ? _styles.expandClassNames.expanded : '');
|
|
17
18
|
};
|
|
19
|
+
var getExpandBodyAriaLabel = exports.getExpandBodyAriaLabel = function getExpandBodyAriaLabel(title, intl) {
|
|
20
|
+
var safeTitle = title.trim() || (intl === null || intl === void 0 ? void 0 : intl.formatMessage(_ui.expandMessages.expandBodyAriaLabelUntitled)) || _ui.expandMessages.expandBodyAriaLabelUntitled.defaultMessage;
|
|
21
|
+
return (intl === null || intl === void 0 ? void 0 : intl.formatMessage(_ui.expandMessages.expandBodyAriaLabel, {
|
|
22
|
+
title: safeTitle
|
|
23
|
+
})) || _ui.expandMessages.expandBodyAriaLabel.defaultMessage.replace('{title}', safeTitle);
|
|
24
|
+
};
|
|
18
25
|
var toDOM = exports.toDOM = function toDOM(node, __livePage, intl, titleReadOnly, contentEditable) {
|
|
19
|
-
var _expandedState$get;
|
|
26
|
+
var _expandedState$get, _node$attrs$title, _intl$formatMessage;
|
|
20
27
|
return ['div', _objectSpread({
|
|
21
28
|
// prettier-ignore
|
|
22
29
|
'class': buildExpandClassName(node.type.name, (_expandedState$get = _expand.expandedState.get(node)) !== null && _expandedState$get !== void 0 ? _expandedState$get : false),
|
|
@@ -48,12 +55,17 @@ var toDOM = exports.toDOM = function toDOM(node, __livePage, intl, titleReadOnly
|
|
|
48
55
|
placeholder: intl && typeof intl.formatMessage === 'function' && intl.formatMessage(_ui.expandMessages.expandPlaceholderText) || _ui.expandMessages.expandPlaceholderText.defaultMessage,
|
|
49
56
|
type: 'text',
|
|
50
57
|
readonly: titleReadOnly ? 'true' : undefined
|
|
51
|
-
}]]], ['div', {
|
|
58
|
+
}]]], [(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_expand_content_a11y_2') ? 'section' : 'div', _objectSpread(_objectSpread({
|
|
52
59
|
// prettier-ignore
|
|
53
60
|
class: "".concat(_styles.expandClassNames.content, " ").concat(_expand.expandedState.get(node) ? '' : _styles.expandClassNames.contentCollapsed),
|
|
54
|
-
contenteditable: contentEditable !== undefined ? contentEditable ? 'true' : 'false' : undefined
|
|
61
|
+
contenteditable: contentEditable !== undefined ? contentEditable ? 'true' : 'false' : undefined
|
|
62
|
+
}, !(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_expand_content_a11y_2') && {
|
|
55
63
|
role: 'textbox',
|
|
56
64
|
'aria-multiline': 'true',
|
|
57
|
-
'aria-label': intl && intl.formatMessage(_ui.expandMessages.
|
|
58
|
-
}, 0
|
|
65
|
+
'aria-label': intl && intl.formatMessage(_ui.expandMessages.expandBodyAriaLabelOriginal) || _ui.expandMessages.expandBodyAriaLabelOriginal.defaultMessage
|
|
66
|
+
}), (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_expand_content_a11y_2') && {
|
|
67
|
+
'aria-label': getExpandBodyAriaLabel((_node$attrs$title = node.attrs.title) !== null && _node$attrs$title !== void 0 ? _node$attrs$title : '', intl),
|
|
68
|
+
'aria-description': (intl === null || intl === void 0 ? void 0 : intl.formatMessage(_ui.expandMessages.expandBodyAriaDescription)) || _ui.expandMessages.expandBodyAriaDescription.defaultMessage,
|
|
69
|
+
'aria-roledescription': (_intl$formatMessage = intl === null || intl === void 0 ? void 0 : intl.formatMessage(_ui.expandMessages.expandBodyRoleDescription)) !== null && _intl$formatMessage !== void 0 ? _intl$formatMessage : _ui.expandMessages.expandBodyRoleDescription.defaultMessage
|
|
70
|
+
}), 0]];
|
|
59
71
|
};
|
|
@@ -13,8 +13,8 @@ var _hooks = require("@atlaskit/editor-common/hooks");
|
|
|
13
13
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
14
14
|
var _menuItem = require("@atlaskit/editor-common/quick-insert/menu-item");
|
|
15
15
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
16
|
-
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
17
16
|
var _expandElement = _interopRequireDefault(require("@atlaskit/icon-lab/core/expand-element"));
|
|
17
|
+
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
18
18
|
var _commands = require("../../legacyExpand/commands");
|
|
19
19
|
var _commands2 = require("../../singlePlayerExpand/commands");
|
|
20
20
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|