@atlaskit/adf-schema 28.1.12 → 28.2.0

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 (210) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/types/index.d.ts +1 -1
  3. package/package.json +1 -1
  4. package/src/__tests__/unit/json-schema/v1.ts +0 -55
  5. package/src/__tests__/unit/schema/create-schema.ts +0 -214
  6. package/src/__tests__/unit/schema/default-schema.ts +0 -192
  7. package/src/__tests__/unit/schema/marks/annotation.ts +0 -46
  8. package/src/__tests__/unit/schema/marks/border.ts +0 -76
  9. package/src/__tests__/unit/schema/marks/breakout.ts +0 -24
  10. package/src/__tests__/unit/schema/marks/code.ts +0 -44
  11. package/src/__tests__/unit/schema/marks/confluence-inline-comment.ts +0 -25
  12. package/src/__tests__/unit/schema/marks/data-consumer.ts +0 -52
  13. package/src/__tests__/unit/schema/marks/em.ts +0 -37
  14. package/src/__tests__/unit/schema/marks/link.ts +0 -188
  15. package/src/__tests__/unit/schema/marks/strike.ts +0 -37
  16. package/src/__tests__/unit/schema/marks/strong.ts +0 -43
  17. package/src/__tests__/unit/schema/marks/subsup.ts +0 -50
  18. package/src/__tests__/unit/schema/marks/text-color.ts +0 -61
  19. package/src/__tests__/unit/schema/marks/underline.ts +0 -36
  20. package/src/__tests__/unit/schema/nodes/_consts.ts +0 -964
  21. package/src/__tests__/unit/schema/nodes/block-card.ts +0 -184
  22. package/src/__tests__/unit/schema/nodes/blockquote.ts +0 -44
  23. package/src/__tests__/unit/schema/nodes/bodied-extension.ts +0 -101
  24. package/src/__tests__/unit/schema/nodes/code-block.ts +0 -221
  25. package/src/__tests__/unit/schema/nodes/confluence-unsupported-block.ts +0 -32
  26. package/src/__tests__/unit/schema/nodes/confluence-unsupported-inline.ts +0 -35
  27. package/src/__tests__/unit/schema/nodes/date.ts +0 -51
  28. package/src/__tests__/unit/schema/nodes/decision-item.ts +0 -46
  29. package/src/__tests__/unit/schema/nodes/decision-list.ts +0 -52
  30. package/src/__tests__/unit/schema/nodes/embed-card.ts +0 -60
  31. package/src/__tests__/unit/schema/nodes/emoji.ts +0 -71
  32. package/src/__tests__/unit/schema/nodes/expand.ts +0 -51
  33. package/src/__tests__/unit/schema/nodes/extension.ts +0 -101
  34. package/src/__tests__/unit/schema/nodes/hard-break.ts +0 -24
  35. package/src/__tests__/unit/schema/nodes/heading.ts +0 -56
  36. package/src/__tests__/unit/schema/nodes/image.ts +0 -32
  37. package/src/__tests__/unit/schema/nodes/inline-card.ts +0 -106
  38. package/src/__tests__/unit/schema/nodes/inline-extension.ts +0 -79
  39. package/src/__tests__/unit/schema/nodes/layout-column.ts +0 -54
  40. package/src/__tests__/unit/schema/nodes/layout-section.ts +0 -95
  41. package/src/__tests__/unit/schema/nodes/list-item.ts +0 -49
  42. package/src/__tests__/unit/schema/nodes/media-group.ts +0 -67
  43. package/src/__tests__/unit/schema/nodes/media-single.ts +0 -171
  44. package/src/__tests__/unit/schema/nodes/media.ts +0 -384
  45. package/src/__tests__/unit/schema/nodes/mention.ts +0 -115
  46. package/src/__tests__/unit/schema/nodes/nestedExpand.ts +0 -72
  47. package/src/__tests__/unit/schema/nodes/ordered-list.ts +0 -49
  48. package/src/__tests__/unit/schema/nodes/panel.ts +0 -180
  49. package/src/__tests__/unit/schema/nodes/paragraph.ts +0 -25
  50. package/src/__tests__/unit/schema/nodes/placeholder.ts +0 -46
  51. package/src/__tests__/unit/schema/nodes/rule.ts +0 -24
  52. package/src/__tests__/unit/schema/nodes/status.ts +0 -120
  53. package/src/__tests__/unit/schema/nodes/tableNodes.ts +0 -555
  54. package/src/__tests__/unit/schema/nodes/task-item.ts +0 -39
  55. package/src/__tests__/unit/schema/nodes/task-list.ts +0 -45
  56. package/src/__tests__/unit/schema/nodes/unknown-block.ts +0 -42
  57. package/src/__tests__/unit/schema/nodes/unsupported-block.ts +0 -42
  58. package/src/__tests__/unit/schema/nodes/unsupported-inline.ts +0 -38
  59. package/src/__tests__/unit/utils/colors.ts +0 -42
  60. package/src/__tests__/unit/utils/url.ts +0 -209
  61. package/src/schema/bitbucket-schema.ts +0 -43
  62. package/src/schema/confluence-schema.ts +0 -76
  63. package/src/schema/create-schema.ts +0 -337
  64. package/src/schema/default-schema.ts +0 -180
  65. package/src/schema/groups.ts +0 -30
  66. package/src/schema/inline-nodes.ts +0 -9
  67. package/src/schema/jira-schema.ts +0 -158
  68. package/src/schema/marks/__tests__/unit/annotation.ts +0 -18
  69. package/src/schema/marks/alignment.ts +0 -48
  70. package/src/schema/marks/annotation.ts +0 -107
  71. package/src/schema/marks/border.ts +0 -74
  72. package/src/schema/marks/breakout.ts +0 -42
  73. package/src/schema/marks/code.ts +0 -45
  74. package/src/schema/marks/confluence-inline-comment.ts +0 -32
  75. package/src/schema/marks/data-consumer.ts +0 -100
  76. package/src/schema/marks/em.ts +0 -19
  77. package/src/schema/marks/fragment.ts +0 -77
  78. package/src/schema/marks/indentation.ts +0 -47
  79. package/src/schema/marks/link.ts +0 -139
  80. package/src/schema/marks/strike.ts +0 -26
  81. package/src/schema/marks/strong.ts +0 -45
  82. package/src/schema/marks/subsup.ts +0 -53
  83. package/src/schema/marks/text-color.ts +0 -172
  84. package/src/schema/marks/type-ahead-query.ts +0 -22
  85. package/src/schema/marks/underline.ts +0 -24
  86. package/src/schema/marks/unsupported-mark.ts +0 -9
  87. package/src/schema/marks/unsupported-node-attributes.ts +0 -8
  88. package/src/schema/nodes/block-card.ts +0 -121
  89. package/src/schema/nodes/blockquote.ts +0 -25
  90. package/src/schema/nodes/bodied-extension.ts +0 -75
  91. package/src/schema/nodes/bullet-list.ts +0 -17
  92. package/src/schema/nodes/caption.ts +0 -51
  93. package/src/schema/nodes/code-block.ts +0 -176
  94. package/src/schema/nodes/confluence-jira-issue.ts +0 -43
  95. package/src/schema/nodes/confluence-unsupported-block.ts +0 -29
  96. package/src/schema/nodes/confluence-unsupported-inline.ts +0 -30
  97. package/src/schema/nodes/date.ts +0 -38
  98. package/src/schema/nodes/decision-item.ts +0 -50
  99. package/src/schema/nodes/decision-list.ts +0 -56
  100. package/src/schema/nodes/doc.ts +0 -30
  101. package/src/schema/nodes/embed-card.ts +0 -62
  102. package/src/schema/nodes/emoji.ts +0 -89
  103. package/src/schema/nodes/expand.ts +0 -101
  104. package/src/schema/nodes/extension.ts +0 -60
  105. package/src/schema/nodes/hard-break.ts +0 -21
  106. package/src/schema/nodes/heading.ts +0 -64
  107. package/src/schema/nodes/image.ts +0 -32
  108. package/src/schema/nodes/inline-card.ts +0 -70
  109. package/src/schema/nodes/inline-extension.ts +0 -57
  110. package/src/schema/nodes/layout-column.ts +0 -68
  111. package/src/schema/nodes/layout-section.ts +0 -93
  112. package/src/schema/nodes/list-item.ts +0 -13
  113. package/src/schema/nodes/media-group.ts +0 -44
  114. package/src/schema/nodes/media-inline.ts +0 -19
  115. package/src/schema/nodes/media-single.ts +0 -179
  116. package/src/schema/nodes/media.ts +0 -253
  117. package/src/schema/nodes/mention.ts +0 -86
  118. package/src/schema/nodes/nested-expand.ts +0 -77
  119. package/src/schema/nodes/ordered-list.ts +0 -62
  120. package/src/schema/nodes/panel.ts +0 -133
  121. package/src/schema/nodes/paragraph.ts +0 -79
  122. package/src/schema/nodes/placeholder.ts +0 -40
  123. package/src/schema/nodes/rule.ts +0 -17
  124. package/src/schema/nodes/status.ts +0 -58
  125. package/src/schema/nodes/tableNodes.ts +0 -478
  126. package/src/schema/nodes/task-item.ts +0 -51
  127. package/src/schema/nodes/task-list.ts +0 -61
  128. package/src/schema/nodes/text.ts +0 -19
  129. package/src/schema/nodes/types/block-content.ts +0 -51
  130. package/src/schema/nodes/types/extensions.ts +0 -36
  131. package/src/schema/nodes/types/inline-content.ts +0 -56
  132. package/src/schema/nodes/types/list.ts +0 -54
  133. package/src/schema/nodes/types/mark.ts +0 -16
  134. package/src/schema/nodes/types/non-nestable-block-content.ts +0 -39
  135. package/src/schema/nodes/types/rich-media-common.ts +0 -51
  136. package/src/schema/nodes/unknown-block.ts +0 -13
  137. package/src/schema/nodes/unsupported-block.ts +0 -28
  138. package/src/schema/nodes/unsupported-inline.ts +0 -27
  139. package/src/schema/unsupported.ts +0 -4
  140. package/src/steps/__tests__/unit/analytics.ts +0 -72
  141. package/src/steps/__tests__/unit/link-meta-step.ts +0 -64
  142. package/src/steps/__tests__/unit/override-document-step.ts +0 -174
  143. package/src/steps/__tests__/unit/set-attrs.ts +0 -71
  144. package/src/steps/analytics.ts +0 -189
  145. package/src/steps/link-meta-step.ts +0 -105
  146. package/src/steps/override-document-step.ts +0 -97
  147. package/src/steps/set-attrs.tsx +0 -74
  148. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-0.json +0 -15
  149. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-1.json +0 -15
  150. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-2.json +0 -15
  151. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-3.json +0 -15
  152. package/src/steps/table/__tests__/__fixtures__/basic/remove-column-at-0.json +0 -9
  153. package/src/steps/table/__tests__/__fixtures__/basic/remove-column-at-1.json +0 -9
  154. package/src/steps/table/__tests__/__fixtures__/basic/remove-column-at-2.json +0 -9
  155. package/src/steps/table/__tests__/__fixtures__/basic/remove-table/remove-last-row-inverted.json +0 -98
  156. package/src/steps/table/__tests__/__fixtures__/basic/remove-table/remove-last-row.json +0 -71
  157. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-0-inverted.json +0 -19
  158. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-0.json +0 -19
  159. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-1-inverted.json +0 -21
  160. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-1.json +0 -21
  161. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-2-inverted.json +0 -21
  162. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-2.json +0 -21
  163. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-3-inverted.json +0 -19
  164. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-3.json +0 -19
  165. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-0-inverted.json +0 -63
  166. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-0.json +0 -21
  167. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-1-inverted.json +0 -64
  168. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-1.json +0 -22
  169. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-2-inverted.json +0 -63
  170. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-2.json +0 -21
  171. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-0-inverted.json +0 -19
  172. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-0.json +0 -19
  173. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-1-inverted.json +0 -19
  174. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-1.json +0 -19
  175. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-2-inverted.json +0 -19
  176. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-2.json +0 -19
  177. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-3-inverted.json +0 -19
  178. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-3.json +0 -19
  179. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-0-inverted.json +0 -52
  180. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-0.json +0 -38
  181. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-1-inverted.json +0 -52
  182. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-1.json +0 -38
  183. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-2-inverted.json +0 -25
  184. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-2.json +0 -11
  185. package/src/steps/table/__tests__/_utils.ts +0 -102
  186. package/src/steps/table/__tests__/add-column-merge-columns.ts +0 -509
  187. package/src/steps/table/__tests__/add-column-merge-rows.ts +0 -466
  188. package/src/steps/table/__tests__/add-column.ts +0 -638
  189. package/src/steps/table/add-column.ts +0 -443
  190. package/src/steps/table/constants.ts +0 -4
  191. package/src/steps/table/sort-column.ts +0 -57
  192. package/src/steps/table/types.ts +0 -48
  193. package/src/steps/table/utils/cell-step.ts +0 -239
  194. package/src/steps/table/utils/cells-at-column.ts +0 -75
  195. package/src/steps/table/utils/find-column.ts +0 -90
  196. package/src/steps/table/utils/get-table-rect-from-doc.ts +0 -37
  197. package/src/steps/table/utils/side-effects/rows.ts +0 -327
  198. package/src/steps/table/utils/side-effects/side-effects.ts +0 -90
  199. package/src/steps/table/utils/side-effects/table.ts +0 -112
  200. package/src/steps/table/utils/side-effects/types.ts +0 -34
  201. package/src/steps/table/utils/table-map.ts +0 -28
  202. package/src/steps/type-ahead.ts +0 -100
  203. package/src/steps.ts +0 -16
  204. package/src/utils/colors.ts +0 -171
  205. package/src/utils/confluence/emoji.ts +0 -99
  206. package/src/utils/extensions.ts +0 -32
  207. package/src/utils/parseDOM.ts +0 -2
  208. package/src/utils/url.ts +0 -173
  209. package/src/utils/uuid.ts +0 -19
  210. package/src/version.json +0 -6
