@atlaskit/adf-schema 28.1.12 → 28.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/__tests__/unit/json-schema/v1.ts +0 -55
- package/src/__tests__/unit/schema/create-schema.ts +0 -214
- package/src/__tests__/unit/schema/default-schema.ts +0 -192
- package/src/__tests__/unit/schema/marks/annotation.ts +0 -46
- package/src/__tests__/unit/schema/marks/border.ts +0 -76
- package/src/__tests__/unit/schema/marks/breakout.ts +0 -24
- package/src/__tests__/unit/schema/marks/code.ts +0 -44
- package/src/__tests__/unit/schema/marks/confluence-inline-comment.ts +0 -25
- package/src/__tests__/unit/schema/marks/data-consumer.ts +0 -52
- package/src/__tests__/unit/schema/marks/em.ts +0 -37
- package/src/__tests__/unit/schema/marks/link.ts +0 -188
- package/src/__tests__/unit/schema/marks/strike.ts +0 -37
- package/src/__tests__/unit/schema/marks/strong.ts +0 -43
- package/src/__tests__/unit/schema/marks/subsup.ts +0 -50
- package/src/__tests__/unit/schema/marks/text-color.ts +0 -61
- package/src/__tests__/unit/schema/marks/underline.ts +0 -36
- package/src/__tests__/unit/schema/nodes/_consts.ts +0 -964
- package/src/__tests__/unit/schema/nodes/block-card.ts +0 -184
- package/src/__tests__/unit/schema/nodes/blockquote.ts +0 -44
- package/src/__tests__/unit/schema/nodes/bodied-extension.ts +0 -101
- package/src/__tests__/unit/schema/nodes/code-block.ts +0 -221
- package/src/__tests__/unit/schema/nodes/confluence-unsupported-block.ts +0 -32
- package/src/__tests__/unit/schema/nodes/confluence-unsupported-inline.ts +0 -35
- package/src/__tests__/unit/schema/nodes/date.ts +0 -51
- package/src/__tests__/unit/schema/nodes/decision-item.ts +0 -46
- package/src/__tests__/unit/schema/nodes/decision-list.ts +0 -52
- package/src/__tests__/unit/schema/nodes/embed-card.ts +0 -60
- package/src/__tests__/unit/schema/nodes/emoji.ts +0 -71
- package/src/__tests__/unit/schema/nodes/expand.ts +0 -51
- package/src/__tests__/unit/schema/nodes/extension.ts +0 -101
- package/src/__tests__/unit/schema/nodes/hard-break.ts +0 -24
- package/src/__tests__/unit/schema/nodes/heading.ts +0 -56
- package/src/__tests__/unit/schema/nodes/image.ts +0 -32
- package/src/__tests__/unit/schema/nodes/inline-card.ts +0 -106
- package/src/__tests__/unit/schema/nodes/inline-extension.ts +0 -79
- package/src/__tests__/unit/schema/nodes/layout-column.ts +0 -54
- package/src/__tests__/unit/schema/nodes/layout-section.ts +0 -95
- package/src/__tests__/unit/schema/nodes/list-item.ts +0 -49
- package/src/__tests__/unit/schema/nodes/media-group.ts +0 -67
- package/src/__tests__/unit/schema/nodes/media-single.ts +0 -171
- package/src/__tests__/unit/schema/nodes/media.ts +0 -384
- package/src/__tests__/unit/schema/nodes/mention.ts +0 -115
- package/src/__tests__/unit/schema/nodes/nestedExpand.ts +0 -72
- package/src/__tests__/unit/schema/nodes/ordered-list.ts +0 -49
- package/src/__tests__/unit/schema/nodes/panel.ts +0 -180
- package/src/__tests__/unit/schema/nodes/paragraph.ts +0 -25
- package/src/__tests__/unit/schema/nodes/placeholder.ts +0 -46
- package/src/__tests__/unit/schema/nodes/rule.ts +0 -24
- package/src/__tests__/unit/schema/nodes/status.ts +0 -120
- package/src/__tests__/unit/schema/nodes/tableNodes.ts +0 -555
- package/src/__tests__/unit/schema/nodes/task-item.ts +0 -39
- package/src/__tests__/unit/schema/nodes/task-list.ts +0 -45
- package/src/__tests__/unit/schema/nodes/unknown-block.ts +0 -42
- package/src/__tests__/unit/schema/nodes/unsupported-block.ts +0 -42
- package/src/__tests__/unit/schema/nodes/unsupported-inline.ts +0 -38
- package/src/__tests__/unit/utils/colors.ts +0 -42
- package/src/__tests__/unit/utils/url.ts +0 -209
- package/src/schema/bitbucket-schema.ts +0 -43
- package/src/schema/confluence-schema.ts +0 -76
- package/src/schema/create-schema.ts +0 -337
- package/src/schema/default-schema.ts +0 -180
- package/src/schema/groups.ts +0 -30
- package/src/schema/inline-nodes.ts +0 -9
- package/src/schema/jira-schema.ts +0 -158
- package/src/schema/marks/__tests__/unit/annotation.ts +0 -18
- package/src/schema/marks/alignment.ts +0 -48
- package/src/schema/marks/annotation.ts +0 -107
- package/src/schema/marks/border.ts +0 -74
- package/src/schema/marks/breakout.ts +0 -42
- package/src/schema/marks/code.ts +0 -45
- package/src/schema/marks/confluence-inline-comment.ts +0 -32
- package/src/schema/marks/data-consumer.ts +0 -100
- package/src/schema/marks/em.ts +0 -19
- package/src/schema/marks/fragment.ts +0 -77
- package/src/schema/marks/indentation.ts +0 -47
- package/src/schema/marks/link.ts +0 -139
- package/src/schema/marks/strike.ts +0 -26
- package/src/schema/marks/strong.ts +0 -45
- package/src/schema/marks/subsup.ts +0 -53
- package/src/schema/marks/text-color.ts +0 -172
- package/src/schema/marks/type-ahead-query.ts +0 -22
- package/src/schema/marks/underline.ts +0 -24
- package/src/schema/marks/unsupported-mark.ts +0 -9
- package/src/schema/marks/unsupported-node-attributes.ts +0 -8
- package/src/schema/nodes/block-card.ts +0 -121
- package/src/schema/nodes/blockquote.ts +0 -25
- package/src/schema/nodes/bodied-extension.ts +0 -75
- package/src/schema/nodes/bullet-list.ts +0 -17
- package/src/schema/nodes/caption.ts +0 -51
- package/src/schema/nodes/code-block.ts +0 -176
- package/src/schema/nodes/confluence-jira-issue.ts +0 -43
- package/src/schema/nodes/confluence-unsupported-block.ts +0 -29
- package/src/schema/nodes/confluence-unsupported-inline.ts +0 -30
- package/src/schema/nodes/date.ts +0 -38
- package/src/schema/nodes/decision-item.ts +0 -50
- package/src/schema/nodes/decision-list.ts +0 -56
- package/src/schema/nodes/doc.ts +0 -30
- package/src/schema/nodes/embed-card.ts +0 -62
- package/src/schema/nodes/emoji.ts +0 -89
- package/src/schema/nodes/expand.ts +0 -101
- package/src/schema/nodes/extension.ts +0 -60
- package/src/schema/nodes/hard-break.ts +0 -21
- package/src/schema/nodes/heading.ts +0 -64
- package/src/schema/nodes/image.ts +0 -32
- package/src/schema/nodes/inline-card.ts +0 -70
- package/src/schema/nodes/inline-extension.ts +0 -57
- package/src/schema/nodes/layout-column.ts +0 -68
- package/src/schema/nodes/layout-section.ts +0 -93
- package/src/schema/nodes/list-item.ts +0 -13
- package/src/schema/nodes/media-group.ts +0 -44
- package/src/schema/nodes/media-inline.ts +0 -19
- package/src/schema/nodes/media-single.ts +0 -179
- package/src/schema/nodes/media.ts +0 -253
- package/src/schema/nodes/mention.ts +0 -86
- package/src/schema/nodes/nested-expand.ts +0 -77
- package/src/schema/nodes/ordered-list.ts +0 -62
- package/src/schema/nodes/panel.ts +0 -133
- package/src/schema/nodes/paragraph.ts +0 -79
- package/src/schema/nodes/placeholder.ts +0 -40
- package/src/schema/nodes/rule.ts +0 -17
- package/src/schema/nodes/status.ts +0 -58
- package/src/schema/nodes/tableNodes.ts +0 -478
- package/src/schema/nodes/task-item.ts +0 -51
- package/src/schema/nodes/task-list.ts +0 -61
- package/src/schema/nodes/text.ts +0 -19
- package/src/schema/nodes/types/block-content.ts +0 -51
- package/src/schema/nodes/types/extensions.ts +0 -36
- package/src/schema/nodes/types/inline-content.ts +0 -56
- package/src/schema/nodes/types/list.ts +0 -54
- package/src/schema/nodes/types/mark.ts +0 -16
- package/src/schema/nodes/types/non-nestable-block-content.ts +0 -39
- package/src/schema/nodes/types/rich-media-common.ts +0 -51
- package/src/schema/nodes/unknown-block.ts +0 -13
- package/src/schema/nodes/unsupported-block.ts +0 -28
- package/src/schema/nodes/unsupported-inline.ts +0 -27
- package/src/schema/unsupported.ts +0 -4
- package/src/steps/__tests__/unit/analytics.ts +0 -72
- package/src/steps/__tests__/unit/link-meta-step.ts +0 -64
- package/src/steps/__tests__/unit/override-document-step.ts +0 -174
- package/src/steps/__tests__/unit/set-attrs.ts +0 -71
- package/src/steps/analytics.ts +0 -189
- package/src/steps/link-meta-step.ts +0 -105
- package/src/steps/override-document-step.ts +0 -97
- package/src/steps/set-attrs.tsx +0 -74
- package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-0.json +0 -15
- package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-1.json +0 -15
- package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-2.json +0 -15
- package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-3.json +0 -15
- package/src/steps/table/__tests__/__fixtures__/basic/remove-column-at-0.json +0 -9
- package/src/steps/table/__tests__/__fixtures__/basic/remove-column-at-1.json +0 -9
- package/src/steps/table/__tests__/__fixtures__/basic/remove-column-at-2.json +0 -9
- package/src/steps/table/__tests__/__fixtures__/basic/remove-table/remove-last-row-inverted.json +0 -98
- package/src/steps/table/__tests__/__fixtures__/basic/remove-table/remove-last-row.json +0 -71
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-0-inverted.json +0 -19
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-0.json +0 -19
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-1-inverted.json +0 -21
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-1.json +0 -21
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-2-inverted.json +0 -21
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-2.json +0 -21
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-3-inverted.json +0 -19
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-3.json +0 -19
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-0-inverted.json +0 -63
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-0.json +0 -21
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-1-inverted.json +0 -64
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-1.json +0 -22
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-2-inverted.json +0 -63
- package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-2.json +0 -21
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-0-inverted.json +0 -19
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-0.json +0 -19
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-1-inverted.json +0 -19
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-1.json +0 -19
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-2-inverted.json +0 -19
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-2.json +0 -19
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-3-inverted.json +0 -19
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-3.json +0 -19
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-0-inverted.json +0 -52
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-0.json +0 -38
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-1-inverted.json +0 -52
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-1.json +0 -38
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-2-inverted.json +0 -25
- package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-2.json +0 -11
- package/src/steps/table/__tests__/_utils.ts +0 -102
- package/src/steps/table/__tests__/add-column-merge-columns.ts +0 -509
- package/src/steps/table/__tests__/add-column-merge-rows.ts +0 -466
- package/src/steps/table/__tests__/add-column.ts +0 -638
- package/src/steps/table/add-column.ts +0 -443
- package/src/steps/table/constants.ts +0 -4
- package/src/steps/table/sort-column.ts +0 -57
- package/src/steps/table/types.ts +0 -48
- package/src/steps/table/utils/cell-step.ts +0 -239
- package/src/steps/table/utils/cells-at-column.ts +0 -75
- package/src/steps/table/utils/find-column.ts +0 -90
- package/src/steps/table/utils/get-table-rect-from-doc.ts +0 -37
- package/src/steps/table/utils/side-effects/rows.ts +0 -327
- package/src/steps/table/utils/side-effects/side-effects.ts +0 -90
- package/src/steps/table/utils/side-effects/table.ts +0 -112
- package/src/steps/table/utils/side-effects/types.ts +0 -34
- package/src/steps/table/utils/table-map.ts +0 -28
- package/src/steps/type-ahead.ts +0 -100
- package/src/steps.ts +0 -16
- package/src/utils/colors.ts +0 -171
- package/src/utils/confluence/emoji.ts +0 -99
- package/src/utils/extensions.ts +0 -32
- package/src/utils/parseDOM.ts +0 -2
- package/src/utils/url.ts +0 -173
- package/src/utils/uuid.ts +0 -19
- package/src/version.json +0 -6
@@ -1,184 +0,0 @@
|
|
1
|
-
import { toDOM, fromHTML } from 'adf-test-helpers/src/adf-schema/html-helpers';
|
2
|
-
import { createSchema } from '../../../../schema/create-schema';
|
3
|
-
import { blockCard } from '../../../../schema/nodes/block-card';
|
4
|
-
|
5
|
-
const packageName = process.env._PACKAGE_NAME_ as string;
|
6
|
-
|
7
|
-
describe(`${packageName}/schema blockCard node`, () => {
|
8
|
-
const schema = createSchema({
|
9
|
-
nodes: ['doc', 'paragraph', 'blockCard', '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
|
-
const datasource = {
|
25
|
-
id: 'datasource-id',
|
26
|
-
parameters: { jql: 'EDM=jql', cloudId: 'cloud-id' },
|
27
|
-
views: [
|
28
|
-
{
|
29
|
-
type: 'table',
|
30
|
-
properties: { columns: [{ key: 'col1' }, { key: 'col2' }] },
|
31
|
-
},
|
32
|
-
],
|
33
|
-
};
|
34
|
-
|
35
|
-
describe('blockCard with "url" attribute', () => {
|
36
|
-
describe('parse html', () => {
|
37
|
-
it('converts to blockCard PM node', () => {
|
38
|
-
const doc = fromHTML(`<a data-block-card href="${url}" />`, schema);
|
39
|
-
const node = doc.firstChild!;
|
40
|
-
expect(node.type.spec).toEqual(blockCard);
|
41
|
-
});
|
42
|
-
|
43
|
-
it('gets attributes from html', () => {
|
44
|
-
const doc = fromHTML(`<a data-block-card href="${url}" />`, schema);
|
45
|
-
|
46
|
-
const node = doc.firstChild!;
|
47
|
-
expect(node.attrs.url).toEqual(url);
|
48
|
-
expect(node.attrs.data).toEqual(null);
|
49
|
-
});
|
50
|
-
});
|
51
|
-
|
52
|
-
describe('encode html', () => {
|
53
|
-
it('converts html data attributes to node attributes', () => {
|
54
|
-
const dom = toDOM(schema.nodes.blockCard.create({ url }), schema)
|
55
|
-
.firstChild as HTMLElement;
|
56
|
-
|
57
|
-
expect(dom.getAttribute('href')).toEqual(url);
|
58
|
-
expect(dom.getAttribute('data-card-data')).toEqual('');
|
59
|
-
});
|
60
|
-
|
61
|
-
it('encodes and decodes to the same node', () => {
|
62
|
-
const node = schema.nodes.blockCard.create({ url });
|
63
|
-
const dom = toDOM(node, schema).firstChild as HTMLElement;
|
64
|
-
const parsedNode = fromHTML(dom.outerHTML, schema).firstChild!;
|
65
|
-
expect(parsedNode).toEqual(node);
|
66
|
-
});
|
67
|
-
});
|
68
|
-
});
|
69
|
-
|
70
|
-
describe('blockCard with "data" attribute', () => {
|
71
|
-
describe('parse html', () => {
|
72
|
-
it('converts to blockCard PM node', () => {
|
73
|
-
const doc = fromHTML(
|
74
|
-
`<a data-block-card href="" data-card-data='${JSON.stringify(
|
75
|
-
data,
|
76
|
-
)}' />`,
|
77
|
-
schema,
|
78
|
-
);
|
79
|
-
const node = doc.firstChild!;
|
80
|
-
expect(node.type.spec).toEqual(blockCard);
|
81
|
-
});
|
82
|
-
|
83
|
-
it('gets attributes from html', () => {
|
84
|
-
const doc = fromHTML(
|
85
|
-
`<a data-block-card href="" data-card-data='${JSON.stringify(
|
86
|
-
data,
|
87
|
-
)}' />`,
|
88
|
-
schema,
|
89
|
-
);
|
90
|
-
|
91
|
-
const node = doc.firstChild!;
|
92
|
-
expect(node.attrs.data).toEqual(data);
|
93
|
-
});
|
94
|
-
});
|
95
|
-
|
96
|
-
describe('encode html', () => {
|
97
|
-
it('converts html data attributes to node attributes', () => {
|
98
|
-
const dom = toDOM(schema.nodes.blockCard.create({ data }), schema)
|
99
|
-
.firstChild as HTMLElement;
|
100
|
-
|
101
|
-
expect(dom.getAttribute('href')).toEqual('');
|
102
|
-
expect(dom.getAttribute('data-card-data')).toEqual(
|
103
|
-
JSON.stringify(data),
|
104
|
-
);
|
105
|
-
});
|
106
|
-
|
107
|
-
it('encodes and decodes to the same node', () => {
|
108
|
-
const node = schema.nodes.blockCard.create({ data });
|
109
|
-
const dom = toDOM(node, schema).firstChild as HTMLElement;
|
110
|
-
const parsedNode = fromHTML(dom.outerHTML, schema).firstChild!;
|
111
|
-
expect(parsedNode).toEqual(node);
|
112
|
-
});
|
113
|
-
});
|
114
|
-
});
|
115
|
-
|
116
|
-
describe('blockCard with "datasource" attribute', () => {
|
117
|
-
describe('parse html', () => {
|
118
|
-
it('converts to blockCard PM node', () => {
|
119
|
-
const doc = fromHTML(
|
120
|
-
`<a data-block-card href="" data-datasource='${JSON.stringify(
|
121
|
-
datasource,
|
122
|
-
)}' />`,
|
123
|
-
schema,
|
124
|
-
);
|
125
|
-
const node = doc.firstChild!;
|
126
|
-
expect(node.type.spec).toEqual(blockCard);
|
127
|
-
});
|
128
|
-
|
129
|
-
it('gets attributes from html', () => {
|
130
|
-
const doc = fromHTML(
|
131
|
-
`<a data-block-card href="" data-datasource='${JSON.stringify(
|
132
|
-
datasource,
|
133
|
-
)}' />`,
|
134
|
-
schema,
|
135
|
-
);
|
136
|
-
|
137
|
-
const node = doc.firstChild!;
|
138
|
-
expect(node.attrs.datasource).toEqual(datasource);
|
139
|
-
});
|
140
|
-
|
141
|
-
it('get attributes from html when layout is not set', () => {
|
142
|
-
const doc = fromHTML(
|
143
|
-
`<a
|
144
|
-
data-block-card
|
145
|
-
href=""
|
146
|
-
data-datasource='${JSON.stringify(datasource)}' />`,
|
147
|
-
schema,
|
148
|
-
);
|
149
|
-
|
150
|
-
const node = doc.firstChild!;
|
151
|
-
expect(node.attrs.layout).toEqual('center');
|
152
|
-
});
|
153
|
-
});
|
154
|
-
|
155
|
-
describe('encode html', () => {
|
156
|
-
it('converts html datasource attributes to node attributes', () => {
|
157
|
-
const dom = toDOM(schema.nodes.blockCard.create({ datasource }), schema)
|
158
|
-
.firstChild as HTMLElement;
|
159
|
-
|
160
|
-
expect(dom.getAttribute('href')).toEqual('');
|
161
|
-
expect(dom.getAttribute('data-datasource')).toEqual(
|
162
|
-
JSON.stringify(datasource),
|
163
|
-
);
|
164
|
-
});
|
165
|
-
|
166
|
-
it('encodes and decodes to the same node', () => {
|
167
|
-
const node = schema.nodes.blockCard.create({ datasource });
|
168
|
-
const dom = toDOM(node, schema).firstChild as HTMLElement;
|
169
|
-
|
170
|
-
const parsedNode = fromHTML(dom.outerHTML, schema).firstChild!;
|
171
|
-
|
172
|
-
// Defaults to center
|
173
|
-
expect(node.attrs.layout).toBeNull();
|
174
|
-
expect(parsedNode).toEqual({
|
175
|
-
...node,
|
176
|
-
attrs: {
|
177
|
-
...node.attrs,
|
178
|
-
layout: 'center',
|
179
|
-
},
|
180
|
-
});
|
181
|
-
});
|
182
|
-
});
|
183
|
-
});
|
184
|
-
});
|
@@ -1,44 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
fromHTML,
|
3
|
-
toHTML,
|
4
|
-
schema,
|
5
|
-
doc,
|
6
|
-
p,
|
7
|
-
blockquote,
|
8
|
-
} from 'adf-test-helpers/src/adf-schema';
|
9
|
-
|
10
|
-
const packageName = process.env._PACKAGE_NAME_ as string;
|
11
|
-
|
12
|
-
describe(`${packageName}/schema blockquote node`, () => {
|
13
|
-
it('should be possible to create a blockquote with a paragraph', () => {
|
14
|
-
const html = toHTML(
|
15
|
-
schema.nodes.blockquote.create({}, schema.nodes.paragraph.create()),
|
16
|
-
schema,
|
17
|
-
);
|
18
|
-
expect(html).toEqual('<blockquote><p></p></blockquote>');
|
19
|
-
});
|
20
|
-
|
21
|
-
it('should not be possible to have heading inside blockquote', () => {
|
22
|
-
const docFromHTML = fromHTML(
|
23
|
-
'<blockquote><h2>text</h2></blockquote>',
|
24
|
-
schema,
|
25
|
-
);
|
26
|
-
expect(docFromHTML.toJSON()).toEqual(doc(blockquote(p('text'))).toJSON());
|
27
|
-
});
|
28
|
-
|
29
|
-
it('should be possible to have paragraph inside blockquote', () => {
|
30
|
-
const docFromHTML = fromHTML(
|
31
|
-
'<blockquote><p>text</p></blockquote>',
|
32
|
-
schema,
|
33
|
-
);
|
34
|
-
expect(docFromHTML.toJSON()).toEqual(doc(blockquote(p('text'))).toJSON());
|
35
|
-
});
|
36
|
-
|
37
|
-
it('should not be possible to have list inside blockquote', () => {
|
38
|
-
const docFromHTML = fromHTML(
|
39
|
-
'<blockquote><ol><li>text</li></ol></blockquote>',
|
40
|
-
schema,
|
41
|
-
);
|
42
|
-
expect(docFromHTML.toJSON()).toEqual(doc(blockquote(p('text'))).toJSON());
|
43
|
-
});
|
44
|
-
});
|
@@ -1,101 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
schema,
|
3
|
-
toDOM,
|
4
|
-
fromHTML,
|
5
|
-
toContext,
|
6
|
-
} from 'adf-test-helpers/src/adf-schema';
|
7
|
-
import { bodiedExtension } from '../../../..';
|
8
|
-
import {
|
9
|
-
doc,
|
10
|
-
bodiedExtension as bodiedExt,
|
11
|
-
p,
|
12
|
-
} from 'adf-test-helpers/src/doc-builder';
|
13
|
-
|
14
|
-
const packageName = process.env._PACKAGE_NAME_ as string;
|
15
|
-
|
16
|
-
describe(`${packageName}/schema bodiedExtension node`, () => {
|
17
|
-
describe('parse html', () => {
|
18
|
-
it('converts to extension PM node', () => {
|
19
|
-
const doc = fromHTML(
|
20
|
-
'<div data-node-type="bodied-extension" data-extension-type="com.example.ext" data-extension-key="ext-007" />',
|
21
|
-
schema,
|
22
|
-
);
|
23
|
-
const node = doc.firstChild!;
|
24
|
-
expect(node.type.spec).toEqual(bodiedExtension);
|
25
|
-
});
|
26
|
-
|
27
|
-
it('gets attributes from html', () => {
|
28
|
-
const extensionType = 'com.atlassian.confluence.macro.core';
|
29
|
-
const extensionKey = 'superMacro';
|
30
|
-
const parameters = { macroparams: { super: true } };
|
31
|
-
|
32
|
-
const doc = fromHTML(
|
33
|
-
`
|
34
|
-
<div
|
35
|
-
data-node-type="bodied-extension"
|
36
|
-
data-extension-type="${extensionType}"
|
37
|
-
data-extension-key="${extensionKey}"
|
38
|
-
data-parameters='${JSON.stringify(parameters)}'
|
39
|
-
><p>hello</p></div>
|
40
|
-
`,
|
41
|
-
schema,
|
42
|
-
);
|
43
|
-
|
44
|
-
const node = doc.firstChild!;
|
45
|
-
expect(node.attrs.extensionType).toEqual(extensionType);
|
46
|
-
expect(node.attrs.extensionKey).toEqual(extensionKey);
|
47
|
-
expect(node.attrs.parameters).toEqual(parameters);
|
48
|
-
});
|
49
|
-
|
50
|
-
it('should not parse extension when pasted inside extension', () => {
|
51
|
-
const document = doc(
|
52
|
-
bodiedExt({ extensionKey: '', extensionType: '' })(p('{<>}')),
|
53
|
-
);
|
54
|
-
const context = toContext(document, schema);
|
55
|
-
const pmDoc = fromHTML(
|
56
|
-
'<div data-node-type="bodied-extension" />',
|
57
|
-
schema,
|
58
|
-
{ context },
|
59
|
-
);
|
60
|
-
const node = pmDoc.firstChild!;
|
61
|
-
expect(node.type.name).toEqual('paragraph');
|
62
|
-
});
|
63
|
-
});
|
64
|
-
|
65
|
-
describe('encode html', () => {
|
66
|
-
it('converts html data attributes to node attributes', () => {
|
67
|
-
const attrs = {
|
68
|
-
extensionType: 'com.atlassian.confluence.macro',
|
69
|
-
extensionKey: 'superMacro',
|
70
|
-
parameters: { macroparams: { super: true } },
|
71
|
-
};
|
72
|
-
const content = schema.nodes.paragraph.create(schema.text('hello'));
|
73
|
-
const node = schema.nodes.bodiedExtension.create(attrs, content);
|
74
|
-
const dom = toDOM(node, schema).firstChild as HTMLElement;
|
75
|
-
|
76
|
-
expect(dom.getAttribute('data-node-type')).toEqual('bodied-extension');
|
77
|
-
expect(dom.getAttribute('data-extension-type')).toEqual(
|
78
|
-
attrs.extensionType,
|
79
|
-
);
|
80
|
-
expect(dom.getAttribute('data-extension-key')).toEqual(
|
81
|
-
attrs.extensionKey,
|
82
|
-
);
|
83
|
-
expect(dom.getAttribute('data-parameters')).toEqual(
|
84
|
-
JSON.stringify(attrs.parameters),
|
85
|
-
);
|
86
|
-
});
|
87
|
-
|
88
|
-
it('encodes and decodes to the same node', () => {
|
89
|
-
const attrs = {
|
90
|
-
extensionType: 'com.atlassian.confluence.macro',
|
91
|
-
extensionKey: 'superMacro',
|
92
|
-
parameters: { macroparams: { super: true } },
|
93
|
-
};
|
94
|
-
const content = schema.nodes.paragraph.create(schema.text('hello'));
|
95
|
-
const node = schema.nodes.bodiedExtension.create(attrs, content);
|
96
|
-
const dom = toDOM(node, schema).firstChild as HTMLElement;
|
97
|
-
const parsedNode = fromHTML(dom.outerHTML, schema).firstChild!;
|
98
|
-
expect(parsedNode).toEqual(node);
|
99
|
-
});
|
100
|
-
});
|
101
|
-
});
|
@@ -1,221 +0,0 @@
|
|
1
|
-
import { createSchema } from '../../../../schema/create-schema';
|
2
|
-
import { codeBlock } from '../../../../schema/nodes/code-block';
|
3
|
-
import { fromHTML, toHTML } from 'adf-test-helpers/src/adf-schema/html-helpers';
|
4
|
-
|
5
|
-
const packageName = process.env._PACKAGE_NAME_ as string;
|
6
|
-
|
7
|
-
describe(`${packageName}/schema codeBlock node`, () => {
|
8
|
-
const schema = makeSchema();
|
9
|
-
|
10
|
-
it('should have code property to be true', () => {
|
11
|
-
expect(schema.nodes.codeBlock.spec.code).toEqual(true);
|
12
|
-
});
|
13
|
-
|
14
|
-
describe('parse from html', () => {
|
15
|
-
describe('parse from editor encoded HTML', () => {
|
16
|
-
describe('when language is not set', () => {
|
17
|
-
it('converts to block code node', () => {
|
18
|
-
const doc = fromHTML(
|
19
|
-
'<pre><span>window.alert("hello");<span></pre>',
|
20
|
-
schema,
|
21
|
-
);
|
22
|
-
|
23
|
-
expect(doc.firstChild!.type.name).toEqual('codeBlock');
|
24
|
-
});
|
25
|
-
|
26
|
-
it('has language attribute as null', () => {
|
27
|
-
const doc = fromHTML(
|
28
|
-
'<pre><span>window.alert("hello");<span></pre>',
|
29
|
-
schema,
|
30
|
-
);
|
31
|
-
|
32
|
-
expect(doc.firstChild!.attrs['language']).toEqual(null);
|
33
|
-
});
|
34
|
-
});
|
35
|
-
|
36
|
-
describe('when language is set', () => {
|
37
|
-
it('converts to block code node', () => {
|
38
|
-
const doc = fromHTML(
|
39
|
-
'<pre data-language="javascript"><span>window.alert("hello");<span></pre>',
|
40
|
-
schema,
|
41
|
-
);
|
42
|
-
|
43
|
-
expect(doc.firstChild!.type.spec).toEqual(codeBlock);
|
44
|
-
});
|
45
|
-
|
46
|
-
it(`extracts language "python" from data-language attribute`, () => {
|
47
|
-
const doc = fromHTML(
|
48
|
-
`<pre data-language='python'><span>window.alert("hello");<span></pre>`,
|
49
|
-
schema,
|
50
|
-
);
|
51
|
-
|
52
|
-
expect(doc.firstChild!.attrs['language']).toEqual('python');
|
53
|
-
});
|
54
|
-
});
|
55
|
-
|
56
|
-
it('preserves all newlines and whitespace', () => {
|
57
|
-
const doc = fromHTML(
|
58
|
-
'<pre><span></span> bar\n baz\n</pre>',
|
59
|
-
schema,
|
60
|
-
);
|
61
|
-
|
62
|
-
expect(doc.firstChild!.textContent).toEqual(' bar\n baz\n');
|
63
|
-
});
|
64
|
-
});
|
65
|
-
|
66
|
-
describe('parse from Bitbucket', () => {
|
67
|
-
describe('when language is not set', () => {
|
68
|
-
it('converts to block code node', () => {
|
69
|
-
const doc = fromHTML(
|
70
|
-
'<div class="codehilite"><pre><span>window.alert("hello");<span></pre></div>',
|
71
|
-
schema,
|
72
|
-
);
|
73
|
-
|
74
|
-
expect(doc.firstChild!.type.spec).toEqual(codeBlock);
|
75
|
-
});
|
76
|
-
|
77
|
-
it('has language attribute as null', () => {
|
78
|
-
const doc = fromHTML(
|
79
|
-
'<div class="codehilite"><pre><span>window.alert("hello");<span></pre></div>',
|
80
|
-
schema,
|
81
|
-
);
|
82
|
-
const codeBlock = doc.firstChild!;
|
83
|
-
|
84
|
-
expect(codeBlock.attrs.language).toEqual(null);
|
85
|
-
});
|
86
|
-
});
|
87
|
-
|
88
|
-
describe('when other class similar to language is set', () => {
|
89
|
-
it('has language attribute as null', () => {
|
90
|
-
const doc = fromHTML(
|
91
|
-
'<div class="codehilite nolanguage-javascript"><pre><span>window.alert("hello");<span></pre></div>',
|
92
|
-
schema,
|
93
|
-
);
|
94
|
-
const codeBlock = doc.firstChild!;
|
95
|
-
|
96
|
-
expect(codeBlock.attrs.language).toEqual(null);
|
97
|
-
});
|
98
|
-
});
|
99
|
-
});
|
100
|
-
|
101
|
-
it('should parse code block from tag with font-family monospace css', () => {
|
102
|
-
const doc = fromHTML(
|
103
|
-
`<meta charset="utf-8"><div style="font-family: Menlo, Monaco, 'Courier New', monospace;">Code :D</div>`,
|
104
|
-
schema,
|
105
|
-
);
|
106
|
-
expect(doc.firstChild!.type.spec).toEqual(codeBlock);
|
107
|
-
});
|
108
|
-
|
109
|
-
it('should parse code block from tag with `whitespace: pre` css', () => {
|
110
|
-
const doc = fromHTML(
|
111
|
-
'<meta charset="utf-8"><div style="white-space: pre;">Hello</div>',
|
112
|
-
schema,
|
113
|
-
);
|
114
|
-
expect(doc.firstChild!.type.name).toEqual('codeBlock');
|
115
|
-
});
|
116
|
-
|
117
|
-
it('should not create code block for `whitespace pre-wrap` css', () => {
|
118
|
-
const doc = fromHTML(
|
119
|
-
'<meta charset="utf-8"><div style="white-space: pre-wrap;">Hello</div>',
|
120
|
-
schema,
|
121
|
-
);
|
122
|
-
expect(doc.firstChild!.type.name).toEqual('paragraph');
|
123
|
-
});
|
124
|
-
|
125
|
-
describe('when language is set', () => {
|
126
|
-
it('converts to block code node', () => {
|
127
|
-
const doc = fromHTML(
|
128
|
-
'<div class="codehilite language-javascript"><pre><span>window.alert("hello");<span></pre></div>',
|
129
|
-
schema,
|
130
|
-
);
|
131
|
-
|
132
|
-
expect(doc.firstChild!.type.spec).toEqual(codeBlock);
|
133
|
-
});
|
134
|
-
|
135
|
-
it(`extracts language attribute from class "language-python"`, () => {
|
136
|
-
const doc = fromHTML(
|
137
|
-
`<div class="codehilite language-python"><pre><span>window.alert("hello");<span></pre></div>`,
|
138
|
-
schema,
|
139
|
-
);
|
140
|
-
const codeBlock = doc.firstChild!;
|
141
|
-
|
142
|
-
expect(codeBlock.attrs.language).toEqual('python');
|
143
|
-
});
|
144
|
-
|
145
|
-
it('removes last new line', () => {
|
146
|
-
const doc = fromHTML(
|
147
|
-
'<div class="codehilite"><pre><span>hello world;<span><span>\n<span></pre></div>',
|
148
|
-
schema,
|
149
|
-
);
|
150
|
-
|
151
|
-
expect(doc.firstChild!.textContent).toEqual('hello world;');
|
152
|
-
});
|
153
|
-
|
154
|
-
it('preserves newlines in the middle and whitespace', () => {
|
155
|
-
const doc = fromHTML(
|
156
|
-
'<div class="codehilite"><pre><span></span> bar\n baz</pre></div>',
|
157
|
-
schema,
|
158
|
-
);
|
159
|
-
|
160
|
-
expect(doc.firstChild!.textContent).toEqual(' bar\n baz');
|
161
|
-
});
|
162
|
-
});
|
163
|
-
});
|
164
|
-
|
165
|
-
describe('convert to HTML', () => {
|
166
|
-
const schema = makeSchema();
|
167
|
-
|
168
|
-
describe('when language is not set', () => {
|
169
|
-
it('converts to pre tag', () => {
|
170
|
-
const codeBlock = schema.nodes.codeBlock.create();
|
171
|
-
expect(toHTML(codeBlock, schema)).toContain('<pre');
|
172
|
-
});
|
173
|
-
|
174
|
-
it('does not set data-language attributes', () => {
|
175
|
-
const codeBlock = schema.nodes.codeBlock.create();
|
176
|
-
expect(toHTML(codeBlock, schema)).not.toContain('data-language');
|
177
|
-
});
|
178
|
-
});
|
179
|
-
|
180
|
-
describe('when language is set to null', () => {
|
181
|
-
it('does not set data-language attributes', () => {
|
182
|
-
const codeBlock = schema.nodes.codeBlock.create({ language: null });
|
183
|
-
expect(toHTML(codeBlock, schema)).not.toContain('data-language');
|
184
|
-
});
|
185
|
-
});
|
186
|
-
|
187
|
-
describe('when language is set to undefined', () => {
|
188
|
-
it('does not set data-language attributes', () => {
|
189
|
-
const codeBlock = schema.nodes.codeBlock.create({
|
190
|
-
language: undefined,
|
191
|
-
});
|
192
|
-
expect(toHTML(codeBlock, schema)).not.toContain('data-language');
|
193
|
-
});
|
194
|
-
});
|
195
|
-
|
196
|
-
describe('when language is set to a value', () => {
|
197
|
-
it('converts to pre tag', () => {
|
198
|
-
const codeBlock = schema.nodes.codeBlock.create({
|
199
|
-
language: 'javascript',
|
200
|
-
});
|
201
|
-
expect(toHTML(codeBlock, schema)).toContain('<pre');
|
202
|
-
});
|
203
|
-
|
204
|
-
it('sets data-language attributes', () => {
|
205
|
-
const codeBlock = schema.nodes.codeBlock.create({
|
206
|
-
language: 'javascript',
|
207
|
-
});
|
208
|
-
expect(toHTML(codeBlock, schema)).toContain(
|
209
|
-
'data-language="javascript"',
|
210
|
-
);
|
211
|
-
});
|
212
|
-
});
|
213
|
-
});
|
214
|
-
});
|
215
|
-
|
216
|
-
function makeSchema() {
|
217
|
-
return createSchema({
|
218
|
-
nodes: ['doc', 'paragraph', 'text', 'codeBlock', 'unsupportedInline'],
|
219
|
-
marks: ['unsupportedMark', 'unsupportedNodeAttribute'],
|
220
|
-
});
|
221
|
-
}
|
@@ -1,32 +0,0 @@
|
|
1
|
-
import { schema, toDOM, fromHTML } from 'adf-test-helpers/src/adf-schema';
|
2
|
-
|
3
|
-
const packageName = process.env._PACKAGE_NAME_ as string;
|
4
|
-
|
5
|
-
describe(`${packageName}/schema unsupportedBlock node`, () => {
|
6
|
-
it('should parse unsupported block nodes', () => {
|
7
|
-
const doc = fromHTML(
|
8
|
-
'<div data-node-type="confluenceUnsupportedBlock" data-confluence-unsupported="block" data-confluence-unsupported-block-cxhtml="foobar"/>',
|
9
|
-
schema,
|
10
|
-
);
|
11
|
-
const unsupportedBlockNode = doc.firstChild!;
|
12
|
-
expect(unsupportedBlockNode.type).toEqual(
|
13
|
-
schema.nodes.confluenceUnsupportedBlock,
|
14
|
-
);
|
15
|
-
expect(unsupportedBlockNode.attrs.cxhtml).toEqual('foobar');
|
16
|
-
});
|
17
|
-
|
18
|
-
it('should encode unsupported block nodes to html', () => {
|
19
|
-
const unsupportedBlockNode = schema.nodes.confluenceUnsupportedBlock.create(
|
20
|
-
{ cxhtml: 'foobar' },
|
21
|
-
);
|
22
|
-
const domNode = toDOM(unsupportedBlockNode, schema)
|
23
|
-
.firstChild as HTMLElement;
|
24
|
-
|
25
|
-
expect(domNode.getAttribute('data-confluence-unsupported')).toEqual(
|
26
|
-
'block',
|
27
|
-
);
|
28
|
-
expect(
|
29
|
-
domNode.getAttribute('data-confluence-unsupported-block-cxhtml'),
|
30
|
-
).toEqual('foobar');
|
31
|
-
});
|
32
|
-
});
|
@@ -1,35 +0,0 @@
|
|
1
|
-
import { toDOM, fromHTML } from 'adf-test-helpers/src/adf-schema/html-helpers';
|
2
|
-
|
3
|
-
import { schema } from 'adf-test-helpers/src/adf-schema';
|
4
|
-
|
5
|
-
const packageName = process.env._PACKAGE_NAME_ as string;
|
6
|
-
|
7
|
-
describe(`${packageName}/schema unsupportedInline node`, () => {
|
8
|
-
it('should parse unsupported inline nodes', () => {
|
9
|
-
const doc = fromHTML(
|
10
|
-
'<div data-node-type="confluenceUnsupportedInline" data-confluence-unsupported="inline" data-confluence-unsupported-inline-cxhtml="foobar"/>',
|
11
|
-
schema,
|
12
|
-
);
|
13
|
-
const paragraph = doc.firstChild!;
|
14
|
-
const unsupportedInlineNode = paragraph.firstChild!;
|
15
|
-
|
16
|
-
expect(unsupportedInlineNode.type).toEqual(
|
17
|
-
schema.nodes.confluenceUnsupportedInline,
|
18
|
-
);
|
19
|
-
expect(unsupportedInlineNode.attrs.cxhtml).toEqual('foobar');
|
20
|
-
});
|
21
|
-
|
22
|
-
it('should encode unsupported inline nodes to html', () => {
|
23
|
-
const unsupportedInlineNode =
|
24
|
-
schema.nodes.confluenceUnsupportedInline.create({ cxhtml: 'foobar' });
|
25
|
-
const domNode = toDOM(unsupportedInlineNode, schema)
|
26
|
-
.firstChild as HTMLElement;
|
27
|
-
|
28
|
-
expect(domNode.getAttribute('data-confluence-unsupported')).toEqual(
|
29
|
-
'inline',
|
30
|
-
);
|
31
|
-
expect(
|
32
|
-
domNode.getAttribute('data-confluence-unsupported-inline-cxhtml'),
|
33
|
-
).toEqual('foobar');
|
34
|
-
});
|
35
|
-
});
|
@@ -1,51 +0,0 @@
|
|
1
|
-
import { toDOM, fromHTML } from 'adf-test-helpers/src/adf-schema/html-helpers';
|
2
|
-
import { date } from '../../../..';
|
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 date node`, () => {
|
9
|
-
describe('parse html', () => {
|
10
|
-
it('converts to date PM node', () => {
|
11
|
-
const doc = fromHTML('<span data-node-type="date" />', schema);
|
12
|
-
const node = doc.firstChild!.firstChild!;
|
13
|
-
expect(node.type.spec).toEqual(date);
|
14
|
-
});
|
15
|
-
|
16
|
-
it('gets attributes from html', () => {
|
17
|
-
const timestamp = '1515639075805';
|
18
|
-
const doc = fromHTML(
|
19
|
-
`
|
20
|
-
<span
|
21
|
-
data-node-type="date"
|
22
|
-
data-timestamp="${timestamp}"
|
23
|
-
/>
|
24
|
-
`,
|
25
|
-
schema,
|
26
|
-
);
|
27
|
-
const node = doc.firstChild!.firstChild!;
|
28
|
-
expect(node.attrs.timestamp).toEqual(timestamp);
|
29
|
-
});
|
30
|
-
});
|
31
|
-
|
32
|
-
describe('encode html', () => {
|
33
|
-
it('converts html data attributes to node attributes', () => {
|
34
|
-
const attrs = { timestamp: '1515639075805' };
|
35
|
-
// extension node can contain no content
|
36
|
-
const node = schema.nodes.date.create(attrs);
|
37
|
-
const dom = toDOM(node, schema).firstChild! as HTMLElement;
|
38
|
-
expect(dom.getAttribute('data-node-type')).toEqual('date');
|
39
|
-
expect(dom.getAttribute('data-timestamp')).toEqual(attrs.timestamp);
|
40
|
-
});
|
41
|
-
|
42
|
-
it('encodes and decodes to the same node', () => {
|
43
|
-
const attrs = { timestamp: '1515639075805' };
|
44
|
-
const node = schema.nodes.date.create(attrs);
|
45
|
-
const dom = toDOM(node, schema).firstChild as HTMLElement;
|
46
|
-
const parsedNode = fromHTML(dom.outerHTML, schema).firstChild!
|
47
|
-
.firstChild!;
|
48
|
-
expect(parsedNode).toEqual(node);
|
49
|
-
});
|
50
|
-
});
|
51
|
-
});
|