@atlaskit/editor-plugin-block-menu 9.2.8 → 9.2.10
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-actions/isTransformToTargetDisabled.js +1 -1
- package/dist/cjs/editor-commands/selection.js +2 -1
- package/dist/cjs/editor-commands/transform-node-utils/TRANSFORMATION_MATRIX.js +272 -201
- package/dist/cjs/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +1 -1
- package/dist/cjs/editor-commands/transform-node-utils/transform.js +26 -6
- package/dist/cjs/editor-commands/transform-node-utils/types.js +1 -0
- package/dist/cjs/editor-commands/transform-node-utils/utils.js +14 -7
- package/dist/cjs/ui/utils/copyLink.js +17 -17
- package/dist/es2019/editor-actions/isTransformToTargetDisabled.js +1 -1
- package/dist/es2019/editor-commands/selection.js +2 -1
- package/dist/es2019/editor-commands/transform-node-utils/TRANSFORMATION_MATRIX.js +75 -7
- package/dist/es2019/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +1 -1
- package/dist/es2019/editor-commands/transform-node-utils/transform.js +25 -5
- package/dist/es2019/editor-commands/transform-node-utils/types.js +1 -0
- package/dist/es2019/editor-commands/transform-node-utils/utils.js +8 -1
- package/dist/esm/editor-actions/isTransformToTargetDisabled.js +1 -1
- package/dist/esm/editor-commands/selection.js +2 -1
- package/dist/esm/editor-commands/transform-node-utils/TRANSFORMATION_MATRIX.js +270 -200
- package/dist/esm/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +1 -1
- package/dist/esm/editor-commands/transform-node-utils/transform.js +25 -5
- package/dist/esm/editor-commands/transform-node-utils/types.js +1 -0
- package/dist/esm/editor-commands/transform-node-utils/utils.js +8 -1
- package/dist/esm/ui/utils/copyLink.js +17 -17
- package/dist/types/editor-commands/transform-node-utils/TRANSFORMATION_MATRIX.d.ts +4 -1
- package/dist/types/editor-commands/transform-node-utils/transform.d.ts +1 -0
- package/dist/types/editor-commands/transform-node-utils/types.d.ts +1 -1
- package/dist/types/editor-commands/transform-node-utils/utils.d.ts +1 -1
- package/dist/types/editor-commands/types.d.ts +1 -1
- package/dist/types-ts4.5/editor-commands/transform-node-utils/TRANSFORMATION_MATRIX.d.ts +4 -1
- package/dist/types-ts4.5/editor-commands/transform-node-utils/transform.d.ts +1 -0
- package/dist/types-ts4.5/editor-commands/transform-node-utils/types.d.ts +1 -1
- package/dist/types-ts4.5/editor-commands/transform-node-utils/utils.d.ts +1 -1
- package/dist/types-ts4.5/editor-commands/types.d.ts +1 -1
- package/package.json +5 -5
|
@@ -4,9 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.isTextNode = exports.isListNode = exports.getTargetNodeTypeNameInContext = exports.getSelectedNode = exports.getBlockNodesInRange = exports.createTextContent = exports.convertTextNodeToParagraph = exports.convertNestedExpandToExpand = exports.convertExpandToNestedExpand = void 0;
|
|
7
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
7
8
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
-
var
|
|
9
|
+
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
9
10
|
var _editorTables = require("@atlaskit/editor-tables");
|
|
11
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
10
12
|
var _types = require("./types");
|
|
11
13
|
/**
|
|
12
14
|
* Determines if a node is a text node (heading or paragraph).
|
|
@@ -30,7 +32,7 @@ var getSelectedNode = exports.getSelectedNode = function getSelectedNode(selecti
|
|
|
30
32
|
};
|
|
31
33
|
}
|
|
32
34
|
if (selection instanceof _editorTables.CellSelection) {
|
|
33
|
-
var tableSelected = (0,
|
|
35
|
+
var tableSelected = (0, _utils2.findParentNodeOfType)(selection.$from.doc.type.schema.nodes.table)(selection);
|
|
34
36
|
return tableSelected;
|
|
35
37
|
}
|
|
36
38
|
if (selection instanceof _state.TextSelection) {
|
|
@@ -42,32 +44,37 @@ var getSelectedNode = exports.getSelectedNode = function getSelectedNode(selecti
|
|
|
42
44
|
codeBlock = _selection$$from$doc$.codeBlock,
|
|
43
45
|
paragraph = _selection$$from$doc$.paragraph,
|
|
44
46
|
heading = _selection$$from$doc$.heading;
|
|
45
|
-
var quoteSelected = (0,
|
|
47
|
+
var quoteSelected = (0, _utils2.findParentNodeOfType)([blockquote])(selection);
|
|
46
48
|
if (quoteSelected) {
|
|
47
49
|
return quoteSelected;
|
|
48
50
|
}
|
|
49
|
-
var codeBlockSelected = (0,
|
|
51
|
+
var codeBlockSelected = (0, _utils2.findParentNodeOfType)([codeBlock])(selection);
|
|
50
52
|
if (codeBlockSelected) {
|
|
51
53
|
return codeBlockSelected;
|
|
52
54
|
}
|
|
53
|
-
var listSelected = (0,
|
|
55
|
+
var listSelected = (0, _utils2.findParentNodeOfType)([bulletList, taskList, orderedList])(selection);
|
|
54
56
|
if (listSelected) {
|
|
55
57
|
return listSelected;
|
|
56
58
|
}
|
|
57
|
-
var paragraphOrHeading = (0,
|
|
59
|
+
var paragraphOrHeading = (0, _utils2.findParentNodeOfType)([paragraph, heading])(selection);
|
|
58
60
|
if (paragraphOrHeading) {
|
|
59
61
|
return paragraphOrHeading;
|
|
60
62
|
}
|
|
61
63
|
}
|
|
62
64
|
return undefined;
|
|
63
65
|
};
|
|
64
|
-
var getTargetNodeTypeNameInContext = exports.getTargetNodeTypeNameInContext = function getTargetNodeTypeNameInContext(nodeTypeName, isNested, parentNode) {
|
|
66
|
+
var getTargetNodeTypeNameInContext = exports.getTargetNodeTypeNameInContext = function getTargetNodeTypeNameInContext(nodeTypeName, isNested, parentNode, schema) {
|
|
65
67
|
if (parentNode && isNested && (parentNode.type.name === 'layoutColumn' || parentNode.type.name === 'bodiedSyncBlock')) {
|
|
66
68
|
return nodeTypeName;
|
|
67
69
|
}
|
|
68
70
|
if (nodeTypeName === 'expand' && isNested) {
|
|
69
71
|
return 'nestedExpand';
|
|
70
72
|
}
|
|
73
|
+
if (nodeTypeName === 'panel' && schema !== null && schema !== void 0 && schema.nodes['panel_c1'] && (0, _expValEquals.expValEquals)('platform_editor_nest_table_in_panel', 'isEnabled', true)) {
|
|
74
|
+
if (!parentNode || (0, _utils.isNodeTypeValidChildOf)('panel_c1', parentNode, schema)) {
|
|
75
|
+
return 'panel_c1';
|
|
76
|
+
}
|
|
77
|
+
}
|
|
71
78
|
return nodeTypeName;
|
|
72
79
|
};
|
|
73
80
|
|
|
@@ -13,50 +13,50 @@ var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
|
13
13
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
14
14
|
var copyLink = exports.copyLink = /*#__PURE__*/function () {
|
|
15
15
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref) {
|
|
16
|
-
var getLinkPath, _ref$blockLinkHashPre, blockLinkHashPrefix, selection, blockRange, node, path, url, href;
|
|
17
|
-
return _regenerator.default.wrap(function
|
|
16
|
+
var getLinkPath, _ref$blockLinkHashPre, blockLinkHashPrefix, selection, blockRange, node, path, url, href, _t;
|
|
17
|
+
return _regenerator.default.wrap(function (_context) {
|
|
18
18
|
while (1) switch (_context.prev = _context.next) {
|
|
19
19
|
case 0:
|
|
20
20
|
getLinkPath = _ref.getLinkPath, _ref$blockLinkHashPre = _ref.blockLinkHashPrefix, blockLinkHashPrefix = _ref$blockLinkHashPre === void 0 ? _blockMenu.DEFAULT_BLOCK_LINK_HASH_PREFIX : _ref$blockLinkHashPre, selection = _ref.selection;
|
|
21
21
|
blockRange = (0, _selection.expandSelectionToBlockRange)(selection);
|
|
22
22
|
if (blockRange) {
|
|
23
|
-
_context.next =
|
|
23
|
+
_context.next = 1;
|
|
24
24
|
break;
|
|
25
25
|
}
|
|
26
26
|
return _context.abrupt("return", false);
|
|
27
|
-
case
|
|
27
|
+
case 1:
|
|
28
28
|
// get the link to the first node in the selection
|
|
29
29
|
node = blockRange.$from.nodeAfter;
|
|
30
30
|
if (!(!node || !node.attrs || !node.attrs.localId)) {
|
|
31
|
-
_context.next =
|
|
31
|
+
_context.next = 2;
|
|
32
32
|
break;
|
|
33
33
|
}
|
|
34
34
|
return _context.abrupt("return", false);
|
|
35
|
-
case
|
|
35
|
+
case 2:
|
|
36
36
|
path = (getLinkPath === null || getLinkPath === void 0 ? void 0 : getLinkPath()) || location.pathname;
|
|
37
|
-
_context.prev =
|
|
37
|
+
_context.prev = 3;
|
|
38
38
|
url = new URL(location.origin + path);
|
|
39
39
|
url.hash = (0, _blockMenu.createBlockLinkHashValue)(node.attrs.localId, blockLinkHashPrefix);
|
|
40
40
|
href = url.toString();
|
|
41
|
-
_context.next =
|
|
41
|
+
_context.next = 4;
|
|
42
42
|
return (0, _clipboard.copyToClipboard)(href);
|
|
43
|
-
case
|
|
44
|
-
_context.next =
|
|
43
|
+
case 4:
|
|
44
|
+
_context.next = 6;
|
|
45
45
|
break;
|
|
46
|
-
case
|
|
47
|
-
_context.prev =
|
|
48
|
-
|
|
49
|
-
(0, _monitoring.logException)(
|
|
46
|
+
case 5:
|
|
47
|
+
_context.prev = 5;
|
|
48
|
+
_t = _context["catch"](3);
|
|
49
|
+
(0, _monitoring.logException)(_t, {
|
|
50
50
|
location: 'editor-plugin-block-menu'
|
|
51
51
|
});
|
|
52
52
|
return _context.abrupt("return", false);
|
|
53
|
-
case
|
|
53
|
+
case 6:
|
|
54
54
|
return _context.abrupt("return", true);
|
|
55
|
-
case
|
|
55
|
+
case 7:
|
|
56
56
|
case "end":
|
|
57
57
|
return _context.stop();
|
|
58
58
|
}
|
|
59
|
-
}, _callee, null, [[
|
|
59
|
+
}, _callee, null, [[3, 5]]);
|
|
60
60
|
}));
|
|
61
61
|
return function copyLink(_x) {
|
|
62
62
|
return _ref2.apply(this, arguments);
|
|
@@ -4,7 +4,7 @@ import { isTransformDisabledBasedOnStepsConfig } from '../editor-commands/transf
|
|
|
4
4
|
import { toNodeTypeValue } from '../editor-commands/transform-node-utils/types';
|
|
5
5
|
import { getBlockNodesInRange, getTargetNodeTypeNameInContext } from '../editor-commands/transform-node-utils/utils';
|
|
6
6
|
export const canParentContainNodeType = (schema, selectedNodeTypeName, parentNode, nodeTypeName, nodeTypeAttrs) => {
|
|
7
|
-
const adjustedNodeTypeName = getTargetNodeTypeNameInContext(nodeTypeName, true, parentNode);
|
|
7
|
+
const adjustedNodeTypeName = getTargetNodeTypeNameInContext(nodeTypeName, true, parentNode, schema);
|
|
8
8
|
if (!adjustedNodeTypeName) {
|
|
9
9
|
return false;
|
|
10
10
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
2
3
|
/**
|
|
3
4
|
* Sets the appropriate selection after transforming a node to a target type
|
|
4
5
|
* @param newTr - The transaction containing the transformed node
|
|
@@ -17,7 +18,7 @@ export const setSelectionAfterTransform = (newTr, nodePos, targetType) => {
|
|
|
17
18
|
// Check if target type is other than list, text, heading, blockquotes
|
|
18
19
|
const isListNode = targetType === 'bulletList' || targetType === 'orderedList' || targetType === 'taskList';
|
|
19
20
|
const isBlockquote = targetType === 'blockquote';
|
|
20
|
-
const isContainer = ['panel', 'expand', 'codeBlock', 'layoutSection'].includes(targetType);
|
|
21
|
+
const isContainer = expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? ['panel', 'panel_c1', 'expand', 'codeBlock', 'layoutSection'].includes(targetType) : ['panel', 'expand', 'codeBlock', 'layoutSection'].includes(targetType);
|
|
21
22
|
if (isListNode || isBlockquote) {
|
|
22
23
|
// For taskList, select all content within the list
|
|
23
24
|
const textStart = transformedNodePos.pos + 1; // Inside the taskList
|
|
@@ -14,9 +14,13 @@ import { wrapBlockquoteToDecisionListStep } from './steps/wrapBlockquoteToDecisi
|
|
|
14
14
|
import { wrapIntoListStep } from './steps/wrapIntoListStep';
|
|
15
15
|
import { wrapMixedContentStep } from './steps/wrapMixedContentStep';
|
|
16
16
|
import { wrapStep } from './steps/wrapStep';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Creates the transformation matrix for all node type pairs.
|
|
19
|
+
* When includePanelC1 is true (platform_editor_nest_table_in_panel experiment on),
|
|
20
|
+
* panel_c1 entries are included as both source and target types.
|
|
21
|
+
* If a transformation is not defined (undefined), it is not available.
|
|
22
|
+
*/
|
|
23
|
+
const createTransformationMatrix = includePanelC1 => ({
|
|
20
24
|
paragraph: {
|
|
21
25
|
heading: [flattenStep, applyTargetTextTypeStep],
|
|
22
26
|
blockquote: [wrapMixedContentStep],
|
|
@@ -25,6 +29,9 @@ export const TRANSFORMATION_MATRIX = {
|
|
|
25
29
|
nestedExpand: [wrapMixedContentStep],
|
|
26
30
|
layoutSection: [wrapMixedContentStep],
|
|
27
31
|
panel: [wrapMixedContentStep],
|
|
32
|
+
...(includePanelC1 ? {
|
|
33
|
+
panel_c1: [wrapMixedContentStep]
|
|
34
|
+
} : {}),
|
|
28
35
|
bulletList: [wrapIntoListStep],
|
|
29
36
|
orderedList: [wrapIntoListStep],
|
|
30
37
|
taskList: [wrapIntoListStep],
|
|
@@ -39,6 +46,9 @@ export const TRANSFORMATION_MATRIX = {
|
|
|
39
46
|
nestedExpand: [wrapMixedContentStep],
|
|
40
47
|
layoutSection: [wrapMixedContentStep],
|
|
41
48
|
panel: [wrapMixedContentStep],
|
|
49
|
+
...(includePanelC1 ? {
|
|
50
|
+
panel_c1: [wrapMixedContentStep]
|
|
51
|
+
} : {}),
|
|
42
52
|
bulletList: [wrapIntoListStep],
|
|
43
53
|
orderedList: [wrapIntoListStep],
|
|
44
54
|
taskList: [wrapIntoListStep],
|
|
@@ -52,8 +62,19 @@ export const TRANSFORMATION_MATRIX = {
|
|
|
52
62
|
layoutSection: [unwrapStep, wrapMixedContentStep],
|
|
53
63
|
paragraph: [unwrapStep]
|
|
54
64
|
},
|
|
65
|
+
panel_c1: includePanelC1 ? {
|
|
66
|
+
blockquote: [unwrapStep, wrapMixedContentStep],
|
|
67
|
+
codeBlock: [unwrapStep, wrapMixedContentStep],
|
|
68
|
+
expand: [unwrapStep, wrapStep],
|
|
69
|
+
nestedExpand: [unwrapStep, wrapStep],
|
|
70
|
+
layoutSection: [unwrapStep, wrapMixedContentStep],
|
|
71
|
+
paragraph: [unwrapStep]
|
|
72
|
+
} : {},
|
|
55
73
|
expand: {
|
|
56
74
|
panel: [unwrapExpandStep, wrapMixedContentStep],
|
|
75
|
+
...(includePanelC1 ? {
|
|
76
|
+
panel_c1: [unwrapExpandStep, wrapMixedContentStep]
|
|
77
|
+
} : {}),
|
|
57
78
|
blockquote: [unwrapExpandStep, wrapMixedContentStep],
|
|
58
79
|
layoutSection: [unwrapExpandStep, wrapMixedContentStep],
|
|
59
80
|
nestedExpand: [unwrapExpandStep, wrapStep],
|
|
@@ -61,6 +82,9 @@ export const TRANSFORMATION_MATRIX = {
|
|
|
61
82
|
},
|
|
62
83
|
nestedExpand: {
|
|
63
84
|
panel: [unwrapExpandStep, wrapMixedContentStep],
|
|
85
|
+
...(includePanelC1 ? {
|
|
86
|
+
panel_c1: [unwrapExpandStep, wrapMixedContentStep]
|
|
87
|
+
} : {}),
|
|
64
88
|
blockquote: [unwrapExpandStep, wrapMixedContentStep],
|
|
65
89
|
layoutSection: [unwrapExpandStep, wrapMixedContentStep],
|
|
66
90
|
paragraph: [unwrapExpandStep]
|
|
@@ -70,6 +94,9 @@ export const TRANSFORMATION_MATRIX = {
|
|
|
70
94
|
nestedExpand: [wrapStep],
|
|
71
95
|
layoutSection: [wrapMixedContentStep],
|
|
72
96
|
panel: [unwrapStep, wrapStep],
|
|
97
|
+
...(includePanelC1 ? {
|
|
98
|
+
panel_c1: [unwrapStep, wrapStep]
|
|
99
|
+
} : {}),
|
|
73
100
|
paragraph: [unwrapStep],
|
|
74
101
|
decisionList: [unwrapStep, wrapBlockquoteToDecisionListStep]
|
|
75
102
|
},
|
|
@@ -78,6 +105,9 @@ export const TRANSFORMATION_MATRIX = {
|
|
|
78
105
|
expand: [unwrapLayoutStep, wrapStep],
|
|
79
106
|
nestedExpand: [unwrapLayoutStep, wrapStep],
|
|
80
107
|
panel: [unwrapLayoutStep, wrapMixedContentStep],
|
|
108
|
+
...(includePanelC1 ? {
|
|
109
|
+
panel_c1: [unwrapLayoutStep, wrapMixedContentStep]
|
|
110
|
+
} : {}),
|
|
81
111
|
paragraph: [unwrapLayoutStep]
|
|
82
112
|
},
|
|
83
113
|
codeBlock: {
|
|
@@ -86,6 +116,9 @@ export const TRANSFORMATION_MATRIX = {
|
|
|
86
116
|
nestedExpand: [wrapStep],
|
|
87
117
|
layoutSection: [wrapMixedContentStep],
|
|
88
118
|
panel: [wrapStep],
|
|
119
|
+
...(includePanelC1 ? {
|
|
120
|
+
panel_c1: [wrapStep]
|
|
121
|
+
} : {}),
|
|
89
122
|
paragraph: [applyTargetTextTypeStep]
|
|
90
123
|
},
|
|
91
124
|
bulletList: {
|
|
@@ -97,6 +130,9 @@ export const TRANSFORMATION_MATRIX = {
|
|
|
97
130
|
nestedExpand: [wrapStep],
|
|
98
131
|
layoutSection: [wrapMixedContentStep],
|
|
99
132
|
panel: [wrapStep],
|
|
133
|
+
...(includePanelC1 ? {
|
|
134
|
+
panel_c1: [wrapStep]
|
|
135
|
+
} : {}),
|
|
100
136
|
paragraph: [flattenListStep, unwrapListStep, applyTargetTextTypeStep]
|
|
101
137
|
},
|
|
102
138
|
orderedList: {
|
|
@@ -108,6 +144,9 @@ export const TRANSFORMATION_MATRIX = {
|
|
|
108
144
|
nestedExpand: [wrapStep],
|
|
109
145
|
layoutSection: [wrapMixedContentStep],
|
|
110
146
|
panel: [wrapStep],
|
|
147
|
+
...(includePanelC1 ? {
|
|
148
|
+
panel_c1: [wrapStep]
|
|
149
|
+
} : {}),
|
|
111
150
|
paragraph: [flattenListStep, unwrapListStep, applyTargetTextTypeStep]
|
|
112
151
|
},
|
|
113
152
|
taskList: {
|
|
@@ -118,6 +157,9 @@ export const TRANSFORMATION_MATRIX = {
|
|
|
118
157
|
nestedExpand: [wrapStep],
|
|
119
158
|
layoutSection: [wrapMixedContentStep],
|
|
120
159
|
panel: [wrapStep],
|
|
160
|
+
...(includePanelC1 ? {
|
|
161
|
+
panel_c1: [wrapStep]
|
|
162
|
+
} : {}),
|
|
121
163
|
paragraph: [flattenListStep, unwrapListStep, applyTargetTextTypeStep]
|
|
122
164
|
},
|
|
123
165
|
table: {
|
|
@@ -131,6 +173,9 @@ export const TRANSFORMATION_MATRIX = {
|
|
|
131
173
|
nestedExpand: [wrapStep],
|
|
132
174
|
layoutSection: [wrapMixedContentStep],
|
|
133
175
|
panel: [wrapStep],
|
|
176
|
+
...(includePanelC1 ? {
|
|
177
|
+
panel_c1: [wrapStep]
|
|
178
|
+
} : {}),
|
|
134
179
|
bulletList: [wrapIntoListStep],
|
|
135
180
|
orderedList: [wrapIntoListStep]
|
|
136
181
|
},
|
|
@@ -139,7 +184,10 @@ export const TRANSFORMATION_MATRIX = {
|
|
|
139
184
|
expand: [wrapStep],
|
|
140
185
|
nestedExpand: [wrapStep],
|
|
141
186
|
layoutSection: [wrapMixedContentStep],
|
|
142
|
-
panel: [wrapStep]
|
|
187
|
+
panel: [wrapStep],
|
|
188
|
+
...(includePanelC1 ? {
|
|
189
|
+
panel_c1: [wrapStep]
|
|
190
|
+
} : {})
|
|
143
191
|
},
|
|
144
192
|
media: {
|
|
145
193
|
blockquote: [wrapStep],
|
|
@@ -148,6 +196,9 @@ export const TRANSFORMATION_MATRIX = {
|
|
|
148
196
|
nestedExpand: [wrapStep],
|
|
149
197
|
layoutSection: [wrapStep],
|
|
150
198
|
panel: [wrapStep],
|
|
199
|
+
...(includePanelC1 ? {
|
|
200
|
+
panel_c1: [wrapStep]
|
|
201
|
+
} : {}),
|
|
151
202
|
bulletList: [wrapIntoListStep],
|
|
152
203
|
orderedList: [wrapIntoListStep],
|
|
153
204
|
taskList: [wrapIntoListStep],
|
|
@@ -162,6 +213,9 @@ export const TRANSFORMATION_MATRIX = {
|
|
|
162
213
|
nestedExpand: [wrapStep],
|
|
163
214
|
layoutSection: [wrapMixedContentStep],
|
|
164
215
|
panel: [wrapStep],
|
|
216
|
+
...(includePanelC1 ? {
|
|
217
|
+
panel_c1: [wrapStep]
|
|
218
|
+
} : {}),
|
|
165
219
|
paragraph: [flattenListStep, unwrapListStep, applyTargetTextTypeStep],
|
|
166
220
|
heading: [flattenListStep, unwrapListStep, applyTargetTextTypeStep]
|
|
167
221
|
},
|
|
@@ -169,7 +223,10 @@ export const TRANSFORMATION_MATRIX = {
|
|
|
169
223
|
expand: [wrapStep],
|
|
170
224
|
nestedExpand: [wrapStep],
|
|
171
225
|
layoutSection: [wrapMixedContentStep],
|
|
172
|
-
panel: [wrapStep]
|
|
226
|
+
panel: [wrapStep],
|
|
227
|
+
...(includePanelC1 ? {
|
|
228
|
+
panel_c1: [wrapStep]
|
|
229
|
+
} : {})
|
|
173
230
|
},
|
|
174
231
|
embedCard: {
|
|
175
232
|
expand: [wrapStep],
|
|
@@ -181,7 +238,10 @@ export const TRANSFORMATION_MATRIX = {
|
|
|
181
238
|
expand: [wrapStep],
|
|
182
239
|
nestedExpand: [wrapStep],
|
|
183
240
|
layoutSection: [wrapMixedContentStep],
|
|
184
|
-
panel: [wrapStep]
|
|
241
|
+
panel: [wrapStep],
|
|
242
|
+
...(includePanelC1 ? {
|
|
243
|
+
panel_c1: [wrapStep]
|
|
244
|
+
} : {})
|
|
185
245
|
},
|
|
186
246
|
bodiedExtension: {
|
|
187
247
|
nestedExpand: [wrapStep],
|
|
@@ -194,6 +254,9 @@ export const TRANSFORMATION_MATRIX = {
|
|
|
194
254
|
nestedExpand: [wrapStep],
|
|
195
255
|
layoutSection: [wrapStep],
|
|
196
256
|
panel: [wrapStep],
|
|
257
|
+
...(includePanelC1 ? {
|
|
258
|
+
panel_c1: [wrapStep]
|
|
259
|
+
} : {}),
|
|
197
260
|
bulletList: [wrapIntoListStep],
|
|
198
261
|
orderedList: [wrapIntoListStep],
|
|
199
262
|
taskList: [wrapIntoListStep],
|
|
@@ -206,6 +269,9 @@ export const TRANSFORMATION_MATRIX = {
|
|
|
206
269
|
nestedExpand: [wrapMixedContentStep],
|
|
207
270
|
layoutSection: [wrapMixedContentStep],
|
|
208
271
|
panel: [wrapMixedContentStep],
|
|
272
|
+
...(includePanelC1 ? {
|
|
273
|
+
panel_c1: [wrapMixedContentStep]
|
|
274
|
+
} : {}),
|
|
209
275
|
bulletList: [convertEachNodeStep, mergeNeighbourListsStep],
|
|
210
276
|
orderedList: [convertEachNodeStep, mergeNeighbourListsStep],
|
|
211
277
|
taskList: [convertEachNodeStep, mergeNeighbourListsStep],
|
|
@@ -213,4 +279,6 @@ export const TRANSFORMATION_MATRIX = {
|
|
|
213
279
|
paragraph: [convertEachNodeStep],
|
|
214
280
|
heading: [applyTargetTextTypeStep]
|
|
215
281
|
}
|
|
216
|
-
};
|
|
282
|
+
});
|
|
283
|
+
export const TRANSFORMATION_MATRIX = createTransformationMatrix(false);
|
|
284
|
+
export const TRANSFORMATION_MATRIX_PANEL_C1 = createTransformationMatrix(true);
|
|
@@ -196,7 +196,7 @@ export const wrapMixedContentStep = (nodes, context) => {
|
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
// All other nodes that cannot be wrapped in the target node - break out
|
|
199
|
-
// Examples: same-type containers,
|
|
199
|
+
// Examples: same-type containers, layoutSections in layouts
|
|
200
200
|
handleUnsupportedNode(node);
|
|
201
201
|
};
|
|
202
202
|
nodes.forEach(processNode);
|
|
@@ -1,6 +1,25 @@
|
|
|
1
|
+
import { isNodeTypeValidChildOf } from '@atlaskit/editor-common/utils';
|
|
2
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
1
3
|
import { getTargetNodeTypeNameInContext } from '../transform-node-utils/utils';
|
|
2
|
-
import { TRANSFORMATION_MATRIX } from './TRANSFORMATION_MATRIX';
|
|
4
|
+
import { TRANSFORMATION_MATRIX, TRANSFORMATION_MATRIX_PANEL_C1 } from './TRANSFORMATION_MATRIX';
|
|
3
5
|
import { getNodeName, toNodeTypeValue } from './types';
|
|
6
|
+
// Upgrade broken-out panel nodes to panel_c1 if the parent node allows it
|
|
7
|
+
export const upgradePanelNodesToPanelC1 = (nodes, parentNode, schema) => {
|
|
8
|
+
if (!schema.nodes['panel_c1'] || !expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true)) {
|
|
9
|
+
return nodes;
|
|
10
|
+
}
|
|
11
|
+
return nodes.map(node => {
|
|
12
|
+
if (node.type.name === 'panel') {
|
|
13
|
+
const shouldUsePanelC1 = !parentNode || isNodeTypeValidChildOf('panel_c1', parentNode, schema);
|
|
14
|
+
if (shouldUsePanelC1) {
|
|
15
|
+
var _schema$nodes$panel_c;
|
|
16
|
+
return (_schema$nodes$panel_c = schema.nodes['panel_c1'].createAndFill(node.attrs, node.content, node.marks)) !== null && _schema$nodes$panel_c !== void 0 ? _schema$nodes$panel_c : node;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return node;
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
|
|
4
23
|
/**
|
|
5
24
|
* Convert a list of nodes to a target node type.
|
|
6
25
|
* If no steps are found, the source nodes are returned unchanged.
|
|
@@ -30,11 +49,11 @@ export const convertNodesToTargetType = ({
|
|
|
30
49
|
}
|
|
31
50
|
const selectedNodeTypeName = toNodeTypeValue(getNodeName(sourceNodes));
|
|
32
51
|
const initialTargetNodeTypeName = toNodeTypeValue(targetNodeType.name);
|
|
33
|
-
const targetNodeTypeName = getTargetNodeTypeNameInContext(initialTargetNodeTypeName, isNested, parentNode);
|
|
52
|
+
const targetNodeTypeName = getTargetNodeTypeNameInContext(initialTargetNodeTypeName, isNested, parentNode, schema);
|
|
34
53
|
if (!selectedNodeTypeName || !targetNodeTypeName) {
|
|
35
54
|
return sourceNodes;
|
|
36
55
|
}
|
|
37
|
-
const steps = TRANSFORMATION_MATRIX[selectedNodeTypeName][targetNodeTypeName];
|
|
56
|
+
const steps = expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? TRANSFORMATION_MATRIX_PANEL_C1[selectedNodeTypeName][targetNodeTypeName] : TRANSFORMATION_MATRIX[selectedNodeTypeName][targetNodeTypeName];
|
|
38
57
|
const context = {
|
|
39
58
|
// sourceNode is incorrect now - what to do here?
|
|
40
59
|
fromNode: sourceNode,
|
|
@@ -45,11 +64,12 @@ export const convertNodesToTargetType = ({
|
|
|
45
64
|
if (!steps || steps.length === 0) {
|
|
46
65
|
return sourceNodes;
|
|
47
66
|
}
|
|
48
|
-
|
|
67
|
+
const resultNodes = steps.reduce((nodes, step) => {
|
|
49
68
|
return step(nodes, context);
|
|
50
69
|
}, sourceNodes);
|
|
70
|
+
return upgradePanelNodesToPanelC1(resultNodes, parentNode, schema);
|
|
51
71
|
};
|
|
52
72
|
export const isTransformDisabledBasedOnStepsConfig = (selectedNodeType, targetNodeType) => {
|
|
53
|
-
const steps = TRANSFORMATION_MATRIX[selectedNodeType][targetNodeType];
|
|
73
|
+
const steps = expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? TRANSFORMATION_MATRIX_PANEL_C1[selectedNodeType][targetNodeType] : TRANSFORMATION_MATRIX[selectedNodeType][targetNodeType];
|
|
54
74
|
return !steps || steps.length === 0;
|
|
55
75
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { isNodeTypeValidChildOf } from '@atlaskit/editor-common/utils';
|
|
1
2
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
3
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
3
4
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
5
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
6
|
import { NODE_CATEGORY_BY_TYPE } from './types';
|
|
5
7
|
|
|
6
8
|
/**
|
|
@@ -57,13 +59,18 @@ export const getSelectedNode = selection => {
|
|
|
57
59
|
}
|
|
58
60
|
return undefined;
|
|
59
61
|
};
|
|
60
|
-
export const getTargetNodeTypeNameInContext = (nodeTypeName, isNested, parentNode) => {
|
|
62
|
+
export const getTargetNodeTypeNameInContext = (nodeTypeName, isNested, parentNode, schema) => {
|
|
61
63
|
if (parentNode && isNested && (parentNode.type.name === 'layoutColumn' || parentNode.type.name === 'bodiedSyncBlock')) {
|
|
62
64
|
return nodeTypeName;
|
|
63
65
|
}
|
|
64
66
|
if (nodeTypeName === 'expand' && isNested) {
|
|
65
67
|
return 'nestedExpand';
|
|
66
68
|
}
|
|
69
|
+
if (nodeTypeName === 'panel' && schema !== null && schema !== void 0 && schema.nodes['panel_c1'] && expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true)) {
|
|
70
|
+
if (!parentNode || isNodeTypeValidChildOf('panel_c1', parentNode, schema)) {
|
|
71
|
+
return 'panel_c1';
|
|
72
|
+
}
|
|
73
|
+
}
|
|
67
74
|
return nodeTypeName;
|
|
68
75
|
};
|
|
69
76
|
|
|
@@ -4,7 +4,7 @@ import { isTransformDisabledBasedOnStepsConfig } from '../editor-commands/transf
|
|
|
4
4
|
import { toNodeTypeValue } from '../editor-commands/transform-node-utils/types';
|
|
5
5
|
import { getBlockNodesInRange, getTargetNodeTypeNameInContext } from '../editor-commands/transform-node-utils/utils';
|
|
6
6
|
export var canParentContainNodeType = function canParentContainNodeType(schema, selectedNodeTypeName, parentNode, nodeTypeName, nodeTypeAttrs) {
|
|
7
|
-
var adjustedNodeTypeName = getTargetNodeTypeNameInContext(nodeTypeName, true, parentNode);
|
|
7
|
+
var adjustedNodeTypeName = getTargetNodeTypeNameInContext(nodeTypeName, true, parentNode, schema);
|
|
8
8
|
if (!adjustedNodeTypeName) {
|
|
9
9
|
return false;
|
|
10
10
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
2
3
|
/**
|
|
3
4
|
* Sets the appropriate selection after transforming a node to a target type
|
|
4
5
|
* @param newTr - The transaction containing the transformed node
|
|
@@ -17,7 +18,7 @@ export var setSelectionAfterTransform = function setSelectionAfterTransform(newT
|
|
|
17
18
|
// Check if target type is other than list, text, heading, blockquotes
|
|
18
19
|
var isListNode = targetType === 'bulletList' || targetType === 'orderedList' || targetType === 'taskList';
|
|
19
20
|
var isBlockquote = targetType === 'blockquote';
|
|
20
|
-
var isContainer = ['panel', 'expand', 'codeBlock', 'layoutSection'].includes(targetType);
|
|
21
|
+
var isContainer = expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? ['panel', 'panel_c1', 'expand', 'codeBlock', 'layoutSection'].includes(targetType) : ['panel', 'expand', 'codeBlock', 'layoutSection'].includes(targetType);
|
|
21
22
|
if (isListNode || isBlockquote) {
|
|
22
23
|
// For taskList, select all content within the list
|
|
23
24
|
var textStart = transformedNodePos.pos + 1; // Inside the taskList
|