@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.
Files changed (218) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/package.json +1 -1
  3. package/build/tsconfig.json +0 -18
  4. package/index.ts +0 -275
  5. package/src/__tests__/unit/json-schema/v1.ts +0 -55
  6. package/src/__tests__/unit/schema/create-schema.ts +0 -214
  7. package/src/__tests__/unit/schema/default-schema.ts +0 -192
  8. package/src/__tests__/unit/schema/marks/annotation.ts +0 -46
  9. package/src/__tests__/unit/schema/marks/border.ts +0 -76
  10. package/src/__tests__/unit/schema/marks/breakout.ts +0 -24
  11. package/src/__tests__/unit/schema/marks/code.ts +0 -44
  12. package/src/__tests__/unit/schema/marks/confluence-inline-comment.ts +0 -25
  13. package/src/__tests__/unit/schema/marks/data-consumer.ts +0 -52
  14. package/src/__tests__/unit/schema/marks/em.ts +0 -37
  15. package/src/__tests__/unit/schema/marks/link.ts +0 -188
  16. package/src/__tests__/unit/schema/marks/strike.ts +0 -37
  17. package/src/__tests__/unit/schema/marks/strong.ts +0 -43
  18. package/src/__tests__/unit/schema/marks/subsup.ts +0 -50
  19. package/src/__tests__/unit/schema/marks/text-color.ts +0 -61
  20. package/src/__tests__/unit/schema/marks/underline.ts +0 -36
  21. package/src/__tests__/unit/schema/nodes/_consts.ts +0 -964
  22. package/src/__tests__/unit/schema/nodes/block-card.ts +0 -184
  23. package/src/__tests__/unit/schema/nodes/blockquote.ts +0 -44
  24. package/src/__tests__/unit/schema/nodes/bodied-extension.ts +0 -101
  25. package/src/__tests__/unit/schema/nodes/code-block.ts +0 -221
  26. package/src/__tests__/unit/schema/nodes/confluence-unsupported-block.ts +0 -32
  27. package/src/__tests__/unit/schema/nodes/confluence-unsupported-inline.ts +0 -35
  28. package/src/__tests__/unit/schema/nodes/date.ts +0 -51
  29. package/src/__tests__/unit/schema/nodes/decision-item.ts +0 -46
  30. package/src/__tests__/unit/schema/nodes/decision-list.ts +0 -52
  31. package/src/__tests__/unit/schema/nodes/embed-card.ts +0 -60
  32. package/src/__tests__/unit/schema/nodes/emoji.ts +0 -71
  33. package/src/__tests__/unit/schema/nodes/expand.ts +0 -51
  34. package/src/__tests__/unit/schema/nodes/extension.ts +0 -101
  35. package/src/__tests__/unit/schema/nodes/hard-break.ts +0 -24
  36. package/src/__tests__/unit/schema/nodes/heading.ts +0 -56
  37. package/src/__tests__/unit/schema/nodes/image.ts +0 -32
  38. package/src/__tests__/unit/schema/nodes/inline-card.ts +0 -106
  39. package/src/__tests__/unit/schema/nodes/inline-extension.ts +0 -79
  40. package/src/__tests__/unit/schema/nodes/layout-column.ts +0 -54
  41. package/src/__tests__/unit/schema/nodes/layout-section.ts +0 -95
  42. package/src/__tests__/unit/schema/nodes/list-item.ts +0 -49
  43. package/src/__tests__/unit/schema/nodes/media-group.ts +0 -67
  44. package/src/__tests__/unit/schema/nodes/media-single.ts +0 -171
  45. package/src/__tests__/unit/schema/nodes/media.ts +0 -384
  46. package/src/__tests__/unit/schema/nodes/mention.ts +0 -115
  47. package/src/__tests__/unit/schema/nodes/nestedExpand.ts +0 -72
  48. package/src/__tests__/unit/schema/nodes/ordered-list.ts +0 -49
  49. package/src/__tests__/unit/schema/nodes/panel.ts +0 -180
  50. package/src/__tests__/unit/schema/nodes/paragraph.ts +0 -25
  51. package/src/__tests__/unit/schema/nodes/placeholder.ts +0 -46
  52. package/src/__tests__/unit/schema/nodes/rule.ts +0 -24
  53. package/src/__tests__/unit/schema/nodes/status.ts +0 -120
  54. package/src/__tests__/unit/schema/nodes/tableNodes.ts +0 -555
  55. package/src/__tests__/unit/schema/nodes/task-item.ts +0 -39
  56. package/src/__tests__/unit/schema/nodes/task-list.ts +0 -45
  57. package/src/__tests__/unit/schema/nodes/unknown-block.ts +0 -42
  58. package/src/__tests__/unit/schema/nodes/unsupported-block.ts +0 -42
  59. package/src/__tests__/unit/schema/nodes/unsupported-inline.ts +0 -38
  60. package/src/__tests__/unit/utils/colors.ts +0 -42
  61. package/src/__tests__/unit/utils/url.ts +0 -209
  62. package/src/index.ts +0 -297
  63. package/src/json-schema/index.ts +0 -2
  64. package/src/schema/bitbucket-schema.ts +0 -43
  65. package/src/schema/confluence-schema.ts +0 -76
  66. package/src/schema/create-schema.ts +0 -337
  67. package/src/schema/default-schema.ts +0 -180
  68. package/src/schema/groups.ts +0 -30
  69. package/src/schema/index.ts +0 -238
  70. package/src/schema/inline-nodes.ts +0 -9
  71. package/src/schema/jira-schema.ts +0 -158
  72. package/src/schema/marks/__tests__/unit/annotation.ts +0 -18
  73. package/src/schema/marks/alignment.ts +0 -48
  74. package/src/schema/marks/annotation.ts +0 -107
  75. package/src/schema/marks/border.ts +0 -74
  76. package/src/schema/marks/breakout.ts +0 -42
  77. package/src/schema/marks/code.ts +0 -45
  78. package/src/schema/marks/confluence-inline-comment.ts +0 -32
  79. package/src/schema/marks/data-consumer.ts +0 -100
  80. package/src/schema/marks/em.ts +0 -19
  81. package/src/schema/marks/fragment.ts +0 -77
  82. package/src/schema/marks/indentation.ts +0 -47
  83. package/src/schema/marks/index.ts +0 -61
  84. package/src/schema/marks/link.ts +0 -139
  85. package/src/schema/marks/strike.ts +0 -26
  86. package/src/schema/marks/strong.ts +0 -45
  87. package/src/schema/marks/subsup.ts +0 -53
  88. package/src/schema/marks/text-color.ts +0 -172
  89. package/src/schema/marks/type-ahead-query.ts +0 -22
  90. package/src/schema/marks/underline.ts +0 -24
  91. package/src/schema/marks/unsupported-mark.ts +0 -9
  92. package/src/schema/marks/unsupported-node-attributes.ts +0 -8
  93. package/src/schema/nodes/block-card.ts +0 -121
  94. package/src/schema/nodes/blockquote.ts +0 -25
  95. package/src/schema/nodes/bodied-extension.ts +0 -75
  96. package/src/schema/nodes/bullet-list.ts +0 -17
  97. package/src/schema/nodes/caption.ts +0 -51
  98. package/src/schema/nodes/code-block.ts +0 -176
  99. package/src/schema/nodes/confluence-jira-issue.ts +0 -43
  100. package/src/schema/nodes/confluence-unsupported-block.ts +0 -29
  101. package/src/schema/nodes/confluence-unsupported-inline.ts +0 -30
  102. package/src/schema/nodes/date.ts +0 -38
  103. package/src/schema/nodes/decision-item.ts +0 -50
  104. package/src/schema/nodes/decision-list.ts +0 -56
  105. package/src/schema/nodes/doc.ts +0 -30
  106. package/src/schema/nodes/embed-card.ts +0 -62
  107. package/src/schema/nodes/emoji.ts +0 -89
  108. package/src/schema/nodes/expand.ts +0 -101
  109. package/src/schema/nodes/extension.ts +0 -60
  110. package/src/schema/nodes/hard-break.ts +0 -21
  111. package/src/schema/nodes/heading.ts +0 -64
  112. package/src/schema/nodes/image.ts +0 -32
  113. package/src/schema/nodes/index.ts +0 -184
  114. package/src/schema/nodes/inline-card.ts +0 -70
  115. package/src/schema/nodes/inline-extension.ts +0 -57
  116. package/src/schema/nodes/layout-column.ts +0 -68
  117. package/src/schema/nodes/layout-section.ts +0 -93
  118. package/src/schema/nodes/list-item.ts +0 -13
  119. package/src/schema/nodes/media-group.ts +0 -44
  120. package/src/schema/nodes/media-inline.ts +0 -19
  121. package/src/schema/nodes/media-single.ts +0 -179
  122. package/src/schema/nodes/media.ts +0 -253
  123. package/src/schema/nodes/mention.ts +0 -86
  124. package/src/schema/nodes/nested-expand.ts +0 -77
  125. package/src/schema/nodes/ordered-list.ts +0 -62
  126. package/src/schema/nodes/panel.ts +0 -133
  127. package/src/schema/nodes/paragraph.ts +0 -79
  128. package/src/schema/nodes/placeholder.ts +0 -40
  129. package/src/schema/nodes/rule.ts +0 -17
  130. package/src/schema/nodes/status.ts +0 -58
  131. package/src/schema/nodes/tableNodes.ts +0 -478
  132. package/src/schema/nodes/task-item.ts +0 -51
  133. package/src/schema/nodes/task-list.ts +0 -61
  134. package/src/schema/nodes/text.ts +0 -19
  135. package/src/schema/nodes/types/block-content.ts +0 -51
  136. package/src/schema/nodes/types/extensions.ts +0 -36
  137. package/src/schema/nodes/types/inline-content.ts +0 -56
  138. package/src/schema/nodes/types/list.ts +0 -54
  139. package/src/schema/nodes/types/mark.ts +0 -16
  140. package/src/schema/nodes/types/non-nestable-block-content.ts +0 -39
  141. package/src/schema/nodes/types/rich-media-common.ts +0 -51
  142. package/src/schema/nodes/unknown-block.ts +0 -13
  143. package/src/schema/nodes/unsupported-block.ts +0 -28
  144. package/src/schema/nodes/unsupported-inline.ts +0 -27
  145. package/src/schema/unsupported.ts +0 -4
  146. package/src/steps/__tests__/unit/analytics.ts +0 -72
  147. package/src/steps/__tests__/unit/link-meta-step.ts +0 -64
  148. package/src/steps/__tests__/unit/override-document-step.ts +0 -174
  149. package/src/steps/__tests__/unit/set-attrs.ts +0 -71
  150. package/src/steps/analytics.ts +0 -189
  151. package/src/steps/link-meta-step.ts +0 -105
  152. package/src/steps/override-document-step.ts +0 -97
  153. package/src/steps/set-attrs.tsx +0 -74
  154. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-0.json +0 -15
  155. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-1.json +0 -15
  156. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-2.json +0 -15
  157. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-3.json +0 -15
  158. package/src/steps/table/__tests__/__fixtures__/basic/remove-column-at-0.json +0 -9
  159. package/src/steps/table/__tests__/__fixtures__/basic/remove-column-at-1.json +0 -9
  160. package/src/steps/table/__tests__/__fixtures__/basic/remove-column-at-2.json +0 -9
  161. package/src/steps/table/__tests__/__fixtures__/basic/remove-table/remove-last-row-inverted.json +0 -98
  162. package/src/steps/table/__tests__/__fixtures__/basic/remove-table/remove-last-row.json +0 -71
  163. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-0-inverted.json +0 -19
  164. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-0.json +0 -19
  165. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-1-inverted.json +0 -21
  166. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-1.json +0 -21
  167. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-2-inverted.json +0 -21
  168. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-2.json +0 -21
  169. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-3-inverted.json +0 -19
  170. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-3.json +0 -19
  171. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-0-inverted.json +0 -63
  172. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-0.json +0 -21
  173. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-1-inverted.json +0 -64
  174. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-1.json +0 -22
  175. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-2-inverted.json +0 -63
  176. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-2.json +0 -21
  177. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-0-inverted.json +0 -19
  178. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-0.json +0 -19
  179. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-1-inverted.json +0 -19
  180. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-1.json +0 -19
  181. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-2-inverted.json +0 -19
  182. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-2.json +0 -19
  183. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-3-inverted.json +0 -19
  184. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-3.json +0 -19
  185. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-0-inverted.json +0 -52
  186. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-0.json +0 -38
  187. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-1-inverted.json +0 -52
  188. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-1.json +0 -38
  189. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-2-inverted.json +0 -25
  190. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-2.json +0 -11
  191. package/src/steps/table/__tests__/_utils.ts +0 -102
  192. package/src/steps/table/__tests__/add-column-merge-columns.ts +0 -509
  193. package/src/steps/table/__tests__/add-column-merge-rows.ts +0 -466
  194. package/src/steps/table/__tests__/add-column.ts +0 -638
  195. package/src/steps/table/add-column.ts +0 -443
  196. package/src/steps/table/constants.ts +0 -4
  197. package/src/steps/table/sort-column.ts +0 -57
  198. package/src/steps/table/types.ts +0 -48
  199. package/src/steps/table/utils/cell-step.ts +0 -239
  200. package/src/steps/table/utils/cells-at-column.ts +0 -75
  201. package/src/steps/table/utils/find-column.ts +0 -90
  202. package/src/steps/table/utils/get-table-rect-from-doc.ts +0 -37
  203. package/src/steps/table/utils/side-effects/rows.ts +0 -327
  204. package/src/steps/table/utils/side-effects/side-effects.ts +0 -90
  205. package/src/steps/table/utils/side-effects/table.ts +0 -112
  206. package/src/steps/table/utils/side-effects/types.ts +0 -34
  207. package/src/steps/table/utils/table-map.ts +0 -28
  208. package/src/steps/type-ahead.ts +0 -100
  209. package/src/steps.ts +0 -16
  210. package/src/utils/colors.ts +0 -171
  211. package/src/utils/confluence/emoji.ts +0 -99
  212. package/src/utils/extensions.ts +0 -32
  213. package/src/utils/index.ts +0 -69
  214. package/src/utils/parseDOM.ts +0 -2
  215. package/src/utils/url.ts +0 -173
  216. package/src/utils/uuid.ts +0 -19
  217. package/src/version.json +0 -6
  218. package/tsconfig.json +0 -13
