@atlaskit/editor-jira-transformer 9.0.1 → 9.0.3
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 +12 -0
- package/dist/cjs/collapse-whitespace.js +2 -0
- package/dist/cjs/fix-doc.js +2 -0
- package/dist/cjs/index.js +39 -3
- package/dist/cjs/parse-html.js +4 -0
- package/dist/cjs/utils.js +43 -3
- package/dist/es2019/collapse-whitespace.js +2 -0
- package/dist/es2019/emojiHelper.js +1 -1
- package/dist/es2019/fix-doc.js +2 -0
- package/dist/es2019/index.js +39 -3
- package/dist/es2019/parse-html.js +4 -0
- package/dist/es2019/utils.js +44 -4
- package/dist/esm/collapse-whitespace.js +2 -0
- package/dist/esm/fix-doc.js +2 -0
- package/dist/esm/index.js +39 -3
- package/dist/esm/parse-html.js +4 -0
- package/dist/esm/utils.js +43 -3
- package/docs/0-intro.tsx +4 -0
- package/package.json +5 -5
- package/tsconfig.json +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,5 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _collapseWhitespace = _interopRequireDefault(require("collapse-whitespace"));
|
|
9
|
+
// Ignored via go/ees005
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
11
|
var collapseWhitespace = _collapseWhitespace.default;
|
|
10
12
|
var _default = exports.default = collapseWhitespace;
|
package/dist/cjs/fix-doc.js
CHANGED
|
@@ -85,6 +85,8 @@ function repairParagraph(p) {
|
|
|
85
85
|
});
|
|
86
86
|
|
|
87
87
|
// Replace old P
|
|
88
|
+
// Ignored via go/ees005
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
88
90
|
var parent = p.parentNode;
|
|
89
91
|
parent.insertBefore(fragment, p.nextSibling);
|
|
90
92
|
// IE11 doesn't support remove
|
package/dist/cjs/index.js
CHANGED
|
@@ -35,12 +35,29 @@ var JIRATransformer = exports.JIRATransformer = /*#__PURE__*/function () {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
// Normalise to XHTML style self closing tags.
|
|
38
|
-
return html
|
|
38
|
+
return html
|
|
39
|
+
// Ignored via go/ees005
|
|
40
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
41
|
+
.replace(/<br><\/br>/g, '<br />')
|
|
42
|
+
// Ignored via go/ees005
|
|
43
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
44
|
+
.replace(/<br>/g, '<br />')
|
|
45
|
+
// Ignored via go/ees005
|
|
46
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
47
|
+
.replace(/<hr><\/hr>/g, '<hr />')
|
|
48
|
+
// Ignored via go/ees005
|
|
49
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
50
|
+
.replace(/<hr>/g, '<hr />')
|
|
51
|
+
// Ignored via go/ees005
|
|
52
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
53
|
+
.replace(/&/g, '&');
|
|
39
54
|
}
|
|
40
55
|
}, {
|
|
41
56
|
key: "parse",
|
|
42
57
|
value: function parse(html) {
|
|
43
58
|
var convertedNodes = new WeakMap();
|
|
59
|
+
// Ignored via go/ees005
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
44
61
|
var dom = (0, _fixDoc.default)((0, _parseHtml.default)(html)).querySelector('body');
|
|
45
62
|
var nodes = (0, _utils.bfsOrder)(dom);
|
|
46
63
|
|
|
@@ -54,7 +71,10 @@ var JIRATransformer = exports.JIRATransformer = /*#__PURE__*/function () {
|
|
|
54
71
|
for (var i = nodes.length - 1; i >= 0; i--) {
|
|
55
72
|
var node = nodes[i];
|
|
56
73
|
// for tables we take tbody content, because tbody is not in schema so the whole bfs thing wouldn't work
|
|
57
|
-
var targetNode =
|
|
74
|
+
var targetNode =
|
|
75
|
+
// Ignored via go/ees005
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
77
|
+
node.tagName && node.tagName.toUpperCase() === 'TABLE' ? node.firstChild : node;
|
|
58
78
|
var _content = this.getContent(targetNode, convertedNodes);
|
|
59
79
|
var candidate = (0, _utils.convert)(_content, node, this.schema);
|
|
60
80
|
if (typeof candidate !== 'undefined') {
|
|
@@ -166,6 +186,9 @@ var JIRATransformer = exports.JIRATransformer = /*#__PURE__*/function () {
|
|
|
166
186
|
if ((0, _schemaJira.isSchemaWithTables)(this.schema) && node.type.name === table.name) {
|
|
167
187
|
return this.encodeTable(node);
|
|
168
188
|
}
|
|
189
|
+
|
|
190
|
+
// Ignored via go/ees005
|
|
191
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
169
192
|
throw new Error("Unexpected node '".concat(node.type.name, "' for HTML encoding"));
|
|
170
193
|
}
|
|
171
194
|
}, {
|
|
@@ -173,6 +196,8 @@ var JIRATransformer = exports.JIRATransformer = /*#__PURE__*/function () {
|
|
|
173
196
|
value: function makeDocument() {
|
|
174
197
|
var doc = document.implementation.createHTMLDocument('');
|
|
175
198
|
doc.body = doc.createElement('body');
|
|
199
|
+
// Ignored via go/ees005
|
|
200
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
176
201
|
doc.documentElement.appendChild(doc.body);
|
|
177
202
|
return doc;
|
|
178
203
|
}
|
|
@@ -181,6 +206,8 @@ var JIRATransformer = exports.JIRATransformer = /*#__PURE__*/function () {
|
|
|
181
206
|
value: function encodeFragment(fragment) {
|
|
182
207
|
var _this = this;
|
|
183
208
|
var documentFragment = this.doc.createDocumentFragment();
|
|
209
|
+
// Ignored via go/ees005
|
|
210
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
184
211
|
fragment.forEach(function (node) {
|
|
185
212
|
return documentFragment.appendChild(_this.encodeNode(node));
|
|
186
213
|
});
|
|
@@ -190,9 +217,14 @@ var JIRATransformer = exports.JIRATransformer = /*#__PURE__*/function () {
|
|
|
190
217
|
key: "encodeHeading",
|
|
191
218
|
value: function encodeHeading(node) {
|
|
192
219
|
function anchorNameEncode(name) {
|
|
220
|
+
// Ignored via go/ees005
|
|
221
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
193
222
|
var noSpaces = name.replace(/ /g, '');
|
|
194
223
|
var uriEncoded = encodeURIComponent(noSpaces);
|
|
195
|
-
var specialsEncoded = uriEncoded.replace(
|
|
224
|
+
var specialsEncoded = uriEncoded.replace(
|
|
225
|
+
// Ignored via go/ees005
|
|
226
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
227
|
+
/[!'()*]/g, function (c) {
|
|
196
228
|
return '%' + c.charCodeAt(0).toString(16);
|
|
197
229
|
});
|
|
198
230
|
return specialsEncoded;
|
|
@@ -258,6 +290,8 @@ var JIRATransformer = exports.JIRATransformer = /*#__PURE__*/function () {
|
|
|
258
290
|
var href = mark.attrs['href'];
|
|
259
291
|
|
|
260
292
|
/** JIRA always expects external-link attribute set on links created via editor unless its #fragment */
|
|
293
|
+
// Ignored via go/ees005
|
|
294
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
261
295
|
if (!href.match(/^#/)) {
|
|
262
296
|
linkElem.setAttribute('class', 'external-link');
|
|
263
297
|
linkElem.setAttribute('rel', 'nofollow');
|
|
@@ -331,6 +365,8 @@ var JIRATransformer = exports.JIRATransformer = /*#__PURE__*/function () {
|
|
|
331
365
|
var hasBlocks = false;
|
|
332
366
|
node.content.forEach(function (childNode) {
|
|
333
367
|
if (childNode.type === _this2.schema.nodes.bulletList || childNode.type === _this2.schema.nodes.orderedList) {
|
|
368
|
+
// Ignored via go/ees005
|
|
369
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
334
370
|
var list = _this2.encodeNode(childNode);
|
|
335
371
|
|
|
336
372
|
/**
|
package/dist/cjs/parse-html.js
CHANGED
|
@@ -8,8 +8,12 @@ exports.default = _default;
|
|
|
8
8
|
var _collapseWhitespace = _interopRequireDefault(require("./collapse-whitespace"));
|
|
9
9
|
function _default(fragment) {
|
|
10
10
|
var html = "<!doctype html><html><body>".concat(fragment, "</body></html>");
|
|
11
|
+
// Ignored via go/ees005
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
13
|
var parser = new window.DOMParser();
|
|
12
14
|
var tree = parser.parseFromString(html, 'text/html');
|
|
15
|
+
// Ignored via go/ees005
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
13
17
|
(0, _collapseWhitespace.default)(tree.documentElement, isBlock);
|
|
14
18
|
return tree;
|
|
15
19
|
}
|
package/dist/cjs/utils.js
CHANGED
|
@@ -78,6 +78,8 @@ function convert(content, node, schema) {
|
|
|
78
78
|
if (!(0, _schemaJira.isSchemaWithAdvancedTextFormattingMarks)(schema)) {
|
|
79
79
|
return null;
|
|
80
80
|
}
|
|
81
|
+
// Ignored via go/ees005
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
81
83
|
return addMarks(content, [schema.marks.strike.create()]);
|
|
82
84
|
case 'B':
|
|
83
85
|
return addMarks(content, [schema.marks.strong.create()]);
|
|
@@ -87,6 +89,8 @@ function convert(content, node, schema) {
|
|
|
87
89
|
if (!(0, _schemaJira.isSchemaWithAdvancedTextFormattingMarks)(schema)) {
|
|
88
90
|
return null;
|
|
89
91
|
}
|
|
92
|
+
// Ignored via go/ees005
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
90
94
|
return addMarks(content, [schema.marks.code.create()]);
|
|
91
95
|
case 'SUB':
|
|
92
96
|
case 'SUP':
|
|
@@ -110,6 +114,8 @@ function convert(content, node, schema) {
|
|
|
110
114
|
// Nodes
|
|
111
115
|
case 'A':
|
|
112
116
|
if (node.className === 'user-hover' && (0, _schemaJira.isSchemaWithMentions)(schema)) {
|
|
117
|
+
// Ignored via go/ees005
|
|
118
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
113
119
|
return schema.nodes.mention.createChecked({
|
|
114
120
|
id: node.getAttribute('rel'),
|
|
115
121
|
text: node.textContent
|
|
@@ -142,7 +148,10 @@ function convert(content, node, schema) {
|
|
|
142
148
|
var jiraKey = node.getAttribute('data-jira-key');
|
|
143
149
|
var link = node.getElementsByTagName('a')[0];
|
|
144
150
|
if (jiraKey && link) {
|
|
145
|
-
return addMarks(_model.Fragment.from(schema.text(jiraKey)), [
|
|
151
|
+
return addMarks(_model.Fragment.from(schema.text(jiraKey)), [
|
|
152
|
+
// Ignored via go/ees005
|
|
153
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
154
|
+
schema.marks.link.create({
|
|
146
155
|
href: link.getAttribute('href'),
|
|
147
156
|
title: link.getAttribute('title')
|
|
148
157
|
})]);
|
|
@@ -201,7 +210,10 @@ function convert(content, node, schema) {
|
|
|
201
210
|
// @see ED-4708
|
|
202
211
|
{
|
|
203
212
|
level: level === 6 ? 5 : level
|
|
204
|
-
}, schema.nodes.heading.validContent(content) ? content :
|
|
213
|
+
}, schema.nodes.heading.validContent(content) ? content :
|
|
214
|
+
// Ignored via go/ees005
|
|
215
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
216
|
+
ensureInline(schema, content, supportedMarks));
|
|
205
217
|
case 'BR':
|
|
206
218
|
return schema.nodes.hardBreak.createChecked();
|
|
207
219
|
case 'HR':
|
|
@@ -222,6 +234,8 @@ function convert(content, node, schema) {
|
|
|
222
234
|
if (child.type === schema.nodes.media) {
|
|
223
235
|
mediaArray.push(child);
|
|
224
236
|
return;
|
|
237
|
+
// Ignored via go/ees005
|
|
238
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
225
239
|
} else if (!(child.isText && /^\s*$/.test(child.text || ''))) {
|
|
226
240
|
hasNonMediaChildren = true;
|
|
227
241
|
}
|
|
@@ -246,11 +260,19 @@ function convert(content, node, schema) {
|
|
|
246
260
|
if ((0, _schemaJira.isSchemaWithLists)(schema)) {
|
|
247
261
|
switch (tag) {
|
|
248
262
|
case 'UL':
|
|
263
|
+
// Ignored via go/ees005
|
|
264
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
249
265
|
return schema.nodes.bulletList.createChecked({}, content);
|
|
250
266
|
case 'OL':
|
|
267
|
+
// Ignored via go/ees005
|
|
268
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
251
269
|
return schema.nodes.orderedList.createChecked({}, content);
|
|
252
270
|
case 'LI':
|
|
271
|
+
// Ignored via go/ees005
|
|
272
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
253
273
|
var compatibleContent = schema.nodes.listItem.validContent(content) ? content : ensureBlocks(content, schema, schema.nodes.listItem);
|
|
274
|
+
// Ignored via go/ees005
|
|
275
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
254
276
|
return schema.nodes.listItem.createChecked({}, compatibleContent);
|
|
255
277
|
}
|
|
256
278
|
}
|
|
@@ -267,7 +289,12 @@ function convert(content, node, schema) {
|
|
|
267
289
|
return null;
|
|
268
290
|
}
|
|
269
291
|
var language = node.className === 'preformatted panel' ? 'plain' : pre.className.split('-')[1];
|
|
292
|
+
|
|
293
|
+
// Ignored via go/ees005
|
|
294
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
270
295
|
var textContent = (pre.textContent || '').replace(/\r\n/g, '\n');
|
|
296
|
+
// Ignored via go/ees005
|
|
297
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
271
298
|
return schema.nodes.codeBlock.createChecked({
|
|
272
299
|
language: language
|
|
273
300
|
}, textContent ? schema.text(textContent) : undefined);
|
|
@@ -278,7 +305,12 @@ function convert(content, node, schema) {
|
|
|
278
305
|
}
|
|
279
306
|
}
|
|
280
307
|
if ((0, _schemaJira.isSchemaWithBlockQuotes)(schema) && tag === 'BLOCKQUOTE') {
|
|
281
|
-
var blockquoteContent =
|
|
308
|
+
var blockquoteContent =
|
|
309
|
+
// Ignored via go/ees005
|
|
310
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
311
|
+
content && content.content.length ? content : schema.nodes.paragraph.createChecked();
|
|
312
|
+
// Ignored via go/ees005
|
|
313
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
282
314
|
return schema.nodes.blockquote.createChecked({}, blockquoteContent);
|
|
283
315
|
}
|
|
284
316
|
|
|
@@ -288,6 +320,8 @@ function convert(content, node, schema) {
|
|
|
288
320
|
case 'TABLE':
|
|
289
321
|
return schema.nodes.table.createChecked({}, content);
|
|
290
322
|
case 'TR':
|
|
323
|
+
// Ignored via go/ees005
|
|
324
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
291
325
|
return schema.nodes.tableRow.createChecked({}, content);
|
|
292
326
|
case 'TD':
|
|
293
327
|
var tdContent = schema.nodes.tableCell.validContent(content) ? content : ensureBlocks(content, schema);
|
|
@@ -308,6 +342,8 @@ function bfsOrder(root) {
|
|
|
308
342
|
var inqueue = [root];
|
|
309
343
|
var outqueue = [];
|
|
310
344
|
var elem;
|
|
345
|
+
// Ignored via go/ees005
|
|
346
|
+
// eslint-disable-next-line no-cond-assign
|
|
311
347
|
while (elem = inqueue.shift()) {
|
|
312
348
|
outqueue.push(elem);
|
|
313
349
|
var childIndex = void 0;
|
|
@@ -367,10 +403,14 @@ function isMedia(node) {
|
|
|
367
403
|
}
|
|
368
404
|
function isMediaSingle(node) {
|
|
369
405
|
if (isMedia(node)) {
|
|
406
|
+
// Ignored via go/ees005
|
|
407
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
370
408
|
var dataNode = node.querySelector('[data-media-services-id]');
|
|
371
409
|
if (dataNode instanceof HTMLElement) {
|
|
372
410
|
var width = parseInt(dataNode.getAttribute('data-width') || '', 10);
|
|
373
411
|
var height = parseInt(dataNode.getAttribute('data-height') || '', 10);
|
|
412
|
+
// Ignored via go/ees005
|
|
413
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
374
414
|
if (node.parentNode.classList.contains('mediaSingle') && width && height) {
|
|
375
415
|
return true;
|
|
376
416
|
}
|
|
@@ -24,7 +24,7 @@ const emojiMap = {
|
|
|
24
24
|
};
|
|
25
25
|
export function mapImageToEmoji(imageElement) {
|
|
26
26
|
let src = imageElement.src;
|
|
27
|
-
|
|
27
|
+
const slashIndex = src.lastIndexOf('/');
|
|
28
28
|
src = src.substr(slashIndex + 1);
|
|
29
29
|
return emojiMap[src] || null;
|
|
30
30
|
}
|
package/dist/es2019/fix-doc.js
CHANGED
|
@@ -77,6 +77,8 @@ function repairParagraph(p) {
|
|
|
77
77
|
});
|
|
78
78
|
|
|
79
79
|
// Replace old P
|
|
80
|
+
// Ignored via go/ees005
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
80
82
|
const parent = p.parentNode;
|
|
81
83
|
parent.insertBefore(fragment, p.nextSibling);
|
|
82
84
|
// IE11 doesn't support remove
|
package/dist/es2019/index.js
CHANGED
|
@@ -20,10 +20,27 @@ export class JIRATransformer {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
// Normalise to XHTML style self closing tags.
|
|
23
|
-
return html
|
|
23
|
+
return html
|
|
24
|
+
// Ignored via go/ees005
|
|
25
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
26
|
+
.replace(/<br><\/br>/g, '<br />')
|
|
27
|
+
// Ignored via go/ees005
|
|
28
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
29
|
+
.replace(/<br>/g, '<br />')
|
|
30
|
+
// Ignored via go/ees005
|
|
31
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
32
|
+
.replace(/<hr><\/hr>/g, '<hr />')
|
|
33
|
+
// Ignored via go/ees005
|
|
34
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
35
|
+
.replace(/<hr>/g, '<hr />')
|
|
36
|
+
// Ignored via go/ees005
|
|
37
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
38
|
+
.replace(/&/g, '&');
|
|
24
39
|
}
|
|
25
40
|
parse(html) {
|
|
26
41
|
const convertedNodes = new WeakMap();
|
|
42
|
+
// Ignored via go/ees005
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
27
44
|
const dom = fixDoc(parseHtml(html)).querySelector('body');
|
|
28
45
|
const nodes = bfsOrder(dom);
|
|
29
46
|
|
|
@@ -37,7 +54,10 @@ export class JIRATransformer {
|
|
|
37
54
|
for (let i = nodes.length - 1; i >= 0; i--) {
|
|
38
55
|
const node = nodes[i];
|
|
39
56
|
// for tables we take tbody content, because tbody is not in schema so the whole bfs thing wouldn't work
|
|
40
|
-
const targetNode =
|
|
57
|
+
const targetNode =
|
|
58
|
+
// Ignored via go/ees005
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
60
|
+
node.tagName && node.tagName.toUpperCase() === 'TABLE' ? node.firstChild : node;
|
|
41
61
|
const content = this.getContent(targetNode, convertedNodes);
|
|
42
62
|
const candidate = convert(content, node, this.schema);
|
|
43
63
|
if (typeof candidate !== 'undefined') {
|
|
@@ -146,24 +166,36 @@ export class JIRATransformer {
|
|
|
146
166
|
if (isSchemaWithTables(this.schema) && node.type.name === table.name) {
|
|
147
167
|
return this.encodeTable(node);
|
|
148
168
|
}
|
|
169
|
+
|
|
170
|
+
// Ignored via go/ees005
|
|
171
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
149
172
|
throw new Error(`Unexpected node '${node.type.name}' for HTML encoding`);
|
|
150
173
|
}
|
|
151
174
|
makeDocument() {
|
|
152
175
|
const doc = document.implementation.createHTMLDocument('');
|
|
153
176
|
doc.body = doc.createElement('body');
|
|
177
|
+
// Ignored via go/ees005
|
|
178
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
154
179
|
doc.documentElement.appendChild(doc.body);
|
|
155
180
|
return doc;
|
|
156
181
|
}
|
|
157
182
|
encodeFragment(fragment) {
|
|
158
183
|
const documentFragment = this.doc.createDocumentFragment();
|
|
184
|
+
// Ignored via go/ees005
|
|
185
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
159
186
|
fragment.forEach(node => documentFragment.appendChild(this.encodeNode(node)));
|
|
160
187
|
return documentFragment;
|
|
161
188
|
}
|
|
162
189
|
encodeHeading(node) {
|
|
163
190
|
function anchorNameEncode(name) {
|
|
191
|
+
// Ignored via go/ees005
|
|
192
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
164
193
|
const noSpaces = name.replace(/ /g, '');
|
|
165
194
|
const uriEncoded = encodeURIComponent(noSpaces);
|
|
166
|
-
const specialsEncoded = uriEncoded.replace(
|
|
195
|
+
const specialsEncoded = uriEncoded.replace(
|
|
196
|
+
// Ignored via go/ees005
|
|
197
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
198
|
+
/[!'()*]/g, c => '%' + c.charCodeAt(0).toString(16));
|
|
167
199
|
return specialsEncoded;
|
|
168
200
|
}
|
|
169
201
|
const {
|
|
@@ -222,6 +254,8 @@ export class JIRATransformer {
|
|
|
222
254
|
const href = mark.attrs['href'];
|
|
223
255
|
|
|
224
256
|
/** JIRA always expects external-link attribute set on links created via editor unless its #fragment */
|
|
257
|
+
// Ignored via go/ees005
|
|
258
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
225
259
|
if (!href.match(/^#/)) {
|
|
226
260
|
linkElem.setAttribute('class', 'external-link');
|
|
227
261
|
linkElem.setAttribute('rel', 'nofollow');
|
|
@@ -279,6 +313,8 @@ export class JIRATransformer {
|
|
|
279
313
|
let hasBlocks = false;
|
|
280
314
|
node.content.forEach(childNode => {
|
|
281
315
|
if (childNode.type === this.schema.nodes.bulletList || childNode.type === this.schema.nodes.orderedList) {
|
|
316
|
+
// Ignored via go/ees005
|
|
317
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
282
318
|
const list = this.encodeNode(childNode);
|
|
283
319
|
|
|
284
320
|
/**
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import collapse from './collapse-whitespace';
|
|
2
2
|
export default function (fragment) {
|
|
3
3
|
const html = `<!doctype html><html><body>${fragment}</body></html>`;
|
|
4
|
+
// Ignored via go/ees005
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
6
|
const parser = new window.DOMParser();
|
|
5
7
|
const tree = parser.parseFromString(html, 'text/html');
|
|
8
|
+
// Ignored via go/ees005
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
6
10
|
collapse(tree.documentElement, isBlock);
|
|
7
11
|
return tree;
|
|
8
12
|
}
|
package/dist/es2019/utils.js
CHANGED
|
@@ -65,6 +65,8 @@ export function convert(content, node, schema) {
|
|
|
65
65
|
if (!isSchemaWithAdvancedTextFormattingMarks(schema)) {
|
|
66
66
|
return null;
|
|
67
67
|
}
|
|
68
|
+
// Ignored via go/ees005
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
68
70
|
return addMarks(content, [schema.marks.strike.create()]);
|
|
69
71
|
case 'B':
|
|
70
72
|
return addMarks(content, [schema.marks.strong.create()]);
|
|
@@ -74,6 +76,8 @@ export function convert(content, node, schema) {
|
|
|
74
76
|
if (!isSchemaWithAdvancedTextFormattingMarks(schema)) {
|
|
75
77
|
return null;
|
|
76
78
|
}
|
|
79
|
+
// Ignored via go/ees005
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
77
81
|
return addMarks(content, [schema.marks.code.create()]);
|
|
78
82
|
case 'SUB':
|
|
79
83
|
case 'SUP':
|
|
@@ -97,6 +101,8 @@ export function convert(content, node, schema) {
|
|
|
97
101
|
// Nodes
|
|
98
102
|
case 'A':
|
|
99
103
|
if (node.className === 'user-hover' && isSchemaWithMentions(schema)) {
|
|
104
|
+
// Ignored via go/ees005
|
|
105
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
100
106
|
return schema.nodes.mention.createChecked({
|
|
101
107
|
id: node.getAttribute('rel'),
|
|
102
108
|
text: node.textContent
|
|
@@ -129,7 +135,10 @@ export function convert(content, node, schema) {
|
|
|
129
135
|
const jiraKey = node.getAttribute('data-jira-key');
|
|
130
136
|
const link = node.getElementsByTagName('a')[0];
|
|
131
137
|
if (jiraKey && link) {
|
|
132
|
-
return addMarks(Fragment.from(schema.text(jiraKey)), [
|
|
138
|
+
return addMarks(Fragment.from(schema.text(jiraKey)), [
|
|
139
|
+
// Ignored via go/ees005
|
|
140
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
141
|
+
schema.marks.link.create({
|
|
133
142
|
href: link.getAttribute('href'),
|
|
134
143
|
title: link.getAttribute('title')
|
|
135
144
|
})]);
|
|
@@ -168,7 +177,7 @@ export function convert(content, node, schema) {
|
|
|
168
177
|
if (node.parentElement && node.parentElement.className.match('jira-issue-macro-key')) {
|
|
169
178
|
return null;
|
|
170
179
|
} else if (node.className === 'emoticon') {
|
|
171
|
-
|
|
180
|
+
const emojiResult = mapImageToEmoji(node);
|
|
172
181
|
if (emojiResult) {
|
|
173
182
|
return schema.text(emojiResult);
|
|
174
183
|
}
|
|
@@ -186,7 +195,10 @@ export function convert(content, node, schema) {
|
|
|
186
195
|
// @see ED-4708
|
|
187
196
|
{
|
|
188
197
|
level: level === 6 ? 5 : level
|
|
189
|
-
}, schema.nodes.heading.validContent(content) ? content :
|
|
198
|
+
}, schema.nodes.heading.validContent(content) ? content :
|
|
199
|
+
// Ignored via go/ees005
|
|
200
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
201
|
+
ensureInline(schema, content, supportedMarks));
|
|
190
202
|
case 'BR':
|
|
191
203
|
return schema.nodes.hardBreak.createChecked();
|
|
192
204
|
case 'HR':
|
|
@@ -208,6 +220,8 @@ export function convert(content, node, schema) {
|
|
|
208
220
|
if (child.type === schema.nodes.media) {
|
|
209
221
|
mediaArray.push(child);
|
|
210
222
|
return;
|
|
223
|
+
// Ignored via go/ees005
|
|
224
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
211
225
|
} else if (!(child.isText && /^\s*$/.test(child.text || ''))) {
|
|
212
226
|
hasNonMediaChildren = true;
|
|
213
227
|
}
|
|
@@ -232,11 +246,19 @@ export function convert(content, node, schema) {
|
|
|
232
246
|
if (isSchemaWithLists(schema)) {
|
|
233
247
|
switch (tag) {
|
|
234
248
|
case 'UL':
|
|
249
|
+
// Ignored via go/ees005
|
|
250
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
235
251
|
return schema.nodes.bulletList.createChecked({}, content);
|
|
236
252
|
case 'OL':
|
|
253
|
+
// Ignored via go/ees005
|
|
254
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
237
255
|
return schema.nodes.orderedList.createChecked({}, content);
|
|
238
256
|
case 'LI':
|
|
257
|
+
// Ignored via go/ees005
|
|
258
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
239
259
|
const compatibleContent = schema.nodes.listItem.validContent(content) ? content : ensureBlocks(content, schema, schema.nodes.listItem);
|
|
260
|
+
// Ignored via go/ees005
|
|
261
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
240
262
|
return schema.nodes.listItem.createChecked({}, compatibleContent);
|
|
241
263
|
}
|
|
242
264
|
}
|
|
@@ -253,7 +275,12 @@ export function convert(content, node, schema) {
|
|
|
253
275
|
return null;
|
|
254
276
|
}
|
|
255
277
|
const language = node.className === 'preformatted panel' ? 'plain' : pre.className.split('-')[1];
|
|
278
|
+
|
|
279
|
+
// Ignored via go/ees005
|
|
280
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
256
281
|
const textContent = (pre.textContent || '').replace(/\r\n/g, '\n');
|
|
282
|
+
// Ignored via go/ees005
|
|
283
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
257
284
|
return schema.nodes.codeBlock.createChecked({
|
|
258
285
|
language
|
|
259
286
|
}, textContent ? schema.text(textContent) : undefined);
|
|
@@ -264,7 +291,12 @@ export function convert(content, node, schema) {
|
|
|
264
291
|
}
|
|
265
292
|
}
|
|
266
293
|
if (isSchemaWithBlockQuotes(schema) && tag === 'BLOCKQUOTE') {
|
|
267
|
-
|
|
294
|
+
const blockquoteContent =
|
|
295
|
+
// Ignored via go/ees005
|
|
296
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
297
|
+
content && content.content.length ? content : schema.nodes.paragraph.createChecked();
|
|
298
|
+
// Ignored via go/ees005
|
|
299
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
268
300
|
return schema.nodes.blockquote.createChecked({}, blockquoteContent);
|
|
269
301
|
}
|
|
270
302
|
|
|
@@ -274,6 +306,8 @@ export function convert(content, node, schema) {
|
|
|
274
306
|
case 'TABLE':
|
|
275
307
|
return schema.nodes.table.createChecked({}, content);
|
|
276
308
|
case 'TR':
|
|
309
|
+
// Ignored via go/ees005
|
|
310
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
277
311
|
return schema.nodes.tableRow.createChecked({}, content);
|
|
278
312
|
case 'TD':
|
|
279
313
|
const tdContent = schema.nodes.tableCell.validContent(content) ? content : ensureBlocks(content, schema);
|
|
@@ -294,6 +328,8 @@ export function bfsOrder(root) {
|
|
|
294
328
|
const inqueue = [root];
|
|
295
329
|
const outqueue = [];
|
|
296
330
|
let elem;
|
|
331
|
+
// Ignored via go/ees005
|
|
332
|
+
// eslint-disable-next-line no-cond-assign
|
|
297
333
|
while (elem = inqueue.shift()) {
|
|
298
334
|
outqueue.push(elem);
|
|
299
335
|
let childIndex;
|
|
@@ -344,10 +380,14 @@ function isMedia(node) {
|
|
|
344
380
|
}
|
|
345
381
|
function isMediaSingle(node) {
|
|
346
382
|
if (isMedia(node)) {
|
|
383
|
+
// Ignored via go/ees005
|
|
384
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
347
385
|
const dataNode = node.querySelector('[data-media-services-id]');
|
|
348
386
|
if (dataNode instanceof HTMLElement) {
|
|
349
387
|
const width = parseInt(dataNode.getAttribute('data-width') || '', 10);
|
|
350
388
|
const height = parseInt(dataNode.getAttribute('data-height') || '', 10);
|
|
389
|
+
// Ignored via go/ees005
|
|
390
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
351
391
|
if (node.parentNode.classList.contains('mediaSingle') && width && height) {
|
|
352
392
|
return true;
|
|
353
393
|
}
|
package/dist/esm/fix-doc.js
CHANGED
|
@@ -79,6 +79,8 @@ function repairParagraph(p) {
|
|
|
79
79
|
});
|
|
80
80
|
|
|
81
81
|
// Replace old P
|
|
82
|
+
// Ignored via go/ees005
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
82
84
|
var parent = p.parentNode;
|
|
83
85
|
parent.insertBefore(fragment, p.nextSibling);
|
|
84
86
|
// IE11 doesn't support remove
|
package/dist/esm/index.js
CHANGED
|
@@ -28,12 +28,29 @@ export var JIRATransformer = /*#__PURE__*/function () {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
// Normalise to XHTML style self closing tags.
|
|
31
|
-
return html
|
|
31
|
+
return html
|
|
32
|
+
// Ignored via go/ees005
|
|
33
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
34
|
+
.replace(/<br><\/br>/g, '<br />')
|
|
35
|
+
// Ignored via go/ees005
|
|
36
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
37
|
+
.replace(/<br>/g, '<br />')
|
|
38
|
+
// Ignored via go/ees005
|
|
39
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
40
|
+
.replace(/<hr><\/hr>/g, '<hr />')
|
|
41
|
+
// Ignored via go/ees005
|
|
42
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
43
|
+
.replace(/<hr>/g, '<hr />')
|
|
44
|
+
// Ignored via go/ees005
|
|
45
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
46
|
+
.replace(/&/g, '&');
|
|
32
47
|
}
|
|
33
48
|
}, {
|
|
34
49
|
key: "parse",
|
|
35
50
|
value: function parse(html) {
|
|
36
51
|
var convertedNodes = new WeakMap();
|
|
52
|
+
// Ignored via go/ees005
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
37
54
|
var dom = fixDoc(parseHtml(html)).querySelector('body');
|
|
38
55
|
var nodes = bfsOrder(dom);
|
|
39
56
|
|
|
@@ -47,7 +64,10 @@ export var JIRATransformer = /*#__PURE__*/function () {
|
|
|
47
64
|
for (var i = nodes.length - 1; i >= 0; i--) {
|
|
48
65
|
var node = nodes[i];
|
|
49
66
|
// for tables we take tbody content, because tbody is not in schema so the whole bfs thing wouldn't work
|
|
50
|
-
var targetNode =
|
|
67
|
+
var targetNode =
|
|
68
|
+
// Ignored via go/ees005
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
70
|
+
node.tagName && node.tagName.toUpperCase() === 'TABLE' ? node.firstChild : node;
|
|
51
71
|
var _content = this.getContent(targetNode, convertedNodes);
|
|
52
72
|
var candidate = convert(_content, node, this.schema);
|
|
53
73
|
if (typeof candidate !== 'undefined') {
|
|
@@ -159,6 +179,9 @@ export var JIRATransformer = /*#__PURE__*/function () {
|
|
|
159
179
|
if (isSchemaWithTables(this.schema) && node.type.name === table.name) {
|
|
160
180
|
return this.encodeTable(node);
|
|
161
181
|
}
|
|
182
|
+
|
|
183
|
+
// Ignored via go/ees005
|
|
184
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
162
185
|
throw new Error("Unexpected node '".concat(node.type.name, "' for HTML encoding"));
|
|
163
186
|
}
|
|
164
187
|
}, {
|
|
@@ -166,6 +189,8 @@ export var JIRATransformer = /*#__PURE__*/function () {
|
|
|
166
189
|
value: function makeDocument() {
|
|
167
190
|
var doc = document.implementation.createHTMLDocument('');
|
|
168
191
|
doc.body = doc.createElement('body');
|
|
192
|
+
// Ignored via go/ees005
|
|
193
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
169
194
|
doc.documentElement.appendChild(doc.body);
|
|
170
195
|
return doc;
|
|
171
196
|
}
|
|
@@ -174,6 +199,8 @@ export var JIRATransformer = /*#__PURE__*/function () {
|
|
|
174
199
|
value: function encodeFragment(fragment) {
|
|
175
200
|
var _this = this;
|
|
176
201
|
var documentFragment = this.doc.createDocumentFragment();
|
|
202
|
+
// Ignored via go/ees005
|
|
203
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
177
204
|
fragment.forEach(function (node) {
|
|
178
205
|
return documentFragment.appendChild(_this.encodeNode(node));
|
|
179
206
|
});
|
|
@@ -183,9 +210,14 @@ export var JIRATransformer = /*#__PURE__*/function () {
|
|
|
183
210
|
key: "encodeHeading",
|
|
184
211
|
value: function encodeHeading(node) {
|
|
185
212
|
function anchorNameEncode(name) {
|
|
213
|
+
// Ignored via go/ees005
|
|
214
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
186
215
|
var noSpaces = name.replace(/ /g, '');
|
|
187
216
|
var uriEncoded = encodeURIComponent(noSpaces);
|
|
188
|
-
var specialsEncoded = uriEncoded.replace(
|
|
217
|
+
var specialsEncoded = uriEncoded.replace(
|
|
218
|
+
// Ignored via go/ees005
|
|
219
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
220
|
+
/[!'()*]/g, function (c) {
|
|
189
221
|
return '%' + c.charCodeAt(0).toString(16);
|
|
190
222
|
});
|
|
191
223
|
return specialsEncoded;
|
|
@@ -251,6 +283,8 @@ export var JIRATransformer = /*#__PURE__*/function () {
|
|
|
251
283
|
var href = mark.attrs['href'];
|
|
252
284
|
|
|
253
285
|
/** JIRA always expects external-link attribute set on links created via editor unless its #fragment */
|
|
286
|
+
// Ignored via go/ees005
|
|
287
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
254
288
|
if (!href.match(/^#/)) {
|
|
255
289
|
linkElem.setAttribute('class', 'external-link');
|
|
256
290
|
linkElem.setAttribute('rel', 'nofollow');
|
|
@@ -324,6 +358,8 @@ export var JIRATransformer = /*#__PURE__*/function () {
|
|
|
324
358
|
var hasBlocks = false;
|
|
325
359
|
node.content.forEach(function (childNode) {
|
|
326
360
|
if (childNode.type === _this2.schema.nodes.bulletList || childNode.type === _this2.schema.nodes.orderedList) {
|
|
361
|
+
// Ignored via go/ees005
|
|
362
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
327
363
|
var list = _this2.encodeNode(childNode);
|
|
328
364
|
|
|
329
365
|
/**
|
package/dist/esm/parse-html.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import collapse from './collapse-whitespace';
|
|
2
2
|
export default function (fragment) {
|
|
3
3
|
var html = "<!doctype html><html><body>".concat(fragment, "</body></html>");
|
|
4
|
+
// Ignored via go/ees005
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
6
|
var parser = new window.DOMParser();
|
|
5
7
|
var tree = parser.parseFromString(html, 'text/html');
|
|
8
|
+
// Ignored via go/ees005
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
6
10
|
collapse(tree.documentElement, isBlock);
|
|
7
11
|
return tree;
|
|
8
12
|
}
|
package/dist/esm/utils.js
CHANGED
|
@@ -70,6 +70,8 @@ export function convert(content, node, schema) {
|
|
|
70
70
|
if (!isSchemaWithAdvancedTextFormattingMarks(schema)) {
|
|
71
71
|
return null;
|
|
72
72
|
}
|
|
73
|
+
// Ignored via go/ees005
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
73
75
|
return addMarks(content, [schema.marks.strike.create()]);
|
|
74
76
|
case 'B':
|
|
75
77
|
return addMarks(content, [schema.marks.strong.create()]);
|
|
@@ -79,6 +81,8 @@ export function convert(content, node, schema) {
|
|
|
79
81
|
if (!isSchemaWithAdvancedTextFormattingMarks(schema)) {
|
|
80
82
|
return null;
|
|
81
83
|
}
|
|
84
|
+
// Ignored via go/ees005
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
82
86
|
return addMarks(content, [schema.marks.code.create()]);
|
|
83
87
|
case 'SUB':
|
|
84
88
|
case 'SUP':
|
|
@@ -102,6 +106,8 @@ export function convert(content, node, schema) {
|
|
|
102
106
|
// Nodes
|
|
103
107
|
case 'A':
|
|
104
108
|
if (node.className === 'user-hover' && isSchemaWithMentions(schema)) {
|
|
109
|
+
// Ignored via go/ees005
|
|
110
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
105
111
|
return schema.nodes.mention.createChecked({
|
|
106
112
|
id: node.getAttribute('rel'),
|
|
107
113
|
text: node.textContent
|
|
@@ -134,7 +140,10 @@ export function convert(content, node, schema) {
|
|
|
134
140
|
var jiraKey = node.getAttribute('data-jira-key');
|
|
135
141
|
var link = node.getElementsByTagName('a')[0];
|
|
136
142
|
if (jiraKey && link) {
|
|
137
|
-
return addMarks(Fragment.from(schema.text(jiraKey)), [
|
|
143
|
+
return addMarks(Fragment.from(schema.text(jiraKey)), [
|
|
144
|
+
// Ignored via go/ees005
|
|
145
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
146
|
+
schema.marks.link.create({
|
|
138
147
|
href: link.getAttribute('href'),
|
|
139
148
|
title: link.getAttribute('title')
|
|
140
149
|
})]);
|
|
@@ -193,7 +202,10 @@ export function convert(content, node, schema) {
|
|
|
193
202
|
// @see ED-4708
|
|
194
203
|
{
|
|
195
204
|
level: level === 6 ? 5 : level
|
|
196
|
-
}, schema.nodes.heading.validContent(content) ? content :
|
|
205
|
+
}, schema.nodes.heading.validContent(content) ? content :
|
|
206
|
+
// Ignored via go/ees005
|
|
207
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
208
|
+
ensureInline(schema, content, supportedMarks));
|
|
197
209
|
case 'BR':
|
|
198
210
|
return schema.nodes.hardBreak.createChecked();
|
|
199
211
|
case 'HR':
|
|
@@ -214,6 +226,8 @@ export function convert(content, node, schema) {
|
|
|
214
226
|
if (child.type === schema.nodes.media) {
|
|
215
227
|
mediaArray.push(child);
|
|
216
228
|
return;
|
|
229
|
+
// Ignored via go/ees005
|
|
230
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
217
231
|
} else if (!(child.isText && /^\s*$/.test(child.text || ''))) {
|
|
218
232
|
hasNonMediaChildren = true;
|
|
219
233
|
}
|
|
@@ -238,11 +252,19 @@ export function convert(content, node, schema) {
|
|
|
238
252
|
if (isSchemaWithLists(schema)) {
|
|
239
253
|
switch (tag) {
|
|
240
254
|
case 'UL':
|
|
255
|
+
// Ignored via go/ees005
|
|
256
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
241
257
|
return schema.nodes.bulletList.createChecked({}, content);
|
|
242
258
|
case 'OL':
|
|
259
|
+
// Ignored via go/ees005
|
|
260
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
243
261
|
return schema.nodes.orderedList.createChecked({}, content);
|
|
244
262
|
case 'LI':
|
|
263
|
+
// Ignored via go/ees005
|
|
264
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
245
265
|
var compatibleContent = schema.nodes.listItem.validContent(content) ? content : ensureBlocks(content, schema, schema.nodes.listItem);
|
|
266
|
+
// Ignored via go/ees005
|
|
267
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
246
268
|
return schema.nodes.listItem.createChecked({}, compatibleContent);
|
|
247
269
|
}
|
|
248
270
|
}
|
|
@@ -259,7 +281,12 @@ export function convert(content, node, schema) {
|
|
|
259
281
|
return null;
|
|
260
282
|
}
|
|
261
283
|
var language = node.className === 'preformatted panel' ? 'plain' : pre.className.split('-')[1];
|
|
284
|
+
|
|
285
|
+
// Ignored via go/ees005
|
|
286
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
262
287
|
var textContent = (pre.textContent || '').replace(/\r\n/g, '\n');
|
|
288
|
+
// Ignored via go/ees005
|
|
289
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
263
290
|
return schema.nodes.codeBlock.createChecked({
|
|
264
291
|
language: language
|
|
265
292
|
}, textContent ? schema.text(textContent) : undefined);
|
|
@@ -270,7 +297,12 @@ export function convert(content, node, schema) {
|
|
|
270
297
|
}
|
|
271
298
|
}
|
|
272
299
|
if (isSchemaWithBlockQuotes(schema) && tag === 'BLOCKQUOTE') {
|
|
273
|
-
var blockquoteContent =
|
|
300
|
+
var blockquoteContent =
|
|
301
|
+
// Ignored via go/ees005
|
|
302
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
303
|
+
content && content.content.length ? content : schema.nodes.paragraph.createChecked();
|
|
304
|
+
// Ignored via go/ees005
|
|
305
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
274
306
|
return schema.nodes.blockquote.createChecked({}, blockquoteContent);
|
|
275
307
|
}
|
|
276
308
|
|
|
@@ -280,6 +312,8 @@ export function convert(content, node, schema) {
|
|
|
280
312
|
case 'TABLE':
|
|
281
313
|
return schema.nodes.table.createChecked({}, content);
|
|
282
314
|
case 'TR':
|
|
315
|
+
// Ignored via go/ees005
|
|
316
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
283
317
|
return schema.nodes.tableRow.createChecked({}, content);
|
|
284
318
|
case 'TD':
|
|
285
319
|
var tdContent = schema.nodes.tableCell.validContent(content) ? content : ensureBlocks(content, schema);
|
|
@@ -300,6 +334,8 @@ export function bfsOrder(root) {
|
|
|
300
334
|
var inqueue = [root];
|
|
301
335
|
var outqueue = [];
|
|
302
336
|
var elem;
|
|
337
|
+
// Ignored via go/ees005
|
|
338
|
+
// eslint-disable-next-line no-cond-assign
|
|
303
339
|
while (elem = inqueue.shift()) {
|
|
304
340
|
outqueue.push(elem);
|
|
305
341
|
var childIndex = void 0;
|
|
@@ -359,10 +395,14 @@ function isMedia(node) {
|
|
|
359
395
|
}
|
|
360
396
|
function isMediaSingle(node) {
|
|
361
397
|
if (isMedia(node)) {
|
|
398
|
+
// Ignored via go/ees005
|
|
399
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
362
400
|
var dataNode = node.querySelector('[data-media-services-id]');
|
|
363
401
|
if (dataNode instanceof HTMLElement) {
|
|
364
402
|
var width = parseInt(dataNode.getAttribute('data-width') || '', 10);
|
|
365
403
|
var height = parseInt(dataNode.getAttribute('data-height') || '', 10);
|
|
404
|
+
// Ignored via go/ees005
|
|
405
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
366
406
|
if (node.parentNode.classList.contains('mediaSingle') && width && height) {
|
|
367
407
|
return true;
|
|
368
408
|
}
|
package/docs/0-intro.tsx
CHANGED
|
@@ -22,8 +22,12 @@ This package provides a transformation from ProseMirror Node → wikimarkup and
|
|
|
22
22
|
${(
|
|
23
23
|
<Example
|
|
24
24
|
packageName="@atlaskit/editor-jira-transformer"
|
|
25
|
+
// Ignored via go/ees005
|
|
26
|
+
// eslint-disable-next-line import/no-commonjs
|
|
25
27
|
Component={require('../examples/1-jira-html-input').default}
|
|
26
28
|
title="Jira HTML Input"
|
|
29
|
+
// Ignored via go/ees005
|
|
30
|
+
// eslint-disable-next-line import/no-commonjs
|
|
27
31
|
source={require('!!raw-loader!../examples/1-jira-html-input')}
|
|
28
32
|
/>
|
|
29
33
|
)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-jira-transformer",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.3",
|
|
4
4
|
"description": "Editor JIRA transformer's",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@atlaskit/adf-schema": "^46.1.0",
|
|
42
|
-
"@atlaskit/editor-common": "^
|
|
42
|
+
"@atlaskit/editor-common": "^99.0.0",
|
|
43
43
|
"@atlaskit/editor-prosemirror": "6.2.1",
|
|
44
44
|
"@babel/runtime": "^7.0.0",
|
|
45
45
|
"collapse-whitespace": "^1.1.6"
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@atlaskit/activity": "^1.0.1",
|
|
52
|
-
"@atlaskit/editor-core": "^203.
|
|
52
|
+
"@atlaskit/editor-core": "^203.10.0",
|
|
53
53
|
"@atlaskit/editor-json-transformer": "^8.21.0",
|
|
54
54
|
"@atlaskit/editor-test-helpers": "^21.0.0",
|
|
55
|
-
"@atlaskit/mention": "^23.
|
|
55
|
+
"@atlaskit/mention": "^23.7.0",
|
|
56
56
|
"@atlaskit/theme": "^14.0.0",
|
|
57
|
-
"@atlaskit/tokens": "
|
|
57
|
+
"@atlaskit/tokens": "3.0.0",
|
|
58
58
|
"@atlaskit/util-data-test": "^17.13.0",
|
|
59
59
|
"@emotion/react": "^11.7.1",
|
|
60
60
|
"typescript": "~5.4.2"
|