@atlaskit/editor-plugin-block-menu 6.0.8 → 6.0.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 +15 -0
- package/dist/cjs/editor-commands/transform-node-utils/TRANSFORMATION_MATRIX.js +224 -0
- package/dist/cjs/editor-commands/transform-node-utils/steps/applyTargetTextTypeStep.js +4 -0
- package/dist/cjs/editor-commands/transform-node-utils/steps/convertEachNodeStep.js +58 -1
- package/dist/cjs/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +12 -1
- package/dist/cjs/editor-commands/transform-node-utils/transform.js +4 -236
- package/dist/cjs/editor-commands/transform-node-utils/utils.js +33 -11
- package/dist/es2019/editor-commands/transform-node-utils/TRANSFORMATION_MATRIX.js +219 -0
- package/dist/es2019/editor-commands/transform-node-utils/steps/applyTargetTextTypeStep.js +4 -0
- package/dist/es2019/editor-commands/transform-node-utils/steps/convertEachNodeStep.js +56 -1
- package/dist/es2019/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +13 -2
- package/dist/es2019/editor-commands/transform-node-utils/transform.js +5 -238
- package/dist/es2019/editor-commands/transform-node-utils/utils.js +32 -10
- package/dist/esm/editor-commands/transform-node-utils/TRANSFORMATION_MATRIX.js +219 -0
- package/dist/esm/editor-commands/transform-node-utils/steps/applyTargetTextTypeStep.js +4 -0
- package/dist/esm/editor-commands/transform-node-utils/steps/convertEachNodeStep.js +58 -1
- package/dist/esm/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +13 -2
- package/dist/esm/editor-commands/transform-node-utils/transform.js +5 -238
- package/dist/esm/editor-commands/transform-node-utils/utils.js +32 -10
- package/dist/types/editor-commands/transform-node-utils/TRANSFORMATION_MATRIX.d.ts +2 -0
- package/dist/types/editor-commands/transform-node-utils/utils.d.ts +10 -5
- package/dist/types-ts4.5/editor-commands/transform-node-utils/TRANSFORMATION_MATRIX.d.ts +2 -0
- package/dist/types-ts4.5/editor-commands/transform-node-utils/utils.d.ts +10 -5
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-menu
|
|
2
2
|
|
|
3
|
+
## 6.0.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`b512bf962fe38`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b512bf962fe38) -
|
|
8
|
+
[ux] codeblock transformations should drop any incompatible content, it should just be wrapped
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 6.0.9
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`c77659e594c55`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c77659e594c55) -
|
|
16
|
+
[ux] Editor-4020: Fix decision to quote and code block, fixed empty panel to code block"
|
|
17
|
+
|
|
3
18
|
## 6.0.8
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TRANSFORMATION_MATRIX = void 0;
|
|
7
|
+
var _flattenStep = require("./flattenStep");
|
|
8
|
+
var _applyTargetTextTypeStep = require("./steps/applyTargetTextTypeStep");
|
|
9
|
+
var _convertEachNodeStep = require("./steps/convertEachNodeStep");
|
|
10
|
+
var _decisionListToListStep = require("./steps/decisionListToListStep");
|
|
11
|
+
var _flattenListStep = require("./steps/flattenListStep");
|
|
12
|
+
var _listToDecisionListStep = require("./steps/listToDecisionListStep");
|
|
13
|
+
var _listToListStep = require("./steps/listToListStep");
|
|
14
|
+
var _mergeNeighbourListsStep = require("./steps/mergeNeighbourListsStep");
|
|
15
|
+
var _unwrapLayoutStep = require("./steps/unwrapLayoutStep");
|
|
16
|
+
var _unwrapListStep = require("./steps/unwrapListStep");
|
|
17
|
+
var _wrapBlockquoteToDecisionListStep = require("./steps/wrapBlockquoteToDecisionListStep");
|
|
18
|
+
var _wrapMixedContentStep = require("./steps/wrapMixedContentStep");
|
|
19
|
+
var _unwrapExpandStep = require("./unwrapExpandStep");
|
|
20
|
+
var _unwrapStep = require("./unwrapStep");
|
|
21
|
+
var _wrapIntoListStep = require("./wrapIntoListStep");
|
|
22
|
+
var _wrapStep = require("./wrapStep");
|
|
23
|
+
// Transform steps for all node type pairs.
|
|
24
|
+
// If a transformation is not defined (undefined), it is not available.
|
|
25
|
+
var TRANSFORMATION_MATRIX = exports.TRANSFORMATION_MATRIX = {
|
|
26
|
+
paragraph: {
|
|
27
|
+
heading: [_flattenStep.flattenStep, _applyTargetTextTypeStep.applyTargetTextTypeStep],
|
|
28
|
+
blockquote: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
29
|
+
codeBlock: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
30
|
+
expand: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
31
|
+
nestedExpand: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
32
|
+
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
33
|
+
panel: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
34
|
+
bulletList: [_wrapIntoListStep.wrapIntoListStep],
|
|
35
|
+
orderedList: [_wrapIntoListStep.wrapIntoListStep],
|
|
36
|
+
taskList: [_wrapIntoListStep.wrapIntoListStep],
|
|
37
|
+
decisionList: [_wrapIntoListStep.wrapIntoListStep]
|
|
38
|
+
},
|
|
39
|
+
heading: {
|
|
40
|
+
heading: [_flattenStep.flattenStep, _applyTargetTextTypeStep.applyTargetTextTypeStep],
|
|
41
|
+
paragraph: [_flattenStep.flattenStep, _applyTargetTextTypeStep.applyTargetTextTypeStep],
|
|
42
|
+
blockquote: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
43
|
+
codeBlock: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
44
|
+
expand: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
45
|
+
nestedExpand: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
46
|
+
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
47
|
+
panel: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
48
|
+
bulletList: [_wrapIntoListStep.wrapIntoListStep],
|
|
49
|
+
orderedList: [_wrapIntoListStep.wrapIntoListStep],
|
|
50
|
+
taskList: [_wrapIntoListStep.wrapIntoListStep],
|
|
51
|
+
decisionList: [_wrapIntoListStep.wrapIntoListStep]
|
|
52
|
+
},
|
|
53
|
+
panel: {
|
|
54
|
+
blockquote: [_unwrapStep.unwrapStep, _wrapMixedContentStep.wrapMixedContentStep],
|
|
55
|
+
codeBlock: [_unwrapStep.unwrapStep, _wrapMixedContentStep.wrapMixedContentStep],
|
|
56
|
+
expand: [_unwrapStep.unwrapStep, _wrapStep.wrapStep],
|
|
57
|
+
nestedExpand: [_unwrapStep.unwrapStep, _wrapStep.wrapStep],
|
|
58
|
+
layoutSection: [_unwrapStep.unwrapStep, _wrapMixedContentStep.wrapMixedContentStep],
|
|
59
|
+
paragraph: [_unwrapStep.unwrapStep]
|
|
60
|
+
},
|
|
61
|
+
expand: {
|
|
62
|
+
panel: [_unwrapExpandStep.unwrapExpandStep, _wrapMixedContentStep.wrapMixedContentStep],
|
|
63
|
+
blockquote: [_unwrapExpandStep.unwrapExpandStep, _wrapMixedContentStep.wrapMixedContentStep],
|
|
64
|
+
layoutSection: [_unwrapExpandStep.unwrapExpandStep, _wrapMixedContentStep.wrapMixedContentStep],
|
|
65
|
+
nestedExpand: [_unwrapExpandStep.unwrapExpandStep, _wrapStep.wrapStep],
|
|
66
|
+
paragraph: [_unwrapExpandStep.unwrapExpandStep]
|
|
67
|
+
},
|
|
68
|
+
nestedExpand: {
|
|
69
|
+
panel: [_unwrapExpandStep.unwrapExpandStep, _wrapMixedContentStep.wrapMixedContentStep],
|
|
70
|
+
blockquote: [_unwrapExpandStep.unwrapExpandStep, _wrapMixedContentStep.wrapMixedContentStep],
|
|
71
|
+
layoutSection: [_unwrapExpandStep.unwrapExpandStep, _wrapMixedContentStep.wrapMixedContentStep],
|
|
72
|
+
paragraph: [_unwrapExpandStep.unwrapExpandStep]
|
|
73
|
+
},
|
|
74
|
+
blockquote: {
|
|
75
|
+
expand: [_wrapStep.wrapStep],
|
|
76
|
+
nestedExpand: [_wrapStep.wrapStep],
|
|
77
|
+
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
78
|
+
panel: [_unwrapStep.unwrapStep, _wrapStep.wrapStep],
|
|
79
|
+
paragraph: [_unwrapStep.unwrapStep],
|
|
80
|
+
heading: [_unwrapStep.unwrapStep, _applyTargetTextTypeStep.applyTargetTextTypeStep],
|
|
81
|
+
decisionList: [_unwrapStep.unwrapStep, _wrapBlockquoteToDecisionListStep.wrapBlockquoteToDecisionListStep]
|
|
82
|
+
},
|
|
83
|
+
layoutSection: {
|
|
84
|
+
blockquote: [_unwrapLayoutStep.unwrapLayoutStep, _wrapMixedContentStep.wrapMixedContentStep],
|
|
85
|
+
expand: [_unwrapLayoutStep.unwrapLayoutStep, _wrapStep.wrapStep],
|
|
86
|
+
nestedExpand: [_unwrapLayoutStep.unwrapLayoutStep, _wrapStep.wrapStep],
|
|
87
|
+
panel: [_unwrapLayoutStep.unwrapLayoutStep, _wrapMixedContentStep.wrapMixedContentStep],
|
|
88
|
+
paragraph: [_unwrapLayoutStep.unwrapLayoutStep]
|
|
89
|
+
},
|
|
90
|
+
codeBlock: {
|
|
91
|
+
blockquote: [_wrapStep.wrapStep],
|
|
92
|
+
expand: [_wrapStep.wrapStep],
|
|
93
|
+
nestedExpand: [_wrapStep.wrapStep],
|
|
94
|
+
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
95
|
+
panel: [_wrapStep.wrapStep],
|
|
96
|
+
paragraph: [_applyTargetTextTypeStep.applyTargetTextTypeStep]
|
|
97
|
+
},
|
|
98
|
+
bulletList: {
|
|
99
|
+
orderedList: [_listToListStep.listToListStep],
|
|
100
|
+
taskList: [_listToListStep.listToListStep],
|
|
101
|
+
decisionList: [_flattenListStep.flattenListStep, _listToDecisionListStep.listToDecisionListStep],
|
|
102
|
+
blockquote: [_wrapStep.wrapStep],
|
|
103
|
+
expand: [_wrapStep.wrapStep],
|
|
104
|
+
nestedExpand: [_wrapStep.wrapStep],
|
|
105
|
+
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
106
|
+
panel: [_wrapStep.wrapStep],
|
|
107
|
+
paragraph: [_flattenListStep.flattenListStep, _unwrapListStep.unwrapListStep, _applyTargetTextTypeStep.applyTargetTextTypeStep]
|
|
108
|
+
},
|
|
109
|
+
orderedList: {
|
|
110
|
+
bulletList: [_listToListStep.listToListStep],
|
|
111
|
+
taskList: [_listToListStep.listToListStep],
|
|
112
|
+
decisionList: [_flattenListStep.flattenListStep, _listToDecisionListStep.listToDecisionListStep],
|
|
113
|
+
blockquote: [_wrapStep.wrapStep],
|
|
114
|
+
expand: [_wrapStep.wrapStep],
|
|
115
|
+
nestedExpand: [_wrapStep.wrapStep],
|
|
116
|
+
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
117
|
+
panel: [_wrapStep.wrapStep],
|
|
118
|
+
paragraph: [_flattenListStep.flattenListStep, _unwrapListStep.unwrapListStep, _applyTargetTextTypeStep.applyTargetTextTypeStep]
|
|
119
|
+
},
|
|
120
|
+
taskList: {
|
|
121
|
+
bulletList: [_listToListStep.listToListStep],
|
|
122
|
+
orderedList: [_listToListStep.listToListStep],
|
|
123
|
+
decisionList: [_flattenListStep.flattenListStep, _listToDecisionListStep.listToDecisionListStep],
|
|
124
|
+
expand: [_wrapStep.wrapStep],
|
|
125
|
+
nestedExpand: [_wrapStep.wrapStep],
|
|
126
|
+
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
127
|
+
panel: [_wrapStep.wrapStep],
|
|
128
|
+
paragraph: [_flattenListStep.flattenListStep, _unwrapListStep.unwrapListStep, _applyTargetTextTypeStep.applyTargetTextTypeStep]
|
|
129
|
+
},
|
|
130
|
+
table: {
|
|
131
|
+
expand: [_wrapStep.wrapStep],
|
|
132
|
+
nestedExpand: [_wrapStep.wrapStep],
|
|
133
|
+
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep]
|
|
134
|
+
},
|
|
135
|
+
mediaSingle: {
|
|
136
|
+
blockquote: [_wrapStep.wrapStep],
|
|
137
|
+
expand: [_wrapStep.wrapStep],
|
|
138
|
+
nestedExpand: [_wrapStep.wrapStep],
|
|
139
|
+
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
140
|
+
panel: [_wrapStep.wrapStep],
|
|
141
|
+
bulletList: [_wrapIntoListStep.wrapIntoListStep],
|
|
142
|
+
orderedList: [_wrapIntoListStep.wrapIntoListStep]
|
|
143
|
+
},
|
|
144
|
+
mediaGroup: {
|
|
145
|
+
blockquote: [_wrapStep.wrapStep],
|
|
146
|
+
expand: [_wrapStep.wrapStep],
|
|
147
|
+
nestedExpand: [_wrapStep.wrapStep],
|
|
148
|
+
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
149
|
+
panel: [_wrapStep.wrapStep]
|
|
150
|
+
},
|
|
151
|
+
media: {
|
|
152
|
+
blockquote: [_wrapStep.wrapStep],
|
|
153
|
+
codeBlock: [_wrapStep.wrapStep],
|
|
154
|
+
expand: [_wrapStep.wrapStep],
|
|
155
|
+
nestedExpand: [_wrapStep.wrapStep],
|
|
156
|
+
layoutSection: [_wrapStep.wrapStep],
|
|
157
|
+
panel: [_wrapStep.wrapStep],
|
|
158
|
+
bulletList: [_wrapIntoListStep.wrapIntoListStep],
|
|
159
|
+
orderedList: [_wrapIntoListStep.wrapIntoListStep],
|
|
160
|
+
taskList: [_wrapIntoListStep.wrapIntoListStep],
|
|
161
|
+
decisionList: [_wrapIntoListStep.wrapIntoListStep]
|
|
162
|
+
},
|
|
163
|
+
decisionList: {
|
|
164
|
+
bulletList: [_decisionListToListStep.decisionListToListStep],
|
|
165
|
+
orderedList: [_decisionListToListStep.decisionListToListStep],
|
|
166
|
+
taskList: [_decisionListToListStep.decisionListToListStep],
|
|
167
|
+
blockquote: [_unwrapListStep.unwrapListStep, _wrapStep.wrapStep],
|
|
168
|
+
codeBlock: [_unwrapListStep.unwrapListStep, _wrapMixedContentStep.wrapMixedContentStep],
|
|
169
|
+
expand: [_wrapStep.wrapStep],
|
|
170
|
+
nestedExpand: [_wrapStep.wrapStep],
|
|
171
|
+
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
172
|
+
panel: [_wrapStep.wrapStep],
|
|
173
|
+
paragraph: [_flattenListStep.flattenListStep, _unwrapListStep.unwrapListStep, _applyTargetTextTypeStep.applyTargetTextTypeStep],
|
|
174
|
+
heading: [_flattenListStep.flattenListStep, _unwrapListStep.unwrapListStep, _applyTargetTextTypeStep.applyTargetTextTypeStep]
|
|
175
|
+
},
|
|
176
|
+
blockCard: {
|
|
177
|
+
expand: [_wrapStep.wrapStep],
|
|
178
|
+
nestedExpand: [_wrapStep.wrapStep],
|
|
179
|
+
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
180
|
+
panel: [_wrapStep.wrapStep]
|
|
181
|
+
},
|
|
182
|
+
embedCard: {
|
|
183
|
+
expand: [_wrapStep.wrapStep],
|
|
184
|
+
nestedExpand: [_wrapStep.wrapStep],
|
|
185
|
+
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep]
|
|
186
|
+
},
|
|
187
|
+
extension: {
|
|
188
|
+
blockquote: [_wrapStep.wrapStep],
|
|
189
|
+
expand: [_wrapStep.wrapStep],
|
|
190
|
+
nestedExpand: [_wrapStep.wrapStep],
|
|
191
|
+
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
192
|
+
panel: [_wrapStep.wrapStep]
|
|
193
|
+
},
|
|
194
|
+
bodiedExtension: {
|
|
195
|
+
nestedExpand: [_wrapStep.wrapStep],
|
|
196
|
+
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep]
|
|
197
|
+
},
|
|
198
|
+
multiBodiedExtension: {
|
|
199
|
+
blockquote: [_wrapStep.wrapStep],
|
|
200
|
+
codeBlock: [_wrapStep.wrapStep],
|
|
201
|
+
expand: [_wrapStep.wrapStep],
|
|
202
|
+
nestedExpand: [_wrapStep.wrapStep],
|
|
203
|
+
layoutSection: [_wrapStep.wrapStep],
|
|
204
|
+
panel: [_wrapStep.wrapStep],
|
|
205
|
+
bulletList: [_wrapIntoListStep.wrapIntoListStep],
|
|
206
|
+
orderedList: [_wrapIntoListStep.wrapIntoListStep],
|
|
207
|
+
taskList: [_wrapIntoListStep.wrapIntoListStep],
|
|
208
|
+
decisionList: [_wrapIntoListStep.wrapIntoListStep]
|
|
209
|
+
},
|
|
210
|
+
multi: {
|
|
211
|
+
blockquote: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
212
|
+
codeBlock: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
213
|
+
expand: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
214
|
+
nestedExpand: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
215
|
+
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
216
|
+
panel: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
217
|
+
bulletList: [_convertEachNodeStep.convertEachNodeStep, _mergeNeighbourListsStep.mergeNeighbourListsStep],
|
|
218
|
+
orderedList: [_convertEachNodeStep.convertEachNodeStep, _mergeNeighbourListsStep.mergeNeighbourListsStep],
|
|
219
|
+
taskList: [_convertEachNodeStep.convertEachNodeStep, _mergeNeighbourListsStep.mergeNeighbourListsStep],
|
|
220
|
+
decisionList: [_convertEachNodeStep.convertEachNodeStep, _mergeNeighbourListsStep.mergeNeighbourListsStep],
|
|
221
|
+
paragraph: [_convertEachNodeStep.convertEachNodeStep],
|
|
222
|
+
heading: [_applyTargetTextTypeStep.applyTargetTextTypeStep]
|
|
223
|
+
}
|
|
224
|
+
};
|
|
@@ -37,6 +37,10 @@ var applyTargetTextTypeStep = exports.applyTargetTextTypeStep = function applyTa
|
|
|
37
37
|
return nodes;
|
|
38
38
|
}
|
|
39
39
|
return nodes.map(function (node) {
|
|
40
|
+
// If codeblock, return nodes as is
|
|
41
|
+
if (targetNodeTypeName === 'heading' && node.type.name === 'codeBlock') {
|
|
42
|
+
return node;
|
|
43
|
+
}
|
|
40
44
|
if (node.isTextblock) {
|
|
41
45
|
// Convert textblock nodes to the target type with content preserved
|
|
42
46
|
var attrs = {};
|
|
@@ -10,6 +10,46 @@ var _transform = require("../transform");
|
|
|
10
10
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
11
11
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
12
12
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
13
|
+
/**
|
|
14
|
+
* Handles the edge case where transforming multi-selection to decisionList results in
|
|
15
|
+
* all content breaking out (no valid children for the target). In this case, creates an empty
|
|
16
|
+
* decisionList to ensure the target type exists.
|
|
17
|
+
*
|
|
18
|
+
* Similar to handleEmptyContainerEdgeCase in wrapMixedContentStep, but specifically for
|
|
19
|
+
* multi-to-decisionList transformations where blockquotes break out.
|
|
20
|
+
*
|
|
21
|
+
* @param result - The current result nodes after processing
|
|
22
|
+
* @param hasCreatedDecisionList - Whether a decisionList was already created during processing
|
|
23
|
+
* @param targetNodeTypeName - The target node type name
|
|
24
|
+
* @param schema - The schema
|
|
25
|
+
* @returns The result nodes with an empty decisionList prepended if needed, or the original result
|
|
26
|
+
*/
|
|
27
|
+
var handleEmptyDecisionListEdgeCase = function handleEmptyDecisionListEdgeCase(result, hasCreatedDecisionList, targetNodeTypeName, schema) {
|
|
28
|
+
// Only apply this edge case for decisionList target
|
|
29
|
+
if (targetNodeTypeName !== 'decisionList') {
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// If no decisionList was created but we have nodes in result, all content broke out
|
|
34
|
+
var allContentBrokeOut = !hasCreatedDecisionList && result.length > 0;
|
|
35
|
+
if (!allContentBrokeOut) {
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Create an empty decisionList
|
|
40
|
+
var decisionListType = schema.nodes.decisionList;
|
|
41
|
+
var decisionItemType = schema.nodes.decisionItem;
|
|
42
|
+
if (decisionListType && decisionItemType) {
|
|
43
|
+
var emptyDecisionItem = decisionItemType.createAndFill();
|
|
44
|
+
if (emptyDecisionItem) {
|
|
45
|
+
var emptyDecisionList = decisionListType.createAndFill({}, [emptyDecisionItem]);
|
|
46
|
+
if (emptyDecisionList) {
|
|
47
|
+
return [emptyDecisionList].concat((0, _toConsumableArray2.default)(result));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
};
|
|
13
53
|
var convertEachNodeStep = exports.convertEachNodeStep = function convertEachNodeStep(nodes, context) {
|
|
14
54
|
var schema = context.schema,
|
|
15
55
|
targetNodeTypeName = context.targetNodeTypeName,
|
|
@@ -18,12 +58,19 @@ var convertEachNodeStep = exports.convertEachNodeStep = function convertEachNode
|
|
|
18
58
|
if (!targetNodeType) {
|
|
19
59
|
return nodes;
|
|
20
60
|
}
|
|
61
|
+
var blockquoteType = schema.nodes.blockquote;
|
|
21
62
|
var resultNodes = [];
|
|
63
|
+
var hasCreatedDecisionList = false;
|
|
22
64
|
var _iterator = _createForOfIteratorHelper(nodes),
|
|
23
65
|
_step;
|
|
24
66
|
try {
|
|
25
67
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
26
68
|
var node = _step.value;
|
|
69
|
+
// Edge case: blockquotes should break out when transforming to decisionList
|
|
70
|
+
if (targetNodeTypeName === 'decisionList' && blockquoteType && node.type === blockquoteType) {
|
|
71
|
+
resultNodes.push(node);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
27
74
|
var transformedNodes = (0, _transform.convertNodesToTargetType)({
|
|
28
75
|
sourceNodes: [node],
|
|
29
76
|
targetNodeType: targetNodeType,
|
|
@@ -33,14 +80,24 @@ var convertEachNodeStep = exports.convertEachNodeStep = function convertEachNode
|
|
|
33
80
|
});
|
|
34
81
|
if (transformedNodes.length > 0) {
|
|
35
82
|
resultNodes.push.apply(resultNodes, (0, _toConsumableArray2.default)(transformedNodes));
|
|
83
|
+
// Track if we created a decisionList
|
|
84
|
+
|
|
85
|
+
if (targetNodeTypeName === 'decisionList' && transformedNodes.some(function (n) {
|
|
86
|
+
return n.type === targetNodeType;
|
|
87
|
+
})) {
|
|
88
|
+
hasCreatedDecisionList = true;
|
|
89
|
+
}
|
|
36
90
|
} else {
|
|
37
91
|
resultNodes.push(node);
|
|
38
92
|
}
|
|
39
93
|
}
|
|
94
|
+
|
|
95
|
+
// Handle edge case: if no decisionList was created, create an empty one
|
|
40
96
|
} catch (err) {
|
|
41
97
|
_iterator.e(err);
|
|
42
98
|
} finally {
|
|
43
99
|
_iterator.f();
|
|
44
100
|
}
|
|
45
|
-
|
|
101
|
+
var finalResult = handleEmptyDecisionListEdgeCase(resultNodes, hasCreatedDecisionList, targetNodeTypeName, schema);
|
|
102
|
+
return finalResult;
|
|
46
103
|
};
|
|
@@ -155,7 +155,18 @@ var wrapMixedContentStep = exports.wrapMixedContentStep = function wrapMixedCont
|
|
|
155
155
|
(_currentContainerCont = currentContainerContent).push.apply(_currentContainerCont, (0, _toConsumableArray2.default)((0, _marks.removeDisallowedMarks)([node], validationType)));
|
|
156
156
|
};
|
|
157
157
|
var handleCodeblockTextNode = function handleCodeblockTextNode(node) {
|
|
158
|
-
|
|
158
|
+
// Split the text node into text parts and incompatible inline nodes
|
|
159
|
+
var parts = (0, _utils.splitTextNodeForCodeBlock)(node, schema);
|
|
160
|
+
parts.forEach(function (part) {
|
|
161
|
+
if (typeof part === 'string') {
|
|
162
|
+
// Text content - add to current codeBlock
|
|
163
|
+
currentContainerContent.push(part);
|
|
164
|
+
} else {
|
|
165
|
+
// Incompatible inline node wrapped in paragraph - break it out
|
|
166
|
+
flushCurrentContainer();
|
|
167
|
+
result.push(part);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
159
170
|
};
|
|
160
171
|
var handleConvertibleTextNode = function handleConvertibleTextNode(node) {
|
|
161
172
|
var paragraph = (0, _utils.convertTextNodeToParagraph)(node, schema);
|
|
@@ -5,237 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.isTransformDisabledBasedOnStepsConfig = exports.convertNodesToTargetType = void 0;
|
|
7
7
|
var _utils = require("../transform-node-utils/utils");
|
|
8
|
-
var
|
|
9
|
-
var _applyTargetTextTypeStep = require("./steps/applyTargetTextTypeStep");
|
|
10
|
-
var _convertEachNodeStep = require("./steps/convertEachNodeStep");
|
|
11
|
-
var _decisionListToListStep = require("./steps/decisionListToListStep");
|
|
12
|
-
var _flattenListStep = require("./steps/flattenListStep");
|
|
13
|
-
var _listToDecisionListStep = require("./steps/listToDecisionListStep");
|
|
14
|
-
var _listToListStep = require("./steps/listToListStep");
|
|
15
|
-
var _mergeNeighbourListsStep = require("./steps/mergeNeighbourListsStep");
|
|
16
|
-
var _unwrapLayoutStep = require("./steps/unwrapLayoutStep");
|
|
17
|
-
var _unwrapListStep = require("./steps/unwrapListStep");
|
|
18
|
-
var _wrapBlockquoteToDecisionListStep = require("./steps/wrapBlockquoteToDecisionListStep");
|
|
19
|
-
var _wrapMixedContentStep = require("./steps/wrapMixedContentStep");
|
|
8
|
+
var _TRANSFORMATION_MATRIX = require("./TRANSFORMATION_MATRIX");
|
|
20
9
|
var _types = require("./types");
|
|
21
|
-
var _unwrapExpandStep = require("./unwrapExpandStep");
|
|
22
|
-
var _unwrapStep = require("./unwrapStep");
|
|
23
|
-
var _wrapIntoListStep = require("./wrapIntoListStep");
|
|
24
|
-
var _wrapStep = require("./wrapStep");
|
|
25
|
-
// Transform steps for combinations of node categories (block/container/list/text)
|
|
26
|
-
var TRANSFORM_STEPS = {
|
|
27
|
-
atomic: {
|
|
28
|
-
atomic: undefined,
|
|
29
|
-
container: [_wrapStep.wrapStep],
|
|
30
|
-
list: [_wrapIntoListStep.wrapIntoListStep],
|
|
31
|
-
text: undefined,
|
|
32
|
-
multi: undefined
|
|
33
|
-
},
|
|
34
|
-
container: {
|
|
35
|
-
atomic: undefined,
|
|
36
|
-
container: [_unwrapStep.unwrapStep, _wrapStep.wrapStep],
|
|
37
|
-
list: undefined,
|
|
38
|
-
text: [_unwrapStep.unwrapStep],
|
|
39
|
-
multi: undefined
|
|
40
|
-
},
|
|
41
|
-
list: {
|
|
42
|
-
atomic: undefined,
|
|
43
|
-
container: [_wrapStep.wrapStep],
|
|
44
|
-
list: [_listToListStep.listToListStep],
|
|
45
|
-
text: [_flattenListStep.flattenListStep, _unwrapListStep.unwrapListStep, _applyTargetTextTypeStep.applyTargetTextTypeStep],
|
|
46
|
-
multi: undefined
|
|
47
|
-
},
|
|
48
|
-
text: {
|
|
49
|
-
atomic: undefined,
|
|
50
|
-
container: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
51
|
-
list: [_wrapIntoListStep.wrapIntoListStep],
|
|
52
|
-
text: [_flattenStep.flattenStep, _applyTargetTextTypeStep.applyTargetTextTypeStep],
|
|
53
|
-
multi: undefined
|
|
54
|
-
},
|
|
55
|
-
multi: {
|
|
56
|
-
atomic: undefined,
|
|
57
|
-
container: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
58
|
-
list: [_convertEachNodeStep.convertEachNodeStep, _mergeNeighbourListsStep.mergeNeighbourListsStep],
|
|
59
|
-
text: [_convertEachNodeStep.convertEachNodeStep],
|
|
60
|
-
multi: undefined
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
// Transform steps for specific pairs of node types that cannot be processed
|
|
65
|
-
// using generic rules/steps from TRANSFORM_STEPS.
|
|
66
|
-
// Use 'null' to indicate unavailable transfrorm for a case where TRANSFORM_STEPS are not undefined.
|
|
67
|
-
var TRANSFORM_STEPS_OVERRIDE = {
|
|
68
|
-
paragraph: {
|
|
69
|
-
paragraph: null
|
|
70
|
-
},
|
|
71
|
-
heading: {},
|
|
72
|
-
panel: {
|
|
73
|
-
panel: null,
|
|
74
|
-
layoutSection: [_unwrapStep.unwrapStep, _wrapMixedContentStep.wrapMixedContentStep],
|
|
75
|
-
codeBlock: [_unwrapStep.unwrapStep, _wrapMixedContentStep.wrapMixedContentStep],
|
|
76
|
-
blockquote: [_unwrapStep.unwrapStep, _wrapMixedContentStep.wrapMixedContentStep],
|
|
77
|
-
taskList: null,
|
|
78
|
-
bulletList: null,
|
|
79
|
-
orderedList: null,
|
|
80
|
-
heading: null
|
|
81
|
-
},
|
|
82
|
-
expand: {
|
|
83
|
-
expand: null,
|
|
84
|
-
panel: [_unwrapExpandStep.unwrapExpandStep, _wrapMixedContentStep.wrapMixedContentStep],
|
|
85
|
-
blockquote: [_unwrapExpandStep.unwrapExpandStep, _wrapMixedContentStep.wrapMixedContentStep],
|
|
86
|
-
layoutSection: [_unwrapExpandStep.unwrapExpandStep, _wrapMixedContentStep.wrapMixedContentStep],
|
|
87
|
-
paragraph: [_unwrapExpandStep.unwrapExpandStep],
|
|
88
|
-
codeBlock: null,
|
|
89
|
-
heading: null
|
|
90
|
-
},
|
|
91
|
-
nestedExpand: {
|
|
92
|
-
expand: null,
|
|
93
|
-
nestedExpand: null,
|
|
94
|
-
panel: [_unwrapExpandStep.unwrapExpandStep, _wrapMixedContentStep.wrapMixedContentStep],
|
|
95
|
-
blockquote: [_unwrapExpandStep.unwrapExpandStep, _wrapMixedContentStep.wrapMixedContentStep],
|
|
96
|
-
paragraph: [_unwrapExpandStep.unwrapExpandStep],
|
|
97
|
-
codeBlock: null,
|
|
98
|
-
heading: null
|
|
99
|
-
},
|
|
100
|
-
blockquote: {
|
|
101
|
-
blockquote: null,
|
|
102
|
-
expand: [_wrapStep.wrapStep],
|
|
103
|
-
nestedExpand: [_wrapStep.wrapStep],
|
|
104
|
-
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
105
|
-
codeBlock: null,
|
|
106
|
-
decisionList: [_unwrapStep.unwrapStep, _wrapBlockquoteToDecisionListStep.wrapBlockquoteToDecisionListStep],
|
|
107
|
-
paragraph: [_unwrapStep.unwrapStep],
|
|
108
|
-
heading: [_unwrapStep.unwrapStep, _applyTargetTextTypeStep.applyTargetTextTypeStep]
|
|
109
|
-
},
|
|
110
|
-
layoutSection: {
|
|
111
|
-
layoutSection: null,
|
|
112
|
-
blockquote: [_unwrapLayoutStep.unwrapLayoutStep, _wrapMixedContentStep.wrapMixedContentStep],
|
|
113
|
-
expand: [_unwrapLayoutStep.unwrapLayoutStep, _wrapStep.wrapStep],
|
|
114
|
-
panel: [_unwrapLayoutStep.unwrapLayoutStep, _wrapMixedContentStep.wrapMixedContentStep],
|
|
115
|
-
codeBlock: null,
|
|
116
|
-
paragraph: [_unwrapLayoutStep.unwrapLayoutStep],
|
|
117
|
-
heading: null
|
|
118
|
-
},
|
|
119
|
-
codeBlock: {
|
|
120
|
-
codeBlock: null,
|
|
121
|
-
blockquote: [_wrapStep.wrapStep],
|
|
122
|
-
expand: [_wrapStep.wrapStep],
|
|
123
|
-
nestedExpand: [_wrapStep.wrapStep],
|
|
124
|
-
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
125
|
-
panel: [_wrapStep.wrapStep],
|
|
126
|
-
paragraph: [_applyTargetTextTypeStep.applyTargetTextTypeStep],
|
|
127
|
-
heading: null
|
|
128
|
-
},
|
|
129
|
-
bulletList: {
|
|
130
|
-
bulletList: null,
|
|
131
|
-
codeBlock: null,
|
|
132
|
-
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
133
|
-
decisionList: [_flattenListStep.flattenListStep, _listToDecisionListStep.listToDecisionListStep],
|
|
134
|
-
heading: null
|
|
135
|
-
},
|
|
136
|
-
orderedList: {
|
|
137
|
-
orderedList: null,
|
|
138
|
-
codeBlock: null,
|
|
139
|
-
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
140
|
-
decisionList: [_flattenListStep.flattenListStep, _listToDecisionListStep.listToDecisionListStep],
|
|
141
|
-
heading: null
|
|
142
|
-
},
|
|
143
|
-
taskList: {
|
|
144
|
-
blockquote: null,
|
|
145
|
-
codeBlock: null,
|
|
146
|
-
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
147
|
-
decisionList: [_flattenListStep.flattenListStep, _listToDecisionListStep.listToDecisionListStep],
|
|
148
|
-
heading: null,
|
|
149
|
-
taskList: null
|
|
150
|
-
},
|
|
151
|
-
table: {
|
|
152
|
-
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
153
|
-
blockquote: null,
|
|
154
|
-
panel: null,
|
|
155
|
-
codeBlock: null,
|
|
156
|
-
orderedList: null,
|
|
157
|
-
bulletList: null,
|
|
158
|
-
taskList: null,
|
|
159
|
-
decisionList: null
|
|
160
|
-
},
|
|
161
|
-
mediaSingle: {
|
|
162
|
-
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
163
|
-
codeBlock: null,
|
|
164
|
-
decisionList: null,
|
|
165
|
-
taskList: null
|
|
166
|
-
},
|
|
167
|
-
mediaGroup: {
|
|
168
|
-
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
169
|
-
codeBlock: null,
|
|
170
|
-
decisionList: null,
|
|
171
|
-
bulletList: null,
|
|
172
|
-
orderedList: null,
|
|
173
|
-
taskList: null
|
|
174
|
-
},
|
|
175
|
-
decisionList: {
|
|
176
|
-
decisionList: null,
|
|
177
|
-
bulletList: [_decisionListToListStep.decisionListToListStep],
|
|
178
|
-
orderedList: [_decisionListToListStep.decisionListToListStep],
|
|
179
|
-
taskList: [_decisionListToListStep.decisionListToListStep],
|
|
180
|
-
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep]
|
|
181
|
-
},
|
|
182
|
-
blockCard: {
|
|
183
|
-
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
184
|
-
blockquote: null,
|
|
185
|
-
codeBlock: null,
|
|
186
|
-
orderedList: null,
|
|
187
|
-
bulletList: null,
|
|
188
|
-
taskList: null,
|
|
189
|
-
decisionList: null
|
|
190
|
-
},
|
|
191
|
-
embedCard: {
|
|
192
|
-
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
193
|
-
blockquote: null,
|
|
194
|
-
panel: null,
|
|
195
|
-
codeBlock: null,
|
|
196
|
-
orderedList: null,
|
|
197
|
-
bulletList: null,
|
|
198
|
-
taskList: null,
|
|
199
|
-
decisionList: null
|
|
200
|
-
},
|
|
201
|
-
extension: {
|
|
202
|
-
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
203
|
-
codeBlock: null,
|
|
204
|
-
decisionList: null,
|
|
205
|
-
taskList: null,
|
|
206
|
-
orderedList: null,
|
|
207
|
-
bulletList: null
|
|
208
|
-
},
|
|
209
|
-
bodiedExtension: {
|
|
210
|
-
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
211
|
-
blockquote: null,
|
|
212
|
-
expand: null,
|
|
213
|
-
panel: null,
|
|
214
|
-
codeBlock: null,
|
|
215
|
-
orderedList: null,
|
|
216
|
-
bulletList: null,
|
|
217
|
-
taskList: null,
|
|
218
|
-
decisionList: null
|
|
219
|
-
},
|
|
220
|
-
multi: {
|
|
221
|
-
heading: [_applyTargetTextTypeStep.applyTargetTextTypeStep]
|
|
222
|
-
// Similar to heading, all structures are kept as is
|
|
223
|
-
// EG: transformed: other lists, paragarph, headings
|
|
224
|
-
// eg: not-transformed: quotes, codeblocks ... all typeof 'containers'
|
|
225
|
-
// decisionList: [],
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
var getTransformStepsForNodeTypes = function getTransformStepsForNodeTypes(selectedNodeTypeName, targetNodeTypeName) {
|
|
229
|
-
var _TRANSFORM_STEPS_OVER;
|
|
230
|
-
var fromCategory = _types.NODE_CATEGORY_BY_TYPE[selectedNodeTypeName];
|
|
231
|
-
var toCategory = _types.NODE_CATEGORY_BY_TYPE[targetNodeTypeName];
|
|
232
|
-
var overrideSteps = (_TRANSFORM_STEPS_OVER = TRANSFORM_STEPS_OVERRIDE[selectedNodeTypeName]) === null || _TRANSFORM_STEPS_OVER === void 0 ? void 0 : _TRANSFORM_STEPS_OVER[targetNodeTypeName];
|
|
233
|
-
if (overrideSteps === null) {
|
|
234
|
-
return null;
|
|
235
|
-
}
|
|
236
|
-
var steps = overrideSteps !== null && overrideSteps !== void 0 ? overrideSteps : TRANSFORM_STEPS[fromCategory][toCategory];
|
|
237
|
-
return steps;
|
|
238
|
-
};
|
|
239
10
|
/**
|
|
240
11
|
* Convert a list of nodes to a target node type.
|
|
241
12
|
* If no steps are found, the source nodes are returned unchanged.
|
|
@@ -268,7 +39,7 @@ var convertNodesToTargetType = exports.convertNodesToTargetType = function conve
|
|
|
268
39
|
if (!selectedNodeTypeName || !targetNodeTypeName) {
|
|
269
40
|
return sourceNodes;
|
|
270
41
|
}
|
|
271
|
-
var steps =
|
|
42
|
+
var steps = _TRANSFORMATION_MATRIX.TRANSFORMATION_MATRIX[selectedNodeTypeName][targetNodeTypeName];
|
|
272
43
|
var context = {
|
|
273
44
|
// sourceNode is incorrect now - what to do here?
|
|
274
45
|
fromNode: sourceNode,
|
|
@@ -284,9 +55,6 @@ var convertNodesToTargetType = exports.convertNodesToTargetType = function conve
|
|
|
284
55
|
}, sourceNodes);
|
|
285
56
|
};
|
|
286
57
|
var isTransformDisabledBasedOnStepsConfig = exports.isTransformDisabledBasedOnStepsConfig = function isTransformDisabledBasedOnStepsConfig(selectedNodeType, targetNodeType) {
|
|
287
|
-
var steps =
|
|
288
|
-
|
|
289
|
-
return true;
|
|
290
|
-
}
|
|
291
|
-
return false;
|
|
58
|
+
var steps = _TRANSFORMATION_MATRIX.TRANSFORMATION_MATRIX[selectedNodeType][targetNodeType];
|
|
59
|
+
return !steps || steps.length === 0;
|
|
292
60
|
};
|