@@ -1,172 +0,0 @@
1
- import { Mark, MarkSpec } from '@atlaskit/editor-prosemirror/model';
2
-
3
- import { hexToEditorTextPaletteColor } from '@atlaskit/editor-palette';
4
-
5
- import { COLOR } from '../groups';
6
- import {
7
- rgbToHex,
8
- N0,
9
- N80,
10
- P50,
11
- P300,
12
- P500,
13
- T75,
14
- T300,
15
- T500,
16
- G75,
17
- G300,
18
- G500,
19
- R75,
20
- R300,
21
- R500,
22
- Y75,
23
- Y200,
24
- Y400,
25
- B75,
26
- B100,
27
- B500,
28
- } from '../../utils/colors';
29
-
30
- export interface TextColorAttributes {
31
- /**
32
- * @pattern "^#[0-9a-fA-F]{6}$"
33
- */
34
- color: string;
35
- }
36
-
37
- /**
38
- * @name textColor_mark
39
- */
40
- export interface TextColorDefinition {
41
- type: 'textColor';
42
- attrs: TextColorAttributes;
43
- }
44
-
45
- export interface TextColorMark extends Mark {
46
- attrs: TextColorAttributes;
47
- }
48
-
49
- export type TextColorKey =
50
- // row 1 original
51
- | 'Light gray'
52
- | 'Purple'
53
- | 'Teal'
54
- | 'Green'
55
- | 'Red'
56
- | 'Orange'
57
- // row 1 extended extras
58
- | 'Dark gray'
59
- | 'Blue'
60
- | 'Yellow'
61
- // row 2
62
- | 'Dark blue'
63
- | 'Dark teal'
64
- | 'Dark green'
65
- | 'Dark red'
66
- | 'Dark purple'
67
- // row 3
68
- | 'White'
69
- | 'Light blue'
70
- | 'Light teal'
71
- | 'Light green'
72
- | 'Light yellow'
73
- | 'Light red'
74
- | 'Light purple';
75
-
76
- // used for extended palette in text color picker
77
- const colorArrayPalette: Array<[string, TextColorKey]> = [
78
- // default row - first color is added programatically
79
- // [N800, 'Squid ink'], // default dark gray
80
- [B500, 'Dark blue'], // Chore coat
81
- [T500, 'Dark teal'], // Shabby chic
82
- [G500, 'Dark green'], // Keen green
83
- [Y400, 'Orange'], // Cheezy blasters
84
- [R500, 'Dark red'], // Dragon's blood
85
- [P500, 'Dark purple'], // Prince
86
- // row 2
87
- [N80, 'Light gray'], // Spooky ghost
88
- [B100, 'Blue'], // Arvo breeze
89
- [T300, 'Teal'], // Tamarama
90
- [G300, 'Green'], // Fine pine
91
- [Y200, 'Yellow'], // Pub mix
92
- [R300, 'Red'], // Poppy surprise
93
- [P300, 'Purple'], // Da' juice
94
- // row 3
95
- [N0, 'White'],
96
- [B75, 'Light blue'], // Schwag
97
- [T75, 'Light teal'], // Arctic chill
98
- [G75, 'Light green'], // Mintie
99
- [Y75, 'Light yellow'], // Dandelion whisper
100
- [R75, 'Light red'], // Bondi sunburn
101
- [P50, 'Light purple'], // Lavender secret
102
- ];
103
-
104
- // @see https://product-fabric.atlassian.net/wiki/spaces/E/pages/55979455/Colour+picker+decisions#Colourpickerdecisions-Visualdesigndecisions
105
- export const colorPalette = new Map<string, TextColorKey>();
106
- /** @deprecated [ED-15849] The extended palette is now rolled into the main one. Use `colorPalette` instead. */
107
- export const colorPaletteExtended = colorPalette;
108
-
109
- colorArrayPalette.forEach(([color, label]) =>
110
- colorPalette.set(color.toLowerCase(), label),
111
- );
112
-
113
- export const textColor: MarkSpec = {
114
- attrs: { color: {} },
115
- inclusive: true,
116
- group: COLOR,
117
- parseDOM: [
118
- {
119
- style: 'color',
120
- getAttrs: (maybeValue) => {
121
- const value = maybeValue as string;
122
- let hexColor;
123
- if (value.match(/^rgb/i)) {
124
- hexColor = rgbToHex(value);
125
- } else if (value[0] === '#') {
126
- hexColor = value.toLowerCase();
127
- }
128
- // else handle other colour formats
129
- return hexColor && colorPalette.has(hexColor)
130
- ? { color: hexColor }
131
- : false;
132
- },
133
- },
134
- // This rule ensures when loading from a renderer or editor where the
135
- // presented text color does not match the stored hex color -- that the
136
- // text color is preserved.
137
- //
138
- // This was initially introduced to ensure text-color marks were not lost
139
- // when text-color was used inside a link, and is now also used to support
140
- // where the hex color stored in ADF is used as an ID for a design system
141
- // token (and based on theme mode -- the presented color will change).
142
- {
143
- tag: '.fabric-text-color-mark',
144
- getAttrs: (maybeElement) => {
145
- if (!(maybeElement instanceof HTMLElement)) {
146
- return false;
147
- }
148
-
149
- const hexColor = maybeElement.dataset.textCustomColor;
150
-
151
- return hexColor && colorPalette.has(hexColor)
152
- ? { color: hexColor }
153
- : false;
154
- },
155
- },
156
- ],
157
- toDOM(mark) {
158
- // Note -- while there is no way to create custom colors using default tooling
159
- // the editor does supported ad hoc color values -- and there may be content
160
- // which has been migrated or created via apis which use such values.
161
- const paletteColorValue =
162
- hexToEditorTextPaletteColor(mark.attrs.color) || mark.attrs.color;
163
- return [
164
- 'span',
165
- {
166
- class: 'fabric-text-color-mark',
167
- style: `--custom-palette-color: ${paletteColorValue}`,
168
- ['data-text-custom-color']: mark.attrs.color,
169
- },
170
- ];
171
- },
172
- };
@@ -1,22 +0,0 @@
1
- import { MarkSpec } from '@atlaskit/editor-prosemirror/model';
2
- import { SEARCH_QUERY } from '../groups';
3
- import { B400 } from '../../utils/colors';
4
-
5
- export const typeAheadQuery: MarkSpec = {
6
- inclusive: true,
7
- group: SEARCH_QUERY,
8
- parseDOM: [{ tag: 'span[data-type-ahead-query]' }],
9
- toDOM(node) {
10
- return [
11
- 'span',
12
- {
13
- 'data-type-ahead-query': 'true',
14
- 'data-trigger': node.attrs.trigger,
15
- style: `color: ${B400}`,
16
- },
17
- ];
18
- },
19
- attrs: {
20
- trigger: { default: '' },
21
- },
22
- };
@@ -1,24 +0,0 @@
1
- import { MarkSpec } from '@atlaskit/editor-prosemirror/model';
2
- import { FONT_STYLE } from '../groups';
3
-
4
- /**
5
- * @name underline_mark
6
- */
7
- export interface UnderlineDefinition {
8
- type: 'underline';
9
- }
10
-
11
- export const underline: MarkSpec = {
12
- inclusive: true,
13
- group: FONT_STYLE,
14
- parseDOM: [
15
- { tag: 'u' },
16
- {
17
- style: 'text-decoration',
18
- getAttrs: (value) => value === 'underline' && null,
19
- },
20
- ],
21
- toDOM(): [string] {
22
- return ['u'];
23
- },
24
- };
@@ -1,9 +0,0 @@
1
- import { MarkSpec } from '@atlaskit/editor-prosemirror/model';
2
-
3
- export const unsupportedMark: MarkSpec = {
4
- toDOM() {
5
- return ['span'];
6
- },
7
- excludes: '',
8
- attrs: { originalValue: {} },
9
- };
@@ -1,8 +0,0 @@
1
- import { MarkSpec } from '@atlaskit/editor-prosemirror/model';
2
-
3
- export const unsupportedNodeAttribute: MarkSpec = {
4
- toDOM() {
5
- return ['span'];
6
- },
7
- attrs: { type: {}, unsupported: {} },
8
- };
@@ -1,121 +0,0 @@
1
- import { NodeSpec, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
- import { Layout, OptionalRichMediaAttributes } from './types/rich-media-common';
3
-
4
- export interface UrlType {
5
- /**
6
- * @validatorFn safeUrl
7
- */
8
- url: string;
9
- }
10
-
11
- export interface DataType {
12
- /**
13
- * @additionalProperties true
14
- */
15
- data: object;
16
- }
17
-
18
- export interface DatasourceAttributeProperties {
19
- id: string;
20
- parameters: object;
21
- /**
22
- * @minItems 1
23
- */
24
- views: { type: string; properties?: object }[];
25
- }
26
-
27
- /**
28
- * @stage 0
29
- */
30
- export interface DatasourceAttributes extends OptionalRichMediaAttributes {
31
- /**
32
- * @validatorFn safeUrl
33
- */
34
- url?: string;
35
- datasource: DatasourceAttributeProperties;
36
- }
37
-
38
- export type CardAttributes = UrlType | DataType;
39
-
40
- /**
41
- * @name blockCard_node
42
- */
43
- export interface BlockCardDefinition {
44
- type: 'blockCard';
45
- attrs: DatasourceAttributes | CardAttributes;
46
- }
47
-
48
- const getCommonAttributesFromDom = (
49
- dom: string | Node,
50
- ): Partial<BlockCardDefinition['attrs']> => {
51
- const anchor = dom as HTMLAnchorElement;
52
- const data = anchor.getAttribute('data-card-data');
53
- const datasource = anchor.getAttribute('data-datasource');
54
-
55
- return {
56
- data: data ? JSON.parse(data) : undefined,
57
- layout: datasource
58
- ? ((dom as HTMLElement).getAttribute('data-layout') as Layout) || 'center'
59
- : undefined,
60
- width: Number((dom as HTMLElement).getAttribute('data-width')) || undefined,
61
- datasource: datasource ? JSON.parse(datasource) : undefined,
62
- };
63
- };
64
-
65
- export const blockCard: NodeSpec = {
66
- inline: false,
67
- group: 'block',
68
- draggable: true,
69
- selectable: true,
70
- attrs: {
71
- url: { default: null },
72
- data: { default: null },
73
- datasource: { default: null },
74
- width: { default: null },
75
- layout: { default: null },
76
- },
77
- parseDOM: [
78
- {
79
- tag: 'a[data-block-card]',
80
-
81
- // bump priority higher than hyperlink
82
- priority: 100,
83
-
84
- getAttrs: (dom) => {
85
- const anchor = dom as HTMLAnchorElement;
86
-
87
- return {
88
- url: anchor.getAttribute('href') || undefined,
89
- ...getCommonAttributesFromDom(dom),
90
- };
91
- },
92
- },
93
-
94
- {
95
- tag: 'div[data-block-card]',
96
-
97
- getAttrs: (dom) => {
98
- const anchor = dom as HTMLDivElement;
99
-
100
- return {
101
- url: anchor.getAttribute('data-card-url') || undefined,
102
- ...getCommonAttributesFromDom(dom),
103
- };
104
- },
105
- },
106
- ],
107
- toDOM(node: PMNode) {
108
- const { url } = node.attrs as UrlType;
109
- const { data } = node.attrs as DataType;
110
- const { layout, width, datasource } = node.attrs as DatasourceAttributes;
111
- const attrs = {
112
- 'data-block-card': '',
113
- href: url || '',
114
- 'data-card-data': data ? JSON.stringify(data) : '',
115
- 'data-datasource': datasource ? JSON.stringify(datasource) : '',
116
- 'data-layout': layout,
117
- 'data-width': `${width}`,
118
- };
119
- return ['a', attrs, node?.attrs?.url || ' '];
120
- },
121
- };
@@ -1,25 +0,0 @@
1
- import { NodeSpec } from '@atlaskit/editor-prosemirror/model';
2
- import { ParagraphDefinition as Paragraph } from './paragraph';
3
-
4
- /**
5
- * @name blockquote_node
6
- */
7
- export interface BlockQuoteDefinition {
8
- type: 'blockquote';
9
- /**
10
- * @minItems 1
11
- * @allowUnsupportedBlock true
12
- */
13
- content: Array<Paragraph>;
14
- }
15
-
16
- export const blockquote: NodeSpec = {
17
- content: '(paragraph | unsupportedBlock)+',
18
- group: 'block',
19
- defining: true,
20
- selectable: false,
21
- parseDOM: [{ tag: 'blockquote' }],
22
- toDOM() {
23
- return ['blockquote', 0];
24
- },
25
- };
@@ -1,75 +0,0 @@
1
- import { NodeSpec, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
- import { getExtensionAttrs } from '../../utils/extensions';
3
- import { ExtensionAttributes } from './types/extensions';
4
- import { MarksObject } from './types/mark';
5
- import { NonNestableBlockContent } from './types/non-nestable-block-content';
6
- import { DataConsumerDefinition } from '../marks/data-consumer';
7
- import { FragmentDefinition } from '../marks/fragment';
8
-
9
- /**
10
- * @name bodiedExtension_node
11
- */
12
- export interface BodiedExtensionBaseDefinition {
13
- type: 'bodiedExtension';
14
- attrs: ExtensionAttributes;
15
- marks?: Array<any>;
16
- /**
17
- * @minItems 1
18
- * @allowUnsupportedBlock true
19
- */
20
- content: Array<NonNestableBlockContent>;
21
- }
22
-
23
- /**
24
- * @name bodiedExtension_with_marks_node
25
- */
26
- export type BodiedExtensionDefinition = BodiedExtensionBaseDefinition &
27
- MarksObject<DataConsumerDefinition | FragmentDefinition>;
28
-
29
- const createBodiedExtensionNodeSpec = (): NodeSpec => {
30
- const nodeSpec: NodeSpec = {
31
- inline: false,
32
- group: 'block',
33
- marks: 'dataConsumer fragment',
34
- content:
35
- '(paragraph | panel | blockquote | orderedList | bulletList | rule | heading | codeBlock | mediaGroup | mediaSingle | decisionList | taskList | table | blockCard | extension | unsupportedBlock | embedCard)+',
36
- defining: true,
37
- selectable: true,
38
- isolating: true,
39
- attrs: {
40
- extensionType: { default: '' },
41
- extensionKey: { default: '' },
42
- parameters: { default: null },
43
- text: { default: null },
44
- layout: { default: 'default' },
45
- localId: { default: null },
46
- },
47
- parseDOM: [
48
- {
49
- context: 'bodiedExtension//',
50
- tag: '[data-node-type="bodied-extension"]',
51
- skip: true,
52
- },
53
- {
54
- tag: '[data-node-type="bodied-extension"]',
55
- getAttrs: (domNode) => getExtensionAttrs(domNode as HTMLElement),
56
- },
57
- ],
58
- toDOM(node: PMNode) {
59
- const attrs = {
60
- 'data-node-type': 'bodied-extension',
61
- 'data-extension-type': node.attrs.extensionType,
62
- 'data-extension-key': node.attrs.extensionKey,
63
- 'data-text': node.attrs.text,
64
- 'data-parameters': JSON.stringify(node.attrs.parameters),
65
- 'data-layout': node.attrs.layout,
66
- 'data-local-id:': node.attrs.localId,
67
- };
68
- return ['div', attrs, 0];
69
- },
70
- };
71
-
72
- return nodeSpec;
73
- };
74
-
75
- export const bodiedExtension = createBodiedExtensionNodeSpec();
@@ -1,17 +0,0 @@
1
- import { NodeSpec } from '@atlaskit/editor-prosemirror/model';
2
-
3
- export const bulletListSelector = '.ak-ul';
4
-
5
- export const bulletList: NodeSpec = {
6
- group: 'block',
7
- content: 'listItem+',
8
- selectable: false,
9
- parseDOM: [{ tag: 'ul' }],
10
- marks: 'unsupportedMark unsupportedNodeAttribute',
11
- toDOM() {
12
- const attrs = {
13
- class: bulletListSelector.substr(1),
14
- };
15
- return ['ul', attrs, 0];
16
- },
17
- };
@@ -1,51 +0,0 @@
1
- import { NodeSpec } from '@atlaskit/editor-prosemirror/model';
2
- import { InlineFormattedText, InlineCode } from './types/inline-content';
3
- import { HardBreakDefinition as HardBreak } from './hard-break';
4
- import { MentionDefinition as Mention } from './mention';
5
- import { EmojiDefinition as Emoji } from './emoji';
6
- import { DateDefinition as Date } from './date';
7
- import { PlaceholderDefinition as Placeholder } from './placeholder';
8
- import { InlineCardDefinition as InlineCard } from './inline-card';
9
- import { StatusDefinition as Status } from './status';
10
-
11
- /**
12
- * @name caption_node
13
- */
14
- export interface CaptionDefinition {
15
- type: 'caption';
16
- /**
17
- * @minItems 0
18
- * @allowUnsupportedInline true
19
- */
20
- content: Array<
21
- | InlineFormattedText
22
- | InlineCode
23
- | HardBreak
24
- | Mention
25
- | Emoji
26
- | Date
27
- | Placeholder
28
- | InlineCard
29
- | Status
30
- >;
31
- }
32
-
33
- export const caption: NodeSpec = {
34
- content:
35
- '(text|hardBreak|mention|emoji|date|placeholder|inlineCard|status|unsupportedInline)*',
36
- isolating: true,
37
- marks: '_',
38
- selectable: false,
39
- parseDOM: [
40
- {
41
- tag: 'figcaption[data-caption]',
42
- },
43
- ],
44
- toDOM(node) {
45
- const attrs: Record<string, string> = {
46
- 'data-caption': 'true',
47
- };
48
-
49
- return ['figcaption', attrs, 0];
50
- },
51
- };