@atlaskit/editor-wikimarkup-transformer 11.1.2 → 11.1.4

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,17 @@
1
1
  # @atlaskit/editor-wikimarkup-transformer
2
2
 
3
+ ## 11.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [`49280fb073e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/49280fb073e) - Removing Array.at usage to support older browsers.
8
+
9
+ ## 11.1.3
10
+
11
+ ### Patch Changes
12
+
13
+ - [`916af279b4d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/916af279b4d) - added validation to handle strong mark under list
14
+
3
15
  ## 11.1.2
4
16
 
5
17
  ### Patch Changes
package/char/package.json CHANGED
@@ -4,5 +4,12 @@
4
4
  "module": "../dist/esm/char.js",
5
5
  "module:es2019": "../dist/es2019/char.js",
6
6
  "sideEffects": false,
7
- "types": "../dist/types/char.d.ts"
7
+ "types": "../dist/types/char.d.ts",
8
+ "typesVersions": {
9
+ ">=4.0 <4.3": {
10
+ "*": [
11
+ "../dist/types-ts4.0/char.d.ts"
12
+ ]
13
+ }
14
+ }
8
15
  }
@@ -128,7 +128,7 @@ function parseString(_ref) {
128
128
  var _inlineNodes2;
129
129
 
130
130
  /*ESS-2539 We are keeping track of consecutive newLines in the newLines array
131
- Whenever more than two consecutive newLines are encountered, we start a new paragraph
131
+ Whenever more than two consecutive newLines are encountered, we start a new paragraph
132
132
  */
133
133
  if (newLines.length >= 2 && (tokenType !== _tokenize.TokenType.HARD_BREAK || buffer.length > 0)) {
134
134
  output.push.apply(output, (0, _toConsumableArray2.default)((0, _normalize.normalizePMNodes)(inlineNodes, schema))); // push newLines to the buffer as a separator between media nodes
@@ -219,24 +219,24 @@ function parseString(_ref) {
219
219
 
220
220
  return [].concat(output, (0, _toConsumableArray2.default)(inlineNodes));
221
221
  }
222
- /* checks whether a newLine is required between two consecutive nodes
223
- Returns true for inline nodes, false for block nodes
222
+ /* checks whether a newLine is required between two consecutive nodes
223
+ Returns true for inline nodes, false for block nodes
224
224
  */
225
225
 
226
226
 
227
227
  function isNewLineRequiredBetweenNodes(currentNodes, buffer, nextNodes) {
228
- var _currentNodes$at;
228
+ var _currentNodes;
229
229
 
230
230
  if (currentNodes.length === 0) {
231
231
  return false;
232
232
  }
233
233
 
234
- if (buffer.length > 0 && (_currentNodes$at = currentNodes.at(-1)) !== null && _currentNodes$at !== void 0 && _currentNodes$at.isBlock) {
234
+ if (buffer.length > 0 && (_currentNodes = currentNodes[currentNodes.length - 1]) !== null && _currentNodes !== void 0 && _currentNodes.isBlock) {
235
235
  return false;
236
236
  }
237
237
 
238
238
  if (buffer.length === 0) {
239
- var _nextNodes$, _nextNodes$2, _currentNodes$at2;
239
+ var _nextNodes$, _nextNodes$2, _currentNodes2;
240
240
 
241
241
  if (nextNodes.length === 0) {
242
242
  return false;
@@ -246,7 +246,7 @@ function isNewLineRequiredBetweenNodes(currentNodes, buffer, nextNodes) {
246
246
  return false;
247
247
  }
248
248
 
249
- if ((_nextNodes$2 = nextNodes[0]) !== null && _nextNodes$2 !== void 0 && _nextNodes$2.isBlock || (_currentNodes$at2 = currentNodes.at(-1)) !== null && _currentNodes$at2 !== void 0 && _currentNodes$at2.isBlock) {
249
+ if ((_nextNodes$2 = nextNodes[0]) !== null && _nextNodes$2 !== void 0 && _nextNodes$2.isBlock || (_currentNodes2 = currentNodes[currentNodes.length - 1]) !== null && _currentNodes2 !== void 0 && _currentNodes2.isBlock) {
250
250
  return false;
251
251
  }
252
252
  }
@@ -255,7 +255,7 @@ function isNewLineRequiredBetweenNodes(currentNodes, buffer, nextNodes) {
255
255
  }
256
256
 
257
257
  function isConsecutiveMediaGroups(currentNodes, nextNodes) {
258
- var _currentNodes$at3, _nextNodes$3;
258
+ var _currentNodes3, _nextNodes$3;
259
259
 
260
- return currentNodes.length > 0 && ((_currentNodes$at3 = currentNodes.at(-1)) === null || _currentNodes$at3 === void 0 ? void 0 : _currentNodes$at3.type.name) === 'mediaGroup' && ((_nextNodes$3 = nextNodes[0]) === null || _nextNodes$3 === void 0 ? void 0 : _nextNodes$3.type.name) === 'mediaGroup';
260
+ return currentNodes.length > 0 && ((_currentNodes3 = currentNodes[currentNodes.length - 1]) === null || _currentNodes3 === void 0 ? void 0 : _currentNodes3.type.name) === 'mediaGroup' && ((_nextNodes$3 = nextNodes[0]) === null || _nextNodes$3 === void 0 ? void 0 : _nextNodes$3.type.name) === 'mediaGroup';
261
261
  }
@@ -23,6 +23,8 @@ var _ = require("./");
23
23
 
24
24
  var _whitespace = require("./whitespace");
25
25
 
26
+ var _text2 = require("../utils/text");
27
+
26
28
  var MAX_LIST_DEPTH = 20;
27
29
  exports.MAX_LIST_DEPTH = MAX_LIST_DEPTH;
28
30
  var LIST_ITEM_REGEXP = new RegExp("^ *([*\\-#]{1,".concat(MAX_LIST_DEPTH, "}) "));
@@ -312,7 +314,11 @@ function sanitize(nodes, schema) {
312
314
  n.text = n.text.toUpperCase();
313
315
  }
314
316
 
315
- contentBuffer.push(n.mark([].concat((0, _toConsumableArray2.default)(n.marks), [mark])));
317
+ if (n.type.name === 'text' && !(0, _text2.hasAnyOfMarks)(n, ['strong', 'code'])) {
318
+ contentBuffer.push(n.mark([].concat((0, _toConsumableArray2.default)(n.marks), [mark])));
319
+ } else {
320
+ contentBuffer.push(n);
321
+ }
316
322
  } else {
317
323
  contentBuffer.push(n);
318
324
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-wikimarkup-transformer",
3
- "version": "11.1.2",
3
+ "version": "11.1.4",
4
4
  "sideEffects": false
5
5
  }
@@ -106,7 +106,7 @@ export function parseString({
106
106
  buffer.push(token.text);
107
107
  } else if (token.type === 'pmnode') {
108
108
  /*ESS-2539 We are keeping track of consecutive newLines in the newLines array
109
- Whenever more than two consecutive newLines are encountered, we start a new paragraph
109
+ Whenever more than two consecutive newLines are encountered, we start a new paragraph
110
110
  */
111
111
  if (newLines.length >= 2 && (tokenType !== TokenType.HARD_BREAK || buffer.length > 0)) {
112
112
  output.push(...normalizePMNodes(inlineNodes, schema)); // push newLines to the buffer as a separator between media nodes
@@ -185,23 +185,23 @@ export function parseString({
185
185
 
186
186
  return [...output, ...inlineNodes];
187
187
  }
188
- /* checks whether a newLine is required between two consecutive nodes
189
- Returns true for inline nodes, false for block nodes
188
+ /* checks whether a newLine is required between two consecutive nodes
189
+ Returns true for inline nodes, false for block nodes
190
190
  */
191
191
 
192
192
  function isNewLineRequiredBetweenNodes(currentNodes, buffer, nextNodes) {
193
- var _currentNodes$at;
193
+ var _currentNodes;
194
194
 
195
195
  if (currentNodes.length === 0) {
196
196
  return false;
197
197
  }
198
198
 
199
- if (buffer.length > 0 && (_currentNodes$at = currentNodes.at(-1)) !== null && _currentNodes$at !== void 0 && _currentNodes$at.isBlock) {
199
+ if (buffer.length > 0 && (_currentNodes = currentNodes[currentNodes.length - 1]) !== null && _currentNodes !== void 0 && _currentNodes.isBlock) {
200
200
  return false;
201
201
  }
202
202
 
203
203
  if (buffer.length === 0) {
204
- var _nextNodes$, _nextNodes$2, _currentNodes$at2;
204
+ var _nextNodes$, _nextNodes$2, _currentNodes2;
205
205
 
206
206
  if (nextNodes.length === 0) {
207
207
  return false;
@@ -211,7 +211,7 @@ function isNewLineRequiredBetweenNodes(currentNodes, buffer, nextNodes) {
211
211
  return false;
212
212
  }
213
213
 
214
- if ((_nextNodes$2 = nextNodes[0]) !== null && _nextNodes$2 !== void 0 && _nextNodes$2.isBlock || (_currentNodes$at2 = currentNodes.at(-1)) !== null && _currentNodes$at2 !== void 0 && _currentNodes$at2.isBlock) {
214
+ if ((_nextNodes$2 = nextNodes[0]) !== null && _nextNodes$2 !== void 0 && _nextNodes$2.isBlock || (_currentNodes2 = currentNodes[currentNodes.length - 1]) !== null && _currentNodes2 !== void 0 && _currentNodes2.isBlock) {
215
215
  return false;
216
216
  }
217
217
  }
@@ -220,7 +220,7 @@ function isNewLineRequiredBetweenNodes(currentNodes, buffer, nextNodes) {
220
220
  }
221
221
 
222
222
  function isConsecutiveMediaGroups(currentNodes, nextNodes) {
223
- var _currentNodes$at3, _nextNodes$3;
223
+ var _currentNodes3, _nextNodes$3;
224
224
 
225
- return currentNodes.length > 0 && ((_currentNodes$at3 = currentNodes.at(-1)) === null || _currentNodes$at3 === void 0 ? void 0 : _currentNodes$at3.type.name) === 'mediaGroup' && ((_nextNodes$3 = nextNodes[0]) === null || _nextNodes$3 === void 0 ? void 0 : _nextNodes$3.type.name) === 'mediaGroup';
225
+ return currentNodes.length > 0 && ((_currentNodes3 = currentNodes[currentNodes.length - 1]) === null || _currentNodes3 === void 0 ? void 0 : _currentNodes3.type.name) === 'mediaGroup' && ((_nextNodes$3 = nextNodes[0]) === null || _nextNodes$3 === void 0 ? void 0 : _nextNodes$3.type.name) === 'mediaGroup';
226
226
  }
@@ -4,6 +4,7 @@ import { normalizePMNodes } from '../utils/normalize';
4
4
  import { parseMacroKeyword } from './keyword';
5
5
  import { TokenType, parseToken } from './';
6
6
  import { parseNewlineOnly } from './whitespace';
7
+ import { hasAnyOfMarks } from '../utils/text';
7
8
  export const MAX_LIST_DEPTH = 20;
8
9
  const LIST_ITEM_REGEXP = new RegExp(`^ *([*\\-#]{1,${MAX_LIST_DEPTH}}) `);
9
10
  const EMPTY_LINE_REGEXP = /^[ \t]*\r?\n/;
@@ -269,7 +270,11 @@ function sanitize(nodes, schema) {
269
270
  n.text = n.text.toUpperCase();
270
271
  }
271
272
 
272
- contentBuffer.push(n.mark([...n.marks, mark]));
273
+ if (n.type.name === 'text' && !hasAnyOfMarks(n, ['strong', 'code'])) {
274
+ contentBuffer.push(n.mark([...n.marks, mark]));
275
+ } else {
276
+ contentBuffer.push(n);
277
+ }
273
278
  } else {
274
279
  contentBuffer.push(n);
275
280
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-wikimarkup-transformer",
3
- "version": "11.1.2",
3
+ "version": "11.1.4",
4
4
  "sideEffects": false
5
5
  }
@@ -111,7 +111,7 @@ export function parseString(_ref) {
111
111
  var _inlineNodes2;
112
112
 
113
113
  /*ESS-2539 We are keeping track of consecutive newLines in the newLines array
114
- Whenever more than two consecutive newLines are encountered, we start a new paragraph
114
+ Whenever more than two consecutive newLines are encountered, we start a new paragraph
115
115
  */
116
116
  if (newLines.length >= 2 && (tokenType !== TokenType.HARD_BREAK || buffer.length > 0)) {
117
117
  output.push.apply(output, _toConsumableArray(normalizePMNodes(inlineNodes, schema))); // push newLines to the buffer as a separator between media nodes
@@ -202,23 +202,23 @@ export function parseString(_ref) {
202
202
 
203
203
  return [].concat(output, _toConsumableArray(inlineNodes));
204
204
  }
205
- /* checks whether a newLine is required between two consecutive nodes
206
- Returns true for inline nodes, false for block nodes
205
+ /* checks whether a newLine is required between two consecutive nodes
206
+ Returns true for inline nodes, false for block nodes
207
207
  */
208
208
 
209
209
  function isNewLineRequiredBetweenNodes(currentNodes, buffer, nextNodes) {
210
- var _currentNodes$at;
210
+ var _currentNodes;
211
211
 
212
212
  if (currentNodes.length === 0) {
213
213
  return false;
214
214
  }
215
215
 
216
- if (buffer.length > 0 && (_currentNodes$at = currentNodes.at(-1)) !== null && _currentNodes$at !== void 0 && _currentNodes$at.isBlock) {
216
+ if (buffer.length > 0 && (_currentNodes = currentNodes[currentNodes.length - 1]) !== null && _currentNodes !== void 0 && _currentNodes.isBlock) {
217
217
  return false;
218
218
  }
219
219
 
220
220
  if (buffer.length === 0) {
221
- var _nextNodes$, _nextNodes$2, _currentNodes$at2;
221
+ var _nextNodes$, _nextNodes$2, _currentNodes2;
222
222
 
223
223
  if (nextNodes.length === 0) {
224
224
  return false;
@@ -228,7 +228,7 @@ function isNewLineRequiredBetweenNodes(currentNodes, buffer, nextNodes) {
228
228
  return false;
229
229
  }
230
230
 
231
- if ((_nextNodes$2 = nextNodes[0]) !== null && _nextNodes$2 !== void 0 && _nextNodes$2.isBlock || (_currentNodes$at2 = currentNodes.at(-1)) !== null && _currentNodes$at2 !== void 0 && _currentNodes$at2.isBlock) {
231
+ if ((_nextNodes$2 = nextNodes[0]) !== null && _nextNodes$2 !== void 0 && _nextNodes$2.isBlock || (_currentNodes2 = currentNodes[currentNodes.length - 1]) !== null && _currentNodes2 !== void 0 && _currentNodes2.isBlock) {
232
232
  return false;
233
233
  }
234
234
  }
@@ -237,7 +237,7 @@ function isNewLineRequiredBetweenNodes(currentNodes, buffer, nextNodes) {
237
237
  }
238
238
 
239
239
  function isConsecutiveMediaGroups(currentNodes, nextNodes) {
240
- var _currentNodes$at3, _nextNodes$3;
240
+ var _currentNodes3, _nextNodes$3;
241
241
 
242
- return currentNodes.length > 0 && ((_currentNodes$at3 = currentNodes.at(-1)) === null || _currentNodes$at3 === void 0 ? void 0 : _currentNodes$at3.type.name) === 'mediaGroup' && ((_nextNodes$3 = nextNodes[0]) === null || _nextNodes$3 === void 0 ? void 0 : _nextNodes$3.type.name) === 'mediaGroup';
242
+ return currentNodes.length > 0 && ((_currentNodes3 = currentNodes[currentNodes.length - 1]) === null || _currentNodes3 === void 0 ? void 0 : _currentNodes3.type.name) === 'mediaGroup' && ((_nextNodes$3 = nextNodes[0]) === null || _nextNodes$3 === void 0 ? void 0 : _nextNodes$3.type.name) === 'mediaGroup';
243
243
  }
@@ -6,6 +6,7 @@ import { normalizePMNodes } from '../utils/normalize';
6
6
  import { parseMacroKeyword } from './keyword';
7
7
  import { TokenType, parseToken } from './';
8
8
  import { parseNewlineOnly } from './whitespace';
9
+ import { hasAnyOfMarks } from '../utils/text';
9
10
  export var MAX_LIST_DEPTH = 20;
10
11
  var LIST_ITEM_REGEXP = new RegExp("^ *([*\\-#]{1,".concat(MAX_LIST_DEPTH, "}) "));
11
12
  var EMPTY_LINE_REGEXP = /^[ \t]*\r?\n/;
@@ -291,7 +292,11 @@ function sanitize(nodes, schema) {
291
292
  n.text = n.text.toUpperCase();
292
293
  }
293
294
 
294
- contentBuffer.push(n.mark([].concat(_toConsumableArray(n.marks), [mark])));
295
+ if (n.type.name === 'text' && !hasAnyOfMarks(n, ['strong', 'code'])) {
296
+ contentBuffer.push(n.mark([].concat(_toConsumableArray(n.marks), [mark])));
297
+ } else {
298
+ contentBuffer.push(n);
299
+ }
295
300
  } else {
296
301
  contentBuffer.push(n);
297
302
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-wikimarkup-transformer",
3
- "version": "11.1.2",
3
+ "version": "11.1.4",
4
4
  "sideEffects": false
5
5
  }
@@ -4,5 +4,12 @@
4
4
  "module": "../dist/esm/interfaces.js",
5
5
  "module:es2019": "../dist/es2019/interfaces.js",
6
6
  "sideEffects": false,
7
- "types": "../dist/types/interfaces.d.ts"
7
+ "types": "../dist/types/interfaces.d.ts",
8
+ "typesVersions": {
9
+ ">=4.0 <4.3": {
10
+ "*": [
11
+ "../dist/types-ts4.0/interfaces.d.ts"
12
+ ]
13
+ }
14
+ }
8
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-wikimarkup-transformer",
3
- "version": "11.1.2",
3
+ "version": "11.1.4",
4
4
  "description": "Wiki markup transformer for JIRA and Confluence",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -33,11 +33,11 @@
33
33
  "devDependencies": {
34
34
  "@atlaskit/activity": "^1.0.1",
35
35
  "@atlaskit/docs": "*",
36
- "@atlaskit/editor-common": "^69.2.0",
37
- "@atlaskit/editor-core": "^172.1.0",
36
+ "@atlaskit/editor-common": "^69.3.0",
37
+ "@atlaskit/editor-core": "^172.2.0",
38
38
  "@atlaskit/editor-test-helpers": "^17.1.0",
39
39
  "@atlaskit/mention": "^21.0.0",
40
- "@atlaskit/profilecard": "^16.12.0",
40
+ "@atlaskit/profilecard": "^17.2.0",
41
41
  "@atlaskit/renderer": "^101.1.0",
42
42
  "@atlaskit/util-data-test": "^17.5.0",
43
43
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
package/report.api.md CHANGED
@@ -1,6 +1,10 @@
1
- ## API Report File for "@atlaskit/editor-wikimarkup-transformer".
1
+ ## API Report File for "@atlaskit/editor-wikimarkup-transformer"
2
2
 
3
- > Do not edit this file. This report is auto-generated by [API Extractor](https://api-extractor.com/).
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ <!--
6
+ Generated API Report version: 2.0
7
+ -->
4
8
 
5
9
  [Learn more about API reports](https://hello.atlassian.net/wiki/spaces/UR/pages/1825484529/Package+API+Reports)
6
10
 
@@ -8,55 +12,69 @@
8
12
  import { Node as Node_2 } from 'prosemirror-model';
9
13
  import { Schema } from 'prosemirror-model';
10
14
 
11
- declare interface Context {
12
- readonly issueKeyRegex?: RegExp | undefined;
13
- readonly tokenErrCallback?: TokenErrCallback;
15
+ // @public (undocumented)
16
+ interface Context {
17
+ // (undocumented)
14
18
  readonly conversion?: {
15
19
  readonly inlineCardConversion?: ConversionMap;
16
20
  readonly mediaConversion?: MediaConversionMap;
17
21
  mentionConversion?: ConversionMap;
18
22
  };
19
- readonly hydration?: {
20
- readonly media?: {
21
- targetCollectionId?: string;
22
- };
23
- };
23
+ // (undocumented)
24
24
  readonly defaults?: {
25
25
  readonly media?: {
26
26
  width: number | null;
27
27
  height: number | null;
28
28
  };
29
29
  };
30
+ // (undocumented)
31
+ readonly hydration?: {
32
+ readonly media?: {
33
+ targetCollectionId?: string;
34
+ };
35
+ };
36
+ // (undocumented)
37
+ readonly issueKeyRegex?: RegExp | undefined;
38
+ // (undocumented)
39
+ readonly tokenErrCallback?: TokenErrCallback;
30
40
  }
31
41
 
32
- declare interface ConversionMap {
42
+ // @public (undocumented)
43
+ interface ConversionMap {
44
+ // (undocumented)
33
45
  [key: string]: string;
34
46
  }
35
47
 
36
- declare interface MediaConversionMap {
48
+ // @public (undocumented)
49
+ interface MediaConversionMap {
50
+ // (undocumented)
37
51
  [key: string]: {
38
52
  transform?: string;
39
53
  embed?: boolean;
40
54
  };
41
55
  }
42
56
 
43
- declare type TokenErrCallback = (err: Error, tokenType: string) => void;
57
+ // @public (undocumented)
58
+ type TokenErrCallback = (err: Error, tokenType: string) => void;
44
59
 
45
- declare interface Transformer_2<T> {
60
+ // @public (undocumented)
61
+ interface Transformer_2<T> {
62
+ // (undocumented)
46
63
  encode(node: Node_2): T;
64
+ // (undocumented)
47
65
  parse(content: T): Node_2;
48
66
  }
49
67
 
50
- declare class WikiMarkupTransformer implements Transformer_2<string> {
51
- private schema;
68
+ // @public (undocumented)
69
+ class WikiMarkupTransformer implements Transformer_2<string> {
52
70
  constructor(schema?: Schema);
53
- private sanitizeWikiMarkup;
71
+ // (undocumented)
54
72
  encode(node: Node_2, context?: Context): string;
73
+ // (undocumented)
55
74
  parse(wikiMarkup: string, context?: Context): Node_2;
56
- private buildContext;
57
75
  }
58
76
  export { WikiMarkupTransformer };
59
77
  export default WikiMarkupTransformer;
60
78
 
61
- export {};
79
+ // (No @packageDocumentation comment for this package)
62
80
  ```