@atlaskit/editor-plugin-block-menu 6.0.32 → 6.0.34
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 +18 -0
- package/dist/cjs/blockMenuPlugin.js +0 -4
- package/dist/cjs/editor-commands/transform-node-utils/steps/applyTargetTextTypeStep.js +11 -1
- package/dist/cjs/ui/block-menu-renderer/fallbacks.js +23 -16
- package/dist/cjs/ui/block-menu.js +12 -1
- package/dist/es2019/blockMenuPlugin.js +0 -4
- package/dist/es2019/editor-commands/transform-node-utils/steps/applyTargetTextTypeStep.js +11 -1
- package/dist/es2019/ui/block-menu-renderer/fallbacks.js +21 -8
- package/dist/es2019/ui/block-menu.js +12 -1
- package/dist/esm/blockMenuPlugin.js +0 -4
- package/dist/esm/editor-commands/transform-node-utils/steps/applyTargetTextTypeStep.js +11 -1
- package/dist/esm/ui/block-menu-renderer/fallbacks.js +23 -16
- package/dist/esm/ui/block-menu.js +12 -1
- package/dist/types/blockMenuPluginType.d.ts +1 -3
- package/dist/types/editor-commands/selection.d.ts +2 -2
- package/dist/types/editor-commands/transforms/transformNodeToTargetType.d.ts +2 -2
- package/dist/types/editor-commands/transforms/types.d.ts +3 -6
- package/dist/types/editor-commands/transforms/utils.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types-ts4.5/blockMenuPluginType.d.ts +1 -3
- package/dist/types-ts4.5/editor-commands/selection.d.ts +2 -2
- package/dist/types-ts4.5/editor-commands/transforms/transformNodeToTargetType.d.ts +2 -2
- package/dist/types-ts4.5/editor-commands/transforms/types.d.ts +3 -6
- package/dist/types-ts4.5/editor-commands/transforms/utils.d.ts +2 -2
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/package.json +2 -2
- package/dist/cjs/editor-commands/formatNode.js +0 -268
- package/dist/es2019/editor-commands/formatNode.js +0 -272
- package/dist/esm/editor-commands/formatNode.js +0 -263
- package/dist/types/editor-commands/formatNode.d.ts +0 -20
- package/dist/types-ts4.5/editor-commands/formatNode.d.ts +0 -20
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-menu
|
|
2
2
|
|
|
3
|
+
## 6.0.34
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`8cdbba82920a6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8cdbba82920a6) -
|
|
8
|
+
[ux] Remove unsupported marks when transforming to text
|
|
9
|
+
- [`9d0d19d5018ae`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9d0d19d5018ae) -
|
|
10
|
+
Remove jsx literal strings in block menu fall back components
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 6.0.33
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [`3b3aa281c8524`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3b3aa281c8524) -
|
|
18
|
+
Editor 4149 Fix keyboard navigation inside turn into
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 6.0.32
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -8,7 +8,6 @@ exports.blockMenuPlugin = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _editorActions = require("./editor-actions");
|
|
10
10
|
var _isTransformToTargetDisabled = require("./editor-actions/isTransformToTargetDisabled");
|
|
11
|
-
var _formatNode2 = require("./editor-commands/formatNode");
|
|
12
11
|
var _transformNode2 = require("./editor-commands/transformNode");
|
|
13
12
|
var _blockMenuExperiences = require("./pm-plugins/experiences/block-menu-experiences");
|
|
14
13
|
var _keymap = require("./pm-plugins/keymap");
|
|
@@ -75,9 +74,6 @@ var blockMenuPlugin = exports.blockMenuPlugin = function blockMenuPlugin(_ref) {
|
|
|
75
74
|
}
|
|
76
75
|
},
|
|
77
76
|
commands: {
|
|
78
|
-
formatNode: function formatNode(targetType, analyticsAttrs) {
|
|
79
|
-
return (0, _formatNode2.formatNode)(api)(targetType, analyticsAttrs);
|
|
80
|
-
},
|
|
81
77
|
transformNode: function transformNode(targetType, metadata) {
|
|
82
78
|
return (0, _transformNode2.transformNode)(api)(targetType, metadata);
|
|
83
79
|
}
|
|
@@ -50,7 +50,17 @@ var applyTargetTextTypeStep = exports.applyTargetTextTypeStep = function applyTa
|
|
|
50
50
|
level: level
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
// Filter out marks that aren't allowed on paragraph/heading nodes
|
|
54
|
+
// Remove 'breakout' mark when converting to paragraph/heading as these nodes don't support breakout
|
|
55
|
+
var filteredMarks = node.marks.filter(function (mark) {
|
|
56
|
+
// breakout marks should be removed when converting to paragraph or heading
|
|
57
|
+
if (mark.type.name === 'breakout') {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
// Keep all other marks (alignment, indentation, etc.)
|
|
61
|
+
return true;
|
|
62
|
+
});
|
|
63
|
+
return targetType.create(attrs, node.content, filteredMarks);
|
|
54
64
|
}
|
|
55
65
|
// Non-textblock nodes are left unchanged
|
|
56
66
|
return node;
|
|
@@ -6,27 +6,34 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.BLOCK_MENU_FALLBACKS = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _reactIntlNext = require("react-intl-next");
|
|
10
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
9
11
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
10
12
|
var _chevronRight = _interopRequireDefault(require("@atlaskit/icon/core/chevron-right"));
|
|
13
|
+
var FallbackNestedMenu = function FallbackNestedMenu(_ref) {
|
|
14
|
+
var children = _ref.children;
|
|
15
|
+
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
16
|
+
formatMessage = _useIntl.formatMessage;
|
|
17
|
+
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarNestedDropdownMenu, {
|
|
18
|
+
elemBefore: undefined,
|
|
19
|
+
elemAfter: /*#__PURE__*/_react.default.createElement(_chevronRight.default, {
|
|
20
|
+
label: ""
|
|
21
|
+
}),
|
|
22
|
+
text: formatMessage(_messages.blockMenuMessages.fallbackNestedMenu),
|
|
23
|
+
enableMaxHeight: true,
|
|
24
|
+
shouldFitContainer: true
|
|
25
|
+
}, children);
|
|
26
|
+
};
|
|
27
|
+
var FallbackMenuItem = function FallbackMenuItem() {
|
|
28
|
+
var _useIntl2 = (0, _reactIntlNext.useIntl)(),
|
|
29
|
+
formatMessage = _useIntl2.formatMessage;
|
|
30
|
+
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, null, formatMessage(_messages.blockMenuMessages.fallbackMenuItem));
|
|
31
|
+
};
|
|
11
32
|
var BLOCK_MENU_FALLBACKS = exports.BLOCK_MENU_FALLBACKS = {
|
|
12
|
-
'block-menu-nested':
|
|
13
|
-
var children = _ref.children;
|
|
14
|
-
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarNestedDropdownMenu, {
|
|
15
|
-
elemBefore: undefined,
|
|
16
|
-
elemAfter: /*#__PURE__*/_react.default.createElement(_chevronRight.default, {
|
|
17
|
-
label: ""
|
|
18
|
-
}),
|
|
19
|
-
text: "Nested Menu",
|
|
20
|
-
enableMaxHeight: true,
|
|
21
|
-
shouldFitContainer: true
|
|
22
|
-
}, children);
|
|
23
|
-
},
|
|
33
|
+
'block-menu-nested': FallbackNestedMenu,
|
|
24
34
|
'block-menu-section': function blockMenuSection(_ref2) {
|
|
25
35
|
var children = _ref2.children;
|
|
26
36
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, null, children);
|
|
27
37
|
},
|
|
28
|
-
|
|
29
|
-
'block-menu-item': function blockMenuItem() {
|
|
30
|
-
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, null, "Block Menu Item");
|
|
31
|
-
}
|
|
38
|
+
'block-menu-item': FallbackMenuItem
|
|
32
39
|
};
|
|
@@ -87,6 +87,16 @@ var BlockMenuContent = function BlockMenuContent(_ref2) {
|
|
|
87
87
|
setOutsideClickTargetRef(el);
|
|
88
88
|
setRef === null || setRef === void 0 || setRef(el);
|
|
89
89
|
};
|
|
90
|
+
var shouldDisableArrowKeyNavigation = function shouldDisableArrowKeyNavigation(event) {
|
|
91
|
+
if (event.key !== 'ArrowUp' && event.key !== 'ArrowDown') {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
var target = event.target;
|
|
95
|
+
if (!(target instanceof HTMLElement)) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
return target.closest('[data-toolbar-nested-dropdown-menu]') !== null;
|
|
99
|
+
};
|
|
90
100
|
return /*#__PURE__*/_react.default.createElement(_compiled.Box, {
|
|
91
101
|
testId: "editor-block-menu",
|
|
92
102
|
role: (0, _expValEquals.expValEquals)('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? 'menu' : undefined,
|
|
@@ -96,7 +106,8 @@ var BlockMenuContent = function BlockMenuContent(_ref2) {
|
|
|
96
106
|
type: _uiMenu.ArrowKeyNavigationType.MENU,
|
|
97
107
|
handleClose: function handleClose(e) {
|
|
98
108
|
return e.preventDefault();
|
|
99
|
-
}
|
|
109
|
+
},
|
|
110
|
+
disableArrowKeyNavigation: shouldDisableArrowKeyNavigation
|
|
100
111
|
}, /*#__PURE__*/_react.default.createElement(_BlockMenuRenderer.BlockMenuRenderer, {
|
|
101
112
|
allRegisteredComponents: blockMenuComponents || []
|
|
102
113
|
})));
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { createBlockMenuRegistry } from './editor-actions';
|
|
3
3
|
import { isTransformToTargetDisabled } from './editor-actions/isTransformToTargetDisabled';
|
|
4
|
-
import { formatNode } from './editor-commands/formatNode';
|
|
5
4
|
import { transformNode } from './editor-commands/transformNode';
|
|
6
5
|
import { getBlockMenuExperiencesPlugin } from './pm-plugins/experiences/block-menu-experiences';
|
|
7
6
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
@@ -63,9 +62,6 @@ export const blockMenuPlugin = ({
|
|
|
63
62
|
}
|
|
64
63
|
},
|
|
65
64
|
commands: {
|
|
66
|
-
formatNode: (targetType, analyticsAttrs) => {
|
|
67
|
-
return formatNode(api)(targetType, analyticsAttrs);
|
|
68
|
-
},
|
|
69
65
|
transformNode: (targetType, metadata) => {
|
|
70
66
|
return transformNode(api)(targetType, metadata);
|
|
71
67
|
}
|
|
@@ -46,7 +46,17 @@ export const applyTargetTextTypeStep = (nodes, context) => {
|
|
|
46
46
|
level
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
// Filter out marks that aren't allowed on paragraph/heading nodes
|
|
50
|
+
// Remove 'breakout' mark when converting to paragraph/heading as these nodes don't support breakout
|
|
51
|
+
const filteredMarks = node.marks.filter(mark => {
|
|
52
|
+
// breakout marks should be removed when converting to paragraph or heading
|
|
53
|
+
if (mark.type.name === 'breakout') {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
// Keep all other marks (alignment, indentation, etc.)
|
|
57
|
+
return true;
|
|
58
|
+
});
|
|
59
|
+
return targetType.create(attrs, node.content, filteredMarks);
|
|
50
60
|
}
|
|
51
61
|
// Non-textblock nodes are left unchanged
|
|
52
62
|
return node;
|
|
@@ -1,21 +1,34 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl-next';
|
|
3
|
+
import { blockMenuMessages } from '@atlaskit/editor-common/messages';
|
|
2
4
|
import { ToolbarDropdownItem, ToolbarDropdownItemSection, ToolbarNestedDropdownMenu } from '@atlaskit/editor-toolbar';
|
|
3
5
|
import ChevronRightIcon from '@atlaskit/icon/core/chevron-right';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const FallbackNestedMenu = ({
|
|
7
|
+
children
|
|
8
|
+
}) => {
|
|
9
|
+
const {
|
|
10
|
+
formatMessage
|
|
11
|
+
} = useIntl();
|
|
12
|
+
return /*#__PURE__*/React.createElement(ToolbarNestedDropdownMenu, {
|
|
8
13
|
elemBefore: undefined,
|
|
9
14
|
elemAfter: /*#__PURE__*/React.createElement(ChevronRightIcon, {
|
|
10
15
|
label: ""
|
|
11
16
|
}),
|
|
12
|
-
text:
|
|
17
|
+
text: formatMessage(blockMenuMessages.fallbackNestedMenu),
|
|
13
18
|
enableMaxHeight: true,
|
|
14
19
|
shouldFitContainer: true
|
|
15
|
-
}, children)
|
|
20
|
+
}, children);
|
|
21
|
+
};
|
|
22
|
+
const FallbackMenuItem = () => {
|
|
23
|
+
const {
|
|
24
|
+
formatMessage
|
|
25
|
+
} = useIntl();
|
|
26
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, null, formatMessage(blockMenuMessages.fallbackMenuItem));
|
|
27
|
+
};
|
|
28
|
+
export const BLOCK_MENU_FALLBACKS = {
|
|
29
|
+
'block-menu-nested': FallbackNestedMenu,
|
|
16
30
|
'block-menu-section': ({
|
|
17
31
|
children
|
|
18
32
|
}) => /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, children),
|
|
19
|
-
|
|
20
|
-
'block-menu-item': () => /*#__PURE__*/React.createElement(ToolbarDropdownItem, null, "Block Menu Item")
|
|
33
|
+
'block-menu-item': FallbackMenuItem
|
|
21
34
|
};
|
|
@@ -80,6 +80,16 @@ const BlockMenuContent = ({
|
|
|
80
80
|
setOutsideClickTargetRef(el);
|
|
81
81
|
setRef === null || setRef === void 0 ? void 0 : setRef(el);
|
|
82
82
|
};
|
|
83
|
+
const shouldDisableArrowKeyNavigation = event => {
|
|
84
|
+
if (event.key !== 'ArrowUp' && event.key !== 'ArrowDown') {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
const target = event.target;
|
|
88
|
+
if (!(target instanceof HTMLElement)) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
return target.closest('[data-toolbar-nested-dropdown-menu]') !== null;
|
|
92
|
+
};
|
|
83
93
|
return /*#__PURE__*/React.createElement(Box, {
|
|
84
94
|
testId: "editor-block-menu",
|
|
85
95
|
role: expValEquals('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? 'menu' : undefined,
|
|
@@ -87,7 +97,8 @@ const BlockMenuContent = ({
|
|
|
87
97
|
xcss: cx(styles.base, editorExperiment('platform_synced_block', true) && styles.emptyMenuSectionStyles)
|
|
88
98
|
}, /*#__PURE__*/React.createElement(ArrowKeyNavigationProvider, {
|
|
89
99
|
type: ArrowKeyNavigationType.MENU,
|
|
90
|
-
handleClose: e => e.preventDefault()
|
|
100
|
+
handleClose: e => e.preventDefault(),
|
|
101
|
+
disableArrowKeyNavigation: shouldDisableArrowKeyNavigation
|
|
91
102
|
}, /*#__PURE__*/React.createElement(BlockMenuRenderer, {
|
|
92
103
|
allRegisteredComponents: blockMenuComponents || []
|
|
93
104
|
})));
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { createBlockMenuRegistry } from './editor-actions';
|
|
3
3
|
import { isTransformToTargetDisabled } from './editor-actions/isTransformToTargetDisabled';
|
|
4
|
-
import { formatNode as _formatNode } from './editor-commands/formatNode';
|
|
5
4
|
import { transformNode as _transformNode } from './editor-commands/transformNode';
|
|
6
5
|
import { getBlockMenuExperiencesPlugin } from './pm-plugins/experiences/block-menu-experiences';
|
|
7
6
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
@@ -68,9 +67,6 @@ export var blockMenuPlugin = function blockMenuPlugin(_ref) {
|
|
|
68
67
|
}
|
|
69
68
|
},
|
|
70
69
|
commands: {
|
|
71
|
-
formatNode: function formatNode(targetType, analyticsAttrs) {
|
|
72
|
-
return _formatNode(api)(targetType, analyticsAttrs);
|
|
73
|
-
},
|
|
74
70
|
transformNode: function transformNode(targetType, metadata) {
|
|
75
71
|
return _transformNode(api)(targetType, metadata);
|
|
76
72
|
}
|
|
@@ -44,7 +44,17 @@ export var applyTargetTextTypeStep = function applyTargetTextTypeStep(nodes, con
|
|
|
44
44
|
level: level
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
// Filter out marks that aren't allowed on paragraph/heading nodes
|
|
48
|
+
// Remove 'breakout' mark when converting to paragraph/heading as these nodes don't support breakout
|
|
49
|
+
var filteredMarks = node.marks.filter(function (mark) {
|
|
50
|
+
// breakout marks should be removed when converting to paragraph or heading
|
|
51
|
+
if (mark.type.name === 'breakout') {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
// Keep all other marks (alignment, indentation, etc.)
|
|
55
|
+
return true;
|
|
56
|
+
});
|
|
57
|
+
return targetType.create(attrs, node.content, filteredMarks);
|
|
48
58
|
}
|
|
49
59
|
// Non-textblock nodes are left unchanged
|
|
50
60
|
return node;
|
|
@@ -1,25 +1,32 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl-next';
|
|
3
|
+
import { blockMenuMessages } from '@atlaskit/editor-common/messages';
|
|
2
4
|
import { ToolbarDropdownItem, ToolbarDropdownItemSection, ToolbarNestedDropdownMenu } from '@atlaskit/editor-toolbar';
|
|
3
5
|
import ChevronRightIcon from '@atlaskit/icon/core/chevron-right';
|
|
6
|
+
var FallbackNestedMenu = function FallbackNestedMenu(_ref) {
|
|
7
|
+
var children = _ref.children;
|
|
8
|
+
var _useIntl = useIntl(),
|
|
9
|
+
formatMessage = _useIntl.formatMessage;
|
|
10
|
+
return /*#__PURE__*/React.createElement(ToolbarNestedDropdownMenu, {
|
|
11
|
+
elemBefore: undefined,
|
|
12
|
+
elemAfter: /*#__PURE__*/React.createElement(ChevronRightIcon, {
|
|
13
|
+
label: ""
|
|
14
|
+
}),
|
|
15
|
+
text: formatMessage(blockMenuMessages.fallbackNestedMenu),
|
|
16
|
+
enableMaxHeight: true,
|
|
17
|
+
shouldFitContainer: true
|
|
18
|
+
}, children);
|
|
19
|
+
};
|
|
20
|
+
var FallbackMenuItem = function FallbackMenuItem() {
|
|
21
|
+
var _useIntl2 = useIntl(),
|
|
22
|
+
formatMessage = _useIntl2.formatMessage;
|
|
23
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, null, formatMessage(blockMenuMessages.fallbackMenuItem));
|
|
24
|
+
};
|
|
4
25
|
export var BLOCK_MENU_FALLBACKS = {
|
|
5
|
-
'block-menu-nested':
|
|
6
|
-
var children = _ref.children;
|
|
7
|
-
return /*#__PURE__*/React.createElement(ToolbarNestedDropdownMenu, {
|
|
8
|
-
elemBefore: undefined,
|
|
9
|
-
elemAfter: /*#__PURE__*/React.createElement(ChevronRightIcon, {
|
|
10
|
-
label: ""
|
|
11
|
-
}),
|
|
12
|
-
text: "Nested Menu",
|
|
13
|
-
enableMaxHeight: true,
|
|
14
|
-
shouldFitContainer: true
|
|
15
|
-
}, children);
|
|
16
|
-
},
|
|
26
|
+
'block-menu-nested': FallbackNestedMenu,
|
|
17
27
|
'block-menu-section': function blockMenuSection(_ref2) {
|
|
18
28
|
var children = _ref2.children;
|
|
19
29
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, children);
|
|
20
30
|
},
|
|
21
|
-
|
|
22
|
-
'block-menu-item': function blockMenuItem() {
|
|
23
|
-
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, null, "Block Menu Item");
|
|
24
|
-
}
|
|
31
|
+
'block-menu-item': FallbackMenuItem
|
|
25
32
|
};
|
|
@@ -78,6 +78,16 @@ var BlockMenuContent = function BlockMenuContent(_ref2) {
|
|
|
78
78
|
setOutsideClickTargetRef(el);
|
|
79
79
|
setRef === null || setRef === void 0 || setRef(el);
|
|
80
80
|
};
|
|
81
|
+
var shouldDisableArrowKeyNavigation = function shouldDisableArrowKeyNavigation(event) {
|
|
82
|
+
if (event.key !== 'ArrowUp' && event.key !== 'ArrowDown') {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
var target = event.target;
|
|
86
|
+
if (!(target instanceof HTMLElement)) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
return target.closest('[data-toolbar-nested-dropdown-menu]') !== null;
|
|
90
|
+
};
|
|
81
91
|
return /*#__PURE__*/React.createElement(Box, {
|
|
82
92
|
testId: "editor-block-menu",
|
|
83
93
|
role: expValEquals('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? 'menu' : undefined,
|
|
@@ -87,7 +97,8 @@ var BlockMenuContent = function BlockMenuContent(_ref2) {
|
|
|
87
97
|
type: ArrowKeyNavigationType.MENU,
|
|
88
98
|
handleClose: function handleClose(e) {
|
|
89
99
|
return e.preventDefault();
|
|
90
|
-
}
|
|
100
|
+
},
|
|
101
|
+
disableArrowKeyNavigation: shouldDisableArrowKeyNavigation
|
|
91
102
|
}, /*#__PURE__*/React.createElement(BlockMenuRenderer, {
|
|
92
103
|
allRegisteredComponents: blockMenuComponents || []
|
|
93
104
|
})));
|
|
@@ -5,11 +5,10 @@ import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
|
5
5
|
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
6
6
|
import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
|
|
7
7
|
import type { NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
8
|
-
import type {
|
|
8
|
+
import type { TransformNodeMetadata } from './editor-commands/transforms/types';
|
|
9
9
|
export declare enum FLAG_ID {
|
|
10
10
|
LINK_COPIED_TO_CLIPBOARD = "link-copied-to-clipboard"
|
|
11
11
|
}
|
|
12
|
-
type FormatNodeCommand = (targetType: FormatNodeTargetType, analyticsAttrs?: FormatNodeAnalyticsAttrs) => EditorCommand;
|
|
13
12
|
type TransformNodeCommand = (targetType: NodeType, metadata?: TransformNodeMetadata) => EditorCommand;
|
|
14
13
|
export type BlockMenuPlugin = NextEditorPlugin<'blockMenu', {
|
|
15
14
|
actions: {
|
|
@@ -18,7 +17,6 @@ export type BlockMenuPlugin = NextEditorPlugin<'blockMenu', {
|
|
|
18
17
|
registerBlockMenuComponents: (blockMenuComponents: Array<RegisterBlockMenuComponent>) => void;
|
|
19
18
|
};
|
|
20
19
|
commands: {
|
|
21
|
-
formatNode: FormatNodeCommand;
|
|
22
20
|
transformNode: TransformNodeCommand;
|
|
23
21
|
};
|
|
24
22
|
dependencies: [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
import type {
|
|
2
|
+
import type { TransfromNodeTargetType } from './transforms/types';
|
|
3
3
|
/**
|
|
4
4
|
* Sets the appropriate selection after transforming a node to a target type
|
|
5
5
|
* @param newTr - The transaction containing the transformed node
|
|
@@ -7,4 +7,4 @@ import type { FormatNodeTargetType } from './transforms/types';
|
|
|
7
7
|
* @param targetType - The target type the node was transformed to
|
|
8
8
|
* @returns The transaction with the updated selection, or the original transaction if no selection change needed
|
|
9
9
|
*/
|
|
10
|
-
export declare const setSelectionAfterTransform: (newTr: Transaction, nodePos: number, targetType:
|
|
10
|
+
export declare const setSelectionAfterTransform: (newTr: Transaction, nodePos: number, targetType: TransfromNodeTargetType) => Transaction;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import type {
|
|
3
|
+
import type { TransfromNodeTargetType } from './types';
|
|
4
4
|
/**
|
|
5
5
|
* Transforms a source node to the specified target type.
|
|
6
6
|
* Throws errors on failure which should be caught at the command level.
|
|
@@ -11,4 +11,4 @@ import type { FormatNodeTargetType } from './types';
|
|
|
11
11
|
* @param targetType - The target node type to transform to
|
|
12
12
|
* @returns The modified transaction if successful, null if transformation is not possible
|
|
13
13
|
*/
|
|
14
|
-
export declare function transformNodeToTargetType(tr: Transaction, sourceNode: PMNode, sourcePos: number, targetType:
|
|
14
|
+
export declare function transformNodeToTargetType(tr: Transaction, sourceNode: PMNode, sourcePos: number, targetType: TransfromNodeTargetType): Transaction | null;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import type { TransformContext } from '@atlaskit/editor-common/transforms';
|
|
3
3
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
export type
|
|
5
|
-
export type
|
|
6
|
-
export type FormatNodeAnalyticsAttrs = {
|
|
4
|
+
export type TransfromNodeTargetType = 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6' | 'paragraph' | 'blockquote' | 'expand' | 'layoutSection' | 'panel' | 'codeBlock' | 'bulletList' | 'orderedList' | 'taskList' | 'decisionList';
|
|
5
|
+
export type TransformNodeMetadata = {
|
|
7
6
|
inputMethod: INPUT_METHOD.BLOCK_MENU;
|
|
8
|
-
triggeredFrom: INPUT_METHOD.MOUSE | INPUT_METHOD.KEYBOARD;
|
|
9
|
-
};
|
|
10
|
-
export type TransformNodeMetadata = FormatNodeAnalyticsAttrs & {
|
|
11
7
|
targetAttrs?: Record<string, unknown>;
|
|
12
8
|
targetTypeName: TransfromNodeTargetType;
|
|
9
|
+
triggeredFrom: INPUT_METHOD.MOUSE | INPUT_METHOD.KEYBOARD;
|
|
13
10
|
};
|
|
14
11
|
export type TransformFunction = (context: TransformContext) => Transaction | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Mark, Node as PMNode, NodeType, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
import type {
|
|
4
|
-
export declare const getTargetNodeInfo: (targetType:
|
|
3
|
+
import type { TransfromNodeTargetType } from './types';
|
|
4
|
+
export declare const getTargetNodeInfo: (targetType: TransfromNodeTargetType, nodes: Record<string, NodeType>) => {
|
|
5
5
|
attrs?: Record<string, unknown>;
|
|
6
6
|
nodeType: NodeType;
|
|
7
7
|
} | null;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { blockMenuPlugin } from './blockMenuPlugin';
|
|
2
2
|
export type { BlockMenuPlugin, RegisterBlockMenuComponent, Parent, BlockMenuPluginOptions, BlockMenuSharedState, } from './blockMenuPluginType';
|
|
3
|
-
export type { TransformNodeMetadata,
|
|
3
|
+
export type { TransformNodeMetadata, TransfromNodeTargetType, } from './editor-commands/transforms/types';
|
|
@@ -5,11 +5,10 @@ import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
|
5
5
|
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
6
6
|
import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
|
|
7
7
|
import type { NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
8
|
-
import type {
|
|
8
|
+
import type { TransformNodeMetadata } from './editor-commands/transforms/types';
|
|
9
9
|
export declare enum FLAG_ID {
|
|
10
10
|
LINK_COPIED_TO_CLIPBOARD = "link-copied-to-clipboard"
|
|
11
11
|
}
|
|
12
|
-
type FormatNodeCommand = (targetType: FormatNodeTargetType, analyticsAttrs?: FormatNodeAnalyticsAttrs) => EditorCommand;
|
|
13
12
|
type TransformNodeCommand = (targetType: NodeType, metadata?: TransformNodeMetadata) => EditorCommand;
|
|
14
13
|
export type BlockMenuPlugin = NextEditorPlugin<'blockMenu', {
|
|
15
14
|
actions: {
|
|
@@ -18,7 +17,6 @@ export type BlockMenuPlugin = NextEditorPlugin<'blockMenu', {
|
|
|
18
17
|
registerBlockMenuComponents: (blockMenuComponents: Array<RegisterBlockMenuComponent>) => void;
|
|
19
18
|
};
|
|
20
19
|
commands: {
|
|
21
|
-
formatNode: FormatNodeCommand;
|
|
22
20
|
transformNode: TransformNodeCommand;
|
|
23
21
|
};
|
|
24
22
|
dependencies: [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
import type {
|
|
2
|
+
import type { TransfromNodeTargetType } from './transforms/types';
|
|
3
3
|
/**
|
|
4
4
|
* Sets the appropriate selection after transforming a node to a target type
|
|
5
5
|
* @param newTr - The transaction containing the transformed node
|
|
@@ -7,4 +7,4 @@ import type { FormatNodeTargetType } from './transforms/types';
|
|
|
7
7
|
* @param targetType - The target type the node was transformed to
|
|
8
8
|
* @returns The transaction with the updated selection, or the original transaction if no selection change needed
|
|
9
9
|
*/
|
|
10
|
-
export declare const setSelectionAfterTransform: (newTr: Transaction, nodePos: number, targetType:
|
|
10
|
+
export declare const setSelectionAfterTransform: (newTr: Transaction, nodePos: number, targetType: TransfromNodeTargetType) => Transaction;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import type {
|
|
3
|
+
import type { TransfromNodeTargetType } from './types';
|
|
4
4
|
/**
|
|
5
5
|
* Transforms a source node to the specified target type.
|
|
6
6
|
* Throws errors on failure which should be caught at the command level.
|
|
@@ -11,4 +11,4 @@ import type { FormatNodeTargetType } from './types';
|
|
|
11
11
|
* @param targetType - The target node type to transform to
|
|
12
12
|
* @returns The modified transaction if successful, null if transformation is not possible
|
|
13
13
|
*/
|
|
14
|
-
export declare function transformNodeToTargetType(tr: Transaction, sourceNode: PMNode, sourcePos: number, targetType:
|
|
14
|
+
export declare function transformNodeToTargetType(tr: Transaction, sourceNode: PMNode, sourcePos: number, targetType: TransfromNodeTargetType): Transaction | null;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import type { TransformContext } from '@atlaskit/editor-common/transforms';
|
|
3
3
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
export type
|
|
5
|
-
export type
|
|
6
|
-
export type FormatNodeAnalyticsAttrs = {
|
|
4
|
+
export type TransfromNodeTargetType = 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6' | 'paragraph' | 'blockquote' | 'expand' | 'layoutSection' | 'panel' | 'codeBlock' | 'bulletList' | 'orderedList' | 'taskList' | 'decisionList';
|
|
5
|
+
export type TransformNodeMetadata = {
|
|
7
6
|
inputMethod: INPUT_METHOD.BLOCK_MENU;
|
|
8
|
-
triggeredFrom: INPUT_METHOD.MOUSE | INPUT_METHOD.KEYBOARD;
|
|
9
|
-
};
|
|
10
|
-
export type TransformNodeMetadata = FormatNodeAnalyticsAttrs & {
|
|
11
7
|
targetAttrs?: Record<string, unknown>;
|
|
12
8
|
targetTypeName: TransfromNodeTargetType;
|
|
9
|
+
triggeredFrom: INPUT_METHOD.MOUSE | INPUT_METHOD.KEYBOARD;
|
|
13
10
|
};
|
|
14
11
|
export type TransformFunction = (context: TransformContext) => Transaction | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Mark, Node as PMNode, NodeType, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
import type {
|
|
4
|
-
export declare const getTargetNodeInfo: (targetType:
|
|
3
|
+
import type { TransfromNodeTargetType } from './types';
|
|
4
|
+
export declare const getTargetNodeInfo: (targetType: TransfromNodeTargetType, nodes: Record<string, NodeType>) => {
|
|
5
5
|
attrs?: Record<string, unknown>;
|
|
6
6
|
nodeType: NodeType;
|
|
7
7
|
} | null;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { blockMenuPlugin } from './blockMenuPlugin';
|
|
2
2
|
export type { BlockMenuPlugin, RegisterBlockMenuComponent, Parent, BlockMenuPluginOptions, BlockMenuSharedState, } from './blockMenuPluginType';
|
|
3
|
-
export type { TransformNodeMetadata,
|
|
3
|
+
export type { TransformNodeMetadata, TransfromNodeTargetType, } from './editor-commands/transforms/types';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-menu",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.34",
|
|
4
4
|
"description": "BlockMenu plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@atlaskit/platform-feature-flags-react": "^0.4.0",
|
|
47
47
|
"@atlaskit/primitives": "^18.0.0",
|
|
48
48
|
"@atlaskit/prosemirror-history": "^0.2.0",
|
|
49
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
49
|
+
"@atlaskit/tmp-editor-statsig": "^20.3.0",
|
|
50
50
|
"@atlaskit/tokens": "^11.0.0",
|
|
51
51
|
"@babel/runtime": "^7.0.0",
|
|
52
52
|
"bind-event-listener": "^3.0.0"
|