@atlaskit/adf-utils 14.3.0 → 16.0.0

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.
Files changed (122) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/cjs/builders/marks/fragment.js +19 -0
  3. package/dist/cjs/builders/nodes/mention.js +2 -2
  4. package/dist/cjs/builders/utils/create-text-nodes.js +1 -1
  5. package/dist/cjs/builders/utils/is-duplicate-mark.js +1 -1
  6. package/dist/cjs/builders.js +128 -120
  7. package/dist/cjs/index.js +53 -37
  8. package/dist/cjs/media-link-transform.js +60 -0
  9. package/dist/cjs/scrub/default-node-replacements.js +2 -2
  10. package/dist/cjs/scrub/scrub-adf.js +2 -2
  11. package/dist/cjs/scrub/scrub-content.js +3 -3
  12. package/dist/cjs/transforms/text-link-code-transform.js +58 -0
  13. package/dist/cjs/traverse/traverse.js +3 -3
  14. package/dist/cjs/traverse.js +4 -4
  15. package/dist/cjs/validator/rules.js +13 -0
  16. package/dist/cjs/validator/specs/atomic_inline.js +1 -1
  17. package/dist/cjs/validator/specs/blockCard.js +2 -1
  18. package/dist/cjs/validator/specs/block_content.js +1 -1
  19. package/dist/cjs/validator/specs/bodiedExtension_with_marks.js +1 -1
  20. package/dist/cjs/validator/specs/doc.js +1 -1
  21. package/dist/cjs/validator/specs/embedCard.js +2 -1
  22. package/dist/cjs/validator/specs/extension_with_marks.js +1 -1
  23. package/dist/cjs/validator/specs/fragment.js +27 -0
  24. package/dist/cjs/validator/specs/index.js +164 -180
  25. package/dist/cjs/validator/specs/inline.js +1 -1
  26. package/dist/cjs/validator/specs/inlineCard.js +2 -1
  27. package/dist/cjs/validator/specs/inlineExtension_with_marks.js +1 -1
  28. package/dist/cjs/validator/specs/link.js +2 -1
  29. package/dist/cjs/validator/specs/non_nestable_block_content.js +1 -1
  30. package/dist/cjs/validator/specs/panel.js +8 -0
  31. package/dist/cjs/validator/specs/table.js +5 -0
  32. package/dist/cjs/validator/specs/tableCell_content.js +1 -1
  33. package/dist/cjs/validator/utils.js +1 -1
  34. package/dist/cjs/validator/validator.js +15 -5
  35. package/dist/cjs/version.json +1 -1
  36. package/dist/es2019/builders/marks/fragment.js +7 -0
  37. package/dist/es2019/builders.js +2 -1
  38. package/dist/es2019/index.js +3 -1
  39. package/dist/es2019/media-link-transform.js +48 -0
  40. package/dist/es2019/transforms/text-link-code-transform.js +37 -0
  41. package/dist/es2019/validator/rules.js +4 -0
  42. package/dist/es2019/validator/specs/atomic_inline.js +1 -1
  43. package/dist/es2019/validator/specs/blockCard.js +2 -1
  44. package/dist/es2019/validator/specs/block_content.js +1 -1
  45. package/dist/es2019/validator/specs/bodiedExtension_with_marks.js +1 -1
  46. package/dist/es2019/validator/specs/doc.js +1 -1
  47. package/dist/es2019/validator/specs/embedCard.js +2 -1
  48. package/dist/es2019/validator/specs/extension_with_marks.js +1 -1
  49. package/dist/es2019/validator/specs/fragment.js +20 -0
  50. package/dist/es2019/validator/specs/index.js +1 -3
  51. package/dist/es2019/validator/specs/inline.js +1 -1
  52. package/dist/es2019/validator/specs/inlineCard.js +2 -1
  53. package/dist/es2019/validator/specs/inlineExtension_with_marks.js +1 -1
  54. package/dist/es2019/validator/specs/link.js +2 -1
  55. package/dist/es2019/validator/specs/non_nestable_block_content.js +1 -1
  56. package/dist/es2019/validator/specs/panel.js +8 -0
  57. package/dist/es2019/validator/specs/table.js +5 -0
  58. package/dist/es2019/validator/specs/tableCell_content.js +1 -1
  59. package/dist/es2019/validator/validator.js +7 -2
  60. package/dist/es2019/version.json +1 -1
  61. package/dist/esm/builders/marks/fragment.js +9 -0
  62. package/dist/esm/builders/nodes/mention.js +2 -2
  63. package/dist/esm/builders.js +2 -1
  64. package/dist/esm/index.js +3 -1
  65. package/dist/esm/media-link-transform.js +50 -0
  66. package/dist/esm/scrub/default-node-replacements.js +2 -2
  67. package/dist/esm/scrub/scrub-adf.js +2 -2
  68. package/dist/esm/scrub/scrub-content.js +2 -2
  69. package/dist/esm/transforms/text-link-code-transform.js +47 -0
  70. package/dist/esm/traverse/traverse.js +2 -2
  71. package/dist/esm/validator/rules.js +4 -0
  72. package/dist/esm/validator/specs/atomic_inline.js +1 -1
  73. package/dist/esm/validator/specs/blockCard.js +2 -1
  74. package/dist/esm/validator/specs/block_content.js +1 -1
  75. package/dist/esm/validator/specs/bodiedExtension_with_marks.js +1 -1
  76. package/dist/esm/validator/specs/doc.js +1 -1
  77. package/dist/esm/validator/specs/embedCard.js +2 -1
  78. package/dist/esm/validator/specs/extension_with_marks.js +1 -1
  79. package/dist/esm/validator/specs/fragment.js +20 -0
  80. package/dist/esm/validator/specs/index.js +1 -3
  81. package/dist/esm/validator/specs/inline.js +1 -1
  82. package/dist/esm/validator/specs/inlineCard.js +2 -1
  83. package/dist/esm/validator/specs/inlineExtension_with_marks.js +1 -1
  84. package/dist/esm/validator/specs/link.js +2 -1
  85. package/dist/esm/validator/specs/non_nestable_block_content.js +1 -1
  86. package/dist/esm/validator/specs/panel.js +8 -0
  87. package/dist/esm/validator/specs/table.js +5 -0
  88. package/dist/esm/validator/specs/tableCell_content.js +1 -1
  89. package/dist/esm/validator/validator.js +13 -5
  90. package/dist/esm/version.json +1 -1
  91. package/dist/types/builders/marks/fragment.d.ts +3 -0
  92. package/dist/types/builders.d.ts +1 -0
  93. package/dist/types/index.d.ts +2 -0
  94. package/dist/types/media-link-transform.d.ts +5 -0
  95. package/dist/types/transforms/text-link-code-transform.d.ts +5 -0
  96. package/dist/types/types/validatorTypes.d.ts +1 -0
  97. package/dist/types/validator/rules.d.ts +3 -0
  98. package/dist/types/validator/specs/blockCard.d.ts +1 -0
  99. package/dist/types/validator/specs/bodiedExtension_with_marks.d.ts +1 -1
  100. package/dist/types/validator/specs/embedCard.d.ts +1 -0
  101. package/dist/types/validator/specs/extension_with_marks.d.ts +1 -1
  102. package/dist/types/validator/specs/fragment.d.ts +21 -0
  103. package/dist/types/validator/specs/index.d.ts +1 -3
  104. package/dist/types/validator/specs/inlineCard.d.ts +1 -0
  105. package/dist/types/validator/specs/inlineExtension_with_marks.d.ts +1 -1
  106. package/dist/types/validator/specs/link.d.ts +1 -0
  107. package/dist/types/validator/specs/panel.d.ts +8 -0
  108. package/dist/types/validator/specs/table.d.ts +5 -0
  109. package/media-link-transform/package.json +7 -0
  110. package/package.json +6 -3
  111. package/dist/cjs/validator/specs/bodiedExtension_with_no_marks.js +0 -17
  112. package/dist/cjs/validator/specs/extension_with_no_marks.js +0 -17
  113. package/dist/cjs/validator/specs/inlineExtension_with_no_marks.js +0 -17
  114. package/dist/es2019/validator/specs/bodiedExtension_with_no_marks.js +0 -10
  115. package/dist/es2019/validator/specs/extension_with_no_marks.js +0 -10
  116. package/dist/es2019/validator/specs/inlineExtension_with_no_marks.js +0 -10
  117. package/dist/esm/validator/specs/bodiedExtension_with_no_marks.js +0 -10
  118. package/dist/esm/validator/specs/extension_with_no_marks.js +0 -10
  119. package/dist/esm/validator/specs/inlineExtension_with_no_marks.js +0 -10
  120. package/dist/types/validator/specs/bodiedExtension_with_no_marks.d.ts +0 -11
  121. package/dist/types/validator/specs/extension_with_no_marks.d.ts +0 -11
  122. package/dist/types/validator/specs/inlineExtension_with_no_marks.d.ts +0 -11
