@atlaskit/adf-schema 28.1.11 → 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 (218) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/package.json +1 -1
  3. package/build/tsconfig.json +0 -18
  4. package/index.ts +0 -275
  5. package/src/__tests__/unit/json-schema/v1.ts +0 -55
  6. package/src/__tests__/unit/schema/create-schema.ts +0 -214
  7. package/src/__tests__/unit/schema/default-schema.ts +0 -192
  8. package/src/__tests__/unit/schema/marks/annotation.ts +0 -46
  9. package/src/__tests__/unit/schema/marks/border.ts +0 -76
  10. package/src/__tests__/unit/schema/marks/breakout.ts +0 -24
  11. package/src/__tests__/unit/schema/marks/code.ts +0 -44
  12. package/src/__tests__/unit/schema/marks/confluence-inline-comment.ts +0 -25
  13. package/src/__tests__/unit/schema/marks/data-consumer.ts +0 -52
  14. package/src/__tests__/unit/schema/marks/em.ts +0 -37
  15. package/src/__tests__/unit/schema/marks/link.ts +0 -188
  16. package/src/__tests__/unit/schema/marks/strike.ts +0 -37
  17. package/src/__tests__/unit/schema/marks/strong.ts +0 -43
  18. package/src/__tests__/unit/schema/marks/subsup.ts +0 -50
  19. package/src/__tests__/unit/schema/marks/text-color.ts +0 -61
  20. package/src/__tests__/unit/schema/marks/underline.ts +0 -36
  21. package/src/__tests__/unit/schema/nodes/_consts.ts +0 -964
  22. package/src/__tests__/unit/schema/nodes/block-card.ts +0 -184
  23. package/src/__tests__/unit/schema/nodes/blockquote.ts +0 -44
  24. package/src/__tests__/unit/schema/nodes/bodied-extension.ts +0 -101
  25. package/src/__tests__/unit/schema/nodes/code-block.ts +0 -221
  26. package/src/__tests__/unit/schema/nodes/confluence-unsupported-block.ts +0 -32
  27. package/src/__tests__/unit/schema/nodes/confluence-unsupported-inline.ts +0 -35
  28. package/src/__tests__/unit/schema/nodes/date.ts +0 -51
  29. package/src/__tests__/unit/schema/nodes/decision-item.ts +0 -46
  30. package/src/__tests__/unit/schema/nodes/decision-list.ts +0 -52
  31. package/src/__tests__/unit/schema/nodes/embed-card.ts +0 -60
  32. package/src/__tests__/unit/schema/nodes/emoji.ts +0 -71
  33. package/src/__tests__/unit/schema/nodes/expand.ts +0 -51
  34. package/src/__tests__/unit/schema/nodes/extension.ts +0 -101
  35. package/src/__tests__/unit/schema/nodes/hard-break.ts +0 -24
  36. package/src/__tests__/unit/schema/nodes/heading.ts +0 -56
  37. package/src/__tests__/unit/schema/nodes/image.ts +0 -32
  38. package/src/__tests__/unit/schema/nodes/inline-card.ts +0 -106
  39. package/src/__tests__/unit/schema/nodes/inline-extension.ts +0 -79
  40. package/src/__tests__/unit/schema/nodes/layout-column.ts +0 -54
  41. package/src/__tests__/unit/schema/nodes/layout-section.ts +0 -95
  42. package/src/__tests__/unit/schema/nodes/list-item.ts +0 -49
  43. package/src/__tests__/unit/schema/nodes/media-group.ts +0 -67
  44. package/src/__tests__/unit/schema/nodes/media-single.ts +0 -171
  45. package/src/__tests__/unit/schema/nodes/media.ts +0 -384
  46. package/src/__tests__/unit/schema/nodes/mention.ts +0 -115
  47. package/src/__tests__/unit/schema/nodes/nestedExpand.ts +0 -72
  48. package/src/__tests__/unit/schema/nodes/ordered-list.ts +0 -49
  49. package/src/__tests__/unit/schema/nodes/panel.ts +0 -180
  50. package/src/__tests__/unit/schema/nodes/paragraph.ts +0 -25
  51. package/src/__tests__/unit/schema/nodes/placeholder.ts +0 -46
  52. package/src/__tests__/unit/schema/nodes/rule.ts +0 -24
  53. package/src/__tests__/unit/schema/nodes/status.ts +0 -120
  54. package/src/__tests__/unit/schema/nodes/tableNodes.ts +0 -555
  55. package/src/__tests__/unit/schema/nodes/task-item.ts +0 -39
  56. package/src/__tests__/unit/schema/nodes/task-list.ts +0 -45
  57. package/src/__tests__/unit/schema/nodes/unknown-block.ts +0 -42
  58. package/src/__tests__/unit/schema/nodes/unsupported-block.ts +0 -42
  59. package/src/__tests__/unit/schema/nodes/unsupported-inline.ts +0 -38
  60. package/src/__tests__/unit/utils/colors.ts +0 -42
  61. package/src/__tests__/unit/utils/url.ts +0 -209
  62. package/src/index.ts +0 -297
  63. package/src/json-schema/index.ts +0 -2
  64. package/src/schema/bitbucket-schema.ts +0 -43
  65. package/src/schema/confluence-schema.ts +0 -76
  66. package/src/schema/create-schema.ts +0 -337
  67. package/src/schema/default-schema.ts +0 -180
  68. package/src/schema/groups.ts +0 -30
  69. package/src/schema/index.ts +0 -238
  70. package/src/schema/inline-nodes.ts +0 -9
  71. package/src/schema/jira-schema.ts +0 -158
  72. package/src/schema/marks/__tests__/unit/annotation.ts +0 -18
  73. package/src/schema/marks/alignment.ts +0 -48
  74. package/src/schema/marks/annotation.ts +0 -107
  75. package/src/schema/marks/border.ts +0 -74
  76. package/src/schema/marks/breakout.ts +0 -42
  77. package/src/schema/marks/code.ts +0 -45
  78. package/src/schema/marks/confluence-inline-comment.ts +0 -32
  79. package/src/schema/marks/data-consumer.ts +0 -100
  80. package/src/schema/marks/em.ts +0 -19
  81. package/src/schema/marks/fragment.ts +0 -77
  82. package/src/schema/marks/indentation.ts +0 -47
  83. package/src/schema/marks/index.ts +0 -61
  84. package/src/schema/marks/link.ts +0 -139
  85. package/src/schema/marks/strike.ts +0 -26
  86. package/src/schema/marks/strong.ts +0 -45
  87. package/src/schema/marks/subsup.ts +0 -53
  88. package/src/schema/marks/text-color.ts +0 -172
  89. package/src/schema/marks/type-ahead-query.ts +0 -22
  90. package/src/schema/marks/underline.ts +0 -24
  91. package/src/schema/marks/unsupported-mark.ts +0 -9
  92. package/src/schema/marks/unsupported-node-attributes.ts +0 -8
  93. package/src/schema/nodes/block-card.ts +0 -121
  94. package/src/schema/nodes/blockquote.ts +0 -25
  95. package/src/schema/nodes/bodied-extension.ts +0 -75
  96. package/src/schema/nodes/bullet-list.ts +0 -17
  97. package/src/schema/nodes/caption.ts +0 -51
  98. package/src/schema/nodes/code-block.ts +0 -176
  99. package/src/schema/nodes/confluence-jira-issue.ts +0 -43
  100. package/src/schema/nodes/confluence-unsupported-block.ts +0 -29
  101. package/src/schema/nodes/confluence-unsupported-inline.ts +0 -30
  102. package/src/schema/nodes/date.ts +0 -38
  103. package/src/schema/nodes/decision-item.ts +0 -50
  104. package/src/schema/nodes/decision-list.ts +0 -56
  105. package/src/schema/nodes/doc.ts +0 -30
  106. package/src/schema/nodes/embed-card.ts +0 -62
  107. package/src/schema/nodes/emoji.ts +0 -89
  108. package/src/schema/nodes/expand.ts +0 -101
  109. package/src/schema/nodes/extension.ts +0 -60
  110. package/src/schema/nodes/hard-break.ts +0 -21
  111. package/src/schema/nodes/heading.ts +0 -64
  112. package/src/schema/nodes/image.ts +0 -32
  113. package/src/schema/nodes/index.ts +0 -184
  114. package/src/schema/nodes/inline-card.ts +0 -70
  115. package/src/schema/nodes/inline-extension.ts +0 -57
  116. package/src/schema/nodes/layout-column.ts +0 -68
  117. package/src/schema/nodes/layout-section.ts +0 -93
  118. package/src/schema/nodes/list-item.ts +0 -13
  119. package/src/schema/nodes/media-group.ts +0 -44
  120. package/src/schema/nodes/media-inline.ts +0 -19
  121. package/src/schema/nodes/media-single.ts +0 -179
  122. package/src/schema/nodes/media.ts +0 -253
  123. package/src/schema/nodes/mention.ts +0 -86
  124. package/src/schema/nodes/nested-expand.ts +0 -77
  125. package/src/schema/nodes/ordered-list.ts +0 -62
  126. package/src/schema/nodes/panel.ts +0 -133
  127. package/src/schema/nodes/paragraph.ts +0 -79
  128. package/src/schema/nodes/placeholder.ts +0 -40
  129. package/src/schema/nodes/rule.ts +0 -17
  130. package/src/schema/nodes/status.ts +0 -58
  131. package/src/schema/nodes/tableNodes.ts +0 -478
  132. package/src/schema/nodes/task-item.ts +0 -51
  133. package/src/schema/nodes/task-list.ts +0 -61
  134. package/src/schema/nodes/text.ts +0 -19
  135. package/src/schema/nodes/types/block-content.ts +0 -51
  136. package/src/schema/nodes/types/extensions.ts +0 -36
  137. package/src/schema/nodes/types/inline-content.ts +0 -56
  138. package/src/schema/nodes/types/list.ts +0 -54
  139. package/src/schema/nodes/types/mark.ts +0 -16
  140. package/src/schema/nodes/types/non-nestable-block-content.ts +0 -39
  141. package/src/schema/nodes/types/rich-media-common.ts +0 -51
  142. package/src/schema/nodes/unknown-block.ts +0 -13
  143. package/src/schema/nodes/unsupported-block.ts +0 -28
  144. package/src/schema/nodes/unsupported-inline.ts +0 -27
  145. package/src/schema/unsupported.ts +0 -4
  146. package/src/steps/__tests__/unit/analytics.ts +0 -72
  147. package/src/steps/__tests__/unit/link-meta-step.ts +0 -64
  148. package/src/steps/__tests__/unit/override-document-step.ts +0 -174
  149. package/src/steps/__tests__/unit/set-attrs.ts +0 -71
  150. package/src/steps/analytics.ts +0 -189
  151. package/src/steps/link-meta-step.ts +0 -105
  152. package/src/steps/override-document-step.ts +0 -97
  153. package/src/steps/set-attrs.tsx +0 -74
  154. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-0.json +0 -15
  155. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-1.json +0 -15
  156. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-2.json +0 -15
  157. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-3.json +0 -15
  158. package/src/steps/table/__tests__/__fixtures__/basic/remove-column-at-0.json +0 -9
  159. package/src/steps/table/__tests__/__fixtures__/basic/remove-column-at-1.json +0 -9
  160. package/src/steps/table/__tests__/__fixtures__/basic/remove-column-at-2.json +0 -9
  161. package/src/steps/table/__tests__/__fixtures__/basic/remove-table/remove-last-row-inverted.json +0 -98
  162. package/src/steps/table/__tests__/__fixtures__/basic/remove-table/remove-last-row.json +0 -71
  163. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-0-inverted.json +0 -19
  164. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-0.json +0 -19
  165. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-1-inverted.json +0 -21
  166. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-1.json +0 -21
  167. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-2-inverted.json +0 -21
  168. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-2.json +0 -21
  169. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-3-inverted.json +0 -19
  170. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-3.json +0 -19
  171. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-0-inverted.json +0 -63
  172. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-0.json +0 -21
  173. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-1-inverted.json +0 -64
  174. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-1.json +0 -22
  175. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-2-inverted.json +0 -63
  176. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-2.json +0 -21
  177. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-0-inverted.json +0 -19
  178. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-0.json +0 -19
  179. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-1-inverted.json +0 -19
  180. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-1.json +0 -19
  181. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-2-inverted.json +0 -19
  182. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-2.json +0 -19
  183. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-3-inverted.json +0 -19
  184. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-3.json +0 -19
  185. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-0-inverted.json +0 -52
  186. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-0.json +0 -38
  187. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-1-inverted.json +0 -52
  188. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-1.json +0 -38
  189. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-2-inverted.json +0 -25
  190. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-2.json +0 -11
  191. package/src/steps/table/__tests__/_utils.ts +0 -102
  192. package/src/steps/table/__tests__/add-column-merge-columns.ts +0 -509
  193. package/src/steps/table/__tests__/add-column-merge-rows.ts +0 -466
  194. package/src/steps/table/__tests__/add-column.ts +0 -638
  195. package/src/steps/table/add-column.ts +0 -443
  196. package/src/steps/table/constants.ts +0 -4
  197. package/src/steps/table/sort-column.ts +0 -57
  198. package/src/steps/table/types.ts +0 -48
  199. package/src/steps/table/utils/cell-step.ts +0 -239
  200. package/src/steps/table/utils/cells-at-column.ts +0 -75
  201. package/src/steps/table/utils/find-column.ts +0 -90
  202. package/src/steps/table/utils/get-table-rect-from-doc.ts +0 -37
  203. package/src/steps/table/utils/side-effects/rows.ts +0 -327
  204. package/src/steps/table/utils/side-effects/side-effects.ts +0 -90
  205. package/src/steps/table/utils/side-effects/table.ts +0 -112
  206. package/src/steps/table/utils/side-effects/types.ts +0 -34
  207. package/src/steps/table/utils/table-map.ts +0 -28
  208. package/src/steps/type-ahead.ts +0 -100
  209. package/src/steps.ts +0 -16
  210. package/src/utils/colors.ts +0 -171
  211. package/src/utils/confluence/emoji.ts +0 -99
  212. package/src/utils/extensions.ts +0 -32
  213. package/src/utils/index.ts +0 -69
  214. package/src/utils/parseDOM.ts +0 -2
  215. package/src/utils/url.ts +0 -173
  216. package/src/utils/uuid.ts +0 -19
  217. package/src/version.json +0 -6
  218. package/tsconfig.json +0 -13
