@atlaskit/editor-plugin-block-menu 5.1.5 → 5.1.6
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 +7 -0
- package/dist/cjs/editor-commands/transform-node-utils/steps/unwrapLayoutStep.js +38 -0
- package/dist/cjs/editor-commands/transform-node-utils/transform.js +24 -4
- package/dist/cjs/editor-commands/transform-node-utils/unwrapExpandStep.js +6 -7
- package/dist/cjs/editor-commands/transform-node-utils/wrapStep.js +0 -1
- package/dist/es2019/editor-commands/transform-node-utils/steps/unwrapLayoutStep.js +30 -0
- package/dist/es2019/editor-commands/transform-node-utils/transform.js +24 -4
- package/dist/es2019/editor-commands/transform-node-utils/unwrapExpandStep.js +8 -7
- package/dist/es2019/editor-commands/transform-node-utils/wrapStep.js +0 -1
- package/dist/esm/editor-commands/transform-node-utils/steps/unwrapLayoutStep.js +31 -0
- package/dist/esm/editor-commands/transform-node-utils/transform.js +24 -4
- package/dist/esm/editor-commands/transform-node-utils/unwrapExpandStep.js +7 -7
- package/dist/esm/editor-commands/transform-node-utils/wrapStep.js +0 -1
- package/dist/types/editor-commands/transform-node-utils/steps/unwrapLayoutStep.d.ts +14 -0
- package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/unwrapLayoutStep.d.ts +14 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-menu
|
|
2
2
|
|
|
3
|
+
## 5.1.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`a202e97c73f3a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a202e97c73f3a) -
|
|
8
|
+
Adds base transform cases for codeBlock, layout, blockquote.
|
|
9
|
+
|
|
3
10
|
## 5.1.5
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.unwrapLayoutStep = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
/**
|
|
10
|
+
* Unwraps a layoutSection node, extracting content from all columns.
|
|
11
|
+
* Works with any number of columns (2, 3, etc.).
|
|
12
|
+
*
|
|
13
|
+
* Example:
|
|
14
|
+
* layoutSection(
|
|
15
|
+
* layoutColumn(p('a'), p('b')),
|
|
16
|
+
* layoutColumn(p('c')),
|
|
17
|
+
* layoutColumn(p('d'))
|
|
18
|
+
* )
|
|
19
|
+
* → [p('a'), p('b'), p('c'), p('d')]
|
|
20
|
+
*/
|
|
21
|
+
var unwrapLayoutStep = exports.unwrapLayoutStep = function unwrapLayoutStep(nodes) {
|
|
22
|
+
var outputNodes = [];
|
|
23
|
+
nodes.forEach(function (node) {
|
|
24
|
+
var isLayoutSection = node.type.name === 'layoutSection';
|
|
25
|
+
if (isLayoutSection) {
|
|
26
|
+
node.children.forEach(function (column) {
|
|
27
|
+
var isLayoutColumn = column.type.name === 'layoutColumn';
|
|
28
|
+
if (isLayoutColumn) {
|
|
29
|
+
outputNodes.push.apply(outputNodes, (0, _toConsumableArray2.default)(column.children));
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
if (outputNodes.length === 0) {
|
|
35
|
+
return nodes;
|
|
36
|
+
}
|
|
37
|
+
return outputNodes;
|
|
38
|
+
};
|
|
@@ -7,6 +7,7 @@ exports.getOutputNodes = void 0;
|
|
|
7
7
|
var _utils = require("../transform-node-utils/utils");
|
|
8
8
|
var _flattenListStep = require("./flattenListStep");
|
|
9
9
|
var _flattenStep = require("./flattenStep");
|
|
10
|
+
var _unwrapLayoutStep = require("./steps/unwrapLayoutStep");
|
|
10
11
|
var _stubStep = require("./stubStep");
|
|
11
12
|
var _types = require("./types");
|
|
12
13
|
var _unwrapExpandStep = require("./unwrapExpandStep");
|
|
@@ -72,6 +73,26 @@ var TRANSFORM_STEPS_OVERRIDE = {
|
|
|
72
73
|
blockquote: [_unwrapExpandStep.unwrapExpandStep, _wrapStep.wrapStep],
|
|
73
74
|
paragraph: [_unwrapExpandStep.unwrapExpandStep],
|
|
74
75
|
codeBlock: [_unwrapExpandStep.unwrapExpandStep, _flattenStep.flattenStep, _wrapStep.wrapStep]
|
|
76
|
+
},
|
|
77
|
+
blockquote: {
|
|
78
|
+
expand: [_wrapStep.wrapStep],
|
|
79
|
+
nestedExpand: [_wrapStep.wrapStep],
|
|
80
|
+
layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep],
|
|
81
|
+
codeBlock: [_unwrapStep.unwrapStep, _flattenStep.flattenStep, _wrapStep.wrapStep]
|
|
82
|
+
},
|
|
83
|
+
layoutSection: {
|
|
84
|
+
blockquote: [_unwrapLayoutStep.unwrapLayoutStep, _wrapStep.wrapStep],
|
|
85
|
+
expand: [_unwrapLayoutStep.unwrapLayoutStep, _wrapStep.wrapStep],
|
|
86
|
+
panel: [_unwrapLayoutStep.unwrapLayoutStep, _wrapStep.wrapStep],
|
|
87
|
+
codeBlock: [_unwrapLayoutStep.unwrapLayoutStep, _flattenStep.flattenStep, _wrapStep.wrapStep],
|
|
88
|
+
paragraph: [_unwrapLayoutStep.unwrapLayoutStep]
|
|
89
|
+
},
|
|
90
|
+
codeBlock: {
|
|
91
|
+
blockquote: [_wrapStep.wrapStep],
|
|
92
|
+
expand: [_wrapStep.wrapStep],
|
|
93
|
+
nestedExpand: [_wrapStep.wrapStep],
|
|
94
|
+
layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep],
|
|
95
|
+
panel: [_wrapStep.wrapStep]
|
|
75
96
|
}
|
|
76
97
|
};
|
|
77
98
|
var getTransformStepsForNodeTypes = function getTransformStepsForNodeTypes(selectedNodeTypeName, targetNodeTypeName) {
|
|
@@ -89,8 +110,8 @@ var getOutputNodes = exports.getOutputNodes = function getOutputNodes(_ref) {
|
|
|
89
110
|
isNested = _ref.isNested;
|
|
90
111
|
var nodesToReplace = [sourceNode];
|
|
91
112
|
var selectedNodeTypeName = (0, _types.toNodeTypeValue)(sourceNode.type.name);
|
|
92
|
-
var
|
|
93
|
-
targetNodeTypeName = (0, _utils.getTargetNodeTypeNameInContext)(
|
|
113
|
+
var initialTargetNodeTypeName = (0, _types.toNodeTypeValue)(targetNodeType.name);
|
|
114
|
+
var targetNodeTypeName = (0, _utils.getTargetNodeTypeNameInContext)(initialTargetNodeTypeName, isNested);
|
|
94
115
|
if (!selectedNodeTypeName || !targetNodeTypeName) {
|
|
95
116
|
// We may decide to return an empty array or undefined here
|
|
96
117
|
return;
|
|
@@ -105,7 +126,6 @@ var getOutputNodes = exports.getOutputNodes = function getOutputNodes(_ref) {
|
|
|
105
126
|
return;
|
|
106
127
|
}
|
|
107
128
|
return steps.reduce(function (nodes, step) {
|
|
108
|
-
|
|
109
|
-
return result;
|
|
129
|
+
return step(nodes, context);
|
|
110
130
|
}, nodesToReplace);
|
|
111
131
|
};
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.unwrapExpandStep = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _unwrapStep = require("./unwrapStep");
|
|
9
10
|
/**
|
|
10
11
|
* Unwraps an expand/nestedExpand node, converting its title attribute to a paragraph
|
|
11
12
|
* and prepending it to the children.
|
|
@@ -15,8 +16,11 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
|
15
16
|
var unwrapExpandStep = exports.unwrapExpandStep = function unwrapExpandStep(nodes, context) {
|
|
16
17
|
var schema = context.schema;
|
|
17
18
|
var outputNodes = [];
|
|
19
|
+
var _schema$nodes = schema.nodes,
|
|
20
|
+
expand = _schema$nodes.expand,
|
|
21
|
+
nestedExpand = _schema$nodes.nestedExpand;
|
|
18
22
|
nodes.forEach(function (node) {
|
|
19
|
-
var isExpand = node.type.name ===
|
|
23
|
+
var isExpand = node.type.name === expand.name || node.type.name === nestedExpand.name;
|
|
20
24
|
if (isExpand) {
|
|
21
25
|
var _node$attrs;
|
|
22
26
|
var title = (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.title;
|
|
@@ -32,12 +36,7 @@ var unwrapExpandStep = exports.unwrapExpandStep = function unwrapExpandStep(node
|
|
|
32
36
|
// Add the children
|
|
33
37
|
outputNodes.push.apply(outputNodes, (0, _toConsumableArray2.default)(node.children));
|
|
34
38
|
} else {
|
|
35
|
-
|
|
36
|
-
if (node.children.length === 0) {
|
|
37
|
-
outputNodes.push(node);
|
|
38
|
-
} else {
|
|
39
|
-
outputNodes.push.apply(outputNodes, (0, _toConsumableArray2.default)(node.children));
|
|
40
|
-
}
|
|
39
|
+
(0, _unwrapStep.unwrapStep)([node], context);
|
|
41
40
|
}
|
|
42
41
|
});
|
|
43
42
|
return outputNodes;
|
|
@@ -7,7 +7,6 @@ exports.wrapStep = void 0;
|
|
|
7
7
|
var wrapStep = exports.wrapStep = function wrapStep(nodes, context) {
|
|
8
8
|
var schema = context.schema,
|
|
9
9
|
targetNodeTypeName = context.targetNodeTypeName;
|
|
10
|
-
// edge case: nestedExpand
|
|
11
10
|
var outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, nodes);
|
|
12
11
|
if (outputNode) {
|
|
13
12
|
return [outputNode];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unwraps a layoutSection node, extracting content from all columns.
|
|
3
|
+
* Works with any number of columns (2, 3, etc.).
|
|
4
|
+
*
|
|
5
|
+
* Example:
|
|
6
|
+
* layoutSection(
|
|
7
|
+
* layoutColumn(p('a'), p('b')),
|
|
8
|
+
* layoutColumn(p('c')),
|
|
9
|
+
* layoutColumn(p('d'))
|
|
10
|
+
* )
|
|
11
|
+
* → [p('a'), p('b'), p('c'), p('d')]
|
|
12
|
+
*/
|
|
13
|
+
export const unwrapLayoutStep = nodes => {
|
|
14
|
+
const outputNodes = [];
|
|
15
|
+
nodes.forEach(node => {
|
|
16
|
+
const isLayoutSection = node.type.name === 'layoutSection';
|
|
17
|
+
if (isLayoutSection) {
|
|
18
|
+
node.children.forEach(column => {
|
|
19
|
+
const isLayoutColumn = column.type.name === 'layoutColumn';
|
|
20
|
+
if (isLayoutColumn) {
|
|
21
|
+
outputNodes.push(...column.children);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
if (outputNodes.length === 0) {
|
|
27
|
+
return nodes;
|
|
28
|
+
}
|
|
29
|
+
return outputNodes;
|
|
30
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getTargetNodeTypeNameInContext } from '../transform-node-utils/utils';
|
|
2
2
|
import { flattenListStep } from './flattenListStep';
|
|
3
3
|
import { flattenStep } from './flattenStep';
|
|
4
|
+
import { unwrapLayoutStep } from './steps/unwrapLayoutStep';
|
|
4
5
|
import { stubStep } from './stubStep';
|
|
5
6
|
import { NODE_CATEGORY_BY_TYPE, toNodeTypeValue } from './types';
|
|
6
7
|
import { unwrapExpandStep } from './unwrapExpandStep';
|
|
@@ -67,6 +68,26 @@ const TRANSFORM_STEPS_OVERRIDE = {
|
|
|
67
68
|
blockquote: [unwrapExpandStep, wrapStep],
|
|
68
69
|
paragraph: [unwrapExpandStep],
|
|
69
70
|
codeBlock: [unwrapExpandStep, flattenStep, wrapStep]
|
|
71
|
+
},
|
|
72
|
+
blockquote: {
|
|
73
|
+
expand: [wrapStep],
|
|
74
|
+
nestedExpand: [wrapStep],
|
|
75
|
+
layoutSection: [wrapIntoLayoutStep],
|
|
76
|
+
codeBlock: [unwrapStep, flattenStep, wrapStep]
|
|
77
|
+
},
|
|
78
|
+
layoutSection: {
|
|
79
|
+
blockquote: [unwrapLayoutStep, wrapStep],
|
|
80
|
+
expand: [unwrapLayoutStep, wrapStep],
|
|
81
|
+
panel: [unwrapLayoutStep, wrapStep],
|
|
82
|
+
codeBlock: [unwrapLayoutStep, flattenStep, wrapStep],
|
|
83
|
+
paragraph: [unwrapLayoutStep]
|
|
84
|
+
},
|
|
85
|
+
codeBlock: {
|
|
86
|
+
blockquote: [wrapStep],
|
|
87
|
+
expand: [wrapStep],
|
|
88
|
+
nestedExpand: [wrapStep],
|
|
89
|
+
layoutSection: [wrapIntoLayoutStep],
|
|
90
|
+
panel: [wrapStep]
|
|
70
91
|
}
|
|
71
92
|
};
|
|
72
93
|
const getTransformStepsForNodeTypes = (selectedNodeTypeName, targetNodeTypeName) => {
|
|
@@ -85,8 +106,8 @@ export const getOutputNodes = ({
|
|
|
85
106
|
}) => {
|
|
86
107
|
const nodesToReplace = [sourceNode];
|
|
87
108
|
const selectedNodeTypeName = toNodeTypeValue(sourceNode.type.name);
|
|
88
|
-
|
|
89
|
-
targetNodeTypeName = getTargetNodeTypeNameInContext(
|
|
109
|
+
const initialTargetNodeTypeName = toNodeTypeValue(targetNodeType.name);
|
|
110
|
+
const targetNodeTypeName = getTargetNodeTypeNameInContext(initialTargetNodeTypeName, isNested);
|
|
90
111
|
if (!selectedNodeTypeName || !targetNodeTypeName) {
|
|
91
112
|
// We may decide to return an empty array or undefined here
|
|
92
113
|
return;
|
|
@@ -101,7 +122,6 @@ export const getOutputNodes = ({
|
|
|
101
122
|
return;
|
|
102
123
|
}
|
|
103
124
|
return steps.reduce((nodes, step) => {
|
|
104
|
-
|
|
105
|
-
return result;
|
|
125
|
+
return step(nodes, context);
|
|
106
126
|
}, nodesToReplace);
|
|
107
127
|
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { unwrapStep } from './unwrapStep';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Unwraps an expand/nestedExpand node, converting its title attribute to a paragraph
|
|
3
5
|
* and prepending it to the children.
|
|
@@ -9,8 +11,12 @@ export const unwrapExpandStep = (nodes, context) => {
|
|
|
9
11
|
schema
|
|
10
12
|
} = context;
|
|
11
13
|
const outputNodes = [];
|
|
14
|
+
const {
|
|
15
|
+
expand,
|
|
16
|
+
nestedExpand
|
|
17
|
+
} = schema.nodes;
|
|
12
18
|
nodes.forEach(node => {
|
|
13
|
-
const isExpand = node.type.name ===
|
|
19
|
+
const isExpand = node.type.name === expand.name || node.type.name === nestedExpand.name;
|
|
14
20
|
if (isExpand) {
|
|
15
21
|
var _node$attrs;
|
|
16
22
|
const title = (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.title;
|
|
@@ -26,12 +32,7 @@ export const unwrapExpandStep = (nodes, context) => {
|
|
|
26
32
|
// Add the children
|
|
27
33
|
outputNodes.push(...node.children);
|
|
28
34
|
} else {
|
|
29
|
-
|
|
30
|
-
if (node.children.length === 0) {
|
|
31
|
-
outputNodes.push(node);
|
|
32
|
-
} else {
|
|
33
|
-
outputNodes.push(...node.children);
|
|
34
|
-
}
|
|
35
|
+
unwrapStep([node], context);
|
|
35
36
|
}
|
|
36
37
|
});
|
|
37
38
|
return outputNodes;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
/**
|
|
3
|
+
* Unwraps a layoutSection node, extracting content from all columns.
|
|
4
|
+
* Works with any number of columns (2, 3, etc.).
|
|
5
|
+
*
|
|
6
|
+
* Example:
|
|
7
|
+
* layoutSection(
|
|
8
|
+
* layoutColumn(p('a'), p('b')),
|
|
9
|
+
* layoutColumn(p('c')),
|
|
10
|
+
* layoutColumn(p('d'))
|
|
11
|
+
* )
|
|
12
|
+
* → [p('a'), p('b'), p('c'), p('d')]
|
|
13
|
+
*/
|
|
14
|
+
export var unwrapLayoutStep = function unwrapLayoutStep(nodes) {
|
|
15
|
+
var outputNodes = [];
|
|
16
|
+
nodes.forEach(function (node) {
|
|
17
|
+
var isLayoutSection = node.type.name === 'layoutSection';
|
|
18
|
+
if (isLayoutSection) {
|
|
19
|
+
node.children.forEach(function (column) {
|
|
20
|
+
var isLayoutColumn = column.type.name === 'layoutColumn';
|
|
21
|
+
if (isLayoutColumn) {
|
|
22
|
+
outputNodes.push.apply(outputNodes, _toConsumableArray(column.children));
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
if (outputNodes.length === 0) {
|
|
28
|
+
return nodes;
|
|
29
|
+
}
|
|
30
|
+
return outputNodes;
|
|
31
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getTargetNodeTypeNameInContext } from '../transform-node-utils/utils';
|
|
2
2
|
import { flattenListStep } from './flattenListStep';
|
|
3
3
|
import { flattenStep } from './flattenStep';
|
|
4
|
+
import { unwrapLayoutStep } from './steps/unwrapLayoutStep';
|
|
4
5
|
import { stubStep } from './stubStep';
|
|
5
6
|
import { NODE_CATEGORY_BY_TYPE, toNodeTypeValue } from './types';
|
|
6
7
|
import { unwrapExpandStep } from './unwrapExpandStep';
|
|
@@ -67,6 +68,26 @@ var TRANSFORM_STEPS_OVERRIDE = {
|
|
|
67
68
|
blockquote: [unwrapExpandStep, wrapStep],
|
|
68
69
|
paragraph: [unwrapExpandStep],
|
|
69
70
|
codeBlock: [unwrapExpandStep, flattenStep, wrapStep]
|
|
71
|
+
},
|
|
72
|
+
blockquote: {
|
|
73
|
+
expand: [wrapStep],
|
|
74
|
+
nestedExpand: [wrapStep],
|
|
75
|
+
layoutSection: [wrapIntoLayoutStep],
|
|
76
|
+
codeBlock: [unwrapStep, flattenStep, wrapStep]
|
|
77
|
+
},
|
|
78
|
+
layoutSection: {
|
|
79
|
+
blockquote: [unwrapLayoutStep, wrapStep],
|
|
80
|
+
expand: [unwrapLayoutStep, wrapStep],
|
|
81
|
+
panel: [unwrapLayoutStep, wrapStep],
|
|
82
|
+
codeBlock: [unwrapLayoutStep, flattenStep, wrapStep],
|
|
83
|
+
paragraph: [unwrapLayoutStep]
|
|
84
|
+
},
|
|
85
|
+
codeBlock: {
|
|
86
|
+
blockquote: [wrapStep],
|
|
87
|
+
expand: [wrapStep],
|
|
88
|
+
nestedExpand: [wrapStep],
|
|
89
|
+
layoutSection: [wrapIntoLayoutStep],
|
|
90
|
+
panel: [wrapStep]
|
|
70
91
|
}
|
|
71
92
|
};
|
|
72
93
|
var getTransformStepsForNodeTypes = function getTransformStepsForNodeTypes(selectedNodeTypeName, targetNodeTypeName) {
|
|
@@ -84,8 +105,8 @@ export var getOutputNodes = function getOutputNodes(_ref) {
|
|
|
84
105
|
isNested = _ref.isNested;
|
|
85
106
|
var nodesToReplace = [sourceNode];
|
|
86
107
|
var selectedNodeTypeName = toNodeTypeValue(sourceNode.type.name);
|
|
87
|
-
var
|
|
88
|
-
targetNodeTypeName = getTargetNodeTypeNameInContext(
|
|
108
|
+
var initialTargetNodeTypeName = toNodeTypeValue(targetNodeType.name);
|
|
109
|
+
var targetNodeTypeName = getTargetNodeTypeNameInContext(initialTargetNodeTypeName, isNested);
|
|
89
110
|
if (!selectedNodeTypeName || !targetNodeTypeName) {
|
|
90
111
|
// We may decide to return an empty array or undefined here
|
|
91
112
|
return;
|
|
@@ -100,7 +121,6 @@ export var getOutputNodes = function getOutputNodes(_ref) {
|
|
|
100
121
|
return;
|
|
101
122
|
}
|
|
102
123
|
return steps.reduce(function (nodes, step) {
|
|
103
|
-
|
|
104
|
-
return result;
|
|
124
|
+
return step(nodes, context);
|
|
105
125
|
}, nodesToReplace);
|
|
106
126
|
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import { unwrapStep } from './unwrapStep';
|
|
3
|
+
|
|
2
4
|
/**
|
|
3
5
|
* Unwraps an expand/nestedExpand node, converting its title attribute to a paragraph
|
|
4
6
|
* and prepending it to the children.
|
|
@@ -8,8 +10,11 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
8
10
|
export var unwrapExpandStep = function unwrapExpandStep(nodes, context) {
|
|
9
11
|
var schema = context.schema;
|
|
10
12
|
var outputNodes = [];
|
|
13
|
+
var _schema$nodes = schema.nodes,
|
|
14
|
+
expand = _schema$nodes.expand,
|
|
15
|
+
nestedExpand = _schema$nodes.nestedExpand;
|
|
11
16
|
nodes.forEach(function (node) {
|
|
12
|
-
var isExpand = node.type.name ===
|
|
17
|
+
var isExpand = node.type.name === expand.name || node.type.name === nestedExpand.name;
|
|
13
18
|
if (isExpand) {
|
|
14
19
|
var _node$attrs;
|
|
15
20
|
var title = (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.title;
|
|
@@ -25,12 +30,7 @@ export var unwrapExpandStep = function unwrapExpandStep(nodes, context) {
|
|
|
25
30
|
// Add the children
|
|
26
31
|
outputNodes.push.apply(outputNodes, _toConsumableArray(node.children));
|
|
27
32
|
} else {
|
|
28
|
-
|
|
29
|
-
if (node.children.length === 0) {
|
|
30
|
-
outputNodes.push(node);
|
|
31
|
-
} else {
|
|
32
|
-
outputNodes.push.apply(outputNodes, _toConsumableArray(node.children));
|
|
33
|
-
}
|
|
33
|
+
unwrapStep([node], context);
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
return outputNodes;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export var wrapStep = function wrapStep(nodes, context) {
|
|
2
2
|
var schema = context.schema,
|
|
3
3
|
targetNodeTypeName = context.targetNodeTypeName;
|
|
4
|
-
// edge case: nestedExpand
|
|
5
4
|
var outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, nodes);
|
|
6
5
|
if (outputNode) {
|
|
7
6
|
return [outputNode];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TransformStep } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Unwraps a layoutSection node, extracting content from all columns.
|
|
4
|
+
* Works with any number of columns (2, 3, etc.).
|
|
5
|
+
*
|
|
6
|
+
* Example:
|
|
7
|
+
* layoutSection(
|
|
8
|
+
* layoutColumn(p('a'), p('b')),
|
|
9
|
+
* layoutColumn(p('c')),
|
|
10
|
+
* layoutColumn(p('d'))
|
|
11
|
+
* )
|
|
12
|
+
* → [p('a'), p('b'), p('c'), p('d')]
|
|
13
|
+
*/
|
|
14
|
+
export declare const unwrapLayoutStep: TransformStep;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TransformStep } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Unwraps a layoutSection node, extracting content from all columns.
|
|
4
|
+
* Works with any number of columns (2, 3, etc.).
|
|
5
|
+
*
|
|
6
|
+
* Example:
|
|
7
|
+
* layoutSection(
|
|
8
|
+
* layoutColumn(p('a'), p('b')),
|
|
9
|
+
* layoutColumn(p('c')),
|
|
10
|
+
* layoutColumn(p('d'))
|
|
11
|
+
* )
|
|
12
|
+
* → [p('a'), p('b'), p('c'), p('d')]
|
|
13
|
+
*/
|
|
14
|
+
export declare const unwrapLayoutStep: TransformStep;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-menu",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.6",
|
|
4
4
|
"description": "BlockMenu plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@atlaskit/css": "^0.17.0",
|
|
32
32
|
"@atlaskit/dropdown-menu": "^16.3.0",
|
|
33
33
|
"@atlaskit/editor-plugin-analytics": "^6.2.0",
|
|
34
|
-
"@atlaskit/editor-plugin-block-controls": "^7.
|
|
34
|
+
"@atlaskit/editor-plugin-block-controls": "^7.12.0",
|
|
35
35
|
"@atlaskit/editor-plugin-decorations": "^6.1.0",
|
|
36
36
|
"@atlaskit/editor-plugin-selection": "^6.1.0",
|
|
37
37
|
"@atlaskit/editor-plugin-user-intent": "^4.0.0",
|
|
@@ -44,7 +44,7 @@
|
|
|
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": "^14.
|
|
47
|
+
"@atlaskit/tmp-editor-statsig": "^14.7.0",
|
|
48
48
|
"@atlaskit/tokens": "^8.4.0",
|
|
49
49
|
"@babel/runtime": "^7.0.0"
|
|
50
50
|
},
|