@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,478 +0,0 @@
1
- import { Node as PmNode, NodeSpec } from '@atlaskit/editor-prosemirror/model';
2
- import { CellAttributes } from '@atlaskit/editor-tables/types';
3
- import { hexToEditorBackgroundPaletteRawValue } from '@atlaskit/editor-palette';
4
- import {
5
- B100,
6
- B50,
7
- B75,
8
- G200,
9
- G50,
10
- G75,
11
- hexToRgba,
12
- isHex,
13
- isRgb,
14
- N0,
15
- N20,
16
- N60,
17
- N800,
18
- P100,
19
- P50,
20
- P75,
21
- R100,
22
- R50,
23
- R75,
24
- rgbToHex,
25
- T100,
26
- T50,
27
- T75,
28
- Y200,
29
- Y50,
30
- Y75,
31
- } from '../../utils/colors';
32
- import { PanelDefinition as Panel } from './panel';
33
- import {
34
- ParagraphDefinition as Paragraph,
35
- ParagraphWithAlignmentDefinition as ParagraphWithMarks,
36
- } from './paragraph';
37
- import { BlockQuoteDefinition as Blockquote } from './blockquote';
38
- import { OrderedListDefinition as OrderedList } from './types/list';
39
- import { BulletListDefinition as BulletList } from './types/list';
40
- import { RuleDefinition as Rule } from './rule';
41
- import {
42
- HeadingDefinition as Heading,
43
- HeadingWithMarksDefinition as HeadingWithMarks,
44
- } from './heading';
45
- import { CodeBlockDefinition as CodeBlock } from './code-block';
46
- import { MediaGroupDefinition as MediaGroup } from './media-group';
47
- import { MediaSingleDefinition as MediaSingle } from './media-single';
48
- import { DecisionListDefinition as DecisionList } from './decision-list';
49
- import { TaskListDefinition as TaskList } from './task-list';
50
- import { ExtensionDefinition as Extension } from './extension';
51
- import { BlockCardDefinition as BlockCard } from './block-card';
52
- import { EmbedCardDefinition as EmbedCard } from './embed-card';
53
- import { NestedExpandDefinition as NestedExpand } from './nested-expand';
54
- import { uuid } from '../../utils/uuid';
55
- import { FragmentDefinition } from '../marks/fragment';
56
-
57
- export type { CellAttributes };
58
- export const tablePrefixSelector = 'pm-table';
59
-
60
- export const tableCellSelector = `${tablePrefixSelector}-cell-content-wrap`;
61
- export const tableHeaderSelector = `${tablePrefixSelector}-header-content-wrap`;
62
- export const tableCellContentWrapperSelector = `${tablePrefixSelector}-cell-nodeview-wrapper`;
63
- export const tableCellContentDomSelector = `${tablePrefixSelector}-cell-nodeview-content-dom`;
64
-
65
- const DEFAULT_TABLE_HEADER_CELL_BACKGROUND = N20.toLocaleLowerCase();
66
-
67
- export const getCellAttrs: (
68
- dom: HTMLElement,
69
- defaultValues?: CellAttributes,
70
- ) => {
71
- colspan: number;
72
- rowspan: number;
73
- colwidth: number[] | null;
74
- background: string | null;
75
- } = (dom: HTMLElement, defaultValues: CellAttributes = {}) => {
76
- const widthAttr = dom.getAttribute('data-colwidth');
77
- const width =
78
- widthAttr && /^\d+(,\d+)*$/.test(widthAttr)
79
- ? widthAttr.split(',').map((str) => Number(str))
80
- : null;
81
- const colspan = Number(dom.getAttribute('colspan') || 1);
82
- let { backgroundColor } = dom.style;
83
-
84
- /**
85
- * We have pivoted to store background color information in
86
- * data-cell-background.
87
- * We will have original hex code (which we map to DST token)
88
- * stored in data-cell-background, use that.
89
- * More details at https://product-fabric.atlassian.net/wiki/spaces/EUXQ/pages/3472556903/Tokenising+tableCell+background+colors#Update-toDom-and-parseDom-to-store-and-read-background-color-from-data-cell-background-attribute.4
90
- */
91
- const dataCellBackground = dom.getAttribute('data-cell-background');
92
- const dataCellBackgroundHexCode =
93
- dataCellBackground && isHex(dataCellBackground)
94
- ? dataCellBackground
95
- : undefined;
96
-
97
- // ignore setting background attr if ds neutral token is detected
98
- if (backgroundColor.includes('--ds-background-neutral')) {
99
- backgroundColor = '';
100
- } else {
101
- if (backgroundColor && isRgb(backgroundColor)) {
102
- const result = rgbToHex(backgroundColor);
103
- if (result !== null) {
104
- backgroundColor = result;
105
- }
106
- }
107
- }
108
-
109
- const backgroundHexCode =
110
- dataCellBackgroundHexCode ||
111
- (backgroundColor && backgroundColor !== defaultValues['background']
112
- ? backgroundColor
113
- : null);
114
-
115
- return {
116
- colspan,
117
- rowspan: Number(dom.getAttribute('rowspan') || 1),
118
- colwidth: width && width.length === colspan ? width : null,
119
- background: backgroundHexCode,
120
- };
121
- };
122
-
123
- export type CellDomAttrs = {
124
- colspan?: string;
125
- rowspan?: string;
126
- style?: string;
127
- colorname?: string;
128
- 'data-colwidth'?: string;
129
- 'data-cell-background'?: string;
130
- class?: string;
131
- };
132
-
133
- /**
134
- * gets cell dom attributes based on node attributes
135
- * @returns CellDomAttrs
136
- */
137
- export const getCellDomAttrs = (node: PmNode): CellDomAttrs => {
138
- const attrs: CellDomAttrs = {};
139
- const nodeType = node.type.name;
140
-
141
- if (node.attrs.colspan !== 1) {
142
- attrs.colspan = node.attrs.colspan;
143
- }
144
- if (node.attrs.rowspan !== 1) {
145
- attrs.rowspan = node.attrs.rowspan;
146
- }
147
-
148
- if (node.attrs.colwidth) {
149
- attrs['data-colwidth'] = node.attrs.colwidth.join(',');
150
- }
151
- if (node.attrs.background) {
152
- const { background } = node.attrs;
153
-
154
- // to ensure that we don't overwrite product's style:
155
- // - it clears background color for <th> if its set to gray
156
- // - it clears background color for <td> if its set to white
157
- // - it clears background color for <th> if ds neutral token is detected
158
- const ignored =
159
- (nodeType === 'tableHeader' &&
160
- background === tableBackgroundColorNames.get('light gray')) ||
161
- (nodeType === 'tableCell' &&
162
- background === tableBackgroundColorNames.get('white')) ||
163
- (nodeType === 'tableHeader' &&
164
- background.includes('--ds-background-neutral'));
165
-
166
- if (ignored) {
167
- attrs.style = '';
168
- } else {
169
- const color =
170
- isRgb(background) && rgbToHex(background)
171
- ? rgbToHex(background)
172
- : background;
173
- const tokenColor = hexToEditorBackgroundPaletteRawValue(color) || color;
174
-
175
- attrs.style = `${attrs.style || ''}background-color: ${tokenColor};`;
176
-
177
- /**
178
- * Storing hex code in data-cell-background because
179
- * we want to have DST token (css variable) or
180
- * DST token value (value (hex code) of css variable) in
181
- * inline style to correct render table cell background
182
- * based on selected theme.
183
- * Currently we rely on background color hex code stored in
184
- * inline style.
185
- * Because of that when we copy and paste table, we end up
186
- * having DST token or DST token value in ADF instead of
187
- * original hex code which we map to DST token.
188
- * So, introducing data-cell-background.
189
- * More details at https://product-fabric.atlassian.net/wiki/spaces/EUXQ/pages/3472556903/Tokenising+tableCell+background+colors#Update-toDom-and-parseDom-to-store-and-read-background-color-from-data-cell-background-attribute.4
190
- */
191
- if (color) {
192
- attrs['data-cell-background'] = color;
193
- }
194
-
195
- attrs.colorname = tableBackgroundColorPalette.get(color);
196
- }
197
- }
198
-
199
- if (nodeType === 'tableHeader') {
200
- attrs.class = tableHeaderSelector;
201
- } else {
202
- attrs.class = tableCellSelector;
203
- }
204
-
205
- return attrs;
206
- };
207
-
208
- export const tableBackgroundColorPalette = new Map<string, string>();
209
-
210
- export const tableBackgroundBorderColor = hexToRgba(N800, 0.12) || N0;
211
- export const tableBackgroundColorNames = new Map<string, string>();
212
-
213
- [
214
- [N0, 'White'],
215
- [B50, 'Light blue'],
216
- [T50, 'Light teal'],
217
- [G50, 'Light green'],
218
- [Y50, 'Light yellow'],
219
- [R50, 'Light red'],
220
- [P50, 'Light purple'],
221
-
222
- [N20, 'Light gray'],
223
- [B75, 'Blue'],
224
- [T75, 'Teal'],
225
- [G75, 'Green'],
226
- [Y75, 'Yellow'],
227
- [R75, 'Red'],
228
- [P75, 'Purple'],
229
-
230
- [N60, 'Gray'],
231
- [B100, 'Dark blue'],
232
- [T100, 'Dark teal'],
233
- [G200, 'Dark green'],
234
- [Y200, 'Dark yellow'],
235
- [R100, 'Dark red'],
236
- [P100, 'Dark purple'],
237
- ].forEach(([colorValue, colorName]) => {
238
- tableBackgroundColorPalette.set(colorValue.toLowerCase(), colorName);
239
- tableBackgroundColorNames.set(
240
- colorName.toLowerCase(),
241
- colorValue.toLowerCase(),
242
- );
243
- });
244
-
245
- export type Layout = 'default' | 'full-width' | 'wide';
246
-
247
- export interface TableAttributes {
248
- isNumberColumnEnabled?: boolean;
249
- layout?: Layout;
250
- __autoSize?: boolean;
251
- /**
252
- * @minLength 1
253
- */
254
- localId?: string;
255
- /**
256
- * @stage 0
257
- */
258
- width?: number;
259
- }
260
-
261
- /**
262
- * @name table_node
263
- */
264
- export interface TableDefinition {
265
- type: 'table';
266
- attrs?: TableAttributes;
267
- /**
268
- * @minItems 1
269
- */
270
- content: Array<TableRow>;
271
- marks?: Array<FragmentDefinition>;
272
- }
273
-
274
- /**
275
- * @name table_row_node
276
- */
277
- export interface TableRow {
278
- type: 'tableRow';
279
- content: Array<TableHeader | TableCell>;
280
- }
281
-
282
- /**
283
- * @name table_cell_content
284
- * @minItems 1
285
- * @allowUnsupportedBlock true
286
- */
287
- export type TableCellContent = Array<
288
- | Panel
289
- | Paragraph
290
- | ParagraphWithMarks
291
- | Blockquote
292
- | OrderedList
293
- | BulletList
294
- | Rule
295
- | Heading
296
- | HeadingWithMarks
297
- | CodeBlock
298
- | MediaGroup
299
- | MediaSingle
300
- | DecisionList
301
- | TaskList
302
- | Extension
303
- | BlockCard
304
- | NestedExpand
305
- | EmbedCard
306
- >;
307
-
308
- /**
309
- * @name table_cell_node
310
- */
311
- export interface TableCell {
312
- type: 'tableCell';
313
- attrs?: CellAttributes;
314
- content: TableCellContent;
315
- }
316
-
317
- /**
318
- * @name table_header_node
319
- */
320
- export interface TableHeader {
321
- type: 'tableHeader';
322
- attrs?: CellAttributes;
323
- content: TableCellContent;
324
- }
325
-
326
- // TODO: Fix any, potential issue. ED-5048
327
- const createTableSpec = (allowCustomWidth: boolean = false): NodeSpec => {
328
- const attrs = {
329
- isNumberColumnEnabled: { default: false },
330
- layout: { default: 'default' },
331
- __autoSize: { default: false },
332
- localId: { default: '' },
333
- };
334
- const finalAttrs = allowCustomWidth
335
- ? {
336
- ...attrs,
337
- width: { default: null },
338
- }
339
- : attrs;
340
-
341
- const tableNodeSpec: NodeSpec = {
342
- content: 'tableRow+',
343
- attrs: finalAttrs,
344
- marks: 'unsupportedMark unsupportedNodeAttribute',
345
- tableRole: 'table',
346
- isolating: true,
347
- selectable: true,
348
- group: 'block',
349
- parseDOM: [
350
- {
351
- tag: 'table',
352
- getAttrs: (node: string | Node) => {
353
- const dom = node as HTMLElement;
354
- const breakoutWrapper = dom.parentElement?.parentElement;
355
-
356
- return {
357
- isNumberColumnEnabled:
358
- dom.getAttribute('data-number-column') === 'true',
359
- layout:
360
- // copying from editor
361
- dom.getAttribute('data-layout') ||
362
- // copying from renderer
363
- breakoutWrapper?.getAttribute('data-layout') ||
364
- 'default',
365
- __autoSize: dom.getAttribute('data-autosize') === 'true',
366
- localId: dom.getAttribute('data-table-local-id') || uuid.generate(),
367
- width: Number(dom.getAttribute('data-table-width')) || null,
368
- };
369
- },
370
- },
371
- ],
372
- toDOM(node: PmNode) {
373
- const attrs = {
374
- 'data-number-column': node.attrs.isNumberColumnEnabled,
375
- 'data-layout': node.attrs.layout,
376
- 'data-autosize': node.attrs.__autoSize,
377
- 'data-table-local-id': node.attrs.localId,
378
- 'data-table-width': node.attrs.width,
379
- };
380
- return ['table', attrs, ['tbody', 0]];
381
- },
382
- };
383
- return tableNodeSpec;
384
- };
385
-
386
- export const table = createTableSpec(false);
387
- export const tableWithCustomWidth = createTableSpec(true);
388
-
389
- const shouldIncludeAttribute = (key: string, value?: string) =>
390
- !key.startsWith('__') && (key !== 'localId' || !!value);
391
-
392
- export const tableToJSON = (node: PmNode) => ({
393
- attrs: Object.keys(node.attrs)
394
- .filter((key) => shouldIncludeAttribute(key, node.attrs[key]))
395
- .reduce<typeof node.attrs>((obj, key) => {
396
- return {
397
- ...obj,
398
- [key]: node.attrs[key],
399
- };
400
- }, {}),
401
- });
402
-
403
- export const tableRow: NodeSpec = {
404
- selectable: false,
405
- content: '(tableCell | tableHeader)+',
406
- marks: 'unsupportedMark unsupportedNodeAttribute',
407
- tableRole: 'row',
408
- parseDOM: [{ tag: 'tr' }],
409
- toDOM() {
410
- return ['tr', 0];
411
- },
412
- };
413
-
414
- const cellAttrs = {
415
- colspan: { default: 1 },
416
- rowspan: { default: 1 },
417
- colwidth: { default: null },
418
- background: { default: null },
419
- };
420
-
421
- export const tableCell: NodeSpec = {
422
- selectable: false,
423
- content:
424
- '(paragraph | panel | blockquote | orderedList | bulletList | rule | heading | codeBlock | mediaSingle | mediaGroup | decisionList | taskList | blockCard | embedCard | extension | nestedExpand | unsupportedBlock)+',
425
- attrs: cellAttrs,
426
- tableRole: 'cell',
427
- marks:
428
- 'alignment dataConsumer fragment unsupportedMark unsupportedNodeAttribute',
429
- isolating: true,
430
- parseDOM: [
431
- // Ignore number cell copied from renderer
432
- {
433
- tag: '.ak-renderer-table-number-column',
434
- ignore: true,
435
- },
436
- {
437
- tag: 'td',
438
- getAttrs: (dom: string | Node) => getCellAttrs(dom as HTMLElement),
439
- },
440
- ],
441
- toDOM: (node: PmNode) => ['td', getCellDomAttrs(node), 0],
442
- };
443
-
444
- export const toJSONTableCell = (node: PmNode) => ({
445
- attrs: (Object.keys(node.attrs) as Array<keyof CellAttributes>).reduce<
446
- Record<string, any>
447
- >((obj, key) => {
448
- if (cellAttrs[key].default !== node.attrs[key]) {
449
- obj[key] = node.attrs[key];
450
- }
451
-
452
- return obj;
453
- }, {}),
454
- });
455
-
456
- export const tableHeader: NodeSpec = {
457
- selectable: false,
458
- content:
459
- '(paragraph | panel | blockquote | orderedList | bulletList | rule | heading | codeBlock | mediaSingle | mediaGroup | decisionList | taskList | blockCard | embedCard | extension | nestedExpand)+',
460
- attrs: cellAttrs,
461
- tableRole: 'header_cell',
462
- isolating: true,
463
- marks:
464
- 'alignment dataConsumer fragment unsupportedMark unsupportedNodeAttribute',
465
- parseDOM: [
466
- {
467
- tag: 'th',
468
- getAttrs: (dom: string | Node) =>
469
- getCellAttrs(dom as HTMLElement, {
470
- background: DEFAULT_TABLE_HEADER_CELL_BACKGROUND,
471
- }),
472
- },
473
- ],
474
-
475
- toDOM: (node: PmNode) => ['th', getCellDomAttrs(node), 0],
476
- };
477
-
478
- export const toJSONTableHeader = toJSONTableCell;
@@ -1,51 +0,0 @@
1
- import { Node, NodeSpec } from '@atlaskit/editor-prosemirror/model';
2
- import { uuid } from '../../utils/uuid';
3
- import { Inline } from './types/inline-content';
4
-
5
- /**
6
- * @name taskItem_node
7
- */
8
- export interface TaskItemDefinition {
9
- type: 'taskItem';
10
- /**
11
- * @allowUnsupportedInline true
12
- */
13
- content?: Array<Inline>;
14
- attrs: {
15
- localId: string;
16
- state: 'TODO' | 'DONE';
17
- };
18
- }
19
-
20
- export const taskItem: NodeSpec = {
21
- content: 'inline*',
22
- defining: true,
23
- selectable: false,
24
- marks: '_',
25
- attrs: {
26
- localId: { default: '' },
27
- state: { default: 'TODO' },
28
- },
29
- parseDOM: [
30
- {
31
- tag: 'div[data-task-local-id]',
32
-
33
- // Default priority is 50. We normally don't change this but since this node type is
34
- // also used by list-item we need to make sure that we run this parser first.
35
- priority: 100,
36
-
37
- getAttrs: (dom) => ({
38
- localId: uuid.generate(),
39
- state: (dom as HTMLElement).getAttribute('data-task-state') || 'TODO',
40
- }),
41
- },
42
- ],
43
- toDOM(node: Node) {
44
- const { localId, state } = node.attrs;
45
- const attrs = {
46
- 'data-task-local-id': localId || 'local-task',
47
- 'data-task-state': state || 'TODO',
48
- };
49
- return ['div', attrs, 0];
50
- },
51
- };
@@ -1,61 +0,0 @@
1
- import { Node, NodeSpec } from '@atlaskit/editor-prosemirror/model';
2
- import { TaskItemDefinition as TaskItemNode } from './task-item';
3
- import { uuid } from '../../utils/uuid';
4
-
5
- export interface TaskListContent
6
- extends Array<TaskItemNode | TaskListDefinition> {
7
- 0: TaskItemNode;
8
- }
9
-
10
- /**
11
- * @name taskList_node
12
- */
13
- export interface TaskListDefinition {
14
- type: 'taskList';
15
- /**
16
- * @minItems 1
17
- * @allowUnsupportedBlock true
18
- */
19
- content: TaskListContent;
20
- attrs: {
21
- localId: string;
22
- };
23
- }
24
-
25
- const name = 'actionList';
26
-
27
- export const taskListSelector = `[data-node-type="${name}"]`;
28
-
29
- export const taskList: NodeSpec = {
30
- group: 'block',
31
- defining: true,
32
- selectable: false,
33
- content: '(taskItem|unsupportedBlock)+ (taskItem|taskList|unsupportedBlock)*',
34
- marks: 'unsupportedMark unsupportedNodeAttribute',
35
- attrs: {
36
- localId: { default: '' },
37
- },
38
- parseDOM: [
39
- {
40
- tag: `div${taskListSelector}`,
41
-
42
- // Default priority is 50. We normally don't change this but since this node type is
43
- // also used by ordered-list we need to make sure that we run this parser first.
44
- priority: 100,
45
-
46
- getAttrs: () => ({
47
- localId: uuid.generate(),
48
- }),
49
- },
50
- ],
51
- toDOM(node: Node) {
52
- const { localId } = node.attrs;
53
- const attrs = {
54
- 'data-node-type': name,
55
- 'data-task-list-local-id': localId || 'local-task-list',
56
- style: 'list-style: none; padding-left: 0',
57
- };
58
-
59
- return ['div', attrs, 0];
60
- },
61
- };
@@ -1,19 +0,0 @@
1
- import { NodeSpec } from '@atlaskit/editor-prosemirror/model';
2
-
3
- /**
4
- * @name text_node
5
- */
6
- export interface TextDefinition {
7
- type: 'text';
8
- /**
9
- * @minLength 1
10
- */
11
- text: string;
12
- marks?: Array<any>;
13
- }
14
-
15
- export const text: NodeSpec & { toDebugString?: () => string } = {
16
- group: 'inline',
17
- toDebugString:
18
- process.env.NODE_ENV !== 'production' ? undefined : () => 'text_node',
19
- };
@@ -1,51 +0,0 @@
1
- import { ExpandDefinition as Expand } from '../expand';
2
- import { BodiedExtensionDefinition as BodiedExtension } from '../bodied-extension';
3
- import { PanelDefinition as Panel } from '../panel';
4
- import {
5
- ParagraphDefinition as Paragraph,
6
- ParagraphWithMarksDefinition as ParagraphWithMarks,
7
- } from '../paragraph';
8
- import { BlockQuoteDefinition as Blockquote } from '../blockquote';
9
- import { OrderedListDefinition as OrderedList } from '../types/list';
10
- import { BulletListDefinition as BulletList } from '../types/list';
11
- import { RuleDefinition as Rule } from '../rule';
12
- import {
13
- HeadingDefinition as Heading,
14
- HeadingWithMarksDefinition as HeadingWithMarks,
15
- } from '../heading';
16
- import { CodeBlockDefinition as CodeBlock } from '../code-block';
17
- import { MediaGroupDefinition as MediaGroup } from '../media-group';
18
- import { MediaSingleDefinition as MediaSingle } from '../media-single';
19
- import { DecisionListDefinition as DecisionList } from '../decision-list';
20
- import { TaskListDefinition as TaskList } from '../task-list';
21
- import { TableDefinition as Table } from '../tableNodes';
22
- import { ExtensionDefinition as Extension } from '../extension';
23
- import { BlockCardDefinition as BlockCard } from '../block-card';
24
- import { EmbedCardDefinition as EmbedCard } from '../embed-card';
25
-
26
- // NOTE: BlockContent is only being used by layoutColumn now.
27
-
28
- /**
29
- * @name block_content
30
- */
31
- export type BlockContent =
32
- | Panel
33
- | Paragraph
34
- | ParagraphWithMarks
35
- | Blockquote
36
- | OrderedList
37
- | BulletList
38
- | Rule
39
- | Heading
40
- | HeadingWithMarks
41
- | CodeBlock
42
- | MediaGroup
43
- | MediaSingle
44
- | DecisionList
45
- | TaskList
46
- | Table
47
- | Expand
48
- | Extension
49
- | BodiedExtension
50
- | BlockCard
51
- | EmbedCard;
@@ -1,36 +0,0 @@
1
- export type Layout = 'default' | 'wide' | 'full-width';
2
-
3
- export interface ExtensionAttributes {
4
- /**
5
- * @minLength 1
6
- */
7
- extensionKey: string;
8
- /**
9
- * @minLength 1
10
- */
11
- extensionType: string;
12
- parameters?: object;
13
- text?: string;
14
- layout?: Layout;
15
- /**
16
- * @minLength 1
17
- */
18
- localId?: string;
19
- }
20
-
21
- export interface InlineExtensionAttributes {
22
- /**
23
- * @minLength 1
24
- */
25
- extensionKey: string;
26
- /**
27
- * @minLength 1
28
- */
29
- extensionType: string;
30
- parameters?: object;
31
- text?: string;
32
- /**
33
- * @minLength 1
34
- */
35
- localId?: string;
36
- }