@atlaskit/adf-utils 19.21.1 → 19.21.2
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 +9 -0
- package/afm-cc/tsconfig.json +2 -2
- package/dist/cjs/scrub/scrub-content.js +2 -1
- package/dist/es2019/scrub/scrub-content.js +2 -1
- package/dist/esm/scrub/scrub-content.js +2 -1
- package/dist/types/builders/types.d.ts +2 -2
- package/dist/types/transforms/dedupe-marks-transform.d.ts +2 -2
- package/dist/types/transforms/indentation-marks-transform.d.ts +1 -1
- package/dist/types/transforms/nested-table-transform.d.ts +2 -2
- package/dist/types/transforms/nodes-missing-content-transform.d.ts +1 -1
- package/dist/types/types/index.d.ts +3 -3
- package/dist/types/types/validatorTypes.d.ts +52 -52
- package/dist/types-ts4.5/builders/types.d.ts +2 -2
- package/dist/types-ts4.5/transforms/dedupe-marks-transform.d.ts +2 -2
- package/dist/types-ts4.5/transforms/indentation-marks-transform.d.ts +1 -1
- package/dist/types-ts4.5/transforms/nested-table-transform.d.ts +2 -2
- package/dist/types-ts4.5/transforms/nodes-missing-content-transform.d.ts +1 -1
- package/dist/types-ts4.5/types/index.d.ts +3 -3
- package/dist/types-ts4.5/types/validatorTypes.d.ts +52 -52
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/adf-utils
|
|
2
2
|
|
|
3
|
+
## 19.21.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`3d63d4f953f04`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3d63d4f953f04) -
|
|
8
|
+
EDITOR-1171 Unifying adf-utils behaviours for blockTaskItem and taskItem
|
|
9
|
+
- [`0fdcb6f2f96fd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0fdcb6f2f96fd) -
|
|
10
|
+
Sorted type and interface props to improve Atlaskit docs
|
|
11
|
+
|
|
3
12
|
## 19.21.1
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/afm-cc/tsconfig.json
CHANGED
|
@@ -31,7 +31,8 @@ var BYPASS_ATTR_LIST = {
|
|
|
31
31
|
tableCell: ['background', 'colspan', 'colwidth', 'defaultMarks', 'rowspan'],
|
|
32
32
|
tableHeader: ['background', 'colspan', 'colwidth', 'defaultMarks', 'rowspan'],
|
|
33
33
|
tableRow: ['defaultMarks'],
|
|
34
|
-
taskItem: ['state']
|
|
34
|
+
taskItem: ['state'],
|
|
35
|
+
blockTaskItem: ['state']
|
|
35
36
|
};
|
|
36
37
|
// Ignored via go/ees005
|
|
37
38
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -18,7 +18,8 @@ const BYPASS_ATTR_LIST = {
|
|
|
18
18
|
tableCell: ['background', 'colspan', 'colwidth', 'defaultMarks', 'rowspan'],
|
|
19
19
|
tableHeader: ['background', 'colspan', 'colwidth', 'defaultMarks', 'rowspan'],
|
|
20
20
|
tableRow: ['defaultMarks'],
|
|
21
|
-
taskItem: ['state']
|
|
21
|
+
taskItem: ['state'],
|
|
22
|
+
blockTaskItem: ['state']
|
|
22
23
|
};
|
|
23
24
|
// Ignored via go/ees005
|
|
24
25
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -24,7 +24,8 @@ var BYPASS_ATTR_LIST = {
|
|
|
24
24
|
tableCell: ['background', 'colspan', 'colwidth', 'defaultMarks', 'rowspan'],
|
|
25
25
|
tableHeader: ['background', 'colspan', 'colwidth', 'defaultMarks', 'rowspan'],
|
|
26
26
|
tableRow: ['defaultMarks'],
|
|
27
|
-
taskItem: ['state']
|
|
27
|
+
taskItem: ['state'],
|
|
28
|
+
blockTaskItem: ['state']
|
|
28
29
|
};
|
|
29
30
|
// Ignored via go/ees005
|
|
30
31
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type ADFEntity, type ADFEntityMark } from '../types';
|
|
2
2
|
interface TransformDedupeMarksResult {
|
|
3
|
-
transformedAdf: ADFEntity;
|
|
4
|
-
isTransformed: boolean;
|
|
5
3
|
discardedMarks: ADFEntityMark[];
|
|
4
|
+
isTransformed: boolean;
|
|
5
|
+
transformedAdf: ADFEntity;
|
|
6
6
|
}
|
|
7
7
|
export declare const transformDedupeMarks: (adf: ADFEntity) => TransformDedupeMarksResult;
|
|
8
8
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ADFEntity } from '../types';
|
|
2
2
|
interface TransformIndentationMarksResult {
|
|
3
|
-
transformedAdf: ADFEntity;
|
|
4
3
|
isTransformed: boolean;
|
|
4
|
+
transformedAdf: ADFEntity;
|
|
5
5
|
}
|
|
6
6
|
export declare const transformIndentationMarks: (adf: ADFEntity) => TransformIndentationMarksResult;
|
|
7
7
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ADFEntity } from '../types';
|
|
2
2
|
export declare const isNestedTableExtension: (extensionNode: ADFEntity) => boolean;
|
|
3
3
|
export declare const transformNestedTablesIncomingDocument: (adf: ADFEntity, options?: {
|
|
4
|
-
environment?: "renderer" | "editor";
|
|
5
4
|
disableNestedRendererTreatment?: boolean;
|
|
5
|
+
environment?: "renderer" | "editor";
|
|
6
6
|
}) => {
|
|
7
|
-
transformedAdf: ADFEntity;
|
|
8
7
|
isTransformed: boolean;
|
|
8
|
+
transformedAdf: ADFEntity;
|
|
9
9
|
};
|
|
10
10
|
export declare const transformNestedTableNodeOutgoingDocument: (tableCellNode: ADFEntity) => ADFEntity;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ADFEntity } from '../types';
|
|
2
2
|
interface TransformNodesMissingContentResult {
|
|
3
|
-
transformedAdf: ADFEntity;
|
|
4
3
|
isTransformed: boolean;
|
|
4
|
+
transformedAdf: ADFEntity;
|
|
5
5
|
}
|
|
6
6
|
export declare const transformNodesMissingContent: (adf: ADFEntity) => TransformNodesMissingContentResult;
|
|
7
7
|
export {};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
export interface ADFEntityMark {
|
|
2
|
-
type: string;
|
|
3
2
|
attrs?: {
|
|
4
3
|
[name: string]: any;
|
|
5
4
|
};
|
|
5
|
+
type: string;
|
|
6
6
|
}
|
|
7
7
|
export interface ADFEntity {
|
|
8
|
-
|
|
8
|
+
[key: string]: any;
|
|
9
9
|
attrs?: {
|
|
10
10
|
[name: string]: any;
|
|
11
11
|
};
|
|
12
12
|
content?: Array<ADFEntity | undefined>;
|
|
13
13
|
marks?: Array<ADFEntityMark>;
|
|
14
14
|
text?: string;
|
|
15
|
-
|
|
15
|
+
type: string;
|
|
16
16
|
}
|
|
17
17
|
export type Visitor = (node: ADFEntity, parent: EntityParent, index: number, depth: number) => ADFEntity | false | undefined | void;
|
|
18
18
|
export type VisitorCollection = {
|
|
@@ -1,105 +1,95 @@
|
|
|
1
1
|
import type { ADFEntity, ADFEntityMark } from '../types';
|
|
2
2
|
export interface MarkValidationResult {
|
|
3
|
-
valid: boolean;
|
|
4
|
-
originalMark: ADFEntityMark;
|
|
5
|
-
newMark?: ADFEntityMark;
|
|
6
3
|
errorCode?: ValidationError['code'];
|
|
7
4
|
message?: string;
|
|
5
|
+
newMark?: ADFEntityMark;
|
|
6
|
+
originalMark: ADFEntityMark;
|
|
7
|
+
valid: boolean;
|
|
8
8
|
}
|
|
9
9
|
export interface Output {
|
|
10
|
-
valid: boolean;
|
|
11
10
|
entity?: ADFEntity;
|
|
11
|
+
valid: boolean;
|
|
12
12
|
}
|
|
13
13
|
export interface NodeValidationResult {
|
|
14
|
-
valid: boolean;
|
|
15
14
|
entity?: ADFEntity;
|
|
16
15
|
marksValidationOutput?: MarkValidationResult[];
|
|
16
|
+
valid: boolean;
|
|
17
17
|
}
|
|
18
18
|
export interface ValidatorContent {
|
|
19
|
-
type: 'array';
|
|
20
|
-
items: Array<string | Array<string>>;
|
|
21
|
-
minItems?: number;
|
|
22
|
-
maxItems?: number;
|
|
23
|
-
optional?: boolean;
|
|
24
19
|
allowUnsupportedBlock: boolean;
|
|
25
20
|
allowUnsupportedInline: boolean;
|
|
26
21
|
isTupleLike?: boolean;
|
|
22
|
+
items: Array<string | Array<string>>;
|
|
23
|
+
maxItems?: number;
|
|
24
|
+
minItems?: number;
|
|
25
|
+
optional?: boolean;
|
|
26
|
+
type: 'array';
|
|
27
27
|
}
|
|
28
28
|
export type AttributesSpec = {
|
|
29
|
-
type: 'number';
|
|
30
|
-
optional?: boolean;
|
|
31
|
-
minimum: number;
|
|
32
29
|
maximum: number;
|
|
33
|
-
} | {
|
|
34
|
-
type: 'integer';
|
|
35
|
-
optional?: boolean;
|
|
36
30
|
minimum: number;
|
|
37
|
-
|
|
31
|
+
optional?: boolean;
|
|
32
|
+
type: 'number';
|
|
38
33
|
} | {
|
|
39
|
-
|
|
34
|
+
maximum: number;
|
|
35
|
+
minimum: number;
|
|
40
36
|
optional?: boolean;
|
|
37
|
+
type: 'integer';
|
|
41
38
|
} | {
|
|
42
|
-
type: 'string';
|
|
43
39
|
optional?: boolean;
|
|
40
|
+
type: 'boolean';
|
|
41
|
+
} | {
|
|
44
42
|
minLength?: number;
|
|
43
|
+
optional?: boolean;
|
|
45
44
|
pattern?: RegExp;
|
|
45
|
+
type: 'string';
|
|
46
46
|
validatorFn?: string;
|
|
47
47
|
} | {
|
|
48
|
+
optional?: boolean;
|
|
48
49
|
type: 'enum';
|
|
49
50
|
values: Array<string>;
|
|
50
|
-
optional?: boolean;
|
|
51
51
|
} | {
|
|
52
|
-
type: 'object';
|
|
53
52
|
optional?: boolean;
|
|
53
|
+
type: 'object';
|
|
54
54
|
} | {
|
|
55
|
-
|
|
55
|
+
isTupleLike?: boolean;
|
|
56
56
|
items: Array<AttributesSpec>;
|
|
57
|
-
optional?: boolean;
|
|
58
|
-
minItems?: number;
|
|
59
57
|
maxItems?: number;
|
|
60
|
-
|
|
58
|
+
minItems?: number;
|
|
59
|
+
optional?: boolean;
|
|
60
|
+
type: 'array';
|
|
61
61
|
} | ValidatorSpecAttrs;
|
|
62
62
|
export interface ValidatorSpecAttrs {
|
|
63
|
+
optional?: boolean;
|
|
63
64
|
props: {
|
|
64
65
|
[key: string]: AttributesSpec;
|
|
65
66
|
};
|
|
66
|
-
optional?: boolean;
|
|
67
67
|
}
|
|
68
68
|
export interface ValidatorSpec {
|
|
69
|
+
maxItems?: number;
|
|
70
|
+
minItems?: number;
|
|
69
71
|
props?: {
|
|
70
|
-
type?: {
|
|
71
|
-
type: 'enum';
|
|
72
|
-
values: Array<string>;
|
|
73
|
-
};
|
|
74
72
|
attrs?: ValidatorSpecAttrs;
|
|
75
73
|
content?: ValidatorContent;
|
|
76
|
-
text?: AttributesSpec;
|
|
77
74
|
marks?: {
|
|
78
|
-
type: 'array';
|
|
79
75
|
items: Array<Array<string>>;
|
|
80
76
|
maxItems?: number;
|
|
81
77
|
optional?: boolean;
|
|
78
|
+
type: 'array';
|
|
79
|
+
};
|
|
80
|
+
text?: AttributesSpec;
|
|
81
|
+
type?: {
|
|
82
|
+
type: 'enum';
|
|
83
|
+
values: Array<string>;
|
|
82
84
|
};
|
|
83
85
|
};
|
|
84
|
-
minItems?: number;
|
|
85
|
-
maxItems?: number;
|
|
86
86
|
required?: Array<string>;
|
|
87
87
|
}
|
|
88
88
|
export interface ValidationErrorMap {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
};
|
|
92
|
-
REDUNDANT_PROPERTIES: {
|
|
93
|
-
props: Array<string>;
|
|
94
|
-
};
|
|
95
|
-
REDUNDANT_ATTRIBUTES: {
|
|
89
|
+
DEPRECATED: never;
|
|
90
|
+
INVALID_ATTRIBUTES: {
|
|
96
91
|
attrs: Array<string>;
|
|
97
92
|
};
|
|
98
|
-
REDUNDANT_MARKS: {
|
|
99
|
-
marks: Array<string>;
|
|
100
|
-
};
|
|
101
|
-
INVALID_TYPE: never;
|
|
102
|
-
INVALID_TEXT: never;
|
|
103
93
|
INVALID_CONTENT: {
|
|
104
94
|
parentType?: string;
|
|
105
95
|
};
|
|
@@ -108,13 +98,23 @@ export interface ValidationErrorMap {
|
|
|
108
98
|
requiredLength: number;
|
|
109
99
|
type: RequiredContentLength;
|
|
110
100
|
};
|
|
111
|
-
|
|
101
|
+
INVALID_TEXT: never;
|
|
102
|
+
INVALID_TYPE: never;
|
|
103
|
+
MISSING_PROPERTIES: {
|
|
104
|
+
props: Array<string>;
|
|
105
|
+
};
|
|
106
|
+
REDUNDANT_ATTRIBUTES: {
|
|
112
107
|
attrs: Array<string>;
|
|
113
108
|
};
|
|
109
|
+
REDUNDANT_MARKS: {
|
|
110
|
+
marks: Array<string>;
|
|
111
|
+
};
|
|
112
|
+
REDUNDANT_PROPERTIES: {
|
|
113
|
+
props: Array<string>;
|
|
114
|
+
};
|
|
114
115
|
UNSUPPORTED_ATTRIBUTES: {
|
|
115
116
|
attrs: Array<string>;
|
|
116
117
|
};
|
|
117
|
-
DEPRECATED: never;
|
|
118
118
|
}
|
|
119
119
|
export type RequiredContentLength = 'minimum' | 'maximum';
|
|
120
120
|
export type Content = Array<string | [string, object] | Array<string>>;
|
|
@@ -127,8 +127,8 @@ export interface ValidationError {
|
|
|
127
127
|
export type ErrorCallback = (entity: ADFEntity, error: ValidationError, options: ErrorCallbackOptions) => ADFEntity | undefined;
|
|
128
128
|
export type ValidationMode = 'strict' | 'loose';
|
|
129
129
|
export interface ValidationOptions {
|
|
130
|
-
mode?: ValidationMode;
|
|
131
130
|
allowPrivateAttributes?: boolean;
|
|
131
|
+
mode?: ValidationMode;
|
|
132
132
|
}
|
|
133
133
|
export interface SpecValidatorResult {
|
|
134
134
|
hasValidated: boolean;
|
|
@@ -136,10 +136,10 @@ export interface SpecValidatorResult {
|
|
|
136
136
|
}
|
|
137
137
|
export type Err = <T extends ValidationErrorType>(code: T, msg: string, meta?: T extends keyof ValidationErrorMap ? ValidationErrorMap[T] : never) => NodeValidationResult;
|
|
138
138
|
export interface ErrorCallbackOptions {
|
|
139
|
-
|
|
140
|
-
isMark?: any;
|
|
139
|
+
allowNestedTables?: boolean;
|
|
141
140
|
allowUnsupportedBlock?: boolean;
|
|
142
141
|
allowUnsupportedInline?: boolean;
|
|
143
|
-
|
|
142
|
+
isMark?: any;
|
|
143
|
+
isNodeAttribute?: boolean;
|
|
144
144
|
}
|
|
145
145
|
export type Validate = (entity: ADFEntity, errorCallback?: ErrorCallback, allowed?: Content, parentSpec?: ValidatorSpec) => Output;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type ADFEntity, type ADFEntityMark } from '../types';
|
|
2
2
|
interface TransformDedupeMarksResult {
|
|
3
|
-
transformedAdf: ADFEntity;
|
|
4
|
-
isTransformed: boolean;
|
|
5
3
|
discardedMarks: ADFEntityMark[];
|
|
4
|
+
isTransformed: boolean;
|
|
5
|
+
transformedAdf: ADFEntity;
|
|
6
6
|
}
|
|
7
7
|
export declare const transformDedupeMarks: (adf: ADFEntity) => TransformDedupeMarksResult;
|
|
8
8
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ADFEntity } from '../types';
|
|
2
2
|
interface TransformIndentationMarksResult {
|
|
3
|
-
transformedAdf: ADFEntity;
|
|
4
3
|
isTransformed: boolean;
|
|
4
|
+
transformedAdf: ADFEntity;
|
|
5
5
|
}
|
|
6
6
|
export declare const transformIndentationMarks: (adf: ADFEntity) => TransformIndentationMarksResult;
|
|
7
7
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ADFEntity } from '../types';
|
|
2
2
|
export declare const isNestedTableExtension: (extensionNode: ADFEntity) => boolean;
|
|
3
3
|
export declare const transformNestedTablesIncomingDocument: (adf: ADFEntity, options?: {
|
|
4
|
-
environment?: "renderer" | "editor";
|
|
5
4
|
disableNestedRendererTreatment?: boolean;
|
|
5
|
+
environment?: "renderer" | "editor";
|
|
6
6
|
}) => {
|
|
7
|
-
transformedAdf: ADFEntity;
|
|
8
7
|
isTransformed: boolean;
|
|
8
|
+
transformedAdf: ADFEntity;
|
|
9
9
|
};
|
|
10
10
|
export declare const transformNestedTableNodeOutgoingDocument: (tableCellNode: ADFEntity) => ADFEntity;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ADFEntity } from '../types';
|
|
2
2
|
interface TransformNodesMissingContentResult {
|
|
3
|
-
transformedAdf: ADFEntity;
|
|
4
3
|
isTransformed: boolean;
|
|
4
|
+
transformedAdf: ADFEntity;
|
|
5
5
|
}
|
|
6
6
|
export declare const transformNodesMissingContent: (adf: ADFEntity) => TransformNodesMissingContentResult;
|
|
7
7
|
export {};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
export interface ADFEntityMark {
|
|
2
|
-
type: string;
|
|
3
2
|
attrs?: {
|
|
4
3
|
[name: string]: any;
|
|
5
4
|
};
|
|
5
|
+
type: string;
|
|
6
6
|
}
|
|
7
7
|
export interface ADFEntity {
|
|
8
|
-
|
|
8
|
+
[key: string]: any;
|
|
9
9
|
attrs?: {
|
|
10
10
|
[name: string]: any;
|
|
11
11
|
};
|
|
12
12
|
content?: Array<ADFEntity | undefined>;
|
|
13
13
|
marks?: Array<ADFEntityMark>;
|
|
14
14
|
text?: string;
|
|
15
|
-
|
|
15
|
+
type: string;
|
|
16
16
|
}
|
|
17
17
|
export type Visitor = (node: ADFEntity, parent: EntityParent, index: number, depth: number) => ADFEntity | false | undefined | void;
|
|
18
18
|
export type VisitorCollection = {
|
|
@@ -1,105 +1,95 @@
|
|
|
1
1
|
import type { ADFEntity, ADFEntityMark } from '../types';
|
|
2
2
|
export interface MarkValidationResult {
|
|
3
|
-
valid: boolean;
|
|
4
|
-
originalMark: ADFEntityMark;
|
|
5
|
-
newMark?: ADFEntityMark;
|
|
6
3
|
errorCode?: ValidationError['code'];
|
|
7
4
|
message?: string;
|
|
5
|
+
newMark?: ADFEntityMark;
|
|
6
|
+
originalMark: ADFEntityMark;
|
|
7
|
+
valid: boolean;
|
|
8
8
|
}
|
|
9
9
|
export interface Output {
|
|
10
|
-
valid: boolean;
|
|
11
10
|
entity?: ADFEntity;
|
|
11
|
+
valid: boolean;
|
|
12
12
|
}
|
|
13
13
|
export interface NodeValidationResult {
|
|
14
|
-
valid: boolean;
|
|
15
14
|
entity?: ADFEntity;
|
|
16
15
|
marksValidationOutput?: MarkValidationResult[];
|
|
16
|
+
valid: boolean;
|
|
17
17
|
}
|
|
18
18
|
export interface ValidatorContent {
|
|
19
|
-
type: 'array';
|
|
20
|
-
items: Array<string | Array<string>>;
|
|
21
|
-
minItems?: number;
|
|
22
|
-
maxItems?: number;
|
|
23
|
-
optional?: boolean;
|
|
24
19
|
allowUnsupportedBlock: boolean;
|
|
25
20
|
allowUnsupportedInline: boolean;
|
|
26
21
|
isTupleLike?: boolean;
|
|
22
|
+
items: Array<string | Array<string>>;
|
|
23
|
+
maxItems?: number;
|
|
24
|
+
minItems?: number;
|
|
25
|
+
optional?: boolean;
|
|
26
|
+
type: 'array';
|
|
27
27
|
}
|
|
28
28
|
export type AttributesSpec = {
|
|
29
|
-
type: 'number';
|
|
30
|
-
optional?: boolean;
|
|
31
|
-
minimum: number;
|
|
32
29
|
maximum: number;
|
|
33
|
-
} | {
|
|
34
|
-
type: 'integer';
|
|
35
|
-
optional?: boolean;
|
|
36
30
|
minimum: number;
|
|
37
|
-
|
|
31
|
+
optional?: boolean;
|
|
32
|
+
type: 'number';
|
|
38
33
|
} | {
|
|
39
|
-
|
|
34
|
+
maximum: number;
|
|
35
|
+
minimum: number;
|
|
40
36
|
optional?: boolean;
|
|
37
|
+
type: 'integer';
|
|
41
38
|
} | {
|
|
42
|
-
type: 'string';
|
|
43
39
|
optional?: boolean;
|
|
40
|
+
type: 'boolean';
|
|
41
|
+
} | {
|
|
44
42
|
minLength?: number;
|
|
43
|
+
optional?: boolean;
|
|
45
44
|
pattern?: RegExp;
|
|
45
|
+
type: 'string';
|
|
46
46
|
validatorFn?: string;
|
|
47
47
|
} | {
|
|
48
|
+
optional?: boolean;
|
|
48
49
|
type: 'enum';
|
|
49
50
|
values: Array<string>;
|
|
50
|
-
optional?: boolean;
|
|
51
51
|
} | {
|
|
52
|
-
type: 'object';
|
|
53
52
|
optional?: boolean;
|
|
53
|
+
type: 'object';
|
|
54
54
|
} | {
|
|
55
|
-
|
|
55
|
+
isTupleLike?: boolean;
|
|
56
56
|
items: Array<AttributesSpec>;
|
|
57
|
-
optional?: boolean;
|
|
58
|
-
minItems?: number;
|
|
59
57
|
maxItems?: number;
|
|
60
|
-
|
|
58
|
+
minItems?: number;
|
|
59
|
+
optional?: boolean;
|
|
60
|
+
type: 'array';
|
|
61
61
|
} | ValidatorSpecAttrs;
|
|
62
62
|
export interface ValidatorSpecAttrs {
|
|
63
|
+
optional?: boolean;
|
|
63
64
|
props: {
|
|
64
65
|
[key: string]: AttributesSpec;
|
|
65
66
|
};
|
|
66
|
-
optional?: boolean;
|
|
67
67
|
}
|
|
68
68
|
export interface ValidatorSpec {
|
|
69
|
+
maxItems?: number;
|
|
70
|
+
minItems?: number;
|
|
69
71
|
props?: {
|
|
70
|
-
type?: {
|
|
71
|
-
type: 'enum';
|
|
72
|
-
values: Array<string>;
|
|
73
|
-
};
|
|
74
72
|
attrs?: ValidatorSpecAttrs;
|
|
75
73
|
content?: ValidatorContent;
|
|
76
|
-
text?: AttributesSpec;
|
|
77
74
|
marks?: {
|
|
78
|
-
type: 'array';
|
|
79
75
|
items: Array<Array<string>>;
|
|
80
76
|
maxItems?: number;
|
|
81
77
|
optional?: boolean;
|
|
78
|
+
type: 'array';
|
|
79
|
+
};
|
|
80
|
+
text?: AttributesSpec;
|
|
81
|
+
type?: {
|
|
82
|
+
type: 'enum';
|
|
83
|
+
values: Array<string>;
|
|
82
84
|
};
|
|
83
85
|
};
|
|
84
|
-
minItems?: number;
|
|
85
|
-
maxItems?: number;
|
|
86
86
|
required?: Array<string>;
|
|
87
87
|
}
|
|
88
88
|
export interface ValidationErrorMap {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
};
|
|
92
|
-
REDUNDANT_PROPERTIES: {
|
|
93
|
-
props: Array<string>;
|
|
94
|
-
};
|
|
95
|
-
REDUNDANT_ATTRIBUTES: {
|
|
89
|
+
DEPRECATED: never;
|
|
90
|
+
INVALID_ATTRIBUTES: {
|
|
96
91
|
attrs: Array<string>;
|
|
97
92
|
};
|
|
98
|
-
REDUNDANT_MARKS: {
|
|
99
|
-
marks: Array<string>;
|
|
100
|
-
};
|
|
101
|
-
INVALID_TYPE: never;
|
|
102
|
-
INVALID_TEXT: never;
|
|
103
93
|
INVALID_CONTENT: {
|
|
104
94
|
parentType?: string;
|
|
105
95
|
};
|
|
@@ -108,13 +98,23 @@ export interface ValidationErrorMap {
|
|
|
108
98
|
requiredLength: number;
|
|
109
99
|
type: RequiredContentLength;
|
|
110
100
|
};
|
|
111
|
-
|
|
101
|
+
INVALID_TEXT: never;
|
|
102
|
+
INVALID_TYPE: never;
|
|
103
|
+
MISSING_PROPERTIES: {
|
|
104
|
+
props: Array<string>;
|
|
105
|
+
};
|
|
106
|
+
REDUNDANT_ATTRIBUTES: {
|
|
112
107
|
attrs: Array<string>;
|
|
113
108
|
};
|
|
109
|
+
REDUNDANT_MARKS: {
|
|
110
|
+
marks: Array<string>;
|
|
111
|
+
};
|
|
112
|
+
REDUNDANT_PROPERTIES: {
|
|
113
|
+
props: Array<string>;
|
|
114
|
+
};
|
|
114
115
|
UNSUPPORTED_ATTRIBUTES: {
|
|
115
116
|
attrs: Array<string>;
|
|
116
117
|
};
|
|
117
|
-
DEPRECATED: never;
|
|
118
118
|
}
|
|
119
119
|
export type RequiredContentLength = 'minimum' | 'maximum';
|
|
120
120
|
export type Content = Array<string | [
|
|
@@ -130,8 +130,8 @@ export interface ValidationError {
|
|
|
130
130
|
export type ErrorCallback = (entity: ADFEntity, error: ValidationError, options: ErrorCallbackOptions) => ADFEntity | undefined;
|
|
131
131
|
export type ValidationMode = 'strict' | 'loose';
|
|
132
132
|
export interface ValidationOptions {
|
|
133
|
-
mode?: ValidationMode;
|
|
134
133
|
allowPrivateAttributes?: boolean;
|
|
134
|
+
mode?: ValidationMode;
|
|
135
135
|
}
|
|
136
136
|
export interface SpecValidatorResult {
|
|
137
137
|
hasValidated: boolean;
|
|
@@ -139,10 +139,10 @@ export interface SpecValidatorResult {
|
|
|
139
139
|
}
|
|
140
140
|
export type Err = <T extends ValidationErrorType>(code: T, msg: string, meta?: T extends keyof ValidationErrorMap ? ValidationErrorMap[T] : never) => NodeValidationResult;
|
|
141
141
|
export interface ErrorCallbackOptions {
|
|
142
|
-
|
|
143
|
-
isMark?: any;
|
|
142
|
+
allowNestedTables?: boolean;
|
|
144
143
|
allowUnsupportedBlock?: boolean;
|
|
145
144
|
allowUnsupportedInline?: boolean;
|
|
146
|
-
|
|
145
|
+
isMark?: any;
|
|
146
|
+
isNodeAttribute?: boolean;
|
|
147
147
|
}
|
|
148
148
|
export type Validate = (entity: ADFEntity, errorCallback?: ErrorCallback, allowed?: Content, parentSpec?: ValidatorSpec) => Output;
|