@@ -1,555 +0,0 @@
1
- import { uuid } from '../../../../utils';
2
- import { createSchema } from '../../../../schema/create-schema';
3
- import {
4
- table,
5
- TableAttributes,
6
- CellAttributes,
7
- } from '../../../../schema/nodes/tableNodes';
8
- import { fromHTML, toHTML } from 'adf-test-helpers/src/adf-schema/html-helpers';
9
-
10
- import {
11
- ATTRIBUTES_PARSE_DEFAULTS,
12
- ATTRIBUTES_PARSE_NUMBERED_COLUMNS,
13
- ATTRIBUTES_PARSE_WIDE_LAYOUT,
14
- ATTRIBUTES_PARSE_FULLWIDTH_LAYOUT,
15
- HTML_PARSE_EDITOR_2x2,
16
- HTML_PARSE_EDITOR_2x2_WITH_HEADER_COLUMN,
17
- HTML_PARSE_EDITOR_2x1_ONLY_HEADERS,
18
- HTML_PARSE_EDITOR_2x1_PARTIAL_CELL_SELECTION,
19
- HTML_PARSE_EDITOR_1x2_PARTIAL_HEADER_CELL,
20
- HTML_PARSE_EDITOR_P_TABLE_P_RANGE,
21
- HTML_PARSE_EDITOR_P_PARTIAL_TABLE,
22
- HTML_PARSE_RENDERER_FULL_TABLE_2x2_NO_HEADERS,
23
- HTML_PARSE_RENDERER_FULL_TABLE_2x2_HEADER_COLUMN,
24
- HTML_PARSE_RENDERER_FULL_TABLE_2x2_HEADER_ROW,
25
- HTML_PARSE_RENDERER_FULL_2x1_TABLE_ONLY_HEADERS,
26
- HTML_PARSE_RENDERER_PARTIAL_TABLE_2x1_CELL_SELECTION,
27
- HTML_PARSE_RENDERER_PARTIAL_TABLE_2x1_HEADER_CELL_SELECTION,
28
- HTML_PARSE_RENDERER_P_TABLE_P_SELECTION_RANGE,
29
- HTML_PARSE_RENDERER_P_PARTIAL_TABLE_SELECTION_RANGE,
30
- HTML_PARSE_GOOGLE_SHEETS_DATA_CELLS,
31
- } from './_consts';
32
-
33
- const makeSchema = () =>
34
- createSchema({
35
- nodes: [
36
- 'doc',
37
- 'paragraph',
38
- 'text',
39
- 'table',
40
- 'tableRow',
41
- 'tableCell',
42
- 'tableHeader',
43
- ],
44
- marks: ['fragment', 'unsupportedMark', 'unsupportedNodeAttribute'],
45
- });
46
-
47
- const TABLE_LOCAL_ID = 'test-table-local-id';
48
- const packageName = process.env._PACKAGE_NAME_ as string;
49
-
50
- describe(`${packageName}/schema table node`, () => {
51
- beforeAll(() => {
52
- uuid.setStatic(TABLE_LOCAL_ID);
53
- });
54
-
55
- afterAll(() => {
56
- uuid.setStatic(false);
57
- });
58
-
59
- const schema = makeSchema();
60
-
61
- it('should have isolating property to be true', () => {
62
- expect(schema.nodes.table.spec.isolating).toEqual(true);
63
- });
64
- it('should have selectable property to be true', () => {
65
- expect(schema.nodes.table.spec.selectable).toEqual(true);
66
- });
67
-
68
- describe('parse attributes', () => {
69
- it('should parse with defaults if missing', () => {
70
- const doc = fromHTML(ATTRIBUTES_PARSE_DEFAULTS, schema);
71
-
72
- const parsedTable = doc.firstChild!;
73
- expect(parsedTable.type.spec).toEqual(table);
74
- expect(parsedTable.attrs).toEqual({
75
- __autoSize: false,
76
- isNumberColumnEnabled: false,
77
- layout: 'default',
78
- localId: TABLE_LOCAL_ID,
79
- });
80
- });
81
-
82
- it('should parse numbered columns', () => {
83
- const doc = fromHTML(ATTRIBUTES_PARSE_NUMBERED_COLUMNS, schema);
84
-
85
- const parsedTable = doc.firstChild!;
86
- expect(parsedTable.type.spec).toEqual(table);
87
- expect(parsedTable.attrs).toEqual({
88
- __autoSize: false,
89
- isNumberColumnEnabled: true,
90
- layout: 'default',
91
- localId: TABLE_LOCAL_ID,
92
- });
93
- });
94
-
95
- it('should parse wide layout', () => {
96
- const doc = fromHTML(ATTRIBUTES_PARSE_WIDE_LAYOUT, schema);
97
-
98
- const parsedTable = doc.firstChild!;
99
- expect(parsedTable.type.spec).toEqual(table);
100
- expect(parsedTable.attrs).toEqual({
101
- __autoSize: false,
102
- isNumberColumnEnabled: false,
103
- layout: 'wide',
104
- localId: TABLE_LOCAL_ID,
105
- });
106
- });
107
-
108
- it('should parse full-width layout', () => {
109
- const doc = fromHTML(ATTRIBUTES_PARSE_FULLWIDTH_LAYOUT, schema);
110
-
111
- const parsedTable = doc.firstChild!;
112
- expect(parsedTable.type.spec).toEqual(table);
113
- expect(parsedTable.attrs).toEqual({
114
- __autoSize: false,
115
- isNumberColumnEnabled: false,
116
- layout: 'full-width',
117
- localId: TABLE_LOCAL_ID,
118
- });
119
- });
120
- });
121
-
122
- describe('parse from HTML/clipboard', () => {
123
- describe('parse from editor encoded HTML', () => {
124
- it('should parse from 2x2 table selection', () => {
125
- const doc = fromHTML(HTML_PARSE_EDITOR_2x2, schema);
126
-
127
- const parsedTable = doc.firstChild!;
128
- // type
129
- expect(parsedTable.type.spec).toEqual(table);
130
- // structure
131
- expect(parsedTable.toString()).toEqual(
132
- 'table(tableRow(tableHeader(paragraph("A")), tableHeader(paragraph("B"))), tableRow(tableCell(paragraph("1")), tableCell(paragraph("2"))))',
133
- );
134
- // attributes
135
- expect(parsedTable.attrs).toEqual({
136
- __autoSize: false,
137
- isNumberColumnEnabled: false,
138
- layout: 'default',
139
- localId: TABLE_LOCAL_ID,
140
- });
141
- });
142
-
143
- it('should parse from 2x2 table selection with header column', () => {
144
- const doc = fromHTML(HTML_PARSE_EDITOR_2x2_WITH_HEADER_COLUMN, schema);
145
-
146
- const parsedTable = doc.firstChild!;
147
- expect(parsedTable.type.spec).toEqual(table);
148
- expect(parsedTable.toString()).toEqual(
149
- 'table(tableRow(tableHeader(paragraph("A")), tableCell(paragraph("B"))), tableRow(tableHeader(paragraph("1")), tableCell(paragraph("2"))))',
150
- );
151
- });
152
-
153
- it('should parse partial selection from 2x1 table header selection', () => {
154
- const doc = fromHTML(HTML_PARSE_EDITOR_2x1_ONLY_HEADERS, schema);
155
-
156
- const parsedTable = doc.firstChild!;
157
- expect(parsedTable.type.spec).toEqual(table);
158
- expect(parsedTable.toString()).toEqual(
159
- 'table(tableRow(tableHeader(paragraph("A")), tableHeader(paragraph("B"))))',
160
- );
161
- });
162
-
163
- it('should parse partial selection from 2x1 table cell selection', () => {
164
- const doc = fromHTML(
165
- HTML_PARSE_EDITOR_2x1_PARTIAL_CELL_SELECTION,
166
- schema,
167
- );
168
-
169
- const parsedTable = doc.firstChild!;
170
- expect(parsedTable.type.spec).toEqual(table);
171
- expect(parsedTable.toString()).toEqual(
172
- 'table(tableRow(tableCell(paragraph("1")), tableCell(paragraph("2"))))',
173
- );
174
- });
175
-
176
- it('should parse partial selection from 1x2 table header/cell selection', () => {
177
- const doc = fromHTML(HTML_PARSE_EDITOR_1x2_PARTIAL_HEADER_CELL, schema);
178
-
179
- const parsedTable = doc.firstChild!;
180
- expect(parsedTable.type.spec).toEqual(table);
181
- expect(parsedTable.toString()).toEqual(
182
- 'table(tableRow(tableHeader(paragraph("B"))), tableRow(tableCell(paragraph("2"))))',
183
- );
184
- });
185
-
186
- it('should parse paragraph/table/paragraph from range selection', () => {
187
- const doc = fromHTML(HTML_PARSE_EDITOR_P_TABLE_P_RANGE, schema);
188
-
189
- const parsedTable = doc.child(1)!;
190
- expect(parsedTable.type.spec).toEqual(table);
191
- expect(parsedTable.toString()).toEqual(
192
- 'table(tableRow(tableHeader(paragraph("A")), tableHeader(paragraph("B"))), tableRow(tableCell(paragraph("1")), tableCell(paragraph("2"))))',
193
- );
194
- });
195
-
196
- it('should parse paragraph and partial table selection from range selection', () => {
197
- const doc = fromHTML(HTML_PARSE_EDITOR_P_PARTIAL_TABLE, schema);
198
-
199
- const parsedTable = doc.child(1)!;
200
- expect(parsedTable.type.spec).toEqual(table);
201
- expect(parsedTable.toString()).toEqual(
202
- 'table(tableRow(tableHeader(paragraph("A")), tableHeader(paragraph("B"))), tableRow(tableCell(paragraph("1"))))',
203
- );
204
- expect(parsedTable.attrs).toEqual({
205
- __autoSize: false,
206
- isNumberColumnEnabled: false,
207
- layout: 'full-width',
208
- localId: TABLE_LOCAL_ID,
209
- });
210
- });
211
- });
212
-
213
- /*
214
- * Scenarios
215
- * - a full 2x2 table selection (no headers)
216
- * - a full 2x2 table selection (with column headers)
217
- * - a full 2x2 table selection (with row headers)
218
- * - a full 2x1 table selection (only headers)
219
- * - a partial 2x1 cell selection
220
- * - a partial 2x1 header/cell selection
221
- * - a paragraph/full table/p selection range
222
- * - a paragraph/partial table selection range
223
- */
224
- describe('parse from renderer encoded HTML', () => {
225
- it('should parse a full 2x2 table selection (no headers)', () => {
226
- const doc = fromHTML(
227
- HTML_PARSE_RENDERER_FULL_TABLE_2x2_NO_HEADERS,
228
- schema,
229
- );
230
-
231
- const parsedTable = doc.firstChild!;
232
- // type
233
- expect(parsedTable.type.spec).toEqual(table);
234
- // structure
235
- expect(parsedTable.toString()).toEqual(
236
- 'table(tableRow(tableCell(paragraph("A")), tableCell(paragraph("B"))), tableRow(tableCell(paragraph("C")), tableCell(paragraph("D"))))',
237
- );
238
- // attributes
239
- expect(parsedTable.attrs).toEqual({
240
- __autoSize: false,
241
- isNumberColumnEnabled: false,
242
- layout: 'default',
243
- localId: TABLE_LOCAL_ID,
244
- });
245
- });
246
-
247
- it('should parse a full 2x2 table selection (with header column)', () => {
248
- const doc = fromHTML(
249
- HTML_PARSE_RENDERER_FULL_TABLE_2x2_HEADER_COLUMN,
250
- schema,
251
- );
252
-
253
- const parsedTable = doc.firstChild!;
254
- // type
255
- expect(parsedTable.type.spec).toEqual(table);
256
- // structure
257
- expect(parsedTable.toString()).toEqual(
258
- 'table(tableRow(tableHeader(paragraph("A")), tableCell(paragraph("B"))), tableRow(tableHeader(paragraph("C")), tableCell(paragraph("D"))))',
259
- );
260
- // attributes
261
- expect(parsedTable.attrs).toEqual({
262
- __autoSize: false,
263
- isNumberColumnEnabled: false,
264
- layout: 'default',
265
- localId: TABLE_LOCAL_ID,
266
- });
267
- });
268
-
269
- it('should parse a full 2x2 table selection (with header row)', () => {
270
- const doc = fromHTML(
271
- HTML_PARSE_RENDERER_FULL_TABLE_2x2_HEADER_ROW,
272
- schema,
273
- );
274
-
275
- const parsedTable = doc.firstChild!;
276
- // type
277
- expect(parsedTable.type.spec).toEqual(table);
278
- // structure
279
- expect(parsedTable.toString()).toEqual(
280
- 'table(tableRow(tableHeader(paragraph("A")), tableHeader(paragraph("B"))), tableRow(tableCell(paragraph("C")), tableCell(paragraph("D"))))',
281
- );
282
- // attributes
283
- expect(parsedTable.attrs).toEqual({
284
- __autoSize: false,
285
- isNumberColumnEnabled: false,
286
- layout: 'default',
287
- localId: TABLE_LOCAL_ID,
288
- });
289
- });
290
- it('should parse a full 2x1 table selection (only headers)', () => {
291
- const doc = fromHTML(
292
- HTML_PARSE_RENDERER_FULL_2x1_TABLE_ONLY_HEADERS,
293
- schema,
294
- );
295
-
296
- const parsedTable = doc.firstChild!;
297
- // type
298
- expect(parsedTable.type.spec).toEqual(table);
299
- // structure
300
- expect(parsedTable.toString()).toEqual(
301
- 'table(tableRow(tableHeader(paragraph("A")), tableHeader(paragraph("B"))), tableRow(tableHeader(paragraph("C")), tableHeader(paragraph("D"))))',
302
- );
303
- // attributes
304
- expect(parsedTable.attrs).toEqual({
305
- __autoSize: false,
306
- isNumberColumnEnabled: false,
307
- layout: 'default',
308
- localId: TABLE_LOCAL_ID,
309
- });
310
- });
311
- it('should parse a partial 2x1 cell selection', () => {
312
- const doc = fromHTML(
313
- HTML_PARSE_RENDERER_PARTIAL_TABLE_2x1_CELL_SELECTION,
314
- schema,
315
- );
316
-
317
- const parsedTable = doc.firstChild!;
318
- // type
319
- expect(parsedTable.type.spec).toEqual(table);
320
- // structure
321
- expect(parsedTable.toString()).toEqual(
322
- 'table(tableRow(tableCell(paragraph("A")), tableCell(paragraph("B"))))',
323
- );
324
- // attributes
325
- expect(parsedTable.attrs).toEqual({
326
- __autoSize: false,
327
- isNumberColumnEnabled: false,
328
- layout: 'default',
329
- localId: TABLE_LOCAL_ID,
330
- });
331
- });
332
- it('should parse a partial 2x1 header/cell selection', () => {
333
- const doc = fromHTML(
334
- HTML_PARSE_RENDERER_PARTIAL_TABLE_2x1_HEADER_CELL_SELECTION,
335
- schema,
336
- );
337
-
338
- const parsedTable = doc.firstChild!;
339
- // type
340
- expect(parsedTable.type.spec).toEqual(table);
341
- // structure
342
- expect(parsedTable.toString()).toEqual(
343
- 'table(tableRow(tableHeader(paragraph("A")), tableCell(paragraph("B"))))',
344
- );
345
- // attributes
346
- expect(parsedTable.attrs).toEqual({
347
- __autoSize: false,
348
- isNumberColumnEnabled: false,
349
- layout: 'default',
350
- localId: TABLE_LOCAL_ID,
351
- });
352
- });
353
- it('should parse a paragraph/full table/p selection range', () => {
354
- const doc = fromHTML(
355
- HTML_PARSE_RENDERER_P_TABLE_P_SELECTION_RANGE,
356
- schema,
357
- );
358
-
359
- const parsedTable = doc.child(1)!;
360
- // type
361
- expect(parsedTable.type.spec).toEqual(table);
362
- // structure
363
- expect(parsedTable.toString()).toEqual(
364
- 'table(tableRow(tableHeader(paragraph("A")), tableHeader(paragraph("B"))), tableRow(tableCell(paragraph("C")), tableCell(paragraph("D"))))',
365
- );
366
- // attributes
367
- expect(parsedTable.attrs).toEqual({
368
- __autoSize: false,
369
- isNumberColumnEnabled: false,
370
- layout: 'default',
371
- localId: TABLE_LOCAL_ID,
372
- });
373
- });
374
- it('should parse a paragraph/partial table selection range', () => {
375
- const doc = fromHTML(
376
- HTML_PARSE_RENDERER_P_PARTIAL_TABLE_SELECTION_RANGE,
377
- schema,
378
- );
379
-
380
- const parsedTable = doc.child(1)!;
381
- // type
382
- expect(parsedTable.type.spec).toEqual(table);
383
- // structure
384
- expect(parsedTable.toString()).toEqual(
385
- 'table(tableRow(tableHeader(paragraph("A")), tableHeader(paragraph("B"))), tableRow(tableCell(paragraph("C"))))',
386
- );
387
- // attributes
388
- expect(parsedTable.attrs).toEqual({
389
- __autoSize: false,
390
- isNumberColumnEnabled: false,
391
- layout: 'default',
392
- localId: TABLE_LOCAL_ID,
393
- });
394
- });
395
- });
396
-
397
- describe('parse from Google sheets encoded HTML', () => {
398
- it('should parse selected cells', () => {
399
- const doc = fromHTML(HTML_PARSE_GOOGLE_SHEETS_DATA_CELLS, schema);
400
-
401
- const parsedTable = doc.firstChild!;
402
- // type
403
- expect(parsedTable.type.spec).toEqual(table);
404
- // structure
405
- expect(parsedTable.toString()).toEqual(
406
- 'table(tableRow(tableCell(paragraph), tableCell(paragraph("Team members"))), tableRow(tableCell(paragraph("1")), tableCell(paragraph("Han"))), tableRow(tableCell(paragraph("2")), tableCell(paragraph("Kristina"))), tableRow(tableCell(paragraph("3")), tableCell(paragraph("Lucy"))), tableRow(tableCell(paragraph("4")), tableCell(paragraph("Mario"))), tableRow(tableCell(paragraph("5")), tableCell(paragraph("Pavlo"))), tableRow(tableCell(paragraph("6")), tableCell(paragraph("Sam"))), tableRow(tableCell(paragraph("7")), tableCell(paragraph("Twig"))), tableRow(tableCell(paragraph("8")), tableCell(paragraph("Wing"))))',
407
- );
408
- // attributes
409
- expect(parsedTable.attrs).toEqual({
410
- __autoSize: false,
411
- isNumberColumnEnabled: false,
412
- layout: 'default',
413
- localId: TABLE_LOCAL_ID,
414
- });
415
- });
416
- });
417
- });
418
-
419
- /*
420
- * scenarios
421
- * - table - default attributes
422
- * - table - change each individual attribute (number col, layout, autosize)
423
- * - cells - default attributes
424
- * - cells - change each individual attribute (colspan, rowspan, style, colorname, colwidth, class
425
- * - header - default attributes
426
- * - header - change each individual attribute colspan, rowspan, style, colorname, colwidth, class)
427
- */
428
- describe('convert to HTML', () => {
429
- const schema = makeSchema();
430
-
431
- describe('table node', () => {
432
- it('should convert default table', () => {
433
- const table = schema.nodes.table.create();
434
- expect(toHTML(table, schema)).toEqual(
435
- '<table data-number-column="false" data-layout="default" data-autosize="false" data-table-local-id=""><tbody></tbody></table>',
436
- );
437
- });
438
-
439
- it('should convert table with layout attribute', () => {
440
- const attrs = { layout: 'full-width' } as TableAttributes;
441
- const table = schema.nodes.table.create(attrs);
442
- expect(toHTML(table, schema)).toEqual(
443
- '<table data-number-column="false" data-layout="full-width" data-autosize="false" data-table-local-id=""><tbody></tbody></table>',
444
- );
445
- });
446
-
447
- it('should convert table with isNumberColumnEnabled attribute', () => {
448
- const attrs = { isNumberColumnEnabled: true } as TableAttributes;
449
- const table = schema.nodes.table.create(attrs);
450
- expect(toHTML(table, schema)).toEqual(
451
- '<table data-number-column="true" data-layout="default" data-autosize="false" data-table-local-id=""><tbody></tbody></table>',
452
- );
453
- });
454
-
455
- it('should convert table with __autoSize attribute', () => {
456
- const attrs = { __autoSize: true } as TableAttributes;
457
- const table = schema.nodes.table.create(attrs);
458
- expect(toHTML(table, schema)).toEqual(
459
- '<table data-number-column="false" data-layout="default" data-autosize="true" data-table-local-id=""><tbody></tbody></table>',
460
- );
461
- });
462
- });
463
-
464
- describe('cell node', () => {
465
- it('should convert default cell', () => {
466
- const cell = schema.nodes.tableCell.create();
467
- expect(toHTML(cell, schema)).toEqual(
468
- '<td class="pm-table-cell-content-wrap"></td>',
469
- );
470
- });
471
- it('should convert default cell with colspan attribute', () => {
472
- const attrs = { colspan: 2 } as CellAttributes;
473
- const cell = schema.nodes.tableCell.create(attrs);
474
- expect(toHTML(cell, schema)).toEqual(
475
- '<td colspan="2" class="pm-table-cell-content-wrap"></td>',
476
- );
477
- });
478
- it('should convert default cell with rowspan attribute', () => {
479
- const attrs = { rowspan: 2 } as CellAttributes;
480
- const cell = schema.nodes.tableCell.create(attrs);
481
- expect(toHTML(cell, schema)).toEqual(
482
- '<td rowspan="2" class="pm-table-cell-content-wrap"></td>',
483
- );
484
- });
485
- it('should convert default cell with colwidth attribute', () => {
486
- const attrs = { colwidth: [200, 300] } as CellAttributes;
487
- const cell = schema.nodes.tableCell.create(attrs);
488
- expect(toHTML(cell, schema)).toEqual(
489
- '<td data-colwidth="200,300" class="pm-table-cell-content-wrap"></td>',
490
- );
491
- });
492
- it('should convert default cell with background attribute', () => {
493
- const attrs = { background: '#ff0000' } as CellAttributes;
494
- const cell = schema.nodes.tableCell.create(attrs);
495
- expect(toHTML(cell, schema)).toEqual(
496
- '<td style="background-color: #ff0000;" data-cell-background="#ff0000" class="pm-table-cell-content-wrap"></td>',
497
- );
498
- });
499
- });
500
-
501
- describe('header node', () => {
502
- it('should convert default header', () => {
503
- const header = schema.nodes.tableHeader.create();
504
- expect(toHTML(header, schema)).toEqual(
505
- '<th class="pm-table-header-content-wrap"></th>',
506
- );
507
- });
508
- it('should convert default header with colspan attribute', () => {
509
- const attrs = { colspan: 2 } as CellAttributes;
510
- const cell = schema.nodes.tableHeader.create(attrs);
511
- expect(toHTML(cell, schema)).toEqual(
512
- '<th colspan="2" class="pm-table-header-content-wrap"></th>',
513
- );
514
- });
515
- it('should convert default header with rowspan attribute', () => {
516
- const attrs = { rowspan: 2 } as CellAttributes;
517
- const cell = schema.nodes.tableHeader.create(attrs);
518
- expect(toHTML(cell, schema)).toEqual(
519
- '<th rowspan="2" class="pm-table-header-content-wrap"></th>',
520
- );
521
- });
522
- it('should convert default header with colwidth attribute', () => {
523
- const attrs = { colwidth: [200, 300] } as CellAttributes;
524
- const cell = schema.nodes.tableHeader.create(attrs);
525
- expect(toHTML(cell, schema)).toEqual(
526
- '<th data-colwidth="200,300" class="pm-table-header-content-wrap"></th>',
527
- );
528
- });
529
- it('should convert default header with background attribute', () => {
530
- const attrs = { background: '#ff0000' } as CellAttributes;
531
- const cell = schema.nodes.tableHeader.create(attrs);
532
- expect(toHTML(cell, schema)).toEqual(
533
- '<th style="background-color: #ff0000;" data-cell-background="#ff0000" class="pm-table-header-content-wrap"></th>',
534
- );
535
- });
536
-
537
- it('should strip out background style with var(--ds-background-neutral)', () => {
538
- const attrs = {
539
- background: 'var(--ds-background-neutral, #F4F5F7)',
540
- } as CellAttributes;
541
- const cell = schema.nodes.tableHeader.create(attrs);
542
- expect(toHTML(cell, schema)).toEqual(
543
- '<th style="" class="pm-table-header-content-wrap"></th>',
544
- );
545
- });
546
- });
547
-
548
- describe('row node', () => {
549
- it('should convert table row', () => {
550
- const row = schema.nodes.tableRow.create();
551
- expect(toHTML(row, schema)).toEqual('<tr></tr>');
552
- });
553
- });
554
- });
555
- });
@@ -1,39 +0,0 @@
1
- import { createSchema } from '../../../../schema/create-schema';
2
- import { toHTML, fromHTML } 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 taskItem node`, () => {
8
- it('serializes to <div> with proper data-attributes', () => {
9
- const html = toHTML(schema.nodes.taskItem.create(), schema);
10
- expect(html).toContain('<div');
11
- expect(html).toContain('data-task-local-id');
12
- expect(html).toContain('data-task-state');
13
- });
14
-
15
- it('matches <div data-task-local-id>', () => {
16
- const doc = fromHTML('<div data-task-local-id>', schema);
17
- const taskItem = doc.firstChild!.firstChild!;
18
- expect(taskItem.type.name).toEqual('taskItem');
19
- });
20
-
21
- it('taskItem requires defining to be true', () => {
22
- expect(schema.nodes.taskItem.spec.defining).toBe(true);
23
- });
24
- });
25
-
26
- function makeSchema() {
27
- return createSchema({
28
- nodes: [
29
- 'doc',
30
- 'paragraph',
31
- 'text',
32
- 'taskList',
33
- 'taskItem',
34
- 'orderedList',
35
- 'bulletList',
36
- 'listItem',
37
- ],
38
- });
39
- }
@@ -1,45 +0,0 @@
1
- import { createSchema } from '../../../../schema/create-schema';
2
- import { toHTML, fromHTML } 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 taskList node`, () => {
8
- it('serializes to <div> with proper data-attributes', () => {
9
- const html = toHTML(
10
- schema.nodes.taskList.create({ localId: 'cheese' }),
11
- schema,
12
- );
13
- expect(html).toContain('<div');
14
- expect(html).toContain('data-task-list-local-id="cheese"');
15
- });
16
-
17
- it('matches <div data-task-list-local-id>', () => {
18
- const doc = fromHTML(
19
- '<div data-node-type="actionList" data-task-list-local-id>',
20
- schema,
21
- );
22
- const taskList = doc.firstChild!;
23
- expect(taskList.type.name).toEqual('taskList');
24
- expect(taskList.attrs.localId).not.toEqual(undefined);
25
- });
26
-
27
- it('taskList requires defining to be true', () => {
28
- expect(schema.nodes.taskList.spec.defining).toBe(true);
29
- });
30
- });
31
-
32
- function makeSchema() {
33
- return createSchema({
34
- nodes: [
35
- 'doc',
36
- 'paragraph',
37
- 'text',
38
- 'taskList',
39
- 'taskItem',
40
- 'orderedList',
41
- 'bulletList',
42
- 'listItem',
43
- ],
44
- });
45
- }
@@ -1,42 +0,0 @@
1
- import { fromHTML, toHTML } from 'adf-test-helpers/src/adf-schema/html-helpers';
2
- import { inlineNodes } from '../../../../schema/inline-nodes';
3
-
4
- import { schema } from 'adf-test-helpers/src/adf-schema';
5
-
6
- const packageName = process.env._PACKAGE_NAME_ as string;
7
-
8
- describe(`${packageName}/schema unknownBlock node`, () => {
9
- describe('should be able to parse inline node', () => {
10
- inlineNodes.forEach((node) => {
11
- /**
12
- * It's not going to work for extension since we made extension attrs parsing more strict.
13
- * Having an empty `data-extension-type` or `data-extension-key` won't be parsed as valid extension anymore.
14
- */
15
- if (node === 'image' || node === 'inlineExtension') {
16
- return;
17
- }
18
- it(node, () => {
19
- let element;
20
-
21
- // schema.nodes.text.create() is not valid
22
- // https://discuss.prosemirror.net/t/how-i-can-create-text-node-types/759
23
- if ('text' === node) {
24
- element = toHTML(schema.text('foo'), schema);
25
- } else {
26
- element = toHTML(schema.nodes[node].create(), schema);
27
- }
28
-
29
- const doc = fromHTML(
30
- `<div data-node-type="unknownBlock">${element}</div>`,
31
- schema,
32
- );
33
- const span = doc.firstChild!;
34
- const elementNode = span.firstChild!;
35
-
36
- expect(elementNode).toBeDefined();
37
- expect(elementNode).toHaveProperty('type');
38
- expect(elementNode.type).toEqual(schema.nodes[node]);
39
- });
40
- });
41
- });
42
- });