@atlaskit/editor-plugin-block-menu 6.0.9 → 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 +8 -0
- package/dist/cjs/editor-commands/transform-node-utils/TRANSFORMATION_MATRIX.js +224 -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 -238
- 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/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 -240
- 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/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 -240
- 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,13 @@
|
|
|
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
|
+
|
|
3
11
|
## 6.0.9
|
|
4
12
|
|
|
5
13
|
### 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
|
+
};
|
|
@@ -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,239 +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
|
-
blockquote: [_unwrapListStep.unwrapListStep, _wrapStep.wrapStep],
|
|
182
|
-
codeBlock: [_unwrapListStep.unwrapListStep, _wrapMixedContentStep.wrapMixedContentStep]
|
|
183
|
-
},
|
|
184
|
-
blockCard: {
|
|
185
|
-
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
186
|
-
blockquote: null,
|
|
187
|
-
codeBlock: null,
|
|
188
|
-
orderedList: null,
|
|
189
|
-
bulletList: null,
|
|
190
|
-
taskList: null,
|
|
191
|
-
decisionList: null
|
|
192
|
-
},
|
|
193
|
-
embedCard: {
|
|
194
|
-
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
195
|
-
blockquote: null,
|
|
196
|
-
panel: null,
|
|
197
|
-
codeBlock: null,
|
|
198
|
-
orderedList: null,
|
|
199
|
-
bulletList: null,
|
|
200
|
-
taskList: null,
|
|
201
|
-
decisionList: null
|
|
202
|
-
},
|
|
203
|
-
extension: {
|
|
204
|
-
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
205
|
-
codeBlock: null,
|
|
206
|
-
decisionList: null,
|
|
207
|
-
taskList: null,
|
|
208
|
-
orderedList: null,
|
|
209
|
-
bulletList: null
|
|
210
|
-
},
|
|
211
|
-
bodiedExtension: {
|
|
212
|
-
layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
|
|
213
|
-
blockquote: null,
|
|
214
|
-
expand: null,
|
|
215
|
-
panel: null,
|
|
216
|
-
codeBlock: null,
|
|
217
|
-
orderedList: null,
|
|
218
|
-
bulletList: null,
|
|
219
|
-
taskList: null,
|
|
220
|
-
decisionList: null
|
|
221
|
-
},
|
|
222
|
-
multi: {
|
|
223
|
-
heading: [_applyTargetTextTypeStep.applyTargetTextTypeStep]
|
|
224
|
-
// Similar to heading, all structures are kept as is
|
|
225
|
-
// EG: transformed: other lists, paragarph, headings
|
|
226
|
-
// eg: not-transformed: quotes, codeblocks ... all typeof 'containers'
|
|
227
|
-
// decisionList: [],
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
var getTransformStepsForNodeTypes = function getTransformStepsForNodeTypes(selectedNodeTypeName, targetNodeTypeName) {
|
|
231
|
-
var _TRANSFORM_STEPS_OVER;
|
|
232
|
-
var fromCategory = _types.NODE_CATEGORY_BY_TYPE[selectedNodeTypeName];
|
|
233
|
-
var toCategory = _types.NODE_CATEGORY_BY_TYPE[targetNodeTypeName];
|
|
234
|
-
var overrideSteps = (_TRANSFORM_STEPS_OVER = TRANSFORM_STEPS_OVERRIDE[selectedNodeTypeName]) === null || _TRANSFORM_STEPS_OVER === void 0 ? void 0 : _TRANSFORM_STEPS_OVER[targetNodeTypeName];
|
|
235
|
-
if (overrideSteps === null) {
|
|
236
|
-
return null;
|
|
237
|
-
}
|
|
238
|
-
var steps = overrideSteps !== null && overrideSteps !== void 0 ? overrideSteps : TRANSFORM_STEPS[fromCategory][toCategory];
|
|
239
|
-
return steps;
|
|
240
|
-
};
|
|
241
10
|
/**
|
|
242
11
|
* Convert a list of nodes to a target node type.
|
|
243
12
|
* If no steps are found, the source nodes are returned unchanged.
|
|
@@ -270,7 +39,7 @@ var convertNodesToTargetType = exports.convertNodesToTargetType = function conve
|
|
|
270
39
|
if (!selectedNodeTypeName || !targetNodeTypeName) {
|
|
271
40
|
return sourceNodes;
|
|
272
41
|
}
|
|
273
|
-
var steps =
|
|
42
|
+
var steps = _TRANSFORMATION_MATRIX.TRANSFORMATION_MATRIX[selectedNodeTypeName][targetNodeTypeName];
|
|
274
43
|
var context = {
|
|
275
44
|
// sourceNode is incorrect now - what to do here?
|
|
276
45
|
fromNode: sourceNode,
|
|
@@ -286,9 +55,6 @@ var convertNodesToTargetType = exports.convertNodesToTargetType = function conve
|
|
|
286
55
|
}, sourceNodes);
|
|
287
56
|
};
|
|
288
57
|
var isTransformDisabledBasedOnStepsConfig = exports.isTransformDisabledBasedOnStepsConfig = function isTransformDisabledBasedOnStepsConfig(selectedNodeType, targetNodeType) {
|
|
289
|
-
var steps =
|
|
290
|
-
|
|
291
|
-
return true;
|
|
292
|
-
}
|
|
293
|
-
return false;
|
|
58
|
+
var steps = _TRANSFORMATION_MATRIX.TRANSFORMATION_MATRIX[selectedNodeType][targetNodeType];
|
|
59
|
+
return !steps || steps.length === 0;
|
|
294
60
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.splitTextNodeForCodeBlock = exports.isTextNode = exports.getTargetNodeTypeNameInContext = exports.getSelectedNode = exports.getBlockNodesInRange = exports.convertTextNodeToParagraph = exports.convertNestedExpandToExpand = exports.convertExpandToNestedExpand = void 0;
|
|
7
7
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
8
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
9
9
|
var _editorTables = require("@atlaskit/editor-tables");
|
|
@@ -131,20 +131,42 @@ var getBlockNodesInRange = exports.getBlockNodesInRange = function getBlockNodes
|
|
|
131
131
|
};
|
|
132
132
|
|
|
133
133
|
/**
|
|
134
|
-
*
|
|
135
|
-
*
|
|
134
|
+
* Splits a text node (paragraph/heading) into parts for codeBlock conversion.
|
|
135
|
+
* Returns an array of:
|
|
136
|
+
* - strings (text content that can go into codeBlock)
|
|
137
|
+
* - PMNodes (incompatible inline nodes wrapped in paragraphs that need to break out)
|
|
136
138
|
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
+
* This preserves inline nodes (like status, inlineExtension) that cannot be represented as plain text.
|
|
140
|
+
*
|
|
141
|
+
* @param node - The text node (paragraph or heading) to split
|
|
142
|
+
* @param schema - The schema to use for creating paragraph nodes
|
|
143
|
+
* @returns Array of strings (for codeBlock) and PMNodes (to break out)
|
|
139
144
|
*/
|
|
140
|
-
var
|
|
141
|
-
var
|
|
145
|
+
var splitTextNodeForCodeBlock = exports.splitTextNodeForCodeBlock = function splitTextNodeForCodeBlock(node, schema) {
|
|
146
|
+
var result = [];
|
|
147
|
+
var currentText = '';
|
|
148
|
+
node.content.forEach(function (child) {
|
|
142
149
|
if (child.isText) {
|
|
143
|
-
|
|
150
|
+
currentText += child.text || '';
|
|
144
151
|
} else if (child.type.name === 'hardBreak') {
|
|
145
|
-
|
|
152
|
+
currentText += '\n';
|
|
153
|
+
} else {
|
|
154
|
+
// Incompatible inline node (status, inlineExtension, etc.)
|
|
155
|
+
// Flush accumulated text if any
|
|
156
|
+
if (currentText) {
|
|
157
|
+
result.push(currentText);
|
|
158
|
+
currentText = '';
|
|
159
|
+
}
|
|
160
|
+
// Wrap the inline node in a paragraph and add it to break out
|
|
161
|
+
var paragraph = schema.nodes.paragraph.create({}, child);
|
|
162
|
+
result.push(paragraph);
|
|
146
163
|
}
|
|
147
|
-
return '';
|
|
148
164
|
});
|
|
149
|
-
|
|
165
|
+
|
|
166
|
+
// Don't forget remaining text (or empty string for empty nodes)
|
|
167
|
+
// Always push at least an empty string so empty paragraphs create empty codeBlocks
|
|
168
|
+
if (currentText || result.length === 0) {
|
|
169
|
+
result.push(currentText);
|
|
170
|
+
}
|
|
171
|
+
return result;
|
|
150
172
|
};
|