@atlaskit/adf-utils 19.14.0 → 19.15.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 +17 -0
- package/afm-jira/tsconfig.json +1 -5
- package/afm-post-office/tsconfig.json +1 -5
- package/dist/cjs/builders/utils/create-text-nodes.js +5 -0
- package/dist/cjs/builders/utils/is-duplicate-mark.js +5 -0
- package/dist/cjs/scrub/default-node-replacements.js +2 -0
- package/dist/cjs/scrub/scrub-adf.js +3 -0
- package/dist/cjs/scrub/scrub-content.js +10 -3
- package/dist/cjs/transforms/errors.js +4 -5
- package/dist/cjs/transforms/nested-table-transform.js +14 -10
- package/dist/cjs/transforms/nodes-missing-content-transform.js +2 -0
- package/dist/cjs/transforms.js +6 -0
- package/dist/cjs/traverse/map.js +2 -0
- package/dist/cjs/traverse/reduce.js +2 -0
- package/dist/cjs/traverse/traverse.js +3 -0
- package/dist/cjs/validator/utils.js +5 -0
- package/dist/cjs/validator/validator.js +130 -15
- package/dist/es2019/builders/utils/create-text-nodes.js +6 -0
- package/dist/es2019/builders/utils/is-duplicate-mark.js +5 -0
- package/dist/es2019/scrub/default-node-replacements.js +4 -0
- package/dist/es2019/scrub/scrub-adf.js +3 -0
- package/dist/es2019/scrub/scrub-content.js +7 -0
- package/dist/es2019/transforms/dedupe-marks-transform.js +2 -2
- package/dist/es2019/transforms/invalid-media-content-transform.js +1 -1
- package/dist/es2019/transforms/nested-table-transform.js +15 -11
- package/dist/es2019/transforms/nodes-missing-content-transform.js +2 -0
- package/dist/es2019/transforms.js +1 -1
- package/dist/es2019/traverse/map.js +3 -0
- package/dist/es2019/traverse/reduce.js +3 -0
- package/dist/es2019/traverse/traverse.js +3 -0
- package/dist/es2019/validator/utils.js +5 -0
- package/dist/es2019/validator/validator.js +139 -19
- package/dist/esm/builders/utils/create-text-nodes.js +6 -0
- package/dist/esm/builders/utils/is-duplicate-mark.js +5 -0
- package/dist/esm/scrub/default-node-replacements.js +2 -0
- package/dist/esm/scrub/scrub-adf.js +3 -0
- package/dist/esm/scrub/scrub-content.js +10 -3
- package/dist/esm/transforms/errors.js +4 -5
- package/dist/esm/transforms/nested-table-transform.js +13 -9
- package/dist/esm/transforms/nodes-missing-content-transform.js +2 -0
- package/dist/esm/transforms.js +1 -1
- package/dist/esm/traverse/map.js +3 -0
- package/dist/esm/traverse/reduce.js +3 -0
- package/dist/esm/traverse/traverse.js +3 -0
- package/dist/esm/validator/utils.js +5 -0
- package/dist/esm/validator/validator.js +131 -14
- package/dist/types/transforms/nested-table-transform.d.ts +1 -0
- package/dist/types/transforms.d.ts +1 -1
- package/dist/types-ts4.5/transforms/nested-table-transform.d.ts +1 -0
- package/dist/types-ts4.5/transforms.d.ts +1 -1
- package/package.json +1 -1
- package/tsconfig.json +0 -1
package/dist/esm/traverse/map.js
CHANGED
|
@@ -22,6 +22,9 @@ export function traverse(adf, visitors) {
|
|
|
22
22
|
node: undefined
|
|
23
23
|
}, visitors, 0, 0);
|
|
24
24
|
}
|
|
25
|
+
|
|
26
|
+
// Ignored via go/ees005
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
25
28
|
function traverseNode(adfNode, parent, visitors, index, depth) {
|
|
26
29
|
var visitor = visitors[adfNode.type] || visitors['any'];
|
|
27
30
|
var newNode = _objectSpread({}, adfNode);
|
|
@@ -19,7 +19,12 @@ export var isString = function isString(s) {
|
|
|
19
19
|
export var isPlainObject = function isPlainObject(x) {
|
|
20
20
|
return _typeof(x) === 'object' && x !== null && !Array.isArray(x);
|
|
21
21
|
};
|
|
22
|
+
|
|
23
|
+
// Ignored via go/ees005
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
25
|
export var copy = function copy(source, dest, key) {
|
|
26
|
+
// Ignored via go/ees005
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
28
|
dest[key] = source[key];
|
|
24
29
|
return dest;
|
|
25
30
|
};
|
|
@@ -4,14 +4,21 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
|
|
|
4
4
|
var _excluded = ["items"];
|
|
5
5
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
|
+
// Ignored via go/ees005
|
|
8
|
+
// eslint-disable-next-line import/no-namespace
|
|
7
9
|
import * as specs from './specs';
|
|
8
10
|
import { copy, isBoolean, isDefined, isInteger, isNumber, isPlainObject, isString, makeArray } from './utils';
|
|
9
11
|
import { validatorFnMap } from './rules';
|
|
12
|
+
|
|
13
|
+
// Ignored via go/ees005
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
15
|
function mapMarksItems(spec) {
|
|
11
16
|
var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (x) {
|
|
12
17
|
return x;
|
|
13
18
|
};
|
|
14
19
|
if (spec.props && spec.props.marks) {
|
|
20
|
+
// Ignored via go/ees005
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
15
22
|
var _ref = spec.props.marks,
|
|
16
23
|
items = _ref.items,
|
|
17
24
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -30,6 +37,9 @@ function mapMarksItems(spec) {
|
|
|
30
37
|
return spec;
|
|
31
38
|
}
|
|
32
39
|
}
|
|
40
|
+
|
|
41
|
+
// Ignored via go/ees005
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
43
|
var partitionObject = function partitionObject(obj, predicate) {
|
|
34
44
|
return Object.keys(obj).reduce(function (acc, key) {
|
|
35
45
|
var result = predicate(key, obj[key], obj);
|
|
@@ -43,13 +53,19 @@ var partitionObject = function partitionObject(obj, predicate) {
|
|
|
43
53
|
* We denormalised the spec to save bundle size.
|
|
44
54
|
*/
|
|
45
55
|
function createSpec(nodes, marks) {
|
|
56
|
+
// Ignored via go/ees005
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
46
58
|
return Object.keys(specs).reduce(function (newSpecs, k) {
|
|
59
|
+
// Ignored via go/ees005
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
61
|
var spec = _objectSpread({}, specs[k]);
|
|
48
62
|
if (spec.props) {
|
|
49
63
|
spec.props = _objectSpread({}, spec.props);
|
|
50
64
|
if (spec.props.content) {
|
|
51
65
|
// 'tableCell_content' => { type: 'array', items: [ ... ] }
|
|
52
66
|
if (isString(spec.props.content)) {
|
|
67
|
+
// Ignored via go/ees005
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
69
|
spec.props.content = specs[spec.props.content];
|
|
54
70
|
}
|
|
55
71
|
|
|
@@ -77,14 +93,27 @@ function createSpec(nodes, marks) {
|
|
|
77
93
|
// ['inline'] => [['emoji', 'hr', ...]]
|
|
78
94
|
// ['media'] => [['media']]
|
|
79
95
|
.map(function (item) {
|
|
80
|
-
return isString(item) ?
|
|
96
|
+
return isString(item) ?
|
|
97
|
+
// Ignored via go/ees005
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
|
+
Array.isArray(specs[item]) ?
|
|
100
|
+
// Ignored via go/ees005
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
102
|
+
specs[item] : [item] : item;
|
|
81
103
|
})
|
|
82
104
|
// [['emoji', 'hr', 'inline_code']] => [['emoji', 'hr', ['text', { marks: {} }]]]
|
|
83
105
|
.map(function (item) {
|
|
84
106
|
return item.map(function (subItem) {
|
|
85
|
-
return
|
|
86
|
-
|
|
87
|
-
|
|
107
|
+
return (
|
|
108
|
+
// Ignored via go/ees005
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
110
|
+
Array.isArray(specs[subItem]) ?
|
|
111
|
+
// Ignored via go/ees005
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
113
|
+
specs[subItem] : isString(subItem) ? subItem :
|
|
114
|
+
// Now `NoMark` produces `items: []`, should be fixed in generator
|
|
115
|
+
['text', subItem]
|
|
116
|
+
);
|
|
88
117
|
})
|
|
89
118
|
// Remove unsupported nodes & marks
|
|
90
119
|
// Filter nodes
|
|
@@ -122,6 +151,9 @@ function createSpec(nodes, marks) {
|
|
|
122
151
|
return newSpecs;
|
|
123
152
|
}, {});
|
|
124
153
|
}
|
|
154
|
+
|
|
155
|
+
// Ignored via go/ees005
|
|
156
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
125
157
|
function getOptionsForType(type, list) {
|
|
126
158
|
if (!list) {
|
|
127
159
|
return {};
|
|
@@ -151,7 +183,11 @@ export function validateAttrs(spec, value) {
|
|
|
151
183
|
if (isValidatorSpecAttrs(spec)) {
|
|
152
184
|
// If spec has ".props" it is ValidatorSpecAttrs and need to pipe back in recursively
|
|
153
185
|
var _partitionObject = partitionObject(spec.props, function (key, subSpec) {
|
|
154
|
-
return
|
|
186
|
+
return (
|
|
187
|
+
// Ignored via go/ees005
|
|
188
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
189
|
+
validateAttrs(subSpec, value[key])
|
|
190
|
+
);
|
|
155
191
|
}),
|
|
156
192
|
_partitionObject2 = _slicedToArray(_partitionObject, 2),
|
|
157
193
|
_ = _partitionObject2[0],
|
|
@@ -173,7 +209,13 @@ export function validateAttrs(spec, value) {
|
|
|
173
209
|
var validatorFnPassed = function validatorFnPassed(rule) {
|
|
174
210
|
return typeof value === 'string' && isDefined(validatorFnMap[rule]) && validatorFnMap[rule](value);
|
|
175
211
|
};
|
|
176
|
-
return isString(value) && (
|
|
212
|
+
return isString(value) && (
|
|
213
|
+
// Ignored via go/ees005
|
|
214
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
215
|
+
isDefined(spec.minLength) ? spec.minLength <= value.length : true) && (isDefined(spec.validatorFn) ? validatorFnPassed(spec.validatorFn) : true) && (
|
|
216
|
+
// Ignored via go/ees005
|
|
217
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
218
|
+
spec.pattern ? new RegExp(spec.pattern).test(value) : true);
|
|
177
219
|
case 'object':
|
|
178
220
|
return isPlainObject(value);
|
|
179
221
|
case 'array':
|
|
@@ -232,7 +274,10 @@ var invalidChildContent = function invalidChildContent(child, errorCallback, par
|
|
|
232
274
|
}, getUnsupportedOptions(parentSpec));
|
|
233
275
|
}
|
|
234
276
|
};
|
|
235
|
-
var unsupportedMarkContent = function unsupportedMarkContent(errorCode, mark, errorCallback, errorMessage
|
|
277
|
+
var unsupportedMarkContent = function unsupportedMarkContent(errorCode, mark, errorCallback, errorMessage
|
|
278
|
+
// Ignored via go/ees005
|
|
279
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
280
|
+
) {
|
|
236
281
|
var message = errorMessage || errorMessageFor(mark.type, 'unsupported mark');
|
|
237
282
|
if (!errorCallback) {
|
|
238
283
|
throw new Error(message);
|
|
@@ -248,7 +293,10 @@ var unsupportedMarkContent = function unsupportedMarkContent(errorCode, mark, er
|
|
|
248
293
|
});
|
|
249
294
|
}
|
|
250
295
|
};
|
|
251
|
-
var unsupportedNodeAttributesContent = function unsupportedNodeAttributesContent(entity, errorCode, invalidAttributes, message, errorCallback
|
|
296
|
+
var unsupportedNodeAttributesContent = function unsupportedNodeAttributesContent(entity, errorCode, invalidAttributes, message, errorCallback
|
|
297
|
+
// Ignored via go/ees005
|
|
298
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
299
|
+
) {
|
|
252
300
|
if (!errorCallback) {
|
|
253
301
|
throw new Error(message);
|
|
254
302
|
} else {
|
|
@@ -273,6 +321,8 @@ export function validator(nodes, marks, options) {
|
|
|
273
321
|
mode = _ref2$mode === void 0 ? 'strict' : _ref2$mode,
|
|
274
322
|
_ref2$allowPrivateAtt = _ref2.allowPrivateAttributes,
|
|
275
323
|
allowPrivateAttributes = _ref2$allowPrivateAtt === void 0 ? false : _ref2$allowPrivateAtt;
|
|
324
|
+
// Ignored via go/ees005
|
|
325
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
276
326
|
var validate = function validate(entity, errorCallback, allowed, parentSpec) {
|
|
277
327
|
var validationResult = validateNode(entity, errorCallback, allowed, parentSpec);
|
|
278
328
|
return {
|
|
@@ -323,6 +373,9 @@ export function validator(nodes, marks, options) {
|
|
|
323
373
|
};
|
|
324
374
|
};
|
|
325
375
|
return validate;
|
|
376
|
+
|
|
377
|
+
// Ignored via go/ees005
|
|
378
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
326
379
|
function marksValidationFor(validator, entity, errorCallback, newEntity, err) {
|
|
327
380
|
var validationResult;
|
|
328
381
|
if (validator.props && validator.props.marks) {
|
|
@@ -338,11 +391,16 @@ export function validator(nodes, marks, options) {
|
|
|
338
391
|
}
|
|
339
392
|
return validationResult;
|
|
340
393
|
}
|
|
394
|
+
// Ignored via go/ees005
|
|
395
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
341
396
|
function validatorFor(spec, typeOptions) {
|
|
342
397
|
return _objectSpread(_objectSpread(_objectSpread({}, spec), typeOptions), spec.props ? {
|
|
343
398
|
props: _objectSpread(_objectSpread({}, spec.props), typeOptions['props'] || {})
|
|
344
399
|
} : {});
|
|
345
400
|
}
|
|
401
|
+
|
|
402
|
+
// Ignored via go/ees005
|
|
403
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
346
404
|
function marksAfterValidation(entity, errorCallback, marksSet, validator) {
|
|
347
405
|
return entity.marks ? entity.marks.map(function (mark) {
|
|
348
406
|
var isAKnownMark = marks ? marks.indexOf(mark.type) > -1 : true;
|
|
@@ -382,11 +440,16 @@ export function validator(nodes, marks, options) {
|
|
|
382
440
|
}) : [];
|
|
383
441
|
}
|
|
384
442
|
function allowedMarksFor(validator) {
|
|
443
|
+
// Ignored via go/ees005
|
|
444
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
385
445
|
var _ref3 = validator.props.marks,
|
|
386
446
|
items = _ref3.items;
|
|
387
447
|
var marksSet = items.length ? Array.isArray(items[0]) ? items[0] : items : [];
|
|
388
448
|
return marksSet;
|
|
389
449
|
}
|
|
450
|
+
|
|
451
|
+
// Ignored via go/ees005
|
|
452
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
390
453
|
function marksForEntitySpecNotSupportingMarks(prevEntity, newEntity, errorCallback, err) {
|
|
391
454
|
var errorCode = 'REDUNDANT_MARKS';
|
|
392
455
|
var currentMarks = prevEntity.marks || [];
|
|
@@ -428,8 +491,13 @@ export function validator(nodes, marks, options) {
|
|
|
428
491
|
valid: true,
|
|
429
492
|
entity: prevEntity
|
|
430
493
|
};
|
|
494
|
+
// Ignored via go/ees005
|
|
495
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
431
496
|
if (validatorSpec.props.text) {
|
|
432
|
-
if (isDefined(prevEntity.text) &&
|
|
497
|
+
if (isDefined(prevEntity.text) &&
|
|
498
|
+
// Ignored via go/ees005
|
|
499
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
500
|
+
!validateAttrs(validatorSpec.props.text, prevEntity.text)) {
|
|
433
501
|
result = err('INVALID_TEXT', "'text' validation failed");
|
|
434
502
|
}
|
|
435
503
|
}
|
|
@@ -440,7 +508,11 @@ export function validator(nodes, marks, options) {
|
|
|
440
508
|
valid: true,
|
|
441
509
|
entity: prevEntity
|
|
442
510
|
};
|
|
511
|
+
// Ignored via go/ees005
|
|
512
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
443
513
|
if (validatorSpec.props.content && prevEntity.content) {
|
|
514
|
+
// Ignored via go/ees005
|
|
515
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
444
516
|
var _content = validatorSpec.props.content,
|
|
445
517
|
minItems = _content.minItems,
|
|
446
518
|
maxItems = _content.maxItems;
|
|
@@ -463,6 +535,8 @@ export function validator(nodes, marks, options) {
|
|
|
463
535
|
}
|
|
464
536
|
function invalidAttributesFor(validatorSpec, prevEntity) {
|
|
465
537
|
var invalidAttrs = [];
|
|
538
|
+
// Ignored via go/ees005
|
|
539
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
466
540
|
var validatorAttrs = {};
|
|
467
541
|
if (validatorSpec.props && validatorSpec.props.attrs) {
|
|
468
542
|
var attrOptions = makeArray(validatorSpec.props.attrs);
|
|
@@ -475,12 +549,16 @@ export function validator(nodes, marks, options) {
|
|
|
475
549
|
var attrOption = attrOptions[i];
|
|
476
550
|
if (attrOption && attrOption.props) {
|
|
477
551
|
var _partitionObject3 = partitionObject(attrOption.props, function (key, spec) {
|
|
552
|
+
// Ignored via go/ees005
|
|
553
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
478
554
|
var valueToValidate = prevEntity.attrs[key];
|
|
479
555
|
return validateAttrs(spec, valueToValidate);
|
|
480
556
|
});
|
|
481
557
|
var _partitionObject4 = _slicedToArray(_partitionObject3, 2);
|
|
482
558
|
invalidAttrs = _partitionObject4[1];
|
|
483
559
|
}
|
|
560
|
+
// Ignored via go/ees005
|
|
561
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
484
562
|
validatorAttrs = attrOption;
|
|
485
563
|
if (!invalidAttrs.length) {
|
|
486
564
|
break;
|
|
@@ -492,6 +570,9 @@ export function validator(nodes, marks, options) {
|
|
|
492
570
|
validatorAttrs: validatorAttrs
|
|
493
571
|
};
|
|
494
572
|
}
|
|
573
|
+
|
|
574
|
+
// Ignored via go/ees005
|
|
575
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
495
576
|
function attributesValidationFor(validatorSpec, prevEntity, newEntity, isMark, errorCallback) {
|
|
496
577
|
var validatorSpecAllowsAttributes = validatorSpec.props && validatorSpec.props.attrs;
|
|
497
578
|
if (prevEntity.attrs) {
|
|
@@ -518,13 +599,19 @@ export function validator(nodes, marks, options) {
|
|
|
518
599
|
entity: prevEntity
|
|
519
600
|
};
|
|
520
601
|
}
|
|
521
|
-
function validateAttributes(validatorSpec, prevEntity,
|
|
602
|
+
function validateAttributes(validatorSpec, prevEntity,
|
|
603
|
+
// Ignored via go/ees005
|
|
604
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
605
|
+
attributes) {
|
|
522
606
|
var invalidAttributesResult = invalidAttributesFor(validatorSpec, prevEntity);
|
|
523
607
|
var invalidAttrs = invalidAttributesResult.invalidAttrs;
|
|
524
608
|
var validatorAttrs = invalidAttributesResult.validatorAttrs;
|
|
525
609
|
var attrs = Object.keys(attributes).filter(function (k) {
|
|
526
610
|
return !(allowPrivateAttributes && k.startsWith('__'));
|
|
527
611
|
});
|
|
612
|
+
|
|
613
|
+
// Ignored via go/ees005
|
|
614
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
528
615
|
var redundantAttrs = attrs.filter(function (a) {
|
|
529
616
|
return !validatorAttrs.props[a];
|
|
530
617
|
});
|
|
@@ -536,6 +623,9 @@ export function validator(nodes, marks, options) {
|
|
|
536
623
|
redundantAttrs: redundantAttrs
|
|
537
624
|
};
|
|
538
625
|
}
|
|
626
|
+
|
|
627
|
+
// Ignored via go/ees005
|
|
628
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
539
629
|
function handleUnsupportedNodeAttributes(prevEntity, newEntity, invalidAttrs, redundantAttrs, errorCallback) {
|
|
540
630
|
var attr = invalidAttrs.concat(redundantAttrs);
|
|
541
631
|
var result = {
|
|
@@ -571,7 +661,10 @@ export function validator(nodes, marks, options) {
|
|
|
571
661
|
marksValidationOutput: [markValidationResult]
|
|
572
662
|
};
|
|
573
663
|
}
|
|
574
|
-
function handleNoAttibutesAllowedInSpecForMark(prevEntity,
|
|
664
|
+
function handleNoAttibutesAllowedInSpecForMark(prevEntity,
|
|
665
|
+
// Ignored via go/ees005
|
|
666
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
667
|
+
attributes) {
|
|
575
668
|
var message = errorMessageFor('redundant attributes found', Object.keys(attributes).join(', '));
|
|
576
669
|
var errorCode = 'REDUNDANT_ATTRIBUTES';
|
|
577
670
|
var markValidationResult = {
|
|
@@ -585,8 +678,12 @@ export function validator(nodes, marks, options) {
|
|
|
585
678
|
marksValidationOutput: [markValidationResult]
|
|
586
679
|
};
|
|
587
680
|
}
|
|
681
|
+
|
|
682
|
+
// Ignored via go/ees005
|
|
683
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
588
684
|
function wrapUnSupportedNodeAttributes(prevEntity, newEntity, invalidAttrs, errorCode, message, errorCallback) {
|
|
589
685
|
var invalidValues = {};
|
|
686
|
+
// eslint-disable-next-line guard-for-in
|
|
590
687
|
for (var invalidAttr in invalidAttrs) {
|
|
591
688
|
invalidValues[invalidAttrs[invalidAttr]] = prevEntity.attrs && prevEntity.attrs[invalidAttrs[invalidAttr]];
|
|
592
689
|
if (newEntity.attrs) {
|
|
@@ -614,13 +711,20 @@ export function validator(nodes, marks, options) {
|
|
|
614
711
|
return [unsupportedNodeAttributeValues];
|
|
615
712
|
}
|
|
616
713
|
}
|
|
714
|
+
|
|
715
|
+
// Ignored via go/ees005
|
|
716
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
617
717
|
function extraPropsValidationFor(validatorSpec, prevEntity, err, newEntity, type) {
|
|
618
718
|
var result = {
|
|
619
719
|
valid: true,
|
|
620
720
|
entity: prevEntity
|
|
621
721
|
};
|
|
622
722
|
var _partitionObject5 = partitionObject(prevEntity, function (k) {
|
|
623
|
-
return
|
|
723
|
+
return (
|
|
724
|
+
// Ignored via go/ees005
|
|
725
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
726
|
+
isDefined(validatorSpec.props[k])
|
|
727
|
+
);
|
|
624
728
|
}),
|
|
625
729
|
_partitionObject6 = _slicedToArray(_partitionObject5, 2),
|
|
626
730
|
requiredProps = _partitionObject6[0],
|
|
@@ -643,7 +747,13 @@ export function validator(nodes, marks, options) {
|
|
|
643
747
|
}
|
|
644
748
|
return result;
|
|
645
749
|
}
|
|
646
|
-
|
|
750
|
+
|
|
751
|
+
// Ignored via go/ees005
|
|
752
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
753
|
+
function specBasedValidationFor(spec,
|
|
754
|
+
// Ignored via go/ees005
|
|
755
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
756
|
+
typeOptions, prevEntity, err, newEntity, type, errorCallback, isMark) {
|
|
647
757
|
var specBasedValidationResult = {
|
|
648
758
|
hasValidated: false
|
|
649
759
|
};
|
|
@@ -736,6 +846,8 @@ export function validator(nodes, marks, options) {
|
|
|
736
846
|
if (validatorSpec.props.content) {
|
|
737
847
|
var contentValidatorSpec = validatorSpec.props.content;
|
|
738
848
|
if (prevEntity.content) {
|
|
849
|
+
// Ignored via go/ees005
|
|
850
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
739
851
|
var validateChildNode = function validateChildNode(child, index) {
|
|
740
852
|
if (child === undefined) {
|
|
741
853
|
return child;
|
|
@@ -747,12 +859,17 @@ export function validator(nodes, marks, options) {
|
|
|
747
859
|
var validMarks = marksValidationOutput.filter(function (mark) {
|
|
748
860
|
return mark.valid;
|
|
749
861
|
});
|
|
862
|
+
// Ignored via go/ees005
|
|
863
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
750
864
|
var finalMarks = marksValidationOutput.map(function (mr) {
|
|
751
865
|
if (mr.valid) {
|
|
752
866
|
return mr.newMark;
|
|
753
867
|
} else {
|
|
754
868
|
if (validMarks.length || isLastValidationSpec || isParentTupleLike || mr.errorCode === 'INVALID_TYPE' || mr.errorCode === 'INVALID_CONTENT' || mr.errorCode === 'REDUNDANT_ATTRIBUTES' || mr.errorCode === 'INVALID_ATTRIBUTES') {
|
|
755
|
-
return unsupportedMarkContent(
|
|
869
|
+
return unsupportedMarkContent(
|
|
870
|
+
// Ignored via go/ees005
|
|
871
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
872
|
+
mr.errorCode, mr.originalMark, errorCallback, mr.message);
|
|
756
873
|
}
|
|
757
874
|
return;
|
|
758
875
|
}
|
|
@@ -4,6 +4,6 @@ export { transformDedupeMarks } from './transforms/dedupe-marks-transform';
|
|
|
4
4
|
export { transformNodesMissingContent } from './transforms/nodes-missing-content-transform';
|
|
5
5
|
export { transformIndentationMarks } from './transforms/indentation-marks-transform';
|
|
6
6
|
export { transformInvalidMediaContent } from './transforms/invalid-media-content-transform';
|
|
7
|
-
export { transformNestedTablesIncomingDocument } from './transforms/nested-table-transform';
|
|
7
|
+
export { transformNestedTablesIncomingDocument, isNestedTableExtension } from './transforms/nested-table-transform';
|
|
8
8
|
export { transformNestedTableNodeOutgoingDocument } from './transforms/nested-table-transform';
|
|
9
9
|
export { NodeNestingTransformError } from './transforms/errors';
|
|
@@ -4,6 +4,6 @@ export { transformDedupeMarks } from './transforms/dedupe-marks-transform';
|
|
|
4
4
|
export { transformNodesMissingContent } from './transforms/nodes-missing-content-transform';
|
|
5
5
|
export { transformIndentationMarks } from './transforms/indentation-marks-transform';
|
|
6
6
|
export { transformInvalidMediaContent } from './transforms/invalid-media-content-transform';
|
|
7
|
-
export { transformNestedTablesIncomingDocument } from './transforms/nested-table-transform';
|
|
7
|
+
export { transformNestedTablesIncomingDocument, isNestedTableExtension } from './transforms/nested-table-transform';
|
|
8
8
|
export { transformNestedTableNodeOutgoingDocument } from './transforms/nested-table-transform';
|
|
9
9
|
export { NodeNestingTransformError } from './transforms/errors';
|
package/package.json
CHANGED