@atlaskit/adf-schema 36.10.9 → 36.10.10

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/next-schema/marks/alignmentAndIndentation.js +5 -6
  3. package/dist/cjs/next-schema/marks/annotation.js +5 -2
  4. package/dist/cjs/next-schema/marks/breakout.js +1 -1
  5. package/dist/cjs/next-schema/marks/code.js +2 -2
  6. package/dist/cjs/next-schema/marks/color.js +29 -0
  7. package/dist/cjs/next-schema/marks/dataConsumer.js +2 -1
  8. package/dist/cjs/next-schema/nodes/text.js +2 -3
  9. package/dist/es2019/next-schema/marks/alignmentAndIndentation.js +5 -6
  10. package/dist/es2019/next-schema/marks/annotation.js +5 -2
  11. package/dist/es2019/next-schema/marks/breakout.js +1 -1
  12. package/dist/es2019/next-schema/marks/code.js +1 -1
  13. package/dist/es2019/next-schema/marks/color.js +24 -0
  14. package/dist/es2019/next-schema/marks/dataConsumer.js +2 -1
  15. package/dist/es2019/next-schema/nodes/text.js +1 -2
  16. package/dist/esm/next-schema/marks/alignmentAndIndentation.js +5 -6
  17. package/dist/esm/next-schema/marks/annotation.js +5 -2
  18. package/dist/esm/next-schema/marks/breakout.js +1 -1
  19. package/dist/esm/next-schema/marks/code.js +1 -1
  20. package/dist/esm/next-schema/marks/color.js +24 -0
  21. package/dist/esm/next-schema/marks/dataConsumer.js +2 -1
  22. package/dist/esm/next-schema/nodes/text.js +1 -2
  23. package/dist/types/next-schema/marks/annotation.d.ts +1 -0
  24. package/dist/types/next-schema/marks/color.d.ts +3 -0
  25. package/package.json +3 -3
  26. package/schema-generators/__tests__/unit/validate-pm-schema.unit.ts +110 -0
  27. package/dist/cjs/next-schema/groups/annotationGroup.js +0 -8
  28. package/dist/cjs/next-schema/groups/colorGroup.js +0 -9
  29. package/dist/cjs/next-schema/marks/backgroundColor.js +0 -15
  30. package/dist/cjs/next-schema/marks/textColor.js +0 -16
  31. package/dist/es2019/next-schema/groups/annotationGroup.js +0 -2
  32. package/dist/es2019/next-schema/groups/colorGroup.js +0 -3
  33. package/dist/es2019/next-schema/marks/backgroundColor.js +0 -9
  34. package/dist/es2019/next-schema/marks/textColor.js +0 -10
  35. package/dist/esm/next-schema/groups/annotationGroup.js +0 -2
  36. package/dist/esm/next-schema/groups/colorGroup.js +0 -3
  37. package/dist/esm/next-schema/marks/backgroundColor.js +0 -9
  38. package/dist/esm/next-schema/marks/textColor.js +0 -10
  39. package/dist/types/next-schema/groups/annotationGroup.d.ts +0 -1
  40. package/dist/types/next-schema/groups/colorGroup.d.ts +0 -1
  41. package/dist/types/next-schema/marks/backgroundColor.d.ts +0 -1
  42. package/dist/types/next-schema/marks/textColor.d.ts +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/adf-schema
2
2
 
3
+ ## 36.10.10
4
+
5
+ ### Patch Changes
6
+
7
+ - b29eee7: update ADF DSL to match old PM spec, add validation unit test to verify nodeSpec and markSpec generated from ADF DSL
8
+
3
9
  ## 36.10.9
4
10
 
5
11
  ### Patch Changes
@@ -8,20 +8,19 @@ var _adfSchemaGenerator = require("@atlaskit/adf-schema-generator");
8
8
  // These marks defined together because they form a cycle within the excludes.
9
9
  var alignment = exports.alignment = (0, _adfSchemaGenerator.adfMark)('alignment');
10
10
  var indentation = exports.indentation = (0, _adfSchemaGenerator.adfMark)('indentation');