@@ -1,180 +0,0 @@
1
- import { NodeSpec } from '@atlaskit/editor-prosemirror/model';
2
- import { createSchema, SchemaConfig } from '../../../../schema/create-schema';
3
- import { toHTML, fromHTML } from 'adf-test-helpers/src/adf-schema/html-helpers';
4
- import { panel } from '../../../../schema/nodes/panel';
5
-
6
- const schema = makeSchema();
7
- const schemaWithAllowCustomPanel = makeSchema({
8
- panel: panel(true),
9
- });
10
-
11
- const schemaWithoutCustomPanel = makeSchema({
12
- panel: panel(false),
13
- });
14
- const packageName = process.env._PACKAGE_NAME_ as string;
15
-
16
- function expectHtmlWithData(html: string, expectedData: Object) {
17
- const parser = new DOMParser();
18
- const dom = parser.parseFromString(html, 'text/html');
19
- const htmlNode = dom.body?.firstChild as HTMLElement;
20
- expect(htmlNode).toBeTruthy();
21
- expect(htmlNode.dataset).toEqual(expect.objectContaining(expectedData));
22
- }
23
-
24
- describe(`${packageName}/schema panel node `, () => {
25
- describe('With default panel NodeSpec ', () => {
26
- it('should have data-panel-type when serializing to DOM', () => {
27
- const html = toHTML(
28
- schema.nodes.panel.create({ panelType: 'info' }),
29
- schema,
30
- );
31
- expectHtmlWithData(html, {
32
- panelType: 'info',
33
- });
34
- });
35
-
36
- it('should have info panel type by default', () => {
37
- const html = toHTML(schema.nodes.panel.create(), schema);
38
- expectHtmlWithData(html, {
39
- panelType: 'info',
40
- });
41
- });
42
- });
43
-
44
- describe('With CustomPanel NodeSpec FF On ', () => {
45
- it('should have data-panel-icon, data-panel-color, data-panel-icon-id and data-panel-icon-text when serializing to DOM', () => {
46
- const html = toHTML(
47
- schemaWithAllowCustomPanel.nodes.panel.create({
48
- panelType: 'custom',
49
- panelIcon: ':smiley:',
50
- panelColor: '#33FF33',
51
- panelIconId: '1f603',
52
- panelIconText: '😃',
53
- }),
54
- schemaWithAllowCustomPanel,
55
- );
56
-
57
- expectHtmlWithData(html, {
58
- panelType: 'custom',
59
- panelIcon: ':smiley:',
60
- panelColor: '#33FF33',
61
- panelIconId: '1f603',
62
- panelIconText: '😃',
63
- });
64
- });
65
-
66
- describe.each([
67
- {
68
- subject: 'panelType',
69
- html: '<div data-panel-type="tip"><p>testing</p></div>',
70
- expected: {
71
- panelType: 'tip',
72
- panelColor: null,
73
- panelIcon: null,
74
- panelIconId: null,
75
- panelIconText: null,
76
- },
77
- },
78
- {
79
- subject: 'icon and color',
80
- html: '<div data-panel-type="custom" data-panel-icon=":smiley:" data-panel-color="#33FF33" data-panel-icon-id="1f603" data-panel-icon-text="😃"><p>testing</p></div>',
81
- expected: {
82
- panelType: 'custom',
83
- panelColor: '#33FF33',
84
- panelIcon: ':smiley:',
85
- panelIconId: '1f603',
86
- panelIconText: '😃',
87
- },
88
- },
89
- ])('extract correct values', ({ html, subject, expected }) => {
90
- it(`for ${subject}`, () => {
91
- const doc = fromHTML(html, schemaWithAllowCustomPanel);
92
- const panel = doc.firstChild!;
93
- expect(panel.type.name).toContain('panel');
94
- expect(panel.attrs).toEqual(expected);
95
- });
96
- });
97
-
98
- it('should extract the correct attributes of panelType', () => {
99
- const doc = fromHTML(
100
- "<div data-panel-type='tip' data-panel-icon=':smiley:' data-panel-color='#33FF33' data-panel-icon-id='1f603' data-panel-icon-text='😃'><p>testing</p></div>",
101
- schemaWithAllowCustomPanel,
102
- );
103
- const panel = doc.firstChild;
104
- expect(panel?.type?.name).toContain('panel');
105
- expect(panel?.attrs).toEqual(
106
- expect.objectContaining({
107
- panelIcon: ':smiley:',
108
- panelColor: '#33FF33',
109
- panelIconId: '1f603',
110
- panelIconText: '😃',
111
- }),
112
- );
113
- });
114
- });
115
-
116
- describe('With CustomPanel NodeSpec FF Off ', () => {
117
- describe.each([
118
- {
119
- subject: 'panelType',
120
- html: '<div data-panel-type="info"><p>testing</p></div>',
121
- expected: {
122
- panelType: 'info',
123
- panelColor: null,
124
- panelIcon: null,
125
- panelIconId: null,
126
- panelIconText: null,
127
- },
128
- },
129
- {
130
- subject: 'icon and color',
131
- html: '<div data-panel-type="custom" data-panel-icon=":smiley:" data-panel-color="#33FF33"><p>testing</p></div>',
132
- expected: {
133
- panelType: 'info',
134
- panelColor: null,
135
- panelIcon: null,
136
- panelIconId: null,
137
- panelIconText: null,
138
- },
139
- },
140
- ])('extract correct values', ({ html, subject, expected }) => {
141
- it(`for ${subject}`, () => {
142
- const doc = fromHTML(html, schemaWithoutCustomPanel);
143
- const panel = doc.firstChild!;
144
- expect(panel.type.name).toContain('panel');
145
- expect(panel.attrs).toEqual(expected);
146
- });
147
- });
148
-
149
- it('should have data-panel-type when serializing to DOM', () => {
150
- const html = toHTML(
151
- schemaWithoutCustomPanel.nodes.panel.create({
152
- panelType: 'info',
153
- }),
154
- schemaWithoutCustomPanel,
155
- );
156
-
157
- expectHtmlWithData(html, {
158
- panelType: 'info',
159
- });
160
- });
161
- });
162
- });
163
-
164
- function makeSchema(customNodeSpecs?: { [key: string]: NodeSpec }) {
165
- const config: SchemaConfig = {
166
- nodes: [
167
- 'doc',
168
- 'paragraph',
169
- 'heading',
170
- 'text',
171
- 'panel',
172
- 'orderedList',
173
- 'bulletList',
174
- 'listItem',
175
- ],
176
- };
177
- return customNodeSpecs
178
- ? createSchema({ ...config, customNodeSpecs })
179
- : createSchema(config);
180
- }
@@ -1,25 +0,0 @@
1
- import { createSchema } from '../../../../schema/create-schema';
2
- import { fromHTML, toHTML } from 'adf-test-helpers/src/adf-schema/html-helpers';
3
-
4
- const schema = makeSchema();
5
- const packageName = process.env._PACKAGE_NAME_ as string;
6
-
7
- describe(`${packageName}/schema paragraph node`, () => {
8
- it('serializes to <p>', () => {
9
- const html = toHTML(schema.nodes.paragraph.create(), schema);
10
- expect(html).toContain('<p>');
11
- });
12
-
13
- it('matches <p>', () => {
14
- const doc = fromHTML('<p>Hello World</p>', schema);
15
- const p = doc.firstChild!;
16
- expect(p.type.name).toEqual('paragraph');
17
- expect(p.firstChild!.text!).toEqual('Hello World');
18
- });
19
- });
20
-
21
- function makeSchema() {
22
- return createSchema({
23
- nodes: ['doc', 'paragraph', 'text'],
24
- });
25
- }
@@ -1,46 +0,0 @@
1
- import { toDOM, fromHTML } from 'adf-test-helpers/src/adf-schema/html-helpers';
2
- import { placeholder } from '../../../..';
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 placeholder node`, () => {
8
- describe('parse html', () => {
9
- it('converts to date PM node', () => {
10
- const doc = fromHTML(
11
- '<span data-placeholder="Type something..." />',
12
- schema,
13
- );
14
- const node = doc.firstChild!.firstChild!;
15
- expect(node.type.spec).toEqual(placeholder);
16
- });
17
-
18
- it('gets attributes from html', () => {
19
- const doc = fromHTML(
20
- '<span data-placeholder="Type something..." />',
21
- schema,
22
- );
23
- const node = doc.firstChild!.firstChild!;
24
- expect(node.attrs.text).toEqual('Type something...');
25
- });
26
- });
27
-
28
- describe('encode html', () => {
29
- it('converts html data attributes to node attributes', () => {
30
- const attrs = { text: 'Type something...' };
31
- // extension node can contain no content
32
- const node = schema.nodes.placeholder.createChecked(attrs);
33
- const dom = toDOM(node, schema).firstChild! as HTMLElement;
34
- expect(dom.getAttribute('data-placeholder')).toEqual('Type something...');
35
- });
36
-
37
- it('encodes and decodes to the same node', () => {
38
- const attrs = { text: 'Type something...' };
39
- const node = schema.nodes.placeholder.createChecked(attrs);
40
- const dom = toDOM(node, schema).firstChild as HTMLElement;
41
- const parsedNode = fromHTML(dom.outerHTML, schema).firstChild!
42
- .firstChild!;
43
- expect(parsedNode).toEqual(node);
44
- });
45
- });
46
- });
@@ -1,24 +0,0 @@
1
- import { createSchema } from '../../../../schema/create-schema';
2
- import { fromHTML, toHTML } from 'adf-test-helpers/src/adf-schema/html-helpers';
3
-
4
- const schema = makeSchema();
5
- const packageName = process.env._PACKAGE_NAME_ as string;
6
-
7
- describe(`${packageName}/schema rule node`, () => {
8
- it('serializes to <hr/>', () => {
9
- const html = toHTML(schema.nodes.rule.create(), schema);
10
- expect(html).toContain('<hr>');
11
- });
12
-
13
- it('matches <hr/>', () => {
14
- const doc = fromHTML('<hr/>', schema);
15
- const p = doc.firstChild!;
16
- expect(p.type.name).toEqual('rule');
17
- });
18
- });
19
-
20
- function makeSchema() {
21
- return createSchema({
22
- nodes: ['doc', 'rule', 'text'],
23
- });
24
- }
@@ -1,120 +0,0 @@
1
- import { toDOM, fromHTML } from 'adf-test-helpers/src/adf-schema/html-helpers';
2
- import { status } from '../../../..';
3
- import { StatusLocalIdRegex } from 'adf-test-helpers/src/constants';
4
- import { schema } from 'adf-test-helpers/src/adf-schema';
5
- const packageName = process.env._PACKAGE_NAME_ as string;
6
-
7
- describe(`${packageName}/schema status node`, () => {
8
- describe('parse html', () => {
9
- it('converts to status PM node', () => {
10
- const doc = fromHTML('<span data-node-type="status" />', schema);
11
- const node = doc.firstChild!.firstChild!;
12
- expect(node.type.spec).toEqual(status);
13
- });
14
-
15
- it('gets attributes from html', () => {
16
- const color = 'blue';
17
- const localId = '6c5e5301-1311-42e2-aa80-1b7557140b3d';
18
- const style = 'bold';
19
- const doc = fromHTML(
20
- `
21
- <span
22
- data-node-type="status"
23
- data-color="${color}"
24
- data-local-id="${localId}"
25
- data-style="${style}"
26
- >
27
- In progress
28
- </span>
29
- `,
30
- schema,
31
- );
32
- const node = doc.firstChild!.firstChild!;
33
- expect(node.attrs).toMatchObject({
34
- text: 'In progress',
35
- color,
36
- localId: expect.stringMatching(StatusLocalIdRegex),
37
- style,
38
- });
39
-
40
- expect(node.attrs.localId).not.toEqual(localId);
41
- });
42
-
43
- it('gets attributes from html without optional ones', () => {
44
- const color = 'blue';
45
- const doc = fromHTML(
46
- `
47
- <span
48
- data-node-type="status"
49
- data-color="${color}"
50
- >
51
- In progress
52
- </span>
53
- `,
54
- schema,
55
- );
56
- const node = doc.firstChild!.firstChild!;
57
-
58
- expect(node.attrs).toMatchObject({
59
- text: 'In progress',
60
- color,
61
- localId: expect.stringMatching(StatusLocalIdRegex),
62
- });
63
- });
64
- });
65
-
66
- describe('encode html', () => {
67
- it('converts html status attributes to node attributes', () => {
68
- const attrs = {
69
- text: 'In progress',
70
- color: 'blue',
71
- localId: '3fba07fc-0458-449c-bba9-04d5555164ea',
72
- style: 'subtle',
73
- };
74
- const node = schema.nodes.status.create(attrs);
75
- const dom = toDOM(node, schema).firstChild! as HTMLElement;
76
- expect(dom.getAttribute('data-node-type')).toEqual('status');
77
- expect(dom.textContent).toEqual(attrs.text);
78
- expect(dom.getAttribute('data-color')).toEqual(attrs.color);
79
- expect(dom.getAttribute('data-local-id')).toEqual(attrs.localId);
80
- expect(dom.getAttribute('data-style')).toEqual(attrs.style);
81
- });
82
-
83
- it('encodes and decodes to the same node', () => {
84
- const attrs = {
85
- text: 'In progress',
86
- color: 'blue',
87
- localId: '3fba07fc-0458-449c-bba9-04d5555164ea',
88
- style: 'bold',
89
- };
90
- const node = schema.nodes.status.create(attrs);
91
- const dom = toDOM(node, schema).firstChild as HTMLElement;
92
- const parsedNode = fromHTML(dom.outerHTML, schema).firstChild!
93
- .firstChild!;
94
-
95
- expect(parsedNode.attrs).toMatchObject({
96
- text: 'In progress',
97
- color: 'blue',
98
- localId: expect.stringMatching(StatusLocalIdRegex),
99
- style: 'bold',
100
- });
101
-
102
- expect(parsedNode.attrs.localId).not.toEqual(attrs.localId);
103
- });
104
-
105
- it('converts html status attributes to node attributes without style', () => {
106
- const attrs = {
107
- text: 'In progress',
108
- color: 'blue',
109
- localId: '3fba07fc-0458-449c-bba9-04d5555164ea',
110
- };
111
- const node = schema.nodes.status.create(attrs);
112
- const dom = toDOM(node, schema).firstChild! as HTMLElement;
113
- expect(dom.getAttribute('data-node-type')).toEqual('status');
114
- expect(dom.textContent).toEqual(attrs.text);
115
- expect(dom.getAttribute('data-color')).toEqual(attrs.color);
116
- expect(dom.getAttribute('data-local-id')).toEqual(attrs.localId);
117
- expect(dom.getAttribute('data-style')).toEqual('');
118
- });
119
- });
120
- });