@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.
Files changed (210) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/types/index.d.ts +1 -1
  3. package/package.json +1 -1
  4. package/src/__tests__/unit/json-schema/v1.ts +0 -55
  5. package/src/__tests__/unit/schema/create-schema.ts +0 -214
  6. package/src/__tests__/unit/schema/default-schema.ts +0 -192
  7. package/src/__tests__/unit/schema/marks/annotation.ts +0 -46
  8. package/src/__tests__/unit/schema/marks/border.ts +0 -76
  9. package/src/__tests__/unit/schema/marks/breakout.ts +0 -24
  10. package/src/__tests__/unit/schema/marks/code.ts +0 -44
  11. package/src/__tests__/unit/schema/marks/confluence-inline-comment.ts +0 -25
  12. package/src/__tests__/unit/schema/marks/data-consumer.ts +0 -52
  13. package/src/__tests__/unit/schema/marks/em.ts +0 -37
  14. package/src/__tests__/unit/schema/marks/link.ts +0 -188
  15. package/src/__tests__/unit/schema/marks/strike.ts +0 -37
  16. package/src/__tests__/unit/schema/marks/strong.ts +0 -43
  17. package/src/__tests__/unit/schema/marks/subsup.ts +0 -50
  18. package/src/__tests__/unit/schema/marks/text-color.ts +0 -61
  19. package/src/__tests__/unit/schema/marks/underline.ts +0 -36
  20. package/src/__tests__/unit/schema/nodes/_consts.ts +0 -964
  21. package/src/__tests__/unit/schema/nodes/block-card.ts +0 -184
  22. package/src/__tests__/unit/schema/nodes/blockquote.ts +0 -44
  23. package/src/__tests__/unit/schema/nodes/bodied-extension.ts +0 -101
  24. package/src/__tests__/unit/schema/nodes/code-block.ts +0 -221
  25. package/src/__tests__/unit/schema/nodes/confluence-unsupported-block.ts +0 -32
  26. package/src/__tests__/unit/schema/nodes/confluence-unsupported-inline.ts +0 -35
  27. package/src/__tests__/unit/schema/nodes/date.ts +0 -51
  28. package/src/__tests__/unit/schema/nodes/decision-item.ts +0 -46
  29. package/src/__tests__/unit/schema/nodes/decision-list.ts +0 -52
  30. package/src/__tests__/unit/schema/nodes/embed-card.ts +0 -60
  31. package/src/__tests__/unit/schema/nodes/emoji.ts +0 -71
  32. package/src/__tests__/unit/schema/nodes/expand.ts +0 -51
  33. package/src/__tests__/unit/schema/nodes/extension.ts +0 -101
  34. package/src/__tests__/unit/schema/nodes/hard-break.ts +0 -24
  35. package/src/__tests__/unit/schema/nodes/heading.ts +0 -56
  36. package/src/__tests__/unit/schema/nodes/image.ts +0 -32
  37. package/src/__tests__/unit/schema/nodes/inline-card.ts +0 -106
  38. package/src/__tests__/unit/schema/nodes/inline-extension.ts +0 -79
  39. package/src/__tests__/unit/schema/nodes/layout-column.ts +0 -54
  40. package/src/__tests__/unit/schema/nodes/layout-section.ts +0 -95
  41. package/src/__tests__/unit/schema/nodes/list-item.ts +0 -49
  42. package/src/__tests__/unit/schema/nodes/media-group.ts +0 -67
  43. package/src/__tests__/unit/schema/nodes/media-single.ts +0 -171
  44. package/src/__tests__/unit/schema/nodes/media.ts +0 -384
  45. package/src/__tests__/unit/schema/nodes/mention.ts +0 -115
  46. package/src/__tests__/unit/schema/nodes/nestedExpand.ts +0 -72
  47. package/src/__tests__/unit/schema/nodes/ordered-list.ts +0 -49
  48. package/src/__tests__/unit/schema/nodes/panel.ts +0 -180
  49. package/src/__tests__/unit/schema/nodes/paragraph.ts +0 -25
  50. package/src/__tests__/unit/schema/nodes/placeholder.ts +0 -46
  51. package/src/__tests__/unit/schema/nodes/rule.ts +0 -24
  52. package/src/__tests__/unit/schema/nodes/status.ts +0 -120
  53. package/src/__tests__/unit/schema/nodes/tableNodes.ts +0 -555
  54. package/src/__tests__/unit/schema/nodes/task-item.ts +0 -39
  55. package/src/__tests__/unit/schema/nodes/task-list.ts +0 -45
  56. package/src/__tests__/unit/schema/nodes/unknown-block.ts +0 -42
  57. package/src/__tests__/unit/schema/nodes/unsupported-block.ts +0 -42
  58. package/src/__tests__/unit/schema/nodes/unsupported-inline.ts +0 -38
  59. package/src/__tests__/unit/utils/colors.ts +0 -42
  60. package/src/__tests__/unit/utils/url.ts +0 -209
  61. package/src/schema/bitbucket-schema.ts +0 -43
  62. package/src/schema/confluence-schema.ts +0 -76
  63. package/src/schema/create-schema.ts +0 -337
  64. package/src/schema/default-schema.ts +0 -180
  65. package/src/schema/groups.ts +0 -30
  66. package/src/schema/inline-nodes.ts +0 -9
  67. package/src/schema/jira-schema.ts +0 -158
  68. package/src/schema/marks/__tests__/unit/annotation.ts +0 -18
  69. package/src/schema/marks/alignment.ts +0 -48
  70. package/src/schema/marks/annotation.ts +0 -107
  71. package/src/schema/marks/border.ts +0 -74
  72. package/src/schema/marks/breakout.ts +0 -42
  73. package/src/schema/marks/code.ts +0 -45
  74. package/src/schema/marks/confluence-inline-comment.ts +0 -32
  75. package/src/schema/marks/data-consumer.ts +0 -100
  76. package/src/schema/marks/em.ts +0 -19
  77. package/src/schema/marks/fragment.ts +0 -77
  78. package/src/schema/marks/indentation.ts +0 -47
  79. package/src/schema/marks/link.ts +0 -139
  80. package/src/schema/marks/strike.ts +0 -26
  81. package/src/schema/marks/strong.ts +0 -45
  82. package/src/schema/marks/subsup.ts +0 -53
  83. package/src/schema/marks/text-color.ts +0 -172
  84. package/src/schema/marks/type-ahead-query.ts +0 -22
  85. package/src/schema/marks/underline.ts +0 -24
  86. package/src/schema/marks/unsupported-mark.ts +0 -9
  87. package/src/schema/marks/unsupported-node-attributes.ts +0 -8
  88. package/src/schema/nodes/block-card.ts +0 -121
  89. package/src/schema/nodes/blockquote.ts +0 -25
  90. package/src/schema/nodes/bodied-extension.ts +0 -75
  91. package/src/schema/nodes/bullet-list.ts +0 -17
  92. package/src/schema/nodes/caption.ts +0 -51
  93. package/src/schema/nodes/code-block.ts +0 -176
  94. package/src/schema/nodes/confluence-jira-issue.ts +0 -43
  95. package/src/schema/nodes/confluence-unsupported-block.ts +0 -29
  96. package/src/schema/nodes/confluence-unsupported-inline.ts +0 -30
  97. package/src/schema/nodes/date.ts +0 -38
  98. package/src/schema/nodes/decision-item.ts +0 -50
  99. package/src/schema/nodes/decision-list.ts +0 -56
  100. package/src/schema/nodes/doc.ts +0 -30
  101. package/src/schema/nodes/embed-card.ts +0 -62
  102. package/src/schema/nodes/emoji.ts +0 -89
  103. package/src/schema/nodes/expand.ts +0 -101
  104. package/src/schema/nodes/extension.ts +0 -60
  105. package/src/schema/nodes/hard-break.ts +0 -21
  106. package/src/schema/nodes/heading.ts +0 -64
  107. package/src/schema/nodes/image.ts +0 -32
  108. package/src/schema/nodes/inline-card.ts +0 -70
  109. package/src/schema/nodes/inline-extension.ts +0 -57
  110. package/src/schema/nodes/layout-column.ts +0 -68
  111. package/src/schema/nodes/layout-section.ts +0 -93
  112. package/src/schema/nodes/list-item.ts +0 -13
  113. package/src/schema/nodes/media-group.ts +0 -44
  114. package/src/schema/nodes/media-inline.ts +0 -19
  115. package/src/schema/nodes/media-single.ts +0 -179
  116. package/src/schema/nodes/media.ts +0 -253
  117. package/src/schema/nodes/mention.ts +0 -86
  118. package/src/schema/nodes/nested-expand.ts +0 -77
  119. package/src/schema/nodes/ordered-list.ts +0 -62
  120. package/src/schema/nodes/panel.ts +0 -133
  121. package/src/schema/nodes/paragraph.ts +0 -79
  122. package/src/schema/nodes/placeholder.ts +0 -40
  123. package/src/schema/nodes/rule.ts +0 -17
  124. package/src/schema/nodes/status.ts +0 -58
  125. package/src/schema/nodes/tableNodes.ts +0 -478
  126. package/src/schema/nodes/task-item.ts +0 -51
  127. package/src/schema/nodes/task-list.ts +0 -61
  128. package/src/schema/nodes/text.ts +0 -19
  129. package/src/schema/nodes/types/block-content.ts +0 -51
  130. package/src/schema/nodes/types/extensions.ts +0 -36
  131. package/src/schema/nodes/types/inline-content.ts +0 -56
  132. package/src/schema/nodes/types/list.ts +0 -54
  133. package/src/schema/nodes/types/mark.ts +0 -16
  134. package/src/schema/nodes/types/non-nestable-block-content.ts +0 -39
  135. package/src/schema/nodes/types/rich-media-common.ts +0 -51
  136. package/src/schema/nodes/unknown-block.ts +0 -13
  137. package/src/schema/nodes/unsupported-block.ts +0 -28
  138. package/src/schema/nodes/unsupported-inline.ts +0 -27
  139. package/src/schema/unsupported.ts +0 -4
  140. package/src/steps/__tests__/unit/analytics.ts +0 -72
  141. package/src/steps/__tests__/unit/link-meta-step.ts +0 -64
  142. package/src/steps/__tests__/unit/override-document-step.ts +0 -174
  143. package/src/steps/__tests__/unit/set-attrs.ts +0 -71
  144. package/src/steps/analytics.ts +0 -189
  145. package/src/steps/link-meta-step.ts +0 -105
  146. package/src/steps/override-document-step.ts +0 -97
  147. package/src/steps/set-attrs.tsx +0 -74
  148. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-0.json +0 -15
  149. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-1.json +0 -15
  150. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-2.json +0 -15
  151. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-3.json +0 -15
  152. package/src/steps/table/__tests__/__fixtures__/basic/remove-column-at-0.json +0 -9
  153. package/src/steps/table/__tests__/__fixtures__/basic/remove-column-at-1.json +0 -9
  154. package/src/steps/table/__tests__/__fixtures__/basic/remove-column-at-2.json +0 -9
  155. package/src/steps/table/__tests__/__fixtures__/basic/remove-table/remove-last-row-inverted.json +0 -98
  156. package/src/steps/table/__tests__/__fixtures__/basic/remove-table/remove-last-row.json +0 -71
  157. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-0-inverted.json +0 -19
  158. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-0.json +0 -19
  159. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-1-inverted.json +0 -21
  160. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-1.json +0 -21
  161. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-2-inverted.json +0 -21
  162. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-2.json +0 -21
  163. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-3-inverted.json +0 -19
  164. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-3.json +0 -19
  165. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-0-inverted.json +0 -63
  166. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-0.json +0 -21
  167. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-1-inverted.json +0 -64
  168. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-1.json +0 -22
  169. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-2-inverted.json +0 -63
  170. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-2.json +0 -21
  171. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-0-inverted.json +0 -19
  172. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-0.json +0 -19
  173. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-1-inverted.json +0 -19
  174. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-1.json +0 -19
  175. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-2-inverted.json +0 -19
  176. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-2.json +0 -19
  177. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-3-inverted.json +0 -19
  178. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-3.json +0 -19
  179. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-0-inverted.json +0 -52
  180. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-0.json +0 -38
  181. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-1-inverted.json +0 -52
  182. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-1.json +0 -38
  183. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-2-inverted.json +0 -25
  184. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-2.json +0 -11
  185. package/src/steps/table/__tests__/_utils.ts +0 -102
  186. package/src/steps/table/__tests__/add-column-merge-columns.ts +0 -509
  187. package/src/steps/table/__tests__/add-column-merge-rows.ts +0 -466
  188. package/src/steps/table/__tests__/add-column.ts +0 -638
  189. package/src/steps/table/add-column.ts +0 -443
  190. package/src/steps/table/constants.ts +0 -4
  191. package/src/steps/table/sort-column.ts +0 -57
  192. package/src/steps/table/types.ts +0 -48
  193. package/src/steps/table/utils/cell-step.ts +0 -239
  194. package/src/steps/table/utils/cells-at-column.ts +0 -75
  195. package/src/steps/table/utils/find-column.ts +0 -90
  196. package/src/steps/table/utils/get-table-rect-from-doc.ts +0 -37
  197. package/src/steps/table/utils/side-effects/rows.ts +0 -327
  198. package/src/steps/table/utils/side-effects/side-effects.ts +0 -90
  199. package/src/steps/table/utils/side-effects/table.ts +0 -112
  200. package/src/steps/table/utils/side-effects/types.ts +0 -34
  201. package/src/steps/table/utils/table-map.ts +0 -28
  202. package/src/steps/type-ahead.ts +0 -100
  203. package/src/steps.ts +0 -16
  204. package/src/utils/colors.ts +0 -171
  205. package/src/utils/confluence/emoji.ts +0 -99
  206. package/src/utils/extensions.ts +0 -32
  207. package/src/utils/parseDOM.ts +0 -2
  208. package/src/utils/url.ts +0 -173
  209. package/src/utils/uuid.ts +0 -19
  210. package/src/version.json +0 -6
