@atlaskit/adf-schema 28.1.12 → 28.1.13

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 (209) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/package.json +1 -1
  3. package/src/__tests__/unit/json-schema/v1.ts +0 -55
  4. package/src/__tests__/unit/schema/create-schema.ts +0 -214
  5. package/src/__tests__/unit/schema/default-schema.ts +0 -192
  6. package/src/__tests__/unit/schema/marks/annotation.ts +0 -46
  7. package/src/__tests__/unit/schema/marks/border.ts +0 -76
  8. package/src/__tests__/unit/schema/marks/breakout.ts +0 -24
  9. package/src/__tests__/unit/schema/marks/code.ts +0 -44
  10. package/src/__tests__/unit/schema/marks/confluence-inline-comment.ts +0 -25
  11. package/src/__tests__/unit/schema/marks/data-consumer.ts +0 -52
  12. package/src/__tests__/unit/schema/marks/em.ts +0 -37
  13. package/src/__tests__/unit/schema/marks/link.ts +0 -188
  14. package/src/__tests__/unit/schema/marks/strike.ts +0 -37
  15. package/src/__tests__/unit/schema/marks/strong.ts +0 -43
  16. package/src/__tests__/unit/schema/marks/subsup.ts +0 -50
  17. package/src/__tests__/unit/schema/marks/text-color.ts +0 -61
  18. package/src/__tests__/unit/schema/marks/underline.ts +0 -36
  19. package/src/__tests__/unit/schema/nodes/_consts.ts +0 -964
  20. package/src/__tests__/unit/schema/nodes/block-card.ts +0 -184
  21. package/src/__tests__/unit/schema/nodes/blockquote.ts +0 -44
  22. package/src/__tests__/unit/schema/nodes/bodied-extension.ts +0 -101
  23. package/src/__tests__/unit/schema/nodes/code-block.ts +0 -221
  24. package/src/__tests__/unit/schema/nodes/confluence-unsupported-block.ts +0 -32
  25. package/src/__tests__/unit/schema/nodes/confluence-unsupported-inline.ts +0 -35
  26. package/src/__tests__/unit/schema/nodes/date.ts +0 -51
  27. package/src/__tests__/unit/schema/nodes/decision-item.ts +0 -46
  28. package/src/__tests__/unit/schema/nodes/decision-list.ts +0 -52
  29. package/src/__tests__/unit/schema/nodes/embed-card.ts +0 -60
  30. package/src/__tests__/unit/schema/nodes/emoji.ts +0 -71
  31. package/src/__tests__/unit/schema/nodes/expand.ts +0 -51
  32. package/src/__tests__/unit/schema/nodes/extension.ts +0 -101
  33. package/src/__tests__/unit/schema/nodes/hard-break.ts +0 -24
  34. package/src/__tests__/unit/schema/nodes/heading.ts +0 -56
  35. package/src/__tests__/unit/schema/nodes/image.ts +0 -32
  36. package/src/__tests__/unit/schema/nodes/inline-card.ts +0 -106
  37. package/src/__tests__/unit/schema/nodes/inline-extension.ts +0 -79
  38. package/src/__tests__/unit/schema/nodes/layout-column.ts +0 -54
  39. package/src/__tests__/unit/schema/nodes/layout-section.ts +0 -95
  40. package/src/__tests__/unit/schema/nodes/list-item.ts +0 -49
  41. package/src/__tests__/unit/schema/nodes/media-group.ts +0 -67
  42. package/src/__tests__/unit/schema/nodes/media-single.ts +0 -171
  43. package/src/__tests__/unit/schema/nodes/media.ts +0 -384
  44. package/src/__tests__/unit/schema/nodes/mention.ts +0 -115
  45. package/src/__tests__/unit/schema/nodes/nestedExpand.ts +0 -72
  46. package/src/__tests__/unit/schema/nodes/ordered-list.ts +0 -49
  47. package/src/__tests__/unit/schema/nodes/panel.ts +0 -180
  48. package/src/__tests__/unit/schema/nodes/paragraph.ts +0 -25
  49. package/src/__tests__/unit/schema/nodes/placeholder.ts +0 -46
  50. package/src/__tests__/unit/schema/nodes/rule.ts +0 -24
  51. package/src/__tests__/unit/schema/nodes/status.ts +0 -120
  52. package/src/__tests__/unit/schema/nodes/tableNodes.ts +0 -555
  53. package/src/__tests__/unit/schema/nodes/task-item.ts +0 -39
  54. package/src/__tests__/unit/schema/nodes/task-list.ts +0 -45
  55. package/src/__tests__/unit/schema/nodes/unknown-block.ts +0 -42
  56. package/src/__tests__/unit/schema/nodes/unsupported-block.ts +0 -42
  57. package/src/__tests__/unit/schema/nodes/unsupported-inline.ts +0 -38
  58. package/src/__tests__/unit/utils/colors.ts +0 -42
  59. package/src/__tests__/unit/utils/url.ts +0 -209
  60. package/src/schema/bitbucket-schema.ts +0 -43
  61. package/src/schema/confluence-schema.ts +0 -76
  62. package/src/schema/create-schema.ts +0 -337
  63. package/src/schema/default-schema.ts +0 -180
  64. package/src/schema/groups.ts +0 -30
  65. package/src/schema/inline-nodes.ts +0 -9
  66. package/src/schema/jira-schema.ts +0 -158
  67. package/src/schema/marks/__tests__/unit/annotation.ts +0 -18
  68. package/src/schema/marks/alignment.ts +0 -48
  69. package/src/schema/marks/annotation.ts +0 -107
  70. package/src/schema/marks/border.ts +0 -74
  71. package/src/schema/marks/breakout.ts +0 -42
  72. package/src/schema/marks/code.ts +0 -45
  73. package/src/schema/marks/confluence-inline-comment.ts +0 -32
  74. package/src/schema/marks/data-consumer.ts +0 -100
  75. package/src/schema/marks/em.ts +0 -19
  76. package/src/schema/marks/fragment.ts +0 -77
  77. package/src/schema/marks/indentation.ts +0 -47
  78. package/src/schema/marks/link.ts +0 -139
  79. package/src/schema/marks/strike.ts +0 -26
  80. package/src/schema/marks/strong.ts +0 -45
  81. package/src/schema/marks/subsup.ts +0 -53
  82. package/src/schema/marks/text-color.ts +0 -172
  83. package/src/schema/marks/type-ahead-query.ts +0 -22
  84. package/src/schema/marks/underline.ts +0 -24
  85. package/src/schema/marks/unsupported-mark.ts +0 -9
  86. package/src/schema/marks/unsupported-node-attributes.ts +0 -8
  87. package/src/schema/nodes/block-card.ts +0 -121
  88. package/src/schema/nodes/blockquote.ts +0 -25
  89. package/src/schema/nodes/bodied-extension.ts +0 -75
  90. package/src/schema/nodes/bullet-list.ts +0 -17
  91. package/src/schema/nodes/caption.ts +0 -51
  92. package/src/schema/nodes/code-block.ts +0 -176
  93. package/src/schema/nodes/confluence-jira-issue.ts +0 -43
  94. package/src/schema/nodes/confluence-unsupported-block.ts +0 -29
  95. package/src/schema/nodes/confluence-unsupported-inline.ts +0 -30
  96. package/src/schema/nodes/date.ts +0 -38
  97. package/src/schema/nodes/decision-item.ts +0 -50
  98. package/src/schema/nodes/decision-list.ts +0 -56
  99. package/src/schema/nodes/doc.ts +0 -30
  100. package/src/schema/nodes/embed-card.ts +0 -62
  101. package/src/schema/nodes/emoji.ts +0 -89
  102. package/src/schema/nodes/expand.ts +0 -101
  103. package/src/schema/nodes/extension.ts +0 -60
  104. package/src/schema/nodes/hard-break.ts +0 -21
  105. package/src/schema/nodes/heading.ts +0 -64
  106. package/src/schema/nodes/image.ts +0 -32
  107. package/src/schema/nodes/inline-card.ts +0 -70
  108. package/src/schema/nodes/inline-extension.ts +0 -57
  109. package/src/schema/nodes/layout-column.ts +0 -68
  110. package/src/schema/nodes/layout-section.ts +0 -93
  111. package/src/schema/nodes/list-item.ts +0 -13
  112. package/src/schema/nodes/media-group.ts +0 -44
  113. package/src/schema/nodes/media-inline.ts +0 -19
  114. package/src/schema/nodes/media-single.ts +0 -179
  115. package/src/schema/nodes/media.ts +0 -253
  116. package/src/schema/nodes/mention.ts +0 -86
  117. package/src/schema/nodes/nested-expand.ts +0 -77
  118. package/src/schema/nodes/ordered-list.ts +0 -62
  119. package/src/schema/nodes/panel.ts +0 -133
  120. package/src/schema/nodes/paragraph.ts +0 -79
  121. package/src/schema/nodes/placeholder.ts +0 -40
  122. package/src/schema/nodes/rule.ts +0 -17
  123. package/src/schema/nodes/status.ts +0 -58
  124. package/src/schema/nodes/tableNodes.ts +0 -478
  125. package/src/schema/nodes/task-item.ts +0 -51
  126. package/src/schema/nodes/task-list.ts +0 -61
  127. package/src/schema/nodes/text.ts +0 -19
  128. package/src/schema/nodes/types/block-content.ts +0 -51
  129. package/src/schema/nodes/types/extensions.ts +0 -36
  130. package/src/schema/nodes/types/inline-content.ts +0 -56
  131. package/src/schema/nodes/types/list.ts +0 -54
  132. package/src/schema/nodes/types/mark.ts +0 -16
  133. package/src/schema/nodes/types/non-nestable-block-content.ts +0 -39
  134. package/src/schema/nodes/types/rich-media-common.ts +0 -51
  135. package/src/schema/nodes/unknown-block.ts +0 -13
  136. package/src/schema/nodes/unsupported-block.ts +0 -28
  137. package/src/schema/nodes/unsupported-inline.ts +0 -27
  138. package/src/schema/unsupported.ts +0 -4
  139. package/src/steps/__tests__/unit/analytics.ts +0 -72
  140. package/src/steps/__tests__/unit/link-meta-step.ts +0 -64
  141. package/src/steps/__tests__/unit/override-document-step.ts +0 -174
  142. package/src/steps/__tests__/unit/set-attrs.ts +0 -71
  143. package/src/steps/analytics.ts +0 -189
  144. package/src/steps/link-meta-step.ts +0 -105
  145. package/src/steps/override-document-step.ts +0 -97
  146. package/src/steps/set-attrs.tsx +0 -74
  147. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-0.json +0 -15
  148. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-1.json +0 -15
  149. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-2.json +0 -15
  150. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-3.json +0 -15
  151. package/src/steps/table/__tests__/__fixtures__/basic/remove-column-at-0.json +0 -9
  152. package/src/steps/table/__tests__/__fixtures__/basic/remove-column-at-1.json +0 -9
  153. package/src/steps/table/__tests__/__fixtures__/basic/remove-column-at-2.json +0 -9
  154. package/src/steps/table/__tests__/__fixtures__/basic/remove-table/remove-last-row-inverted.json +0 -98
  155. package/src/steps/table/__tests__/__fixtures__/basic/remove-table/remove-last-row.json +0 -71
  156. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-0-inverted.json +0 -19
  157. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-0.json +0 -19
  158. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-1-inverted.json +0 -21
  159. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-1.json +0 -21
  160. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-2-inverted.json +0 -21
  161. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-2.json +0 -21
  162. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-3-inverted.json +0 -19
  163. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-3.json +0 -19
  164. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-0-inverted.json +0 -63
  165. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-0.json +0 -21
  166. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-1-inverted.json +0 -64
  167. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-1.json +0 -22
  168. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-2-inverted.json +0 -63
  169. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-2.json +0 -21
  170. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-0-inverted.json +0 -19
  171. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-0.json +0 -19
  172. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-1-inverted.json +0 -19
  173. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-1.json +0 -19
  174. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-2-inverted.json +0 -19
  175. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-2.json +0 -19
  176. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-3-inverted.json +0 -19
  177. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-3.json +0 -19
  178. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-0-inverted.json +0 -52
  179. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-0.json +0 -38
  180. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-1-inverted.json +0 -52
  181. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-1.json +0 -38
  182. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-2-inverted.json +0 -25
  183. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-2.json +0 -11
  184. package/src/steps/table/__tests__/_utils.ts +0 -102
  185. package/src/steps/table/__tests__/add-column-merge-columns.ts +0 -509
  186. package/src/steps/table/__tests__/add-column-merge-rows.ts +0 -466
  187. package/src/steps/table/__tests__/add-column.ts +0 -638
  188. package/src/steps/table/add-column.ts +0 -443
  189. package/src/steps/table/constants.ts +0 -4
  190. package/src/steps/table/sort-column.ts +0 -57
  191. package/src/steps/table/types.ts +0 -48
  192. package/src/steps/table/utils/cell-step.ts +0 -239
  193. package/src/steps/table/utils/cells-at-column.ts +0 -75
  194. package/src/steps/table/utils/find-column.ts +0 -90
  195. package/src/steps/table/utils/get-table-rect-from-doc.ts +0 -37
  196. package/src/steps/table/utils/side-effects/rows.ts +0 -327
  197. package/src/steps/table/utils/side-effects/side-effects.ts +0 -90
  198. package/src/steps/table/utils/side-effects/table.ts +0 -112
  199. package/src/steps/table/utils/side-effects/types.ts +0 -34
  200. package/src/steps/table/utils/table-map.ts +0 -28
  201. package/src/steps/type-ahead.ts +0 -100
  202. package/src/steps.ts +0 -16
  203. package/src/utils/colors.ts +0 -171
  204. package/src/utils/confluence/emoji.ts +0 -99
  205. package/src/utils/extensions.ts +0 -32
  206. package/src/utils/parseDOM.ts +0 -2
  207. package/src/utils/url.ts +0 -173
  208. package/src/utils/uuid.ts +0 -19
  209. package/src/version.json +0 -6
