@atlaskit/adf-utils 14.2.0 → 15.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.
- package/CHANGELOG.md +42 -0
- package/dist/cjs/builders/marks/fragment.js +19 -0
- package/dist/cjs/builders/nodes/mention.js +2 -2
- package/dist/cjs/builders/utils/create-text-nodes.js +1 -1
- package/dist/cjs/builders/utils/is-duplicate-mark.js +1 -1
- package/dist/cjs/builders.js +128 -120
- package/dist/cjs/index.js +49 -41
- package/dist/cjs/scrub/default-node-replacements.js +2 -2
- package/dist/cjs/scrub/scrub-adf.js +2 -2
- package/dist/cjs/scrub/scrub-content.js +3 -3
- package/dist/cjs/transforms/text-link-code-transform.js +58 -0
- package/dist/cjs/traverse/traverse.js +3 -3
- package/dist/cjs/traverse.js +4 -4
- 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_marks.js +1 -1
- 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_marks.js +1 -1
- package/dist/cjs/validator/specs/fragment.js +27 -0
- package/dist/cjs/validator/specs/index.js +170 -170
- 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_marks.js +1 -1
- 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/non_nestable_block_content.js +1 -1
- package/dist/cjs/validator/specs/panel.js +8 -0
- package/dist/cjs/validator/specs/table.js +5 -0
- package/dist/cjs/validator/specs/tableCell_content.js +1 -1
- package/dist/cjs/validator/utils.js +1 -1
- package/dist/cjs/validator/validator.js +27 -19
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/builders/marks/fragment.js +7 -0
- package/dist/es2019/builders.js +2 -1
- package/dist/es2019/index.js +2 -1
- package/dist/es2019/transforms/text-link-code-transform.js +37 -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/es2019/validator/specs/bodiedExtension_with_marks.js +1 -1
- 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_marks.js +1 -1
- package/dist/es2019/validator/specs/fragment.js +20 -0
- package/dist/es2019/validator/specs/index.js +3 -3
- 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_marks.js +1 -1
- 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/non_nestable_block_content.js +1 -1
- package/dist/es2019/validator/specs/panel.js +8 -0
- package/dist/es2019/validator/specs/table.js +5 -0
- package/dist/es2019/validator/specs/tableCell_content.js +1 -1
- package/dist/es2019/validator/validator.js +19 -16
- package/dist/es2019/version.json +1 -1
- package/dist/esm/builders/marks/fragment.js +9 -0
- package/dist/esm/builders/nodes/mention.js +2 -2
- package/dist/esm/builders.js +2 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/scrub/default-node-replacements.js +2 -2
- package/dist/esm/scrub/scrub-adf.js +2 -2
- package/dist/esm/scrub/scrub-content.js +2 -2
- package/dist/esm/transforms/text-link-code-transform.js +47 -0
- package/dist/esm/traverse/traverse.js +2 -2
- 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/esm/validator/specs/bodiedExtension_with_marks.js +1 -1
- 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_marks.js +1 -1
- package/dist/esm/validator/specs/fragment.js +20 -0
- package/dist/esm/validator/specs/index.js +3 -3
- 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_marks.js +1 -1
- 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/non_nestable_block_content.js +1 -1
- package/dist/esm/validator/specs/panel.js +8 -0
- package/dist/esm/validator/specs/table.js +5 -0
- package/dist/esm/validator/specs/tableCell_content.js +1 -1
- package/dist/esm/validator/validator.js +25 -19
- 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.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/transforms/text-link-code-transform.d.ts +5 -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_marks.d.ts +1 -1
- package/dist/types/validator/specs/embedCard.d.ts +1 -0
- package/dist/types/validator/specs/extension_with_marks.d.ts +1 -1
- package/dist/types/validator/specs/fragment.d.ts +21 -0
- package/dist/types/validator/specs/index.d.ts +3 -3
- package/dist/types/validator/specs/inlineCard.d.ts +1 -0
- package/dist/types/validator/specs/inlineExtension_with_marks.d.ts +1 -1
- 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/panel.d.ts +8 -0
- package/dist/types/validator/specs/table.d.ts +5 -0
- package/package.json +6 -3
- package/dist/cjs/validator/specs/bodiedExtension_with_no_marks.js +0 -17
- package/dist/cjs/validator/specs/extension_with_no_marks.js +0 -17
- package/dist/cjs/validator/specs/inlineExtension_with_no_marks.js +0 -17
- package/dist/es2019/validator/specs/bodiedExtension_with_no_marks.js +0 -10
- package/dist/es2019/validator/specs/extension_with_no_marks.js +0 -10
- package/dist/es2019/validator/specs/inlineExtension_with_no_marks.js +0 -10
- package/dist/esm/validator/specs/bodiedExtension_with_no_marks.js +0 -10
- package/dist/esm/validator/specs/extension_with_no_marks.js +0 -10
- package/dist/esm/validator/specs/inlineExtension_with_no_marks.js +0 -10
- package/dist/types/validator/specs/bodiedExtension_with_no_marks.d.ts +0 -11
- package/dist/types/validator/specs/extension_with_no_marks.d.ts +0 -11
- package/dist/types/validator/specs/inlineExtension_with_no_marks.d.ts +0 -11
|
@@ -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,9 @@ function createSpec(nodes, marks) {
|
|
|
69
70
|
};
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
spec.props.content.items = spec.props.content.items
|
|
73
|
+
spec.props.content.items = spec.props.content.items // ['inline'] => [['emoji', 'hr', ...]]
|
|
73
74
|
// ['media'] => [['media']]
|
|
74
|
-
map(item => isString(item) ? Array.isArray(specs[item]) ? specs[item] : [item] : item) // [['emoji', 'hr', 'inline_code']] => [['emoji', 'hr', ['text', { marks: {} }]]]
|
|
75
|
+
.map(item => isString(item) ? Array.isArray(specs[item]) ? specs[item] : [item] : item) // [['emoji', 'hr', 'inline_code']] => [['emoji', 'hr', ['text', { marks: {} }]]]
|
|
75
76
|
.map(item => item.map(subItem => Array.isArray(specs[subItem]) ? specs[subItem] : isString(subItem) ? subItem : // Now `NoMark` produces `items: []`, should be fixed in generator
|
|
76
77
|
['text', subItem]) // Remove unsupported nodes & marks
|
|
77
78
|
// Filter nodes
|
|
@@ -153,7 +154,9 @@ export function validateAttrs(spec, value) {
|
|
|
153
154
|
return isInteger(value) && (isDefined(spec.minimum) ? spec.minimum <= value : true) && (isDefined(spec.maximum) ? spec.maximum >= value : true);
|
|
154
155
|
|
|
155
156
|
case 'string':
|
|
156
|
-
|
|
157
|
+
const validatorFnPassed = rule => typeof value === 'string' && isDefined(validatorFnMap[rule]) && validatorFnMap[rule](value);
|
|
158
|
+
|
|
159
|
+
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
160
|
|
|
158
161
|
case 'object':
|
|
159
162
|
return isPlainObject(value);
|
|
@@ -364,19 +367,19 @@ export function validator(nodes, marks, options) {
|
|
|
364
367
|
} // this checks for mark level attribute errors
|
|
365
368
|
// and propagates error code and message
|
|
366
369
|
else if (finalResult.marksValidationOutput && finalResult.marksValidationOutput.length) {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
370
|
+
return {
|
|
371
|
+
valid: false,
|
|
372
|
+
originalMark: mark,
|
|
373
|
+
errorCode: finalResult.marksValidationOutput[0].errorCode,
|
|
374
|
+
message: finalResult.marksValidationOutput[0].message
|
|
375
|
+
};
|
|
376
|
+
} else {
|
|
377
|
+
return {
|
|
378
|
+
valid: false,
|
|
379
|
+
originalMark: mark,
|
|
380
|
+
errorCode: 'INVALID_TYPE'
|
|
381
|
+
};
|
|
382
|
+
}
|
|
380
383
|
} else {
|
|
381
384
|
return {
|
|
382
385
|
valid: false,
|
package/dist/es2019/version.json
CHANGED
|
@@ -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);
|
|
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]
|
|
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 var mention = function mention(attrs) {
|
|
8
8
|
return {
|
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/index.js
CHANGED
|
@@ -2,4 +2,5 @@ export { a, alignment, b, blockCard, blockQuote, bodiedExtension, br, breakout,
|
|
|
2
2
|
export { filter, map, reduce, traverse } from './traverse';
|
|
3
3
|
export { scrubAdf } from './scrub';
|
|
4
4
|
export { validateAttrs, validator } from './validator';
|
|
5
|
-
export { getEmptyADF } from './empty-adf';
|
|
5
|
+
export { getEmptyADF } from './empty-adf';
|
|
6
|
+
export { transformTextLinkCodeMarks } from './transforms/text-link-code-transform';
|
|
@@ -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);
|
|
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]
|
|
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);
|
|
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]
|
|
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);
|
|
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]
|
|
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);
|
|
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]
|
|
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;
|
|
@@ -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', 'embedCard', 'table', 'expand_with_no_mark', 'bodiedExtension_with_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', '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
|
}
|
|
@@ -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,9 +74,10 @@ 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';
|
|
82
80
|
export { default as layoutSection } from './layoutSection';
|
|
81
|
+
export { default as layoutSection_full } from './layoutSection_full';
|
|
82
|
+
export { default as layoutSection_with_single_column } from './layoutSection_with_single_column';
|
|
83
83
|
export { default as doc } from './doc';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default ['hardBreak', 'mention', 'emoji', '
|
|
1
|
+
export default ['hardBreak', 'mention', 'emoji', 'inlineExtension_with_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
|
+
}];
|
|
@@ -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', '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', '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);
|
|
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]
|
|
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,
|
|
22
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
21
23
|
|
|
22
24
|
return _objectSpread(_objectSpread({}, spec), {}, {
|
|
23
25
|
props: _objectSpread(_objectSpread({}, spec.props), {}, {
|
|
@@ -81,9 +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
|
|
86
|
+
spec.props.content.items = spec.props.content.items // ['inline'] => [['emoji', 'hr', ...]]
|
|
85
87
|
// ['media'] => [['media']]
|
|
86
|
-
map(function (item) {
|
|
88
|
+
.map(function (item) {
|
|
87
89
|
return isString(item) ? Array.isArray(specs[item]) ? specs[item] : [item] : item;
|
|
88
90
|
}) // [['emoji', 'hr', 'inline_code']] => [['emoji', 'hr', ['text', { marks: {} }]]]
|
|
89
91
|
.map(function (item) {
|
|
@@ -178,7 +180,11 @@ export function validateAttrs(spec, value) {
|
|
|
178
180
|
return isInteger(value) && (isDefined(spec.minimum) ? spec.minimum <= value : true) && (isDefined(spec.maximum) ? spec.maximum >= value : true);
|
|
179
181
|
|
|
180
182
|
case 'string':
|
|
181
|
-
|
|
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);
|
|
182
188
|
|
|
183
189
|
case 'object':
|
|
184
190
|
return isPlainObject(value);
|
|
@@ -385,19 +391,19 @@ export function validator(nodes, marks, options) {
|
|
|
385
391
|
} // this checks for mark level attribute errors
|
|
386
392
|
// and propagates error code and message
|
|
387
393
|
else if (finalResult.marksValidationOutput && finalResult.marksValidationOutput.length) {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
394
|
+
return {
|
|
395
|
+
valid: false,
|
|
396
|
+
originalMark: mark,
|
|
397
|
+
errorCode: finalResult.marksValidationOutput[0].errorCode,
|
|
398
|
+
message: finalResult.marksValidationOutput[0].message
|
|
399
|
+
};
|
|
400
|
+
} else {
|
|
401
|
+
return {
|
|
402
|
+
valid: false,
|
|
403
|
+
originalMark: mark,
|
|
404
|
+
errorCode: 'INVALID_TYPE'
|
|
405
|
+
};
|
|
406
|
+
}
|
|
401
407
|
} else {
|
|
402
408
|
return {
|
|
403
409
|
valid: false,
|
package/dist/esm/version.json
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { BreakoutMarkAttrs, BreakoutMarkDefinition, CodeBlockDefinition, LayoutSectionDefinition } from '@atlaskit/adf-schema';
|
|
2
2
|
import { WithAppliedMark } from '../types';
|
|
3
|
-
export declare const breakout: (attrs: BreakoutMarkAttrs) => (maybeNode: CodeBlockDefinition | LayoutSectionDefinition) => WithAppliedMark<CodeBlockDefinition |
|
|
3
|
+
export declare const breakout: (attrs: BreakoutMarkAttrs) => (maybeNode: CodeBlockDefinition | LayoutSectionDefinition) => WithAppliedMark<CodeBlockDefinition | import("@atlaskit/adf-schema").LayoutSectionFullDefinition | import("@atlaskit/adf-schema").LayoutSectionWithSingleColumnDefinition, BreakoutMarkDefinition>;
|
|
@@ -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>;
|
package/dist/types/builders.d.ts
CHANGED
|
@@ -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';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -5,3 +5,4 @@ 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 { transformTextLinkCodeMarks } from './transforms/text-link-code-transform';
|