@atlaskit/editor-jira-transformer 8.2.3 → 8.2.5
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 +13 -0
- package/dist/cjs/collapse-whitespace.js +0 -3
- package/dist/cjs/emojiHelper.js +0 -1
- package/dist/cjs/fix-doc.js +8 -25
- package/dist/cjs/index.js +63 -126
- package/dist/cjs/parse-html.js +0 -5
- package/dist/cjs/schema.js +0 -1
- package/dist/cjs/utils.js +25 -99
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/fix-doc.js +8 -24
- package/dist/es2019/index.js +29 -92
- package/dist/es2019/parse-html.js +0 -2
- package/dist/es2019/utils.js +22 -80
- package/dist/es2019/version.json +1 -1
- package/dist/esm/fix-doc.js +8 -24
- package/dist/esm/index.js +63 -118
- package/dist/esm/parse-html.js +0 -2
- package/dist/esm/utils.js +26 -90
- package/dist/esm/version.json +1 -1
- package/package.json +10 -8
- package/report.api.md +14 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
|
|
4
3
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, 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 normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
5
|
-
|
|
6
4
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
7
|
-
|
|
8
5
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
9
|
-
|
|
10
6
|
import { Fragment, Node as PMNode } from 'prosemirror-model';
|
|
11
7
|
import parseHtml from './parse-html';
|
|
12
8
|
import fixDoc from './fix-doc';
|
|
@@ -15,24 +11,23 @@ import { isSchemaWithLists, isSchemaWithMentions, isSchemaWithEmojis, isSchemaWi
|
|
|
15
11
|
export var JIRATransformer = /*#__PURE__*/function () {
|
|
16
12
|
function JIRATransformer(schema, customEncoders, mediaContextInfo) {
|
|
17
13
|
_classCallCheck(this, JIRATransformer);
|
|
18
|
-
|
|
19
14
|
this.schema = schema;
|
|
20
15
|
this.customEncoders = customEncoders || {};
|
|
21
16
|
this.mediaContextInfo = mediaContextInfo;
|
|
22
17
|
}
|
|
23
|
-
|
|
24
18
|
_createClass(JIRATransformer, [{
|
|
25
19
|
key: "encode",
|
|
26
20
|
value: function encode(node) {
|
|
27
21
|
this.doc = this.makeDocument();
|
|
28
22
|
this.doc.body.appendChild(this.encodeFragment(node.content));
|
|
29
|
-
var html = this.doc.body.innerHTML;
|
|
23
|
+
var html = this.doc.body.innerHTML;
|
|
30
24
|
|
|
25
|
+
// JIRA encodes empty documents as an empty string
|
|
31
26
|
if (html === '<p></p>') {
|
|
32
27
|
return '';
|
|
33
|
-
}
|
|
34
|
-
|
|
28
|
+
}
|
|
35
29
|
|
|
30
|
+
// Normalise to XHTML style self closing tags.
|
|
36
31
|
return html.replace(/<br><\/br>/g, '<br />').replace(/<br>/g, '<br />').replace(/<hr><\/hr>/g, '<hr />').replace(/<hr>/g, '<hr />').replace(/&/g, '&');
|
|
37
32
|
}
|
|
38
33
|
}, {
|
|
@@ -40,87 +35,86 @@ export var JIRATransformer = /*#__PURE__*/function () {
|
|
|
40
35
|
value: function parse(html) {
|
|
41
36
|
var convertedNodes = new WeakMap();
|
|
42
37
|
var dom = fixDoc(parseHtml(html)).querySelector('body');
|
|
43
|
-
var nodes = bfsOrder(dom);
|
|
38
|
+
var nodes = bfsOrder(dom);
|
|
44
39
|
|
|
40
|
+
// JIRA encodes empty content as a single nbsp
|
|
45
41
|
if (nodes.length === 1 && nodes[0].textContent === '\xa0') {
|
|
46
42
|
var schemaNodes = this.schema.nodes;
|
|
47
43
|
return schemaNodes.doc.createChecked({}, schemaNodes.paragraph.createChecked());
|
|
48
|
-
}
|
|
49
|
-
|
|
44
|
+
}
|
|
50
45
|
|
|
46
|
+
// Process through nodes in reverse (so deepest child elements are first).
|
|
51
47
|
for (var i = nodes.length - 1; i >= 0; i--) {
|
|
52
|
-
var node = nodes[i];
|
|
53
|
-
|
|
48
|
+
var node = nodes[i];
|
|
49
|
+
// for tables we take tbody content, because tbody is not in schema so the whole bfs thing wouldn't work
|
|
54
50
|
var targetNode = node.tagName && node.tagName.toUpperCase() === 'TABLE' ? node.firstChild : node;
|
|
55
|
-
|
|
56
51
|
var _content = this.getContent(targetNode, convertedNodes);
|
|
57
|
-
|
|
58
52
|
var candidate = convert(_content, node, this.schema);
|
|
59
|
-
|
|
60
53
|
if (typeof candidate !== 'undefined') {
|
|
61
54
|
convertedNodes.set(node, candidate);
|
|
62
55
|
}
|
|
63
56
|
}
|
|
57
|
+
var content = this.getContent(dom, convertedNodes);
|
|
64
58
|
|
|
65
|
-
|
|
59
|
+
// Dangling inline nodes can't be directly inserted into a document, so
|
|
66
60
|
// we attempt to wrap in a paragraph.
|
|
67
|
-
|
|
68
61
|
var compatibleContent = this.schema.nodes.doc.validContent(content) ? content : ensureBlocks(content, this.schema);
|
|
69
62
|
return this.schema.nodes.doc.createChecked({}, compatibleContent);
|
|
70
63
|
}
|
|
64
|
+
|
|
71
65
|
/*
|
|
72
66
|
* Contructs a struct string of replacement blocks and marks for a given node
|
|
73
67
|
*/
|
|
74
|
-
|
|
75
68
|
}, {
|
|
76
69
|
key: "getContent",
|
|
77
70
|
value: function getContent(node, convertedNodes) {
|
|
78
71
|
var fragment = Fragment.fromArray([]);
|
|
79
72
|
var childIndex;
|
|
80
|
-
|
|
81
73
|
for (childIndex = 0; childIndex < node.childNodes.length; childIndex++) {
|
|
82
74
|
var child = node.childNodes[childIndex];
|
|
83
75
|
var thing = convertedNodes.get(child);
|
|
84
|
-
|
|
85
76
|
if (thing instanceof Fragment || thing instanceof PMNode) {
|
|
86
77
|
fragment = fragment.append(Fragment.from(thing));
|
|
87
78
|
}
|
|
88
79
|
}
|
|
89
|
-
|
|
90
80
|
return fragment;
|
|
91
81
|
}
|
|
92
82
|
}, {
|
|
93
83
|
key: "encodeNode",
|
|
94
84
|
value: function encodeNode(node) {
|
|
95
85
|
var _this$schema$nodes = this.schema.nodes,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
86
|
+
blockquote = _this$schema$nodes.blockquote,
|
|
87
|
+
bulletList = _this$schema$nodes.bulletList,
|
|
88
|
+
codeBlock = _this$schema$nodes.codeBlock,
|
|
89
|
+
hardBreak = _this$schema$nodes.hardBreak,
|
|
90
|
+
heading = _this$schema$nodes.heading,
|
|
91
|
+
listItem = _this$schema$nodes.listItem,
|
|
92
|
+
mention = _this$schema$nodes.mention,
|
|
93
|
+
emoji = _this$schema$nodes.emoji,
|
|
94
|
+
orderedList = _this$schema$nodes.orderedList,
|
|
95
|
+
paragraph = _this$schema$nodes.paragraph,
|
|
96
|
+
rule = _this$schema$nodes.rule,
|
|
97
|
+
mediaInline = _this$schema$nodes.mediaInline,
|
|
98
|
+
mediaGroup = _this$schema$nodes.mediaGroup,
|
|
99
|
+
mediaSingle = _this$schema$nodes.mediaSingle,
|
|
100
|
+
media = _this$schema$nodes.media,
|
|
101
|
+
table = _this$schema$nodes.table;
|
|
102
|
+
|
|
103
|
+
// We compare node type names in this method rather than
|
|
112
104
|
// node types directly as the node comparision fails.
|
|
105
|
+
|
|
113
106
|
// This suggests the schema which is coming from
|
|
114
107
|
// the doc has been recreated after being passed
|
|
115
108
|
// to this transformer on setup which is somewhat
|
|
116
109
|
// unexpected.
|
|
110
|
+
|
|
117
111
|
// This package is internally (within editor) considered
|
|
118
112
|
// "obsolete", and we are aiming to either hand over
|
|
119
113
|
// or deprecate.
|
|
114
|
+
|
|
120
115
|
// This "fix" is being done to unblock an existing
|
|
121
116
|
// consumer so they can apply an unrelated security
|
|
122
117
|
// upgrade.
|
|
123
|
-
|
|
124
118
|
if (node.isText) {
|
|
125
119
|
return this.encodeText(node);
|
|
126
120
|
} else if (node.type.name === heading.name) {
|
|
@@ -132,7 +126,6 @@ export var JIRATransformer = /*#__PURE__*/function () {
|
|
|
132
126
|
} else if (node.type.name === hardBreak.name) {
|
|
133
127
|
return this.encodeHardBreak();
|
|
134
128
|
}
|
|
135
|
-
|
|
136
129
|
if (isSchemaWithLists(this.schema)) {
|
|
137
130
|
if (node.type.name === bulletList.name) {
|
|
138
131
|
return this.encodeBulletList(node);
|
|
@@ -142,23 +135,18 @@ export var JIRATransformer = /*#__PURE__*/function () {
|
|
|
142
135
|
return this.encodeListItem(node);
|
|
143
136
|
}
|
|
144
137
|
}
|
|
145
|
-
|
|
146
138
|
if (isSchemaWithMentions(this.schema) && node.type.name === mention.name) {
|
|
147
139
|
return this.encodeMention(node, this.customEncoders.mention);
|
|
148
140
|
}
|
|
149
|
-
|
|
150
141
|
if (isSchemaWithEmojis(this.schema) && node.type.name === emoji.name) {
|
|
151
142
|
return this.encodeEmoji(node);
|
|
152
143
|
}
|
|
153
|
-
|
|
154
144
|
if (isSchemaWithCodeBlock(this.schema) && node.type.name === codeBlock.name) {
|
|
155
145
|
return this.encodeCodeBlock(node);
|
|
156
146
|
}
|
|
157
|
-
|
|
158
147
|
if (isSchemaWithBlockQuotes(this.schema) && node.type.name === blockquote.name) {
|
|
159
148
|
return this.encodeBlockQuote(node);
|
|
160
149
|
}
|
|
161
|
-
|
|
162
150
|
if (isSchemaWithMedia(this.schema)) {
|
|
163
151
|
if (node.type.name === mediaGroup.name) {
|
|
164
152
|
return this.encodeMediaGroup(node);
|
|
@@ -168,11 +156,9 @@ export var JIRATransformer = /*#__PURE__*/function () {
|
|
|
168
156
|
return this.encodeMedia(node);
|
|
169
157
|
}
|
|
170
158
|
}
|
|
171
|
-
|
|
172
159
|
if (isSchemaWithTables(this.schema) && node.type.name === table.name) {
|
|
173
160
|
return this.encodeTable(node);
|
|
174
161
|
}
|
|
175
|
-
|
|
176
162
|
throw new Error("Unexpected node '".concat(node.type.name, "' for HTML encoding"));
|
|
177
163
|
}
|
|
178
164
|
}, {
|
|
@@ -187,7 +173,6 @@ export var JIRATransformer = /*#__PURE__*/function () {
|
|
|
187
173
|
key: "encodeFragment",
|
|
188
174
|
value: function encodeFragment(fragment) {
|
|
189
175
|
var _this = this;
|
|
190
|
-
|
|
191
176
|
var documentFragment = this.doc.createDocumentFragment();
|
|
192
177
|
fragment.forEach(function (node) {
|
|
193
178
|
return documentFragment.appendChild(_this.encodeNode(node));
|
|
@@ -205,9 +190,8 @@ export var JIRATransformer = /*#__PURE__*/function () {
|
|
|
205
190
|
});
|
|
206
191
|
return specialsEncoded;
|
|
207
192
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
193
|
+
var level = node.attrs.level;
|
|
194
|
+
// @see ED-4708
|
|
211
195
|
var elem = this.doc.createElement("h".concat(level === 6 ? 5 : level));
|
|
212
196
|
var anchor = this.doc.createElement('a');
|
|
213
197
|
anchor.setAttribute('name', anchorNameEncode(node.textContent));
|
|
@@ -229,76 +213,61 @@ export var JIRATransformer = /*#__PURE__*/function () {
|
|
|
229
213
|
var root = this.doc.createDocumentFragment();
|
|
230
214
|
var elem = root;
|
|
231
215
|
var _this$schema$marks = this.schema.marks,
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
216
|
+
code = _this$schema$marks.code,
|
|
217
|
+
em = _this$schema$marks.em,
|
|
218
|
+
link = _this$schema$marks.link,
|
|
219
|
+
typeAheadQuery = _this$schema$marks.typeAheadQuery,
|
|
220
|
+
strike = _this$schema$marks.strike,
|
|
221
|
+
strong = _this$schema$marks.strong,
|
|
222
|
+
subsup = _this$schema$marks.subsup,
|
|
223
|
+
underline = _this$schema$marks.underline,
|
|
224
|
+
textColor = _this$schema$marks.textColor;
|
|
242
225
|
var _iterator = _createForOfIteratorHelper(node.marks),
|
|
243
|
-
|
|
244
|
-
|
|
226
|
+
_step;
|
|
245
227
|
try {
|
|
246
228
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
247
229
|
var mark = _step.value;
|
|
248
|
-
|
|
249
230
|
switch (mark.type) {
|
|
250
231
|
case strong:
|
|
251
232
|
elem = elem.appendChild(this.doc.createElement('b'));
|
|
252
233
|
break;
|
|
253
|
-
|
|
254
234
|
case em:
|
|
255
235
|
elem = elem.appendChild(this.doc.createElement('em'));
|
|
256
236
|
break;
|
|
257
|
-
|
|
258
237
|
case code:
|
|
259
238
|
elem = elem.appendChild(this.doc.createElement('tt'));
|
|
260
239
|
break;
|
|
261
|
-
|
|
262
240
|
case strike:
|
|
263
241
|
elem = elem.appendChild(this.doc.createElement('del'));
|
|
264
242
|
break;
|
|
265
|
-
|
|
266
243
|
case underline:
|
|
267
244
|
elem = elem.appendChild(this.doc.createElement('ins'));
|
|
268
245
|
break;
|
|
269
|
-
|
|
270
246
|
case subsup:
|
|
271
247
|
elem = elem.appendChild(this.doc.createElement(mark.attrs['type']));
|
|
272
248
|
break;
|
|
273
|
-
|
|
274
249
|
case link:
|
|
275
250
|
var linkElem = this.doc.createElement('a');
|
|
276
251
|
var href = mark.attrs['href'];
|
|
277
|
-
/** JIRA always expects external-link attribute set on links created via editor unless its #fragment */
|
|
278
252
|
|
|
253
|
+
/** JIRA always expects external-link attribute set on links created via editor unless its #fragment */
|
|
279
254
|
if (!href.match(/^#/)) {
|
|
280
255
|
linkElem.setAttribute('class', 'external-link');
|
|
281
256
|
linkElem.setAttribute('rel', 'nofollow');
|
|
282
257
|
}
|
|
283
|
-
|
|
284
258
|
linkElem.setAttribute('href', href);
|
|
285
|
-
|
|
286
259
|
if (mark.attrs['title']) {
|
|
287
260
|
linkElem.setAttribute('title', mark.attrs['title']);
|
|
288
261
|
}
|
|
289
|
-
|
|
290
262
|
elem = elem.appendChild(linkElem);
|
|
291
263
|
break;
|
|
292
|
-
|
|
293
264
|
case textColor:
|
|
294
265
|
var fontElem = this.doc.createElement('font');
|
|
295
266
|
fontElem.setAttribute('color', mark.attrs['color']);
|
|
296
267
|
elem = elem.appendChild(fontElem);
|
|
297
268
|
break;
|
|
298
|
-
|
|
299
269
|
case typeAheadQuery:
|
|
300
270
|
break;
|
|
301
|
-
|
|
302
271
|
default:
|
|
303
272
|
throw new Error("Unable to encode mark '".concat(mark.type.name, "'"));
|
|
304
273
|
}
|
|
@@ -308,7 +277,6 @@ export var JIRATransformer = /*#__PURE__*/function () {
|
|
|
308
277
|
} finally {
|
|
309
278
|
_iterator.f();
|
|
310
279
|
}
|
|
311
|
-
|
|
312
280
|
elem.textContent = node.text;
|
|
313
281
|
return root;
|
|
314
282
|
} else {
|
|
@@ -332,11 +300,9 @@ export var JIRATransformer = /*#__PURE__*/function () {
|
|
|
332
300
|
elem.setAttribute('class', 'alternate');
|
|
333
301
|
elem.setAttribute('type', 'disc');
|
|
334
302
|
elem.appendChild(this.encodeFragment(node.content));
|
|
335
|
-
|
|
336
303
|
for (var index = 0; index < elem.childElementCount; index++) {
|
|
337
304
|
elem.children[index].setAttribute('data-parent', 'ul');
|
|
338
305
|
}
|
|
339
|
-
|
|
340
306
|
return elem;
|
|
341
307
|
}
|
|
342
308
|
}, {
|
|
@@ -344,40 +310,34 @@ export var JIRATransformer = /*#__PURE__*/function () {
|
|
|
344
310
|
value: function encodeOrderedList(node) {
|
|
345
311
|
var elem = this.doc.createElement('ol');
|
|
346
312
|
elem.appendChild(this.encodeFragment(node.content));
|
|
347
|
-
|
|
348
313
|
for (var index = 0; index < elem.childElementCount; index++) {
|
|
349
314
|
elem.children[index].setAttribute('data-parent', 'ol');
|
|
350
315
|
}
|
|
351
|
-
|
|
352
316
|
return elem;
|
|
353
317
|
}
|
|
354
318
|
}, {
|
|
355
319
|
key: "encodeListItem",
|
|
356
320
|
value: function encodeListItem(node) {
|
|
357
321
|
var _this2 = this;
|
|
358
|
-
|
|
359
322
|
var elem = this.doc.createElement('li');
|
|
360
|
-
|
|
361
323
|
if (node.content.childCount) {
|
|
362
324
|
var hasBlocks = false;
|
|
363
325
|
node.content.forEach(function (childNode) {
|
|
364
326
|
if (childNode.type === _this2.schema.nodes.bulletList || childNode.type === _this2.schema.nodes.orderedList) {
|
|
365
327
|
var list = _this2.encodeNode(childNode);
|
|
328
|
+
|
|
366
329
|
/**
|
|
367
330
|
* Changing type for nested list:
|
|
368
331
|
*
|
|
369
332
|
* Second level -> circle
|
|
370
333
|
* Third and deeper -> square
|
|
371
334
|
*/
|
|
372
|
-
|
|
373
|
-
|
|
374
335
|
if (list instanceof HTMLElement && list.tagName === 'UL') {
|
|
375
336
|
list.setAttribute('type', 'circle');
|
|
376
337
|
[].forEach.call(list.querySelectorAll('ul'), function (ul) {
|
|
377
338
|
ul.setAttribute('type', 'square');
|
|
378
339
|
});
|
|
379
340
|
}
|
|
380
|
-
|
|
381
341
|
elem.appendChild(list);
|
|
382
342
|
} else if (childNode.type.name === 'paragraph' && !hasBlocks) {
|
|
383
343
|
// Strip the paragraph node from the list item.
|
|
@@ -386,12 +346,10 @@ export var JIRATransformer = /*#__PURE__*/function () {
|
|
|
386
346
|
if (childNode.isBlock) {
|
|
387
347
|
hasBlocks = true;
|
|
388
348
|
}
|
|
389
|
-
|
|
390
349
|
elem.appendChild(_this2.encodeNode(childNode));
|
|
391
350
|
}
|
|
392
351
|
});
|
|
393
352
|
}
|
|
394
|
-
|
|
395
353
|
return elem;
|
|
396
354
|
}
|
|
397
355
|
}, {
|
|
@@ -416,8 +374,8 @@ export var JIRATransformer = /*#__PURE__*/function () {
|
|
|
416
374
|
elem.setAttribute('class', 'code panel');
|
|
417
375
|
var content = this.doc.createElement('div');
|
|
418
376
|
content.setAttribute('class', 'codeContent panelContent');
|
|
419
|
-
var pre = this.doc.createElement('pre');
|
|
420
|
-
|
|
377
|
+
var pre = this.doc.createElement('pre');
|
|
378
|
+
// java is default language for JIRA
|
|
421
379
|
pre.setAttribute('class', "code-".concat((node.attrs.language || 'plain').toLocaleLowerCase()));
|
|
422
380
|
pre.appendChild(this.encodeFragment(node.content));
|
|
423
381
|
content.appendChild(pre);
|
|
@@ -452,31 +410,26 @@ export var JIRATransformer = /*#__PURE__*/function () {
|
|
|
452
410
|
value: function addDataToNode(domNode, mediaNode) {
|
|
453
411
|
var defaultDisplayType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'thumbnail';
|
|
454
412
|
var _mediaNode$attrs = mediaNode.attrs,
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
413
|
+
id = _mediaNode$attrs.id,
|
|
414
|
+
type = _mediaNode$attrs.type,
|
|
415
|
+
collection = _mediaNode$attrs.collection,
|
|
416
|
+
__fileName = _mediaNode$attrs.__fileName,
|
|
417
|
+
__displayType = _mediaNode$attrs.__displayType,
|
|
418
|
+
width = _mediaNode$attrs.width,
|
|
419
|
+
height = _mediaNode$attrs.height;
|
|
420
|
+
// Order of dataset matters in IE Edge, please keep the current order
|
|
463
421
|
domNode.setAttribute('data-attachment-type', __displayType || defaultDisplayType);
|
|
464
|
-
|
|
465
422
|
if (__fileName) {
|
|
466
423
|
domNode.setAttribute('data-attachment-name', __fileName);
|
|
467
424
|
}
|
|
468
|
-
|
|
469
425
|
if (width) {
|
|
470
426
|
domNode.setAttribute('data-width', width);
|
|
471
427
|
}
|
|
472
|
-
|
|
473
428
|
if (height) {
|
|
474
429
|
domNode.setAttribute('data-height', height);
|
|
475
430
|
}
|
|
476
|
-
|
|
477
431
|
domNode.setAttribute('data-media-services-type', type);
|
|
478
432
|
domNode.setAttribute('data-media-services-id', id);
|
|
479
|
-
|
|
480
433
|
if (collection) {
|
|
481
434
|
domNode.setAttribute('data-media-services-collection', collection);
|
|
482
435
|
}
|
|
@@ -485,9 +438,9 @@ export var JIRATransformer = /*#__PURE__*/function () {
|
|
|
485
438
|
key: "buildURLWithContextInfo",
|
|
486
439
|
value: function buildURLWithContextInfo(fileId, contextInfo) {
|
|
487
440
|
var clientId = contextInfo.clientId,
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
441
|
+
baseUrl = contextInfo.baseUrl,
|
|
442
|
+
token = contextInfo.token,
|
|
443
|
+
collection = contextInfo.collection;
|
|
491
444
|
return "".concat(baseUrl, "/file/").concat(fileId, "/image?token=").concat(token, "&client=").concat(clientId, "&collection=").concat(collection, "&width=200&height=200&mode=fit");
|
|
492
445
|
}
|
|
493
446
|
}, {
|
|
@@ -502,7 +455,6 @@ export var JIRATransformer = /*#__PURE__*/function () {
|
|
|
502
455
|
// span.no-br > a[data-media] > content
|
|
503
456
|
var elem = this.doc.createElement('span');
|
|
504
457
|
var a = this.doc.createElement('a');
|
|
505
|
-
|
|
506
458
|
if (node.attrs.__displayType === 'file' || !(node.attrs.__displayType || this.isImageMimeType(node.attrs.__fileMimeType))) {
|
|
507
459
|
elem.setAttribute('class', 'nobr');
|
|
508
460
|
this.addDataToNode(a, node, 'file');
|
|
@@ -510,20 +462,18 @@ export var JIRATransformer = /*#__PURE__*/function () {
|
|
|
510
462
|
} else {
|
|
511
463
|
elem.setAttribute('class', 'image-wrap');
|
|
512
464
|
var img = this.doc.createElement('img');
|
|
513
|
-
img.setAttribute('alt', node.attrs.__fileName);
|
|
514
|
-
|
|
465
|
+
img.setAttribute('alt', node.attrs.__fileName);
|
|
466
|
+
// Newly uploaded items have collection
|
|
515
467
|
if (node.attrs.collection && this.mediaContextInfo && this.mediaContextInfo.uploadContext) {
|
|
516
468
|
img.setAttribute('src', this.buildURLWithContextInfo(node.attrs.id, this.mediaContextInfo.uploadContext));
|
|
517
469
|
} else if (this.mediaContextInfo && this.mediaContextInfo.viewContext) {
|
|
518
470
|
img.setAttribute('src', this.buildURLWithContextInfo(node.attrs.id, this.mediaContextInfo.viewContext));
|
|
519
471
|
}
|
|
520
|
-
|
|
521
472
|
this.addDataToNode(img, node);
|
|
522
473
|
var jiraThumb = this.doc.createElement('jira-attachment-thumbnail');
|
|
523
474
|
jiraThumb.appendChild(img);
|
|
524
475
|
a.appendChild(jiraThumb);
|
|
525
476
|
}
|
|
526
|
-
|
|
527
477
|
elem.appendChild(a);
|
|
528
478
|
return elem;
|
|
529
479
|
}
|
|
@@ -531,17 +481,13 @@ export var JIRATransformer = /*#__PURE__*/function () {
|
|
|
531
481
|
key: "encodeTable",
|
|
532
482
|
value: function encodeTable(node) {
|
|
533
483
|
var _this3 = this;
|
|
534
|
-
|
|
535
484
|
var elem = this.doc.createElement('table');
|
|
536
485
|
var tbody = this.doc.createElement('tbody');
|
|
537
486
|
node.descendants(function (rowNode) {
|
|
538
487
|
var rowElement = _this3.doc.createElement('tr');
|
|
539
|
-
|
|
540
488
|
rowNode.descendants(function (colNode) {
|
|
541
489
|
var cellType = colNode.type === _this3.schema.nodes.tableCell ? 'd' : 'h';
|
|
542
|
-
|
|
543
490
|
var cellElement = _this3.doc.createElement("t".concat(cellType));
|
|
544
|
-
|
|
545
491
|
cellElement.setAttribute('class', "confluenceT".concat(cellType));
|
|
546
492
|
cellElement.appendChild(_this3.encodeFragment(colNode.content));
|
|
547
493
|
rowElement.appendChild(cellElement);
|
|
@@ -555,6 +501,5 @@ export var JIRATransformer = /*#__PURE__*/function () {
|
|
|
555
501
|
return elem;
|
|
556
502
|
}
|
|
557
503
|
}]);
|
|
558
|
-
|
|
559
504
|
return JIRATransformer;
|
|
560
505
|
}();
|
package/dist/esm/parse-html.js
CHANGED
|
@@ -6,7 +6,6 @@ export default function (fragment) {
|
|
|
6
6
|
collapse(tree.documentElement, isBlock);
|
|
7
7
|
return tree;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
9
|
function isBlock(node) {
|
|
11
10
|
// these blocks are mainly used to collapse whitespace between the blocks
|
|
12
11
|
// (preventing spurious text nodes of ' ')
|
|
@@ -62,6 +61,5 @@ function isBlock(node) {
|
|
|
62
61
|
case 'UL':
|
|
63
62
|
return true;
|
|
64
63
|
}
|
|
65
|
-
|
|
66
64
|
return false;
|
|
67
65
|
}
|