@@ -1,8 +1,8 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
 
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
4
 
5
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
6
 
7
7
  import { scrubAttrs } from './scrub-content';
8
8
 
@@ -1,9 +1,9 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
 
4
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
4
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
5
 
6
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
7
 
8
8
  import { traverse } from '../traverse/traverse';
9
9
  import { scrubAttrs, scrubStr, scrubLink } from './scrub-content';
@@ -3,9 +3,9 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
5
5
 
6
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
6
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7
7
 
8
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
8
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
9
9
 
10
10
  var DUMMY_TEXT = "Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur Excepteur sint occaecat cupidatat non proident sunt in culpa qui officia deserunt mollit anim id est laborum";
11
11
  var DUMMY_DIGITS = ['2', '7', '4', '3', '5', '9', '1', '8', '0', '5'];
@@ -0,0 +1,47 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
+
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
+
7
+ import { traverse } from '../traverse/traverse';
8
+
9
+ var hasLinkAndCodeMarks = function hasLinkAndCodeMarks(node) {
10
+ var _node$marks;
11
+
12
+ var marks = (_node$marks = node.marks) === null || _node$marks === void 0 ? void 0 : _node$marks.map(function (mark) {
13
+ return mark.type;
14
+ });
15
+ return (marks === null || marks === void 0 ? void 0 : marks.includes('link')) && (marks === null || marks === void 0 ? void 0 : marks.includes('code'));
16
+ };
17
+
18
+ var removeCodeMarks = function removeCodeMarks(node) {
19
+ if (node.marks) {
20
+ return _objectSpread(_objectSpread({}, node), {}, {
21
+ marks: node.marks.filter(function (mark) {
22
+ return mark.type !== 'code';
23
+ })
24
+ });
25
+ }
26
+
27
+ return node;
28
+ }; // See: HOT-97965 https://product-fabric.atlassian.net/browse/ED-14400
29
+ // We declared in code mark spec that links and marks should not co-exist on
30
+ // text nodes. This util strips code marks from bad text nodes and preserves links.
31
+
32
+
33
+ export var transformTextLinkCodeMarks = function transformTextLinkCodeMarks(adf) {
34
+ var isTransformed = false;
35
+ var transformedAdf = traverse(adf, {
36
+ text: function text(node) {
37
+ if (hasLinkAndCodeMarks(node)) {
38
+ isTransformed = true;
39
+ return removeCodeMarks(node);
40
+ }
41
+ }
42
+ });
43
+ return {
44
+ transformedAdf: transformedAdf,
45
+ isTransformed: isTransformed
46
+ };
47
+ };
@@ -1,8 +1,8 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
 
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
4
 