@@ -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();
@@ -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';
@@ -1,9 +0,0 @@
1
- import * as nodes from './nodes';
2
-
3
- const typedNodes: Record<string, any> = nodes;
4
-
5
- export const inlineNodes = new Set(
6
- Object.keys(typedNodes).filter(
7
- (key) => typedNodes[key] && typedNodes[key].group === 'inline',
8
- ),
9
- );
@@ -1,158 +0,0 @@
1
- import { createSchema } from './create-schema';
2
- import { Schema } from '@atlaskit/editor-prosemirror/model';
3
-
4
- /**
5
- * @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
6
- **/
7
- export interface JIRASchemaConfig {
8
- allowLists?: boolean;
9
- allowMentions?: boolean;
10
- allowEmojis?: boolean;
11
- allowLinks?: boolean;
12
- allowAdvancedTextFormatting?: boolean;
13
- allowCodeBlock?: boolean;
14
- allowBlockQuote?: boolean;
15
- allowSubSup?: boolean;
16
- allowMedia?: boolean;
17
- allowTextColor?: boolean;
18
- allowTables?: boolean;
19
- }
20
-
21
- /**
22
- * @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
23
- **/
24
- export default function makeSchema(config: JIRASchemaConfig) {
25
- const nodes = ['doc', 'paragraph', 'text', 'hardBreak', 'heading', 'rule'];
26
- const marks = [
27
- 'strong',
28
- 'em',
29
- 'underline',
30
- 'typeAheadQuery',
31
- 'unsupportedMark',
32
- 'unsupportedNodeAttribute',
33
- ];
34
-
35
- if (config.allowLinks) {
36
- marks.push('link');
37
- }
38
-
39
- if (config.allowLists) {
40
- nodes.push('orderedList', 'bulletList', 'listItem');
41
- }
42
-
43
- if (config.allowMentions) {
44
- nodes.push('mention');
45
- marks.push('mentionQuery');
46
- }
47
-
48
- if (config.allowEmojis) {
49
- nodes.push('emoji');
50
- }
51
-
52
- if (config.allowAdvancedTextFormatting) {
53
- marks.push('strike', 'code');
54
- }
55
-
56
- if (config.allowSubSup) {
57
- marks.push('subsup');
58
- }
59
-
60
- if (config.allowCodeBlock) {
61
- nodes.push('codeBlock');
62
- }
63
-
64
- if (config.allowBlockQuote) {
65
- nodes.push('blockquote');
66
- }
67
-
68
- if (config.allowMedia) {
69
- nodes.push('mediaGroup', 'mediaSingle', 'media', 'caption', 'mediaInline');
70
- }
71
-
72
- if (config.allowTextColor) {
73
- marks.push('textColor');
74
- }
75
-
76
- if (config.allowTables) {
77
- nodes.push('table', 'tableCell', 'tableHeader', 'tableRow');
78
- }
79
-
80
- return createSchema({ nodes, marks });
81
- }
82
- /**
83
- * @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
84
- **/
85
- export function isSchemaWithLists(schema: Schema): boolean {
86
- return !!schema.nodes.bulletList;
87
- }
88
- /**
89
- * @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
90
- **/
91
- export function isSchemaWithMentions(schema: Schema): boolean {
92
- return !!schema.nodes.mention;
93
- }
94
- /**
95
- * @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
96
- **/
97
- export function isSchemaWithEmojis(schema: Schema): boolean {
98
- return !!schema.nodes.emoji;
99
- }
100
- /**
101
- * @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
102
- **/
103
- export function isSchemaWithLinks(schema: Schema): boolean {
104
- return !!schema.marks.link;
105
- }
106
- /**
107
- * @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
108
- **/
109
- export function isSchemaWithAdvancedTextFormattingMarks(
110
- schema: Schema,
111
- ): boolean {
112
- return !!schema.marks.code && !!schema.marks.strike;
113
- }
114
- /**
115
- * @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
116
- **/
117
- export function isSchemaWithSubSupMark(schema: Schema): boolean {
118
- return !!schema.marks.subsup;
119
- }
120
- /**
121
- * @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
122
- **/
123
- export function isSchemaWithCodeBlock(schema: Schema): boolean {
124
- return !!schema.nodes.codeBlock;
125
- }
126
- /**
127
- * @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
128
- **/
129
- export function isSchemaWithBlockQuotes(schema: Schema): boolean {
130
- return !!schema.nodes.blockquote;
131
- }
132
- /**
133
- * @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
134
- **/
135
- export function isSchemaWithMedia(schema: Schema): boolean {
136
- return (
137
- !!schema.nodes.mediaGroup &&
138
- !!schema.nodes.media &&
139
- !!schema.nodes.mediaInline
140
- );
141
- }
142
- /**
143
- * @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
144
- **/
145
- export function isSchemaWithTextColor(schema: Schema): boolean {
146
- return !!schema.marks.textColor;
147
- }
148
- /**
149
- * @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
150
- **/
151
- export function isSchemaWithTables(schema: Schema): boolean {
152
- return (
153
- !!schema.nodes.table &&
154
- !!schema.nodes.tableCell &&
155
- !!schema.nodes.tableHeader &&
156
- !!schema.nodes.tableRow
157
- );
158
- }