@atlaskit/adf-schema 52.9.3 → 52.9.5
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 +15 -0
- package/dist/cjs/schema/nodes/code-block.js +19 -7
- package/dist/es2019/schema/nodes/code-block.js +19 -7
- package/dist/esm/schema/nodes/code-block.js +19 -7
- package/dist/types/validator-schema/generated/validatorSpec.d.ts +26 -26
- package/dist/types-ts4.5/validator-schema/generated/validatorSpec.d.ts +26 -26
- package/package.json +2 -2
- package/schema-generators/validator-full-schema.ts +95 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/adf-schema
|
|
2
2
|
|
|
3
|
+
## 52.9.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`967cff1c14097`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/967cff1c14097) -
|
|
8
|
+
Add isolatedDeclarations: true to tsconfig.app.json and tsconfig.dev.json
|
|
9
|
+
|
|
10
|
+
## 52.9.4
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [`ded95ac7efcc4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ded95ac7efcc4) -
|
|
15
|
+
Persist code block wrap state in ADF, default code blocks created across editor runtime paths to
|
|
16
|
+
wrapped, and update the wrap toolbar tooltip behind platform_editor_code_block_q4_lovability.
|
|
17
|
+
|
|
3
18
|
## 52.9.3
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -199,7 +199,11 @@ var codeBlockWithExtendedAttributes = exports.codeBlockWithExtendedAttributes =
|
|
|
199
199
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
200
200
|
dom.getAttribute('data-language');
|
|
201
201
|
dom = removeLastNewLine(dom);
|
|
202
|
-
var
|
|
202
|
+
var wrapAttr = dom.getAttribute('data-wrap');
|
|
203
|
+
var isCopiedFromEditor = Boolean(dom.closest('[data-pm-slice]') || dom.hasAttribute('data-pm-slice'));
|
|
204
|
+
// Default external HTML paste to wrapped when data-wrap is absent, but preserve
|
|
205
|
+
// unwrapped editor-origin paste when copied content has data-pm-slice.
|
|
206
|
+
var wrap = wrapAttr === null ? !isCopiedFromEditor : wrapAttr !== 'false';
|
|
203
207
|
var hideLineNumbers = dom.getAttribute('data-hide-line-numbers') === 'true';
|
|
204
208
|
return {
|
|
205
209
|
language: language,
|
|
@@ -218,7 +222,9 @@ var codeBlockWithExtendedAttributes = exports.codeBlockWithExtendedAttributes =
|
|
|
218
222
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
219
223
|
var dom = domNode;
|
|
220
224
|
if (dom.style.whiteSpace === 'pre' || dom.style.fontFamily && dom.style.fontFamily.toLowerCase().indexOf('monospace') > -1) {
|
|
221
|
-
return {
|
|
225
|
+
return {
|
|
226
|
+
wrap: true
|
|
227
|
+
};
|
|
222
228
|
}
|
|
223
229
|
return false;
|
|
224
230
|
},
|
|
@@ -234,7 +240,9 @@ var codeBlockWithExtendedAttributes = exports.codeBlockWithExtendedAttributes =
|
|
|
234
240
|
getAttrs: function getAttrs(dom) {
|
|
235
241
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
236
242
|
if (dom.querySelector('td[class*="blob-code"]')) {
|
|
237
|
-
return {
|
|
243
|
+
return {
|
|
244
|
+
wrap: true
|
|
245
|
+
};
|
|
238
246
|
}
|
|
239
247
|
return false;
|
|
240
248
|
}
|
|
@@ -254,7 +262,9 @@ var codeBlockWithExtendedAttributes = exports.codeBlockWithExtendedAttributes =
|
|
|
254
262
|
return line.remove();
|
|
255
263
|
});
|
|
256
264
|
}
|
|
257
|
-
return {
|
|
265
|
+
return {
|
|
266
|
+
wrap: true
|
|
267
|
+
};
|
|
258
268
|
}
|
|
259
269
|
}],
|
|
260
270
|
toDOM: function toDOM(node) {
|
|
@@ -263,9 +273,11 @@ var codeBlockWithExtendedAttributes = exports.codeBlockWithExtendedAttributes =
|
|
|
263
273
|
if ((node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.localId) !== undefined) {
|
|
264
274
|
attrs['data-local-id'] = node.attrs.localId;
|
|
265
275
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
276
|
+
|
|
277
|
+
// Always serialize data-wrap explicitly (both true and false) so that
|
|
278
|
+
// editor-to-editor paste can distinguish intentional wrap:false from
|
|
279
|
+
// absent data-wrap (which parseDOM defaults to wrap:true for external HTML).
|
|
280
|
+
attrs['data-wrap'] = node.attrs.wrap ? 'true' : 'false';
|
|
269
281
|
if (node.attrs.hideLineNumbers) {
|
|
270
282
|
attrs['data-hide-line-numbers'] = 'true';
|
|
271
283
|
}
|
|
@@ -187,7 +187,11 @@ export const codeBlockWithExtendedAttributes = {
|
|
|
187
187
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
188
188
|
dom.getAttribute('data-language');
|
|
189
189
|
dom = removeLastNewLine(dom);
|
|
190
|
-
const
|
|
190
|
+
const wrapAttr = dom.getAttribute('data-wrap');
|
|
191
|
+
const isCopiedFromEditor = Boolean(dom.closest('[data-pm-slice]') || dom.hasAttribute('data-pm-slice'));
|
|
192
|
+
// Default external HTML paste to wrapped when data-wrap is absent, but preserve
|
|
193
|
+
// unwrapped editor-origin paste when copied content has data-pm-slice.
|
|
194
|
+
const wrap = wrapAttr === null ? !isCopiedFromEditor : wrapAttr !== 'false';
|
|
191
195
|
const hideLineNumbers = dom.getAttribute('data-hide-line-numbers') === 'true';
|
|
192
196
|
return {
|
|
193
197
|
language,
|
|
@@ -206,7 +210,9 @@ export const codeBlockWithExtendedAttributes = {
|
|
|
206
210
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
207
211
|
const dom = domNode;
|
|
208
212
|
if (dom.style.whiteSpace === 'pre' || dom.style.fontFamily && dom.style.fontFamily.toLowerCase().indexOf('monospace') > -1) {
|
|
209
|
-
return {
|
|
213
|
+
return {
|
|
214
|
+
wrap: true
|
|
215
|
+
};
|
|
210
216
|
}
|
|
211
217
|
return false;
|
|
212
218
|
},
|
|
@@ -222,7 +228,9 @@ export const codeBlockWithExtendedAttributes = {
|
|
|
222
228
|
getAttrs: dom => {
|
|
223
229
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
224
230
|
if (dom.querySelector('td[class*="blob-code"]')) {
|
|
225
|
-
return {
|
|
231
|
+
return {
|
|
232
|
+
wrap: true
|
|
233
|
+
};
|
|
226
234
|
}
|
|
227
235
|
return false;
|
|
228
236
|
}
|
|
@@ -240,7 +248,9 @@ export const codeBlockWithExtendedAttributes = {
|
|
|
240
248
|
// `react-syntax-highlighter-line-number` check, so that we don't remove real code
|
|
241
249
|
lineNumber.forEach(line => line.remove());
|
|
242
250
|
}
|
|
243
|
-
return {
|
|
251
|
+
return {
|
|
252
|
+
wrap: true
|
|
253
|
+
};
|
|
244
254
|
}
|
|
245
255
|
}],
|
|
246
256
|
toDOM(node) {
|
|
@@ -249,9 +259,11 @@ export const codeBlockWithExtendedAttributes = {
|
|
|
249
259
|
if ((node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.localId) !== undefined) {
|
|
250
260
|
attrs['data-local-id'] = node.attrs.localId;
|
|
251
261
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
262
|
+
|
|
263
|
+
// Always serialize data-wrap explicitly (both true and false) so that
|
|
264
|
+
// editor-to-editor paste can distinguish intentional wrap:false from
|
|
265
|
+
// absent data-wrap (which parseDOM defaults to wrap:true for external HTML).
|
|
266
|
+
attrs['data-wrap'] = node.attrs.wrap ? 'true' : 'false';
|
|
255
267
|
if (node.attrs.hideLineNumbers) {
|
|
256
268
|
attrs['data-hide-line-numbers'] = 'true';
|
|
257
269
|
}
|
|
@@ -193,7 +193,11 @@ export var codeBlockWithExtendedAttributes = _objectSpread({}, codeBlockWithExte
|
|
|
193
193
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
194
194
|
dom.getAttribute('data-language');
|
|
195
195
|
dom = removeLastNewLine(dom);
|
|
196
|
-
var
|
|
196
|
+
var wrapAttr = dom.getAttribute('data-wrap');
|
|
197
|
+
var isCopiedFromEditor = Boolean(dom.closest('[data-pm-slice]') || dom.hasAttribute('data-pm-slice'));
|
|
198
|
+
// Default external HTML paste to wrapped when data-wrap is absent, but preserve
|
|
199
|
+
// unwrapped editor-origin paste when copied content has data-pm-slice.
|
|
200
|
+
var wrap = wrapAttr === null ? !isCopiedFromEditor : wrapAttr !== 'false';
|
|
197
201
|
var hideLineNumbers = dom.getAttribute('data-hide-line-numbers') === 'true';
|
|
198
202
|
return {
|
|
199
203
|
language: language,
|
|
@@ -212,7 +216,9 @@ export var codeBlockWithExtendedAttributes = _objectSpread({}, codeBlockWithExte
|
|
|
212
216
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
213
217
|
var dom = domNode;
|
|
214
218
|
if (dom.style.whiteSpace === 'pre' || dom.style.fontFamily && dom.style.fontFamily.toLowerCase().indexOf('monospace') > -1) {
|
|
215
|
-
return {
|
|
219
|
+
return {
|
|
220
|
+
wrap: true
|
|
221
|
+
};
|
|
216
222
|
}
|
|
217
223
|
return false;
|
|
218
224
|
},
|
|
@@ -228,7 +234,9 @@ export var codeBlockWithExtendedAttributes = _objectSpread({}, codeBlockWithExte
|
|
|
228
234
|
getAttrs: function getAttrs(dom) {
|
|
229
235
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
230
236
|
if (dom.querySelector('td[class*="blob-code"]')) {
|
|
231
|
-
return {
|
|
237
|
+
return {
|
|
238
|
+
wrap: true
|
|
239
|
+
};
|
|
232
240
|
}
|
|
233
241
|
return false;
|
|
234
242
|
}
|
|
@@ -248,7 +256,9 @@ export var codeBlockWithExtendedAttributes = _objectSpread({}, codeBlockWithExte
|
|
|
248
256
|
return line.remove();
|
|
249
257
|
});
|
|
250
258
|
}
|
|
251
|
-
return {
|
|
259
|
+
return {
|
|
260
|
+
wrap: true
|
|
261
|
+
};
|
|
252
262
|
}
|
|
253
263
|
}],
|
|
254
264
|
toDOM: function toDOM(node) {
|
|
@@ -257,9 +267,11 @@ export var codeBlockWithExtendedAttributes = _objectSpread({}, codeBlockWithExte
|
|
|
257
267
|
if ((node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.localId) !== undefined) {
|
|
258
268
|
attrs['data-local-id'] = node.attrs.localId;
|
|
259
269
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
270
|
+
|
|
271
|
+
// Always serialize data-wrap explicitly (both true and false) so that
|
|
272
|
+
// editor-to-editor paste can distinguish intentional wrap:false from
|
|
273
|
+
// absent data-wrap (which parseDOM defaults to wrap:true for external HTML).
|
|
274
|
+
attrs['data-wrap'] = node.attrs.wrap ? 'true' : 'false';
|
|
263
275
|
if (node.attrs.hideLineNumbers) {
|
|
264
276
|
attrs['data-hide-line-numbers'] = 'true';
|
|
265
277
|
}
|
|
@@ -54,6 +54,7 @@ export declare const blockCard: {
|
|
|
54
54
|
props: {
|
|
55
55
|
attrs: ({
|
|
56
56
|
props: {
|
|
57
|
+
data?: undefined;
|
|
57
58
|
datasource: {
|
|
58
59
|
props: {
|
|
59
60
|
id: {
|
|
@@ -97,35 +98,34 @@ export declare const blockCard: {
|
|
|
97
98
|
optional: boolean;
|
|
98
99
|
type: string;
|
|
99
100
|
};
|
|
100
|
-
data?: undefined;
|
|
101
101
|
};
|
|
102
102
|
} | {
|
|
103
103
|
props: {
|
|
104
|
+
data?: undefined;
|
|
105
|
+
datasource?: undefined;
|
|
106
|
+
layout?: undefined;
|
|
104
107
|
localId: {
|
|
105
108
|
optional: boolean;
|
|
106
109
|
type: string;
|
|
107
110
|
};
|
|
108
111
|
url: {
|
|
112
|
+
optional?: undefined;
|
|
109
113
|
type: string;
|
|
110
114
|
validatorFn: string;
|
|
111
|
-
optional?: undefined;
|
|
112
115
|
};
|
|
113
|
-
datasource?: undefined;
|
|
114
|
-
layout?: undefined;
|
|
115
116
|
width?: undefined;
|
|
116
|
-
data?: undefined;
|
|
117
117
|
};
|
|
118
118
|
} | {
|
|
119
119
|
props: {
|
|
120
120
|
data: {
|
|
121
121
|
type: string;
|
|
122
122
|
};
|
|
123
|
+
datasource?: undefined;
|
|
124
|
+
layout?: undefined;
|
|
123
125
|
localId: {
|
|
124
126
|
optional: boolean;
|
|
125
127
|
type: string;
|
|
126
128
|
};
|
|
127
|
-
datasource?: undefined;
|
|
128
|
-
layout?: undefined;
|
|
129
129
|
url?: undefined;
|
|
130
130
|
width?: undefined;
|
|
131
131
|
};
|
|
@@ -225,7 +225,7 @@ export declare const bodiedExtension: {
|
|
|
225
225
|
type: string;
|
|
226
226
|
};
|
|
227
227
|
marks: {
|
|
228
|
-
items:
|
|
228
|
+
items: unknown[];
|
|
229
229
|
optional: boolean;
|
|
230
230
|
type: string;
|
|
231
231
|
};
|
|
@@ -738,7 +738,7 @@ export declare const extension: {
|
|
|
738
738
|
};
|
|
739
739
|
};
|
|
740
740
|
marks: {
|
|
741
|
-
items:
|
|
741
|
+
items: unknown[];
|
|
742
742
|
optional: boolean;
|
|
743
743
|
type: string;
|
|
744
744
|
};
|
|
@@ -855,7 +855,7 @@ export declare const heading: {
|
|
|
855
855
|
type: string;
|
|
856
856
|
};
|
|
857
857
|
marks: {
|
|
858
|
-
items:
|
|
858
|
+
items: unknown[];
|
|
859
859
|
optional: boolean;
|
|
860
860
|
type: string;
|
|
861
861
|
};
|
|
@@ -886,7 +886,7 @@ export declare const heading_with_indentation: (string | {
|
|
|
886
886
|
export declare const heading_with_no_marks: (string | {
|
|
887
887
|
props: {
|
|
888
888
|
marks: {
|
|
889
|
-
items:
|
|
889
|
+
items: unknown[];
|
|
890
890
|
maxItems: number;
|
|
891
891
|
optional: boolean;
|
|
892
892
|
type: string;
|
|
@@ -915,6 +915,7 @@ export declare const inlineCard: {
|
|
|
915
915
|
props: {
|
|
916
916
|
attrs: ({
|
|
917
917
|
props: {
|
|
918
|
+
data?: undefined;
|
|
918
919
|
localId: {
|
|
919
920
|
optional: boolean;
|
|
920
921
|
type: string;
|
|
@@ -923,7 +924,6 @@ export declare const inlineCard: {
|
|
|
923
924
|
type: string;
|
|
924
925
|
validatorFn: string;
|
|
925
926
|
};
|
|
926
|
-
data?: undefined;
|
|
927
927
|
};
|
|
928
928
|
} | {
|
|
929
929
|
props: {
|
|
@@ -977,7 +977,7 @@ export declare const inlineExtension: {
|
|
|
977
977
|
};
|
|
978
978
|
};
|
|
979
979
|
marks: {
|
|
980
|
-
items:
|
|
980
|
+
items: unknown[];
|
|
981
981
|
optional: boolean;
|
|
982
982
|
type: string;
|
|
983
983
|
};
|
|
@@ -1185,11 +1185,11 @@ export declare const media: {
|
|
|
1185
1185
|
type: string;
|
|
1186
1186
|
values: string[];
|
|
1187
1187
|
};
|
|
1188
|
+
url?: undefined;
|
|
1188
1189
|
width: {
|
|
1189
1190
|
optional: boolean;
|
|
1190
1191
|
type: string;
|
|
1191
1192
|
};
|
|
1192
|
-
url?: undefined;
|
|
1193
1193
|
};
|
|
1194
1194
|
} | {
|
|
1195
1195
|
props: {
|
|
@@ -1197,14 +1197,17 @@ export declare const media: {
|
|
|
1197
1197
|
optional: boolean;
|
|
1198
1198
|
type: string;
|
|
1199
1199
|
};
|
|
1200
|
+
collection?: undefined;
|
|
1200
1201
|
height: {
|
|
1201
1202
|
optional: boolean;
|
|
1202
1203
|
type: string;
|
|
1203
1204
|
};
|
|
1205
|
+
id?: undefined;
|
|
1204
1206
|
localId: {
|
|
1205
1207
|
optional: boolean;
|
|
1206
1208
|
type: string;
|
|
1207
1209
|
};
|
|
1210
|
+
occurrenceKey?: undefined;
|
|
1208
1211
|
type: {
|
|
1209
1212
|
type: string;
|
|
1210
1213
|
values: string[];
|
|
@@ -1216,9 +1219,6 @@ export declare const media: {
|
|
|
1216
1219
|
optional: boolean;
|
|
1217
1220
|
type: string;
|
|
1218
1221
|
};
|
|
1219
|
-
collection?: undefined;
|
|
1220
|
-
id?: undefined;
|
|
1221
|
-
occurrenceKey?: undefined;
|
|
1222
1222
|
};
|
|
1223
1223
|
})[];
|
|
1224
1224
|
marks: {
|
|
@@ -1340,15 +1340,15 @@ export declare const mediaSingle: {
|
|
|
1340
1340
|
type: string;
|
|
1341
1341
|
};
|
|
1342
1342
|
width: {
|
|
1343
|
-
minimum: number;
|
|
1344
|
-
type: string;
|
|
1345
1343
|
maximum?: undefined;
|
|
1344
|
+
minimum: number;
|
|
1346
1345
|
optional?: undefined;
|
|
1346
|
+
type: string;
|
|
1347
1347
|
};
|
|
1348
1348
|
widthType: {
|
|
1349
|
+
optional?: undefined;
|
|
1349
1350
|
type: string;
|
|
1350
1351
|
values: string[];
|
|
1351
|
-
optional?: undefined;
|
|
1352
1352
|
};
|
|
1353
1353
|
};
|
|
1354
1354
|
})[];
|
|
@@ -1471,7 +1471,7 @@ export declare const multiBodiedExtension: {
|
|
|
1471
1471
|
type: string;
|
|
1472
1472
|
};
|
|
1473
1473
|
marks: {
|
|
1474
|
-
items:
|
|
1474
|
+
items: unknown[];
|
|
1475
1475
|
optional: boolean;
|
|
1476
1476
|
type: string;
|
|
1477
1477
|
};
|
|
@@ -1512,7 +1512,7 @@ export declare const nestedExpand_content: {
|
|
|
1512
1512
|
export declare const nestedExpand_with_no_marks: (string | {
|
|
1513
1513
|
props: {
|
|
1514
1514
|
marks: {
|
|
1515
|
-
items:
|
|
1515
|
+
items: unknown[];
|
|
1516
1516
|
maxItems: number;
|
|
1517
1517
|
optional: boolean;
|
|
1518
1518
|
type: string;
|
|
@@ -1607,7 +1607,7 @@ export declare const paragraph: {
|
|
|
1607
1607
|
type: string;
|
|
1608
1608
|
};
|
|
1609
1609
|
marks: {
|
|
1610
|
-
items:
|
|
1610
|
+
items: unknown[];
|
|
1611
1611
|
optional: boolean;
|
|
1612
1612
|
type: string;
|
|
1613
1613
|
};
|
|
@@ -1647,7 +1647,7 @@ export declare const paragraph_with_indentation: (string | {
|
|
|
1647
1647
|
export declare const paragraph_with_no_marks: (string | {
|
|
1648
1648
|
props: {
|
|
1649
1649
|
marks: {
|
|
1650
|
-
items:
|
|
1650
|
+
items: unknown[];
|
|
1651
1651
|
maxItems: number;
|
|
1652
1652
|
optional: boolean;
|
|
1653
1653
|
type: string;
|
|
@@ -1979,7 +1979,7 @@ export declare const taskList: {
|
|
|
1979
1979
|
export declare const text: {
|
|
1980
1980
|
props: {
|
|
1981
1981
|
marks: {
|
|
1982
|
-
items:
|
|
1982
|
+
items: unknown[];
|
|
1983
1983
|
optional: boolean;
|
|
1984
1984
|
type: string;
|
|
1985
1985
|
};
|
|
@@ -2023,7 +2023,7 @@ export declare const text_link_inline: (string | {
|
|
|
2023
2023
|
export declare const text_with_no_marks: (string | {
|
|
2024
2024
|
props: {
|
|
2025
2025
|
marks: {
|
|
2026
|
-
items:
|
|
2026
|
+
items: unknown[];
|
|
2027
2027
|
maxItems: number;
|
|
2028
2028
|
optional: boolean;
|
|
2029
2029
|
type: string;
|
|
@@ -54,6 +54,7 @@ export declare const blockCard: {
|
|
|
54
54
|
props: {
|
|
55
55
|
attrs: ({
|
|
56
56
|
props: {
|
|
57
|
+
data?: undefined;
|
|
57
58
|
datasource: {
|
|
58
59
|
props: {
|
|
59
60
|
id: {
|
|
@@ -97,35 +98,34 @@ export declare const blockCard: {
|
|
|
97
98
|
optional: boolean;
|
|
98
99
|
type: string;
|
|
99
100
|
};
|
|
100
|
-
data?: undefined;
|
|
101
101
|
};
|
|
102
102
|
} | {
|
|
103
103
|
props: {
|
|
104
|
+
data?: undefined;
|
|
105
|
+
datasource?: undefined;
|
|
106
|
+
layout?: undefined;
|
|
104
107
|
localId: {
|
|
105
108
|
optional: boolean;
|
|
106
109
|
type: string;
|
|
107
110
|
};
|
|
108
111
|
url: {
|
|
112
|
+
optional?: undefined;
|
|
109
113
|
type: string;
|
|
110
114
|
validatorFn: string;
|
|
111
|
-
optional?: undefined;
|
|
112
115
|
};
|
|
113
|
-
datasource?: undefined;
|
|
114
|
-
layout?: undefined;
|
|
115
116
|
width?: undefined;
|
|
116
|
-
data?: undefined;
|
|
117
117
|
};
|
|
118
118
|
} | {
|
|
119
119
|
props: {
|
|
120
120
|
data: {
|
|
121
121
|
type: string;
|
|
122
122
|
};
|
|
123
|
+
datasource?: undefined;
|
|
124
|
+
layout?: undefined;
|
|
123
125
|
localId: {
|
|
124
126
|
optional: boolean;
|
|
125
127
|
type: string;
|
|
126
128
|
};
|
|
127
|
-
datasource?: undefined;
|
|
128
|
-
layout?: undefined;
|
|
129
129
|
url?: undefined;
|
|
130
130
|
width?: undefined;
|
|
131
131
|
};
|
|
@@ -225,7 +225,7 @@ export declare const bodiedExtension: {
|
|
|
225
225
|
type: string;
|
|
226
226
|
};
|
|
227
227
|
marks: {
|
|
228
|
-
items:
|
|
228
|
+
items: unknown[];
|
|
229
229
|
optional: boolean;
|
|
230
230
|
type: string;
|
|
231
231
|
};
|
|
@@ -738,7 +738,7 @@ export declare const extension: {
|
|
|
738
738
|
};
|
|
739
739
|
};
|
|
740
740
|
marks: {
|
|
741
|
-
items:
|
|
741
|
+
items: unknown[];
|
|
742
742
|
optional: boolean;
|
|
743
743
|
type: string;
|
|
744
744
|
};
|
|
@@ -855,7 +855,7 @@ export declare const heading: {
|
|
|
855
855
|
type: string;
|
|
856
856
|
};
|
|
857
857
|
marks: {
|
|
858
|
-
items:
|
|
858
|
+
items: unknown[];
|
|
859
859
|
optional: boolean;
|
|
860
860
|
type: string;
|
|
861
861
|
};
|
|
@@ -886,7 +886,7 @@ export declare const heading_with_indentation: (string | {
|
|
|
886
886
|
export declare const heading_with_no_marks: (string | {
|
|
887
887
|
props: {
|
|
888
888
|
marks: {
|
|
889
|
-
items:
|
|
889
|
+
items: unknown[];
|
|
890
890
|
maxItems: number;
|
|
891
891
|
optional: boolean;
|
|
892
892
|
type: string;
|
|
@@ -915,6 +915,7 @@ export declare const inlineCard: {
|
|
|
915
915
|
props: {
|
|
916
916
|
attrs: ({
|
|
917
917
|
props: {
|
|
918
|
+
data?: undefined;
|
|
918
919
|
localId: {
|
|
919
920
|
optional: boolean;
|
|
920
921
|
type: string;
|
|
@@ -923,7 +924,6 @@ export declare const inlineCard: {
|
|
|
923
924
|
type: string;
|
|
924
925
|
validatorFn: string;
|
|
925
926
|
};
|
|
926
|
-
data?: undefined;
|
|
927
927
|
};
|
|
928
928
|
} | {
|
|
929
929
|
props: {
|
|
@@ -977,7 +977,7 @@ export declare const inlineExtension: {
|
|
|
977
977
|
};
|
|
978
978
|
};
|
|
979
979
|
marks: {
|
|
980
|
-
items:
|
|
980
|
+
items: unknown[];
|
|
981
981
|
optional: boolean;
|
|
982
982
|
type: string;
|
|
983
983
|
};
|
|
@@ -1185,11 +1185,11 @@ export declare const media: {
|
|
|
1185
1185
|
type: string;
|
|
1186
1186
|
values: string[];
|
|
1187
1187
|
};
|
|
1188
|
+
url?: undefined;
|
|
1188
1189
|
width: {
|
|
1189
1190
|
optional: boolean;
|
|
1190
1191
|
type: string;
|
|
1191
1192
|
};
|
|
1192
|
-
url?: undefined;
|
|
1193
1193
|
};
|
|
1194
1194
|
} | {
|
|
1195
1195
|
props: {
|
|
@@ -1197,14 +1197,17 @@ export declare const media: {
|
|
|
1197
1197
|
optional: boolean;
|
|
1198
1198
|
type: string;
|
|
1199
1199
|
};
|
|
1200
|
+
collection?: undefined;
|
|
1200
1201
|
height: {
|
|
1201
1202
|
optional: boolean;
|
|
1202
1203
|
type: string;
|
|
1203
1204
|
};
|
|
1205
|
+
id?: undefined;
|
|
1204
1206
|
localId: {
|
|
1205
1207
|
optional: boolean;
|
|
1206
1208
|
type: string;
|
|
1207
1209
|
};
|
|
1210
|
+
occurrenceKey?: undefined;
|
|
1208
1211
|
type: {
|
|
1209
1212
|
type: string;
|
|
1210
1213
|
values: string[];
|
|
@@ -1216,9 +1219,6 @@ export declare const media: {
|
|
|
1216
1219
|
optional: boolean;
|
|
1217
1220
|
type: string;
|
|
1218
1221
|
};
|
|
1219
|
-
collection?: undefined;
|
|
1220
|
-
id?: undefined;
|
|
1221
|
-
occurrenceKey?: undefined;
|
|
1222
1222
|
};
|
|
1223
1223
|
})[];
|
|
1224
1224
|
marks: {
|
|
@@ -1340,15 +1340,15 @@ export declare const mediaSingle: {
|
|
|
1340
1340
|
type: string;
|
|
1341
1341
|
};
|
|
1342
1342
|
width: {
|
|
1343
|
-
minimum: number;
|
|
1344
|
-
type: string;
|
|
1345
1343
|
maximum?: undefined;
|
|
1344
|
+
minimum: number;
|
|
1346
1345
|
optional?: undefined;
|
|
1346
|
+
type: string;
|
|
1347
1347
|
};
|
|
1348
1348
|
widthType: {
|
|
1349
|
+
optional?: undefined;
|
|
1349
1350
|
type: string;
|
|
1350
1351
|
values: string[];
|
|
1351
|
-
optional?: undefined;
|
|
1352
1352
|
};
|
|
1353
1353
|
};
|
|
1354
1354
|
})[];
|
|
@@ -1471,7 +1471,7 @@ export declare const multiBodiedExtension: {
|
|
|
1471
1471
|
type: string;
|
|
1472
1472
|
};
|
|
1473
1473
|
marks: {
|
|
1474
|
-
items:
|
|
1474
|
+
items: unknown[];
|
|
1475
1475
|
optional: boolean;
|
|
1476
1476
|
type: string;
|
|
1477
1477
|
};
|
|
@@ -1512,7 +1512,7 @@ export declare const nestedExpand_content: {
|
|
|
1512
1512
|
export declare const nestedExpand_with_no_marks: (string | {
|
|
1513
1513
|
props: {
|
|
1514
1514
|
marks: {
|
|
1515
|
-
items:
|
|
1515
|
+
items: unknown[];
|
|
1516
1516
|
maxItems: number;
|
|
1517
1517
|
optional: boolean;
|
|
1518
1518
|
type: string;
|
|
@@ -1607,7 +1607,7 @@ export declare const paragraph: {
|
|
|
1607
1607
|
type: string;
|
|
1608
1608
|
};
|
|
1609
1609
|
marks: {
|
|
1610
|
-
items:
|
|
1610
|
+
items: unknown[];
|
|
1611
1611
|
optional: boolean;
|
|
1612
1612
|
type: string;
|
|
1613
1613
|
};
|
|
@@ -1647,7 +1647,7 @@ export declare const paragraph_with_indentation: (string | {
|
|
|
1647
1647
|
export declare const paragraph_with_no_marks: (string | {
|
|
1648
1648
|
props: {
|
|
1649
1649
|
marks: {
|
|
1650
|
-
items:
|
|
1650
|
+
items: unknown[];
|
|
1651
1651
|
maxItems: number;
|
|
1652
1652
|
optional: boolean;
|
|
1653
1653
|
type: string;
|
|
@@ -1979,7 +1979,7 @@ export declare const taskList: {
|
|
|
1979
1979
|
export declare const text: {
|
|
1980
1980
|
props: {
|
|
1981
1981
|
marks: {
|
|
1982
|
-
items:
|
|
1982
|
+
items: unknown[];
|
|
1983
1983
|
optional: boolean;
|
|
1984
1984
|
type: string;
|
|
1985
1985
|
};
|
|
@@ -2023,7 +2023,7 @@ export declare const text_link_inline: (string | {
|
|
|
2023
2023
|
export declare const text_with_no_marks: (string | {
|
|
2024
2024
|
props: {
|
|
2025
2025
|
marks: {
|
|
2026
|
-
items:
|
|
2026
|
+
items: unknown[];
|
|
2027
2027
|
maxItems: number;
|
|
2028
2028
|
optional: boolean;
|
|
2029
2029
|
type: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/adf-schema",
|
|
3
|
-
"version": "52.9.
|
|
3
|
+
"version": "52.9.5",
|
|
4
4
|
"description": "Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@atlaskit/adf-schema-generator": "^2.2.0",
|
|
44
44
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
45
45
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
46
|
-
"@atlaskit/tmp-editor-statsig": "^77.
|
|
46
|
+
"@atlaskit/tmp-editor-statsig": "^77.2.0",
|
|
47
47
|
"@babel/runtime": "^7.0.0",
|
|
48
48
|
"css-color-names": "0.0.4",
|
|
49
49
|
"linkify-it": "^3.0.3",
|
|
@@ -37,7 +37,11 @@ function serializeValidatorJson(value: unknown, depth = 0): string {
|
|
|
37
37
|
if (value.length === 0) {
|
|
38
38
|
return '[]';
|
|
39
39
|
}
|
|
40
|
-
const
|
|
40
|
+
const items = value.filter((item) => item !== undefined);
|
|
41
|
+
if (items.length === 0) {
|
|
42
|
+
return '[]';
|
|
43
|
+
}
|
|
44
|
+
const inner = items
|
|
41
45
|
.map((item) => serializeValidatorJson(item, depth + 1))
|
|
42
46
|
.join(`,${indent(depth + 1)}`);
|
|
43
47
|
return `[${indent(depth + 1)}${inner}${indent(depth)}]`;
|
|
@@ -60,12 +64,101 @@ function serializeValidatorJson(value: unknown, depth = 0): string {
|
|
|
60
64
|
throw new Error(`Unsupported value in validator spec: ${typeof value}`);
|
|
61
65
|
}
|
|
62
66
|
|
|
67
|
+
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
68
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Emit the TypeScript type annotation for a value, widening all primitive
|
|
73
|
+
* literals to their base types (e.g. `'enum'` → `string`, `100` → `number`).
|
|
74
|
+
*
|
|
75
|
+
* This produces an explicit type annotation on each generated `export const`
|
|
76
|
+
* so that:
|
|
77
|
+
* 1. Running the codegen never silently removes type information.
|
|
78
|
+
* 2. Consumers that use `--isolatedDeclarations` get an explicit declaration
|
|
79
|
+
* rather than relying on type inference from a deeply-nested literal.
|
|
80
|
+
*
|
|
81
|
+
* For arrays whose elements all share the same structural type, the result is
|
|
82
|
+
* `T[]`. For heterogeneous arrays (e.g. an extends tuple like
|
|
83
|
+
* `[string, ValidatorSpecNode]` or an anyOf attrs list), the result is
|
|
84
|
+
* `(T1 | T2 | ...)[]`, deduplicating structurally identical element types.
|
|
85
|
+
*
|
|
86
|
+
* The `siblings` argument carries parallel values from sibling array branches
|
|
87
|
+
* at the current path — used to produce a discriminated-union style annotation
|
|
88
|
+
* for object branches that have non-overlapping key sets. When an object
|
|
89
|
+
* branch is missing a key that another sibling branch has, the missing key is
|
|
90
|
+
* emitted as `key?: undefined`. This matches the TypeScript pattern used to
|
|
91
|
+
* make `anyOf`-style attribute unions mutually exclusive (e.g. `media`'s
|
|
92
|
+
* `file` vs `link` attrs, `blockCard`'s three attribute variants).
|
|
93
|
+
*/
|
|
94
|
+
function serializeValidatorType(value: unknown, depth = 0, siblings: unknown[] = []): string {
|
|
95
|
+
if (value === null) {
|
|
96
|
+
return 'null';
|
|
97
|
+
}
|
|
98
|
+
if (value === undefined) {
|
|
99
|
+
return 'undefined';
|
|
100
|
+
}
|
|
101
|
+
if (typeof value === 'string') {
|
|
102
|
+
return 'string';
|
|
103
|
+
}
|
|
104
|
+
if (typeof value === 'number') {
|
|
105
|
+
return 'number';
|
|
106
|
+
}
|
|
107
|
+
if (typeof value === 'boolean') {
|
|
108
|
+
return 'boolean';
|
|
109
|
+
}
|
|
110
|
+
if (Array.isArray(value)) {
|
|
111
|
+
if (value.length === 0) {
|
|
112
|
+
return 'unknown[]';
|
|
113
|
+
}
|
|
114
|
+
const items = value.filter((item) => item !== undefined);
|
|
115
|
+
if (items.length === 0) {
|
|
116
|
+
return 'unknown[]';
|
|
117
|
+
}
|
|
118
|
+
const elementTypes = items.map((item, i) => {
|
|
119
|
+
const otherElements = items.filter((_, j) => j !== i);
|
|
120
|
+
return serializeValidatorType(item, depth + 1, otherElements);
|
|
121
|
+
});
|
|
122
|
+
const uniqueTypes = [...new Set(elementTypes)];
|
|
123
|
+
const elementType = uniqueTypes.length === 1 ? uniqueTypes[0] : `(${uniqueTypes.join(' | ')})`;
|
|
124
|
+
return `${elementType}[]`;
|
|
125
|
+
}
|
|
126
|
+
if (typeof value === 'object') {
|
|
127
|
+
const selfRecord = value as Record<string, unknown>;
|
|
128
|
+
const siblingObjects = siblings.filter(isPlainObject);
|
|
129
|
+
const ownKeys = Object.keys(selfRecord);
|
|
130
|
+
const allKeys = new Set<string>(ownKeys);
|
|
131
|
+
for (const sibling of siblingObjects) {
|
|
132
|
+
for (const key of Object.keys(sibling)) {
|
|
133
|
+
allKeys.add(key);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (allKeys.size === 0) {
|
|
137
|
+
return '{}';
|
|
138
|
+
}
|
|
139
|
+
const sortedKeys = [...allKeys].sort((a, b) => a.localeCompare(b));
|
|
140
|
+
const inner = sortedKeys
|
|
141
|
+
.map((k) => {
|
|
142
|
+
const keyName = /^[a-zA-Z_$][\w$]*$/u.test(k) ? k : JSON.stringify(k);
|
|
143
|
+
if (k in selfRecord) {
|
|
144
|
+
const siblingsForK = siblingObjects.filter((s) => k in s).map((s) => s[k]);
|
|
145
|
+
return `${keyName}: ${serializeValidatorType(selfRecord[k], depth + 1, siblingsForK)}`;
|
|
146
|
+
}
|
|
147
|
+
return `${keyName}?: undefined`;
|
|
148
|
+
})
|
|
149
|
+
.join(`;${indent(depth + 1)}`);
|
|
150
|
+
return `{${indent(depth + 1)}${inner};${indent(depth)}}`;
|
|
151
|
+
}
|
|
152
|
+
throw new Error(`Unsupported value in validator type: ${typeof value}`);
|
|
153
|
+
}
|
|
154
|
+
|
|
63
155
|
function generateValidatorSpec() {
|
|
64
156
|
const output = adfToValidatorSpec(adfNode);
|
|
65
157
|
return Object.entries(output)
|
|
66
158
|
.map(([key, entry]) => {
|
|
67
159
|
const { json } = entry as { json: unknown };
|
|
68
|
-
|
|
160
|
+
const type = serializeValidatorType(json);
|
|
161
|
+
return `export const ${key}: ${type} = ${serializeValidatorJson(json)};`;
|
|
69
162
|
})
|
|
70
163
|
.join('\n\n');
|
|
71
164
|
}
|