@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.
- package/CHANGELOG.md +12 -0
- package/package.json +1 -1
- package/build/tsconfig.json +0 -18
- package/index.ts +0 -275
- 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/index.ts +0 -297
- package/src/json-schema/index.ts +0 -2
- 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/index.ts +0 -238
- 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/index.ts +0 -61
- 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/index.ts +0 -184
- 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/index.ts +0 -69
- 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
- package/tsconfig.json +0 -13
@@ -1,93 +0,0 @@
|
|
1
|
-
import { NodeSpec } from '@atlaskit/editor-prosemirror/model';
|
2
|
-
import { LayoutColumnDefinition } from './layout-column';
|
3
|
-
import { BreakoutMarkDefinition } from '../marks';
|
4
|
-
|
5
|
-
/**
|
6
|
-
* @name layoutSection_node
|
7
|
-
*/
|
8
|
-
export type LayoutSectionBaseDefinition = {
|
9
|
-
type: 'layoutSection';
|
10
|
-
marks?: Array<BreakoutMarkDefinition>;
|
11
|
-
// Can't use Array<any> because `prosemirror-schema-compatibility-tests` can't handle it.
|
12
|
-
content: Array<LayoutColumnDefinition>;
|
13
|
-
};
|
14
|
-
|
15
|
-
/**
|
16
|
-
* Need duplicate `type` and `marks` to make both validator and json-schema satisfied
|
17
|
-
*/
|
18
|
-
|
19
|
-
/**
|
20
|
-
* @name layoutSection_full_node
|
21
|
-
*/
|
22
|
-
export type LayoutSectionFullDefinition = LayoutSectionBaseDefinition & {
|
23
|
-
type: 'layoutSection';
|
24
|
-
marks?: Array<BreakoutMarkDefinition>;
|
25
|
-
/**
|
26
|
-
* @minItems 2
|
27
|
-
* @maxItems 3
|
28
|
-
* @allowUnsupportedBlock true
|
29
|
-
*/
|
30
|
-
content: Array<LayoutColumnDefinition>;
|
31
|
-
};
|
32
|
-
|
33
|
-
/**
|
34
|
-
* @stage 0
|
35
|
-
* @name layoutSection_with_single_column_node
|
36
|
-
*/
|
37
|
-
export type LayoutSectionWithSingleColumnDefinition =
|
38
|
-
LayoutSectionBaseDefinition & {
|
39
|
-
type: 'layoutSection';
|
40
|
-
marks?: Array<BreakoutMarkDefinition>;
|
41
|
-
/**
|
42
|
-
* @minItems 1
|
43
|
-
* @maxItems 3
|
44
|
-
* @allowUnsupportedBlock true
|
45
|
-
*/
|
46
|
-
content: Array<LayoutColumnDefinition>;
|
47
|
-
};
|
48
|
-
|
49
|
-
export type LayoutSectionDefinition =
|
50
|
-
| LayoutSectionFullDefinition
|
51
|
-
| LayoutSectionWithSingleColumnDefinition;
|
52
|
-
|
53
|
-
export const layoutSection: NodeSpec = {
|
54
|
-
content:
|
55
|
-
'(layoutColumn | unsupportedBlock){1,3} unsupportedBlock* | unsupportedBlock+',
|
56
|
-
marks: 'unsupportedMark unsupportedNodeAttribute',
|
57
|
-
isolating: true,
|
58
|
-
parseDOM: [
|
59
|
-
{
|
60
|
-
context: 'layoutSection//|layoutColumn//',
|
61
|
-
tag: 'div[data-layout-section]',
|
62
|
-
skip: true,
|
63
|
-
},
|
64
|
-
{
|
65
|
-
tag: 'div[data-layout-section]',
|
66
|
-
},
|
67
|
-
],
|
68
|
-
toDOM() {
|
69
|
-
const attrs = { 'data-layout-section': 'true' };
|
70
|
-
return ['div', attrs, 0];
|
71
|
-
},
|
72
|
-
};
|
73
|
-
|
74
|
-
export const layoutSectionWithSingleColumn: NodeSpec = {
|
75
|
-
content:
|
76
|
-
'(layoutColumn | unsupportedBlock){1,3} unsupportedBlock* | unsupportedBlock+',
|
77
|
-
marks: 'unsupportedMark unsupportedNodeAttribute',
|
78
|
-
isolating: true,
|
79
|
-
parseDOM: [
|
80
|
-
{
|
81
|
-
context: 'layoutSection//|layoutColumn//',
|
82
|
-
tag: 'div[data-layout-section]',
|
83
|
-
skip: true,
|
84
|
-
},
|
85
|
-
{
|
86
|
-
tag: 'div[data-layout-section]',
|
87
|
-
},
|
88
|
-
],
|
89
|
-
toDOM() {
|
90
|
-
const attrs = { 'data-layout-section': 'true' };
|
91
|
-
return ['div', attrs, 0];
|
92
|
-
},
|
93
|
-
};
|
@@ -1,13 +0,0 @@
|
|
1
|
-
import { NodeSpec } from '@atlaskit/editor-prosemirror/model';
|
2
|
-
|
3
|
-
export const listItem: NodeSpec = {
|
4
|
-
content:
|
5
|
-
'(paragraph | mediaSingle | codeBlock | unsupportedBlock) (paragraph | bulletList | orderedList | mediaSingle | codeBlock | unsupportedBlock)*',
|
6
|
-
marks: 'unsupportedMark unsupportedNodeAttribute',
|
7
|
-
defining: true,
|
8
|
-
selectable: false,
|
9
|
-
parseDOM: [{ tag: 'li' }],
|
10
|
-
toDOM() {
|
11
|
-
return ['li', 0];
|
12
|
-
},
|
13
|
-
};
|
@@ -1,44 +0,0 @@
|
|
1
|
-
import { NodeSpec } from '@atlaskit/editor-prosemirror/model';
|
2
|
-
import { MediaDefinition as Media } from './media';
|
3
|
-
|
4
|
-
/**
|
5
|
-
* @name mediaGroup_node
|
6
|
-
*/
|
7
|
-
export interface MediaGroupDefinition {
|
8
|
-
type: 'mediaGroup';
|
9
|
-
/**
|
10
|
-
* @minItems 1
|
11
|
-
* @allowUnsupportedBlock true
|
12
|
-
*/
|
13
|
-
content: Array<Media>;
|
14
|
-
}
|
15
|
-
|
16
|
-
// Temporary due to an existing issue in validator below:
|
17
|
-
// https://product-fabric.atlassian.net/jira/servicedesk/projects/DTR/queues/issue/DTR-1429
|
18
|
-
// TODO: Remove border and link marks from white list
|
19
|
-
export const mediaGroup: NodeSpec = {
|
20
|
-
inline: false,
|
21
|
-
group: 'block',
|
22
|
-
content: '(media|unsupportedBlock)+',
|
23
|
-
attrs: {},
|
24
|
-
marks: 'unsupportedMark unsupportedNodeAttribute border link',
|
25
|
-
selectable: false,
|
26
|
-
parseDOM: [
|
27
|
-
{
|
28
|
-
tag: 'div[data-node-type="mediaGroup"]',
|
29
|
-
},
|
30
|
-
{
|
31
|
-
tag: 'div[class="MediaGroup"]',
|
32
|
-
},
|
33
|
-
],
|
34
|
-
|
35
|
-
toDOM() {
|
36
|
-
return [
|
37
|
-
'div',
|
38
|
-
{
|
39
|
-
'data-node-type': 'mediaGroup',
|
40
|
-
},
|
41
|
-
0,
|
42
|
-
];
|
43
|
-
},
|
44
|
-
};
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import { NodeSpec } from '@atlaskit/editor-prosemirror/model';
|
2
|
-
import { LinkDefinition } from '../marks/link';
|
3
|
-
import { createMediaSpec, defaultAttrs, MediaBaseAttributes } from './media';
|
4
|
-
|
5
|
-
export interface MediaInlineAttributes extends MediaBaseAttributes {
|
6
|
-
data?: object;
|
7
|
-
type?: 'file' | 'link';
|
8
|
-
}
|
9
|
-
|
10
|
-
/**
|
11
|
-
* @name mediaInline_node
|
12
|
-
*/
|
13
|
-
export interface MediaInlineDefinition {
|
14
|
-
type: 'mediaInline';
|
15
|
-
attrs: MediaInlineAttributes;
|
16
|
-
marks?: Array<LinkDefinition>;
|
17
|
-
}
|
18
|
-
|
19
|
-
export const mediaInline: NodeSpec = createMediaSpec(defaultAttrs, true);
|
@@ -1,179 +0,0 @@
|
|
1
|
-
import { NodeSpec, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
2
|
-
import { MediaDefinition as Media } from './media';
|
3
|
-
import { LinkDefinition } from '../marks/link';
|
4
|
-
|
5
|
-
import { ExtendedMediaAttributes, WidthType } from './types/rich-media-common';
|
6
|
-
import { CaptionDefinition as Caption } from './caption';
|
7
|
-
import { isDOMElement } from '../../utils/parseDOM';
|
8
|
-
|
9
|
-
export type MediaSingleDefinition =
|
10
|
-
| MediaSingleFullDefinition
|
11
|
-
| MediaSingleWithCaptionDefinition;
|
12
|
-
|
13
|
-
/**
|
14
|
-
* @name mediaSingle_node
|
15
|
-
* @additionalProperties true
|
16
|
-
*/
|
17
|
-
export interface MediaSingleBaseDefinition {
|
18
|
-
type: 'mediaSingle';
|
19
|
-
attrs?: ExtendedMediaAttributes;
|
20
|
-
marks?: Array<LinkDefinition>;
|
21
|
-
}
|
22
|
-
|
23
|
-
/**
|
24
|
-
* @additionalProperties true
|
25
|
-
*/
|
26
|
-
export interface MediaCaptionContent {
|
27
|
-
/**
|
28
|
-
* @minItems 1
|
29
|
-
* @maxItems 2
|
30
|
-
* @allowUnsupportedBlock true
|
31
|
-
*/
|
32
|
-
content: [Media, Caption?];
|
33
|
-
}
|
34
|
-
/**
|
35
|
-
* @name mediaSingle_caption_node
|
36
|
-
*/
|
37
|
-
export type MediaSingleWithCaptionDefinition = MediaSingleBaseDefinition &
|
38
|
-
MediaCaptionContent;
|
39
|
-
|
40
|
-
/**
|
41
|
-
* @additionalProperties true
|
42
|
-
*/
|
43
|
-
export interface MediaSingleFullContent {
|
44
|
-
/**
|
45
|
-
* @minItems 1
|
46
|
-
* @maxItems 1
|
47
|
-
* @allowUnsupportedBlock true
|
48
|
-
*/
|
49
|
-
content: Array<Media>;
|
50
|
-
}
|
51
|
-
|
52
|
-
/**
|
53
|
-
* @name mediaSingle_full_node
|
54
|
-
*/
|
55
|
-
export type MediaSingleFullDefinition = MediaSingleBaseDefinition &
|
56
|
-
MediaSingleFullContent;
|
57
|
-
|
58
|
-
export const defaultAttrs: {
|
59
|
-
width: {
|
60
|
-
default: null;
|
61
|
-
};
|
62
|
-
layout: {
|
63
|
-
default: string;
|
64
|
-
};
|
65
|
-
} = {
|
66
|
-
width: { default: null }, // null makes small images to have original size by default
|
67
|
-
layout: { default: 'center' },
|
68
|
-
};
|
69
|
-
|
70
|
-
export const mediaSingleSpec = ({
|
71
|
-
withCaption = false,
|
72
|
-
withExtendedWidthTypes = false,
|
73
|
-
}: {
|
74
|
-
withCaption?: boolean | undefined;
|
75
|
-
withExtendedWidthTypes?: boolean | undefined;
|
76
|
-
}): NodeSpec => {
|
77
|
-
const content = withCaption
|
78
|
-
? 'media|unsupportedBlock+|media (caption|unsupportedBlock) unsupportedBlock*'
|
79
|
-
: 'media|unsupportedBlock+|media unsupportedBlock+';
|
80
|
-
|
81
|
-
const atom = !withCaption;
|
82
|
-
|
83
|
-
const getAttrs = (dom: string | Node) => {
|
84
|
-
if (!isDOMElement(dom)) {
|
85
|
-
// this should never happen
|
86
|
-
return { layout: 'center' };
|
87
|
-
}
|
88
|
-
|
89
|
-
const layout = dom.getAttribute('data-layout') || 'center';
|
90
|
-
const width = Number(dom.getAttribute('data-width')) || null;
|
91
|
-
const widthType = dom.getAttribute('data-width-type');
|
92
|
-
|
93
|
-
if (withExtendedWidthTypes) {
|
94
|
-
return { layout, width, widthType };
|
95
|
-
} else if (widthType === WidthType.PIXEL) {
|
96
|
-
// if editor does not support widthType attribute.
|
97
|
-
// We ignore width and widthType together.
|
98
|
-
return { layout };
|
99
|
-
} else {
|
100
|
-
return { layout, width };
|
101
|
-
}
|
102
|
-
};
|
103
|
-
|
104
|
-
const getAttrsFromNode = (node: PMNode) => {
|
105
|
-
const { layout, width } = node.attrs;
|
106
|
-
const attrs = {
|
107
|
-
'data-node-type': 'mediaSingle',
|
108
|
-
'data-layout': layout,
|
109
|
-
'data-width': '',
|
110
|
-
};
|
111
|
-
|
112
|
-
if (width) {
|
113
|
-
attrs['data-width'] =
|
114
|
-
isFinite(width) && Math.floor(width) === width
|
115
|
-
? width
|
116
|
-
: width.toFixed(2);
|
117
|
-
}
|
118
|
-
|
119
|
-
if (withExtendedWidthTypes && node.attrs.widthType) {
|
120
|
-
const { widthType } = node.attrs;
|
121
|
-
return {
|
122
|
-
...attrs,
|
123
|
-
'data-width-type': widthType || WidthType.PERCENTAGE,
|
124
|
-
};
|
125
|
-
}
|
126
|
-
|
127
|
-
return attrs;
|
128
|
-
};
|
129
|
-
|
130
|
-
return {
|
131
|
-
inline: false,
|
132
|
-
group: 'block',
|
133
|
-
selectable: true,
|
134
|
-
atom,
|
135
|
-
content,
|
136
|
-
attrs: withExtendedWidthTypes
|
137
|
-
? { ...defaultAttrs, widthType: { default: null } }
|
138
|
-
: defaultAttrs,
|
139
|
-
marks: 'unsupportedMark unsupportedNodeAttribute border link',
|
140
|
-
parseDOM: [
|
141
|
-
{
|
142
|
-
tag: 'div[data-node-type="mediaSingle"]',
|
143
|
-
getAttrs,
|
144
|
-
},
|
145
|
-
],
|
146
|
-
toDOM(node: PMNode) {
|
147
|
-
return ['div', getAttrsFromNode(node), 0];
|
148
|
-
},
|
149
|
-
};
|
150
|
-
};
|
151
|
-
|
152
|
-
export const mediaSingle: NodeSpec = mediaSingleSpec({
|
153
|
-
withCaption: false,
|
154
|
-
withExtendedWidthTypes: false,
|
155
|
-
});
|
156
|
-
|
157
|
-
export const mediaSingleWithCaption: NodeSpec = mediaSingleSpec({
|
158
|
-
withCaption: true,
|
159
|
-
withExtendedWidthTypes: false,
|
160
|
-
});
|
161
|
-
|
162
|
-
export const mediaSingleWithWidthType: NodeSpec = mediaSingleSpec({
|
163
|
-
withCaption: false,
|
164
|
-
withExtendedWidthTypes: true,
|
165
|
-
});
|
166
|
-
|
167
|
-
export const mediaSingleFull: NodeSpec = mediaSingleSpec({
|
168
|
-
withCaption: true,
|
169
|
-
withExtendedWidthTypes: true,
|
170
|
-
});
|
171
|
-
|
172
|
-
export const toJSON = (node: PMNode) => ({
|
173
|
-
attrs: Object.keys(node.attrs).reduce<any>((obj, key) => {
|
174
|
-
if (node.attrs[key] !== null) {
|
175
|
-
obj[key] = node.attrs[key];
|
176
|
-
}
|
177
|
-
return obj;
|
178
|
-
}, {}),
|
179
|
-
});
|
@@ -1,253 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
NodeSpec,
|
3
|
-
Node as PMNode,
|
4
|
-
ParseRule,
|
5
|
-
} from '@atlaskit/editor-prosemirror/model';
|
6
|
-
import { N30 } from '../../utils/colors';
|
7
|
-
import { BorderMarkDefinition } from '../marks/border';
|
8
|
-
import { LinkDefinition } from '../marks/link';
|
9
|
-
|
10
|
-
export type MediaType = 'file' | 'link' | 'external';
|
11
|
-
export type DisplayType = 'file' | 'thumbnail';
|
12
|
-
|
13
|
-
export type DefaultAttributes<T> = {
|
14
|
-
[P in keyof T]: {
|
15
|
-
default?: T[P] | null;
|
16
|
-
};
|
17
|
-
};
|
18
|
-
|
19
|
-
/**
|
20
|
-
* @name media_node
|
21
|
-
*/
|
22
|
-
export interface MediaDefinition {
|
23
|
-
type: 'media';
|
24
|
-
/**
|
25
|
-
* @minItems 1
|
26
|
-
*/
|
27
|
-
attrs: MediaADFAttrs;
|
28
|
-
|
29
|
-
marks?: Array<LinkDefinition | BorderMarkDefinition>;
|
30
|
-
}
|
31
|
-
|
32
|
-
export interface MediaBaseAttributes {
|
33
|
-
/**
|
34
|
-
* @minLength 1
|
35
|
-
*/
|
36
|
-
id: string;
|
37
|
-
collection: string;
|
38
|
-
height?: number;
|
39
|
-
width?: number;
|
40
|
-
/**
|
41
|
-
* @minLength 1
|
42
|
-
*/
|
43
|
-
occurrenceKey?: string;
|
44
|
-
alt?: string;
|
45
|
-
// For both CQ and JIRA
|
46
|
-
__fileName?: string | null;
|
47
|
-
// For CQ
|
48
|
-
__fileSize?: number | null;
|
49
|
-
__fileMimeType?: string | null;
|
50
|
-
// For JIRA
|
51
|
-
__displayType?: DisplayType | null;
|
52
|
-
// For copy & paste
|
53
|
-
__contextId?: string | null;
|
54
|
-
// For tracing media operations
|
55
|
-
__mediaTraceId?: string | null;
|
56
|
-
|
57
|
-
// is set to true when new external media is inserted, false for external media in existing documents
|
58
|
-
__external?: boolean;
|
59
|
-
}
|
60
|
-
|
61
|
-
export interface MediaAttributes extends MediaBaseAttributes {
|
62
|
-
type: 'file' | 'link';
|
63
|
-
}
|
64
|
-
|
65
|
-
export interface ExternalMediaAttributes {
|
66
|
-
type: 'external';
|
67
|
-
url: string;
|
68
|
-
alt?: string;
|
69
|
-
width?: number;
|
70
|
-
height?: number;
|
71
|
-
__external?: boolean;
|
72
|
-
}
|
73
|
-
|
74
|
-
export type MediaADFAttrs = MediaAttributes | ExternalMediaAttributes;
|
75
|
-
|
76
|
-
export const defaultAttrs: DefaultAttributes<MediaADFAttrs> = {
|
77
|
-
id: { default: '' },
|
78
|
-
type: { default: 'file' },
|
79
|
-
collection: { default: '' },
|
80
|
-
occurrenceKey: { default: null },
|
81
|
-
alt: { default: '' },
|
82
|
-
width: { default: null },
|
83
|
-
height: { default: null },
|
84
|
-
url: { default: null },
|
85
|
-
__fileName: { default: null },
|
86
|
-
__fileSize: { default: null },
|
87
|
-
__fileMimeType: { default: null },
|
88
|
-
__displayType: { default: null },
|
89
|
-
__contextId: { default: null },
|
90
|
-
__mediaTraceId: { default: null },
|
91
|
-
__external: { default: false },
|
92
|
-
};
|
93
|
-
|
94
|
-
interface MutableMediaAttributes extends MediaAttributes {
|
95
|
-
[key: string]: string | number | undefined | null | boolean;
|
96
|
-
}
|
97
|
-
|
98
|
-
export const createMediaSpec = (
|
99
|
-
attributes: Partial<NodeSpec['attrs']>,
|
100
|
-
inline: boolean = false,
|
101
|
-
): NodeSpec => {
|
102
|
-
const domNodeType = inline ? 'span' : 'div';
|
103
|
-
const nodeName = inline ? 'mediaInline' : 'media';
|
104
|
-
const parseDOM: ParseRule[] = [
|
105
|
-
{
|
106
|
-
tag: `${domNodeType}[data-node-type="${nodeName}"]`,
|
107
|
-
getAttrs: (dom) => {
|
108
|
-
const attrs = {} as MutableMediaAttributes;
|
109
|
-
|
110
|
-
if (attributes) {
|
111
|
-
Object.keys(attributes).forEach((k) => {
|
112
|
-
const key = camelCaseToKebabCase(k).replace(/^__/, '');
|
113
|
-
const value =
|
114
|
-
(dom as HTMLElement).getAttribute(`data-${key}`) || '';
|
115
|
-
if (value) {
|
116
|
-
attrs[k] = value;
|
117
|
-
}
|
118
|
-
});
|
119
|
-
}
|
120
|
-
|
121
|
-
// Need to do validation & type conversion manually
|
122
|
-
if (attrs.__fileSize) {
|
123
|
-
attrs.__fileSize = +attrs.__fileSize;
|
124
|
-
}
|
125
|
-
|
126
|
-
const width = Number(attrs.width);
|
127
|
-
if (typeof width !== 'undefined' && !isNaN(width)) {
|
128
|
-
attrs.width = width;
|
129
|
-
}
|
130
|
-
|
131
|
-
const height = Number(attrs.height);
|
132
|
-
if (typeof height !== 'undefined' && !isNaN(height)) {
|
133
|
-
attrs.height = height;
|
134
|
-
}
|
135
|
-
|
136
|
-
return attrs as MediaAttributes;
|
137
|
-
},
|
138
|
-
},
|
139
|
-
// Don't match data URI
|
140
|
-
{
|
141
|
-
tag: 'img[src^="data:image"]',
|
142
|
-
ignore: true,
|
143
|
-
},
|
144
|
-
];
|
145
|
-
|
146
|
-
// media-inline.ts uses this same function to generate the nodespec
|
147
|
-
// this ensures that we don't make a media inline out of a copied image
|
148
|
-
// https://product-fabric.atlassian.net/browse/EDM-2996
|
149
|
-
if (!inline) {
|
150
|
-
parseDOM.push({
|
151
|
-
tag: 'img:not(.smart-link-icon)',
|
152
|
-
getAttrs: (dom) => {
|
153
|
-
return {
|
154
|
-
type: 'external',
|
155
|
-
url: (dom as HTMLElement).getAttribute('src') || '',
|
156
|
-
alt: (dom as HTMLElement).getAttribute('alt') || '',
|
157
|
-
} as ExternalMediaAttributes;
|
158
|
-
},
|
159
|
-
});
|
160
|
-
}
|
161
|
-
|
162
|
-
return {
|
163
|
-
selectable: true,
|
164
|
-
inline,
|
165
|
-
group: inline ? 'inline' : undefined,
|
166
|
-
attrs: attributes as NodeSpec['attrs'],
|
167
|
-
parseDOM,
|
168
|
-
toDOM(node: PMNode) {
|
169
|
-
const attrs = {
|
170
|
-
'data-id': node.attrs.id,
|
171
|
-
'data-node-type': `${nodeName}`,
|
172
|
-
'data-type': node.attrs.type,
|
173
|
-
'data-collection': node.attrs.collection,
|
174
|
-
'data-occurrence-key': node.attrs.occurrenceKey,
|
175
|
-
'data-width': node.attrs.width,
|
176
|
-
'data-height': node.attrs.height,
|
177
|
-
'data-url': node.attrs.url,
|
178
|
-
'data-alt': node.attrs.alt,
|
179
|
-
// toDOM is used for static rendering as well as editor rendering. This comes into play for
|
180
|
-
// emails, copy/paste, etc, so the title and styling here *is* useful (despite a React-based
|
181
|
-
// node view being used for editing).
|
182
|
-
title: 'Attachment',
|
183
|
-
// Manually kept in sync with the style of media cards. The goal is to render a plain gray
|
184
|
-
// rectangle that provides an affordance for media.
|
185
|
-
style: `display: inline-block; border-radius: 3px; background: ${N30}; box-shadow: 0 1px 1px rgba(9, 30, 66, 0.2), 0 0 1px 0 rgba(9, 30, 66, 0.24);`,
|
186
|
-
};
|
187
|
-
|
188
|
-
copyPrivateAttributes(
|
189
|
-
node.attrs,
|
190
|
-
attrs,
|
191
|
-
(key) => `data-${camelCaseToKebabCase(key.slice(2))}`,
|
192
|
-
);
|
193
|
-
|
194
|
-
return [`${domNodeType}`, attrs];
|
195
|
-
},
|
196
|
-
};
|
197
|
-
};
|
198
|
-
|
199
|
-
export const media: NodeSpec = createMediaSpec(defaultAttrs);
|
200
|
-
|
201
|
-
export const camelCaseToKebabCase = (str: string) =>
|
202
|
-
str.replace(/([^A-Z]+)([A-Z])/g, (_, x, y) => `${x}-${y.toLowerCase()}`);
|
203
|
-
|
204
|
-
export const copyPrivateAttributes: (
|
205
|
-
from: Record<string, any>,
|
206
|
-
to: Record<string, any>,
|
207
|
-
map?: ((str: string) => string) | undefined,
|
208
|
-
) => void = (
|
209
|
-
from: Record<string, any>,
|
210
|
-
to: Record<string, any>,
|
211
|
-
map?: (str: string) => string,
|
212
|
-
) => {
|
213
|
-
if (media.attrs) {
|
214
|
-
Object.keys(media.attrs).forEach((key) => {
|
215
|
-
if (key[0] === '_' && key[1] === '_' && from[key]) {
|
216
|
-
to[map ? map(key) : key] = from[key];
|
217
|
-
}
|
218
|
-
});
|
219
|
-
}
|
220
|
-
};
|
221
|
-
|
222
|
-
/**
|
223
|
-
* There's no concept of optional property in ProseMirror. It sets value as `null`
|
224
|
-
* when there's no use of any property. We are filtering out all private & optional attrs here.
|
225
|
-
*/
|
226
|
-
const optionalAttributes = ['occurrenceKey', 'width', 'height', 'url', 'alt'];
|
227
|
-
const externalOnlyAttributes = ['type', 'url', 'width', 'height', 'alt'];
|
228
|
-
|
229
|
-
export const toJSON = (node: PMNode) => ({
|
230
|
-
attrs: Object.keys(node.attrs)
|
231
|
-
// Strip private attributes e.g. __fileName, __fileSize, __fileMimeType, etc.
|
232
|
-
.filter((key) => !(key[0] === '_' && key[1] === '_'))
|
233
|
-
.reduce<Record<string, any>>((obj, key) => {
|
234
|
-
if (
|
235
|
-
node.attrs.type === 'external' &&
|
236
|
-
externalOnlyAttributes.indexOf(key) === -1
|
237
|
-
) {
|
238
|
-
return obj;
|
239
|
-
}
|
240
|
-
if (
|
241
|
-
optionalAttributes.indexOf(key) > -1 &&
|
242
|
-
(node.attrs[key] === null || node.attrs[key] === '')
|
243
|
-
) {
|
244
|
-
return obj;
|
245
|
-
}
|
246
|
-
if (['width', 'height'].indexOf(key) !== -1) {
|
247
|
-
obj[key] = Number(node.attrs[key]);
|
248
|
-
return obj;
|
249
|
-
}
|
250
|
-
obj[key] = node.attrs[key];
|
251
|
-
return obj;
|
252
|
-
}, {}),
|
253
|
-
});
|
@@ -1,86 +0,0 @@
|
|
1
|
-
import { NodeSpec, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
2
|
-
|
3
|
-
export enum USER_TYPES {
|
4
|
-
DEFAULT = 'DEFAULT',
|
5
|
-
SPECIAL = 'SPECIAL',
|
6
|
-
APP = 'APP',
|
7
|
-
}
|
8
|
-
|
9
|
-
export type UserType = keyof typeof USER_TYPES;
|
10
|
-
|
11
|
-
export interface MentionAttributes {
|
12
|
-
id: string;
|
13
|
-
text?: string;
|
14
|
-
userType?: UserType;
|
15
|
-
accessLevel?: string;
|
16
|
-
}
|
17
|
-
|
18
|
-
/**
|
19
|
-
* @name mention_node
|
20
|
-
*/
|
21
|
-
export interface MentionDefinition {
|
22
|
-
type: 'mention';
|
23
|
-
attrs: MentionAttributes;
|
24
|
-
}
|
25
|
-
|
26
|
-
export const mention: NodeSpec = {
|
27
|
-
inline: true,
|
28
|
-
group: 'inline',
|
29
|
-
selectable: true,
|
30
|
-
attrs: {
|
31
|
-
id: { default: '' },
|
32
|
-
text: { default: '' },
|
33
|
-
accessLevel: { default: '' },
|
34
|
-
userType: { default: null },
|
35
|
-
},
|
36
|
-
parseDOM: [
|
37
|
-
{
|
38
|
-
tag: 'span[data-mention-id]',
|
39
|
-
getAttrs: (domNode) => {
|
40
|
-
const dom = domNode as HTMLElement;
|
41
|
-
const attrs: MentionAttributes = {
|
42
|
-
id: dom.getAttribute('data-mention-id') || mention.attrs!.id.default,
|
43
|
-
text: dom.textContent || mention.attrs!.text.default,
|
44
|
-
accessLevel:
|
45
|
-
dom.getAttribute('data-access-level') ||
|
46
|
-
mention.attrs!.accessLevel.default,
|
47
|
-
};
|
48
|
-
|
49
|
-
const userType = dom.getAttribute('data-user-type') as USER_TYPES;
|
50
|
-
if (USER_TYPES[userType]) {
|
51
|
-
attrs.userType = userType;
|
52
|
-
}
|
53
|
-
|
54
|
-
return attrs;
|
55
|
-
},
|
56
|
-
},
|
57
|
-
],
|
58
|
-
toDOM(node) {
|
59
|
-
const { id, accessLevel, text, userType } = node.attrs;
|
60
|
-
const attrs: any = {
|
61
|
-
'data-mention-id': id,
|
62
|
-
'data-access-level': accessLevel,
|
63
|
-
contenteditable: 'false',
|
64
|
-
};
|
65
|
-
if (userType) {
|
66
|
-
attrs['data-user-type'] = userType;
|
67
|
-
}
|
68
|
-
return ['span', attrs, text];
|
69
|
-
},
|
70
|
-
};
|
71
|
-
|
72
|
-
const isOptional = (key: string) => {
|
73
|
-
return ['userType'].indexOf(key) > -1;
|
74
|
-
};
|
75
|
-
|
76
|
-
export const toJSON = (node: PMNode) => ({
|
77
|
-
attrs: Object.keys(node.attrs).reduce<typeof node.attrs>((obj, key) => {
|
78
|
-
if (isOptional(key) && !node.attrs[key]) {
|
79
|
-
return obj;
|
80
|
-
}
|
81
|
-
return {
|
82
|
-
...obj,
|
83
|
-
[key]: node.attrs[key],
|
84
|
-
};
|
85
|
-
}, {}),
|
86
|
-
});
|