@atlaskit/editor-plugin-block-menu 5.2.9 → 5.2.11
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 +14 -0
- package/dist/cjs/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +0 -23
- package/dist/cjs/editor-commands/transform-node-utils/transform.js +2 -2
- package/dist/cjs/editor-commands/transform-node-utils/unwrapExpandStep.js +20 -4
- package/dist/cjs/editor-commands/transform-node-utils/utils.js +40 -4
- package/dist/cjs/editor-commands/transform-node-utils/wrapStep.js +20 -1
- package/dist/cjs/ui/block-menu-components.js +30 -20
- package/dist/cjs/ui/hooks/useSuggestedItems.js +57 -0
- package/dist/cjs/ui/suggested-items-menu-section.js +21 -0
- package/dist/cjs/ui/suggested-menu-items.js +19 -0
- package/dist/cjs/ui/utils/suggested-items-rank.js +1 -1
- package/dist/es2019/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +0 -23
- package/dist/es2019/editor-commands/transform-node-utils/transform.js +2 -2
- package/dist/es2019/editor-commands/transform-node-utils/unwrapExpandStep.js +20 -2
- package/dist/es2019/editor-commands/transform-node-utils/utils.js +39 -3
- package/dist/es2019/editor-commands/transform-node-utils/wrapStep.js +21 -1
- package/dist/es2019/ui/block-menu-components.js +12 -4
- package/dist/es2019/ui/hooks/useSuggestedItems.js +45 -0
- package/dist/es2019/ui/suggested-items-menu-section.js +15 -0
- package/dist/es2019/ui/suggested-menu-items.js +13 -0
- package/dist/es2019/ui/utils/suggested-items-rank.js +31 -43
- package/dist/esm/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +0 -23
- package/dist/esm/editor-commands/transform-node-utils/transform.js +2 -2
- package/dist/esm/editor-commands/transform-node-utils/unwrapExpandStep.js +20 -3
- package/dist/esm/editor-commands/transform-node-utils/utils.js +39 -3
- package/dist/esm/editor-commands/transform-node-utils/wrapStep.js +21 -1
- package/dist/esm/ui/block-menu-components.js +30 -20
- package/dist/esm/ui/hooks/useSuggestedItems.js +51 -0
- package/dist/esm/ui/suggested-items-menu-section.js +14 -0
- package/dist/esm/ui/suggested-menu-items.js +12 -0
- package/dist/esm/ui/utils/suggested-items-rank.js +2 -2
- package/dist/types/editor-commands/transform-node-utils/unwrapExpandStep.d.ts +5 -0
- package/dist/types/editor-commands/transform-node-utils/utils.d.ts +17 -0
- package/dist/types/editor-commands/transform-node-utils/wrapStep.d.ts +5 -0
- package/dist/types/ui/hooks/useSuggestedItems.d.ts +3 -0
- package/dist/types/ui/suggested-items-menu-section.d.ts +9 -0
- package/dist/{types-ts4.5/ui/suggested-items-renderer.d.ts → types/ui/suggested-menu-items.d.ts} +2 -2
- package/dist/types-ts4.5/editor-commands/transform-node-utils/unwrapExpandStep.d.ts +5 -0
- package/dist/types-ts4.5/editor-commands/transform-node-utils/utils.d.ts +17 -0
- package/dist/types-ts4.5/editor-commands/transform-node-utils/wrapStep.d.ts +5 -0
- package/dist/types-ts4.5/ui/hooks/useSuggestedItems.d.ts +3 -0
- package/dist/types-ts4.5/ui/suggested-items-menu-section.d.ts +9 -0
- package/dist/{types/ui/suggested-items-renderer.d.ts → types-ts4.5/ui/suggested-menu-items.d.ts} +2 -2
- package/package.json +4 -4
- package/dist/cjs/ui/suggested-items-renderer.js +0 -62
- package/dist/es2019/ui/suggested-items-renderer.js +0 -48
- package/dist/esm/ui/suggested-items-renderer.js +0 -54
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useSuggestedItems } from './hooks/useSuggestedItems';
|
|
3
|
+
export var SuggestedMenuItems = /*#__PURE__*/React.memo(function (_ref) {
|
|
4
|
+
var api = _ref.api;
|
|
5
|
+
var suggestedItems = useSuggestedItems(api);
|
|
6
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, suggestedItems.map(function (item) {
|
|
7
|
+
var ItemComponent = item.component;
|
|
8
|
+
return ItemComponent ? /*#__PURE__*/React.createElement(ItemComponent, {
|
|
9
|
+
key: item.key
|
|
10
|
+
}) : null;
|
|
11
|
+
}));
|
|
12
|
+
});
|
|
@@ -17,7 +17,7 @@ var _TRANSFORM_SUGGESTED_;
|
|
|
17
17
|
* }
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { TRANSFORM_STRUCTURE_PANEL_MENU_ITEM, TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM, TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM, TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM, TRANSFORM_STRUCTURE_CODE_BLOCK_MENU_ITEM, TRANSFORM_STRUCTURE_BULLETED_LIST_MENU_ITEM, TRANSFORM_STRUCTURE_NUMBERED_LIST_MENU_ITEM, TRANSFORM_STRUCTURE_TASK_LIST_MENU_ITEM,
|
|
20
|
+
import { TRANSFORM_STRUCTURE_PANEL_MENU_ITEM, TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM, TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM, TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM, TRANSFORM_STRUCTURE_CODE_BLOCK_MENU_ITEM, TRANSFORM_STRUCTURE_BULLETED_LIST_MENU_ITEM, TRANSFORM_STRUCTURE_NUMBERED_LIST_MENU_ITEM, TRANSFORM_STRUCTURE_TASK_LIST_MENU_ITEM, TRANSFORM_HEADINGS_H1_MENU_ITEM, TRANSFORM_HEADINGS_H2_MENU_ITEM, TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM } from '@atlaskit/editor-common/block-menu';
|
|
21
21
|
export var BLOCK_MENU_NODE_TYPES = {
|
|
22
22
|
PARAGRAPH: 'paragraph',
|
|
23
23
|
EXPAND: 'expand',
|
|
@@ -37,7 +37,7 @@ export var BLOCK_MENU_NODE_TYPES = {
|
|
|
37
37
|
EMBED_CARD: 'embedCard',
|
|
38
38
|
TABLE: 'table'
|
|
39
39
|
};
|
|
40
|
-
export var TRANSFORM_SUGGESTED_ITEMS_RANK = (_TRANSFORM_SUGGESTED_ = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_TRANSFORM_SUGGESTED_, BLOCK_MENU_NODE_TYPES.PARAGRAPH, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100),
|
|
40
|
+
export var TRANSFORM_SUGGESTED_ITEMS_RANK = (_TRANSFORM_SUGGESTED_ = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_TRANSFORM_SUGGESTED_, BLOCK_MENU_NODE_TYPES.PARAGRAPH, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_HEADINGS_H1_MENU_ITEM.key, 200), TRANSFORM_HEADINGS_H2_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.EXPAND, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.BLOCKQUOTE, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.LAYOUT_SECTION, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.PANEL, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_CODE_BLOCK_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.CODE_BLOCK, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.DECISION, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.BULLET_LIST, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_NUMBERED_LIST_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.ORDERED_LIST, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_TASK_LIST_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_BULLETED_LIST_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.HEADING, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_BULLETED_LIST_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 300)), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_TRANSFORM_SUGGESTED_, BLOCK_MENU_NODE_TYPES.TASK_LIST, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_NUMBERED_LIST_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_BULLETED_LIST_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.MEDIA_SINGLE, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.EXTENSION, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.BODIED_EXTENSION, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 300)));
|
|
41
41
|
export var getSuggestedItemsForNodeType = function getSuggestedItemsForNodeType(nodeType) {
|
|
42
42
|
return TRANSFORM_SUGGESTED_ITEMS_RANK[nodeType];
|
|
43
43
|
};
|
|
@@ -3,6 +3,11 @@ import type { TransformStep } from './types';
|
|
|
3
3
|
* Unwraps an expand/nestedExpand node, converting its title attribute to a paragraph
|
|
4
4
|
* and prepending it to the children.
|
|
5
5
|
*
|
|
6
|
+
* Any nestedExpand children are converted to regular expands since nestedExpand
|
|
7
|
+
* can only exist inside an expand.
|
|
8
|
+
*
|
|
6
9
|
* Example: expand({ title: 'title' })(p('b')) → [p('title'), p('b')]
|
|
10
|
+
* Example: expand({ title: 'outer' })(nestedExpand({ title: 'inner' })(p('x')))
|
|
11
|
+
* → [p('outer'), expand({ title: 'inner' })(p('x'))]
|
|
7
12
|
*/
|
|
8
13
|
export declare const unwrapExpandStep: TransformStep;
|
|
@@ -14,6 +14,23 @@ export declare const getTargetNodeTypeNameInContext: (nodeTypeName: NodeTypeName
|
|
|
14
14
|
export declare const expandSelectionToBlockRange: (selection: Selection, schema: Schema) => {
|
|
15
15
|
$from: import("prosemirror-model").ResolvedPos;
|
|
16
16
|
$to: import("prosemirror-model").ResolvedPos;
|
|
17
|
+
range: NodeRange | null;
|
|
18
|
+
} | {
|
|
19
|
+
$from: import("prosemirror-model").ResolvedPos;
|
|
20
|
+
$to: import("prosemirror-model").ResolvedPos;
|
|
21
|
+
range?: undefined;
|
|
17
22
|
};
|
|
18
23
|
export declare const isListType: (node: PMNode, schema: Schema) => boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Converts a nestedExpand to a regular expand node.
|
|
26
|
+
* NestedExpands can only exist inside expands, so when breaking out or placing
|
|
27
|
+
* in containers that don't support nesting, they must be converted.
|
|
28
|
+
*/
|
|
29
|
+
export declare const convertNestedExpandToExpand: (node: PMNode, schema: Schema) => PMNode | null;
|
|
30
|
+
/**
|
|
31
|
+
* Converts an expand to a nestedExpand node.
|
|
32
|
+
* When placing an expand inside another expand, it must become a nestedExpand
|
|
33
|
+
* since expand cannot be a direct child of expand.
|
|
34
|
+
*/
|
|
35
|
+
export declare const convertExpandToNestedExpand: (node: PMNode, schema: Schema) => PMNode | null;
|
|
19
36
|
export declare const getBlockNodesInRange: (range: NodeRange) => PMNode[];
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import type { TransformStep } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps nodes into the target container type.
|
|
4
|
+
* When wrapping into expand, any expand children are converted to nestedExpand
|
|
5
|
+
* since expand cannot be a direct child of expand.
|
|
6
|
+
*/
|
|
2
7
|
export declare const wrapStep: TransformStep;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { BlockMenuPlugin, RegisterBlockMenuItem } from '../../blockMenuPluginType';
|
|
3
|
+
export declare const useSuggestedItems: (api: ExtractInjectionAPI<BlockMenuPlugin> | undefined) => RegisterBlockMenuItem[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { BlockMenuPlugin } from '../blockMenuPluginType';
|
|
4
|
+
type SuggestedItemsMenuSectionProps = {
|
|
5
|
+
api: ExtractInjectionAPI<BlockMenuPlugin> | undefined;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
};
|
|
8
|
+
export declare const SuggestedItemsMenuSection: React.NamedExoticComponent<SuggestedItemsMenuSectionProps>;
|
|
9
|
+
export {};
|
package/dist/{types-ts4.5/ui/suggested-items-renderer.d.ts → types/ui/suggested-menu-items.d.ts}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { BlockMenuPlugin } from '../blockMenuPluginType';
|
|
4
|
-
type
|
|
4
|
+
type SuggestedMenuItemsProps = {
|
|
5
5
|
api: ExtractInjectionAPI<BlockMenuPlugin> | undefined;
|
|
6
6
|
};
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const SuggestedMenuItems: React.NamedExoticComponent<SuggestedMenuItemsProps>;
|
|
8
8
|
export {};
|
|
@@ -3,6 +3,11 @@ import type { TransformStep } from './types';
|
|
|
3
3
|
* Unwraps an expand/nestedExpand node, converting its title attribute to a paragraph
|
|
4
4
|
* and prepending it to the children.
|
|
5
5
|
*
|
|
6
|
+
* Any nestedExpand children are converted to regular expands since nestedExpand
|
|
7
|
+
* can only exist inside an expand.
|
|
8
|
+
*
|
|
6
9
|
* Example: expand({ title: 'title' })(p('b')) → [p('title'), p('b')]
|
|
10
|
+
* Example: expand({ title: 'outer' })(nestedExpand({ title: 'inner' })(p('x')))
|
|
11
|
+
* → [p('outer'), expand({ title: 'inner' })(p('x'))]
|
|
7
12
|
*/
|
|
8
13
|
export declare const unwrapExpandStep: TransformStep;
|
|
@@ -14,6 +14,23 @@ export declare const getTargetNodeTypeNameInContext: (nodeTypeName: NodeTypeName
|
|
|
14
14
|
export declare const expandSelectionToBlockRange: (selection: Selection, schema: Schema) => {
|
|
15
15
|
$from: import("prosemirror-model").ResolvedPos;
|
|
16
16
|
$to: import("prosemirror-model").ResolvedPos;
|
|
17
|
+
range: NodeRange | null;
|
|
18
|
+
} | {
|
|
19
|
+
$from: import("prosemirror-model").ResolvedPos;
|
|
20
|
+
$to: import("prosemirror-model").ResolvedPos;
|
|
21
|
+
range?: undefined;
|
|
17
22
|
};
|
|
18
23
|
export declare const isListType: (node: PMNode, schema: Schema) => boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Converts a nestedExpand to a regular expand node.
|
|
26
|
+
* NestedExpands can only exist inside expands, so when breaking out or placing
|
|
27
|
+
* in containers that don't support nesting, they must be converted.
|
|
28
|
+
*/
|
|
29
|
+
export declare const convertNestedExpandToExpand: (node: PMNode, schema: Schema) => PMNode | null;
|
|
30
|
+
/**
|
|
31
|
+
* Converts an expand to a nestedExpand node.
|
|
32
|
+
* When placing an expand inside another expand, it must become a nestedExpand
|
|
33
|
+
* since expand cannot be a direct child of expand.
|
|
34
|
+
*/
|
|
35
|
+
export declare const convertExpandToNestedExpand: (node: PMNode, schema: Schema) => PMNode | null;
|
|
19
36
|
export declare const getBlockNodesInRange: (range: NodeRange) => PMNode[];
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import type { TransformStep } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps nodes into the target container type.
|
|
4
|
+
* When wrapping into expand, any expand children are converted to nestedExpand
|
|
5
|
+
* since expand cannot be a direct child of expand.
|
|
6
|
+
*/
|
|
2
7
|
export declare const wrapStep: TransformStep;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { BlockMenuPlugin, RegisterBlockMenuItem } from '../../blockMenuPluginType';
|
|
3
|
+
export declare const useSuggestedItems: (api: ExtractInjectionAPI<BlockMenuPlugin> | undefined) => RegisterBlockMenuItem[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { BlockMenuPlugin } from '../blockMenuPluginType';
|
|
4
|
+
type SuggestedItemsMenuSectionProps = {
|
|
5
|
+
api: ExtractInjectionAPI<BlockMenuPlugin> | undefined;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
};
|
|
8
|
+
export declare const SuggestedItemsMenuSection: React.NamedExoticComponent<SuggestedItemsMenuSectionProps>;
|
|
9
|
+
export {};
|
package/dist/{types/ui/suggested-items-renderer.d.ts → types-ts4.5/ui/suggested-menu-items.d.ts}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { BlockMenuPlugin } from '../blockMenuPluginType';
|
|
4
|
-
type
|
|
4
|
+
type SuggestedMenuItemsProps = {
|
|
5
5
|
api: ExtractInjectionAPI<BlockMenuPlugin> | undefined;
|
|
6
6
|
};
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const SuggestedMenuItems: React.NamedExoticComponent<SuggestedMenuItemsProps>;
|
|
8
8
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-menu",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.11",
|
|
4
4
|
"description": "BlockMenu plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -44,12 +44,12 @@
|
|
|
44
44
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
45
45
|
"@atlaskit/platform-feature-flags-react": "^0.4.0",
|
|
46
46
|
"@atlaskit/primitives": "^16.4.0",
|
|
47
|
-
"@atlaskit/tmp-editor-statsig": "^15.
|
|
48
|
-
"@atlaskit/tokens": "^8.
|
|
47
|
+
"@atlaskit/tmp-editor-statsig": "^15.11.0",
|
|
48
|
+
"@atlaskit/tokens": "^8.5.0",
|
|
49
49
|
"@babel/runtime": "^7.0.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@atlaskit/editor-common": "^110.
|
|
52
|
+
"@atlaskit/editor-common": "^110.44.0",
|
|
53
53
|
"react": "^18.2.0",
|
|
54
54
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
55
55
|
},
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.SuggestedItemsRenderer = void 0;
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
10
|
-
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
11
|
-
var _utils = require("../editor-commands/transform-node-utils/utils");
|
|
12
|
-
var _suggestedItemsRank = require("./utils/suggested-items-rank");
|
|
13
|
-
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); }
|
|
14
|
-
var SuggestedItemsRenderer = exports.SuggestedItemsRenderer = /*#__PURE__*/_react.default.memo(function (_ref) {
|
|
15
|
-
var _api$blockMenu;
|
|
16
|
-
var api = _ref.api;
|
|
17
|
-
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['blockControls'], function (states) {
|
|
18
|
-
var _states$blockControls;
|
|
19
|
-
return {
|
|
20
|
-
preservedSelection: (_states$blockControls = states.blockControlsState) === null || _states$blockControls === void 0 ? void 0 : _states$blockControls.preservedSelection
|
|
21
|
-
};
|
|
22
|
-
}),
|
|
23
|
-
preservedSelection = _useSharedPluginState.preservedSelection;
|
|
24
|
-
var blockMenuComponents = api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.actions.getBlockMenuComponents();
|
|
25
|
-
var menuItemsMap = (0, _react.useMemo)(function () {
|
|
26
|
-
if (!blockMenuComponents) {
|
|
27
|
-
return new Map();
|
|
28
|
-
}
|
|
29
|
-
return new Map(blockMenuComponents.filter(function (c) {
|
|
30
|
-
return c.type === 'block-menu-item';
|
|
31
|
-
}).map(function (item) {
|
|
32
|
-
return [item.key, item];
|
|
33
|
-
}));
|
|
34
|
-
}, [blockMenuComponents]);
|
|
35
|
-
var suggestedItems = (0, _react.useMemo)(function () {
|
|
36
|
-
if (!preservedSelection || menuItemsMap.size === 0) {
|
|
37
|
-
return [];
|
|
38
|
-
}
|
|
39
|
-
var selectedNode = (0, _utils.getSelectedNode)(preservedSelection);
|
|
40
|
-
if (!selectedNode) {
|
|
41
|
-
return [];
|
|
42
|
-
}
|
|
43
|
-
var nodeTypeName = selectedNode.node.type.name;
|
|
44
|
-
var sortedKeys = (0, _suggestedItemsRank.getSortedSuggestedItems)(nodeTypeName);
|
|
45
|
-
return sortedKeys.map(function (key) {
|
|
46
|
-
return menuItemsMap.get(key);
|
|
47
|
-
}).filter(function (item) {
|
|
48
|
-
return item !== undefined;
|
|
49
|
-
});
|
|
50
|
-
}, [menuItemsMap, preservedSelection]);
|
|
51
|
-
if (suggestedItems.length === 0) {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
|
|
55
|
-
title: "Suggested"
|
|
56
|
-
}, suggestedItems.map(function (item) {
|
|
57
|
-
var ItemComponent = item.component;
|
|
58
|
-
return ItemComponent ? /*#__PURE__*/_react.default.createElement(ItemComponent, {
|
|
59
|
-
key: item.key
|
|
60
|
-
}) : null;
|
|
61
|
-
}));
|
|
62
|
-
});
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
2
|
-
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
3
|
-
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
4
|
-
import { getSelectedNode } from '../editor-commands/transform-node-utils/utils';
|
|
5
|
-
import { getSortedSuggestedItems } from './utils/suggested-items-rank';
|
|
6
|
-
export const SuggestedItemsRenderer = /*#__PURE__*/React.memo(({
|
|
7
|
-
api
|
|
8
|
-
}) => {
|
|
9
|
-
var _api$blockMenu;
|
|
10
|
-
const {
|
|
11
|
-
preservedSelection
|
|
12
|
-
} = useSharedPluginStateWithSelector(api, ['blockControls'], states => {
|
|
13
|
-
var _states$blockControls;
|
|
14
|
-
return {
|
|
15
|
-
preservedSelection: (_states$blockControls = states.blockControlsState) === null || _states$blockControls === void 0 ? void 0 : _states$blockControls.preservedSelection
|
|
16
|
-
};
|
|
17
|
-
});
|
|
18
|
-
const blockMenuComponents = api === null || api === void 0 ? void 0 : (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.actions.getBlockMenuComponents();
|
|
19
|
-
const menuItemsMap = useMemo(() => {
|
|
20
|
-
if (!blockMenuComponents) {
|
|
21
|
-
return new Map();
|
|
22
|
-
}
|
|
23
|
-
return new Map(blockMenuComponents.filter(c => c.type === 'block-menu-item').map(item => [item.key, item]));
|
|
24
|
-
}, [blockMenuComponents]);
|
|
25
|
-
const suggestedItems = useMemo(() => {
|
|
26
|
-
if (!preservedSelection || menuItemsMap.size === 0) {
|
|
27
|
-
return [];
|
|
28
|
-
}
|
|
29
|
-
const selectedNode = getSelectedNode(preservedSelection);
|
|
30
|
-
if (!selectedNode) {
|
|
31
|
-
return [];
|
|
32
|
-
}
|
|
33
|
-
const nodeTypeName = selectedNode.node.type.name;
|
|
34
|
-
const sortedKeys = getSortedSuggestedItems(nodeTypeName);
|
|
35
|
-
return sortedKeys.map(key => menuItemsMap.get(key)).filter(item => item !== undefined);
|
|
36
|
-
}, [menuItemsMap, preservedSelection]);
|
|
37
|
-
if (suggestedItems.length === 0) {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
41
|
-
title: "Suggested"
|
|
42
|
-
}, suggestedItems.map(item => {
|
|
43
|
-
const ItemComponent = item.component;
|
|
44
|
-
return ItemComponent ? /*#__PURE__*/React.createElement(ItemComponent, {
|
|
45
|
-
key: item.key
|
|
46
|
-
}) : null;
|
|
47
|
-
}));
|
|
48
|
-
});
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
2
|
-
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
3
|
-
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
4
|
-
import { getSelectedNode } from '../editor-commands/transform-node-utils/utils';
|
|
5
|
-
import { getSortedSuggestedItems } from './utils/suggested-items-rank';
|
|
6
|
-
export var SuggestedItemsRenderer = /*#__PURE__*/React.memo(function (_ref) {
|
|
7
|
-
var _api$blockMenu;
|
|
8
|
-
var api = _ref.api;
|
|
9
|
-
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['blockControls'], function (states) {
|
|
10
|
-
var _states$blockControls;
|
|
11
|
-
return {
|
|
12
|
-
preservedSelection: (_states$blockControls = states.blockControlsState) === null || _states$blockControls === void 0 ? void 0 : _states$blockControls.preservedSelection
|
|
13
|
-
};
|
|
14
|
-
}),
|
|
15
|
-
preservedSelection = _useSharedPluginState.preservedSelection;
|
|
16
|
-
var blockMenuComponents = api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.actions.getBlockMenuComponents();
|
|
17
|
-
var menuItemsMap = useMemo(function () {
|
|
18
|
-
if (!blockMenuComponents) {
|
|
19
|
-
return new Map();
|
|
20
|
-
}
|
|
21
|
-
return new Map(blockMenuComponents.filter(function (c) {
|
|
22
|
-
return c.type === 'block-menu-item';
|
|
23
|
-
}).map(function (item) {
|
|
24
|
-
return [item.key, item];
|
|
25
|
-
}));
|
|
26
|
-
}, [blockMenuComponents]);
|
|
27
|
-
var suggestedItems = useMemo(function () {
|
|
28
|
-
if (!preservedSelection || menuItemsMap.size === 0) {
|
|
29
|
-
return [];
|
|
30
|
-
}
|
|
31
|
-
var selectedNode = getSelectedNode(preservedSelection);
|
|
32
|
-
if (!selectedNode) {
|
|
33
|
-
return [];
|
|
34
|
-
}
|
|
35
|
-
var nodeTypeName = selectedNode.node.type.name;
|
|
36
|
-
var sortedKeys = getSortedSuggestedItems(nodeTypeName);
|
|
37
|
-
return sortedKeys.map(function (key) {
|
|
38
|
-
return menuItemsMap.get(key);
|
|
39
|
-
}).filter(function (item) {
|
|
40
|
-
return item !== undefined;
|
|
41
|
-
});
|
|
42
|
-
}, [menuItemsMap, preservedSelection]);
|
|
43
|
-
if (suggestedItems.length === 0) {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
47
|
-
title: "Suggested"
|
|
48
|
-
}, suggestedItems.map(function (item) {
|
|
49
|
-
var ItemComponent = item.component;
|
|
50
|
-
return ItemComponent ? /*#__PURE__*/React.createElement(ItemComponent, {
|
|
51
|
-
key: item.key
|
|
52
|
-
}) : null;
|
|
53
|
-
}));
|
|
54
|
-
});
|