@atlaskit/adf-utils 19.27.2 → 19.27.4

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,19 @@
1
1
  # @atlaskit/adf-utils
2
2
 
3
+ ## 19.27.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 19.27.3
10
+
11
+ ### Patch Changes
12
+
13
+ - [`aeb46591ec80a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/aeb46591ec80a) -
14
+ [ux] EDITOR-5627 flexible task list indentation adf schema updates
15
+ - Updated dependencies
16
+
3
17
  ## 19.27.2
4
18
 
5
19
  ### Patch Changes
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.fontSize = void 0;
7
+ var _applyMark = require("../utils/apply-mark");
8
+ var fontSize = exports.fontSize = function fontSize(attrs) {
9
+ return function (maybeNode) {
10
+ return (0, _applyMark.applyMark)({
11
+ type: 'fontSize',
12
+ attrs: attrs
13
+ }, maybeNode);
14
+ };
15
+ };
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.nativeEmbedsFallbackTransform = void 0;
7
+ var _traverse = require("../traverse/traverse");
8
+ var NATIVE_EMBED_EXTENSION_KEY = 'native-embed';
9
+
10
+ /**
11
+ * Replaces any `extension` nodes whose `extensionKey` is
12
+ * `native-embed` with a paragraph containing an `inlineCard`
13
+ * node pointing at the same URL.
14
+ * If a native-embed node has no URL it is dropped from the document.
15
+ */
16
+ var nativeEmbedsFallbackTransform = exports.nativeEmbedsFallbackTransform = function nativeEmbedsFallbackTransform(adf) {
17
+ var isTransformed = false;
18
+ var transformedAdf = (0, _traverse.traverse)(adf, {
19
+ extension: function extension(node) {
20
+ var _node$attrs, _node$attrs2;
21
+ if (((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs['extensionKey'].split(':')[0]) !== NATIVE_EMBED_EXTENSION_KEY) {
22
+ return node;
23
+ }
24
+ var url = (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 || (_node$attrs2 = _node$attrs2['parameters']) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.url;
25
+ if (!url) {
26
+ isTransformed = true;
27
+ return false;
28
+ }
29
+ isTransformed = true;
30
+ return {
31
+ type: 'paragraph',
32
+ content: [{
33
+ type: 'inlineCard',
34
+ attrs: {
35
+ url: url
36
+ }
37
+ }]
38
+ };
39
+ }
40
+ });
41
+ return {
42
+ transformedAdf: transformedAdf,
43
+ isTransformed: isTransformed
44
+ };
45
+ };
@@ -15,6 +15,12 @@ Object.defineProperty(exports, "isNestedTableExtension", {
15
15
  return _nestedTableTransform.isNestedTableExtension;
16
16
  }
17
17
  });
18
+ Object.defineProperty(exports, "nativeEmbedsFallbackTransform", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _nativeEmbedsFallbackTransform.nativeEmbedsFallbackTransform;
22
+ }
23
+ });
18
24
  Object.defineProperty(exports, "syncBlockFallbackTransform", {
19
25
  enumerable: true,
20
26
  get: function get() {
@@ -84,4 +90,5 @@ var _indentationMarksTransform = require("./transforms/indentation-marks-transfo
84
90
  var _invalidMediaContentTransform = require("./transforms/invalid-media-content-transform");
85
91
  var _nestedTableTransform = require("./transforms/nested-table-transform");
86
92
  var _errors = require("./transforms/errors");
87
- var _syncBlockFallbackTransform = require("./transforms/sync-block-fallback-transform");
93
+ var _syncBlockFallbackTransform = require("./transforms/sync-block-fallback-transform");
94
+ var _nativeEmbedsFallbackTransform = require("./transforms/native-embeds-fallback-transform");
@@ -195,6 +195,12 @@ Object.defineProperty(exports, "extension_with_marks", {
195
195
  return _schemaValidator.extension_with_marks;
196
196
  }
197
197
  });
198
+ Object.defineProperty(exports, "fontSize", {
199
+ enumerable: true,
200
+ get: function get() {
201
+ return _schemaValidator.fontSize;
202
+ }
203
+ });
198
204
  Object.defineProperty(exports, "fragment", {
199
205
  enumerable: true,
200
206
  get: function get() {
@@ -399,6 +405,24 @@ Object.defineProperty(exports, "paragraph_with_alignment", {
399
405
  return _schemaValidator.paragraph_with_alignment;
400
406
  }
401
407
  });
408
+ Object.defineProperty(exports, "paragraph_with_font_size", {
409
+ enumerable: true,
410
+ get: function get() {
411
+ return _schemaValidator.paragraph_with_font_size;
412
+ }
413
+ });
414
+ Object.defineProperty(exports, "paragraph_with_font_size_and_alignment", {
415
+ enumerable: true,
416
+ get: function get() {
417
+ return _schemaValidator.paragraph_with_font_size_and_alignment;
418
+ }
419
+ });
420
+ Object.defineProperty(exports, "paragraph_with_font_size_and_indentation", {
421
+ enumerable: true,
422
+ get: function get() {
423
+ return _schemaValidator.paragraph_with_font_size_and_indentation;
424
+ }
425
+ });
402
426
  Object.defineProperty(exports, "paragraph_with_indentation", {
403
427
  enumerable: true,
404
428
  get: function get() {
@@ -489,6 +513,12 @@ Object.defineProperty(exports, "taskList", {
489
513
  return _schemaValidator.taskList;
490
514
  }
491
515
  });
516
+ Object.defineProperty(exports, "taskList_with_flexible_first_child", {
517
+ enumerable: true,
518
+ get: function get() {
519
+ return _schemaValidator.taskList_with_flexible_first_child;
520
+ }
521
+ });
492
522
  Object.defineProperty(exports, "text", {
493
523
  enumerable: true,
494
524
  get: function get() {
@@ -8,8 +8,8 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.createSpec = createSpec;
9
9
  exports.validateAttrs = validateAttrs;
10
10
  exports.validator = validator;
11
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
12
11
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
13
13
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
14
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
15
15
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
@@ -64,6 +64,18 @@ var partitionObject = function partitionObject(obj, predicate) {
64
64
  }, [[], []]);
65
65
  };
66
66
 
67
+ /**
68
+ * Checks if a spec is a variant spec.
69
+ * A variant spec is an array where the first element is a string (base spec name)
70
+ * and the second element is a ValidatorSpec object { props: { ... } }
71
+ *
72
+ * @param spec - The spec to check
73
+ * @returns true if the spec is a variant spec, false otherwise
74
+ */
75
+ var isVariant = function isVariant(spec) {
76
+ return (0, _typeof2.default)(spec) === 'object' && !!spec && 0 in spec && 1 in spec && typeof spec[0] === 'string' && (0, _typeof2.default)(spec[1]) === 'object';
77
+ };
78
+
67
79
  /**
68
80
  * Normalizes the structure of files imported from './specs'.
69
81
  * We denormalised the spec to save bundle size.
@@ -75,6 +87,15 @@ function createSpec(nodes, marks) {
75
87
  // Ignored via go/ees005
76
88
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
77
89
  var spec = _objectSpread({}, specs[k]);
90
+ if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_flexible_list_indentation', 'isEnabled', true) && isVariant(spec) &&
91
+ // Only apply to variants which are explicitly marked for override in `variantSpecOverrides`
92
+ Object.values(variantSpecOverrides).includes(k)) {
93
+ // This allows the variant spec to also have the content normalization applied to it
94
+ // When the spec is a variant it will be in the form of ['base_spec_name', { props: { ... } }]
95
+ // So the actual validator spec of the variant will be the second item in the array
96
+ // We also need to shallow clone this to ensure we don't mutate the original spec
97
+ spec = _objectSpread({}, spec[1]);
98
+ }
78
99
  if (spec.props) {
79
100
  spec.props = _objectSpread({}, spec.props);
80
101
  if (spec.props.content) {
@@ -329,25 +350,30 @@ var unsupportedNodeAttributesContent = function unsupportedNodeAttributesContent
329
350
  }
330
351
  };
331
352
 
353
+ /**
354
+ * Map of base spec names to a preferred variant spec that should be used in their place during validation.
355
+ *
356
+ * WARNING: The variant spec must be a strict superset of the base spec, i.e. any content valid
357
+ * under the base spec must also be valid under the variant
358
+ */
359
+ var variantSpecOverrides = {
360
+ listItem: 'listItem_with_flexible_first_child',
361
+ taskList: 'taskList_with_flexible_first_child'
362
+ };
363
+
332
364
  /**
333
365
  * Replaces base validator specs with their designated variant overrides
334
366
  */
335
367
  var applyVariantSpecOverrides = function applyVariantSpecOverrides(validatorSpecs) {
336
- /**
337
- * Map of base spec names to a variant spec that should be used in their place during validation.
338
- *
339
- * WARNING: The variant spec must be a strict superset of the base spec, i.e. any content valid
340
- * under the base spec must also be valid under the variant
341
- */
342
- var variantSpecOverrides = {
343
- listItem: 'listItem_with_flexible_first_child'
344
- };
345
368
  Object.entries(variantSpecOverrides).forEach(function (_ref2) {
346
369
  var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
347
370
  base = _ref3[0],
348
371
  variant = _ref3[1];
349
- if (validatorSpecs[base] && validatorSpecs[variant]) {
350
- validatorSpecs[base] = validatorSpecs[variant];
372
+ var baseSpec = validatorSpecs[base];
373
+ var variantOverride = validatorSpecs[variant];
374
+ if (baseSpec !== null && baseSpec !== void 0 && baseSpec.props && variantOverride !== null && variantOverride !== void 0 && variantOverride.props && (0, _typeof2.default)(baseSpec.props) === 'object' && (0, _typeof2.default)(variantOverride.props) === 'object') {
375
+ // Merge variant overrides INTO the base spec
376
+ baseSpec.props = _objectSpread(_objectSpread({}, baseSpec.props), variantOverride.props);
351
377
  }
352
378
  });
353
379
  };
@@ -0,0 +1,5 @@
1
+ import { applyMark } from '../utils/apply-mark';
2
+ export const fontSize = attrs => maybeNode => applyMark({
3
+ type: 'fontSize',
4
+ attrs
5
+ }, maybeNode);
@@ -0,0 +1,39 @@
1
+ import { traverse } from '../traverse/traverse';
2
+ const NATIVE_EMBED_EXTENSION_KEY = 'native-embed';
3
+
4
+ /**
5
+ * Replaces any `extension` nodes whose `extensionKey` is
6
+ * `native-embed` with a paragraph containing an `inlineCard`
7
+ * node pointing at the same URL.
8
+ * If a native-embed node has no URL it is dropped from the document.
9
+ */
10
+ export const nativeEmbedsFallbackTransform = adf => {
11
+ let isTransformed = false;
12
+ const transformedAdf = traverse(adf, {
13
+ extension: node => {
14
+ var _node$attrs, _node$attrs2, _node$attrs2$paramete;
15
+ if (((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs['extensionKey'].split(':')[0]) !== NATIVE_EMBED_EXTENSION_KEY) {
16
+ return node;
17
+ }
18
+ const url = (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : (_node$attrs2$paramete = _node$attrs2['parameters']) === null || _node$attrs2$paramete === void 0 ? void 0 : _node$attrs2$paramete.url;
19
+ if (!url) {
20
+ isTransformed = true;
21
+ return false;
22
+ }
23
+ isTransformed = true;
24
+ return {
25
+ type: 'paragraph',
26
+ content: [{
27
+ type: 'inlineCard',
28
+ attrs: {
29
+ url
30
+ }
31
+ }]
32
+ };
33
+ }
34
+ });
35
+ return {
36
+ transformedAdf,
37
+ isTransformed
38
+ };
39
+ };
@@ -11,4 +11,5 @@ export { transformInvalidMediaContent } from './transforms/invalid-media-content
11
11
  export { transformNestedTablesIncomingDocument, isNestedTableExtension } from './transforms/nested-table-transform';
12
12
  export { transformNestedTableNodeOutgoingDocument } from './transforms/nested-table-transform';
13
13
  export { NodeNestingTransformError } from './transforms/errors';
14
- export { syncBlockFallbackTransform } from './transforms/sync-block-fallback-transform';
14
+ export { syncBlockFallbackTransform } from './transforms/sync-block-fallback-transform';
15
+ export { nativeEmbedsFallbackTransform } from './transforms/native-embeds-fallback-transform';
@@ -1,2 +1,2 @@
1
1
  /* eslint-disable @atlaskit/editor/no-re-export */
2
- export { alignment, annotation, backgroundColor, blockCard, block_content, blockRootOnly, blockquote, blockTaskItem, bodiedExtension, bodiedExtension_with_marks, border, breakout, bulletList, caption, code, codeBlock, codeBlock_root_only, text_with_no_marks, confluenceInlineComment, dataConsumer, date, decisionItem, decisionList, doc, em, embedCard, emoji, expand, expand_root_only, extension, extensionFrame, extension_with_marks, fragment, hardBreak, heading, heading_with_alignment, heading_with_indentation, heading_with_no_marks, indentation, inlineCard, inlineExtension, inlineExtension_with_marks, inline_content, layoutColumn, layoutSection, layoutSection_full, layoutSection_with_single_column, link, listItem, listItem_with_flexible_first_child, media, mediaGroup, mediaInline, mediaSingle, mediaSingle_caption, mediaSingle_full, mention, multiBodiedExtension, nestedExpand, nestedExpand_content, nestedExpand_with_no_marks, non_nestable_block_content, orderedList, panel, paragraph, paragraph_with_alignment, paragraph_with_indentation, paragraph_with_no_marks, placeholder, rule, status, strike, strong, subsup, table, tableCell, tableHeader, tableRow, taskItem, taskList, text, textColor, text_code_inline, text_formatted, text_link_inline, underline, syncBlock, bodiedSyncBlock } from '@atlaskit/adf-schema/schema-validator';
2
+ export { alignment, annotation, backgroundColor, blockCard, block_content, blockRootOnly, blockquote, blockTaskItem, bodiedExtension, bodiedExtension_with_marks, border, breakout, bulletList, caption, code, codeBlock, codeBlock_root_only, text_with_no_marks, confluenceInlineComment, dataConsumer, date, decisionItem, decisionList, doc, em, embedCard, emoji, expand, expand_root_only, extension, extensionFrame, extension_with_marks, fontSize, fragment, hardBreak, heading, heading_with_alignment, heading_with_indentation, heading_with_no_marks, indentation, inlineCard, inlineExtension, inlineExtension_with_marks, inline_content, layoutColumn, layoutSection, layoutSection_full, layoutSection_with_single_column, link, listItem, listItem_with_flexible_first_child, media, mediaGroup, mediaInline, mediaSingle, mediaSingle_caption, mediaSingle_full, mention, multiBodiedExtension, nestedExpand, nestedExpand_content, nestedExpand_with_no_marks, non_nestable_block_content, orderedList, panel, paragraph, paragraph_with_alignment, paragraph_with_font_size, paragraph_with_font_size_and_alignment, paragraph_with_font_size_and_indentation, paragraph_with_indentation, paragraph_with_no_marks, placeholder, rule, status, strike, strong, subsup, table, tableCell, tableHeader, tableRow, taskItem, taskList, taskList_with_flexible_first_child, text, textColor, text_code_inline, text_formatted, text_link_inline, underline, syncBlock, bodiedSyncBlock } from '@atlaskit/adf-schema/schema-validator';
@@ -44,6 +44,16 @@ const partitionObject = (obj, predicate) => Object.keys(obj).reduce((acc, key) =
44
44
  return acc;
45
45
  }, [[], []]);
46
46
 
47
+ /**
48
+ * Checks if a spec is a variant spec.
49
+ * A variant spec is an array where the first element is a string (base spec name)
50
+ * and the second element is a ValidatorSpec object { props: { ... } }
51
+ *
52
+ * @param spec - The spec to check
53
+ * @returns true if the spec is a variant spec, false otherwise
54
+ */
55
+ const isVariant = spec => typeof spec === 'object' && !!spec && 0 in spec && 1 in spec && typeof spec[0] === 'string' && typeof spec[1] === 'object';
56
+
47
57
  /**
48
58
  * Normalizes the structure of files imported from './specs'.
49
59
  * We denormalised the spec to save bundle size.
@@ -54,9 +64,20 @@ export function createSpec(nodes, marks) {
54
64
  return Object.keys(specs).reduce((newSpecs, k) => {
55
65
  // Ignored via go/ees005
56
66
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
57
- const spec = {
67
+ let spec = {
58
68
  ...specs[k]
59
69
  };
70
+ if (expValEqualsNoExposure('platform_editor_flexible_list_indentation', 'isEnabled', true) && isVariant(spec) &&
71
+ // Only apply to variants which are explicitly marked for override in `variantSpecOverrides`
72
+ Object.values(variantSpecOverrides).includes(k)) {
73
+ // This allows the variant spec to also have the content normalization applied to it
74
+ // When the spec is a variant it will be in the form of ['base_spec_name', { props: { ... } }]
75
+ // So the actual validator spec of the variant will be the second item in the array
76
+ // We also need to shallow clone this to ensure we don't mutate the original spec
77
+ spec = {
78
+ ...spec[1]
79
+ };
80
+ }
60
81
  if (spec.props) {
61
82
  spec.props = {
62
83
  ...spec.props
@@ -290,22 +311,31 @@ const unsupportedNodeAttributesContent = (entity, errorCode, invalidAttributes,
290
311
  }
291
312
  };
292
313
 
314
+ /**
315
+ * Map of base spec names to a preferred variant spec that should be used in their place during validation.
316
+ *
317
+ * WARNING: The variant spec must be a strict superset of the base spec, i.e. any content valid
318
+ * under the base spec must also be valid under the variant
319
+ */
320
+ const variantSpecOverrides = {
321
+ listItem: 'listItem_with_flexible_first_child',
322
+ taskList: 'taskList_with_flexible_first_child'
323
+ };
324
+
293
325
  /**
294
326
  * Replaces base validator specs with their designated variant overrides
295
327
  */
296
328
  const applyVariantSpecOverrides = validatorSpecs => {
297
- /**
298
- * Map of base spec names to a variant spec that should be used in their place during validation.
299
- *
300
- * WARNING: The variant spec must be a strict superset of the base spec, i.e. any content valid
301
- * under the base spec must also be valid under the variant
302
- */
303
- const variantSpecOverrides = {
304
- listItem: 'listItem_with_flexible_first_child'
305
- };
306
329
  Object.entries(variantSpecOverrides).forEach(([base, variant]) => {
307
- if (validatorSpecs[base] && validatorSpecs[variant]) {
308
- validatorSpecs[base] = validatorSpecs[variant];
330
+ const baseSpec = validatorSpecs[base];
331
+ const variantOverride = validatorSpecs[variant];
332
+ if (baseSpec !== null && baseSpec !== void 0 && baseSpec.props && variantOverride !== null && variantOverride !== void 0 && variantOverride.props && typeof baseSpec.props === 'object' && typeof variantOverride.props === 'object') {
333
+ // Merge variant overrides INTO the base spec
334
+ baseSpec.props = {
335
+ ...baseSpec.props,
336
+ // keeps type, attrs, marks, etc.
337
+ ...variantOverride.props // overrides content (and anything else the variant changes)
338
+ };
309
339
  }
310
340
  });
311
341
  };
@@ -0,0 +1,9 @@
1
+ import { applyMark } from '../utils/apply-mark';
2
+ export var fontSize = function fontSize(attrs) {
3
+ return function (maybeNode) {
4
+ return applyMark({
5
+ type: 'fontSize',
6
+ attrs: attrs
7
+ }, maybeNode);
8
+ };
9
+ };
@@ -0,0 +1,39 @@
1
+ import { traverse } from '../traverse/traverse';
2
+ var NATIVE_EMBED_EXTENSION_KEY = 'native-embed';
3
+
4
+ /**
5
+ * Replaces any `extension` nodes whose `extensionKey` is
6
+ * `native-embed` with a paragraph containing an `inlineCard`
7
+ * node pointing at the same URL.
8
+ * If a native-embed node has no URL it is dropped from the document.
9
+ */
10
+ export var nativeEmbedsFallbackTransform = function nativeEmbedsFallbackTransform(adf) {
11
+ var isTransformed = false;
12
+ var transformedAdf = traverse(adf, {
13
+ extension: function extension(node) {
14
+ var _node$attrs, _node$attrs2;
15
+ if (((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs['extensionKey'].split(':')[0]) !== NATIVE_EMBED_EXTENSION_KEY) {
16
+ return node;
17
+ }
18
+ var url = (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 || (_node$attrs2 = _node$attrs2['parameters']) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.url;
19
+ if (!url) {
20
+ isTransformed = true;
21
+ return false;
22
+ }
23
+ isTransformed = true;
24
+ return {
25
+ type: 'paragraph',
26
+ content: [{
27
+ type: 'inlineCard',
28
+ attrs: {
29
+ url: url
30
+ }
31
+ }]
32
+ };
33
+ }
34
+ });
35
+ return {
36
+ transformedAdf: transformedAdf,
37
+ isTransformed: isTransformed
38
+ };
39
+ };
@@ -11,4 +11,5 @@ export { transformInvalidMediaContent } from './transforms/invalid-media-content
11
11
  export { transformNestedTablesIncomingDocument, isNestedTableExtension } from './transforms/nested-table-transform';
12
12
  export { transformNestedTableNodeOutgoingDocument } from './transforms/nested-table-transform';
13
13
  export { NodeNestingTransformError } from './transforms/errors';
14
- export { syncBlockFallbackTransform } from './transforms/sync-block-fallback-transform';
14
+ export { syncBlockFallbackTransform } from './transforms/sync-block-fallback-transform';
15
+ export { nativeEmbedsFallbackTransform } from './transforms/native-embeds-fallback-transform';
@@ -1,2 +1,2 @@
1
1
  /* eslint-disable @atlaskit/editor/no-re-export */
2
- export { alignment, annotation, backgroundColor, blockCard, block_content, blockRootOnly, blockquote, blockTaskItem, bodiedExtension, bodiedExtension_with_marks, border, breakout, bulletList, caption, code, codeBlock, codeBlock_root_only, text_with_no_marks, confluenceInlineComment, dataConsumer, date, decisionItem, decisionList, doc, em, embedCard, emoji, expand, expand_root_only, extension, extensionFrame, extension_with_marks, fragment, hardBreak, heading, heading_with_alignment, heading_with_indentation, heading_with_no_marks, indentation, inlineCard, inlineExtension, inlineExtension_with_marks, inline_content, layoutColumn, layoutSection, layoutSection_full, layoutSection_with_single_column, link, listItem, listItem_with_flexible_first_child, media, mediaGroup, mediaInline, mediaSingle, mediaSingle_caption, mediaSingle_full, mention, multiBodiedExtension, nestedExpand, nestedExpand_content, nestedExpand_with_no_marks, non_nestable_block_content, orderedList, panel, paragraph, paragraph_with_alignment, paragraph_with_indentation, paragraph_with_no_marks, placeholder, rule, status, strike, strong, subsup, table, tableCell, tableHeader, tableRow, taskItem, taskList, text, textColor, text_code_inline, text_formatted, text_link_inline, underline, syncBlock, bodiedSyncBlock } from '@atlaskit/adf-schema/schema-validator';
2
+ export { alignment, annotation, backgroundColor, blockCard, block_content, blockRootOnly, blockquote, blockTaskItem, bodiedExtension, bodiedExtension_with_marks, border, breakout, bulletList, caption, code, codeBlock, codeBlock_root_only, text_with_no_marks, confluenceInlineComment, dataConsumer, date, decisionItem, decisionList, doc, em, embedCard, emoji, expand, expand_root_only, extension, extensionFrame, extension_with_marks, fontSize, fragment, hardBreak, heading, heading_with_alignment, heading_with_indentation, heading_with_no_marks, indentation, inlineCard, inlineExtension, inlineExtension_with_marks, inline_content, layoutColumn, layoutSection, layoutSection_full, layoutSection_with_single_column, link, listItem, listItem_with_flexible_first_child, media, mediaGroup, mediaInline, mediaSingle, mediaSingle_caption, mediaSingle_full, mention, multiBodiedExtension, nestedExpand, nestedExpand_content, nestedExpand_with_no_marks, non_nestable_block_content, orderedList, panel, paragraph, paragraph_with_alignment, paragraph_with_font_size, paragraph_with_font_size_and_alignment, paragraph_with_font_size_and_indentation, paragraph_with_indentation, paragraph_with_no_marks, placeholder, rule, status, strike, strong, subsup, table, tableCell, tableHeader, tableRow, taskItem, taskList, taskList_with_flexible_first_child, text, textColor, text_code_inline, text_formatted, text_link_inline, underline, syncBlock, bodiedSyncBlock } from '@atlaskit/adf-schema/schema-validator';
@@ -1,5 +1,5 @@
1
- import _typeof from "@babel/runtime/helpers/typeof";
2
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import _typeof from "@babel/runtime/helpers/typeof";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
5
  var _excluded = ["items"];
@@ -55,6 +55,18 @@ var partitionObject = function partitionObject(obj, predicate) {
55
55
  }, [[], []]);
56
56
  };
57
57
 
58
+ /**
59
+ * Checks if a spec is a variant spec.
60
+ * A variant spec is an array where the first element is a string (base spec name)
61
+ * and the second element is a ValidatorSpec object { props: { ... } }
62
+ *
63
+ * @param spec - The spec to check
64
+ * @returns true if the spec is a variant spec, false otherwise
65
+ */
66
+ var isVariant = function isVariant(spec) {
67
+ return _typeof(spec) === 'object' && !!spec && 0 in spec && 1 in spec && typeof spec[0] === 'string' && _typeof(spec[1]) === 'object';
68
+ };
69
+
58
70
  /**
59
71
  * Normalizes the structure of files imported from './specs'.
60
72
  * We denormalised the spec to save bundle size.
@@ -66,6 +78,15 @@ export function createSpec(nodes, marks) {
66
78
  // Ignored via go/ees005
67
79
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
68
80
  var spec = _objectSpread({}, specs[k]);
81
+ if (expValEqualsNoExposure('platform_editor_flexible_list_indentation', 'isEnabled', true) && isVariant(spec) &&
82
+ // Only apply to variants which are explicitly marked for override in `variantSpecOverrides`
83
+ Object.values(variantSpecOverrides).includes(k)) {
84
+ // This allows the variant spec to also have the content normalization applied to it
85
+ // When the spec is a variant it will be in the form of ['base_spec_name', { props: { ... } }]
86
+ // So the actual validator spec of the variant will be the second item in the array
87
+ // We also need to shallow clone this to ensure we don't mutate the original spec
88
+ spec = _objectSpread({}, spec[1]);
89
+ }
69
90
  if (spec.props) {
70
91
  spec.props = _objectSpread({}, spec.props);
71
92
  if (spec.props.content) {
@@ -320,25 +341,30 @@ var unsupportedNodeAttributesContent = function unsupportedNodeAttributesContent
320
341
  }
321
342
  };
322
343
 
344
+ /**
345
+ * Map of base spec names to a preferred variant spec that should be used in their place during validation.
346
+ *
347
+ * WARNING: The variant spec must be a strict superset of the base spec, i.e. any content valid
348
+ * under the base spec must also be valid under the variant
349
+ */
350
+ var variantSpecOverrides = {
351
+ listItem: 'listItem_with_flexible_first_child',
352
+ taskList: 'taskList_with_flexible_first_child'
353
+ };
354
+
323
355
  /**
324
356
  * Replaces base validator specs with their designated variant overrides
325
357
  */
326
358
  var applyVariantSpecOverrides = function applyVariantSpecOverrides(validatorSpecs) {
327
- /**
328
- * Map of base spec names to a variant spec that should be used in their place during validation.
329
- *
330
- * WARNING: The variant spec must be a strict superset of the base spec, i.e. any content valid
331
- * under the base spec must also be valid under the variant
332
- */
333
- var variantSpecOverrides = {
334
- listItem: 'listItem_with_flexible_first_child'
335
- };
336
359
  Object.entries(variantSpecOverrides).forEach(function (_ref2) {
337
360
  var _ref3 = _slicedToArray(_ref2, 2),
338
361
  base = _ref3[0],
339
362
  variant = _ref3[1];
340
- if (validatorSpecs[base] && validatorSpecs[variant]) {
341
- validatorSpecs[base] = validatorSpecs[variant];
363
+ var baseSpec = validatorSpecs[base];
364
+ var variantOverride = validatorSpecs[variant];
365
+ if (baseSpec !== null && baseSpec !== void 0 && baseSpec.props && variantOverride !== null && variantOverride !== void 0 && variantOverride.props && _typeof(baseSpec.props) === 'object' && _typeof(variantOverride.props) === 'object') {
366
+ // Merge variant overrides INTO the base spec
367
+ baseSpec.props = _objectSpread(_objectSpread({}, baseSpec.props), variantOverride.props);
342
368
  }
343
369
  });
344
370
  };
@@ -0,0 +1,3 @@
1
+ import { type FontSizeMarkAttrs, type FontSizeMarkDefinition, type ParagraphDefinition } from '@atlaskit/adf-schema';
2
+ import { type WithMark, type WithAppliedMark } from '../types';
3
+ export declare const fontSize: (attrs: FontSizeMarkAttrs) => (maybeNode: WithMark | string) => WithAppliedMark<ParagraphDefinition, FontSizeMarkDefinition>;
@@ -0,0 +1,11 @@
1
+ import { type ADFEntity } from '../types';
2
+ /**
3
+ * Replaces any `extension` nodes whose `extensionKey` is
4
+ * `native-embed` with a paragraph containing an `inlineCard`
5
+ * node pointing at the same URL.
6
+ * If a native-embed node has no URL it is dropped from the document.
7
+ */
8
+ export declare const nativeEmbedsFallbackTransform: (adf: ADFEntity) => {
9
+ isTransformed: boolean;
10
+ transformedAdf: false | ADFEntity;
11
+ };
@@ -9,3 +9,4 @@ export { transformNestedTablesIncomingDocument, isNestedTableExtension, } from '
9
9
  export { transformNestedTableNodeOutgoingDocument } from './transforms/nested-table-transform';
10
10
  export { NodeNestingTransformError } from './transforms/errors';
11
11
  export { syncBlockFallbackTransform } from './transforms/sync-block-fallback-transform';
12
+ export { nativeEmbedsFallbackTransform } from './transforms/native-embeds-fallback-transform';
@@ -1 +1 @@
1
- export { alignment, annotation, backgroundColor, blockCard, block_content, blockRootOnly, blockquote, blockTaskItem, bodiedExtension, bodiedExtension_with_marks, border, breakout, bulletList, caption, code, codeBlock, codeBlock_root_only, text_with_no_marks, confluenceInlineComment, dataConsumer, date, decisionItem, decisionList, doc, em, embedCard, emoji, expand, expand_root_only, extension, extensionFrame, extension_with_marks, fragment, hardBreak, heading, heading_with_alignment, heading_with_indentation, heading_with_no_marks, indentation, inlineCard, inlineExtension, inlineExtension_with_marks, inline_content, layoutColumn, layoutSection, layoutSection_full, layoutSection_with_single_column, link, listItem, listItem_with_flexible_first_child, media, mediaGroup, mediaInline, mediaSingle, mediaSingle_caption, mediaSingle_full, mention, multiBodiedExtension, nestedExpand, nestedExpand_content, nestedExpand_with_no_marks, non_nestable_block_content, orderedList, panel, paragraph, paragraph_with_alignment, paragraph_with_indentation, paragraph_with_no_marks, placeholder, rule, status, strike, strong, subsup, table, tableCell, tableHeader, tableRow, taskItem, taskList, text, textColor, text_code_inline, text_formatted, text_link_inline, underline, syncBlock, bodiedSyncBlock, } from '@atlaskit/adf-schema/schema-validator';
1
+ export { alignment, annotation, backgroundColor, blockCard, block_content, blockRootOnly, blockquote, blockTaskItem, bodiedExtension, bodiedExtension_with_marks, border, breakout, bulletList, caption, code, codeBlock, codeBlock_root_only, text_with_no_marks, confluenceInlineComment, dataConsumer, date, decisionItem, decisionList, doc, em, embedCard, emoji, expand, expand_root_only, extension, extensionFrame, extension_with_marks, fontSize, fragment, hardBreak, heading, heading_with_alignment, heading_with_indentation, heading_with_no_marks, indentation, inlineCard, inlineExtension, inlineExtension_with_marks, inline_content, layoutColumn, layoutSection, layoutSection_full, layoutSection_with_single_column, link, listItem, listItem_with_flexible_first_child, media, mediaGroup, mediaInline, mediaSingle, mediaSingle_caption, mediaSingle_full, mention, multiBodiedExtension, nestedExpand, nestedExpand_content, nestedExpand_with_no_marks, non_nestable_block_content, orderedList, panel, paragraph, paragraph_with_alignment, paragraph_with_font_size, paragraph_with_font_size_and_alignment, paragraph_with_font_size_and_indentation, paragraph_with_indentation, paragraph_with_no_marks, placeholder, rule, status, strike, strong, subsup, table, tableCell, tableHeader, tableRow, taskItem, taskList, taskList_with_flexible_first_child, text, textColor, text_code_inline, text_formatted, text_link_inline, underline, syncBlock, bodiedSyncBlock, } from '@atlaskit/adf-schema/schema-validator';
@@ -0,0 +1,3 @@
1
+ import { type FontSizeMarkAttrs, type FontSizeMarkDefinition, type ParagraphDefinition } from '@atlaskit/adf-schema';
2
+ import { type WithMark, type WithAppliedMark } from '../types';
3
+ export declare const fontSize: (attrs: FontSizeMarkAttrs) => (maybeNode: WithMark | string) => WithAppliedMark<ParagraphDefinition, FontSizeMarkDefinition>;
@@ -0,0 +1,11 @@
1
+ import { type ADFEntity } from '../types';
2
+ /**
3
+ * Replaces any `extension` nodes whose `extensionKey` is
4
+ * `native-embed` with a paragraph containing an `inlineCard`
5
+ * node pointing at the same URL.
6
+ * If a native-embed node has no URL it is dropped from the document.
7
+ */
8
+ export declare const nativeEmbedsFallbackTransform: (adf: ADFEntity) => {
9
+ isTransformed: boolean;
10
+ transformedAdf: false | ADFEntity;
11
+ };
@@ -9,3 +9,4 @@ export { transformNestedTablesIncomingDocument, isNestedTableExtension, } from '
9
9
  export { transformNestedTableNodeOutgoingDocument } from './transforms/nested-table-transform';
10
10
  export { NodeNestingTransformError } from './transforms/errors';
11
11
  export { syncBlockFallbackTransform } from './transforms/sync-block-fallback-transform';
12
+ export { nativeEmbedsFallbackTransform } from './transforms/native-embeds-fallback-transform';
@@ -1 +1 @@
1
- export { alignment, annotation, backgroundColor, blockCard, block_content, blockRootOnly, blockquote, blockTaskItem, bodiedExtension, bodiedExtension_with_marks, border, breakout, bulletList, caption, code, codeBlock, codeBlock_root_only, text_with_no_marks, confluenceInlineComment, dataConsumer, date, decisionItem, decisionList, doc, em, embedCard, emoji, expand, expand_root_only, extension, extensionFrame, extension_with_marks, fragment, hardBreak, heading, heading_with_alignment, heading_with_indentation, heading_with_no_marks, indentation, inlineCard, inlineExtension, inlineExtension_with_marks, inline_content, layoutColumn, layoutSection, layoutSection_full, layoutSection_with_single_column, link, listItem, listItem_with_flexible_first_child, media, mediaGroup, mediaInline, mediaSingle, mediaSingle_caption, mediaSingle_full, mention, multiBodiedExtension, nestedExpand, nestedExpand_content, nestedExpand_with_no_marks, non_nestable_block_content, orderedList, panel, paragraph, paragraph_with_alignment, paragraph_with_indentation, paragraph_with_no_marks, placeholder, rule, status, strike, strong, subsup, table, tableCell, tableHeader, tableRow, taskItem, taskList, text, textColor, text_code_inline, text_formatted, text_link_inline, underline, syncBlock, bodiedSyncBlock, } from '@atlaskit/adf-schema/schema-validator';
1
+ export { alignment, annotation, backgroundColor, blockCard, block_content, blockRootOnly, blockquote, blockTaskItem, bodiedExtension, bodiedExtension_with_marks, border, breakout, bulletList, caption, code, codeBlock, codeBlock_root_only, text_with_no_marks, confluenceInlineComment, dataConsumer, date, decisionItem, decisionList, doc, em, embedCard, emoji, expand, expand_root_only, extension, extensionFrame, extension_with_marks, fontSize, fragment, hardBreak, heading, heading_with_alignment, heading_with_indentation, heading_with_no_marks, indentation, inlineCard, inlineExtension, inlineExtension_with_marks, inline_content, layoutColumn, layoutSection, layoutSection_full, layoutSection_with_single_column, link, listItem, listItem_with_flexible_first_child, media, mediaGroup, mediaInline, mediaSingle, mediaSingle_caption, mediaSingle_full, mention, multiBodiedExtension, nestedExpand, nestedExpand_content, nestedExpand_with_no_marks, non_nestable_block_content, orderedList, panel, paragraph, paragraph_with_alignment, paragraph_with_font_size, paragraph_with_font_size_and_alignment, paragraph_with_font_size_and_indentation, paragraph_with_indentation, paragraph_with_no_marks, placeholder, rule, status, strike, strong, subsup, table, tableCell, tableHeader, tableRow, taskItem, taskList, taskList_with_flexible_first_child, text, textColor, text_code_inline, text_formatted, text_link_inline, underline, syncBlock, bodiedSyncBlock, } from '@atlaskit/adf-schema/schema-validator';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-utils",
3
- "version": "19.27.2",
3
+ "version": "19.27.4",
4
4
  "description": "Set of utilities to traverse, modify and create ADF documents.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -26,9 +26,9 @@
26
26
  "team": "Editor: Collaboration"
27
27
  },
28
28
  "dependencies": {
29
- "@atlaskit/adf-schema": "^52.0.0",
29
+ "@atlaskit/adf-schema": "^52.2.0",
30
30
  "@atlaskit/platform-feature-flags": "^1.1.0",
31
- "@atlaskit/tmp-editor-statsig": "^32.0.0",
31
+ "@atlaskit/tmp-editor-statsig": "^33.0.0",
32
32
  "@babel/runtime": "^7.0.0"
33
33
  },
34
34
  "devDependencies": {