@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.
- package/CHANGELOG.md +12 -0
- package/dist/types/index.d.ts +1 -1
- 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,44 +0,0 @@
|
|
1
|
-
import { createSchema } from '../../../../schema/create-schema';
|
2
|
-
import {
|
3
|
-
fromHTML,
|
4
|
-
toHTML,
|
5
|
-
textWithMarks,
|
6
|
-
} from 'adf-test-helpers/src/adf-schema';
|
7
|
-
|
8
|
-
const packageName = process.env._PACKAGE_NAME_ as string;
|
9
|
-
|
10
|
-
describe(`${packageName}/schema code mark`, () => {
|
11
|
-
itMatches('<span class="code">text</span>', 'text');
|
12
|
-
itMatches('<code>text</code>', 'text');
|
13
|
-
itMatches('<tt>text</tt>', 'text');
|
14
|
-
itMatches(
|
15
|
-
`<span style="font-family: Menlo, Monaco, 'Courier New', monospace;">text</span>`,
|
16
|
-
'text',
|
17
|
-
);
|
18
|
-
itMatches(`<span style="white-space: pre;">text</span>`, 'text');
|
19
|
-
|
20
|
-
it('serializes to <span class="code">', () => {
|
21
|
-
const schema = makeSchema();
|
22
|
-
const node = schema.text('foo', [schema.marks.code.create()]);
|
23
|
-
expect(toHTML(node, schema)).toEqual(
|
24
|
-
'<span class="code" spellcheck="false">foo</span>',
|
25
|
-
);
|
26
|
-
});
|
27
|
-
});
|
28
|
-
|
29
|
-
function makeSchema() {
|
30
|
-
return createSchema({
|
31
|
-
nodes: ['doc', 'paragraph', 'text'],
|
32
|
-
marks: ['code'],
|
33
|
-
});
|
34
|
-
}
|
35
|
-
|
36
|
-
function itMatches(html: string, expectedText: string) {
|
37
|
-
it(`matches ${html}`, () => {
|
38
|
-
const schema = makeSchema();
|
39
|
-
const doc = fromHTML(`${html}`, schema);
|
40
|
-
const codeNode = schema.marks.code.create();
|
41
|
-
|
42
|
-
expect(textWithMarks(doc, expectedText, [codeNode])).toBe(true);
|
43
|
-
});
|
44
|
-
}
|
@@ -1,25 +0,0 @@
|
|
1
|
-
import { createSchema } from '../../../../schema/create-schema';
|
2
|
-
import { toHTML } from 'adf-test-helpers/src/adf-schema/html-helpers';
|
3
|
-
|
4
|
-
const packageName = process.env._PACKAGE_NAME_ as string;
|
5
|
-
|
6
|
-
describe(`${packageName}/schema confluence-inline-comment mark`, () => {
|
7
|
-
it('serializes to <span data-reference="hash-ref-goes-here">', () => {
|
8
|
-
const schema = makeSchema();
|
9
|
-
const node = schema.text('foo', [
|
10
|
-
schema.marks.confluenceInlineComment.create({
|
11
|
-
reference: 'hash-ref-goes-here',
|
12
|
-
}),
|
13
|
-
]);
|
14
|
-
expect(toHTML(node, schema)).toContain(
|
15
|
-
'data-reference="hash-ref-goes-here"',
|
16
|
-
);
|
17
|
-
});
|
18
|
-
});
|
19
|
-
|
20
|
-
function makeSchema() {
|
21
|
-
return createSchema({
|
22
|
-
nodes: ['doc', 'paragraph', 'text'],
|
23
|
-
marks: ['confluenceInlineComment'],
|
24
|
-
});
|
25
|
-
}
|
@@ -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
|
-
import { Schema } from '@atlaskit/editor-prosemirror/model';
|
4
|
-
|
5
|
-
const packageName = process.env._PACKAGE_NAME_ as string;
|
6
|
-
|
7
|
-
describe(`${packageName}/schema data-consumer mark`, () => {
|
8
|
-
let schema: Schema;
|
9
|
-
const firstSourceId = 'first-source-id';
|
10
|
-
const secondSourceId = 'second-source-id';
|
11
|
-
const dataSourceString = `"${firstSourceId}","${secondSourceId}"`;
|
12
|
-
|
13
|
-
beforeEach(() => {
|
14
|
-
schema = makeSchema();
|
15
|
-
});
|
16
|
-
|
17
|
-
it('serializes to the correct HTML', () => {
|
18
|
-
const node = schema.text('foo', [
|
19
|
-
schema.marks.dataConsumer.create({
|
20
|
-
sources: [firstSourceId, secondSourceId],
|
21
|
-
}),
|
22
|
-
]);
|
23
|
-
const html = toHTML(node, schema);
|
24
|
-
|
25
|
-
expect(html).toContain(`data-sources="[${dataSourceString}]"`);
|
26
|
-
expect(html).toContain('data-mark-type="dataConsumer"');
|
27
|
-
});
|
28
|
-
|
29
|
-
it.each(['div', 'span'])(
|
30
|
-
'parses annotation correctly from html for %s',
|
31
|
-
(wrapperType) => {
|
32
|
-
const doc = fromHTML(
|
33
|
-
`<${wrapperType} data-mark-type="dataConsumer" data-sources="[${dataSourceString}]">foo</${wrapperType}>`,
|
34
|
-
schema,
|
35
|
-
);
|
36
|
-
const dataConsumerNode = doc.firstChild!;
|
37
|
-
|
38
|
-
expect(dataConsumerNode.marks).toHaveLength(1);
|
39
|
-
expect(dataConsumerNode.marks[0].type.name).toBe('dataConsumer');
|
40
|
-
expect(dataConsumerNode.marks[0].attrs).toEqual({
|
41
|
-
sources: [firstSourceId, secondSourceId],
|
42
|
-
});
|
43
|
-
},
|
44
|
-
);
|
45
|
-
});
|
46
|
-
|
47
|
-
function makeSchema() {
|
48
|
-
return createSchema({
|
49
|
-
nodes: ['doc', 'paragraph', 'text'],
|
50
|
-
marks: ['dataConsumer'],
|
51
|
-
});
|
52
|
-
}
|
@@ -1,37 +0,0 @@
|
|
1
|
-
import { createSchema } from '../../../../schema/create-schema';
|
2
|
-
import {
|
3
|
-
fromHTML,
|
4
|
-
toHTML,
|
5
|
-
textWithMarks,
|
6
|
-
} from 'adf-test-helpers/src/adf-schema';
|
7
|
-
|
8
|
-
const packageName = process.env._PACKAGE_NAME_ as string;
|
9
|
-
|
10
|
-
describe(`${packageName}/schema em mark`, () => {
|
11
|
-
itMatches('<em>text</em>', 'text');
|
12
|
-
itMatches('<i>text</i>', 'text');
|
13
|
-
itMatches('<span style="font-style: italic">text</span>', 'text');
|
14
|
-
|
15
|
-
it('serializes to <em>', () => {
|
16
|
-
const schema = makeSchema();
|
17
|
-
const node = schema.text('foo', [schema.marks.em.create()]);
|
18
|
-
expect(toHTML(node, schema)).toEqual('<em>foo</em>');
|
19
|
-
});
|
20
|
-
});
|
21
|
-
|
22
|
-
function makeSchema() {
|
23
|
-
return createSchema({
|
24
|
-
nodes: ['doc', 'paragraph', 'text'],
|
25
|
-
marks: ['em'],
|
26
|
-
});
|
27
|
-
}
|
28
|
-
|
29
|
-
function itMatches(html: string, expectedText: string) {
|
30
|
-
it(`matches ${html}`, () => {
|
31
|
-
const schema = makeSchema();
|
32
|
-
const doc = fromHTML(`${html}`, schema);
|
33
|
-
const emNode = schema.marks.em.create();
|
34
|
-
|
35
|
-
expect(textWithMarks(doc, expectedText, [emNode])).toBe(true);
|
36
|
-
});
|
37
|
-
}
|
@@ -1,188 +0,0 @@
|
|
1
|
-
import { createSchema } from '../../../../schema/create-schema';
|
2
|
-
import {
|
3
|
-
toHTML,
|
4
|
-
fromHTML,
|
5
|
-
textWithMarks,
|
6
|
-
} from 'adf-test-helpers/src/adf-schema';
|
7
|
-
import { Node } from '@atlaskit/editor-prosemirror/model';
|
8
|
-
|
9
|
-
const href = 'http://atlassian.com';
|
10
|
-
const href2 = 'http://atlassian.com/test';
|
11
|
-
const href3 = 'http://atlassian.com?test=123';
|
12
|
-
const unsafeHref = 'javascript:alert("hack")';
|
13
|
-
const content = 'foo';
|
14
|
-
const sampleLink = `<a href="${href}">${content}</a>`;
|
15
|
-
const sampleBlockLink = `<a href="${href}" data-block-link="true" class="blockLink"><p>${content}</p></a>`;
|
16
|
-
const emptyLink = `<a>${content}</a>`;
|
17
|
-
const packageName = process.env._PACKAGE_NAME_ as string;
|
18
|
-
|
19
|
-
describe(`${packageName}/schema link mark`, () => {
|
20
|
-
itMatches(`<p>${sampleLink}</p>`, href, content);
|
21
|
-
itMatches(
|
22
|
-
`<p><a href="${href}" title="test" alt="hello">${content}</a></p>`,
|
23
|
-
href,
|
24
|
-
content,
|
25
|
-
);
|
26
|
-
itMatches(`<p><a href="${href2}">${content}</a></p>`, href2, content);
|
27
|
-
itMatches(`<p><a href="${href3}">${content}</a></p>`, href3, content);
|
28
|
-
|
29
|
-
describe('when there is a textColor mark', () => {
|
30
|
-
it('should not throw an error when the check() is called', () => {
|
31
|
-
const doc = {
|
32
|
-
type: 'text',
|
33
|
-
text: 'Foo',
|
34
|
-
marks: [
|
35
|
-
{
|
36
|
-
type: 'link',
|
37
|
-
attrs: {
|
38
|
-
href: 'http://example.com',
|
39
|
-
},
|
40
|
-
},
|
41
|
-
|
42
|
-
{
|
43
|
-
type: 'textColor',
|
44
|
-
attrs: {
|
45
|
-
color: '#ff5630',
|
46
|
-
},
|
47
|
-
},
|
48
|
-
],
|
49
|
-
};
|
50
|
-
|
51
|
-
const textNode = Node.fromJSON(makeSchema(), doc);
|
52
|
-
expect(() => {
|
53
|
-
textNode.check();
|
54
|
-
}).not.toThrow();
|
55
|
-
});
|
56
|
-
});
|
57
|
-
|
58
|
-
describe('whitelist URLs', () => {
|
59
|
-
const schema = makeSchema();
|
60
|
-
|
61
|
-
it(`should parse links starting from http://`, () => {
|
62
|
-
const doc = fromHTML(
|
63
|
-
`<p><a href="http://www.atlassian.com">Atlassian</a></p>`,
|
64
|
-
schema,
|
65
|
-
);
|
66
|
-
const textNode = doc.firstChild!.firstChild!;
|
67
|
-
|
68
|
-
expect(textNode.marks).toHaveLength(1);
|
69
|
-
});
|
70
|
-
|
71
|
-
it(`should parse links starting from https://`, () => {
|
72
|
-
const doc = fromHTML(
|
73
|
-
`<p><a href="https://www.atlassian.com">Atlassian</a></p>`,
|
74
|
-
schema,
|
75
|
-
);
|
76
|
-
const textNode = doc.firstChild!.firstChild!;
|
77
|
-
|
78
|
-
expect(textNode.marks).toHaveLength(1);
|
79
|
-
});
|
80
|
-
|
81
|
-
it(`should parse links starting from sourcetree://`, () => {
|
82
|
-
const doc = fromHTML(
|
83
|
-
`<p><a href="sourcetree://cloneRepo/ssh://user@bitbucket.org/owner/repo.git">Clone me</a></p>`,
|
84
|
-
schema,
|
85
|
-
);
|
86
|
-
const textNode = doc.firstChild!.firstChild!;
|
87
|
-
|
88
|
-
expect(textNode.marks).toHaveLength(1);
|
89
|
-
});
|
90
|
-
|
91
|
-
it(`should parse root relative links`, () => {
|
92
|
-
const doc = fromHTML(`<p><a href="/TEST-100">TEST-100</a></p>`, schema);
|
93
|
-
const textNode = doc.firstChild!.firstChild!;
|
94
|
-
|
95
|
-
expect(textNode.marks).toHaveLength(1);
|
96
|
-
});
|
97
|
-
|
98
|
-
it(`should not parse links starting from javascript://`, () => {
|
99
|
-
const doc = fromHTML(
|
100
|
-
`<p><a href="javascript:alert(1)">Click me</a></p>`,
|
101
|
-
schema,
|
102
|
-
);
|
103
|
-
const textNode = doc.firstChild!.firstChild!;
|
104
|
-
|
105
|
-
expect(textNode.marks).toHaveLength(0);
|
106
|
-
});
|
107
|
-
|
108
|
-
it(`should not parse links starting from javascript://`, () => {
|
109
|
-
const doc = fromHTML(
|
110
|
-
`<p><a href="view-source:https://bitbucket.org/atlassian/atlaskit/pull-requests/3196/fix-component-prevent-javascript-links-for/diff">View source</a></p>`,
|
111
|
-
schema,
|
112
|
-
);
|
113
|
-
const textNode = doc.firstChild!.firstChild!;
|
114
|
-
|
115
|
-
expect(textNode.marks).toHaveLength(0);
|
116
|
-
});
|
117
|
-
|
118
|
-
it(`should remove unsafe link when serialize`, () => {
|
119
|
-
const schema = makeSchema();
|
120
|
-
const node = schema.text(content, [
|
121
|
-
schema.marks.link.create({ href: unsafeHref }),
|
122
|
-
]);
|
123
|
-
const html: string = toHTML(node, schema);
|
124
|
-
|
125
|
-
expect(html).toContain(`${emptyLink}`);
|
126
|
-
});
|
127
|
-
});
|
128
|
-
|
129
|
-
describe('serialization', () => {
|
130
|
-
it(`serializes to ${sampleLink}`, () => {
|
131
|
-
const schema = makeSchema();
|
132
|
-
const node = schema.text(content, [schema.marks.link.create({ href })]);
|
133
|
-
const html: string = toHTML(node, schema);
|
134
|
-
expect(html).toContain(`${sampleLink}`);
|
135
|
-
});
|
136
|
-
it(`serializes block marked links ${sampleLink}`, () => {
|
137
|
-
const schema = makeSchema();
|
138
|
-
const node = schema.nodes.paragraph.create(null, schema.text(content), [
|
139
|
-
schema.marks.link.create({ href }),
|
140
|
-
]);
|
141
|
-
const html: string = toHTML(node, schema);
|
142
|
-
expect(html).toContain(`${sampleBlockLink}`);
|
143
|
-
});
|
144
|
-
});
|
145
|
-
|
146
|
-
describe('confluence metadata', () => {
|
147
|
-
it('creates a PM node with attributes from ADF', () => {
|
148
|
-
const doc = {
|
149
|
-
type: 'text',
|
150
|
-
text: 'Foo',
|
151
|
-
marks: [
|
152
|
-
{
|
153
|
-
type: 'link',
|
154
|
-
attrs: {
|
155
|
-
href: 'http://example.com',
|
156
|
-
__confluenceMetadata: {
|
157
|
-
linkType: 'value',
|
158
|
-
},
|
159
|
-
},
|
160
|
-
},
|
161
|
-
],
|
162
|
-
};
|
163
|
-
|
164
|
-
const text = Node.fromJSON(makeSchema(), doc);
|
165
|
-
expect(text.marks[0].attrs).toHaveProperty('__confluenceMetadata');
|
166
|
-
expect(text.marks[0].attrs.__confluenceMetadata).toHaveProperty(
|
167
|
-
'linkType',
|
168
|
-
'value',
|
169
|
-
);
|
170
|
-
});
|
171
|
-
});
|
172
|
-
});
|
173
|
-
|
174
|
-
function makeSchema() {
|
175
|
-
return createSchema({
|
176
|
-
nodes: ['doc', 'paragraph', 'text'],
|
177
|
-
marks: ['link', 'textColor'],
|
178
|
-
});
|
179
|
-
}
|
180
|
-
|
181
|
-
function itMatches(html: string, href: string, expectedText: string) {
|
182
|
-
it(`matches ${html}`, () => {
|
183
|
-
const schema = makeSchema();
|
184
|
-
const doc = fromHTML(html, schema);
|
185
|
-
const link = schema.marks.link.create({ href });
|
186
|
-
expect(textWithMarks(doc, expectedText, [link])).toBe(true);
|
187
|
-
});
|
188
|
-
}
|
@@ -1,37 +0,0 @@
|
|
1
|
-
import { createSchema } from '../../../../schema/create-schema';
|
2
|
-
import {
|
3
|
-
fromHTML,
|
4
|
-
toHTML,
|
5
|
-
textWithMarks,
|
6
|
-
} from 'adf-test-helpers/src/adf-schema';
|
7
|
-
|
8
|
-
const packageName = process.env._PACKAGE_NAME_ as string;
|
9
|
-
|
10
|
-
describe(`${packageName}/schema strike mark`, () => {
|
11
|
-
itMatches('<s>text</s>', 'text');
|
12
|
-
itMatches('<del>text</del>', 'text');
|
13
|
-
itMatches('<strike>text</strike>', 'text');
|
14
|
-
itMatches('<span style="text-decoration: line-through">text</span>', 'text');
|
15
|
-
|
16
|
-
it('serializes to <s>', () => {
|
17
|
-
const schema = makeSchema();
|
18
|
-
const node = schema.text('foo', [schema.marks.strike.create()]);
|
19
|
-
expect(toHTML(node, schema)).toEqual('<s>foo</s>');
|
20
|
-
});
|
21
|
-
});
|
22
|
-
|
23
|
-
function makeSchema() {
|
24
|
-
return createSchema({
|
25
|
-
nodes: ['doc', 'paragraph', 'text'],
|
26
|
-
marks: ['strike'],
|
27
|
-
});
|
28
|
-
}
|
29
|
-
|
30
|
-
function itMatches(html: string, expectedText: string) {
|
31
|
-
it(`matches ${html}`, () => {
|
32
|
-
const schema = makeSchema();
|
33
|
-
const doc = fromHTML(html, schema);
|
34
|
-
const strike = schema.marks.strike.create();
|
35
|
-
expect(textWithMarks(doc, expectedText, [strike])).toBe(true);
|
36
|
-
});
|
37
|
-
}
|
@@ -1,43 +0,0 @@
|
|
1
|
-
import { createSchema } from '../../../../schema/create-schema';
|
2
|
-
import {
|
3
|
-
fromHTML,
|
4
|
-
toHTML,
|
5
|
-
textWithMarks,
|
6
|
-
} from 'adf-test-helpers/src/adf-schema';
|
7
|
-
|
8
|
-
const packageName = process.env._PACKAGE_NAME_ as string;
|
9
|
-
|
10
|
-
describe(`${packageName}/schema strong mark`, () => {
|
11
|
-
itMatches('<strong>text</strong>', 'text');
|
12
|
-
itMatches('<b>text</b>', 'text');
|
13
|
-
itMatches('<b style="font-weight: bold">text</b>', 'text');
|
14
|
-
itMatches('<span style="font-weight: bold">text</span>', 'text');
|
15
|
-
|
16
|
-
it('serializes to <strong>', () => {
|
17
|
-
const schema = makeSchema();
|
18
|
-
const node = schema.text('foo', [schema.marks.strong.create()]);
|
19
|
-
expect(toHTML(node, schema)).toEqual('<strong>foo</strong>');
|
20
|
-
});
|
21
|
-
|
22
|
-
it('should not match <b style=font-weight: normal> as strong', () => {
|
23
|
-
const schema = makeSchema();
|
24
|
-
const doc = fromHTML('<b style="font-weight: normal">text</b>', schema);
|
25
|
-
expect(textWithMarks(doc, 'text', [])).toBe(true);
|
26
|
-
});
|
27
|
-
});
|
28
|
-
|
29
|
-
function makeSchema() {
|
30
|
-
return createSchema({
|
31
|
-
nodes: ['doc', 'paragraph', 'text'],
|
32
|
-
marks: ['strong'],
|
33
|
-
});
|
34
|
-
}
|
35
|
-
|
36
|
-
function itMatches(html: string, expectedText: string) {
|
37
|
-
it(`matches ${html}`, () => {
|
38
|
-
const schema = makeSchema();
|
39
|
-
const doc = fromHTML(html, schema);
|
40
|
-
const strong = schema.marks.strong.create();
|
41
|
-
expect(textWithMarks(doc, expectedText, [strong])).toBe(true);
|
42
|
-
});
|
43
|
-
}
|
@@ -1,50 +0,0 @@
|
|
1
|
-
import { createSchema } from '../../../../schema/create-schema';
|
2
|
-
import {
|
3
|
-
fromHTML,
|
4
|
-
toHTML,
|
5
|
-
textWithMarks,
|
6
|
-
} from 'adf-test-helpers/src/adf-schema';
|
7
|
-
|
8
|
-
const packageName = process.env._PACKAGE_NAME_ as string;
|
9
|
-
|
10
|
-
describe(`${packageName}/schema subsup mark`, () => {
|
11
|
-
itMatches('<sub>text</sub>', 'text', { type: 'sub' });
|
12
|
-
itMatches('<sup>text</sup>', 'text', { type: 'sup' });
|
13
|
-
|
14
|
-
it('serializes to <sub>', () => {
|
15
|
-
const schema = makeSchema();
|
16
|
-
const node = schema.text('foo', [
|
17
|
-
schema.marks.subsup.create({ type: 'sub' }),
|
18
|
-
]);
|
19
|
-
expect(toHTML(node, schema)).toEqual('<sub>foo</sub>');
|
20
|
-
});
|
21
|
-
|
22
|
-
it('serializes to <sup>', () => {
|
23
|
-
const schema = makeSchema();
|
24
|
-
const node = schema.text('foo', [
|
25
|
-
schema.marks.subsup.create({ type: 'sup' }),
|
26
|
-
]);
|
27
|
-
expect(toHTML(node, schema)).toEqual('<sup>foo</sup>');
|
28
|
-
});
|
29
|
-
});
|
30
|
-
|
31
|
-
function makeSchema() {
|
32
|
-
return createSchema({
|
33
|
-
nodes: ['doc', 'paragraph', 'text'],
|
34
|
-
marks: ['subsup'],
|
35
|
-
});
|
36
|
-
}
|
37
|
-
|
38
|
-
function itMatches(
|
39
|
-
html: string,
|
40
|
-
expectedText: string,
|
41
|
-
attrs: { type: 'sub' | 'sup' },
|
42
|
-
) {
|
43
|
-
it(`matches ${html}`, () => {
|
44
|
-
const schema = makeSchema();
|
45
|
-
const doc = fromHTML(`${html}`, schema);
|
46
|
-
const subsupNode = schema.marks.subsup.create(attrs);
|
47
|
-
|
48
|
-
expect(textWithMarks(doc, expectedText, [subsupNode])).toBe(true);
|
49
|
-
});
|
50
|
-
}
|
@@ -1,61 +0,0 @@
|
|
1
|
-
import { createSchema } from '../../../../schema/create-schema';
|
2
|
-
import {
|
3
|
-
fromHTML,
|
4
|
-
toHTML,
|
5
|
-
textWithMarks,
|
6
|
-
} from 'adf-test-helpers/src/adf-schema';
|
7
|
-
|
8
|
-
const testColorObj1 = { color: '#97a0af' };
|
9
|
-
const testColorObj2 = { color: '#97A0AF' };
|
10
|
-
const packageName = process.env._PACKAGE_NAME_ as string;
|
11
|
-
|
12
|
-
describe(`${packageName}/schema textColor mark`, () => {
|
13
|
-
itMatches(
|
14
|
-
`<span style="color: rgb(151, 160, 175);">text</span>`,
|
15
|
-
'text',
|
16
|
-
testColorObj1,
|
17
|
-
);
|
18
|
-
itMatches(`<span style="color: #97a0af;">text</span>`, 'text', testColorObj1);
|
19
|
-
itMatches(`<span style="color: #97A0AF;">text</span>`, 'text', testColorObj1);
|
20
|
-
|
21
|
-
it('serializes to <span style="color: ...">', () => {
|
22
|
-
const schema = makeSchema();
|
23
|
-
const node = schema.text('foo', [
|
24
|
-
schema.marks.textColor.create(testColorObj1),
|
25
|
-
]);
|
26
|
-
expect(toHTML(node, schema)).toEqual(
|
27
|
-
`<span class=\"fabric-text-color-mark\" style=\"--custom-palette-color: var(--ds-icon-accent-gray, #97A0AF)\" data-text-custom-color=\"#97a0af\">foo</span>`,
|
28
|
-
);
|
29
|
-
});
|
30
|
-
|
31
|
-
it('serializes to <span style="color: ..."> case preserving', () => {
|
32
|
-
const schema = makeSchema();
|
33
|
-
const node = schema.text('foo', [
|
34
|
-
schema.marks.textColor.create(testColorObj2),
|
35
|
-
]);
|
36
|
-
expect(toHTML(node, schema)).toEqual(
|
37
|
-
`<span class=\"fabric-text-color-mark\" style=\"--custom-palette-color: var(--ds-icon-accent-gray, #97A0AF)\" data-text-custom-color=\"#97A0AF\">foo</span>`,
|
38
|
-
);
|
39
|
-
});
|
40
|
-
});
|
41
|
-
|
42
|
-
function makeSchema() {
|
43
|
-
return createSchema({
|
44
|
-
nodes: ['doc', 'paragraph', 'text'],
|
45
|
-
marks: ['textColor'],
|
46
|
-
});
|
47
|
-
}
|
48
|
-
|
49
|
-
function itMatches(
|
50
|
-
html: string,
|
51
|
-
expectedText: string,
|
52
|
-
attrs: { color: string },
|
53
|
-
) {
|
54
|
-
it(`matches ${html}`, () => {
|
55
|
-
const schema = makeSchema();
|
56
|
-
const doc = fromHTML(`${html}`, schema);
|
57
|
-
const textColorNode = schema.marks.textColor.create(attrs);
|
58
|
-
|
59
|
-
expect(textWithMarks(doc, expectedText, [textColorNode])).toBe(true);
|
60
|
-
});
|
61
|
-
}
|
@@ -1,36 +0,0 @@
|
|
1
|
-
import { createSchema } from '../../../../schema/create-schema';
|
2
|
-
import {
|
3
|
-
fromHTML,
|
4
|
-
toHTML,
|
5
|
-
textWithMarks,
|
6
|
-
} from 'adf-test-helpers/src/adf-schema';
|
7
|
-
|
8
|
-
const packageName = process.env._PACKAGE_NAME_ as string;
|
9
|
-
|
10
|
-
describe(`${packageName}/schema underline mark`, () => {
|
11
|
-
itMatches('<u>text</u>', 'text');
|
12
|
-
itMatches('<span style="text-decoration: underline">text</span>', 'text');
|
13
|
-
|
14
|
-
it('serializes to <u>', () => {
|
15
|
-
const schema = makeSchema();
|
16
|
-
const node = schema.text('foo', [schema.marks.underline.create()]);
|
17
|
-
expect(toHTML(node, schema)).toEqual('<u>foo</u>');
|
18
|
-
});
|
19
|
-
});
|
20
|
-
|
21
|
-
function makeSchema() {
|
22
|
-
return createSchema({
|
23
|
-
nodes: ['doc', 'paragraph', 'text'],
|
24
|
-
marks: ['underline'],
|
25
|
-
});
|
26
|
-
}
|
27
|
-
|
28
|
-
function itMatches(html: string, expectedText: string) {
|
29
|
-
it(`matches ${html}`, () => {
|
30
|
-
const schema = makeSchema();
|
31
|
-
const doc = fromHTML(`${html}`, schema);
|
32
|
-
const underlineNode = schema.marks.underline.create();
|
33
|
-
|
34
|
-
expect(textWithMarks(doc, expectedText, [underlineNode])).toBe(true);
|
35
|
-
});
|
36
|
-
}
|