@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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # @atlaskit/editor-jira-transformer
2
2
 
3
+ ## 8.2.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [`2e01c9c74b5`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2e01c9c74b5) - DUMMY remove before merging to master; dupe adf-schema via adf-utils
8
+ - Updated dependencies
9
+
10
+ ## 8.2.4
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies
15
+
3
16
  ## 8.2.3
4
17
 
5
18
  ### Patch Changes
@@ -1,14 +1,11 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
8
  var _collapseWhitespace = _interopRequireDefault(require("collapse-whitespace"));
11
-
12
9
  var collapseWhitespace = _collapseWhitespace.default;
13
10
  var _default = collapseWhitespace;
14
11
  exports.default = _default;
@@ -28,7 +28,6 @@ var emojiMap = {
28
28
  'flag.png': '🚩',
29
29
  'flag_gray.png': '🏳'
30
30
  };
31
-
32
31
  function mapImageToEmoji(imageElement) {
33
32
  var src = imageElement.src;
34
33
  var slashIndex = src.lastIndexOf('/');
@@ -4,58 +4,47 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = _default;
7
-
8
7
  function getNodeName(node) {
9
8
  return node && node.nodeName.toUpperCase();
10
9
  }
11
-
12
10
  function isMedia(node) {
13
11
  if (!node) {
14
12
  return false;
15
13
  }
16
-
17
14
  if (getNodeName(node) === 'SPAN' && node instanceof HTMLElement) {
18
15
  return !!node.querySelector('a > jira-attachment-thumbnail > img[data-attachment-type="thumbnail"], ' + 'a[data-attachment-type="file"]');
19
16
  }
20
-
21
17
  return false;
22
18
  }
23
-
24
19
  function repairParagraph(p) {
25
20
  var paragraphs = [];
26
21
  var buffer = [];
27
22
  var mediaGroupFound = false;
28
23
  var skipBuffer = false;
29
-
30
24
  var processMedia = function processMedia() {
31
25
  if (buffer.length) {
32
26
  var head = buffer[0];
33
-
34
27
  if (getNodeName(head) === 'BR') {
35
28
  buffer.shift();
36
29
  }
37
-
38
30
  paragraphs.push(buffer);
39
31
  buffer = [];
40
32
  }
41
33
  };
42
-
43
34
  for (var i = 0, length = p.childNodes.length; i < length; i++) {
44
35
  var node = p.childNodes[i];
45
- skipBuffer = false; // [..., M, BR, ...]
46
-
36
+ skipBuffer = false;
37
+ // [..., M, BR, ...]
47
38
  if (getNodeName(node) === 'BR') {
48
39
  // [mmm, M, BR, ...]
49
40
  if (mediaGroupFound) {
50
41
  processMedia();
51
42
  mediaGroupFound = false;
52
43
  skipBuffer = true;
53
- } // [..., BR, M, ...]
54
-
55
-
44
+ }
45
+ // [..., BR, M, ...]
56
46
  if (isMedia(node.nextSibling)) {
57
47
  mediaGroupFound = true;
58
-
59
48
  if (buffer.length) {
60
49
  paragraphs.push(buffer);
61
50
  buffer = [];
@@ -72,23 +61,19 @@ function repairParagraph(p) {
72
61
  if (getNodeName(node) === '#TEXT' && (node.textContent || '').trim() === '') {
73
62
  continue;
74
63
  }
75
-
76
64
  buffer = (paragraphs.pop() || []).concat(buffer);
77
65
  mediaGroupFound = false;
78
66
  }
79
67
  }
80
-
81
68
  if (!skipBuffer) {
82
69
  buffer.push(node);
83
70
  }
84
71
  }
85
-
86
72
  if (mediaGroupFound) {
87
73
  processMedia();
88
74
  } else {
89
75
  paragraphs.push(buffer);
90
76
  }
91
-
92
77
  if (paragraphs.length > 1) {
93
78
  var fragment = document.createDocumentFragment();
94
79
  paragraphs.forEach(function (childP) {
@@ -97,21 +82,19 @@ function repairParagraph(p) {
97
82
  return innerP.appendChild(child);
98
83
  });
99
84
  fragment.appendChild(innerP);
100
- }); // Replace old P
85
+ });
101
86
 
87
+ // Replace old P
102
88
  var parent = p.parentNode;
103
- parent.insertBefore(fragment, p.nextSibling); // IE11 doesn't support remove
104
-
89
+ parent.insertBefore(fragment, p.nextSibling);
90
+ // IE11 doesn't support remove
105
91
  parent.removeChild(p);
106
92
  }
