@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 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
@@ -3,9 +3,9 @@
3
3
  "compilerOptions": {
4
4
  "declaration": true,
5
5
  "target": "es5",
6
- "composite": true,
7
6
  "outDir": "../../../../../confluence/tsDist/@atlaskit__adf-utils",
8
- "rootDir": "../"
7
+ "rootDir": "../",
8
+ "composite": true
9
9
  },
10
10
  "include": [
11
11
  "../src/**/*.ts",
@@ -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,7 +1,7 @@
1
1
  export type WithMark = {
2
- type: any;
3
- marks?: Array<any>;
4
2
  [prop: string]: any;
3
+ marks?: Array<any>;
4
+ type: any;
5
5
  };
6
6
  export type WithAppliedMark<T, M> = T & {
7
7
  marks?: Array<M>;
@@ -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
- type: string;
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
- [key: string]: any;
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
- maximum: number;
31
+ optional?: boolean;
32
+ type: 'number';
38
33
  } | {
39
- type: 'boolean';
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
- type: 'array';
55
+ isTupleLike?: boolean;
56
56
  items: Array<AttributesSpec>;
57
- optional?: boolean;
58
- minItems?: number;
59
57
  maxItems?: number;
60
- isTupleLike?: boolean;
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
- MISSING_PROPERTIES: {
90
- props: Array<string>;
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
- INVALID_ATTRIBUTES: {
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
- isNodeAttribute?: boolean;
140
- isMark?: any;
139
+ allowNestedTables?: boolean;
141
140
  allowUnsupportedBlock?: boolean;
142
141
  allowUnsupportedInline?: boolean;
143
- allowNestedTables?: boolean;
142
+ isMark?: any;
143
+ isNodeAttribute?: boolean;
144
144
  }
145
145
  export type Validate = (entity: ADFEntity, errorCallback?: ErrorCallback, allowed?: Content, parentSpec?: ValidatorSpec) => Output;
@@ -1,7 +1,7 @@
1
1
  export type WithMark = {
2
- type: any;
3
- marks?: Array<any>;
4
2
  [prop: string]: any;
3
+ marks?: Array<any>;
4
+ type: any;
5
5
  };
6
6
  export type WithAppliedMark<T, M> = T & {
7
7
  marks?: Array<M>;
@@ -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
- type: string;
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
- [key: string]: any;
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
- maximum: number;
31
+ optional?: boolean;
32
+ type: 'number';
38
33
  } | {
39
- type: 'boolean';
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
- type: 'array';
55
+ isTupleLike?: boolean;
56
56
  items: Array<AttributesSpec>;
57
- optional?: boolean;
58
- minItems?: number;
59
57
  maxItems?: number;
60
- isTupleLike?: boolean;
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
- MISSING_PROPERTIES: {
90
- props: Array<string>;
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
- INVALID_ATTRIBUTES: {
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
- isNodeAttribute?: boolean;
143
- isMark?: any;
142
+ allowNestedTables?: boolean;
144
143
  allowUnsupportedBlock?: boolean;
145
144
  allowUnsupportedInline?: boolean;
146
- allowNestedTables?: boolean;
145
+ isMark?: any;
146
+ isNodeAttribute?: boolean;
147
147
  }
148
148
  export type Validate = (entity: ADFEntity, errorCallback?: ErrorCallback, allowed?: Content, parentSpec?: ValidatorSpec) => Output;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-utils",
3
- "version": "19.21.1",
3
+ "version": "19.21.2",
4
4
  "description": "Set of utilities to traverse, modify and create ADF documents.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"