11
- var alignementMarkExclusionGroup = (0, _adfSchemaGenerator.adfMarkGroup)('alignmentMarkExclusion', [alignment]);
12
- var indentationMarkExclusionGroup = (0, _adfSchemaGenerator.adfMarkGroup)('indentationMarkExclusion', [indentation]);
11
+ var alignementMarkExclusionGroup = (0, _adfSchemaGenerator.adfMarkGroup)('alignment', [alignment]);
12
+ var indentationMarkExclusionGroup = (0, _adfSchemaGenerator.adfMarkGroup)('indentation', [indentation]);
13
13
  alignment.define({
14
- excludes: [indentationMarkExclusionGroup],
14
+ excludes: [alignementMarkExclusionGroup, indentationMarkExclusionGroup],
15
15
  attrs: {
16
16
  align: {
17
17
  type: 'enum',
18
- values: ['center', 'end'],
19
- default: 'center'
18
+ values: ['center', 'end']
20
19
  }
21
20
  }
22
21
  });
23
22
  indentation.define({
24
- excludes: [alignementMarkExclusionGroup],
23
+ excludes: [indentationMarkExclusionGroup, alignementMarkExclusionGroup],
25
24
  attrs: {
26
25
  level: {
27
26
  type: 'number',
@@ -3,10 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.annotation = void 0;
6
+ exports.annotationGroup = exports.annotation = void 0;
7
7
  var _adfSchemaGenerator = require("@atlaskit/adf-schema-generator");
8
- var annotation = exports.annotation = (0, _adfSchemaGenerator.adfMark)('annotation').define({
8
+ var annotation = exports.annotation = (0, _adfSchemaGenerator.adfMark)('annotation');
9
+ var annotationGroup = exports.annotationGroup = (0, _adfSchemaGenerator.adfMarkGroup)('annotation', [annotation]);
10
+ annotation.define({
9
11
  inclusive: true,
12
+ group: annotationGroup,
10
13
  attrs: {
11
14
  id: {
12
15
  type: 'string',
@@ -7,7 +7,7 @@ exports.breakout = void 0;
7
7
  var _adfSchemaGenerator = require("@atlaskit/adf-schema-generator");
8
8
  var breakout = exports.breakout = (0, _adfSchemaGenerator.adfMark)('breakout').define({
9
9
  spanning: false,
10
- inclusive: true,
10
+ inclusive: false,
11
11
  attrs: {
12
12
  mode: {
13
13
  type: 'enum',
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.code = void 0;
7
7
  var _adfSchemaGenerator = require("@atlaskit/adf-schema-generator");
8
- var _colorGroup = require("../groups/colorGroup");
9
8
  var _fontStyleGroup = require("../groups/fontStyleGroup");
10
9
  var _linkMarkGroup = require("../groups/linkMarkGroup");
11
10
  var _searchQueryMarkGroup = require("../groups/searchQueryMarkGroup");
11
+ var _color = require("./color");
12
12
  var code = exports.code = (0, _adfSchemaGenerator.adfMark)('code').define({
13
- excludes: [_fontStyleGroup.fontStyleGroup, _linkMarkGroup.linkMarkGroup, _searchQueryMarkGroup.searchQueryMarkGroup, _colorGroup.colorGroup],
13
+ excludes: [_fontStyleGroup.fontStyleGroup, _linkMarkGroup.linkMarkGroup, _searchQueryMarkGroup.searchQueryMarkGroup, _color.colorGroup],
14
14
  inclusive: true
15
15
  });
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.textColor = exports.colorGroup = exports.backgroundColor = void 0;
7
+ var _adfSchemaGenerator = require("@atlaskit/adf-schema-generator");
8
+ var backgroundColor = exports.backgroundColor = (0, _adfSchemaGenerator.adfMark)('backgroundColor');
9
+ var textColor = exports.textColor = (0, _adfSchemaGenerator.adfMark)('textColor');
10
+ var colorGroup = exports.colorGroup = (0, _adfSchemaGenerator.adfMarkGroup)('color', [textColor, backgroundColor]);
11
+ backgroundColor.define({
12
+ inclusive: true,
13
+ excludes: [colorGroup],
14
+ attrs: {
15
+ color: {
16
+ pattern: '^#[0-9a-fA-F]{6}$',
17
+ type: 'string'
18
+ }
19
+ }
20
+ });
21
+ textColor.define({
22
+ inclusive: true,
23
+ attrs: {
24
+ color: {
25
+ type: 'string',
26
+ pattern: '^#[0-9a-fA-F]{6}$'
27
+ }
28
+ }
29
+ });
@@ -12,7 +12,8 @@ var dataConsumer = exports.dataConsumer = (0, _adfSchemaGenerator.adfMark)('data
12
12
  items: {
13
13
  type: 'string'
14
14
  },
15
- minItems: 1
15
+ minItems: 1,
16
+ default: []
16
17
  }
17
18
  }
18
19
  });
@@ -12,11 +12,10 @@ var _link = require("../marks/link");
12
12
  var _strike = require("../marks/strike");
13
13
  var _strong = require("../marks/strong");
14
14
  var _subsup = require("../marks/subsup");
15
- var _textColor = require("../marks/textColor");
16
15
  var _underline = require("../marks/underline");
17
- var _backgroundColor = require("../marks/backgroundColor");
16
+ var _color = require("../marks/color");
18
17
  var text = exports.text = (0, _adfSchemaGenerator.adfNode)('text').define({}).variant('formatted', {
19
- marks: [_link.link, _em.em, _strong.strong, _strike.strike, _subsup.subsup, _underline.underline, _textColor.textColor, _annotation.annotation, _backgroundColor.backgroundColor]
18
+ marks: [_link.link, _em.em, _strong.strong, _strike.strike, _subsup.subsup, _underline.underline, _color.textColor, _annotation.annotation, _color.backgroundColor]
20
19
  }).variant('code_inline', {
21
20
  marks: [_code.code, _link.link, _annotation.annotation]
22
21
  });
@@ -4,20 +4,19 @@ import { adfMarkGroup } from '@atlaskit/adf-schema-generator';
4
4
  // These marks defined together because they form a cycle within the excludes.
5
5
  export const alignment = adfMark('alignment');
6
6
  export const indentation = adfMark('indentation');
7
- const alignementMarkExclusionGroup = adfMarkGroup('alignmentMarkExclusion', [alignment]);
8
- const indentationMarkExclusionGroup = adfMarkGroup('indentationMarkExclusion', [indentation]);
7
+ const alignementMarkExclusionGroup = adfMarkGroup('alignment', [alignment]);
8
+ const indentationMarkExclusionGroup = adfMarkGroup('indentation', [indentation]);
9
9
  alignment.define({
10
- excludes: [indentationMarkExclusionGroup],
10
+ excludes: [alignementMarkExclusionGroup, indentationMarkExclusionGroup],
11
11
  attrs: {
12
12
  align: {
13
13
  type: 'enum',
14
- values: ['center', 'end'],
15
- default: 'center'
14
+ values: ['center', 'end']
16
15
  }
17
16
  }
18
17
  });
19
18
  indentation.define({
20
- excludes: [alignementMarkExclusionGroup],
19
+ excludes: [indentationMarkExclusionGroup, alignementMarkExclusionGroup],
21
20
  attrs: {
22
21
  level: {
23
22
  type: 'number',
@@ -1,6 +1,9 @@
1
- import { adfMark } from '@atlaskit/adf-schema-generator';
2
- export const annotation = adfMark('annotation').define({
1
+ import { adfMark, adfMarkGroup } from '@atlaskit/adf-schema-generator';
2
+ export const annotation = adfMark('annotation');
3
+ export const annotationGroup = adfMarkGroup('annotation', [annotation]);
4
+ annotation.define({
3
5
  inclusive: true,
6
+ group: annotationGroup,
4
7
  attrs: {
5
8
  id: {
6
9
  type: 'string',
@@ -1,7 +1,7 @@
1
1
  import { adfMark } from '@atlaskit/adf-schema-generator';
2
2
  export const breakout = adfMark('breakout').define({
3
3
  spanning: false,
4
- inclusive: true,
4
+ inclusive: false,
5
5
  attrs: {
6
6
  mode: {
7
7
  type: 'enum',
@@ -1,8 +1,8 @@
1
1
  import { adfMark } from '@atlaskit/adf-schema-generator';
2
- import { colorGroup } from '../groups/colorGroup';
3
2
  import { fontStyleGroup } from '../groups/fontStyleGroup';
4
3
  import { linkMarkGroup } from '../groups/linkMarkGroup';
5
4
  import { searchQueryMarkGroup } from '../groups/searchQueryMarkGroup';
5
+ import { colorGroup } from './color';
6
6
  export const code = adfMark('code').define({
7
7
  excludes: [fontStyleGroup, linkMarkGroup, searchQueryMarkGroup, colorGroup],
8
8
  inclusive: true
@@ -0,0 +1,24 @@
1
+ import { adfMark } from '@atlaskit/adf-schema-generator';
2
+ import { adfMarkGroup } from '@atlaskit/adf-schema-generator';
3
+ export const backgroundColor = adfMark('backgroundColor');
4
+ export const textColor = adfMark('textColor');
5
+ export const colorGroup = adfMarkGroup('color', [textColor, backgroundColor]);
6
+ backgroundColor.define({
7
+ inclusive: true,
8
+ excludes: [colorGroup],
9
+ attrs: {
10
+ color: {
11
+ pattern: '^#[0-9a-fA-F]{6}$',
12
+ type: 'string'
13
+ }
14
+ }
15
+ });
16
+ textColor.define({
17
+ inclusive: true,
18
+ attrs: {
19
+ color: {
20
+ type: 'string',
21
+ pattern: '^#[0-9a-fA-F]{6}$'
22
+ }
23
+ }
24
+ });
@@ -6,7 +6,8 @@ export const dataConsumer = adfMark('dataConsumer').define({
6
6
  items: {
7
7
  type: 'string'
8
8
  },
9
- minItems: 1
9
+ minItems: 1,
10
+ default: []
10
11
  }
11
12
  }
12
13
  });
@@ -6,9 +6,8 @@ import { link } from '../marks/link';
6
6
  import { strike } from '../marks/strike';
7
7
  import { strong } from '../marks/strong';
8
8
  import { subsup } from '../marks/subsup';
9
- import { textColor } from '../marks/textColor';
10
9
  import { underline } from '../marks/underline';
11
- import { backgroundColor } from '../marks/backgroundColor';
10
+ import { backgroundColor, textColor } from '../marks/color';
12
11
  export const text = adfNode('text').define({}).variant('formatted', {
13
12
  marks: [link, em, strong, strike, subsup, underline, textColor, annotation, backgroundColor]
14
13
  }).variant('code_inline', {
@@ -4,20 +4,19 @@ import { adfMarkGroup } from '@atlaskit/adf-schema-generator';
4
4
  // These marks defined together because they form a cycle within the excludes.
5
5
  export var alignment = adfMark('alignment');
6
6
  export var indentation = adfMark('indentation');
7
- var alignementMarkExclusionGroup = adfMarkGroup('alignmentMarkExclusion', [alignment]);
8
- var indentationMarkExclusionGroup = adfMarkGroup('indentationMarkExclusion', [indentation]);
7
+ var alignementMarkExclusionGroup = adfMarkGroup('alignment', [alignment]);
8
+ var indentationMarkExclusionGroup = adfMarkGroup('indentation', [indentation]);
9
9
  alignment.define({
10
- excludes: [indentationMarkExclusionGroup],
10
+ excludes: [alignementMarkExclusionGroup, indentationMarkExclusionGroup],
11
11
  attrs: {
12
12
  align: {
13
13
  type: 'enum',
14
- values: ['center', 'end'],
15
- default: 'center'
14
+ values: ['center', 'end']
16
15
  }
17
16
  }
18
17
  });
19
18
  indentation.define({
20
- excludes: [alignementMarkExclusionGroup],
19
+ excludes: [indentationMarkExclusionGroup, alignementMarkExclusionGroup],
21
20
  attrs: {
22
21
  level: {
23
22
  type: 'number',
@@ -1,6 +1,9 @@
1
- import { adfMark } from '@atlaskit/adf-schema-generator';
2
- export var annotation = adfMark('annotation').define({
1
+ import { adfMark, adfMarkGroup } from '@atlaskit/adf-schema-generator';
2
+ export var annotation = adfMark('annotation');
3
+ export var annotationGroup = adfMarkGroup('annotation', [annotation]);
4
+ annotation.define({
3
5
  inclusive: true,
6
+ group: annotationGroup,
4
7
  attrs: {
5
8
  id: {
6
9
  type: 'string',
@@ -1,7 +1,7 @@
1
1
  import { adfMark } from '@atlaskit/adf-schema-generator';
2
2
  export var breakout = adfMark('breakout').define({
3
3
  spanning: false,
4
- inclusive: true,
4
+ inclusive: false,
5
5
  attrs: {
6
6
  mode: {
7
7
  type: 'enum',
@@ -1,8 +1,8 @@
1
1
  import { adfMark } from '@atlaskit/adf-schema-generator';
2
- import { colorGroup } from '../groups/colorGroup';
3
2
  import { fontStyleGroup } from '../groups/fontStyleGroup';
4
3
  import { linkMarkGroup } from '../groups/linkMarkGroup';
5
4
  import { searchQueryMarkGroup } from '../groups/searchQueryMarkGroup';
5
+ import { colorGroup } from './color';
6
6
  export var code = adfMark('code').define({
7
7
  excludes: [fontStyleGroup, linkMarkGroup, searchQueryMarkGroup, colorGroup],
8
8
  inclusive: true
@@ -0,0 +1,24 @@
1
+ import { adfMark } from '@atlaskit/adf-schema-generator';
2
+ import { adfMarkGroup } from '@atlaskit/adf-schema-generator';
3
+ export var backgroundColor = adfMark('backgroundColor');
4
+ export var textColor = adfMark('textColor');
5
+ export var colorGroup = adfMarkGroup('color', [textColor, backgroundColor]);
6
+ backgroundColor.define({
7
+ inclusive: true,
8
+ excludes: [colorGroup],
9
+ attrs: {
10
+ color: {
11
+ pattern: '^#[0-9a-fA-F]{6}$',
12
+ type: 'string'
13
+ }
14
+ }
15
+ });
16
+ textColor.define({
17
+ inclusive: true,
18
+ attrs: {
19
+ color: {
20
+ type: 'string',
21
+ pattern: '^#[0-9a-fA-F]{6}$'
22
+ }
23
+ }
24
+ });
@@ -6,7 +6,8 @@ export var dataConsumer = adfMark('dataConsumer').define({
6
6
  items: {
7
7
  type: 'string'
8
8
  },
9
- minItems: 1
9
+ minItems: 1,
10
+ default: []
10
11
  }
11
12
  }
12
13
  });
@@ -6,9 +6,8 @@ import { link } from '../marks/link';
6
6
  import { strike } from '../marks/strike';
7
7
  import { strong } from '../marks/strong';
8
8
  import { subsup } from '../marks/subsup';
9
- import { textColor } from '../marks/textColor';
10
9
  import { underline } from '../marks/underline';
11
- import { backgroundColor } from '../marks/backgroundColor';
10
+ import { backgroundColor, textColor } from '../marks/color';
12
11
  export var text = adfNode('text').define({}).variant('formatted', {
13
12
  marks: [link, em, strong, strike, subsup, underline, textColor, annotation, backgroundColor]
14
13
  }).variant('code_inline', {
@@ -1 +1,2 @@
1
1
  export declare const annotation: import("@atlaskit/adf-schema-generator/dist/types/adfMark").ADFMark<import("@atlaskit/adf-schema-generator/dist/types/types/ADFMarkSpec").ADFMarkSpec>;
2
+ export declare const annotationGroup: import("@atlaskit/adf-schema-generator/dist/types/types/ADFMarkGroup").ADFMarkGroup;
@@ -0,0 +1,3 @@
1
+ export declare const backgroundColor: import("@atlaskit/adf-schema-generator/dist/types/adfMark").ADFMark<import("@atlaskit/adf-schema-generator/dist/types/types/ADFMarkSpec").ADFMarkSpec>;
2
+ export declare const textColor: import("@atlaskit/adf-schema-generator/dist/types/adfMark").ADFMark<import("@atlaskit/adf-schema-generator/dist/types/types/ADFMarkSpec").ADFMarkSpec>;
3
+ export declare const colorGroup: import("@atlaskit/adf-schema-generator/dist/types/types/ADFMarkGroup").ADFMarkGroup;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-schema",
3
- "version": "36.10.9",
3
+ "version": "36.10.10",
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/"
@@ -21,7 +21,7 @@
21
21
  "generate:json-schema:full": "json-schema-generator --outDir=./json-schema/v1/ ./src/schema/nodes/doc.ts",
22
22
  "ak-postbuild": "yarn build:json-schema",
23
23
  "test": "yarn test:unit",
24
- "test:unit": "yarn workspace @atlaskit/editor-prosemirror build && jest --testPathPattern=adf-schema/src --config=../../jest.config.js",
24
+ "test:unit": "yarn workspace @atlaskit/editor-prosemirror build && jest --testPathPattern=packages/adf-schema/ --config=../../jest.config.js",
25
25
  "build:cjs": "NODE_ENV=production BABEL_ENV=production:node-cjs babel --config-file ../../babel.config.js src --out-dir dist/cjs -x .ts,.tsx",
26
26
  "build:esm": "NODE_ENV=production BABEL_ENV=production:esm babel --config-file ../../babel.config.js src -d dist/esm -x .ts,.tsx",
27
27
  "build:es2019": "NODE_ENV=production BABEL_ENV=production:es2019 babel --config-file ../../babel.config.js src -d dist/es2019 -x .ts,.tsx",
@@ -45,7 +45,7 @@
45
45
  },
46
46
  "devDependencies": {
47
47
  "@atlassian/adf-schema-json": "^1.15.0",
48
- "@atlaskit/adf-schema-generator": "^1.8.2",
48
+ "@atlaskit/adf-schema-generator": "^1.8.3",
49
49
  "@babel/cli": "^7.22.9",
50
50
  "@babel/core": "^7.22.9",
51
51
  "@babel/plugin-proposal-class-properties": "^7.18.6",
@@ -0,0 +1,110 @@
1
+ import { MarkSpec, NodeSpec, Schema } from '@atlaskit/editor-prosemirror/model';
2
+ import * as newMarkSpecs from '@atlaskit/adf-schema-generator/src/generated/markTypes';
3
+ import * as newNodeSpecs from '@atlaskit/adf-schema-generator/src/generated/nodeTypes';
4
+ import {
5
+ MarkSpecFactory,
6
+ NodeSpecFactory,
7
+ } from '@atlaskit/adf-schema-generator/src/transforms/adfToPm/createPMSpecFactory';
8
+ import { defaultSchema } from '../../../src/schema/default-schema';
9
+
10
+ function isMarkSpec(value: MarkSpec | NodeSpec): value is MarkSpec {
11
+ return true;
12
+ }
13
+
14
+ /**
15
+ * Custom omit function, mainly used to filter out parseDOM and toDOM from old spec
16
+ * and some special logic to filter out certain field when compare spec
17
+ * @param data
18
+ * @param keys
19
+ * @returns
20
+ */
21
+ function omit<T extends object>(data: T, keys: (keyof T)[]): T {
22
+ const result = { ...data };
23
+ for (const k of keys) {
24
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
25
+ delete result[k];
26
+ }
27
+ if (isMarkSpec(data)) {
28
+ // Treat excludes: '' same as no excludes property
29
+ if (data.excludes !== undefined && data.excludes === '') {
30
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
31
+ delete result['excludes'];
32
+ }
33
+ }
34
+ return result;
35
+ }
36
+
37
+ describe('validate PM schema', () => {
38
+ describe('marks', () => {
39
+ const { marks } = defaultSchema as Schema;
40
+ const skipLists = [
41
+ 'link', // TODO: new link mark is not matching old link mark
42
+ 'confluenceInlineComment', // TODO: not exist in ADF DSL
43
+ 'unsupportedMark', // TODO: not exist in ADF DSL
44
+ 'unsupportedNodeAttribute', // TODO: not exist in ADF DSL
45
+ 'typeAheadQuery', // TODO: not exist in ADF DSL
46
+ // Following marks not exported in adf-schema
47
+ '__colorGroupDeclaration',
48
+ '__fontStyleGroupDeclaration',
49
+ '__searchQueryGroupDeclaration',
50
+ '__linkGroupDeclaration',
51
+ ];
52
+
53
+ const testCases = Object.entries(marks).map(([key, value]) => {
54
+ return {
55
+ name: key,
56
+ legacyMarkSpec: value.spec,
57
+ newMarkSpecFn: newMarkSpecs[`${key}`] as MarkSpecFactory,
58
+ skip: skipLists.includes(key),
59
+ };
60
+ });
61
+
62
+ const getTestingMethod = (skip: boolean) => {
63
+ return skip ? it.skip : it;
64
+ };
65
+
66
+ testCases.forEach(({ name, legacyMarkSpec, newMarkSpecFn, skip }) => {
67
+ const testMethod = getTestingMethod(skip);
68
+
69
+ testMethod(`validate markSpec for mark ${name}`, () => {
70
+ // check if there's any missing markSpec
71
+ expect(newMarkSpecFn).toBeDefined();
72
+ const newMarkSpec = newMarkSpecFn({});
73
+ expect(omit(newMarkSpec, ['parseDOM', 'toDOM'])).toEqual(
74
+ omit(legacyMarkSpec, ['parseDOM', 'toDOM']),
75
+ );
76
+ });
77
+ });
78
+ });
79
+
80
+ // TODO: content from node is too strict, need a custom comparor
81
+ // TODO: marks are not matching, especially missing unsupportedBlock, unsupportedNodeAttribute
82
+ describe.skip('nodes', () => {
83
+ const { nodes } = defaultSchema as Schema;
84
+ const skipLists = ['unknownBlock', 'unsupportedBlock', 'unsupportedInline'];
85
+ const testCases = Object.entries(nodes).map(([key, value]) => {
86
+ return {
87
+ name: key,
88
+ legacyNodeSpec: value.spec,
89
+ newNodeSpecFn: newNodeSpecs[`${key}`] as NodeSpecFactory,
90
+ skip: skipLists.includes(key),
91
+ };
92
+ });
93
+
94
+ const getTestingMethod = (skip: boolean) => {
95
+ return skip ? it.skip : it;
96
+ };
97
+
98
+ testCases.forEach(({ name, legacyNodeSpec, newNodeSpecFn, skip }) => {
99
+ const testMethod = getTestingMethod(skip);
100
+ testMethod(`validate nodeSpec for node ${name}`, () => {
101
+ // check if there's any missing nodeSpec
102
+ expect(newNodeSpecFn).toBeDefined();
103
+ const newNodeSpec = newNodeSpecFn({});
104
+ expect(omit(newNodeSpec, ['parseDOM', 'toDOM'])).toEqual(
105
+ omit(legacyNodeSpec, ['parseDOM', 'toDOM']),
106
+ );
107
+ });
108
+ });
109
+ });
110
+ });
@@ -1,8 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.annotationGroup = void 0;
7
- var _adfSchemaGenerator = require("@atlaskit/adf-schema-generator");
8
- var annotationGroup = exports.annotationGroup = (0, _adfSchemaGenerator.adfMarkGroup)('annotation');
@@ -1,9 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.colorGroup = void 0;
7
- var _adfSchemaGenerator = require("@atlaskit/adf-schema-generator");
8
- var _textColor = require("../marks/textColor");
9
- var colorGroup = exports.colorGroup = (0, _adfSchemaGenerator.adfMarkGroup)('color', [_textColor.textColor]);
@@ -1,15 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.backgroundColor = void 0;
7
- var _adfSchemaGenerator = require("@atlaskit/adf-schema-generator");
8
- var backgroundColor = exports.backgroundColor = (0, _adfSchemaGenerator.adfMark)('backgroundColor').define({
9
- attrs: {
10
- color: {
11
- pattern: '^#[0-9a-fA-F]{6}$',
12
- type: 'string'
13
- }
14
- }
15
- });
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.textColor = void 0;
7
- var _adfSchemaGenerator = require("@atlaskit/adf-schema-generator");
8
- var textColor = exports.textColor = (0, _adfSchemaGenerator.adfMark)('textColor').define({
9
- inclusive: true,
10
- attrs: {
11
- color: {
12
- type: 'string',
13
- pattern: '^#[0-9a-fA-F]{6}$'
14
- }
15
- }
16
- });
@@ -1,2 +0,0 @@
1
- import { adfMarkGroup } from '@atlaskit/adf-schema-generator';
2
- export const annotationGroup = adfMarkGroup('annotation');
@@ -1,3 +0,0 @@
1
- import { adfMarkGroup } from '@atlaskit/adf-schema-generator';
2
- import { textColor } from '../marks/textColor';
3
- export const colorGroup = adfMarkGroup('color', [textColor]);
@@ -1,9 +0,0 @@
1
- import { adfMark } from '@atlaskit/adf-schema-generator';
2
- export const backgroundColor = adfMark('backgroundColor').define({
3
- attrs: {
4
- color: {
5
- pattern: '^#[0-9a-fA-F]{6}$',
6
- type: 'string'
7
- }
8
- }
9
- });
@@ -1,10 +0,0 @@
1
- import { adfMark } from '@atlaskit/adf-schema-generator';
2
- export const textColor = adfMark('textColor').define({
3
- inclusive: true,
4
- attrs: {
5
- color: {
6
- type: 'string',
7
- pattern: '^#[0-9a-fA-F]{6}$'
8
- }
9
- }
10
- });
@@ -1,2 +0,0 @@
1
- import { adfMarkGroup } from '@atlaskit/adf-schema-generator';
2
- export var annotationGroup = adfMarkGroup('annotation');
@@ -1,3 +0,0 @@
1
- import { adfMarkGroup } from '@atlaskit/adf-schema-generator';
2
- import { textColor } from '../marks/textColor';
3
- export var colorGroup = adfMarkGroup('color', [textColor]);
@@ -1,9 +0,0 @@
1
- import { adfMark } from '@atlaskit/adf-schema-generator';
2
- export var backgroundColor = adfMark('backgroundColor').define({
3
- attrs: {
4
- color: {
5
- pattern: '^#[0-9a-fA-F]{6}$',
6
- type: 'string'
7
- }
8
- }
9
- });
@@ -1,10 +0,0 @@
1
- import { adfMark } from '@atlaskit/adf-schema-generator';
2
- export var textColor = adfMark('textColor').define({
3
- inclusive: true,
4
- attrs: {
5
- color: {
6
- type: 'string',
7
- pattern: '^#[0-9a-fA-F]{6}$'
8
- }
9
- }
10
- });
@@ -1 +0,0 @@
1
- export declare const annotationGroup: import("@atlaskit/adf-schema-generator/dist/types/types/ADFMarkGroup").ADFMarkGroup;
@@ -1 +0,0 @@
1
- export declare const colorGroup: import("@atlaskit/adf-schema-generator/dist/types/types/ADFMarkGroup").ADFMarkGroup;
@@ -1 +0,0 @@
1
- export declare const backgroundColor: import("@atlaskit/adf-schema-generator/dist/types/adfMark").ADFMark<import("@atlaskit/adf-schema-generator/dist/types/types/ADFMarkSpec").ADFMarkSpec>;
@@ -1 +0,0 @@
1
- export declare const textColor: import("@atlaskit/adf-schema-generator/dist/types/adfMark").ADFMark<import("@atlaskit/adf-schema-generator/dist/types/types/ADFMarkSpec").ADFMarkSpec>;