107
93
  }
108
-
109
94
  function _default(doc) {
110
95
  var paragraphs = doc.querySelectorAll('p');
111
-
112
96
  for (var i = 0, length = paragraphs.length; i < length; i++) {
113
97
  repairParagraph(paragraphs[i]);
114
98
  }
115
-
116
99
  return doc;
117
100
  }
package/dist/cjs/index.js CHANGED
@@ -1,32 +1,20 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.JIRATransformer = void 0;
9
-
10
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
-
12
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
-
14
10
  var _prosemirrorModel = require("prosemirror-model");
15
-
16
11
  var _parseHtml = _interopRequireDefault(require("./parse-html"));
17
-
18
12
  var _fixDoc = _interopRequireDefault(require("./fix-doc"));
19
-
20
13
  var _utils = require("./utils");
21
-
22
14
  var _schemaJira = require("@atlaskit/adf-schema/schema-jira");
23
-
24
15
  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; } } }; }
25
-
26
16
  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); }
27
-
28
17
  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; }
29
-
30
18
  var JIRATransformer = /*#__PURE__*/function () {
31
19
  function JIRATransformer(schema, customEncoders, mediaContextInfo) {
32
20
  (0, _classCallCheck2.default)(this, JIRATransformer);
@@ -34,19 +22,19 @@ var JIRATransformer = /*#__PURE__*/function () {
34
22
  this.customEncoders = customEncoders || {};
35
23
  this.mediaContextInfo = mediaContextInfo;
36
24
  }
37
-
38
25
  (0, _createClass2.default)(JIRATransformer, [{
39
26
  key: "encode",
40
27
  value: function encode(node) {
41
28
  this.doc = this.makeDocument();
42
29
  this.doc.body.appendChild(this.encodeFragment(node.content));
43
- var html = this.doc.body.innerHTML; // JIRA encodes empty documents as an empty string
30
+ var html = this.doc.body.innerHTML;
44
31
 
32
+ // JIRA encodes empty documents as an empty string
45
33
  if (html === '<p></p>') {
46
34
  return '';
47
- } // Normalise to XHTML style self closing tags.
48
-
35
+ }
49
36
 
37
+ // Normalise to XHTML style self closing tags.
50
38
  return html.replace(/<br><\/br>/g, '<br />').replace(/<br>/g, '<br />').replace(/<hr><\/hr>/g, '<hr />').replace(/<hr>/g, '<hr />').replace(/&amp;/g, '&');
51
39
  }
52
40
  }, {
@@ -54,88 +42,86 @@ var JIRATransformer = /*#__PURE__*/function () {
54
42
  value: function parse(html) {
55
43
  var convertedNodes = new WeakMap();
56
44
  var dom = (0, _fixDoc.default)((0, _parseHtml.default)(html)).querySelector('body');
57
- var nodes = (0, _utils.bfsOrder)(dom); // JIRA encodes empty content as a single nbsp
45
+ var nodes = (0, _utils.bfsOrder)(dom);
58
46
 
47
+ // JIRA encodes empty content as a single nbsp
59
48
  if (nodes.length === 1 && nodes[0].textContent === '\xa0') {
60
49
  var schemaNodes = this.schema.nodes;
61
50
  return schemaNodes.doc.createChecked({}, schemaNodes.paragraph.createChecked());
62
- } // Process through nodes in reverse (so deepest child elements are first).
63
-
51
+ }
64
52
 
53
+ // Process through nodes in reverse (so deepest child elements are first).
65
54
  for (var i = nodes.length - 1; i >= 0; i--) {
66
- var node = nodes[i]; // for tables we take tbody content, because tbody is not in schema so the whole bfs thing wouldn't work
67
-
55
+ var node = nodes[i];
56
+ // for tables we take tbody content, because tbody is not in schema so the whole bfs thing wouldn't work
68
57
  var targetNode = node.tagName && node.tagName.toUpperCase() === 'TABLE' ? node.firstChild : node;
69
-
70
58
  var _content = this.getContent(targetNode, convertedNodes);
71
-
72
59
  var candidate = (0, _utils.convert)(_content, node, this.schema);
73
-
74
60
  if (typeof candidate !== 'undefined') {
75
61
  convertedNodes.set(node, candidate);
76
62
  }
77
63
  }
64
+ var content = this.getContent(dom, convertedNodes);
78
65
 
79
- var content = this.getContent(dom, convertedNodes); // Dangling inline nodes can't be directly inserted into a document, so
66
+ // Dangling inline nodes can't be directly inserted into a document, so
80
67
  // we attempt to wrap in a paragraph.
81
-
82
68
  var compatibleContent = this.schema.nodes.doc.validContent(content) ? content : (0, _utils.ensureBlocks)(content, this.schema);
83
69
  return this.schema.nodes.doc.createChecked({}, compatibleContent);
84
70
  }
71
+
85
72
  /*
86
73
  * Contructs a struct string of replacement blocks and marks for a given node
87
74
  */
88
-
89
75
  }, {
90
76
  key: "getContent",
91
77
  value: function getContent(node, convertedNodes) {
92
78
  var fragment = _prosemirrorModel.Fragment.fromArray([]);
93
-
94
79
  var childIndex;
95
-
96
80
  for (childIndex = 0; childIndex < node.childNodes.length; childIndex++) {
97
81
  var child = node.childNodes[childIndex];
98
82
  var thing = convertedNodes.get(child);
99
-
100
83
  if (thing instanceof _prosemirrorModel.Fragment || thing instanceof _prosemirrorModel.Node) {
101
84
  fragment = fragment.append(_prosemirrorModel.Fragment.from(thing));
102
85
  }
103
86
  }
104
-
105
87
  return fragment;
106
88
  }
107
89
  }, {
108
90
  key: "encodeNode",
109
91
  value: function encodeNode(node) {
110
92
  var _this$schema$nodes = this.schema.nodes,
111
- blockquote = _this$schema$nodes.blockquote,
112
- bulletList = _this$schema$nodes.bulletList,
113
- codeBlock = _this$schema$nodes.codeBlock,
114
- hardBreak = _this$schema$nodes.hardBreak,
115
- heading = _this$schema$nodes.heading,
116
- listItem = _this$schema$nodes.listItem,
117
- mention = _this$schema$nodes.mention,
118
- emoji = _this$schema$nodes.emoji,
119
- orderedList = _this$schema$nodes.orderedList,
120
- paragraph = _this$schema$nodes.paragraph,
121
- rule = _this$schema$nodes.rule,
122
- mediaInline = _this$schema$nodes.mediaInline,
123
- mediaGroup = _this$schema$nodes.mediaGroup,
124
- mediaSingle = _this$schema$nodes.mediaSingle,
125
- media = _this$schema$nodes.media,
126
- table = _this$schema$nodes.table; // We compare node type names in this method rather than
93
+ blockquote = _this$schema$nodes.blockquote,
94
+ bulletList = _this$schema$nodes.bulletList,
95
+ codeBlock = _this$schema$nodes.codeBlock,
96
+ hardBreak = _this$schema$nodes.hardBreak,
97
+ heading = _this$schema$nodes.heading,
98
+ listItem = _this$schema$nodes.listItem,
99
+ mention = _this$schema$nodes.mention,
100
+ emoji = _this$schema$nodes.emoji,
101
+ orderedList = _this$schema$nodes.orderedList,
102
+ paragraph = _this$schema$nodes.paragraph,
103
+ rule = _this$schema$nodes.rule,
104
+ mediaInline = _this$schema$nodes.mediaInline,
105
+ mediaGroup = _this$schema$nodes.mediaGroup,
106
+ mediaSingle = _this$schema$nodes.mediaSingle,
107
+ media = _this$schema$nodes.media,
108
+ table = _this$schema$nodes.table;
109
+
110
+ // We compare node type names in this method rather than
127
111
  // node types directly as the node comparision fails.
112
+
128
113
  // This suggests the schema which is coming from
129
114
  // the doc has been recreated after being passed
130
115
  // to this transformer on setup which is somewhat
131
116
  // unexpected.
117
+
132
118
  // This package is internally (within editor) considered
133
119
  // "obsolete", and we are aiming to either hand over
134
120
  // or deprecate.
121
+
135
122
  // This "fix" is being done to unblock an existing
136
123
  // consumer so they can apply an unrelated security
137
124
  // upgrade.
138
-
139
125
  if (node.isText) {
140
126
  return this.encodeText(node);
141
127
  } else if (node.type.name === heading.name) {
@@ -147,7 +133,6 @@ var JIRATransformer = /*#__PURE__*/function () {
147
133
  } else if (node.type.name === hardBreak.name) {
148
134
  return this.encodeHardBreak();
149
135
  }
150
-
151
136
  if ((0, _schemaJira.isSchemaWithLists)(this.schema)) {
152
137
  if (node.type.name === bulletList.name) {
153
138
  return this.encodeBulletList(node);
@@ -157,23 +142,18 @@ var JIRATransformer = /*#__PURE__*/function () {
157
142
  return this.encodeListItem(node);
158
143
  }
159
144
  }
160
-
161
145
  if ((0, _schemaJira.isSchemaWithMentions)(this.schema) && node.type.name === mention.name) {
162
146
  return this.encodeMention(node, this.customEncoders.mention);
163
147
  }
164
-
165
148
  if ((0, _schemaJira.isSchemaWithEmojis)(this.schema) && node.type.name === emoji.name) {
166
149
  return this.encodeEmoji(node);
167
150
  }
168
-
169
151
  if ((0, _schemaJira.isSchemaWithCodeBlock)(this.schema) && node.type.name === codeBlock.name) {
170
152
  return this.encodeCodeBlock(node);
171
153
  }
172
-
173
154
  if ((0, _schemaJira.isSchemaWithBlockQuotes)(this.schema) && node.type.name === blockquote.name) {
174
155
  return this.encodeBlockQuote(node);
175
156
  }
176
-
177
157
  if ((0, _schemaJira.isSchemaWithMedia)(this.schema)) {
178
158
  if (node.type.name === mediaGroup.name) {
179
159
  return this.encodeMediaGroup(node);
@@ -183,11 +163,9 @@ var JIRATransformer = /*#__PURE__*/function () {
183
163
  return this.encodeMedia(node);
184
164
  }
185
165
  }
186
-
187
166
  if ((0, _schemaJira.isSchemaWithTables)(this.schema) && node.type.name === table.name) {
188
167
  return this.encodeTable(node);
189
168
  }
190
-
191
169
  throw new Error("Unexpected node '".concat(node.type.name, "' for HTML encoding"));
192
170
  }
193
171
  }, {
@@ -202,7 +180,6 @@ var JIRATransformer = /*#__PURE__*/function () {
202
180
  key: "encodeFragment",
203
181
  value: function encodeFragment(fragment) {
204
182
  var _this = this;
205
-
206
183
  var documentFragment = this.doc.createDocumentFragment();
207
184
  fragment.forEach(function (node) {
208
185
  return documentFragment.appendChild(_this.encodeNode(node));
@@ -220,9 +197,8 @@ var JIRATransformer = /*#__PURE__*/function () {
220
197
  });
221
198
  return specialsEncoded;
222
199
  }
223
-
224
- var level = node.attrs.level; // @see ED-4708
225
-
200
+ var level = node.attrs.level;
201
+ // @see ED-4708
226
202
  var elem = this.doc.createElement("h".concat(level === 6 ? 5 : level));
227
203
  var anchor = this.doc.createElement('a');
228
204
  anchor.setAttribute('name', anchorNameEncode(node.textContent));
@@ -244,76 +220,61 @@ var JIRATransformer = /*#__PURE__*/function () {
244
220
  var root = this.doc.createDocumentFragment();
245
221
  var elem = root;
246
222
  var _this$schema$marks = this.schema.marks,
247
- code = _this$schema$marks.code,
248
- em = _this$schema$marks.em,
249
- link = _this$schema$marks.link,
250
- typeAheadQuery = _this$schema$marks.typeAheadQuery,
251
- strike = _this$schema$marks.strike,
252
- strong = _this$schema$marks.strong,
253
- subsup = _this$schema$marks.subsup,
254
- underline = _this$schema$marks.underline,
255
- textColor = _this$schema$marks.textColor;
256
-
223
+ code = _this$schema$marks.code,
224
+ em = _this$schema$marks.em,
225
+ link = _this$schema$marks.link,
226
+ typeAheadQuery = _this$schema$marks.typeAheadQuery,
227
+ strike = _this$schema$marks.strike,
228
+ strong = _this$schema$marks.strong,
229
+ subsup = _this$schema$marks.subsup,
230
+ underline = _this$schema$marks.underline,
231
+ textColor = _this$schema$marks.textColor;
257
232
  var _iterator = _createForOfIteratorHelper(node.marks),
258
- _step;
259
-
233
+ _step;
260
234
  try {
261
235
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
262
236
  var mark = _step.value;
263
-
264
237
  switch (mark.type) {
265
238
  case strong:
266
239
  elem = elem.appendChild(this.doc.createElement('b'));
267
240
  break;
268
-
269
241
  case em:
270
242
  elem = elem.appendChild(this.doc.createElement('em'));
271
243
  break;
272
-
273
244
  case code:
274
245
  elem = elem.appendChild(this.doc.createElement('tt'));
275
246
  break;
276
-
277
247
  case strike:
278
248
  elem = elem.appendChild(this.doc.createElement('del'));
279
249
  break;
280
-
281
250
  case underline:
282
251
  elem = elem.appendChild(this.doc.createElement('ins'));
283
252
  break;
284
-
285
253
  case subsup:
286
254
  elem = elem.appendChild(this.doc.createElement(mark.attrs['type']));
287
255
  break;
288
-
289
256
  case link:
290
257
  var linkElem = this.doc.createElement('a');
291
258
  var href = mark.attrs['href'];
292
- /** JIRA always expects external-link attribute set on links created via editor unless its #fragment */
293
259
 
260
+ /** JIRA always expects external-link attribute set on links created via editor unless its #fragment */
294
261
  if (!href.match(/^#/)) {
295
262
  linkElem.setAttribute('class', 'external-link');
296
263
  linkElem.setAttribute('rel', 'nofollow');
297
264
  }
298
-
299
265
  linkElem.setAttribute('href', href);
300
-
301
266
  if (mark.attrs['title']) {
302
267
  linkElem.setAttribute('title', mark.attrs['title']);
303
268
  }
304
-
305
269
  elem = elem.appendChild(linkElem);
306
270
  break;
307
-
308
271
  case textColor:
309
272
  var fontElem = this.doc.createElement('font');
310
273
  fontElem.setAttribute('color', mark.attrs['color']);
311
274
  elem = elem.appendChild(fontElem);
312
275
  break;
313
-
314
276
  case typeAheadQuery:
315
277
  break;
316
-
317
278
  default:
318
279
  throw new Error("Unable to encode mark '".concat(mark.type.name, "'"));
319
280
  }
@@ -323,7 +284,6 @@ var JIRATransformer = /*#__PURE__*/function () {
323
284
  } finally {
324
285
  _iterator.f();
325
286
  }
326
-
327
287
  elem.textContent = node.text;
328
288
  return root;
329
289
  } else {
@@ -347,11 +307,9 @@ var JIRATransformer = /*#__PURE__*/function () {
347
307
  elem.setAttribute('class', 'alternate');
348
308
  elem.setAttribute('type', 'disc');
349
309
  elem.appendChild(this.encodeFragment(node.content));
350
-
351
310
  for (var index = 0; index < elem.childElementCount; index++) {
352
311
  elem.children[index].setAttribute('data-parent', 'ul');
353
312
  }
354
-
355
313
  return elem;
356
314
  }
357
315
  }, {
@@ -359,40 +317,34 @@ var JIRATransformer = /*#__PURE__*/function () {
359
317
  value: function encodeOrderedList(node) {
360
318
  var elem = this.doc.createElement('ol');
361
319
  elem.appendChild(this.encodeFragment(node.content));
362
-
363
320
  for (var index = 0; index < elem.childElementCount; index++) {
364
321
  elem.children[index].setAttribute('data-parent', 'ol');
365
322
  }
366
-
367
323
  return elem;
368
324
  }
369
325
  }, {
370
326
  key: "encodeListItem",
371
327
  value: function encodeListItem(node) {
372
328
  var _this2 = this;
373
-
374
329
  var elem = this.doc.createElement('li');
375
-
376
330
  if (node.content.childCount) {
377
331
  var hasBlocks = false;
378
332
  node.content.forEach(function (childNode) {
379
333
  if (childNode.type === _this2.schema.nodes.bulletList || childNode.type === _this2.schema.nodes.orderedList) {
380
334
  var list = _this2.encodeNode(childNode);
335
+
381
336
  /**
382
337
  * Changing type for nested list:
383
338
  *
384
339
  * Second level -> circle
385
340
  * Third and deeper -> square
386
341
  */
387
-
388
-
389
342
  if (list instanceof HTMLElement && list.tagName === 'UL') {
390
343
  list.setAttribute('type', 'circle');
391
344
  [].forEach.call(list.querySelectorAll('ul'), function (ul) {
392
345
  ul.setAttribute('type', 'square');
393
346
  });
394
347
  }
395
-
396
348
  elem.appendChild(list);
397
349
  } else if (childNode.type.name === 'paragraph' && !hasBlocks) {
398
350
  // Strip the paragraph node from the list item.
@@ -401,12 +353,10 @@ var JIRATransformer = /*#__PURE__*/function () {
401
353
  if (childNode.isBlock) {
402
354
  hasBlocks = true;
403
355
  }
404
-
405
356
  elem.appendChild(_this2.encodeNode(childNode));
406
357
  }
407
358
  });
408
359
  }
409
-
410
360
  return elem;
411
361
  }
412
362
  }, {
@@ -431,8 +381,8 @@ var JIRATransformer = /*#__PURE__*/function () {
431
381
  elem.setAttribute('class', 'code panel');
432
382
  var content = this.doc.createElement('div');
433
383
  content.setAttribute('class', 'codeContent panelContent');
434
- var pre = this.doc.createElement('pre'); // java is default language for JIRA
435
-
384
+ var pre = this.doc.createElement('pre');
385
+ // java is default language for JIRA
436
386
  pre.setAttribute('class', "code-".concat((node.attrs.language || 'plain').toLocaleLowerCase()));
437
387
  pre.appendChild(this.encodeFragment(node.content));
438
388
  content.appendChild(pre);
@@ -467,31 +417,26 @@ var JIRATransformer = /*#__PURE__*/function () {
467
417
  value: function addDataToNode(domNode, mediaNode) {
468
418
  var defaultDisplayType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'thumbnail';
469
419
  var _mediaNode$attrs = mediaNode.attrs,
470
- id = _mediaNode$attrs.id,
471
- type = _mediaNode$attrs.type,
472
- collection = _mediaNode$attrs.collection,
473
- __fileName = _mediaNode$attrs.__fileName,
474
- __displayType = _mediaNode$attrs.__displayType,
475
- width = _mediaNode$attrs.width,
476
- height = _mediaNode$attrs.height; // Order of dataset matters in IE Edge, please keep the current order
477
-
420
+ id = _mediaNode$attrs.id,
421
+ type = _mediaNode$attrs.type,
422
+ collection = _mediaNode$attrs.collection,
423
+ __fileName = _mediaNode$attrs.__fileName,
424
+ __displayType = _mediaNode$attrs.__displayType,
425
+ width = _mediaNode$attrs.width,
426
+ height = _mediaNode$attrs.height;
427
+ // Order of dataset matters in IE Edge, please keep the current order
478
428
  domNode.setAttribute('data-attachment-type', __displayType || defaultDisplayType);
479
-
480
429
  if (__fileName) {
481
430
  domNode.setAttribute('data-attachment-name', __fileName);
482
431
  }
483
-
484
432
  if (width) {
485
433
  domNode.setAttribute('data-width', width);
486
434
  }
487
-
488
435
  if (height) {
489
436
  domNode.setAttribute('data-height', height);
490
437
  }
491
-
492
438
  domNode.setAttribute('data-media-services-type', type);
493
439
  domNode.setAttribute('data-media-services-id', id);
494
-
495
440
  if (collection) {
496
441
  domNode.setAttribute('data-media-services-collection', collection);
497
442
  }
@@ -500,9 +445,9 @@ var JIRATransformer = /*#__PURE__*/function () {
500
445
  key: "buildURLWithContextInfo",
501
446
  value: function buildURLWithContextInfo(fileId, contextInfo) {
502
447
  var clientId = contextInfo.clientId,
503
- baseUrl = contextInfo.baseUrl,
504
- token = contextInfo.token,
505
- collection = contextInfo.collection;
448
+ baseUrl = contextInfo.baseUrl,
449
+ token = contextInfo.token,
450
+ collection = contextInfo.collection;
506
451
  return "".concat(baseUrl, "/file/").concat(fileId, "/image?token=").concat(token, "&client=").concat(clientId, "&collection=").concat(collection, "&width=200&height=200&mode=fit");
507
452
  }
508
453
  }, {
@@ -517,7 +462,6 @@ var JIRATransformer = /*#__PURE__*/function () {
517
462
  // span.no-br > a[data-media] > content
518
463
  var elem = this.doc.createElement('span');
519
464
  var a = this.doc.createElement('a');
520
-
521
465
  if (node.attrs.__displayType === 'file' || !(node.attrs.__displayType || this.isImageMimeType(node.attrs.__fileMimeType))) {
522
466
  elem.setAttribute('class', 'nobr');
523
467
  this.addDataToNode(a, node, 'file');
@@ -525,20 +469,18 @@ var JIRATransformer = /*#__PURE__*/function () {
525
469
  } else {
526
470
  elem.setAttribute('class', 'image-wrap');
527
471
  var img = this.doc.createElement('img');
528
- img.setAttribute('alt', node.attrs.__fileName); // Newly uploaded items have collection
529
-
472
+ img.setAttribute('alt', node.attrs.__fileName);
473
+ // Newly uploaded items have collection
530
474
  if (node.attrs.collection && this.mediaContextInfo && this.mediaContextInfo.uploadContext) {
531
475
  img.setAttribute('src', this.buildURLWithContextInfo(node.attrs.id, this.mediaContextInfo.uploadContext));
532
476
  } else if (this.mediaContextInfo && this.mediaContextInfo.viewContext) {
533
477
  img.setAttribute('src', this.buildURLWithContextInfo(node.attrs.id, this.mediaContextInfo.viewContext));
534
478
  }
535
-
536
479
  this.addDataToNode(img, node);
537
480
  var jiraThumb = this.doc.createElement('jira-attachment-thumbnail');
538
481
  jiraThumb.appendChild(img);
539
482
  a.appendChild(jiraThumb);
540
483
  }
541
-
542
484
  elem.appendChild(a);
543
485
  return elem;
544
486
  }
@@ -546,17 +488,13 @@ var JIRATransformer = /*#__PURE__*/function () {
546
488
  key: "encodeTable",
547
489
  value: function encodeTable(node) {
548
490
  var _this3 = this;
549
-
550
491
  var elem = this.doc.createElement('table');
551
492
  var tbody = this.doc.createElement('tbody');
552
493
  node.descendants(function (rowNode) {
553
494
  var rowElement = _this3.doc.createElement('tr');
554
-
555
495
  rowNode.descendants(function (colNode) {
556
496
  var cellType = colNode.type === _this3.schema.nodes.tableCell ? 'd' : 'h';
557
-
558
497
  var cellElement = _this3.doc.createElement("t".concat(cellType));
559
-
560
498
  cellElement.setAttribute('class', "confluenceT".concat(cellType));
561
499
  cellElement.appendChild(_this3.encodeFragment(colNode.content));
562
500
  rowElement.appendChild(cellElement);
@@ -572,5 +510,4 @@ var JIRATransformer = /*#__PURE__*/function () {
572
510
  }]);
573
511
  return JIRATransformer;
574
512
  }();
575
-
576
513
  exports.JIRATransformer = JIRATransformer;