@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,46 +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 decisionItem node`, () => {
8
- it('serializes to <li> with proper data-attributes', () => {
9
- const html = toHTML(schema.nodes.decisionItem.create(), schema);
10
- expect(html).toContain('<li');
11
- expect(html).toContain('data-decision-local-id');
12
- expect(html).toContain('data-decision-state');
13
- });
14
-
15
- it('matches <li data-decision-local-id>', () => {
16
- const doc = fromHTML('<li data-decision-local-id>', schema);
17
- const decisionItem = doc.firstChild!.firstChild!;
18
- expect(decisionItem.type.name).toEqual('decisionItem');
19
- });
20
-
21
- it('does not match <li>', () => {
22
- const doc = fromHTML('<li>', schema);
23
- const listItem = doc.firstChild!.firstChild!;
24
- expect(listItem.type.name).toEqual('listItem');
25
- });
26
-
27
- it('decisionItem requires defining to be true', () => {
28
- expect(schema.nodes.decisionItem.spec.defining).toBe(true);
29
- });
30
- });
31
-
32
- function makeSchema() {
33
- return createSchema({
34
- nodes: [
35
- 'doc',
36
- 'paragraph',
37
- 'heading',
38
- 'text',
39
- 'decisionList',
40
- 'decisionItem',
41
- 'orderedList',
42
- 'bulletList',
43
- 'listItem',
44
- ],
45
- });
46
- }
@@ -1,52 +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 decisionList node`, () => {
8
- it('serializes to <ol> with proper data-attributes', () => {
9
- const html = toHTML(
10
- schema.nodes.decisionList.create({ localId: 'cheese' }),
11
- schema,
12
- );
13
- expect(html).toContain('<ol');
14
- expect(html).toContain('data-decision-list-local-id="cheese"');
15
- });
16
-
17
- it('matches <ol data-decision-list-local-id>', () => {
18
- const doc = fromHTML(
19
- '<ol data-node-type="decisionList" data-decision-list-local-id>',
20
- schema,
21
- );
22
- const decisionList = doc.firstChild!;
23
- expect(decisionList.type.name).toEqual('decisionList');
24
- expect(decisionList.attrs.localId).not.toEqual(undefined);
25
- });
26
-
27
- it('does not match <ol>', () => {
28
- const doc = fromHTML('<ol>', schema);
29
- const orderedList = doc.firstChild!;
30
- expect(orderedList.type.name).toEqual('orderedList');
31
- });
32
-
33
- it('decisionList requires defining to be true', () => {
34
- expect(schema.nodes.decisionList.spec.defining).toBe(true);
35
- });
36
- });
37
-
38
- function makeSchema() {
39
- return createSchema({
40
- nodes: [
41
- 'doc',
42
- 'paragraph',
43
- 'heading',
44
- 'text',
45
- 'decisionList',
46
- 'decisionItem',
47
- 'orderedList',
48
- 'bulletList',
49
- 'listItem',
50
- ],
51
- });
52
- }
@@ -1,60 +0,0 @@
1
- import { toDOM, fromHTML } from 'adf-test-helpers/src/adf-schema/html-helpers';
2
- import { createSchema } from '../../../../schema/create-schema';
3
- import { embedCard } from '../../../../schema/nodes/embed-card';
4
-
5
- const packageName = process.env._PACKAGE_NAME_ as string;
6
-
7
- describe(`${packageName}/schema embedCard node`, () => {
8
- const schema = createSchema({
9
- nodes: ['doc', 'paragraph', 'embedCard', 'text'],
10
- });
11
-
12
- const url = 'https://product-fabric.atlassian.net/browse/ED-1';
13
-
14
- describe('embedCard with "url" attribute', () => {
15
- describe('parse html', () => {
16
- it('converts to embedCard PM node', () => {
17
- const doc = fromHTML(
18
- `<meta charset='utf-8'><div data-embed-card="" data-card-url="https://product-fabric.atlassian.net/browse/ED-1" data-layout="center"></div>`,
19
- schema,
20
- );
21
- const node = doc.firstChild!;
22
- expect(node.type.spec).toEqual(embedCard);
23
- });
24
-
25
- it('gets attributes from html', () => {
26
- const doc = fromHTML(
27
- `<meta charset='utf-8'><div data-embed-card="" data-card-url="https://product-fabric.atlassian.net/browse/ED-1" data-layout="center"></div>`,
28
- schema,
29
- );
30
-
31
- const node = doc.firstChild!;
32
- expect(node.attrs.url).toEqual(url);
33
- });
34
- });
35
-
36
- describe('encode html', () => {
37
- it('converts html data attributes to node attributes', () => {
38
- const dom = toDOM(
39
- schema.nodes.embedCard.create({ url, layout: 'center', width: 50 }),
40
- schema,
41
- ).firstChild as HTMLElement;
42
-
43
- expect(dom.getAttribute('data-card-url')).toEqual(url);
44
- expect(dom.getAttribute('data-layout')).toEqual('center');
45
- expect(dom.getAttribute('data-width')).toEqual('50');
46
- });
47
-
48
- it('encodes and decodes to the same node', () => {
49
- const node = schema.nodes.embedCard.create({
50
- url,
51
- layout: 'center',
52
- width: 50,
53
- });
54
- const dom = toDOM(node, schema).firstChild as HTMLElement;
55
- const parsedNode = fromHTML(dom.outerHTML, schema).firstChild!;
56
- expect(parsedNode).toEqual(node);
57
- });
58
- });
59
- });
60
- });
@@ -1,71 +0,0 @@
1
- import { createSchema } from '../../../../schema/create-schema';
2
- import {
3
- fromHTML as fromHTML_,
4
- toHTML,
5
- } from 'adf-test-helpers/src/adf-schema/html-helpers';
6
-
7
- const schema = makeSchema();
8
- const fromHTML = (html: string) => fromHTML_(html, schema);
9
- const packageName = process.env._PACKAGE_NAME_ as string;
10
-
11
- describe(`${packageName}/schema underline emoji node`, () => {
12
- it('should have all emoji node props when serializing to DOM', () => {
13
- const html = toHTML(
14
- schema.nodes.emoji.create({ shortName: 'abc', id: '123', text: 'xyz' }),
15
- schema,
16
- );
17
- expect(html).toContain('data-emoji-short-name="abc"');
18
- expect(html).toContain('data-emoji-id="123"');
19
- expect(html).toContain('data-emoji-text="xyz"');
20
- expect(html).toContain('contenteditable="false"');
21
- });
22
-
23
- it('should extract the correct values of emoji id', () => {
24
- const doc = fromHTML(
25
- '<span data-emoji-short-name="abc" data-emoji-id="123" data-emoji-text="xyz"></span>',
26
- );
27
- const emoji = doc.firstChild!.firstChild!;
28
-
29
- expect(emoji.type.name).toEqual('emoji');
30
- expect(emoji.attrs.shortName).toEqual('abc');
31
- expect(emoji.attrs.id).toEqual('123');
32
- expect(emoji.attrs.text).toEqual('xyz');
33
- });
34
-
35
- it('should have minimal emoji id props when serializing to DOM (minimal representation)', () => {
36
- const html = toHTML(
37
- schema.nodes.emoji.create({ shortName: 'abc' }),
38
- schema,
39
- );
40
- expect(html).toContain('data-emoji-short-name="abc"');
41
- expect(html).toContain('contenteditable="false"');
42
- });
43
-
44
- it('should extract the correct values of emoji (minimal representation)', () => {
45
- const doc = fromHTML("<span data-emoji-short-name='abc'></span>");
46
- const emoji = doc.firstChild!.firstChild!;
47
-
48
- expect(emoji.type.name).toEqual('emoji');
49
- expect(emoji.attrs.shortName).toEqual('abc');
50
- expect(emoji.attrs.id).toEqual('');
51
- expect(emoji.attrs.text).toEqual('');
52
- });
53
-
54
- it('should extract the correct values of emoji from bitbucket (minimal representation)', () => {
55
- const doc = fromHTML(
56
- '<img class="emoji" data-emoji-short-name="abc" data-emoji-id="123" data-emoji-text="xyz"></img>',
57
- );
58
- const emoji = doc.firstChild!.firstChild!;
59
-
60
- expect(emoji.type.name).toEqual('emoji');
61
- expect(emoji.attrs.shortName).toEqual('abc');
62
- expect(emoji.attrs.id).toEqual('123');
63
- expect(emoji.attrs.text).toEqual('xyz');
64
- });
65
- });
66
-
67
- function makeSchema() {
68
- return createSchema({
69
- nodes: ['doc', 'paragraph', 'text', 'emoji'],
70
- });
71
- }
@@ -1,51 +0,0 @@
1
- import { toDOM, fromHTML } from 'adf-test-helpers/src/adf-schema/html-helpers';
2
- import { expand } from '../../../..';
3
- import { schema } from 'adf-test-helpers/src/adf-schema';
4
- const packageName = process.env._PACKAGE_NAME_ as string;
5
-
6
- describe(`${packageName}/schema expand node`, () => {
7
- describe('parse html', () => {
8
- it('converts to PM node', () => {
9
- const doc = fromHTML('<div data-node-type="expand" />', schema);
10
- const node = doc.firstChild!;
11
- expect(node.type.spec).toEqual(expand);
12
- });
13
-
14
- it('gets attributes from html', () => {
15
- const title = 'Homer Simpson';
16
- const doc = fromHTML(
17
- `
18
- <div
19
- data-node-type="expand"
20
- data-title="${title}"
21
- ><p>hello</p></div>
22
- `,
23
- schema,
24
- );
25
-
26
- const node = doc.firstChild!;
27
- expect(node.attrs.title).toEqual(title);
28
- });
29
- });
30
-
31
- describe('encode html', () => {
32
- it('converts html data attributes to node attributes', () => {
33
- const title = 'Homer Simpson';
34
- const content = schema.nodes.paragraph.create(schema.text('hello'));
35
- const node = schema.nodes.expand.create({ title }, content);
36
- const dom = toDOM(node, schema).firstChild as HTMLElement;
37
-
38
- expect(dom.getAttribute('data-node-type')).toEqual('expand');
39
- expect(dom.getAttribute('data-title')).toEqual(title);
40
- });
41
-
42
- it('encodes and decodes to the same node', () => {
43
- const title = 'Homer Simpson';
44
- const content = schema.nodes.paragraph.create(schema.text('hello'));
45
- const node = schema.nodes.expand.create({ title }, content);
46
- const dom = toDOM(node, schema).firstChild as HTMLElement;
47
- const parsedNode = fromHTML(dom.outerHTML, schema).firstChild!;
48
- expect(parsedNode).toEqual(node);
49
- });
50
- });
51
- });
@@ -1,101 +0,0 @@
1
- import { createSchema } from '../../../../schema/create-schema';
2
- import { toDOM, fromHTML } from 'adf-test-helpers/src/adf-schema/html-helpers';
3
- import { extension } from '../../../..';
4
- import { dataConsumer } from '../../../..';
5
- import { Schema } from '@atlaskit/editor-prosemirror/model';
6
-
7
- const packageName = process.env._PACKAGE_NAME_ as string;
8
-
9
- describe(`${packageName}/schema extension node`, () => {
10
- let schema: Schema;
11
- beforeEach(() => {
12
- schema = makeSchema();
13
- });
14
- describe('parse html', () => {
15
- it('parses a dataConsumer mark correctly', () => {
16
- const extensionHtml =
17
- '<div data-node-type="extension" data-extension-type="com.example.ext" data-extension-key="gallery" />';
18
- const withDataConsumerMark = `<span data-mark-type="dataConsumer" data-sources="[&quot;someid&quot;]">${extensionHtml}</span>`;
19
- const doc = fromHTML(withDataConsumerMark, schema);
20
- const extensionNode = doc.firstChild!;
21
- const dataConsumerMark = doc.firstChild!.marks[0];
22
- expect(dataConsumerMark.type.spec).toEqual(dataConsumer);
23
- expect(extensionNode.type.spec).toEqual(extension);
24
- });
25
-
26
- it('converts to extension PM node', () => {
27
- const doc = fromHTML(
28
- '<div data-node-type="extension" data-extension-type="com.example.ext" data-extension-key="gallery" />',
29
- schema,
30
- );
31
- const node = doc.firstChild!;
32
- expect(node.type.spec).toEqual(extension);
33
- });
34
-
35
- it('gets attributes from html', () => {
36
- const extensionType = 'com.atlassian.confluence.macro.core';
37
- const extensionKey = 'gallery';
38
- const parameters = { macroparams: { width: '100px' } };
39
-
40
- const doc = fromHTML(
41
- `
42
- <div
43
- data-node-type="extension"
44
- data-extension-type="${extensionType}"
45
- data-extension-key="${extensionKey}"
46
- data-parameters='${JSON.stringify(parameters)}'
47
- />
48
- `,
49
- schema,
50
- );
51
-
52
- const node = doc.firstChild!;
53
- expect(node.attrs.extensionType).toEqual(extensionType);
54
- expect(node.attrs.extensionKey).toEqual(extensionKey);
55
- expect(node.attrs.parameters).toEqual(parameters);
56
- });
57
- });
58
-
59
- describe('encode html', () => {
60
- it('converts html data attributes to node attributes', () => {
61
- const attrs = {
62
- extensionType: 'com.atlassian.confluence.macro.core',
63
- extensionKey: 'gallery',
64
- parameters: { macroparams: { width: '100px' } },
65
- };
66
- // extension node can contain no content
67
- const node = schema.nodes.extension.create(attrs);
68
- const dom = toDOM(node, schema).firstChild as HTMLElement;
69
-
70
- expect(dom.getAttribute('data-node-type')).toEqual('extension');
71
- expect(dom.getAttribute('data-extension-type')).toEqual(
72
- attrs.extensionType,
73
- );
74
- expect(dom.getAttribute('data-extension-key')).toEqual(
75
- attrs.extensionKey,
76
- );
77
- expect(dom.getAttribute('data-parameters')).toEqual(
78
- JSON.stringify(attrs.parameters),
79
- );
80
- });
81
-
82
- it('encodes and decodes to the same node', () => {
83
- const attrs = {
84
- extensionType: 'com.atlassian.confluence.macro.core',
85
- extensionKey: 'gallery',
86
- parameters: { macroparams: { width: '100px' } },
87
- };
88
- const node = schema.nodes.extension.create(attrs);
89
- const dom = toDOM(node, schema).firstChild as HTMLElement;
90
- const parsedNode = fromHTML(dom.outerHTML, schema).firstChild!;
91
- expect(parsedNode).toEqual(node);
92
- });
93
- });
94
- });
95
-
96
- function makeSchema() {
97
- return createSchema({
98
- nodes: ['doc', 'paragraph', 'text', 'extension'],
99
- marks: ['dataConsumer'],
100
- });
101
- }
@@ -1,24 +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 hardBreak node`, () => {
8
- it('serializes to <br>', () => {
9
- const html = toHTML(schema.nodes.hardBreak.create(), schema);
10
- expect(html).toContain('<br>');
11
- });
12
-
13
- it('matches <br>', () => {
14
- const doc = fromHTML('<br>', schema);
15
- const br = doc.firstChild!.firstChild!;
16
- expect(br.type.name).toEqual('hardBreak');
17
- });
18
- });
19
-
20
- function makeSchema() {
21
- return createSchema({
22
- nodes: ['doc', 'paragraph', 'text', 'hardBreak'],
23
- });
24
- }
@@ -1,56 +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
- strong,
5
- doc as editorDoc,
6
- h1,
7
- a as link,
8
- em,
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 heading node`, () => {
15
- it('serializes to <h4>', () => {
16
- const html = toHTML(schema.nodes.heading.create({ level: 4 }), schema);
17
- expect(html).toContain('<h4>');
18
- });
19
-
20
- it('matches <h3>', () => {
21
- const doc = fromHTML('<h3>', schema);
22
- const h3 = doc.firstChild!;
23
- expect(h3.type.name).toEqual('heading');
24
- });
25
-
26
- it('can have inline strong', () => {
27
- const doc = fromHTML('<h1><b>hello</b></h1>', schema);
28
- expect(doc.toJSON()).toEqual(
29
- editorDoc(h1(strong('hello')))(schema).toJSON(),
30
- );
31
- });
32
-
33
- it('can have inline italic', () => {
34
- const doc = fromHTML('<h1><em>hello</em></h1>', schema);
35
- expect(doc.toJSON()).toEqual(editorDoc(h1(em('hello')))(schema).toJSON());
36
- });
37
-
38
- it('can have inline links', () => {
39
- const doc = fromHTML(
40
- '<h1><a href="http://www.atlassian.com" rel="nofollow" title="@abodera" class="mention mention-me">hello</a></h1>',
41
- schema,
42
- );
43
- expect(doc.toJSON()).toEqual(
44
- editorDoc(h1(link({ href: 'http://www.atlassian.com' })('hello')))(
45
- schema,
46
- ).toJSON(),
47
- );
48
- });
49
- });
50
-
51
- function makeSchema() {
52
- return createSchema({
53
- nodes: ['doc', 'paragraph', 'text', 'heading'],
54
- marks: ['strong', 'em', 'link'],
55
- });
56
- }
@@ -1,32 +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 src = 'http://test.com';
6
- const srcDataURI = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAY)';
7
- const packageName = process.env._PACKAGE_NAME_ as string;
8
-
9
- describe(`${packageName}/schema image node`, () => {
10
- it('serializes to <img>', () => {
11
- const html = toHTML(schema.nodes.image.create({ src }), schema);
12
- expect(html).toContain(`<img src="${src}" alt="">`);
13
- });
14
-
15
- it('matches <img src="...">', () => {
16
- const doc = fromHTML(`<img src="${src}" />`, schema);
17
- const img = doc.firstChild!.firstChild!;
18
- expect(img.type.name).toEqual('image');
19
- });
20
-
21
- it('does not match <img src="data:image/...">', () => {
22
- const doc = fromHTML(`<img src="${srcDataURI}" />`, schema);
23
- const img = doc.firstChild!.firstChild!;
24
- expect(img).toBeNull();
25
- });
26
- });
27
-
28
- function makeSchema() {
29
- return createSchema({
30
- nodes: ['doc', 'paragraph', 'text', 'image'],
31
- });
32
- }
@@ -1,106 +0,0 @@
1
- import { toDOM, fromHTML } from 'adf-test-helpers/src/adf-schema/html-helpers';
2
- import { createSchema } from '../../../../schema/create-schema';
3
- import { inlineCard } from '../../../../schema/nodes/inline-card';
4
-
5
- const packageName = process.env._PACKAGE_NAME_ as string;
6
-
7
- describe(`${packageName}/schema inlineCard node`, () => {
8
- const schema = createSchema({
9
- nodes: ['doc', 'paragraph', 'inlineCard', 'text'],
10
- });
11
-
12
- const url = 'https://product-fabric.atlassian.net/browse/ED-1';
13
- const data = {
14
- '@type': 'Document',
15
- generator: {
16
- '@type': 'Application',
17
- name: 'Confluence',
18
- },
19
- url: 'https://extranet.atlassian.com/pages/viewpage.action?pageId=3088533424',
20
- name: 'Founder Update 76: Hello, Trello!',
21
- summary:
22
- 'Today is a big day for Atlassian – we have entered into an agreement to buy Trello. (boom)',
23
- };
24
-
25
- describe('inlineCard with "url" attribute', () => {
26
- describe('parse html', () => {
27
- it('converts to inlineCard PM node', () => {
28
- const doc = fromHTML(`<a data-inline-card href="${url}" />`, schema);
29
- const node = doc.firstChild!.firstChild!;
30
- expect(node.type.spec).toEqual(inlineCard);
31
- });
32
-
33
- it('gets attributes from html', () => {
34
- const doc = fromHTML(`<a data-inline-card href="${url}" />`, schema);
35
-
36
- const node = doc.firstChild!.firstChild!;
37
- expect(node.attrs.url).toEqual(url);
38
- expect(node.attrs.data).toEqual(null);
39
- });
40
- });
41
-
42
- describe('encode html', () => {
43
- it('converts html data attributes to node attributes', () => {
44
- const dom = toDOM(schema.nodes.inlineCard.create({ url }), schema)
45
- .firstChild as HTMLElement;
46
-
47
- expect(dom.getAttribute('href')).toEqual(url);
48
- });
49
-
50
- it('encodes and decodes to the same node', () => {
51
- const node = schema.nodes.inlineCard.create({ url });
52
- const dom = toDOM(node, schema).firstChild as HTMLElement;
53
- const parsedNode = fromHTML(dom.outerHTML, schema).firstChild!
54
- .firstChild!;
55
- expect(parsedNode).toEqual(node);
56
- });
57
- });
58
- });
59
-
60
- describe('inlineCard with "data" attribute', () => {
61
- describe('parse html', () => {
62
- it('converts to inlineCard PM node', () => {
63
- const doc = fromHTML(
64
- `<a data-inline-card href="" data-card-data='${JSON.stringify(
65
- data,
66
- )}' />`,
67
- schema,
68
- );
69
- const node = doc.firstChild!.firstChild!;
70
- expect(node.type.spec).toEqual(inlineCard);
71
- });
72
-
73
- it('gets attributes from html', () => {
74
- const doc = fromHTML(
75
- `<a data-inline-card href="" data-card-data='${JSON.stringify(
76
- data,
77
- )}' />`,
78
- schema,
79
- );
80
-
81
- const node = doc.firstChild!.firstChild!;
82
- expect(node.attrs.data).toEqual(data);
83
- });
84
- });
85
-
86
- describe('encode html', () => {
87
- it('converts html data attributes to node attributes', () => {
88
- const dom = toDOM(schema.nodes.inlineCard.create({ data }), schema)
89
- .firstChild as HTMLElement;
90
-
91
- expect(dom.getAttribute('href')).toEqual('');
92
- expect(dom.getAttribute('data-card-data')).toEqual(
93
- JSON.stringify(data),
94
- );
95
- });
96
-
97
- it('encodes and decodes to the same node', () => {
98
- const node = schema.nodes.inlineCard.create({ url });
99
- const dom = toDOM(node, schema).firstChild as HTMLElement;
100
- const parsedNode = fromHTML(dom.outerHTML, schema).firstChild!
101
- .firstChild!;
102
- expect(parsedNode).toEqual(node);
103
- });
104
- });
105
- });
106
- });
@@ -1,79 +0,0 @@
1
- import { toDOM, fromHTML } from 'adf-test-helpers/src/adf-schema/html-helpers';
2
- import { inlineExtension } 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 inlineExtension node`, () => {
8
- describe('parse html', () => {
9
- it('converts to inlineExtension PM node', () => {
10
- const doc = fromHTML(
11
- '<span data-extension-type="com.atlassian.confluence.macro" data-extension-key="status" />',
12
- schema,
13
- );
14
- const node = doc.firstChild!.firstChild!;
15
- expect(node.type.spec).toEqual(inlineExtension);
16
- });
17
-
18
- it('gets attributes from html', () => {
19
- const extensionType = 'com.atlassian.confluence.macro';
20
- const extensionKey = 'status';
21
- const parameters = { color: 'yellow', text: 'In progress' };
22
-
23
- const doc = fromHTML(
24
- `
25
- <span
26
- data-extension-type="${extensionType}"
27
- data-extension-key="${extensionKey}"
28
- data-parameters='${JSON.stringify(parameters)}'
29
- />
30
- `,
31
- schema,
32
- );
33
-
34
- const node = doc.firstChild!.firstChild!;
35
- expect(node.attrs.extensionType).toEqual(extensionType);
36
- expect(node.attrs.extensionKey).toEqual(extensionKey);
37
- expect(node.attrs.parameters).toEqual(parameters);
38
- });
39
- });
40
-
41
- describe('encode html', () => {
42
- it('converts html data attributes to node attributes', () => {
43
- const attrs = {
44
- extensionType: 'com.atlassian.confluence.macro',
45
- extensionKey: 'status',
46
- parameters: {
47
- macroparams: { color: 'green', text: 'Decided' },
48
- },
49
- };
50
- const dom = toDOM(schema.nodes.inlineExtension.create(attrs), schema)
51
- .firstChild as HTMLElement;
52
-
53
- expect(dom.getAttribute('data-extension-type')).toEqual(
54
- attrs.extensionType,
55
- );
56
- expect(dom.getAttribute('data-extension-key')).toEqual(
57
- attrs.extensionKey,
58
- );
59
- expect(dom.getAttribute('data-parameters')).toEqual(
60
- JSON.stringify(attrs.parameters),
61
- );
62
- });
63
-
64
- it('encodes and decodes to the same node', () => {
65
- const attrs = {
66
- extensionType: 'com.atlassian.confluence.macro',
67
- extensionKey: 'status',
68
- parameters: {
69
- macroparams: { color: 'red', text: 'At risk' },
70
- },
71
- };
72
- const node = schema.nodes.inlineExtension.create(attrs);
73
- const dom = toDOM(node, schema).firstChild as HTMLElement;
74
- const parsedNode = fromHTML(dom.outerHTML, schema).firstChild!
75
- .firstChild!;
76
- expect(parsedNode).toEqual(node);
77
- });
78
- });
79
- });