@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,76 +0,0 @@
|
|
1
|
-
import { createSchema } from './create-schema';
|
2
|
-
import { Schema } from '@atlaskit/editor-prosemirror/model';
|
3
|
-
|
4
|
-
const nodes = [
|
5
|
-
'doc',
|
6
|
-
'paragraph',
|
7
|
-
'blockquote',
|
8
|
-
'codeBlock',
|
9
|
-
'panel',
|
10
|
-
'hardBreak',
|
11
|
-
'orderedList',
|
12
|
-
'bulletList',
|
13
|
-
'heading',
|
14
|
-
'mediaInline',
|
15
|
-
'mediaGroup',
|
16
|
-
'mediaSingle',
|
17
|
-
'media',
|
18
|
-
'caption',
|
19
|
-
'confluenceUnsupportedBlock',
|
20
|
-
'confluenceJiraIssue',
|
21
|
-
'expand',
|
22
|
-
'nestedExpand',
|
23
|
-
'extension',
|
24
|
-
'inlineExtension',
|
25
|
-
'bodiedExtension',
|
26
|
-
'listItem',
|
27
|
-
'mention',
|
28
|
-
'text',
|
29
|
-
'confluenceUnsupportedInline',
|
30
|
-
'media',
|
31
|
-
'rule',
|
32
|
-
'table',
|
33
|
-
'tableCell',
|
34
|
-
'tableHeader',
|
35
|
-
'tableRow',
|
36
|
-
'emoji',
|
37
|
-
'taskList',
|
38
|
-
'taskItem',
|
39
|
-
'date',
|
40
|
-
'placeholder',
|
41
|
-
'decisionList',
|
42
|
-
'decisionItem',
|
43
|
-
'layoutSection',
|
44
|
-
'layoutColumn',
|
45
|
-
'inlineCard',
|
46
|
-
'unsupportedBlock',
|
47
|
-
'unsupportedInline',
|
48
|
-
];
|
49
|
-
|
50
|
-
const marks = [
|
51
|
-
'link',
|
52
|
-
'em',
|
53
|
-
'strong',
|
54
|
-
'strike',
|
55
|
-
'subsup',
|
56
|
-
'underline',
|
57
|
-
'mentionQuery',
|
58
|
-
'code',
|
59
|
-
'textColor',
|
60
|
-
'confluenceInlineComment',
|
61
|
-
'annotation',
|
62
|
-
'unsupportedMark',
|
63
|
-
'unsupportedNodeAttribute',
|
64
|
-
];
|
65
|
-
|
66
|
-
/**
|
67
|
-
* @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
|
68
|
-
**/
|
69
|
-
export const confluenceSchema: Schema = createSchema({ nodes, marks });
|
70
|
-
/**
|
71
|
-
* @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
|
72
|
-
**/
|
73
|
-
export const confluenceSchemaWithMediaSingle: Schema = createSchema({
|
74
|
-
nodes: nodes.concat('mediaSingle'),
|
75
|
-
marks,
|
76
|
-
});
|
@@ -1,337 +0,0 @@
|
|
1
|
-
import { NodeSpec, MarkSpec, Schema } from '@atlaskit/editor-prosemirror/model';
|
2
|
-
import { COLOR, FONT_STYLE, SEARCH_QUERY, LINK } from './groups';
|
3
|
-
|
4
|
-
import {
|
5
|
-
link,
|
6
|
-
em,
|
7
|
-
strong,
|
8
|
-
textColor,
|
9
|
-
strike,
|
10
|
-
subsup,
|
11
|
-
underline,
|
12
|
-
code,
|
13
|
-
typeAheadQuery,
|
14
|
-
confluenceInlineComment,
|
15
|
-
breakout,
|
16
|
-
alignment,
|
17
|
-
indentation,
|
18
|
-
annotation,
|
19
|
-
unsupportedMark,
|
20
|
-
unsupportedNodeAttribute,
|
21
|
-
dataConsumer,
|
22
|
-
fragment,
|
23
|
-
border,
|
24
|
-
} from './marks';
|
25
|
-
|
26
|
-
import {
|
27
|
-
confluenceJiraIssue,
|
28
|
-
confluenceUnsupportedBlock,
|
29
|
-
confluenceUnsupportedInline,
|
30
|
-
doc,
|
31
|
-
paragraph,
|
32
|
-
text,
|
33
|
-
bulletList,
|
34
|
-
orderedListWithOrder,
|
35
|
-
listItem,
|
36
|
-
heading,
|
37
|
-
blockquote,
|
38
|
-
codeBlock,
|
39
|
-
panel,
|
40
|
-
rule,
|
41
|
-
image,
|
42
|
-
mention,
|
43
|
-
media,
|
44
|
-
mediaInline,
|
45
|
-
mediaSingleWithCaption,
|
46
|
-
mediaGroup,
|
47
|
-
hardBreak,
|
48
|
-
emoji,
|
49
|
-
table,
|
50
|
-
tableCell,
|
51
|
-
tableHeader,
|
52
|
-
tableRow,
|
53
|
-
decisionList,
|
54
|
-
decisionItem,
|
55
|
-
taskList,
|
56
|
-
taskItem,
|
57
|
-
unknownBlock,
|
58
|
-
extension,
|
59
|
-
inlineExtension,
|
60
|
-
bodiedExtension,
|
61
|
-
date,
|
62
|
-
placeholder,
|
63
|
-
layoutSection,
|
64
|
-
layoutColumn,
|
65
|
-
inlineCard,
|
66
|
-
blockCard,
|
67
|
-
unsupportedBlock,
|
68
|
-
unsupportedInline,
|
69
|
-
status,
|
70
|
-
expand,
|
71
|
-
nestedExpand,
|
72
|
-
embedCard,
|
73
|
-
caption,
|
74
|
-
} from './nodes';
|
75
|
-
|
76
|
-
function addItems(
|
77
|
-
builtInItems: SchemaBuiltInItem[],
|
78
|
-
config: string[],
|
79
|
-
customSpecs: SchemaCustomNodeSpecs | SchemaCustomMarkSpecs = {},
|
80
|
-
) {
|
81
|
-
if (!config) {
|
82
|
-
return {};
|
83
|
-
}
|
84
|
-
|
85
|
-
/**
|
86
|
-
* Add built-in Node / Mark specs
|
87
|
-
*/
|
88
|
-
const items = builtInItems.reduce<Record<string, NodeSpec | MarkSpec>>(
|
89
|
-
(items, { name, spec }) => {
|
90
|
-
if (config.indexOf(name) !== -1) {
|
91
|
-
items[name] = customSpecs[name] || spec;
|
92
|
-
}
|
93
|
-
|
94
|
-
return items;
|
95
|
-
},
|
96
|
-
{},
|
97
|
-
);
|
98
|
-
|
99
|
-
/**
|
100
|
-
* Add Custom Node / Mark specs
|
101
|
-
*/
|
102
|
-
return Object.keys(customSpecs).reduce((items, name) => {
|
103
|
-
if (items[name]) {
|
104
|
-
return items;
|
105
|
-
}
|
106
|
-
|
107
|
-
items[name] = customSpecs[name];
|
108
|
-
|
109
|
-
return items;
|
110
|
-
}, items);
|
111
|
-
}
|
112
|
-
|
113
|
-
// We use groups to allow schemas to be constructed in different shapes without changing node/mark
|
114
|
-
// specs, but this means nodes/marks are defined with groups that might never be used in the schema.
|
115
|
-
// In this scenario ProseMirror will complain and prevent the schema from being constructed.
|
116
|
-
//
|
117
|
-
// To avoid the problem, we include items that serve to "declare" the groups in the schema. This
|
118
|
-
// approach unfortunately leaves unused items in the schema, but has the benefit of avoiding the
|
119
|
-
// need to manipulate `exclude` or content expression values for potentially every schema item.
|
120
|
-
function groupDeclaration(name: string) {
|
121
|
-
return {
|
122
|
-
name: `__${name}GroupDeclaration`,
|
123
|
-
spec: {
|
124
|
-
group: name,
|
125
|
-
},
|
126
|
-
};
|
127
|
-
}
|
128
|
-
|
129
|
-
const markGroupDeclarations = [
|
130
|
-
groupDeclaration(COLOR),
|
131
|
-
groupDeclaration(FONT_STYLE),
|
132
|
-
groupDeclaration(SEARCH_QUERY),
|
133
|
-
groupDeclaration(LINK),
|
134
|
-
];
|
135
|
-
|
136
|
-
const markGroupDeclarationsNames = markGroupDeclarations.map(
|
137
|
-
(groupMark) => groupMark.name,
|
138
|
-
);
|
139
|
-
|
140
|
-
const nodesInOrder: SchemaBuiltInItem[] = [
|
141
|
-
{ name: 'doc', spec: doc },
|
142
|
-
{ name: 'paragraph', spec: paragraph },
|
143
|
-
{ name: 'text', spec: text },
|
144
|
-
{ name: 'bulletList', spec: bulletList },
|
145
|
-
{ name: 'orderedList', spec: orderedListWithOrder },
|
146
|
-
{ name: 'listItem', spec: listItem },
|
147
|
-
{ name: 'heading', spec: heading },
|
148
|
-
{ name: 'blockquote', spec: blockquote },
|
149
|
-
{ name: 'codeBlock', spec: codeBlock },
|
150
|
-
{ name: 'panel', spec: panel(true) },
|
151
|
-
{ name: 'rule', spec: rule },
|
152
|
-
{ name: 'image', spec: image },
|
153
|
-
{ name: 'mention', spec: mention },
|
154
|
-
{ name: 'caption', spec: caption },
|
155
|
-
{ name: 'media', spec: media },
|
156
|
-
{ name: 'mediaGroup', spec: mediaGroup },
|
157
|
-
{ name: 'mediaSingle', spec: mediaSingleWithCaption },
|
158
|
-
{ name: 'mediaInline', spec: mediaInline },
|
159
|
-
{ name: 'placeholder', spec: placeholder },
|
160
|
-
{ name: 'layoutSection', spec: layoutSection },
|
161
|
-
{ name: 'layoutColumn', spec: layoutColumn },
|
162
|
-
{ name: 'hardBreak', spec: hardBreak },
|
163
|
-
{ name: 'emoji', spec: emoji },
|
164
|
-
{ name: 'table', spec: table },
|
165
|
-
{ name: 'tableCell', spec: tableCell },
|
166
|
-
{ name: 'tableRow', spec: tableRow },
|
167
|
-
{ name: 'tableHeader', spec: tableHeader },
|
168
|
-
{ name: 'confluenceJiraIssue', spec: confluenceJiraIssue },
|
169
|
-
{ name: 'confluenceUnsupportedInline', spec: confluenceUnsupportedInline },
|
170
|
-
{ name: 'confluenceUnsupportedBlock', spec: confluenceUnsupportedBlock },
|
171
|
-
{ name: 'decisionList', spec: decisionList },
|
172
|
-
{ name: 'decisionItem', spec: decisionItem },
|
173
|
-
{ name: 'taskList', spec: taskList },
|
174
|
-
{ name: 'taskItem', spec: taskItem },
|
175
|
-
{ name: 'date', spec: date },
|
176
|
-
{ name: 'status', spec: status },
|
177
|
-
{ name: 'expand', spec: expand },
|
178
|
-
{ name: 'nestedExpand', spec: nestedExpand },
|
179
|
-
{ name: 'extension', spec: extension },
|
180
|
-
{ name: 'inlineExtension', spec: inlineExtension },
|
181
|
-
{ name: 'bodiedExtension', spec: bodiedExtension },
|
182
|
-
{ name: 'inlineCard', spec: inlineCard },
|
183
|
-
{ name: 'blockCard', spec: blockCard },
|
184
|
-
{ name: 'embedCard', spec: embedCard },
|
185
|
-
{ name: 'unknownBlock', spec: unknownBlock },
|
186
|
-
{ name: 'unsupportedBlock', spec: unsupportedBlock },
|
187
|
-
{ name: 'unsupportedInline', spec: unsupportedInline },
|
188
|
-
];
|
189
|
-
|
190
|
-
const marksInOrder: SchemaBuiltInItem[] = [
|
191
|
-
{ name: 'link', spec: link },
|
192
|
-
{ name: 'em', spec: em },
|
193
|
-
{ name: 'strong', spec: strong },
|
194
|
-
{ name: 'textColor', spec: textColor },
|
195
|
-
{ name: 'strike', spec: strike },
|
196
|
-
{ name: 'subsup', spec: subsup },
|
197
|
-
{ name: 'underline', spec: underline },
|
198
|
-
{ name: 'code', spec: code },
|
199
|
-
{ name: 'typeAheadQuery', spec: typeAheadQuery },
|
200
|
-
{ name: 'alignment', spec: alignment },
|
201
|
-
{ name: 'annotation', spec: annotation },
|
202
|
-
{ name: 'confluenceInlineComment', spec: confluenceInlineComment },
|
203
|
-
...markGroupDeclarations,
|
204
|
-
{ name: 'breakout', spec: breakout },
|
205
|
-
{ name: 'dataConsumer', spec: dataConsumer },
|
206
|
-
{ name: 'fragment', spec: fragment },
|
207
|
-
{ name: 'indentation', spec: indentation },
|
208
|
-
{ name: 'border', spec: border },
|
209
|
-
{ name: 'unsupportedMark', spec: unsupportedMark },
|
210
|
-
{ name: 'unsupportedNodeAttribute', spec: unsupportedNodeAttribute },
|
211
|
-
];
|
212
|
-
|
213
|
-
/**
|
214
|
-
* Creates a schema preserving order of marks and nodes.
|
215
|
-
*/
|
216
|
-
export function createSchema<
|
217
|
-
N extends string = string,
|
218
|
-
M extends string = string,
|
219
|
-
>(config: SchemaConfig<N, M>): Schema<N, M> {
|
220
|
-
const { customNodeSpecs, customMarkSpecs } = config;
|
221
|
-
const nodesConfig = Object.keys(customNodeSpecs || {}).concat(config.nodes);
|
222
|
-
const marksConfig = Object.keys(customMarkSpecs || {})
|
223
|
-
.concat(config.marks || [])
|
224
|
-
.concat(markGroupDeclarationsNames);
|
225
|
-
|
226
|
-
let nodes = addItems(nodesInOrder, nodesConfig, customNodeSpecs) as Record<
|
227
|
-
string,
|
228
|
-
NodeSpec
|
229
|
-
>;
|
230
|
-
let marks = addItems(marksInOrder, marksConfig, customMarkSpecs) as Record<
|
231
|
-
string,
|
232
|
-
MarkSpec
|
233
|
-
>;
|
234
|
-
nodes = sanitizeNodes(nodes, marks);
|
235
|
-
return new Schema<string, string>({
|
236
|
-
nodes,
|
237
|
-
marks,
|
238
|
-
});
|
239
|
-
}
|
240
|
-
|
241
|
-
export function sanitizeNodes(
|
242
|
-
nodes: { [key: string]: NodeSpec },
|
243
|
-
supportedMarks: { [key: string]: MarkSpec },
|
244
|
-
): { [key: string]: NodeSpec } {
|
245
|
-
const nodeNames = Object.keys(nodes);
|
246
|
-
nodeNames.forEach((nodeKey) => {
|
247
|
-
const nodeSpec = { ...nodes[nodeKey] };
|
248
|
-
if (nodeSpec.marks && nodeSpec.marks !== '_') {
|
249
|
-
nodeSpec.marks = nodeSpec.marks
|
250
|
-
.split(' ')
|
251
|
-
.filter((mark) => !!supportedMarks[mark])
|
252
|
-
.join(' ');
|
253
|
-
}
|
254
|
-
if (nodeSpec.content) {
|
255
|
-
nodeSpec.content = sanitizeNodeSpecContent(nodes, nodeSpec.content);
|
256
|
-
}
|
257
|
-
nodes[nodeKey] = nodeSpec;
|
258
|
-
});
|
259
|
-
return nodes;
|
260
|
-
}
|
261
|
-
|
262
|
-
export function sanitizeNodeSpecContent(
|
263
|
-
nodes: { [key: string]: NodeSpec },
|
264
|
-
rawContent: string,
|
265
|
-
): string {
|
266
|
-
const content = rawContent.replace(/\W/g, ' ');
|
267
|
-
const contentKeys = content.split(' ');
|
268
|
-
const unsupportedContentKeys = contentKeys.filter(
|
269
|
-
(contentKey) => !isContentSupported(nodes, contentKey),
|
270
|
-
);
|
271
|
-
return unsupportedContentKeys.reduce(
|
272
|
-
(newContent, nodeName) => sanitizedContent(newContent, nodeName),
|
273
|
-
rawContent,
|
274
|
-
);
|
275
|
-
}
|
276
|
-
|
277
|
-
function sanitizedContent(
|
278
|
-
content: string | undefined,
|
279
|
-
invalidContent: string,
|
280
|
-
): string {
|
281
|
-
if (!invalidContent.length) {
|
282
|
-
return content || '';
|
283
|
-
}
|
284
|
-
|
285
|
-
if (!content || !content.match(/\w/)) {
|
286
|
-
return '';
|
287
|
-
}
|
288
|
-
|
289
|
-
const pattern = `(${invalidContent}((\\s)*\\|)+)|((\\|(\\s)*)+${invalidContent})|(${invalidContent}$)|(${invalidContent}(\\+|\\*))`;
|
290
|
-
return content
|
291
|
-
.replace(new RegExp(pattern, 'g'), '')
|
292
|
-
.replace(' ', ' ')
|
293
|
-
.trim();
|
294
|
-
}
|
295
|
-
|
296
|
-
function isContentSupported(
|
297
|
-
nodes: { [key: string]: NodeSpec },
|
298
|
-
contentKey: string,
|
299
|
-
): boolean {
|
300
|
-
const nodeKeys = Object.keys(nodes);
|
301
|
-
|
302
|
-
// content is with valid node
|
303
|
-
if (nodeKeys.indexOf(contentKey) > -1) {
|
304
|
-
return true;
|
305
|
-
}
|
306
|
-
|
307
|
-
// content is with valid group
|
308
|
-
for (const supportedKey in nodes) {
|
309
|
-
const nodeSpec = nodes[supportedKey];
|
310
|
-
if (nodeSpec && nodeSpec.group === contentKey) {
|
311
|
-
return true;
|
312
|
-
}
|
313
|
-
}
|
314
|
-
|
315
|
-
return false;
|
316
|
-
}
|
317
|
-
|
318
|
-
export interface SchemaConfig<N = string, M = string> {
|
319
|
-
nodes: N[];
|
320
|
-
customNodeSpecs?: SchemaCustomNodeSpecs;
|
321
|
-
marks?: M[];
|
322
|
-
customMarkSpecs?: SchemaCustomMarkSpecs;
|
323
|
-
}
|
324
|
-
|
325
|
-
export interface SchemaBuiltInItem {
|
326
|
-
name: string;
|
327
|
-
spec: NodeSpec | MarkSpec;
|
328
|
-
}
|
329
|
-
|
330
|
-
export interface SchemaCustomNodeSpecs {
|
331
|
-
[name: string]: NodeSpec;
|
332
|
-
}
|
333
|
-
export interface SchemaCustomMarkSpecs {
|
334
|
-
[name: string]: MarkSpec;
|
335
|
-
}
|
336
|
-
|
337
|
-
export const allowCustomPanel: boolean = true;
|
@@ -1,180 +0,0 @@
|
|
1
|
-
import memoizeOne from 'memoize-one';
|
2
|
-
|
3
|
-
import {
|
4
|
-
mediaSingleFull,
|
5
|
-
layoutSectionWithSingleColumn,
|
6
|
-
tableWithCustomWidth,
|
7
|
-
} from './nodes';
|
8
|
-
import { createSchema, SchemaConfig } from './create-schema';
|
9
|
-
|
10
|
-
type DefaultSchemaNodes =
|
11
|
-
| 'doc'
|
12
|
-
| 'paragraph'
|
13
|
-
| 'text'
|
14
|
-
| 'bulletList'
|
15
|
-
| 'orderedList'
|
16
|
-
| 'listItem'
|
17
|
-
| 'heading'
|
18
|
-
| 'blockquote'
|
19
|
-
| 'codeBlock'
|
20
|
-
| 'panel'
|
21
|
-
| 'rule'
|
22
|
-
| 'image'
|
23
|
-
| 'mention'
|
24
|
-
| 'media'
|
25
|
-
| 'caption'
|
26
|
-
| 'mediaGroup'
|
27
|
-
| 'mediaSingle'
|
28
|
-
| 'mediaInline'
|
29
|
-
| 'confluenceUnsupportedBlock'
|
30
|
-
| 'confluenceUnsupportedInline'
|
31
|
-
| 'confluenceJiraIssue'
|
32
|
-
| 'expand'
|
33
|
-
| 'nestedExpand'
|
34
|
-
| 'extension'
|
35
|
-
| 'inlineExtension'
|
36
|
-
| 'bodiedExtension'
|
37
|
-
| 'hardBreak'
|
38
|
-
| 'emoji'
|
39
|
-
| 'table'
|
40
|
-
| 'tableCell'
|
41
|
-
| 'tableHeader'
|
42
|
-
| 'tableRow'
|
43
|
-
| 'decisionList'
|
44
|
-
| 'decisionItem'
|
45
|
-
| 'taskList'
|
46
|
-
| 'taskItem'
|
47
|
-
| 'unknownBlock'
|
48
|
-
| 'date'
|
49
|
-
| 'status'
|
50
|
-
| 'placeholder'
|
51
|
-
| 'layoutSection'
|
52
|
-
| 'layoutColumn'
|
53
|
-
| 'inlineCard'
|
54
|
-
| 'blockCard'
|
55
|
-
| 'embedCard'
|
56
|
-
| 'unsupportedBlock'
|
57
|
-
| 'unsupportedInline';
|
58
|
-
|
59
|
-
type DefaultSchemaMarks =
|
60
|
-
| 'link'
|
61
|
-
| 'em'
|
62
|
-
| 'strong'
|
63
|
-
| 'strike'
|
64
|
-
| 'subsup'
|
65
|
-
| 'underline'
|
66
|
-
| 'code'
|
67
|
-
| 'textColor'
|
68
|
-
| 'confluenceInlineComment'
|
69
|
-
| 'breakout'
|
70
|
-
| 'alignment'
|
71
|
-
| 'indentation'
|
72
|
-
| 'annotation'
|
73
|
-
| 'border'
|
74
|
-
| 'unsupportedMark'
|
75
|
-
| 'unsupportedNodeAttribute'
|
76
|
-
| 'typeAheadQuery'
|
77
|
-
| 'dataConsumer'
|
78
|
-
| 'fragment';
|
79
|
-
|
80
|
-
const getDefaultSchemaConfig = (): SchemaConfig<
|
81
|
-
DefaultSchemaNodes,
|
82
|
-
DefaultSchemaMarks
|
83
|
-
> => {
|
84
|
-
let defaultSchemaConfig: SchemaConfig<
|
85
|
-
DefaultSchemaNodes,
|
86
|
-
DefaultSchemaMarks
|
87
|
-
> = {
|
88
|
-
nodes: [
|
89
|
-
'doc',
|
90
|
-
'paragraph',
|
91
|
-
'text',
|
92
|
-
'bulletList',
|
93
|
-
'orderedList',
|
94
|
-
'listItem',
|
95
|
-
'heading',
|
96
|
-
'blockquote',
|
97
|
-
'codeBlock',
|
98
|
-
'panel',
|
99
|
-
'rule',
|
100
|
-
'image',
|
101
|
-
'caption',
|
102
|
-
'mention',
|
103
|
-
'media',
|
104
|
-
'mediaGroup',
|
105
|
-
'mediaSingle',
|
106
|
-
'mediaInline',
|
107
|
-
'confluenceUnsupportedBlock',
|
108
|
-
'confluenceUnsupportedInline',
|
109
|
-
'confluenceJiraIssue',
|
110
|
-
'expand',
|
111
|
-
'nestedExpand',
|
112
|
-
'extension',
|
113
|
-
'inlineExtension',
|
114
|
-
'bodiedExtension',
|
115
|
-
'hardBreak',
|
116
|
-
'emoji',
|
117
|
-
'table',
|
118
|
-
'tableCell',
|
119
|
-
'tableHeader',
|
120
|
-
'tableRow',
|
121
|
-
'decisionList',
|
122
|
-
'decisionItem',
|
123
|
-
'taskList',
|
124
|
-
'taskItem',
|
125
|
-
'unknownBlock',
|
126
|
-
'date',
|
127
|
-
'status',
|
128
|
-
'placeholder',
|
129
|
-
'layoutSection',
|
130
|
-
'layoutColumn',
|
131
|
-
'inlineCard',
|
132
|
-
'blockCard',
|
133
|
-
'embedCard',
|
134
|
-
'unsupportedBlock',
|
135
|
-
'unsupportedInline',
|
136
|
-
],
|
137
|
-
marks: [
|
138
|
-
'link',
|
139
|
-
'em',
|
140
|
-
'strong',
|
141
|
-
'strike',
|
142
|
-
'subsup',
|
143
|
-
'underline',
|
144
|
-
'code',
|
145
|
-
'textColor',
|
146
|
-
'confluenceInlineComment',
|
147
|
-
'breakout',
|
148
|
-
'alignment',
|
149
|
-
'indentation',
|
150
|
-
'annotation',
|
151
|
-
'dataConsumer',
|
152
|
-
'border',
|
153
|
-
'unsupportedMark',
|
154
|
-
'unsupportedNodeAttribute',
|
155
|
-
'typeAheadQuery', // https://product-fabric.atlassian.net/browse/ED-10214,
|
156
|
-
'fragment',
|
157
|
-
],
|
158
|
-
};
|
159
|
-
return defaultSchemaConfig;
|
160
|
-
};
|
161
|
-
|
162
|
-
export const defaultSchemaConfig: SchemaConfig<
|
163
|
-
DefaultSchemaNodes,
|
164
|
-
DefaultSchemaMarks
|
165
|
-
> = getDefaultSchemaConfig();
|
166
|
-
|
167
|
-
export const getSchemaBasedOnStage = memoizeOne((stage = 'final') => {
|
168
|
-
const defaultSchemaConfig = getDefaultSchemaConfig();
|
169
|
-
if (stage === 'stage0') {
|
170
|
-
defaultSchemaConfig.customNodeSpecs = {
|
171
|
-
layoutSection: layoutSectionWithSingleColumn,
|
172
|
-
table: tableWithCustomWidth,
|
173
|
-
mediaSingle: mediaSingleFull,
|
174
|
-
};
|
175
|
-
}
|
176
|
-
|
177
|
-
return createSchema(defaultSchemaConfig);
|
178
|
-
});
|
179
|
-
|
180
|
-
export const defaultSchema = getSchemaBasedOnStage();
|
package/src/schema/groups.ts
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
// # What do marks exist?
|
2
|
-
//
|
3
|
-
// Marks are categorised into different groups. One motivation for this was to allow the `code` mark
|
4
|
-
// to exclude other marks, without needing to explicitly name them. Explicit naming requires the
|
5
|
-
// named mark to exist in the schema. This is undesirable because we want to construct different
|
6
|
-
// schemas that have different sets of nodes/marks.
|
7
|
-
//
|
8
|
-
// Groups provide a level of indirection, and solve this problem. For the immediate use-case, one
|
9
|
-
// group called "not_code" would have sufficed, but this an ultra-specialised to code.
|
10
|
-
|
11
|
-
// Mark group for font styling (e.g. bold, italic, underline, superscript).
|
12
|
-
export const FONT_STYLE = 'fontStyle';
|
13
|
-
|
14
|
-
// Marks group for search queries.
|
15
|
-
export const SEARCH_QUERY = 'searchQuery';
|
16
|
-
|
17
|
-
// Marks group for links.
|
18
|
-
export const LINK = 'link';
|
19
|
-
|
20
|
-
// Marks group for colors (text-color, background-color, etc).
|
21
|
-
export const COLOR = 'color';
|
22
|
-
|
23
|
-
// They need to be on their own group so that they can exclude each other
|
24
|
-
// and also work when one of them is disabled.
|
25
|
-
|
26
|
-
// Marks group for alignment.
|
27
|
-
export const ALIGNMENT = 'alignment';
|
28
|
-
|
29
|
-
// Marks group for indentation.
|
30
|
-
export const INDENTATION = 'indentation';
|