@atlaskit/editor-plugin-expand 20.0.2 → 20.0.4
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/singlePlayerExpand/node-views/index.js +33 -17
- package/dist/cjs/singlePlayerExpand/ui/NodeView.js +18 -6
- package/dist/es2019/legacyExpand/nodeviews/index.js +86 -54
- package/dist/es2019/singlePlayerExpand/node-views/index.js +32 -16
- package/dist/es2019/singlePlayerExpand/ui/NodeView.js +19 -5
- package/dist/esm/legacyExpand/nodeviews/index.js +49 -21
- package/dist/esm/singlePlayerExpand/node-views/index.js +34 -18
- package/dist/esm/singlePlayerExpand/ui/NodeView.js +17 -5
- package/dist/types/legacyExpand/nodeviews/index.d.ts +1 -0
- package/dist/types/singlePlayerExpand/ui/NodeView.d.ts +1 -0
- package/package.json +7 -7
|
@@ -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$
|
|
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
|
-
|
|
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$
|
|
165
|
-
var
|
|
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 (
|
|
169
|
-
return
|
|
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$
|
|
243
|
-
deleteExpand((_this$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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",
|
|
@@ -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.
|
|
51
|
-
},
|
|
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,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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-expand",
|
|
3
|
-
"version": "20.0.
|
|
3
|
+
"version": "20.0.4",
|
|
4
4
|
"description": "Expand plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
],
|
|
22
22
|
"atlaskit:src": "src/index.ts",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@atlaskit/adf-schema": "^57.
|
|
25
|
-
"@atlaskit/button": "^25.
|
|
24
|
+
"@atlaskit/adf-schema": "^57.6.0",
|
|
25
|
+
"@atlaskit/button": "^25.4.0",
|
|
26
26
|
"@atlaskit/editor-plugin-analytics": "^19.0.0",
|
|
27
|
-
"@atlaskit/editor-plugin-block-controls": "^20.
|
|
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",
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
"@atlaskit/editor-shared-styles": "^4.3.0",
|
|
38
38
|
"@atlaskit/editor-tables": "^3.2.0",
|
|
39
39
|
"@atlaskit/editor-toolbar": "^2.7.0",
|
|
40
|
-
"@atlaskit/editor-ui-control-model": "^2.
|
|
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": "^
|
|
46
|
+
"@atlaskit/tmp-editor-statsig": "^202.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.
|
|
55
|
+
"@atlaskit/editor-common": "^123.5.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"
|