@atlaskit/editor-plugin-block-menu 0.0.12 → 0.0.14
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 +15 -0
- package/afm-cc/tsconfig.json +4 -1
- package/afm-dev-agents/tsconfig.json +3 -0
- package/afm-jira/tsconfig.json +3 -0
- package/afm-passionfruit/tsconfig.json +3 -0
- package/afm-post-office/tsconfig.json +3 -0
- package/afm-rovo-extension/tsconfig.json +3 -0
- package/afm-townsquare/tsconfig.json +3 -0
- package/dist/cjs/blockMenuPlugin.js +6 -0
- package/dist/cjs/editor-commands/formatNode.js +23 -0
- package/dist/cjs/editor-commands/transforms/block-transforms.js +37 -0
- package/dist/cjs/editor-commands/transforms/container-transforms.js +59 -0
- package/dist/cjs/editor-commands/transforms/list-transforms.js +53 -0
- package/dist/cjs/editor-commands/transforms/transformNodeToTargetType.js +50 -0
- package/dist/cjs/editor-commands/transforms/types.js +5 -0
- package/dist/cjs/editor-commands/transforms/utils.js +109 -0
- package/dist/cjs/ui/block-menu-components.js +55 -42
- package/dist/cjs/ui/block-menu-renderer.js +48 -11
- package/dist/es2019/blockMenuPlugin.js +6 -0
- package/dist/es2019/editor-commands/formatNode.js +20 -0
- package/dist/es2019/editor-commands/transforms/block-transforms.js +38 -0
- package/dist/es2019/editor-commands/transforms/container-transforms.js +55 -0
- package/dist/es2019/editor-commands/transforms/list-transforms.js +49 -0
- package/dist/es2019/editor-commands/transforms/transformNodeToTargetType.js +48 -0
- package/dist/es2019/editor-commands/transforms/types.js +1 -0
- package/dist/es2019/editor-commands/transforms/utils.js +103 -0
- package/dist/es2019/ui/block-menu-components.js +45 -32
- package/dist/es2019/ui/block-menu-renderer.js +46 -11
- package/dist/esm/blockMenuPlugin.js +6 -0
- package/dist/esm/editor-commands/formatNode.js +17 -0
- package/dist/esm/editor-commands/transforms/block-transforms.js +32 -0
- package/dist/esm/editor-commands/transforms/container-transforms.js +54 -0
- package/dist/esm/editor-commands/transforms/list-transforms.js +48 -0
- package/dist/esm/editor-commands/transforms/transformNodeToTargetType.js +44 -0
- package/dist/esm/editor-commands/transforms/types.js +1 -0
- package/dist/esm/editor-commands/transforms/utils.js +103 -0
- package/dist/esm/ui/block-menu-components.js +56 -43
- package/dist/esm/ui/block-menu-renderer.js +48 -11
- package/dist/types/blockMenuPluginType.d.ts +27 -3
- package/dist/types/editor-commands/formatNode.d.ts +9 -0
- package/dist/types/editor-commands/transforms/block-transforms.d.ts +5 -0
- package/dist/types/editor-commands/transforms/container-transforms.d.ts +17 -0
- package/dist/types/editor-commands/transforms/list-transforms.d.ts +17 -0
- package/dist/types/editor-commands/transforms/transformNodeToTargetType.d.ts +4 -0
- package/dist/types/editor-commands/transforms/types.d.ts +11 -0
- package/dist/types/editor-commands/transforms/utils.d.ts +12 -0
- package/dist/types-ts4.5/blockMenuPluginType.d.ts +27 -3
- package/dist/types-ts4.5/editor-commands/formatNode.d.ts +9 -0
- package/dist/types-ts4.5/editor-commands/transforms/block-transforms.d.ts +5 -0
- package/dist/types-ts4.5/editor-commands/transforms/container-transforms.d.ts +17 -0
- package/dist/types-ts4.5/editor-commands/transforms/list-transforms.d.ts +17 -0
- package/dist/types-ts4.5/editor-commands/transforms/transformNodeToTargetType.d.ts +4 -0
- package/dist/types-ts4.5/editor-commands/transforms/types.d.ts +11 -0
- package/dist/types-ts4.5/editor-commands/transforms/utils.d.ts +12 -0
- package/package.json +13 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-menu
|
|
2
2
|
|
|
3
|
+
## 0.0.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 0.0.13
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`6dd96d8ae168d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6dd96d8ae168d) -
|
|
14
|
+
[ux] ED-28581 ED-28581: Updated renderer logic to better support nest menu items register from
|
|
15
|
+
outside block menu
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 0.0.12
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/afm-cc/tsconfig.json
CHANGED
|
@@ -50,6 +50,9 @@
|
|
|
50
50
|
{
|
|
51
51
|
"path": "../../../design-system/icon-lab/afm-cc/tsconfig.json"
|
|
52
52
|
},
|
|
53
|
+
{
|
|
54
|
+
"path": "../../../platform/feature-flags/afm-cc/tsconfig.json"
|
|
55
|
+
},
|
|
53
56
|
{
|
|
54
57
|
"path": "../../../design-system/primitives/afm-cc/tsconfig.json"
|
|
55
58
|
},
|
|
@@ -60,4 +63,4 @@
|
|
|
60
63
|
"path": "../../editor-common/afm-cc/tsconfig.json"
|
|
61
64
|
}
|
|
62
65
|
]
|
|
63
|
-
}
|
|
66
|
+
}
|
package/afm-jira/tsconfig.json
CHANGED
|
@@ -50,6 +50,9 @@
|
|
|
50
50
|
{
|
|
51
51
|
"path": "../../../design-system/icon-lab/afm-passionfruit/tsconfig.json"
|
|
52
52
|
},
|
|
53
|
+
{
|
|
54
|
+
"path": "../../../platform/feature-flags/afm-passionfruit/tsconfig.json"
|
|
55
|
+
},
|
|
53
56
|
{
|
|
54
57
|
"path": "../../../design-system/primitives/afm-passionfruit/tsconfig.json"
|
|
55
58
|
},
|
|
@@ -50,6 +50,9 @@
|
|
|
50
50
|
{
|
|
51
51
|
"path": "../../../design-system/icon-lab/afm-post-office/tsconfig.json"
|
|
52
52
|
},
|
|
53
|
+
{
|
|
54
|
+
"path": "../../../platform/feature-flags/afm-post-office/tsconfig.json"
|
|
55
|
+
},
|
|
53
56
|
{
|
|
54
57
|
"path": "../../../design-system/primitives/afm-post-office/tsconfig.json"
|
|
55
58
|
},
|
|
@@ -50,6 +50,9 @@
|
|
|
50
50
|
{
|
|
51
51
|
"path": "../../../design-system/icon-lab/afm-rovo-extension/tsconfig.json"
|
|
52
52
|
},
|
|
53
|
+
{
|
|
54
|
+
"path": "../../../platform/feature-flags/afm-rovo-extension/tsconfig.json"
|
|
55
|
+
},
|
|
53
56
|
{
|
|
54
57
|
"path": "../../../design-system/primitives/afm-rovo-extension/tsconfig.json"
|
|
55
58
|
},
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.blockMenuPlugin = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _editorActions = require("./editor-actions");
|
|
10
|
+
var _formatNode2 = require("./editor-commands/formatNode");
|
|
10
11
|
var _main = require("./pm-plugins/main");
|
|
11
12
|
var _blockMenu = _interopRequireDefault(require("./ui/block-menu"));
|
|
12
13
|
var _blockMenuComponents = require("./ui/block-menu-components");
|
|
@@ -34,6 +35,11 @@ var blockMenuPlugin = exports.blockMenuPlugin = function blockMenuPlugin(_ref) {
|
|
|
34
35
|
return registry.components;
|
|
35
36
|
}
|
|
36
37
|
},
|
|
38
|
+
commands: {
|
|
39
|
+
formatNode: function formatNode(currentNode, targetType) {
|
|
40
|
+
return (0, _formatNode2.formatNode)(currentNode, targetType);
|
|
41
|
+
}
|
|
42
|
+
},
|
|
37
43
|
contentComponent: function contentComponent(_ref2) {
|
|
38
44
|
var editorView = _ref2.editorView,
|
|
39
45
|
popupsMountPoint = _ref2.popupsMountPoint,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.formatNode = void 0;
|
|
7
|
+
var _transformNodeToTargetType = require("./transforms/transformNodeToTargetType");
|
|
8
|
+
/**
|
|
9
|
+
* Formats the current node or selection to the specified target type
|
|
10
|
+
* @param currentNode - The current node
|
|
11
|
+
* @param targetType - The target node type to convert to
|
|
12
|
+
*/
|
|
13
|
+
var formatNode = exports.formatNode = function formatNode(currentNode, targetType) {
|
|
14
|
+
return function (_ref) {
|
|
15
|
+
var tr = _ref.tr;
|
|
16
|
+
var selection = tr.selection;
|
|
17
|
+
try {
|
|
18
|
+
return (0, _transformNodeToTargetType.transformNodeToTargetType)(tr, currentNode, selection.from, targetType);
|
|
19
|
+
} catch (e) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.transformBlockNode = void 0;
|
|
7
|
+
var _containerTransforms = require("./container-transforms");
|
|
8
|
+
var _listTransforms = require("./list-transforms");
|
|
9
|
+
var _utils = require("./utils");
|
|
10
|
+
/**
|
|
11
|
+
* Transform block nodes (paragraph, heading, codeblock)
|
|
12
|
+
*/
|
|
13
|
+
var transformBlockNode = exports.transformBlockNode = function transformBlockNode(context) {
|
|
14
|
+
var tr = context.tr,
|
|
15
|
+
targetNodeType = context.targetNodeType,
|
|
16
|
+
targetAttrs = context.targetAttrs;
|
|
17
|
+
var selection = tr.selection;
|
|
18
|
+
var $from = selection.$from,
|
|
19
|
+
$to = selection.$to;
|
|
20
|
+
|
|
21
|
+
// Handle transformation to list types
|
|
22
|
+
if ((0, _utils.isListNodeType)(targetNodeType)) {
|
|
23
|
+
return (0, _listTransforms.transformToList)();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Handle transformation to container types (panel, expand, blockquote)
|
|
27
|
+
if ((0, _utils.isContainerNodeType)(targetNodeType)) {
|
|
28
|
+
return (0, _containerTransforms.transformToContainer)();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Handle block type transformation (paragraph, heading, codeblock)
|
|
32
|
+
if ((0, _utils.isBlockNodeType)(targetNodeType)) {
|
|
33
|
+
tr.setBlockType($from.pos, $to.pos, targetNodeType, targetAttrs);
|
|
34
|
+
return tr;
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.unwrapAndConvertToList = exports.unwrapAndConvertToBlockType = exports.transformToContainer = exports.transformContainerNode = void 0;
|
|
7
|
+
var _utils = require("./utils");
|
|
8
|
+
/**
|
|
9
|
+
* Transform selection to container type
|
|
10
|
+
*/
|
|
11
|
+
var transformToContainer = exports.transformToContainer = function transformToContainer() {
|
|
12
|
+
return null;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Transform container nodes (panel, expand, blockquote)
|
|
17
|
+
*/
|
|
18
|
+
var transformContainerNode = exports.transformContainerNode = function transformContainerNode(_ref) {
|
|
19
|
+
var tr = _ref.tr,
|
|
20
|
+
sourcePos = _ref.sourcePos,
|
|
21
|
+
targetNodeType = _ref.targetNodeType,
|
|
22
|
+
targetAttrs = _ref.targetAttrs;
|
|
23
|
+
if (sourcePos === null) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Transform container to block type - unwrap and convert content
|
|
28
|
+
if ((0, _utils.isBlockNodeType)(targetNodeType)) {
|
|
29
|
+
return unwrapAndConvertToBlockType();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Transform container to list type
|
|
33
|
+
if ((0, _utils.isListNodeType)(targetNodeType)) {
|
|
34
|
+
return unwrapAndConvertToList();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Transform between container types
|
|
38
|
+
if ((0, _utils.isContainerNodeType)(targetNodeType)) {
|
|
39
|
+
tr.setNodeMarkup(sourcePos, targetNodeType, targetAttrs);
|
|
40
|
+
return tr;
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Unwrap container node and convert content to block type
|
|
47
|
+
*/
|
|
48
|
+
var unwrapAndConvertToBlockType = exports.unwrapAndConvertToBlockType = function unwrapAndConvertToBlockType() {
|
|
49
|
+
// Convert to block type directly
|
|
50
|
+
return null;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Unwrap container node and convert content to list
|
|
55
|
+
*/
|
|
56
|
+
var unwrapAndConvertToList = exports.unwrapAndConvertToList = function unwrapAndConvertToList() {
|
|
57
|
+
// Convert to list directly
|
|
58
|
+
return null;
|
|
59
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.transformToList = exports.transformListNode = exports.transformBetweenListTypes = exports.liftListToBlockType = void 0;
|
|
7
|
+
var _utils = require("./utils");
|
|
8
|
+
/**
|
|
9
|
+
* Transform selection to list type
|
|
10
|
+
*/
|
|
11
|
+
var transformToList = exports.transformToList = function transformToList() {
|
|
12
|
+
return null;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Transform list nodes
|
|
17
|
+
*/
|
|
18
|
+
var transformListNode = exports.transformListNode = function transformListNode(_ref) {
|
|
19
|
+
var targetNodeType = _ref.targetNodeType;
|
|
20
|
+
// Transform list to block type
|
|
21
|
+
if ((0, _utils.isBlockNodeType)(targetNodeType)) {
|
|
22
|
+
// Lift list items out of the list and convert to target block type
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Transform list to container type
|
|
27
|
+
if ((0, _utils.isContainerNodeType)(targetNodeType)) {
|
|
28
|
+
// Lift list items out of the list and convert to container type
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Transform between list types
|
|
33
|
+
if ((0, _utils.isListNodeType)(targetNodeType)) {
|
|
34
|
+
// Lift list items out of the list and convert to the other list type
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Lift list content and convert to block type
|
|
42
|
+
*/
|
|
43
|
+
var liftListToBlockType = exports.liftListToBlockType = function liftListToBlockType() {
|
|
44
|
+
// Convert to target block type directly
|
|
45
|
+
return null;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Transform between different list types
|
|
50
|
+
*/
|
|
51
|
+
var transformBetweenListTypes = exports.transformBetweenListTypes = function transformBetweenListTypes() {
|
|
52
|
+
return null;
|
|
53
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.transformNodeToTargetType = transformNodeToTargetType;
|
|
7
|
+
var _blockTransforms = require("./block-transforms");
|
|
8
|
+
var _containerTransforms = require("./container-transforms");
|
|
9
|
+
var _listTransforms = require("./list-transforms");
|
|
10
|
+
var _utils = require("./utils");
|
|
11
|
+
function transformNodeToTargetType(tr, sourceNode, sourcePos, targetType) {
|
|
12
|
+
var nodes = tr.doc.type.schema.nodes;
|
|
13
|
+
var targetNodeInfo = (0, _utils.getTargetNodeInfo)(targetType, nodes);
|
|
14
|
+
if (!targetNodeInfo) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
var targetNodeType = targetNodeInfo.nodeType,
|
|
18
|
+
targetAttrs = targetNodeInfo.attrs;
|
|
19
|
+
|
|
20
|
+
// Early return if trying to transform to the same type
|
|
21
|
+
if (sourceNode.type === targetNodeType) {
|
|
22
|
+
return tr; // No transformation needed
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Prepare transformation context
|
|
26
|
+
var transformationContext = {
|
|
27
|
+
tr: tr,
|
|
28
|
+
sourceNode: sourceNode,
|
|
29
|
+
sourcePos: sourcePos,
|
|
30
|
+
targetNodeType: targetNodeType,
|
|
31
|
+
targetAttrs: targetAttrs
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Route to appropriate transformation strategy based on source node type
|
|
35
|
+
try {
|
|
36
|
+
if ((0, _utils.isBlockNode)(sourceNode)) {
|
|
37
|
+
return (0, _blockTransforms.transformBlockNode)(transformationContext);
|
|
38
|
+
}
|
|
39
|
+
if ((0, _utils.isListNode)(sourceNode)) {
|
|
40
|
+
return (0, _listTransforms.transformListNode)(transformationContext);
|
|
41
|
+
}
|
|
42
|
+
if ((0, _utils.isContainerNode)(sourceNode)) {
|
|
43
|
+
return (0, _containerTransforms.transformContainerNode)(transformationContext);
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
} catch (e) {
|
|
47
|
+
// Node transformation failed
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isListNodeType = exports.isListNode = exports.isContainerNodeType = exports.isContainerNode = exports.isBlockNodeType = exports.isBlockNode = exports.getTargetNodeInfo = void 0;
|
|
7
|
+
var getTargetNodeInfo = exports.getTargetNodeInfo = function getTargetNodeInfo(targetType, nodes) {
|
|
8
|
+
switch (targetType) {
|
|
9
|
+
case 'heading1':
|
|
10
|
+
return {
|
|
11
|
+
nodeType: nodes.heading,
|
|
12
|
+
attrs: {
|
|
13
|
+
level: 1
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
case 'heading2':
|
|
17
|
+
return {
|
|
18
|
+
nodeType: nodes.heading,
|
|
19
|
+
attrs: {
|
|
20
|
+
level: 2
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
case 'heading3':
|
|
24
|
+
return {
|
|
25
|
+
nodeType: nodes.heading,
|
|
26
|
+
attrs: {
|
|
27
|
+
level: 3
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
case 'heading4':
|
|
31
|
+
return {
|
|
32
|
+
nodeType: nodes.heading,
|
|
33
|
+
attrs: {
|
|
34
|
+
level: 4
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
case 'heading5':
|
|
38
|
+
return {
|
|
39
|
+
nodeType: nodes.heading,
|
|
40
|
+
attrs: {
|
|
41
|
+
level: 5
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
case 'heading6':
|
|
45
|
+
return {
|
|
46
|
+
nodeType: nodes.heading,
|
|
47
|
+
attrs: {
|
|
48
|
+
level: 6
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
case 'paragraph':
|
|
52
|
+
return {
|
|
53
|
+
nodeType: nodes.paragraph
|
|
54
|
+
};
|
|
55
|
+
case 'blockquote':
|
|
56
|
+
return {
|
|
57
|
+
nodeType: nodes.blockquote
|
|
58
|
+
};
|
|
59
|
+
case 'expand':
|
|
60
|
+
return {
|
|
61
|
+
nodeType: nodes.expand
|
|
62
|
+
};
|
|
63
|
+
case 'panel':
|
|
64
|
+
return {
|
|
65
|
+
nodeType: nodes.panel,
|
|
66
|
+
attrs: {
|
|
67
|
+
panelType: 'info'
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
case 'codeblock':
|
|
71
|
+
return {
|
|
72
|
+
nodeType: nodes.codeBlock
|
|
73
|
+
};
|
|
74
|
+
case 'bulletList':
|
|
75
|
+
return {
|
|
76
|
+
nodeType: nodes.bulletList
|
|
77
|
+
};
|
|
78
|
+
case 'orderedList':
|
|
79
|
+
return {
|
|
80
|
+
nodeType: nodes.orderedList
|
|
81
|
+
};
|
|
82
|
+
case 'taskList':
|
|
83
|
+
return {
|
|
84
|
+
nodeType: nodes.taskList
|
|
85
|
+
};
|
|
86
|
+
default:
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// Helper functions to categorize node types
|
|
92
|
+
var isBlockNode = exports.isBlockNode = function isBlockNode(node) {
|
|
93
|
+
return ['paragraph', 'heading', 'codeBlock'].includes(node.type.name);
|
|
94
|
+
};
|
|
95
|
+
var isListNode = exports.isListNode = function isListNode(node) {
|
|
96
|
+
return ['bulletList', 'orderedList', 'taskList', 'listItem'].includes(node.type.name);
|
|
97
|
+
};
|
|
98
|
+
var isContainerNode = exports.isContainerNode = function isContainerNode(node) {
|
|
99
|
+
return ['panel', 'expand', 'blockquote'].includes(node.type.name);
|
|
100
|
+
};
|
|
101
|
+
var isBlockNodeType = exports.isBlockNodeType = function isBlockNodeType(nodeType) {
|
|
102
|
+
return ['paragraph', 'heading', 'codeBlock'].includes(nodeType.name);
|
|
103
|
+
};
|
|
104
|
+
var isListNodeType = exports.isListNodeType = function isListNodeType(nodeType) {
|
|
105
|
+
return ['bulletList', 'orderedList', 'taskList'].includes(nodeType.name);
|
|
106
|
+
};
|
|
107
|
+
var isContainerNodeType = exports.isContainerNodeType = function isContainerNodeType(nodeType) {
|
|
108
|
+
return ['panel', 'expand', 'blockquote'].includes(nodeType.name);
|
|
109
|
+
};
|
|
@@ -10,8 +10,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
10
10
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
11
11
|
var _changes = _interopRequireDefault(require("@atlaskit/icon/core/changes"));
|
|
12
12
|
var _chevronRight = _interopRequireDefault(require("@atlaskit/icon/core/chevron-right"));
|
|
13
|
-
var
|
|
14
|
-
var _task = _interopRequireDefault(require("@atlaskit/icon/core/task"));
|
|
13
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
14
|
var _copyBlock = _interopRequireDefault(require("./copy-block"));
|
|
16
15
|
var _copyLink = require("./copy-link");
|
|
17
16
|
var _deleteButton = require("./delete-button");
|
|
@@ -46,23 +45,64 @@ var getMoveUpMoveDownMenuComponents = function getMoveUpMoveDownMenuComponents(a
|
|
|
46
45
|
}
|
|
47
46
|
}];
|
|
48
47
|
};
|
|
49
|
-
var
|
|
50
|
-
var api = _ref.api,
|
|
51
|
-
config = _ref.config;
|
|
48
|
+
var getFormatMenuComponents = function getFormatMenuComponents() {
|
|
52
49
|
return [{
|
|
50
|
+
type: 'block-menu-nested',
|
|
51
|
+
key: 'nested-menu-format',
|
|
52
|
+
parent: {
|
|
53
|
+
type: 'block-menu-section',
|
|
54
|
+
key: 'block-menu-section-primary',
|
|
55
|
+
rank: 100
|
|
56
|
+
},
|
|
57
|
+
component: function component() {
|
|
58
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
59
|
+
children: null
|
|
60
|
+
},
|
|
61
|
+
children = _ref.children;
|
|
62
|
+
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarNestedDropdownMenu, {
|
|
63
|
+
text: "Format",
|
|
64
|
+
elemBefore: /*#__PURE__*/_react.default.createElement(_changes.default, {
|
|
65
|
+
label: ""
|
|
66
|
+
}),
|
|
67
|
+
elemAfter: /*#__PURE__*/_react.default.createElement(_chevronRight.default, {
|
|
68
|
+
label: 'example nested menu'
|
|
69
|
+
})
|
|
70
|
+
}, children);
|
|
71
|
+
}
|
|
72
|
+
}, {
|
|
53
73
|
type: 'block-menu-section',
|
|
54
|
-
key: '
|
|
74
|
+
key: 'nested-menu-format-section-primary',
|
|
75
|
+
parent: {
|
|
76
|
+
type: 'block-menu-nested',
|
|
77
|
+
key: 'nested-menu-format',
|
|
78
|
+
rank: 100
|
|
79
|
+
},
|
|
80
|
+
component: function component() {
|
|
81
|
+
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
82
|
+
children: null
|
|
83
|
+
},
|
|
84
|
+
children = _ref2.children;
|
|
85
|
+
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, null, children);
|
|
86
|
+
}
|
|
87
|
+
}];
|
|
88
|
+
};
|
|
89
|
+
var getBlockMenuComponents = exports.getBlockMenuComponents = function getBlockMenuComponents(_ref3) {
|
|
90
|
+
var api = _ref3.api,
|
|
91
|
+
config = _ref3.config;
|
|
92
|
+
return [].concat((0, _toConsumableArray2.default)((0, _platformFeatureFlags.fg)('platform_editor_block_menu_format') ? getFormatMenuComponents() : []), [{
|
|
93
|
+
type: 'block-menu-section',
|
|
94
|
+
key: 'block-menu-section-primary',
|
|
55
95
|
rank: 100,
|
|
56
|
-
component: function component(
|
|
57
|
-
var children =
|
|
96
|
+
component: function component(_ref4) {
|
|
97
|
+
var children = _ref4.children;
|
|
58
98
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, null, children);
|
|
59
99
|
}
|
|
60
100
|
}, {
|
|
61
101
|
type: 'block-menu-section',
|
|
62
102
|
key: 'block-menu-section-copy',
|
|
63
103
|
rank: 200,
|
|
64
|
-
component: function component(
|
|
65
|
-
var children =
|
|
104
|
+
component: function component(_ref5) {
|
|
105
|
+
var children = _ref5.children;
|
|
66
106
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
|
|
67
107
|
hasSeparator: true
|
|
68
108
|
}, children);
|
|
@@ -98,8 +138,8 @@ var getBlockMenuComponents = exports.getBlockMenuComponents = function getBlockM
|
|
|
98
138
|
type: 'block-menu-section',
|
|
99
139
|
key: 'block-menu-section-move-up-down',
|
|
100
140
|
rank: 300,
|
|
101
|
-
component: function component(
|
|
102
|
-
var children =
|
|
141
|
+
component: function component(_ref6) {
|
|
142
|
+
var children = _ref6.children;
|
|
103
143
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
|
|
104
144
|
hasSeparator: true
|
|
105
145
|
}, children);
|
|
@@ -108,40 +148,13 @@ var getBlockMenuComponents = exports.getBlockMenuComponents = function getBlockM
|
|
|
108
148
|
type: 'block-menu-section',
|
|
109
149
|
key: 'block-menu-section-delete',
|
|
110
150
|
rank: 400,
|
|
111
|
-
component: function component(
|
|
112
|
-
var children =
|
|
151
|
+
component: function component(_ref7) {
|
|
152
|
+
var children = _ref7.children;
|
|
113
153
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
|
|
114
154
|
hasSeparator: true
|
|
115
155
|
}, children);
|
|
116
156
|
}
|
|
117
|
-
}, {
|
|
118
|
-
type: 'block-menu-nested',
|
|
119
|
-
key: 'nested-menu',
|
|
120
|
-
parent: {
|
|
121
|
-
type: 'block-menu-section',
|
|
122
|
-
key: 'block-menu-section-format',
|
|
123
|
-
rank: 100
|
|
124
|
-
},
|
|
125
|
-
component: function component() {
|
|
126
|
-
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarNestedDropdownMenu, {
|
|
127
|
-
text: "Format",
|
|
128
|
-
elemBefore: /*#__PURE__*/_react.default.createElement(_changes.default, {
|
|
129
|
-
label: ""
|
|
130
|
-
}),
|
|
131
|
-
elemAfter: /*#__PURE__*/_react.default.createElement(_chevronRight.default, {
|
|
132
|
-
label: 'example nested menu'
|
|
133
|
-
})
|
|
134
|
-
}, /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, null, /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
|
|
135
|
-
elemBefore: /*#__PURE__*/_react.default.createElement(_task.default, {
|
|
136
|
-
label: ""
|
|
137
|
-
})
|
|
138
|
-
}, "Action item"), /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
|
|
139
|
-
elemBefore: /*#__PURE__*/_react.default.createElement(_listBulleted.default, {
|
|
140
|
-
label: ""
|
|
141
|
-
})
|
|
142
|
-
}, "Bullet list")));
|
|
143
|
-
}
|
|
144
|
-
}].concat((0, _toConsumableArray2.default)(getMoveUpMoveDownMenuComponents(api)), [{
|
|
157
|
+
}], (0, _toConsumableArray2.default)(getMoveUpMoveDownMenuComponents(api)), [{
|
|
145
158
|
type: 'block-menu-item',
|
|
146
159
|
key: 'block-menu-item-delete',
|
|
147
160
|
parent: {
|