@atlaskit/adf-utils 14.1.0 → 14.4.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.
- package/CHANGELOG.md +37 -0
- package/build/tsconfig.json +6 -2
- package/dist/cjs/builders/marks/fragment.js +19 -0
- package/dist/cjs/builders/nodes/media-inline.js +15 -0
- package/dist/cjs/builders/types.js +5 -1
- package/dist/cjs/builders.js +8 -0
- package/dist/cjs/types/index.js +5 -1
- package/dist/cjs/types/validatorTypes.js +5 -1
- package/dist/cjs/validator/entry.js +5 -1
- package/dist/cjs/validator/rules.js +13 -0
- package/dist/cjs/validator/specs/atomic_inline.js +1 -1
- package/dist/cjs/validator/specs/blockCard.js +2 -1
- package/dist/cjs/validator/specs/block_content.js +1 -1
- package/dist/cjs/validator/specs/{bodiedExtension_with_no_marks.js → bodiedExtension_with_experimental_marks.js} +1 -2
- package/dist/cjs/validator/specs/doc.js +1 -1
- package/dist/cjs/validator/specs/embedCard.js +2 -1
- package/dist/cjs/validator/specs/{extension_with_no_marks.js → extension_with_experimental_marks.js} +1 -2
- package/dist/cjs/validator/specs/fragment.js +27 -0
- package/dist/cjs/validator/specs/index.js +58 -26
- package/dist/cjs/validator/specs/inline.js +1 -1
- package/dist/cjs/validator/specs/inlineCard.js +2 -1
- package/dist/cjs/validator/specs/{inlineExtension_with_no_marks.js → inlineExtension_with_experimental_marks.js} +1 -2
- package/dist/cjs/validator/specs/layoutSection.js +4 -7
- package/dist/cjs/validator/specs/layoutSection_full.js +27 -0
- package/dist/cjs/validator/specs/layoutSection_with_single_column.js +27 -0
- package/dist/cjs/validator/specs/link.js +2 -1
- package/dist/cjs/validator/specs/mediaInline.js +52 -0
- package/dist/cjs/validator/specs/non_nestable_block_content.js +1 -1
- package/dist/cjs/validator/specs/tableCell_content.js +1 -1
- package/dist/cjs/validator/validator.js +21 -17
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/builders/marks/fragment.js +7 -0
- package/dist/es2019/builders/nodes/media-inline.js +4 -0
- package/dist/es2019/builders/types.js +1 -0
- package/dist/es2019/builders.js +2 -1
- package/dist/es2019/types/index.js +1 -0
- package/dist/es2019/types/validatorTypes.js +1 -0
- package/dist/es2019/validator/entry.js +1 -0
- package/dist/es2019/validator/rules.js +4 -0
- package/dist/es2019/validator/specs/atomic_inline.js +1 -1
- package/dist/es2019/validator/specs/blockCard.js +2 -1
- package/dist/es2019/validator/specs/block_content.js +1 -1
- package/dist/{esm/validator/specs/bodiedExtension_with_no_marks.js → es2019/validator/specs/bodiedExtension_with_experimental_marks.js} +1 -2
- package/dist/es2019/validator/specs/doc.js +1 -1
- package/dist/es2019/validator/specs/embedCard.js +2 -1
- package/dist/es2019/validator/specs/{extension_with_no_marks.js → extension_with_experimental_marks.js} +1 -2
- package/dist/es2019/validator/specs/fragment.js +20 -0
- package/dist/es2019/validator/specs/index.js +8 -4
- package/dist/es2019/validator/specs/inline.js +1 -1
- package/dist/es2019/validator/specs/inlineCard.js +2 -1
- package/dist/es2019/validator/specs/{inlineExtension_with_no_marks.js → inlineExtension_with_experimental_marks.js} +1 -2
- package/dist/es2019/validator/specs/layoutSection.js +4 -7
- package/dist/es2019/validator/specs/layoutSection_full.js +20 -0
- package/dist/es2019/validator/specs/layoutSection_with_single_column.js +20 -0
- package/dist/es2019/validator/specs/link.js +2 -1
- package/dist/es2019/validator/specs/mediaInline.js +45 -0
- package/dist/es2019/validator/specs/non_nestable_block_content.js +1 -1
- package/dist/es2019/validator/specs/tableCell_content.js +1 -1
- package/dist/es2019/validator/validator.js +18 -17
- package/dist/es2019/version.json +1 -1
- package/dist/esm/builders/marks/fragment.js +9 -0
- package/dist/esm/builders/nodes/media-inline.js +6 -0
- package/dist/esm/builders/types.js +1 -0
- package/dist/esm/builders.js +2 -1
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/types/validatorTypes.js +1 -0
- package/dist/esm/validator/entry.js +1 -0
- package/dist/esm/validator/rules.js +4 -0
- package/dist/esm/validator/specs/atomic_inline.js +1 -1
- package/dist/esm/validator/specs/blockCard.js +2 -1
- package/dist/esm/validator/specs/block_content.js +1 -1
- package/dist/{es2019/validator/specs/bodiedExtension_with_no_marks.js → esm/validator/specs/bodiedExtension_with_experimental_marks.js} +1 -2
- package/dist/esm/validator/specs/doc.js +1 -1
- package/dist/esm/validator/specs/embedCard.js +2 -1
- package/dist/esm/validator/specs/{extension_with_no_marks.js → extension_with_experimental_marks.js} +1 -2
- package/dist/esm/validator/specs/fragment.js +20 -0
- package/dist/esm/validator/specs/index.js +8 -4
- package/dist/esm/validator/specs/inline.js +1 -1
- package/dist/esm/validator/specs/inlineCard.js +2 -1
- package/dist/esm/validator/specs/{inlineExtension_with_no_marks.js → inlineExtension_with_experimental_marks.js} +1 -2
- package/dist/esm/validator/specs/layoutSection.js +4 -7
- package/dist/esm/validator/specs/layoutSection_full.js +20 -0
- package/dist/esm/validator/specs/layoutSection_with_single_column.js +20 -0
- package/dist/esm/validator/specs/link.js +2 -1
- package/dist/esm/validator/specs/mediaInline.js +45 -0
- package/dist/esm/validator/specs/non_nestable_block_content.js +1 -1
- package/dist/esm/validator/specs/tableCell_content.js +1 -1
- package/dist/esm/validator/validator.js +20 -17
- package/dist/esm/version.json +1 -1
- package/dist/types/builders/marks/breakout.d.ts +1 -1
- package/dist/types/builders/marks/fragment.d.ts +3 -0
- package/dist/types/builders/nodes/media-inline.d.ts +2 -0
- package/dist/types/builders.d.ts +1 -0
- package/dist/types/types/validatorTypes.d.ts +1 -0
- package/dist/types/validator/rules.d.ts +3 -0
- package/dist/types/validator/specs/blockCard.d.ts +1 -0
- package/dist/types/validator/specs/{bodiedExtension_with_no_marks.d.ts → bodiedExtension_with_experimental_marks.d.ts} +1 -2
- package/dist/types/validator/specs/embedCard.d.ts +1 -0
- package/dist/types/validator/specs/{extension_with_no_marks.d.ts → extension_with_experimental_marks.d.ts} +1 -2
- package/dist/types/validator/specs/fragment.d.ts +21 -0
- package/dist/types/validator/specs/index.d.ts +8 -4
- package/dist/types/validator/specs/inlineCard.d.ts +1 -0
- package/dist/types/validator/specs/{inlineExtension_with_no_marks.d.ts → inlineExtension_with_experimental_marks.d.ts} +1 -2
- package/dist/types/validator/specs/layoutSection.d.ts +3 -6
- package/dist/types/validator/specs/layoutSection_full.d.ts +21 -0
- package/dist/types/validator/specs/layoutSection_with_single_column.d.ts +21 -0
- package/dist/types/validator/specs/link.d.ts +1 -0
- package/dist/types/validator/specs/mediaInline.d.ts +46 -0
- package/package.json +9 -6
|
@@ -20,6 +20,8 @@ var specs = _interopRequireWildcard(require("./specs"));
|
|
|
20
20
|
|
|
21
21
|
var _utils = require("./utils");
|
|
22
22
|
|
|
23
|
+
var _rules = require("./rules");
|
|
24
|
+
|
|
23
25
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
24
26
|
|
|
25
27
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -99,9 +101,7 @@ function createSpec(nodes, marks) {
|
|
|
99
101
|
spec.props.content = _objectSpread({}, spec.props.content);
|
|
100
102
|
}
|
|
101
103
|
|
|
102
|
-
spec.props.content.items = spec.props.content.items.
|
|
103
|
-
// ['media'] => [['media']]
|
|
104
|
-
map(function (item) {
|
|
104
|
+
spec.props.content.items = spec.props.content.items.map(function (item) {
|
|
105
105
|
return (0, _utils.isString)(item) ? Array.isArray(specs[item]) ? specs[item] : [item] : item;
|
|
106
106
|
}) // [['emoji', 'hr', 'inline_code']] => [['emoji', 'hr', ['text', { marks: {} }]]]
|
|
107
107
|
.map(function (item) {
|
|
@@ -196,7 +196,11 @@ function validateAttrs(spec, value) {
|
|
|
196
196
|
return (0, _utils.isInteger)(value) && ((0, _utils.isDefined)(spec.minimum) ? spec.minimum <= value : true) && ((0, _utils.isDefined)(spec.maximum) ? spec.maximum >= value : true);
|
|
197
197
|
|
|
198
198
|
case 'string':
|
|
199
|
-
|
|
199
|
+
var validatorFnPassed = function validatorFnPassed(rule) {
|
|
200
|
+
return typeof value === 'string' && (0, _utils.isDefined)(_rules.validatorFnMap[rule]) && _rules.validatorFnMap[rule](value);
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
return (0, _utils.isString)(value) && ((0, _utils.isDefined)(spec.minLength) ? spec.minLength <= value.length : true) && ((0, _utils.isDefined)(spec.validatorFn) ? validatorFnPassed(spec.validatorFn) : true) && (spec.pattern ? new RegExp(spec.pattern).test(value) : true);
|
|
200
204
|
|
|
201
205
|
case 'object':
|
|
202
206
|
return (0, _utils.isPlainObject)(value);
|
|
@@ -403,19 +407,19 @@ function validator(nodes, marks, options) {
|
|
|
403
407
|
} // this checks for mark level attribute errors
|
|
404
408
|
// and propagates error code and message
|
|
405
409
|
else if (finalResult.marksValidationOutput && finalResult.marksValidationOutput.length) {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
410
|
+
return {
|
|
411
|
+
valid: false,
|
|
412
|
+
originalMark: mark,
|
|
413
|
+
errorCode: finalResult.marksValidationOutput[0].errorCode,
|
|
414
|
+
message: finalResult.marksValidationOutput[0].message
|
|
415
|
+
};
|
|
416
|
+
} else {
|
|
417
|
+
return {
|
|
418
|
+
valid: false,
|
|
419
|
+
originalMark: mark,
|
|
420
|
+
errorCode: 'INVALID_TYPE'
|
|
421
|
+
};
|
|
422
|
+
}
|
|
419
423
|
} else {
|
|
420
424
|
return {
|
|
421
425
|
valid: false,
|
package/dist/cjs/version.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/es2019/builders.js
CHANGED
|
@@ -13,7 +13,8 @@ export { underline } from './builders/marks/underline';
|
|
|
13
13
|
export { underline as u } from './builders/marks/underline';
|
|
14
14
|
export { alignment } from './builders/marks/alignment';
|
|
15
15
|
export { indentation } from './builders/marks/indentation';
|
|
16
|
-
export { dataConsumer } from './builders/marks/data-consumer';
|
|
16
|
+
export { dataConsumer } from './builders/marks/data-consumer';
|
|
17
|
+
export { fragment } from './builders/marks/fragment'; // Nodes Builders
|
|
17
18
|
|
|
18
19
|
export { blockQuote } from './builders/nodes/blockquote';
|
|
19
20
|
export { bodiedExtension } from './builders/nodes/bodied-extension';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default ['hardBreak', 'mention', 'emoji', '
|
|
1
|
+
export default ['hardBreak', 'mention', 'emoji', 'inlineExtension_with_marks', 'date', 'placeholder', 'inlineCard', 'status', 'mediaInline'];
|
|
@@ -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', '
|
|
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', 'extension_with_experimental_marks', 'embedCard', 'table', 'expand_with_no_mark', 'bodiedExtension_with_marks', 'bodiedExtension_with_experimental_marks'];
|
|
@@ -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', '
|
|
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', 'extension_with_experimental_marks', 'embedCard', 'table', 'expand_with_no_mark', 'expand_with_breakout_mark', 'bodiedExtension_with_marks', 'bodiedExtension_with_experimental_marks', 'layoutSection_full', 'layoutSection_with_single_column']],
|
|
14
14
|
allowUnsupportedBlock: true
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -13,18 +13,21 @@ 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
|
+
export { default as inlineExtension_with_experimental_marks } from './inlineExtension_with_experimental_marks';
|
|
22
23
|
export { default as date } from './date';
|
|
23
24
|
export { default as placeholder } from './placeholder';
|
|
24
25
|
export { default as blockCard } from './blockCard';
|
|
25
26
|
export { default as inlineCard } from './inlineCard';
|
|
26
27
|
export { default as status } from './status';
|
|
27
28
|
export { default as text } from './text';
|
|
29
|
+
export { default as media } from './media';
|
|
30
|
+
export { default as mediaInline } from './mediaInline';
|
|
28
31
|
export { default as formatted_text_inline } from './formatted_text_inline';
|
|
29
32
|
export { default as link_text_inline } from './link_text_inline';
|
|
30
33
|
export { default as code_inline } from './code_inline';
|
|
@@ -35,7 +38,6 @@ export { default as paragraph_with_no_marks } from './paragraph_with_no_marks';
|
|
|
35
38
|
export { default as paragraph_with_alignment } from './paragraph_with_alignment';
|
|
36
39
|
export { default as paragraph_with_indentation } from './paragraph_with_indentation';
|
|
37
40
|
export { default as bulletList } from './bulletList';
|
|
38
|
-
export { default as media } from './media';
|
|
39
41
|
export { default as caption } from './caption';
|
|
40
42
|
export { default as mediaSingle } from './mediaSingle';
|
|
41
43
|
export { default as mediaSingle_full } from './mediaSingle_full';
|
|
@@ -58,8 +60,8 @@ export { default as decisionList } from './decisionList';
|
|
|
58
60
|
export { default as taskItem } from './taskItem';
|
|
59
61
|
export { default as taskList } from './taskList';
|
|
60
62
|
export { default as extension } from './extension';
|
|
61
|
-
export { default as extension_with_no_marks } from './extension_with_no_marks';
|
|
62
63
|
export { default as extension_with_marks } from './extension_with_marks';
|
|
64
|
+
export { default as extension_with_experimental_marks } from './extension_with_experimental_marks';
|
|
63
65
|
export { default as embedCard } from './embedCard';
|
|
64
66
|
export { default as nestedExpand_content } from './nestedExpand_content';
|
|
65
67
|
export { default as nestedExpand } from './nestedExpand';
|
|
@@ -74,9 +76,11 @@ export { default as expand } from './expand';
|
|
|
74
76
|
export { default as expand_with_no_mark } from './expand_with_no_mark';
|
|
75
77
|
export { default as expand_with_breakout_mark } from './expand_with_breakout_mark';
|
|
76
78
|
export { default as bodiedExtension } from './bodiedExtension';
|
|
77
|
-
export { default as bodiedExtension_with_no_marks } from './bodiedExtension_with_no_marks';
|
|
78
79
|
export { default as bodiedExtension_with_marks } from './bodiedExtension_with_marks';
|
|
80
|
+
export { default as bodiedExtension_with_experimental_marks } from './bodiedExtension_with_experimental_marks';
|
|
79
81
|
export { default as block_content } from './block_content';
|
|
80
82
|
export { default as layoutColumn } from './layoutColumn';
|
|
81
83
|
export { default as layoutSection } from './layoutSection';
|
|
84
|
+
export { default as layoutSection_full } from './layoutSection_full';
|
|
85
|
+
export { default as layoutSection_with_single_column } from './layoutSection_with_single_column';
|
|
82
86
|
export { default as doc } from './doc';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default ['hardBreak', 'mention', 'emoji', '
|
|
1
|
+
export default ['hardBreak', 'mention', 'emoji', 'inlineExtension_with_marks', 'inlineExtension_with_experimental_marks', 'date', 'placeholder', 'inlineCard', 'status', 'mediaInline', 'formatted_text_inline', 'code_inline'];
|
|
@@ -4,17 +4,14 @@ export default {
|
|
|
4
4
|
type: 'enum',
|
|
5
5
|
values: ['layoutSection']
|
|
6
6
|
},
|
|
7
|
-
content: {
|
|
8
|
-
type: 'array',
|
|
9
|
-
items: ['layoutColumn'],
|
|
10
|
-
minItems: 2,
|
|
11
|
-
maxItems: 3,
|
|
12
|
-
allowUnsupportedBlock: true
|
|
13
|
-
},
|
|
14
7
|
marks: {
|
|
15
8
|
type: 'array',
|
|
16
9
|
items: ['breakout'],
|
|
17
10
|
optional: true
|
|
11
|
+
},
|
|
12
|
+
content: {
|
|
13
|
+
type: 'array',
|
|
14
|
+
items: ['layoutColumn']
|
|
18
15
|
}
|
|
19
16
|
}
|
|
20
17
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default ['layoutSection', {
|
|
2
|
+
props: {
|
|
3
|
+
type: {
|
|
4
|
+
type: 'enum',
|
|
5
|
+
values: ['layoutSection']
|
|
6
|
+
},
|
|
7
|
+
marks: {
|
|
8
|
+
type: 'array',
|
|
9
|
+
items: ['breakout'],
|
|
10
|
+
optional: true
|
|
11
|
+
},
|
|
12
|
+
content: {
|
|
13
|
+
type: 'array',
|
|
14
|
+
items: ['layoutColumn'],
|
|
15
|
+
minItems: 2,
|
|
16
|
+
maxItems: 3,
|
|
17
|
+
allowUnsupportedBlock: true
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default ['layoutSection', {
|
|
2
|
+
props: {
|
|
3
|
+
type: {
|
|
4
|
+
type: 'enum',
|
|
5
|
+
values: ['layoutSection']
|
|
6
|
+
},
|
|
7
|
+
marks: {
|
|
8
|
+
type: 'array',
|
|
9
|
+
items: ['breakout'],
|
|
10
|
+
optional: true
|
|
11
|
+
},
|
|
12
|
+
content: {
|
|
13
|
+
type: 'array',
|
|
14
|
+
items: ['layoutColumn'],
|
|
15
|
+
minItems: 1,
|
|
16
|
+
maxItems: 3,
|
|
17
|
+
allowUnsupportedBlock: true
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
props: {
|
|
3
|
+
type: {
|
|
4
|
+
type: 'enum',
|
|
5
|
+
values: ['mediaInline']
|
|
6
|
+
},
|
|
7
|
+
attrs: {
|
|
8
|
+
props: {
|
|
9
|
+
data: {
|
|
10
|
+
type: 'object',
|
|
11
|
+
optional: true
|
|
12
|
+
},
|
|
13
|
+
id: {
|
|
14
|
+
type: 'string',
|
|
15
|
+
minLength: 1
|
|
16
|
+
},
|
|
17
|
+
collection: {
|
|
18
|
+
type: 'string'
|
|
19
|
+
},
|
|
20
|
+
height: {
|
|
21
|
+
type: 'number',
|
|
22
|
+
optional: true
|
|
23
|
+
},
|
|
24
|
+
width: {
|
|
25
|
+
type: 'number',
|
|
26
|
+
optional: true
|
|
27
|
+
},
|
|
28
|
+
occurrenceKey: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
minLength: 1,
|
|
31
|
+
optional: true
|
|
32
|
+
},
|
|
33
|
+
alt: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
optional: true
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
marks: {
|
|
40
|
+
type: 'array',
|
|
41
|
+
items: ['link'],
|
|
42
|
+
optional: true
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
@@ -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', '
|
|
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', 'extension_with_experimental_marks', 'embedCard', 'table'];
|
|
@@ -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', '
|
|
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', 'extension_with_experimental_marks', 'embedCard', 'nestedExpand_with_no_marks']],
|
|
4
4
|
minItems: 1,
|
|
5
5
|
allowUnsupportedBlock: true
|
|
6
6
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as specs from './specs';
|
|
2
2
|
import { copy, isBoolean, isDefined, isInteger, isNumber, isPlainObject, isString, makeArray } from './utils';
|
|
3
|
+
import { validatorFnMap } from './rules';
|
|
3
4
|
|
|
4
5
|
function mapMarksItems(spec, fn = x => x) {
|
|
5
6
|
if (spec.props && spec.props.marks) {
|
|
@@ -69,9 +70,7 @@ function createSpec(nodes, marks) {
|
|
|
69
70
|
};
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
spec.props.content.items = spec.props.content.items. // ['
|
|
73
|
-
// ['media'] => [['media']]
|
|
74
|
-
map(item => isString(item) ? Array.isArray(specs[item]) ? specs[item] : [item] : item) // [['emoji', 'hr', 'inline_code']] => [['emoji', 'hr', ['text', { marks: {} }]]]
|
|
73
|
+
spec.props.content.items = spec.props.content.items.map(item => isString(item) ? Array.isArray(specs[item]) ? specs[item] : [item] : item) // [['emoji', 'hr', 'inline_code']] => [['emoji', 'hr', ['text', { marks: {} }]]]
|
|
75
74
|
.map(item => item.map(subItem => Array.isArray(specs[subItem]) ? specs[subItem] : isString(subItem) ? subItem : // Now `NoMark` produces `items: []`, should be fixed in generator
|
|
76
75
|
['text', subItem]) // Remove unsupported nodes & marks
|
|
77
76
|
// Filter nodes
|
|
@@ -153,7 +152,9 @@ export function validateAttrs(spec, value) {
|
|
|
153
152
|
return isInteger(value) && (isDefined(spec.minimum) ? spec.minimum <= value : true) && (isDefined(spec.maximum) ? spec.maximum >= value : true);
|
|
154
153
|
|
|
155
154
|
case 'string':
|
|
156
|
-
|
|
155
|
+
const validatorFnPassed = rule => typeof value === 'string' && isDefined(validatorFnMap[rule]) && validatorFnMap[rule](value);
|
|
156
|
+
|
|
157
|
+
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);
|
|
157
158
|
|
|
158
159
|
case 'object':
|
|
159
160
|
return isPlainObject(value);
|
|
@@ -364,19 +365,19 @@ export function validator(nodes, marks, options) {
|
|
|
364
365
|
} // this checks for mark level attribute errors
|
|
365
366
|
// and propagates error code and message
|
|
366
367
|
else if (finalResult.marksValidationOutput && finalResult.marksValidationOutput.length) {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
368
|
+
return {
|
|
369
|
+
valid: false,
|
|
370
|
+
originalMark: mark,
|
|
371
|
+
errorCode: finalResult.marksValidationOutput[0].errorCode,
|
|
372
|
+
message: finalResult.marksValidationOutput[0].message
|
|
373
|
+
};
|
|
374
|
+
} else {
|
|
375
|
+
return {
|
|
376
|
+
valid: false,
|
|
377
|
+
originalMark: mark,
|
|
378
|
+
errorCode: 'INVALID_TYPE'
|
|
379
|
+
};
|
|
380
|
+
}
|
|
380
381
|
} else {
|
|
381
382
|
return {
|
|
382
383
|
valid: false,
|
package/dist/es2019/version.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/esm/builders.js
CHANGED
|
@@ -13,7 +13,8 @@ export { underline } from './builders/marks/underline';
|
|
|
13
13
|
export { underline as u } from './builders/marks/underline';
|
|
14
14
|
export { alignment } from './builders/marks/alignment';
|
|
15
15
|
export { indentation } from './builders/marks/indentation';
|
|
16
|
-
export { dataConsumer } from './builders/marks/data-consumer';
|
|
16
|
+
export { dataConsumer } from './builders/marks/data-consumer';
|
|
17
|
+
export { fragment } from './builders/marks/fragment'; // Nodes Builders
|
|
17
18
|
|
|
18
19
|
export { blockQuote } from './builders/nodes/blockquote';
|
|
19
20
|
export { bodiedExtension } from './builders/nodes/bodied-extension';
|
package/dist/esm/types/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default ['hardBreak', 'mention', 'emoji', '
|
|
1
|
+
export default ['hardBreak', 'mention', 'emoji', 'inlineExtension_with_marks', 'date', 'placeholder', 'inlineCard', 'status', 'mediaInline'];
|
|
@@ -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', '
|
|
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', 'extension_with_experimental_marks', 'embedCard', 'table', 'expand_with_no_mark', 'bodiedExtension_with_marks', 'bodiedExtension_with_experimental_marks'];
|
|
@@ -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', '
|
|
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', 'extension_with_experimental_marks', 'embedCard', 'table', 'expand_with_no_mark', 'expand_with_breakout_mark', 'bodiedExtension_with_marks', 'bodiedExtension_with_experimental_marks', 'layoutSection_full', 'layoutSection_with_single_column']],
|
|
14
14
|
allowUnsupportedBlock: true
|
|
15
15
|
}
|
|
16
16
|
}
|