@atlaskit/editor-plugin-block-menu 6.0.20 → 6.0.22
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/afm-jira/tsconfig.json +4 -1
- package/afm-products/tsconfig.json +3 -0
- package/dist/cjs/editor-commands/transformNode.js +8 -10
- package/dist/cjs/ui/MenuSection.js +21 -0
- package/dist/cjs/ui/block-menu-components.js +26 -6
- package/dist/cjs/ui/delete-button.js +1 -4
- package/dist/cjs/ui/suggested-items-menu-section.js +5 -1
- package/dist/es2019/editor-commands/transformNode.js +6 -8
- package/dist/es2019/ui/MenuSection.js +16 -0
- package/dist/es2019/ui/block-menu-components.js +24 -6
- package/dist/es2019/ui/delete-button.js +1 -4
- package/dist/es2019/ui/suggested-items-menu-section.js +6 -1
- package/dist/esm/editor-commands/transformNode.js +9 -10
- package/dist/esm/ui/MenuSection.js +14 -0
- package/dist/esm/ui/block-menu-components.js +26 -6
- package/dist/esm/ui/delete-button.js +1 -4
- package/dist/esm/ui/suggested-items-menu-section.js +5 -1
- package/dist/types/ui/MenuSection.d.ts +9 -0
- package/dist/types-ts4.5/ui/MenuSection.d.ts +9 -0
- package/package.json +3 -3
- package/build/tsconfig.json +0 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-menu
|
|
2
2
|
|
|
3
|
+
## 6.0.22
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`33f11753a7104`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/33f11753a7104) -
|
|
8
|
+
[ux] Added i18n for sections' titles in the Turn into menu.
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 6.0.21
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`b30d6077b3e91`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b30d6077b3e91) -
|
|
16
|
+
[ux] Suggested section should be hidden when total number to native transfroms is less than 7.
|
|
17
|
+
- [`265980d7959cf`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/265980d7959cf) -
|
|
18
|
+
[ux] recursive node decoration and 'selected danger' classname
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 6.0.20
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/afm-jira/tsconfig.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": "../../../../tsconfig.
|
|
2
|
+
"extends": "../../../../tsconfig.local-consumption.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"target": "es5",
|
|
5
5
|
"outDir": "../../../../../jira/tsDist/@atlaskit__editor-plugin-block-menu/app",
|
|
@@ -69,6 +69,9 @@
|
|
|
69
69
|
{
|
|
70
70
|
"path": "../../../design-system/primitives/afm-jira/tsconfig.json"
|
|
71
71
|
},
|
|
72
|
+
{
|
|
73
|
+
"path": "../../prosemirror-history/afm-jira/tsconfig.json"
|
|
74
|
+
},
|
|
72
75
|
{
|
|
73
76
|
"path": "../../tmp-editor-statsig/afm-jira/tsconfig.json"
|
|
74
77
|
},
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.transformNode = void 0;
|
|
8
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
7
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
8
|
var _performanceMeasures = require("@atlaskit/editor-common/performance-measures");
|
|
11
9
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
@@ -33,10 +31,7 @@ var transformNode = exports.transformNode = function transformNode(api) {
|
|
|
33
31
|
var isParentLayout = selectedParent.type === nodes.layoutColumn;
|
|
34
32
|
var isNested = (0, _isNestedNode.isNestedNode)(preservedSelection, '') && !isParentLayout;
|
|
35
33
|
var isList = (0, _utils.isListNode)(selectedParent);
|
|
36
|
-
var
|
|
37
|
-
var sliceEnd = isList ? $to.pos + 1 : $to.pos;
|
|
38
|
-
var slice = tr.doc.slice(sliceStart, sliceEnd);
|
|
39
|
-
var sourceNodes = (0, _toConsumableArray2.default)(slice.content.content);
|
|
34
|
+
var sourceNodes = (0, _selection.getSourceNodesFromSelectionRange)(tr, preservedSelection);
|
|
40
35
|
var sourceNodeTypes = {};
|
|
41
36
|
sourceNodes.forEach(function (node) {
|
|
42
37
|
var typeName = node.type.name;
|
|
@@ -50,7 +45,8 @@ var transformNode = exports.transformNode = function transformNode(api) {
|
|
|
50
45
|
targetAttrs: metadata === null || metadata === void 0 ? void 0 : metadata.targetAttrs,
|
|
51
46
|
parentNode: selectedParent
|
|
52
47
|
});
|
|
53
|
-
var content = resultNodes.length > 0 ? resultNodes :
|
|
48
|
+
var content = resultNodes.length > 0 ? resultNodes : sourceNodes;
|
|
49
|
+
var sliceStart = isList ? $from.pos - 1 : $from.pos;
|
|
54
50
|
if (preservedSelection instanceof _state.NodeSelection && preservedSelection.node.type === nodes.mediaSingle) {
|
|
55
51
|
var _api$blockControls2;
|
|
56
52
|
// when node is media single, use tr.replaceWith freeze editor, if modify position, tr.replaceWith creates duplicats
|
|
@@ -65,10 +61,12 @@ var transformNode = exports.transformNode = function transformNode(api) {
|
|
|
65
61
|
// when we replace and insert content, we need to manually map the preserved selection
|
|
66
62
|
// through the transaction, otherwise it will treat the selection as having been deleted
|
|
67
63
|
// and stop preserving it
|
|
68
|
-
var oldSize =
|
|
69
|
-
|
|
64
|
+
var oldSize = sourceNodes.reduce(function (sum, node) {
|
|
65
|
+
return sum + node.nodeSize;
|
|
66
|
+
}, 0);
|
|
67
|
+
var newSize = content.reduce(function (sum, node) {
|
|
70
68
|
return sum + node.nodeSize;
|
|
71
|
-
}, 0)
|
|
69
|
+
}, 0);
|
|
72
70
|
api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || _api$blockControls2.commands.mapPreservedSelection(new _transform.Mapping([new _transform.StepMap([0, oldSize, newSize])]))({
|
|
73
71
|
tr: tr
|
|
74
72
|
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.MenuSection = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _reactIntlNext = require("react-intl-next");
|
|
10
|
+
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
11
|
+
var MenuSection = exports.MenuSection = function MenuSection(_ref) {
|
|
12
|
+
var children = _ref.children,
|
|
13
|
+
title = _ref.title,
|
|
14
|
+
hasSeparator = _ref.hasSeparator;
|
|
15
|
+
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
16
|
+
formatMessage = _useIntl.formatMessage;
|
|
17
|
+
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
|
|
18
|
+
title: formatMessage(title),
|
|
19
|
+
hasSeparator: hasSeparator
|
|
20
|
+
}, children);
|
|
21
|
+
};
|
|
@@ -8,19 +8,36 @@ exports.getBlockMenuComponents = void 0;
|
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _blockMenu = require("@atlaskit/editor-common/block-menu");
|
|
11
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
11
12
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
13
|
+
var _utils = require("./block-menu-renderer/utils");
|
|
12
14
|
var _copyLink = require("./copy-link");
|
|
13
15
|
var _copySection = require("./copy-section");
|
|
14
16
|
var _deleteButton = require("./delete-button");
|
|
15
17
|
var _deleteSection = require("./delete-section");
|
|
16
18
|
var _formatMenuNested = require("./format-menu-nested");
|
|
17
19
|
var _formatMenuSection = require("./format-menu-section");
|
|
20
|
+
var _MenuSection = require("./MenuSection");
|
|
18
21
|
var _moveDown = require("./move-down");
|
|
19
22
|
var _moveUp = require("./move-up");
|
|
20
23
|
var _suggestedItemsMenuSection = require("./suggested-items-menu-section");
|
|
21
24
|
var _suggestedMenuItems = require("./suggested-menu-items");
|
|
22
25
|
var _createMenuItemsMap = require("./utils/createMenuItemsMap");
|
|
23
26
|
var _getSuggestedItemsFromSelection = require("./utils/getSuggestedItemsFromSelection");
|
|
27
|
+
var MIN_NUMBER_OF_AVAILABLE_NATIVE_TRANSFORMS = 7;
|
|
28
|
+
var getTotalNumberOfAvailableNativeTransforms = function getTotalNumberOfAvailableNativeTransforms(blockMenuComponents) {
|
|
29
|
+
if (!blockMenuComponents) {
|
|
30
|
+
return 0;
|
|
31
|
+
}
|
|
32
|
+
var childrenMap = (0, _utils.buildChildrenMap)(blockMenuComponents);
|
|
33
|
+
var headingsKey = (0, _utils.getChildrenMapKey)(_blockMenu.TRANSFORM_HEADINGS_MENU_SECTION.key, 'block-menu-section');
|
|
34
|
+
var structureKey = (0, _utils.getChildrenMapKey)(_blockMenu.TRANSFORM_STRUCTURE_MENU_SECTION.key, 'block-menu-section');
|
|
35
|
+
var headingsChildren = childrenMap.get(headingsKey) || [];
|
|
36
|
+
var structureChildren = childrenMap.get(structureKey) || [];
|
|
37
|
+
return [].concat((0, _toConsumableArray2.default)(headingsChildren), (0, _toConsumableArray2.default)(structureChildren)).filter(function (c) {
|
|
38
|
+
return (0, _utils.willComponentRender)(c, childrenMap);
|
|
39
|
+
}).length;
|
|
40
|
+
};
|
|
24
41
|
var getMoveUpMoveDownMenuComponents = function getMoveUpMoveDownMenuComponents(api) {
|
|
25
42
|
return [{
|
|
26
43
|
type: 'block-menu-item',
|
|
@@ -101,6 +118,9 @@ var getTurnIntoMenuComponents = function getTurnIntoMenuComponents(api) {
|
|
|
101
118
|
isHidden: function isHidden() {
|
|
102
119
|
var _api$blockMenu, _api$selection, _api$blockControls;
|
|
103
120
|
var blockMenuComponents = api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.actions.getBlockMenuComponents();
|
|
121
|
+
if (getTotalNumberOfAvailableNativeTransforms(blockMenuComponents) < MIN_NUMBER_OF_AVAILABLE_NATIVE_TRANSFORMS) {
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
104
124
|
var menuItemsMap = (0, _createMenuItemsMap.createMenuItemsMap)(blockMenuComponents);
|
|
105
125
|
var selection = api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 || (_api$selection = _api$selection.sharedState.currentState()) === null || _api$selection === void 0 ? void 0 : _api$selection.selection;
|
|
106
126
|
var preservedSelection = api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.sharedState.currentState()) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.preservedSelection;
|
|
@@ -121,8 +141,8 @@ var getTurnIntoMenuComponents = function getTurnIntoMenuComponents(api) {
|
|
|
121
141
|
children: null
|
|
122
142
|
},
|
|
123
143
|
children = _ref3.children;
|
|
124
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
125
|
-
title:
|
|
144
|
+
return /*#__PURE__*/_react.default.createElement(_MenuSection.MenuSection, {
|
|
145
|
+
title: _messages.blockMenuMessages.create
|
|
126
146
|
}, children);
|
|
127
147
|
}
|
|
128
148
|
}, {
|
|
@@ -138,8 +158,8 @@ var getTurnIntoMenuComponents = function getTurnIntoMenuComponents(api) {
|
|
|
138
158
|
children: null
|
|
139
159
|
},
|
|
140
160
|
children = _ref4.children;
|
|
141
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
142
|
-
title:
|
|
161
|
+
return /*#__PURE__*/_react.default.createElement(_MenuSection.MenuSection, {
|
|
162
|
+
title: _messages.blockMenuMessages.structure
|
|
143
163
|
}, children);
|
|
144
164
|
}
|
|
145
165
|
}, {
|
|
@@ -155,8 +175,8 @@ var getTurnIntoMenuComponents = function getTurnIntoMenuComponents(api) {
|
|
|
155
175
|
children: null
|
|
156
176
|
},
|
|
157
177
|
children = _ref5.children;
|
|
158
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
159
|
-
title:
|
|
178
|
+
return /*#__PURE__*/_react.default.createElement(_MenuSection.MenuSection, {
|
|
179
|
+
title: _messages.blockMenuMessages.headings,
|
|
160
180
|
hasSeparator: true
|
|
161
181
|
}, children);
|
|
162
182
|
}
|
|
@@ -18,11 +18,9 @@ var _text = _interopRequireDefault(require("@atlaskit/primitives/text"));
|
|
|
18
18
|
var _consts = require("./consts");
|
|
19
19
|
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); }
|
|
20
20
|
var DeleteDropdownItemContent = function DeleteDropdownItemContent(_ref) {
|
|
21
|
-
var _api$core$sharedState;
|
|
22
21
|
var api = _ref.api;
|
|
23
22
|
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
24
23
|
formatMessage = _useIntl.formatMessage;
|
|
25
|
-
var nodeTypes = Object.values((api === null || api === void 0 || (_api$core$sharedState = api.core.sharedState.currentState()) === null || _api$core$sharedState === void 0 || (_api$core$sharedState = _api$core$sharedState.schema) === null || _api$core$sharedState === void 0 ? void 0 : _api$core$sharedState.nodes) || {});
|
|
26
24
|
var onClick = function onClick() {
|
|
27
25
|
api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
|
|
28
26
|
var _api$analytics, _api$blockControls, _api$blockControls2;
|
|
@@ -51,14 +49,13 @@ var DeleteDropdownItemContent = function DeleteDropdownItemContent(_ref) {
|
|
|
51
49
|
var _api$decorations, _api$decorations$hove;
|
|
52
50
|
var tr = _ref3.tr;
|
|
53
51
|
api === null || api === void 0 || (_api$decorations = api.decorations) === null || _api$decorations === void 0 || (_api$decorations = _api$decorations.commands) === null || _api$decorations === void 0 || (_api$decorations$hove = _api$decorations.hoverDecoration) === null || _api$decorations$hove === void 0 || _api$decorations$hove.call(_api$decorations, {
|
|
54
|
-
nodeType: nodeTypes,
|
|
55
52
|
add: true
|
|
56
53
|
})({
|
|
57
54
|
tr: tr
|
|
58
55
|
});
|
|
59
56
|
return tr;
|
|
60
57
|
});
|
|
61
|
-
}, [api
|
|
58
|
+
}, [api]);
|
|
62
59
|
var onRemoveHoverDecoration = (0, _react.useCallback)(function () {
|
|
63
60
|
api === null || api === void 0 || api.core.actions.execute(function (_ref4) {
|
|
64
61
|
var _api$decorations2, _api$decorations2$rem;
|
|
@@ -6,16 +6,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.SuggestedItemsMenuSection = 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 _useSuggestedItems = require("./hooks/useSuggestedItems");
|
|
11
13
|
var SuggestedItemsMenuSection = exports.SuggestedItemsMenuSection = /*#__PURE__*/_react.default.memo(function (_ref) {
|
|
12
14
|
var api = _ref.api,
|
|
13
15
|
children = _ref.children;
|
|
14
16
|
var suggestedItems = (0, _useSuggestedItems.useSuggestedItems)(api);
|
|
17
|
+
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
18
|
+
formatMessage = _useIntl.formatMessage;
|
|
15
19
|
if (suggestedItems.length === 0) {
|
|
16
20
|
return null;
|
|
17
21
|
}
|
|
18
22
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
|
|
19
|
-
title:
|
|
23
|
+
title: formatMessage(_messages.blockMenuMessages.suggested)
|
|
20
24
|
}, children);
|
|
21
25
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
|
|
3
|
-
import { expandSelectionToBlockRange } from '@atlaskit/editor-common/selection';
|
|
3
|
+
import { expandSelectionToBlockRange, getSourceNodesFromSelectionRange } from '@atlaskit/editor-common/selection';
|
|
4
4
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import { Mapping, StepMap } from '@atlaskit/editor-prosemirror/transform';
|
|
6
6
|
import { isNestedNode } from '../ui/utils/isNestedNode';
|
|
@@ -27,10 +27,7 @@ export const transformNode = api => (targetType, metadata) => ({
|
|
|
27
27
|
const isParentLayout = selectedParent.type === nodes.layoutColumn;
|
|
28
28
|
const isNested = isNestedNode(preservedSelection, '') && !isParentLayout;
|
|
29
29
|
const isList = isListNode(selectedParent);
|
|
30
|
-
const
|
|
31
|
-
const sliceEnd = isList ? $to.pos + 1 : $to.pos;
|
|
32
|
-
const slice = tr.doc.slice(sliceStart, sliceEnd);
|
|
33
|
-
const sourceNodes = [...slice.content.content];
|
|
30
|
+
const sourceNodes = getSourceNodesFromSelectionRange(tr, preservedSelection);
|
|
34
31
|
const sourceNodeTypes = {};
|
|
35
32
|
sourceNodes.forEach(node => {
|
|
36
33
|
const typeName = node.type.name;
|
|
@@ -44,7 +41,8 @@ export const transformNode = api => (targetType, metadata) => ({
|
|
|
44
41
|
targetAttrs: metadata === null || metadata === void 0 ? void 0 : metadata.targetAttrs,
|
|
45
42
|
parentNode: selectedParent
|
|
46
43
|
});
|
|
47
|
-
const content = resultNodes.length > 0 ? resultNodes :
|
|
44
|
+
const content = resultNodes.length > 0 ? resultNodes : sourceNodes;
|
|
45
|
+
const sliceStart = isList ? $from.pos - 1 : $from.pos;
|
|
48
46
|
if (preservedSelection instanceof NodeSelection && preservedSelection.node.type === nodes.mediaSingle) {
|
|
49
47
|
var _api$blockControls2;
|
|
50
48
|
// when node is media single, use tr.replaceWith freeze editor, if modify position, tr.replaceWith creates duplicats
|
|
@@ -59,8 +57,8 @@ export const transformNode = api => (targetType, metadata) => ({
|
|
|
59
57
|
// when we replace and insert content, we need to manually map the preserved selection
|
|
60
58
|
// through the transaction, otherwise it will treat the selection as having been deleted
|
|
61
59
|
// and stop preserving it
|
|
62
|
-
const oldSize =
|
|
63
|
-
const newSize =
|
|
60
|
+
const oldSize = sourceNodes.reduce((sum, node) => sum + node.nodeSize, 0);
|
|
61
|
+
const newSize = content.reduce((sum, node) => sum + node.nodeSize, 0);
|
|
64
62
|
api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.commands.mapPreservedSelection(new Mapping([new StepMap([0, oldSize, newSize])]))({
|
|
65
63
|
tr
|
|
66
64
|
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl-next';
|
|
3
|
+
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
4
|
+
export const MenuSection = ({
|
|
5
|
+
children,
|
|
6
|
+
title,
|
|
7
|
+
hasSeparator
|
|
8
|
+
}) => {
|
|
9
|
+
const {
|
|
10
|
+
formatMessage
|
|
11
|
+
} = useIntl();
|
|
12
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
13
|
+
title: formatMessage(title),
|
|
14
|
+
hasSeparator: hasSeparator
|
|
15
|
+
}, children);
|
|
16
|
+
};
|
|
@@ -1,18 +1,33 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { BLOCK_ACTIONS_COPY_LINK_TO_BLOCK_MENU_ITEM, BLOCK_ACTIONS_MENU_SECTION, BLOCK_ACTIONS_MENU_SECTION_RANK, DELETE_MENU_SECTION, DELETE_MENU_SECTION_RANK, DELETE_MENU_ITEM, POSITION_MENU_SECTION, POSITION_MENU_SECTION_RANK, POSITION_MOVE_DOWN_MENU_ITEM, POSITION_MOVE_UP_MENU_ITEM, TRANSFORM_MENU_ITEM, TRANSFORM_MENU_ITEM_RANK, TRANSFORM_MENU_SECTION, TRANSFORM_MENU_SECTION_RANK, TRANSFORM_CREATE_MENU_SECTION, TRANSFORM_SUGGESTED_MENU_SECTION, TRANSFORM_STRUCTURE_MENU_SECTION, TRANSFORM_HEADINGS_MENU_SECTION, MAIN_BLOCK_MENU_SECTION_RANK, TRANSFORM_SUGGESTED_MENU_SECTION_RANK, TRANSFORM_SUGGESTED_MENU_ITEM } from '@atlaskit/editor-common/block-menu';
|
|
3
|
+
import { blockMenuMessages } from '@atlaskit/editor-common/messages';
|
|
3
4
|
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
5
|
+
import { buildChildrenMap, getChildrenMapKey, willComponentRender } from './block-menu-renderer/utils';
|
|
4
6
|
import { CopyLinkDropdownItem } from './copy-link';
|
|
5
7
|
import { CopySection } from './copy-section';
|
|
6
8
|
import { DeleteDropdownItem } from './delete-button';
|
|
7
9
|
import { DeleteSection } from './delete-section';
|
|
8
10
|
import { FormatMenuComponent } from './format-menu-nested';
|
|
9
11
|
import { FormatMenuSection } from './format-menu-section';
|
|
12
|
+
import { MenuSection } from './MenuSection';
|
|
10
13
|
import { MoveDownDropdownItem } from './move-down';
|
|
11
14
|
import { MoveUpDropdownItem } from './move-up';
|
|
12
15
|
import { SuggestedItemsMenuSection } from './suggested-items-menu-section';
|
|
13
16
|
import { SuggestedMenuItems } from './suggested-menu-items';
|
|
14
17
|
import { createMenuItemsMap } from './utils/createMenuItemsMap';
|
|
15
18
|
import { getSuggestedItemsFromSelection } from './utils/getSuggestedItemsFromSelection';
|
|
19
|
+
const MIN_NUMBER_OF_AVAILABLE_NATIVE_TRANSFORMS = 7;
|
|
20
|
+
const getTotalNumberOfAvailableNativeTransforms = blockMenuComponents => {
|
|
21
|
+
if (!blockMenuComponents) {
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
const childrenMap = buildChildrenMap(blockMenuComponents);
|
|
25
|
+
const headingsKey = getChildrenMapKey(TRANSFORM_HEADINGS_MENU_SECTION.key, 'block-menu-section');
|
|
26
|
+
const structureKey = getChildrenMapKey(TRANSFORM_STRUCTURE_MENU_SECTION.key, 'block-menu-section');
|
|
27
|
+
const headingsChildren = childrenMap.get(headingsKey) || [];
|
|
28
|
+
const structureChildren = childrenMap.get(structureKey) || [];
|
|
29
|
+
return [...headingsChildren, ...structureChildren].filter(c => willComponentRender(c, childrenMap)).length;
|
|
30
|
+
};
|
|
16
31
|
const getMoveUpMoveDownMenuComponents = api => {
|
|
17
32
|
return [{
|
|
18
33
|
type: 'block-menu-item',
|
|
@@ -85,6 +100,9 @@ const getTurnIntoMenuComponents = api => {
|
|
|
85
100
|
isHidden: () => {
|
|
86
101
|
var _api$blockMenu, _api$selection, _api$selection$shared, _api$blockControls, _api$blockControls$sh;
|
|
87
102
|
const blockMenuComponents = api === null || api === void 0 ? void 0 : (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.actions.getBlockMenuComponents();
|
|
103
|
+
if (getTotalNumberOfAvailableNativeTransforms(blockMenuComponents) < MIN_NUMBER_OF_AVAILABLE_NATIVE_TRANSFORMS) {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
88
106
|
const menuItemsMap = createMenuItemsMap(blockMenuComponents);
|
|
89
107
|
const selection = api === null || api === void 0 ? void 0 : (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : (_api$selection$shared = _api$selection.sharedState.currentState()) === null || _api$selection$shared === void 0 ? void 0 : _api$selection$shared.selection;
|
|
90
108
|
const preservedSelection = api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : (_api$blockControls$sh = _api$blockControls.sharedState.currentState()) === null || _api$blockControls$sh === void 0 ? void 0 : _api$blockControls$sh.preservedSelection;
|
|
@@ -105,8 +123,8 @@ const getTurnIntoMenuComponents = api => {
|
|
|
105
123
|
} = {
|
|
106
124
|
children: null
|
|
107
125
|
}) => {
|
|
108
|
-
return /*#__PURE__*/React.createElement(
|
|
109
|
-
title:
|
|
126
|
+
return /*#__PURE__*/React.createElement(MenuSection, {
|
|
127
|
+
title: blockMenuMessages.create
|
|
110
128
|
}, children);
|
|
111
129
|
}
|
|
112
130
|
}, {
|
|
@@ -122,8 +140,8 @@ const getTurnIntoMenuComponents = api => {
|
|
|
122
140
|
} = {
|
|
123
141
|
children: null
|
|
124
142
|
}) => {
|
|
125
|
-
return /*#__PURE__*/React.createElement(
|
|
126
|
-
title:
|
|
143
|
+
return /*#__PURE__*/React.createElement(MenuSection, {
|
|
144
|
+
title: blockMenuMessages.structure
|
|
127
145
|
}, children);
|
|
128
146
|
}
|
|
129
147
|
}, {
|
|
@@ -139,8 +157,8 @@ const getTurnIntoMenuComponents = api => {
|
|
|
139
157
|
} = {
|
|
140
158
|
children: null
|
|
141
159
|
}) => {
|
|
142
|
-
return /*#__PURE__*/React.createElement(
|
|
143
|
-
title:
|
|
160
|
+
return /*#__PURE__*/React.createElement(MenuSection, {
|
|
161
|
+
title: blockMenuMessages.headings,
|
|
144
162
|
hasSeparator: true
|
|
145
163
|
}, children);
|
|
146
164
|
}
|
|
@@ -11,11 +11,9 @@ import { BLOCK_MENU_ITEM_NAME } from './consts';
|
|
|
11
11
|
const DeleteDropdownItemContent = ({
|
|
12
12
|
api
|
|
13
13
|
}) => {
|
|
14
|
-
var _api$core$sharedState, _api$core$sharedState2;
|
|
15
14
|
const {
|
|
16
15
|
formatMessage
|
|
17
16
|
} = useIntl();
|
|
18
|
-
const nodeTypes = Object.values((api === null || api === void 0 ? void 0 : (_api$core$sharedState = api.core.sharedState.currentState()) === null || _api$core$sharedState === void 0 ? void 0 : (_api$core$sharedState2 = _api$core$sharedState.schema) === null || _api$core$sharedState2 === void 0 ? void 0 : _api$core$sharedState2.nodes) || {});
|
|
19
17
|
const onClick = () => {
|
|
20
18
|
api === null || api === void 0 ? void 0 : api.core.actions.execute(({
|
|
21
19
|
tr
|
|
@@ -46,14 +44,13 @@ const DeleteDropdownItemContent = ({
|
|
|
46
44
|
}) => {
|
|
47
45
|
var _api$decorations, _api$decorations$comm, _api$decorations$comm2;
|
|
48
46
|
api === null || api === void 0 ? void 0 : (_api$decorations = api.decorations) === null || _api$decorations === void 0 ? void 0 : (_api$decorations$comm = _api$decorations.commands) === null || _api$decorations$comm === void 0 ? void 0 : (_api$decorations$comm2 = _api$decorations$comm.hoverDecoration) === null || _api$decorations$comm2 === void 0 ? void 0 : _api$decorations$comm2.call(_api$decorations$comm, {
|
|
49
|
-
nodeType: nodeTypes,
|
|
50
47
|
add: true
|
|
51
48
|
})({
|
|
52
49
|
tr
|
|
53
50
|
});
|
|
54
51
|
return tr;
|
|
55
52
|
});
|
|
56
|
-
}, [api
|
|
53
|
+
}, [api]);
|
|
57
54
|
const onRemoveHoverDecoration = useCallback(() => {
|
|
58
55
|
api === null || api === void 0 ? void 0 : api.core.actions.execute(({
|
|
59
56
|
tr
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl-next';
|
|
3
|
+
import { blockMenuMessages } from '@atlaskit/editor-common/messages';
|
|
2
4
|
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
3
5
|
import { useSuggestedItems } from './hooks/useSuggestedItems';
|
|
4
6
|
export const SuggestedItemsMenuSection = /*#__PURE__*/React.memo(({
|
|
@@ -6,10 +8,13 @@ export const SuggestedItemsMenuSection = /*#__PURE__*/React.memo(({
|
|
|
6
8
|
children
|
|
7
9
|
}) => {
|
|
8
10
|
const suggestedItems = useSuggestedItems(api);
|
|
11
|
+
const {
|
|
12
|
+
formatMessage
|
|
13
|
+
} = useIntl();
|
|
9
14
|
if (suggestedItems.length === 0) {
|
|
10
15
|
return null;
|
|
11
16
|
}
|
|
12
17
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
13
|
-
title:
|
|
18
|
+
title: formatMessage(blockMenuMessages.suggested)
|
|
14
19
|
}, children);
|
|
15
20
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
3
2
|
import { startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
|
|
4
|
-
import { expandSelectionToBlockRange } from '@atlaskit/editor-common/selection';
|
|
3
|
+
import { expandSelectionToBlockRange, getSourceNodesFromSelectionRange } from '@atlaskit/editor-common/selection';
|
|
5
4
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
5
|
import { Mapping, StepMap } from '@atlaskit/editor-prosemirror/transform';
|
|
7
6
|
import { isNestedNode } from '../ui/utils/isNestedNode';
|
|
@@ -26,10 +25,7 @@ export var transformNode = function transformNode(api) {
|
|
|
26
25
|
var isParentLayout = selectedParent.type === nodes.layoutColumn;
|
|
27
26
|
var isNested = isNestedNode(preservedSelection, '') && !isParentLayout;
|
|
28
27
|
var isList = isListNode(selectedParent);
|
|
29
|
-
var
|
|
30
|
-
var sliceEnd = isList ? $to.pos + 1 : $to.pos;
|
|
31
|
-
var slice = tr.doc.slice(sliceStart, sliceEnd);
|
|
32
|
-
var sourceNodes = _toConsumableArray(slice.content.content);
|
|
28
|
+
var sourceNodes = getSourceNodesFromSelectionRange(tr, preservedSelection);
|
|
33
29
|
var sourceNodeTypes = {};
|
|
34
30
|
sourceNodes.forEach(function (node) {
|
|
35
31
|
var typeName = node.type.name;
|
|
@@ -43,7 +39,8 @@ export var transformNode = function transformNode(api) {
|
|
|
43
39
|
targetAttrs: metadata === null || metadata === void 0 ? void 0 : metadata.targetAttrs,
|
|
44
40
|
parentNode: selectedParent
|
|
45
41
|
});
|
|
46
|
-
var content = resultNodes.length > 0 ? resultNodes :
|
|
42
|
+
var content = resultNodes.length > 0 ? resultNodes : sourceNodes;
|
|
43
|
+
var sliceStart = isList ? $from.pos - 1 : $from.pos;
|
|
47
44
|
if (preservedSelection instanceof NodeSelection && preservedSelection.node.type === nodes.mediaSingle) {
|
|
48
45
|
var _api$blockControls2;
|
|
49
46
|
// when node is media single, use tr.replaceWith freeze editor, if modify position, tr.replaceWith creates duplicats
|
|
@@ -58,10 +55,12 @@ export var transformNode = function transformNode(api) {
|
|
|
58
55
|
// when we replace and insert content, we need to manually map the preserved selection
|
|
59
56
|
// through the transaction, otherwise it will treat the selection as having been deleted
|
|
60
57
|
// and stop preserving it
|
|
61
|
-
var oldSize =
|
|
62
|
-
|
|
58
|
+
var oldSize = sourceNodes.reduce(function (sum, node) {
|
|
59
|
+
return sum + node.nodeSize;
|
|
60
|
+
}, 0);
|
|
61
|
+
var newSize = content.reduce(function (sum, node) {
|
|
63
62
|
return sum + node.nodeSize;
|
|
64
|
-
}, 0)
|
|
63
|
+
}, 0);
|
|
65
64
|
api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || _api$blockControls2.commands.mapPreservedSelection(new Mapping([new StepMap([0, oldSize, newSize])]))({
|
|
66
65
|
tr: tr
|
|
67
66
|
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl-next';
|
|
3
|
+
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
4
|
+
export var MenuSection = function MenuSection(_ref) {
|
|
5
|
+
var children = _ref.children,
|
|
6
|
+
title = _ref.title,
|
|
7
|
+
hasSeparator = _ref.hasSeparator;
|
|
8
|
+
var _useIntl = useIntl(),
|
|
9
|
+
formatMessage = _useIntl.formatMessage;
|
|
10
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
11
|
+
title: formatMessage(title),
|
|
12
|
+
hasSeparator: hasSeparator
|
|
13
|
+
}, children);
|
|
14
|
+
};
|
|
@@ -1,19 +1,36 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { BLOCK_ACTIONS_COPY_LINK_TO_BLOCK_MENU_ITEM, BLOCK_ACTIONS_MENU_SECTION, BLOCK_ACTIONS_MENU_SECTION_RANK, DELETE_MENU_SECTION, DELETE_MENU_SECTION_RANK, DELETE_MENU_ITEM, POSITION_MENU_SECTION, POSITION_MENU_SECTION_RANK, POSITION_MOVE_DOWN_MENU_ITEM, POSITION_MOVE_UP_MENU_ITEM, TRANSFORM_MENU_ITEM, TRANSFORM_MENU_ITEM_RANK, TRANSFORM_MENU_SECTION, TRANSFORM_MENU_SECTION_RANK, TRANSFORM_CREATE_MENU_SECTION, TRANSFORM_SUGGESTED_MENU_SECTION, TRANSFORM_STRUCTURE_MENU_SECTION, TRANSFORM_HEADINGS_MENU_SECTION, MAIN_BLOCK_MENU_SECTION_RANK, TRANSFORM_SUGGESTED_MENU_SECTION_RANK, TRANSFORM_SUGGESTED_MENU_ITEM } from '@atlaskit/editor-common/block-menu';
|
|
4
|
+
import { blockMenuMessages } from '@atlaskit/editor-common/messages';
|
|
4
5
|
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
6
|
+
import { buildChildrenMap, getChildrenMapKey, willComponentRender } from './block-menu-renderer/utils';
|
|
5
7
|
import { CopyLinkDropdownItem } from './copy-link';
|
|
6
8
|
import { CopySection } from './copy-section';
|
|
7
9
|
import { DeleteDropdownItem } from './delete-button';
|
|
8
10
|
import { DeleteSection } from './delete-section';
|
|
9
11
|
import { FormatMenuComponent } from './format-menu-nested';
|
|
10
12
|
import { FormatMenuSection } from './format-menu-section';
|
|
13
|
+
import { MenuSection } from './MenuSection';
|
|
11
14
|
import { MoveDownDropdownItem } from './move-down';
|
|
12
15
|
import { MoveUpDropdownItem } from './move-up';
|
|
13
16
|
import { SuggestedItemsMenuSection } from './suggested-items-menu-section';
|
|
14
17
|
import { SuggestedMenuItems } from './suggested-menu-items';
|
|
15
18
|
import { createMenuItemsMap } from './utils/createMenuItemsMap';
|
|
16
19
|
import { getSuggestedItemsFromSelection } from './utils/getSuggestedItemsFromSelection';
|
|
20
|
+
var MIN_NUMBER_OF_AVAILABLE_NATIVE_TRANSFORMS = 7;
|
|
21
|
+
var getTotalNumberOfAvailableNativeTransforms = function getTotalNumberOfAvailableNativeTransforms(blockMenuComponents) {
|
|
22
|
+
if (!blockMenuComponents) {
|
|
23
|
+
return 0;
|
|
24
|
+
}
|
|
25
|
+
var childrenMap = buildChildrenMap(blockMenuComponents);
|
|
26
|
+
var headingsKey = getChildrenMapKey(TRANSFORM_HEADINGS_MENU_SECTION.key, 'block-menu-section');
|
|
27
|
+
var structureKey = getChildrenMapKey(TRANSFORM_STRUCTURE_MENU_SECTION.key, 'block-menu-section');
|
|
28
|
+
var headingsChildren = childrenMap.get(headingsKey) || [];
|
|
29
|
+
var structureChildren = childrenMap.get(structureKey) || [];
|
|
30
|
+
return [].concat(_toConsumableArray(headingsChildren), _toConsumableArray(structureChildren)).filter(function (c) {
|
|
31
|
+
return willComponentRender(c, childrenMap);
|
|
32
|
+
}).length;
|
|
33
|
+
};
|
|
17
34
|
var getMoveUpMoveDownMenuComponents = function getMoveUpMoveDownMenuComponents(api) {
|
|
18
35
|
return [{
|
|
19
36
|
type: 'block-menu-item',
|
|
@@ -94,6 +111,9 @@ var getTurnIntoMenuComponents = function getTurnIntoMenuComponents(api) {
|
|
|
94
111
|
isHidden: function isHidden() {
|
|
95
112
|
var _api$blockMenu, _api$selection, _api$blockControls;
|
|
96
113
|
var blockMenuComponents = api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.actions.getBlockMenuComponents();
|
|
114
|
+
if (getTotalNumberOfAvailableNativeTransforms(blockMenuComponents) < MIN_NUMBER_OF_AVAILABLE_NATIVE_TRANSFORMS) {
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
97
117
|
var menuItemsMap = createMenuItemsMap(blockMenuComponents);
|
|
98
118
|
var selection = api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 || (_api$selection = _api$selection.sharedState.currentState()) === null || _api$selection === void 0 ? void 0 : _api$selection.selection;
|
|
99
119
|
var preservedSelection = api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.sharedState.currentState()) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.preservedSelection;
|
|
@@ -114,8 +134,8 @@ var getTurnIntoMenuComponents = function getTurnIntoMenuComponents(api) {
|
|
|
114
134
|
children: null
|
|
115
135
|
},
|
|
116
136
|
children = _ref3.children;
|
|
117
|
-
return /*#__PURE__*/React.createElement(
|
|
118
|
-
title:
|
|
137
|
+
return /*#__PURE__*/React.createElement(MenuSection, {
|
|
138
|
+
title: blockMenuMessages.create
|
|
119
139
|
}, children);
|
|
120
140
|
}
|
|
121
141
|
}, {
|
|
@@ -131,8 +151,8 @@ var getTurnIntoMenuComponents = function getTurnIntoMenuComponents(api) {
|
|
|
131
151
|
children: null
|
|
132
152
|
},
|
|
133
153
|
children = _ref4.children;
|
|
134
|
-
return /*#__PURE__*/React.createElement(
|
|
135
|
-
title:
|
|
154
|
+
return /*#__PURE__*/React.createElement(MenuSection, {
|
|
155
|
+
title: blockMenuMessages.structure
|
|
136
156
|
}, children);
|
|
137
157
|
}
|
|
138
158
|
}, {
|
|
@@ -148,8 +168,8 @@ var getTurnIntoMenuComponents = function getTurnIntoMenuComponents(api) {
|
|
|
148
168
|
children: null
|
|
149
169
|
},
|
|
150
170
|
children = _ref5.children;
|
|
151
|
-
return /*#__PURE__*/React.createElement(
|
|
152
|
-
title:
|
|
171
|
+
return /*#__PURE__*/React.createElement(MenuSection, {
|
|
172
|
+
title: blockMenuMessages.headings,
|
|
153
173
|
hasSeparator: true
|
|
154
174
|
}, children);
|
|
155
175
|
}
|
|
@@ -9,11 +9,9 @@ import { Box } from '@atlaskit/primitives/box';
|
|
|
9
9
|
import Text from '@atlaskit/primitives/text';
|
|
10
10
|
import { BLOCK_MENU_ITEM_NAME } from './consts';
|
|
11
11
|
var DeleteDropdownItemContent = function DeleteDropdownItemContent(_ref) {
|
|
12
|
-
var _api$core$sharedState;
|
|
13
12
|
var api = _ref.api;
|
|
14
13
|
var _useIntl = useIntl(),
|
|
15
14
|
formatMessage = _useIntl.formatMessage;
|
|
16
|
-
var nodeTypes = Object.values((api === null || api === void 0 || (_api$core$sharedState = api.core.sharedState.currentState()) === null || _api$core$sharedState === void 0 || (_api$core$sharedState = _api$core$sharedState.schema) === null || _api$core$sharedState === void 0 ? void 0 : _api$core$sharedState.nodes) || {});
|
|
17
15
|
var onClick = function onClick() {
|
|
18
16
|
api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
|
|
19
17
|
var _api$analytics, _api$blockControls, _api$blockControls2;
|
|
@@ -42,14 +40,13 @@ var DeleteDropdownItemContent = function DeleteDropdownItemContent(_ref) {
|
|
|
42
40
|
var _api$decorations, _api$decorations$hove;
|
|
43
41
|
var tr = _ref3.tr;
|
|
44
42
|
api === null || api === void 0 || (_api$decorations = api.decorations) === null || _api$decorations === void 0 || (_api$decorations = _api$decorations.commands) === null || _api$decorations === void 0 || (_api$decorations$hove = _api$decorations.hoverDecoration) === null || _api$decorations$hove === void 0 || _api$decorations$hove.call(_api$decorations, {
|
|
45
|
-
nodeType: nodeTypes,
|
|
46
43
|
add: true
|
|
47
44
|
})({
|
|
48
45
|
tr: tr
|
|
49
46
|
});
|
|
50
47
|
return tr;
|
|
51
48
|
});
|
|
52
|
-
}, [api
|
|
49
|
+
}, [api]);
|
|
53
50
|
var onRemoveHoverDecoration = useCallback(function () {
|
|
54
51
|
api === null || api === void 0 || api.core.actions.execute(function (_ref4) {
|
|
55
52
|
var _api$decorations2, _api$decorations2$rem;
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl-next';
|
|
3
|
+
import { blockMenuMessages } from '@atlaskit/editor-common/messages';
|
|
2
4
|
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
3
5
|
import { useSuggestedItems } from './hooks/useSuggestedItems';
|
|
4
6
|
export var SuggestedItemsMenuSection = /*#__PURE__*/React.memo(function (_ref) {
|
|
5
7
|
var api = _ref.api,
|
|
6
8
|
children = _ref.children;
|
|
7
9
|
var suggestedItems = useSuggestedItems(api);
|
|
10
|
+
var _useIntl = useIntl(),
|
|
11
|
+
formatMessage = _useIntl.formatMessage;
|
|
8
12
|
if (suggestedItems.length === 0) {
|
|
9
13
|
return null;
|
|
10
14
|
}
|
|
11
15
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
12
|
-
title:
|
|
16
|
+
title: formatMessage(blockMenuMessages.suggested)
|
|
13
17
|
}, children);
|
|
14
18
|
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type MessageDescriptor } from 'react-intl-next';
|
|
3
|
+
type MenuSectionProps = {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
hasSeparator?: boolean;
|
|
6
|
+
title: MessageDescriptor;
|
|
7
|
+
};
|
|
8
|
+
export declare const MenuSection: ({ children, title, hasSeparator, }: MenuSectionProps) => React.JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type MessageDescriptor } from 'react-intl-next';
|
|
3
|
+
type MenuSectionProps = {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
hasSeparator?: boolean;
|
|
6
|
+
title: MessageDescriptor;
|
|
7
|
+
};
|
|
8
|
+
export declare const MenuSection: ({ children, title, hasSeparator, }: MenuSectionProps) => React.JSX.Element;
|
|
9
|
+
export {};
|
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.22",
|
|
4
4
|
"description": "BlockMenu plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"@atlaskit/platform-feature-flags-react": "^0.4.0",
|
|
47
47
|
"@atlaskit/primitives": "^17.1.0",
|
|
48
48
|
"@atlaskit/prosemirror-history": "^0.2.0",
|
|
49
|
-
"@atlaskit/tmp-editor-statsig": "^16.
|
|
50
|
-
"@atlaskit/tokens": "^10.
|
|
49
|
+
"@atlaskit/tmp-editor-statsig": "^16.28.0",
|
|
50
|
+
"@atlaskit/tokens": "^10.1.0",
|
|
51
51
|
"@babel/runtime": "^7.0.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
package/build/tsconfig.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../tsconfig",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"target": "es5",
|
|
5
|
-
"paths": {}
|
|
6
|
-
},
|
|
7
|
-
"include": [
|
|
8
|
-
"../src/**/*.ts",
|
|
9
|
-
"../src/**/*.tsx"
|
|
10
|
-
],
|
|
11
|
-
"exclude": [
|
|
12
|
-
"../src/**/__tests__/*",
|
|
13
|
-
"../src/**/*.test.*",
|
|
14
|
-
"../src/**/test.*",
|
|
15
|
-
"../src/**/examples.*"
|
|
16
|
-
]
|
|
17
|
-
}
|