@@ -1,54 +0,0 @@
1
- import { createSchema } from '../../../../schema/create-schema';
2
- import {
3
- fromHTML,
4
- toHTML,
5
- toContext,
6
- } from 'adf-test-helpers/src/adf-schema/html-helpers';
7
- import {
8
- layoutSection,
9
- layoutColumn,
10
- doc,
11
- p,
12
- } from 'adf-test-helpers/src/doc-builder';
13
-
14
- const schema = makeSchema();
15
- const packageName = process.env._PACKAGE_NAME_ as string;
16
-
17
- describe(`${packageName}/schema layout-column node`, () => {
18
- it('serializes to <div data-layout-column />', () => {
19
- const html = toHTML(schema.nodes.layoutColumn.create(), schema);
20
- expect(html).toContain('<div data-layout-column="true">');
21
- });
22
-
23
- it('matches <div data-layout-column /> inside layoutSection', () => {
24
- const doc = fromHTML(
25
- '<div data-layout-section="true"><div data-layout-column/></div>',
26
- schema,
27
- );
28
- const node = doc.firstChild!.firstChild!;
29
- expect(node.type.name).toEqual('layoutColumn');
30
- });
31
-
32
- it('should not match <div data-layout-column /> when pasted inside layoutSection/layoutColumn', () => {
33
- const document = doc(
34
- layoutSection(
35
- layoutColumn({ width: 50 })(p('{<>}')),
36
- layoutColumn({ width: 50 })(p('')),
37
- ),
38
- );
39
- const context = toContext(document, schema);
40
- const pmDoc = fromHTML(
41
- '<div data-layout-column><p>Text</p></div>',
42
- schema,
43
- { context },
44
- );
45
- const node = pmDoc.firstChild!;
46
- expect(node.type.name).toEqual('paragraph');
47
- });
48
- });
49
-
50
- function makeSchema() {
51
- return createSchema({
52
- nodes: ['doc', 'layoutSection', 'layoutColumn', 'paragraph', 'text'],
53
- });
54
- }
@@ -1,95 +0,0 @@
1
- import { createSchema } from '../../../../schema/create-schema';
2
- import { fromHTML, toHTML } from 'adf-test-helpers/src/adf-schema/html-helpers';
3
- import {
4
- unsupportedBlock,
5
- layoutSection,
6
- doc,
7
- layoutColumn,
8
- p,
9
- } from 'adf-test-helpers/src/doc-builder';
10
-
11
- const schema = makeSchema();
12
- const packageName = process.env._PACKAGE_NAME_ as string;
13
-
14
- describe(`${packageName}/schema layout-section node`, () => {
15
- it('serializes to <div data-layout-section="true"/>', () => {
16
- const html = toHTML(schema.nodes.layoutSection.create(), schema);
17
- expect(html).toContain('<div data-layout-section="true">');
18
- });
19
-
20
- it('matches <div data-layout-section="true" />', () => {
21
- const doc = fromHTML('<div data-layout-section="true" />', schema);
22
- const node = doc.firstChild!;
23
- expect(node.type.name).toEqual('layoutSection');
24
- });
25
-
26
- describe('when there is multiple unsupportedBlock after some layoutColumn', () => {
27
- it('should not throw an invalid content exception', () => {
28
- const documentRaw = doc(
29
- // prettier-ignore
30
- layoutSection(
31
- layoutColumn({ width: 33 })(
32
- p(''),
33
- ),
34
- layoutColumn({ width: 33 })(
35
- p(''),
36
- ),
37
- layoutColumn({ width: 33 })(
38
- p(''),
39
- ),
40
-
41
- unsupportedBlock({})(),
42
- ),
43
- );
44
-
45
- expect(() => {
46
- documentRaw(schema);
47
- }).not.toThrow();
48
- });
49
- });
50
-
51
- describe('when there is only one unsupportedBlock inside a layoutSection', () => {
52
- it('should not throw an invalid content exception', () => {
53
- const documentRaw = doc(
54
- // prettier-ignore
55
- layoutSection(
56
- unsupportedBlock({})(),
57
- ),
58
- );
59
-
60
- expect(() => {
61
- documentRaw(schema);
62
- }).not.toThrow();
63
- });
64
- });
65
-
66
- describe('when there is only one layoutColumn inside a layoutSection', () => {
67
- it('should throw an invalid content exception', () => {
68
- const documentRaw = doc(
69
- // prettier-ignore
70
- layoutSection(
71
- layoutColumn({ width: 100 })(
72
- p(''),
73
- ),
74
- ),
75
- );
76
-
77
- expect(() => {
78
- documentRaw(schema);
79
- }).not.toThrow();
80
- });
81
- });
82
- });
83
-
84
- function makeSchema() {
85
- return createSchema({
86
- nodes: [
87
- 'doc',
88
- 'unsupportedBlock',
89
- 'layoutSection',
90
- 'layoutColumn',
91
- 'paragraph',
92
- 'text',
93
- ],
94
- });
95
- }
@@ -1,49 +0,0 @@
1
- import { toHTML, fromHTML } from 'adf-test-helpers/src/adf-schema/html-helpers';
2
-
3
- import { doc, ol, li, p } from 'adf-test-helpers/src/adf-schema/schema-builder';
4
-
5
- import { schema } from 'adf-test-helpers/src/adf-schema';
6
- const packageName = process.env._PACKAGE_NAME_ as string;
7
-
8
- describe(`${packageName}/schema listItem node`, () => {
9
- it('should be possible to create a list item with a single paragraph', () => {
10
- const html = toHTML(
11
- schema.nodes.listItem.create({}, schema.nodes.paragraph.create()),
12
- schema,
13
- );
14
- expect(html).toContain('<li><p></p></li>');
15
- });
16
-
17
- it('should not be possible to have blockquote inside list', () => {
18
- const docFromHTML = fromHTML(
19
- '<ol><li><blockquote>text</blockquote></li></ol>',
20
- schema,
21
- );
22
- expect(docFromHTML.toJSON()).toEqual(doc(ol()(li(p('text')))).toJSON());
23
- });
24
-
25
- it('should be possible to have paragraph inside list', () => {
26
- const docFromHTML = fromHTML('<ol><li><p>text</p></li></ol>', schema);
27
- expect(docFromHTML.toJSON()).toEqual(doc(ol()(li(p('text')))).toJSON());
28
- });
29
-
30
- it('should be possible to have sublist inside list', () => {
31
- const docFromHTML = fromHTML(
32
- '<ol><li><p>text</p><ol><li><p>sublist</p></li></ol></li></ol>',
33
- schema,
34
- );
35
- expect(docFromHTML.toJSON()).toEqual(
36
- doc(ol()(li(p('text'), ol()(li(p('sublist')))))).toJSON(),
37
- );
38
- });
39
-
40
- it('should not be possible to have sublist and first child inside list', () => {
41
- const docFromHTML = fromHTML(
42
- '<ol><li><ol><li><p>sublist</p></li></ol><p>text</p></li></ol>',
43
- schema,
44
- );
45
- expect(docFromHTML.toJSON()).toEqual(
46
- doc(ol()(li(p('sublist'), p('text')))).toJSON(),
47
- );
48
- });
49
- });
@@ -1,67 +0,0 @@
1
- import { fromHTML, toDOM } from 'adf-test-helpers/src/adf-schema/html-helpers';
2
-
3
- import { schema } from 'adf-test-helpers/src/adf-schema';
4
-
5
- const packageName = process.env._PACKAGE_NAME_ as string;
6
-
7
- describe(`${packageName}/schema mediaGroup node`, () => {
8
- describe('parse html', () => {
9
- it('gets attributes from html', () => {
10
- const doc = fromHTML(
11
- `
12
- <div
13
- data-node-type="mediaGroup"
14
- />
15
- `,
16
- schema,
17
- );
18
-
19
- const mediaGroupNode = doc.firstChild!;
20
-
21
- expect(mediaGroupNode.type).toEqual(schema.nodes.mediaGroup);
22
- });
23
-
24
- it('auto creates a media node inside mediaSingle node', () => {
25
- const doc = fromHTML(
26
- `
27
- <div
28
- data-node-type="mediaGroup"
29
- />
30
- `,
31
- schema,
32
- );
33
-
34
- const mediaGroupNode = doc.firstChild!;
35
-
36
- expect(mediaGroupNode.childCount).toEqual(1);
37
- expect(mediaGroupNode.child(0)).toEqual(schema.nodes.media.create());
38
- });
39
- });
40
-
41
- describe('encode node', () => {
42
- it('converts attributes to related data attribute in html', () => {
43
- const mediaGroupNode = schema.nodes.mediaGroup.create();
44
-
45
- const mediaGroupDom = toDOM(mediaGroupNode, schema)
46
- .firstChild as HTMLElement;
47
- const nodeType = mediaGroupDom.getAttribute('data-node-type');
48
-
49
- expect(nodeType).toEqual('mediaGroup');
50
- });
51
- });
52
-
53
- it('encodes and decodes to the same node', () => {
54
- const { mediaGroup, media } = schema.nodes;
55
- const mediaGroupNode = mediaGroup.create({}, media.create());
56
-
57
- const mediaGroupDom = toDOM(mediaGroupNode, schema)
58
- .firstChild as HTMLElement;
59
-
60
- const parsedMediaGroup = fromHTML(
61
- mediaGroupDom.outerHTML,
62
- schema,
63
- ).firstChild;
64
-
65
- expect(parsedMediaGroup).toEqual(mediaGroupNode);
66
- });
67
- });
@@ -1,171 +0,0 @@
1
- import { toDOM, fromHTML } from 'adf-test-helpers/src/adf-schema/html-helpers';
2
-
3
- import { schema } from 'adf-test-helpers/src/adf-schema';
4
-
5
- const packageName = process.env._PACKAGE_NAME_ as string;
6
-
7
- describe(`${packageName}/schema mediaSingle node`, () => {
8
- describe('parse html', () => {
9
- it('gets attributes from html', () => {
10
- const doc = fromHTML(
11
- `
12
- <div
13
- data-node-type="mediaSingle"
14
- data-layout="wrap-right"
15
- data-width="32.3"
16
- data-width-type="percentage"
17
- />
18
- `,
19
- schema,
20
- );
21
-
22
- const mediaSingleNode = doc.firstChild!;
23
-
24
- expect(mediaSingleNode.type).toEqual(schema.nodes.mediaSingle);
25
- expect(mediaSingleNode.attrs.layout).toEqual('wrap-right');
26
- expect(mediaSingleNode.attrs.width).toEqual(32.3);
27
- expect(mediaSingleNode.attrs.widthType).toEqual('percentage');
28
- });
29
-
30
- it('defaults to align center', () => {
31
- const doc = fromHTML(
32
- `
33
- <div
34
- data-node-type="mediaSingle"
35
- />
36
- `,
37
- schema,
38
- );
39
-
40
- const mediaSingleNode = doc.firstChild!;
41
-
42
- expect(mediaSingleNode.type).toEqual(schema.nodes.mediaSingle);
43
- expect(mediaSingleNode.attrs.layout).toEqual('center');
44
- expect(mediaSingleNode.attrs.width).toBeNull();
45
- expect(mediaSingleNode.attrs.widthType).toBeNull();
46
- });
47
-
48
- it('auto creates a media node inside mediaSingle node', () => {
49
- const doc = fromHTML(
50
- `
51
- <div
52
- data-node-type="mediaSingle"
53
- data-alignment="left"
54
- data-display="block"
55
- />
56
- `,
57
- schema,
58
- );
59
-
60
- const mediaSingleNode = doc.firstChild!;
61
-
62
- expect(mediaSingleNode.childCount).toEqual(1);
63
- expect(mediaSingleNode.child(0)).toEqual(schema.nodes.media.create());
64
- });
65
- });
66
-
67
- describe('encode node', () => {
68
- it('converts layout and nodetype to html data attribute', () => {
69
- const mediaSingleNode = schema.nodes.mediaSingle.create({
70
- layout: 'center',
71
- });
72
-
73
- const mediaSingleDom = toDOM(mediaSingleNode, schema)
74
- .firstChild as HTMLElement;
75
- const layout = mediaSingleDom.getAttribute('data-layout');
76
- const nodeType = mediaSingleDom.getAttribute('data-node-type');
77
-
78
- expect(layout).toEqual('center');
79
- expect(nodeType).toEqual('mediaSingle');
80
- });
81
- });
82
-
83
- it('converts attributes to related data attribute in html with', () => {
84
- const mediaSingleNode = schema.nodes.mediaSingle.create({
85
- layout: 'center',
86
- width: 64.333333,
87
- });
88
-
89
- const mediaSingleDom = toDOM(mediaSingleNode, schema)
90
- .firstChild as HTMLElement;
91
- const layout = mediaSingleDom.getAttribute('data-layout');
92
- const width = mediaSingleDom.getAttribute('data-width');
93
-
94
- expect(layout).toEqual('center');
95
- expect(width).toEqual('64.33');
96
- });
97
-
98
- it('converts attributes with integer width', () => {
99
- const mediaSingleNode = schema.nodes.mediaSingle.create({
100
- layout: 'center',
101
- width: 64,
102
- });
103
-
104
- const mediaSingleDom = toDOM(mediaSingleNode, schema)
105
- .firstChild as HTMLElement;
106
- const layout = mediaSingleDom.getAttribute('data-layout');
107
- const width = mediaSingleDom.getAttribute('data-width');
108
-
109
- expect(layout).toEqual('center');
110
- expect(width).toEqual('64');
111
- });
112
-
113
- it('converts attributes with widthType', () => {
114
- const mediaSingleNode = schema.nodes.mediaSingle.create({
115
- layout: 'center',
116
- width: 640,
117
- widthType: 'pixel',
118
- });
119
-
120
- const mediaSingleDom = toDOM(mediaSingleNode, schema)
121
- .firstChild as HTMLElement;
122
- const layout = mediaSingleDom.getAttribute('data-layout');
123
- const width = mediaSingleDom.getAttribute('data-width');
124
- const widthType = mediaSingleDom.getAttribute('data-width-type');
125
-
126
- expect(layout).toEqual('center');
127
- expect(width).toEqual('640');
128
- expect(widthType).toEqual('pixel');
129
- });
130
-
131
- it('encodes and decodes wide mediaSingle to the same node', () => {
132
- const { mediaSingle, media } = schema.nodes;
133
- const mediaSingleNode = mediaSingle.create(
134
- {
135
- layout: 'wide',
136
- },
137
- media.create(),
138
- );
139
-
140
- const mediaSingleDom = toDOM(mediaSingleNode, schema)
141
- .firstChild as HTMLElement;
142
-
143
- const parsedMediaSingle = fromHTML(
144
- mediaSingleDom.outerHTML,
145
- schema,
146
- ).firstChild;
147
-
148
- expect(parsedMediaSingle).toEqual(mediaSingleNode);
149
- });
150
-
151
- it('encodes and decodes mediaSingle with width to the same node', () => {
152
- const { mediaSingle, media } = schema.nodes;
153
- const mediaSingleNode = mediaSingle.create(
154
- {
155
- layout: 'center',
156
- width: 32.5,
157
- },
158
- media.create(),
159
- );
160
-
161
- const mediaSingleDom = toDOM(mediaSingleNode, schema)
162
- .firstChild as HTMLElement;
163
-
164
- const parsedMediaSingle = fromHTML(
165
- mediaSingleDom.outerHTML,
166
- schema,
167
- ).firstChild;
168
-
169
- expect(parsedMediaSingle).toEqual(mediaSingleNode);
170
- });
171
- });