5
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
6
 
7
7
  export function validateVisitors(_visitors) {
8
8
  return true;
@@ -0,0 +1,4 @@
1
+ import { isSafeUrl } from '@atlaskit/adf-schema/url';
2
+ export var validatorFnMap = {
3
+ safeUrl: isSafeUrl
4
+ };
@@ -1 +1 @@
1
- export default ['hardBreak', 'mention', 'emoji', 'inlineExtension_with_no_marks', 'date', 'placeholder', 'inlineCard', 'status', 'mediaInline'];
1
+ export default ['hardBreak', 'mention', 'emoji', 'inlineExtension_with_marks', 'date', 'placeholder', 'inlineCard', 'status', 'mediaInline'];
@@ -7,7 +7,8 @@ export default {
7
7
  attrs: [{
8
8
  props: {
9
9
  url: {
10
- type: 'string'
10
+ type: 'string',
11
+ validatorFn: 'safeUrl'
11
12
  }
12
13
  }
13
14
  }, {
@@ -1 +1 @@
1
- export default ['blockCard', 'paragraph_with_no_marks', 'paragraph_with_alignment', 'bulletList', 'mediaSingle_full', 'mediaSingle_caption', 'codeBlock_with_no_marks', 'orderedList', 'heading_with_no_marks', 'heading_with_alignment', 'heading_with_indentation', 'panel', 'blockquote', 'rule', 'mediaGroup', 'decisionList', 'taskList', 'extension_with_no_marks', 'extension_with_marks', 'embedCard', 'table', 'expand_with_no_mark', 'bodiedExtension_with_no_marks', 'bodiedExtension_with_marks'];
1
+ export default ['blockCard', 'paragraph_with_no_marks', 'paragraph_with_alignment', 'bulletList', 'mediaSingle_full', 'mediaSingle_caption', 'codeBlock_with_no_marks', 'orderedList', 'heading_with_no_marks', 'heading_with_alignment', 'heading_with_indentation', 'panel', 'blockquote', 'rule', 'mediaGroup', 'decisionList', 'taskList', 'extension_with_marks', 'embedCard', 'table', 'expand_with_no_mark', 'bodiedExtension_with_marks'];
@@ -2,7 +2,7 @@ export default ['bodiedExtension', {
2
2
  props: {
3
3
  marks: {
4
4
  type: 'array',
5
- items: ['dataConsumer'],
5
+ items: [['dataConsumer', 'fragment']],
6
6
  optional: true
7
7
  }
8
8
  }
@@ -10,7 +10,7 @@ export default {
10
10
  },
11
11
  content: {
12
12
  type: 'array',
13
- items: [['blockCard', 'paragraph_with_no_marks', 'paragraph_with_alignment', 'paragraph_with_indentation', 'bulletList', 'mediaSingle_full', 'mediaSingle_caption', 'codeBlock_with_no_marks', 'codeBlock_with_marks', 'orderedList', 'heading_with_no_marks', 'heading_with_alignment', 'heading_with_indentation', 'panel', 'blockquote', 'rule', 'mediaGroup', 'decisionList', 'taskList', 'extension_with_no_marks', 'extension_with_marks', 'embedCard', 'table', 'expand_with_no_mark', 'expand_with_breakout_mark', 'bodiedExtension_with_no_marks', 'bodiedExtension_with_marks', 'layoutSection_full', 'layoutSection_with_single_column']],
13
+ items: [['blockCard', 'paragraph_with_no_marks', 'paragraph_with_alignment', 'paragraph_with_indentation', 'bulletList', 'mediaSingle_full', 'mediaSingle_caption', 'codeBlock_with_no_marks', 'codeBlock_with_marks', 'orderedList', 'heading_with_no_marks', 'heading_with_alignment', 'heading_with_indentation', 'panel', 'blockquote', 'rule', 'mediaGroup', 'decisionList', 'taskList', 'extension_with_marks', 'embedCard', 'table', 'expand_with_no_mark', 'expand_with_breakout_mark', 'bodiedExtension_with_marks', 'layoutSection_full', 'layoutSection_with_single_column']],
14
14
  allowUnsupportedBlock: true
15
15
  }
16
16
  }
@@ -15,7 +15,8 @@ export default {
15
15
  optional: true
16
16
  },
17
17
  url: {
18
- type: 'string'
18
+ type: 'string',
19
+ validatorFn: 'safeUrl'
19
20
  },
20
21
  width: {
21
22
  type: 'number',
@@ -2,7 +2,7 @@ export default ['extension', {
2
2
  props: {
3
3
  marks: {
4
4
  type: 'array',
5
- items: ['dataConsumer'],
5
+ items: [['dataConsumer', 'fragment']],
6
6
  optional: true
7
7
  }
8
8
  }
@@ -0,0 +1,20 @@
1
+ export default {
2
+ props: {
3
+ type: {
4
+ type: 'enum',
5
+ values: ['fragment']
6
+ },
7
+ attrs: {
8
+ props: {
9
+ localId: {
10
+ type: 'string',
11
+ minLength: 1
12
+ },
13
+ name: {
14
+ type: 'string',
15
+ optional: true
16
+ }
17
+ }
18
+ }
19
+ }
20
+ };
@@ -13,11 +13,11 @@ export { default as alignment } from './alignment';
13
13
  export { default as indentation } from './indentation';
14
14
  export { default as annotation } from './annotation';
15
15
  export { default as dataConsumer } from './dataConsumer';
16
+ export { default as fragment } from './fragment';
16
17
  export { default as hardBreak } from './hardBreak';
17
18
  export { default as mention } from './mention';
18
19
  export { default as emoji } from './emoji';
19
20
  export { default as inlineExtension } from './inlineExtension';
20
- export { default as inlineExtension_with_no_marks } from './inlineExtension_with_no_marks';
21
21
  export { default as inlineExtension_with_marks } from './inlineExtension_with_marks';
22
22
  export { default as date } from './date';
23
23
  export { default as placeholder } from './placeholder';
@@ -59,7 +59,6 @@ export { default as decisionList } from './decisionList';
59
59
  export { default as taskItem } from './taskItem';
60
60
  export { default as taskList } from './taskList';
61
61
  export { default as extension } from './extension';
62
- export { default as extension_with_no_marks } from './extension_with_no_marks';
63
62
  export { default as extension_with_marks } from './extension_with_marks';
64
63
  export { default as embedCard } from './embedCard';
65
64
  export { default as nestedExpand_content } from './nestedExpand_content';
@@ -75,7 +74,6 @@ export { default as expand } from './expand';
75
74
  export { default as expand_with_no_mark } from './expand_with_no_mark';
76
75
  export { default as expand_with_breakout_mark } from './expand_with_breakout_mark';
77
76
  export { default as bodiedExtension } from './bodiedExtension';
78
- export { default as bodiedExtension_with_no_marks } from './bodiedExtension_with_no_marks';
79
77
  export { default as bodiedExtension_with_marks } from './bodiedExtension_with_marks';
80
78
  export { default as block_content } from './block_content';
81
79
  export { default as layoutColumn } from './layoutColumn';
@@ -1 +1 @@
1
- export default ['hardBreak', 'mention', 'emoji', 'inlineExtension_with_no_marks', 'inlineExtension_with_marks', 'date', 'placeholder', 'inlineCard', 'status', 'mediaInline', 'formatted_text_inline', 'code_inline'];
1
+ export default ['hardBreak', 'mention', 'emoji', 'inlineExtension_with_marks', 'date', 'placeholder', 'inlineCard', 'status', 'mediaInline', 'formatted_text_inline', 'code_inline'];
@@ -7,7 +7,8 @@ export default {
7
7
  attrs: [{
8
8
  props: {
9
9
  url: {
10
- type: 'string'
10
+ type: 'string',
11
+ validatorFn: 'safeUrl'
11
12
  }
12
13
  }
13
14
  }, {
@@ -2,7 +2,7 @@ export default ['inlineExtension', {
2
2
  props: {
3
3
  marks: {
4
4
  type: 'array',
5
- items: ['dataConsumer'],
5
+ items: [['dataConsumer', 'fragment']],
6
6
  optional: true
7
7
  }
8
8
  }
@@ -7,7 +7,8 @@ export default {
7
7
  attrs: {
8
8
  props: {
9
9
  href: {
10
- type: 'string'
10
+ type: 'string',
11
+ validatorFn: 'safeUrl'
11
12
  },
12
13
  title: {
13
14
  type: 'string',
@@ -1 +1 @@
1
- export default ['blockCard', 'paragraph_with_no_marks', 'bulletList', 'mediaSingle_full', 'mediaSingle_caption', 'codeBlock_with_no_marks', 'orderedList', 'heading_with_no_marks', 'panel', 'blockquote', 'rule', 'mediaGroup', 'decisionList', 'taskList', 'extension_with_no_marks', 'extension_with_marks', 'embedCard', 'table'];
1
+ export default ['blockCard', 'paragraph_with_no_marks', 'bulletList', 'mediaSingle_full', 'mediaSingle_caption', 'codeBlock_with_no_marks', 'orderedList', 'heading_with_no_marks', 'panel', 'blockquote', 'rule', 'mediaGroup', 'decisionList', 'taskList', 'extension_with_marks', 'embedCard', 'table'];
@@ -17,6 +17,14 @@ export default {
17
17
  panelColor: {
18
18
  type: 'string',
19
19
  optional: true
20
+ },
21
+ panelIconId: {
22
+ type: 'string',
23
+ optional: true
24
+ },
25
+ panelIconText: {
26
+ type: 'string',
27
+ optional: true
20
28
  }
21
29
  }
22
30
  },
@@ -27,6 +27,11 @@ export default {
27
27
  type: 'array',
28
28
  items: ['tableRow'],
29
29
  minItems: 1
30
+ },
31
+ marks: {
32
+ type: 'array',
33
+ items: ['fragment'],
34
+ optional: true
30
35
  }
31
36
  }
32
37
  };
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  type: 'array',
3
- items: [['blockCard', 'paragraph_with_no_marks', 'paragraph_with_alignment', 'bulletList', 'mediaSingle_full', 'mediaSingle_caption', 'codeBlock_with_no_marks', 'orderedList', 'heading_with_no_marks', 'heading_with_alignment', 'heading_with_indentation', 'panel', 'blockquote', 'rule', 'mediaGroup', 'decisionList', 'taskList', 'extension_with_no_marks', 'extension_with_marks', 'embedCard', 'nestedExpand_with_no_marks']],
3
+ items: [['blockCard', 'paragraph_with_no_marks', 'paragraph_with_alignment', 'bulletList', 'mediaSingle_full', 'mediaSingle_caption', 'codeBlock_with_no_marks', 'orderedList', 'heading_with_no_marks', 'heading_with_alignment', 'heading_with_indentation', 'panel', 'blockquote', 'rule', 'mediaGroup', 'decisionList', 'taskList', 'extension_with_marks', 'embedCard', 'nestedExpand_with_no_marks']],
4
4
  minItems: 1,
5
5
  allowUnsupportedBlock: true
6
6
  };
@@ -1,13 +1,15 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
+ var _excluded = ["items"];
4
5
 
5
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
6
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
7
 
7
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
8
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
9
 
9
10
  import * as specs from './specs';
10
11
  import { copy, isBoolean, isDefined, isInteger, isNumber, isPlainObject, isString, makeArray } from './utils';
12
+ import { validatorFnMap } from './rules';
11
13
 
12
14
  function mapMarksItems(spec) {
13
15
  var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (x) {
@@ -17,7 +19,7 @@ function mapMarksItems(spec) {
17
19
  if (spec.props && spec.props.marks) {
18
20
  var _ref = spec.props.marks,
19
21
  items = _ref.items,
20
- rest = _objectWithoutProperties(_ref, ["items"]);
22
+ rest = _objectWithoutProperties(_ref, _excluded);
21
23
 
22
24
  return _objectSpread(_objectSpread({}, spec), {}, {
23
25
  props: _objectSpread(_objectSpread({}, spec.props), {}, {
@@ -81,7 +83,9 @@ function createSpec(nodes, marks) {
81
83
  spec.props.content = _objectSpread({}, spec.props.content);
82
84
  }
83
85
 
84
- spec.props.content.items = spec.props.content.items.map(function (item) {
86
+ spec.props.content.items = spec.props.content.items // ['inline'] => [['emoji', 'hr', ...]]
87
+ // ['media'] => [['media']]
88
+ .map(function (item) {
85
89
  return isString(item) ? Array.isArray(specs[item]) ? specs[item] : [item] : item;
86
90
  }) // [['emoji', 'hr', 'inline_code']] => [['emoji', 'hr', ['text', { marks: {} }]]]
87
91
  .map(function (item) {
@@ -176,7 +180,11 @@ export function validateAttrs(spec, value) {
176
180
  return isInteger(value) && (isDefined(spec.minimum) ? spec.minimum <= value : true) && (isDefined(spec.maximum) ? spec.maximum >= value : true);
177
181
 
178
182
  case 'string':
179
- return isString(value) && (isDefined(spec.minLength) ? spec.minLength <= value.length : true) && (spec.pattern ? new RegExp(spec.pattern).test(value) : true);
183
+ var validatorFnPassed = function validatorFnPassed(rule) {
184
+ return typeof value === 'string' && isDefined(validatorFnMap[rule]) && validatorFnMap[rule](value);
185
+ };
186
+
187
+ return isString(value) && (isDefined(spec.minLength) ? spec.minLength <= value.length : true) && (isDefined(spec.validatorFn) ? validatorFnPassed(spec.validatorFn) : true) && (spec.pattern ? new RegExp(spec.pattern).test(value) : true);
180
188
 
181
189
  case 'object':
182
190
  return isPlainObject(value);
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-utils",
3
- "version": "14.3.0",
3
+ "version": "16.0.0",
4
4
  "sideEffects": false
5
5
  }
@@ -0,0 +1,3 @@
1
+ import { ExtensionDefinition, BodiedExtensionDefinition, InlineExtensionDefinition, TableDefinition, FragmentAttributes, FragmentDefinition } from '@atlaskit/adf-schema';
2
+ import { WithAppliedMark } from '../types';
3
+ export declare const fragment: (attrs: FragmentAttributes) => (maybeNode: TableDefinition | ExtensionDefinition | BodiedExtensionDefinition | InlineExtensionDefinition) => WithAppliedMark<ExtensionDefinition | BodiedExtensionDefinition | InlineExtensionDefinition | TableDefinition, FragmentDefinition>;
@@ -13,6 +13,7 @@ export { underline as u } from './builders/marks/underline';
13
13
  export { alignment } from './builders/marks/alignment';
14
14
  export { indentation } from './builders/marks/indentation';
15
15
  export { dataConsumer } from './builders/marks/data-consumer';
16
+ export { fragment } from './builders/marks/fragment';
16
17
  export { blockQuote } from './builders/nodes/blockquote';
17
18
  export { bodiedExtension } from './builders/nodes/bodied-extension';
18
19
  export { blockCard } from './builders/nodes/block-card';
@@ -5,3 +5,5 @@ export { validateAttrs, validator } from './validator';
5
5
  export type { Content, ErrorCallback, Output, ValidationError, ValidationErrorMap, ValidationErrorType, ValidationMode, ValidationOptions, ErrorCallbackOptions, Validate, } from './types/validatorTypes';
6
6
  export type { ADFEntity, ADFEntityMark, Visitor, VisitorCollection, } from './types';
7
7
  export { getEmptyADF } from './empty-adf';
8
+ export { transformMediaLinkMarks } from './media-link-transform';
9
+ export { transformTextLinkCodeMarks } from './transforms/text-link-code-transform';
@@ -0,0 +1,5 @@
1
+ import { ADFEntity } from './types';
2
+ export declare const transformMediaLinkMarks: (adf: ADFEntity) => {
3
+ transformedAdf: false | ADFEntity;
4
+ isTransformed: boolean;
5
+ };
@@ -0,0 +1,5 @@
1
+ import { ADFEntity } from '../types';
2
+ export declare const transformTextLinkCodeMarks: (adf: ADFEntity) => {
3
+ transformedAdf: false | ADFEntity;
4
+ isTransformed: boolean;
5
+ };
@@ -43,6 +43,7 @@ export declare type AttributesSpec = {
43
43
  optional?: boolean;
44
44
  minLength?: number;
45
45
  pattern?: RegExp;
46
+ validatorFn?: string;
46
47
  } | {
47
48
  type: 'enum';
48
49
  values: Array<string>;
@@ -0,0 +1,3 @@
1
+ export declare const validatorFnMap: {
2
+ [key: string]: (value: string) => boolean;
3
+ };
@@ -8,6 +8,7 @@ declare const _default: {
8
8
  props: {
9
9
  url: {
10
10
  type: string;
11
+ validatorFn: string;
11
12
  };
12
13
  data?: undefined;
13
14
  };
@@ -2,7 +2,7 @@ declare const _default: (string | {
2
2
  props: {
3
3
  marks: {
4
4
  type: string;
5
- items: string[];
5
+ items: string[][];
6
6
  optional: boolean;
7
7
  };
8
8
  };
@@ -16,6 +16,7 @@ declare const _default: {
16
16
  };
17
17
  url: {
18
18
  type: string;
19
+ validatorFn: string;
19
20
  };
20
21
  width: {
21
22
  type: string;
@@ -2,7 +2,7 @@ declare const _default: (string | {
2
2
  props: {
3
3
  marks: {
4
4
  type: string;
5
- items: string[];
5
+ items: string[][];
6
6
  optional: boolean;
7
7
  };
8
8
  };
@@ -0,0 +1,21 @@
1
+ declare const _default: {
2
+ props: {
3
+ type: {
4
+ type: string;
5
+ values: string[];
6
+ };
7
+ attrs: {
8
+ props: {
9
+ localId: {
10
+ type: string;
11
+ minLength: number;
12
+ };
13
+ name: {
14
+ type: string;
15
+ optional: boolean;
16
+ };
17
+ };
18
+ };
19
+ };
20
+ };
21
+ export default _default;
@@ -12,11 +12,11 @@ export { default as alignment } from './alignment';
12
12
  export { default as indentation } from './indentation';
13
13
  export { default as annotation } from './annotation';
14
14
  export { default as dataConsumer } from './dataConsumer';
15
+ export { default as fragment } from './fragment';
15
16
  export { default as hardBreak } from './hardBreak';
16
17
  export { default as mention } from './mention';
17
18
  export { default as emoji } from './emoji';
18
19
  export { default as inlineExtension } from './inlineExtension';
19
- export { default as inlineExtension_with_no_marks } from './inlineExtension_with_no_marks';
20
20
  export { default as inlineExtension_with_marks } from './inlineExtension_with_marks';
21
21
  export { default as date } from './date';
22
22
  export { default as placeholder } from './placeholder';
@@ -58,7 +58,6 @@ export { default as decisionList } from './decisionList';
58
58
  export { default as taskItem } from './taskItem';
59
59
  export { default as taskList } from './taskList';
60
60
  export { default as extension } from './extension';
61
- export { default as extension_with_no_marks } from './extension_with_no_marks';
62
61
  export { default as extension_with_marks } from './extension_with_marks';
63
62
  export { default as embedCard } from './embedCard';
64
63
  export { default as nestedExpand_content } from './nestedExpand_content';
@@ -74,7 +73,6 @@ export { default as expand } from './expand';
74
73
  export { default as expand_with_no_mark } from './expand_with_no_mark';
75
74
  export { default as expand_with_breakout_mark } from './expand_with_breakout_mark';
76
75
  export { default as bodiedExtension } from './bodiedExtension';
77
- export { default as bodiedExtension_with_no_marks } from './bodiedExtension_with_no_marks';
78
76
  export { default as bodiedExtension_with_marks } from './bodiedExtension_with_marks';
79
77
  export { default as block_content } from './block_content';
80
78
  export { default as layoutColumn } from './layoutColumn';
@@ -8,6 +8,7 @@ declare const _default: {
8
8
  props: {
9
9
  url: {
10
10
  type: string;
11
+ validatorFn: string;
11
12
  };
12
13
  data?: undefined;
13
14
  };
@@ -2,7 +2,7 @@ declare const _default: (string | {
2
2
  props: {
3
3
  marks: {
4
4
  type: string;
5
- items: string[];
5
+ items: string[][];
6
6
  optional: boolean;
7
7
  };
8
8
  };
@@ -8,6 +8,7 @@ declare const _default: {
8
8
  props: {
9
9
  href: {
10
10
  type: string;
11
+ validatorFn: string;
11
12
  };
12
13
  title: {
13
14
  type: string;
@@ -18,6 +18,14 @@ declare const _default: {
18
18
  type: string;
19
19
  optional: boolean;
20
20
  };
21
+ panelIconId: {
22
+ type: string;
23
+ optional: boolean;
24
+ };
25
+ panelIconText: {
26
+ type: string;
27
+ optional: boolean;
28
+ };
21
29
  };
22
30
  };
23
31
  content: {
@@ -28,6 +28,11 @@ declare const _default: {
28
28
  items: string[];
29
29
  minItems: number;
30
30
  };
31
+ marks: {
32
+ type: string;
33
+ items: string[];
34
+ optional: boolean;
35
+ };
31
36
  };
32
37
  };
33
38
  export default _default;
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "@atlaskit/adf-utils/media-link-transform",
3
+ "main": "../dist/cjs/media-link-transform.js",
4
+ "module": "../dist/esm/media-link-transform.js",
5
+ "module:es2019": "../dist/es2019/media-link-transform.js",
6
+ "types": "../dist/types/media-link-transform.d.ts"
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-utils",
3
- "version": "14.3.0",
3
+ "version": "16.0.0",
4
4
  "description": "Set of utilities to traverse, modify and create ADF documents.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -24,12 +24,12 @@
24
24
  "generate:spec": "rm -rf ./src/validator/specs/ && ../json-schema-generator/bin.js --outDir=./src/validator/specs/ --mode=Spec --stage=0 ./src/validator/entry.ts"
25
25
  },
26
26
  "dependencies": {
27
- "@atlaskit/adf-schema": "^19.2.0",
27
+ "@atlaskit/adf-schema": "^22.0.0",
28
28
  "@babel/runtime": "^7.0.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@atlaskit/docs": "*",
32
- "@atlaskit/json-schema-generator": "^3.1.0",
32
+ "@atlaskit/json-schema-generator": "^3.2.0",
33
33
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
34
34
  "react": "^16.8.0",
35
35
  "typescript": "3.9.6",
@@ -40,6 +40,9 @@
40
40
  "circular-dependencies": [
41
41
  "file-level"
42
42
  ]
43
+ },
44
+ "@repo/internal": {
45
+ "deprecation": "no-deprecated-imports"
43
46
  }
44
47
  },
45
48
  "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"