@atlaskit/adf-schema 28.1.12 → 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 (209) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/package.json +1 -1
  3. package/src/__tests__/unit/json-schema/v1.ts +0 -55
  4. package/src/__tests__/unit/schema/create-schema.ts +0 -214
  5. package/src/__tests__/unit/schema/default-schema.ts +0 -192
  6. package/src/__tests__/unit/schema/marks/annotation.ts +0 -46
  7. package/src/__tests__/unit/schema/marks/border.ts +0 -76
  8. package/src/__tests__/unit/schema/marks/breakout.ts +0 -24
  9. package/src/__tests__/unit/schema/marks/code.ts +0 -44
  10. package/src/__tests__/unit/schema/marks/confluence-inline-comment.ts +0 -25
  11. package/src/__tests__/unit/schema/marks/data-consumer.ts +0 -52
  12. package/src/__tests__/unit/schema/marks/em.ts +0 -37
  13. package/src/__tests__/unit/schema/marks/link.ts +0 -188
  14. package/src/__tests__/unit/schema/marks/strike.ts +0 -37
  15. package/src/__tests__/unit/schema/marks/strong.ts +0 -43
  16. package/src/__tests__/unit/schema/marks/subsup.ts +0 -50
  17. package/src/__tests__/unit/schema/marks/text-color.ts +0 -61
  18. package/src/__tests__/unit/schema/marks/underline.ts +0 -36
  19. package/src/__tests__/unit/schema/nodes/_consts.ts +0 -964
  20. package/src/__tests__/unit/schema/nodes/block-card.ts +0 -184
  21. package/src/__tests__/unit/schema/nodes/blockquote.ts +0 -44
  22. package/src/__tests__/unit/schema/nodes/bodied-extension.ts +0 -101
  23. package/src/__tests__/unit/schema/nodes/code-block.ts +0 -221
  24. package/src/__tests__/unit/schema/nodes/confluence-unsupported-block.ts +0 -32
  25. package/src/__tests__/unit/schema/nodes/confluence-unsupported-inline.ts +0 -35
  26. package/src/__tests__/unit/schema/nodes/date.ts +0 -51
  27. package/src/__tests__/unit/schema/nodes/decision-item.ts +0 -46
  28. package/src/__tests__/unit/schema/nodes/decision-list.ts +0 -52
  29. package/src/__tests__/unit/schema/nodes/embed-card.ts +0 -60
  30. package/src/__tests__/unit/schema/nodes/emoji.ts +0 -71
  31. package/src/__tests__/unit/schema/nodes/expand.ts +0 -51
  32. package/src/__tests__/unit/schema/nodes/extension.ts +0 -101
  33. package/src/__tests__/unit/schema/nodes/hard-break.ts +0 -24
  34. package/src/__tests__/unit/schema/nodes/heading.ts +0 -56
  35. package/src/__tests__/unit/schema/nodes/image.ts +0 -32
  36. package/src/__tests__/unit/schema/nodes/inline-card.ts +0 -106
  37. package/src/__tests__/unit/schema/nodes/inline-extension.ts +0 -79
  38. package/src/__tests__/unit/schema/nodes/layout-column.ts +0 -54
  39. package/src/__tests__/unit/schema/nodes/layout-section.ts +0 -95
  40. package/src/__tests__/unit/schema/nodes/list-item.ts +0 -49
  41. package/src/__tests__/unit/schema/nodes/media-group.ts +0 -67
  42. package/src/__tests__/unit/schema/nodes/media-single.ts +0 -171
  43. package/src/__tests__/unit/schema/nodes/media.ts +0 -384
  44. package/src/__tests__/unit/schema/nodes/mention.ts +0 -115
  45. package/src/__tests__/unit/schema/nodes/nestedExpand.ts +0 -72
  46. package/src/__tests__/unit/schema/nodes/ordered-list.ts +0 -49
  47. package/src/__tests__/unit/schema/nodes/panel.ts +0 -180
  48. package/src/__tests__/unit/schema/nodes/paragraph.ts +0 -25
  49. package/src/__tests__/unit/schema/nodes/placeholder.ts +0 -46
  50. package/src/__tests__/unit/schema/nodes/rule.ts +0 -24
  51. package/src/__tests__/unit/schema/nodes/status.ts +0 -120
  52. package/src/__tests__/unit/schema/nodes/tableNodes.ts +0 -555
  53. package/src/__tests__/unit/schema/nodes/task-item.ts +0 -39
  54. package/src/__tests__/unit/schema/nodes/task-list.ts +0 -45
  55. package/src/__tests__/unit/schema/nodes/unknown-block.ts +0 -42
  56. package/src/__tests__/unit/schema/nodes/unsupported-block.ts +0 -42
  57. package/src/__tests__/unit/schema/nodes/unsupported-inline.ts +0 -38
  58. package/src/__tests__/unit/utils/colors.ts +0 -42
  59. package/src/__tests__/unit/utils/url.ts +0 -209
  60. package/src/schema/bitbucket-schema.ts +0 -43
  61. package/src/schema/confluence-schema.ts +0 -76
  62. package/src/schema/create-schema.ts +0 -337
  63. package/src/schema/default-schema.ts +0 -180
  64. package/src/schema/groups.ts +0 -30
  65. package/src/schema/inline-nodes.ts +0 -9
  66. package/src/schema/jira-schema.ts +0 -158
  67. package/src/schema/marks/__tests__/unit/annotation.ts +0 -18
  68. package/src/schema/marks/alignment.ts +0 -48
  69. package/src/schema/marks/annotation.ts +0 -107
  70. package/src/schema/marks/border.ts +0 -74
  71. package/src/schema/marks/breakout.ts +0 -42
  72. package/src/schema/marks/code.ts +0 -45
  73. package/src/schema/marks/confluence-inline-comment.ts +0 -32
  74. package/src/schema/marks/data-consumer.ts +0 -100
  75. package/src/schema/marks/em.ts +0 -19
  76. package/src/schema/marks/fragment.ts +0 -77
  77. package/src/schema/marks/indentation.ts +0 -47
  78. package/src/schema/marks/link.ts +0 -139
  79. package/src/schema/marks/strike.ts +0 -26
  80. package/src/schema/marks/strong.ts +0 -45
  81. package/src/schema/marks/subsup.ts +0 -53
  82. package/src/schema/marks/text-color.ts +0 -172
  83. package/src/schema/marks/type-ahead-query.ts +0 -22
  84. package/src/schema/marks/underline.ts +0 -24
  85. package/src/schema/marks/unsupported-mark.ts +0 -9
  86. package/src/schema/marks/unsupported-node-attributes.ts +0 -8
  87. package/src/schema/nodes/block-card.ts +0 -121
  88. package/src/schema/nodes/blockquote.ts +0 -25
  89. package/src/schema/nodes/bodied-extension.ts +0 -75
  90. package/src/schema/nodes/bullet-list.ts +0 -17
  91. package/src/schema/nodes/caption.ts +0 -51
  92. package/src/schema/nodes/code-block.ts +0 -176
  93. package/src/schema/nodes/confluence-jira-issue.ts +0 -43
  94. package/src/schema/nodes/confluence-unsupported-block.ts +0 -29
  95. package/src/schema/nodes/confluence-unsupported-inline.ts +0 -30
  96. package/src/schema/nodes/date.ts +0 -38
  97. package/src/schema/nodes/decision-item.ts +0 -50
  98. package/src/schema/nodes/decision-list.ts +0 -56
  99. package/src/schema/nodes/doc.ts +0 -30
  100. package/src/schema/nodes/embed-card.ts +0 -62
  101. package/src/schema/nodes/emoji.ts +0 -89
  102. package/src/schema/nodes/expand.ts +0 -101
  103. package/src/schema/nodes/extension.ts +0 -60
  104. package/src/schema/nodes/hard-break.ts +0 -21
  105. package/src/schema/nodes/heading.ts +0 -64
  106. package/src/schema/nodes/image.ts +0 -32
  107. package/src/schema/nodes/inline-card.ts +0 -70
  108. package/src/schema/nodes/inline-extension.ts +0 -57
  109. package/src/schema/nodes/layout-column.ts +0 -68
  110. package/src/schema/nodes/layout-section.ts +0 -93
  111. package/src/schema/nodes/list-item.ts +0 -13
  112. package/src/schema/nodes/media-group.ts +0 -44
  113. package/src/schema/nodes/media-inline.ts +0 -19
  114. package/src/schema/nodes/media-single.ts +0 -179
  115. package/src/schema/nodes/media.ts +0 -253
  116. package/src/schema/nodes/mention.ts +0 -86
  117. package/src/schema/nodes/nested-expand.ts +0 -77
  118. package/src/schema/nodes/ordered-list.ts +0 -62
  119. package/src/schema/nodes/panel.ts +0 -133
  120. package/src/schema/nodes/paragraph.ts +0 -79
  121. package/src/schema/nodes/placeholder.ts +0 -40
  122. package/src/schema/nodes/rule.ts +0 -17
  123. package/src/schema/nodes/status.ts +0 -58
  124. package/src/schema/nodes/tableNodes.ts +0 -478
  125. package/src/schema/nodes/task-item.ts +0 -51
  126. package/src/schema/nodes/task-list.ts +0 -61
  127. package/src/schema/nodes/text.ts +0 -19
  128. package/src/schema/nodes/types/block-content.ts +0 -51
  129. package/src/schema/nodes/types/extensions.ts +0 -36
  130. package/src/schema/nodes/types/inline-content.ts +0 -56
  131. package/src/schema/nodes/types/list.ts +0 -54
  132. package/src/schema/nodes/types/mark.ts +0 -16
  133. package/src/schema/nodes/types/non-nestable-block-content.ts +0 -39
  134. package/src/schema/nodes/types/rich-media-common.ts +0 -51
  135. package/src/schema/nodes/unknown-block.ts +0 -13
  136. package/src/schema/nodes/unsupported-block.ts +0 -28
  137. package/src/schema/nodes/unsupported-inline.ts +0 -27
  138. package/src/schema/unsupported.ts +0 -4
  139. package/src/steps/__tests__/unit/analytics.ts +0 -72
  140. package/src/steps/__tests__/unit/link-meta-step.ts +0 -64
  141. package/src/steps/__tests__/unit/override-document-step.ts +0 -174
  142. package/src/steps/__tests__/unit/set-attrs.ts +0 -71
  143. package/src/steps/analytics.ts +0 -189
  144. package/src/steps/link-meta-step.ts +0 -105
  145. package/src/steps/override-document-step.ts +0 -97
  146. package/src/steps/set-attrs.tsx +0 -74
  147. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-0.json +0 -15
  148. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-1.json +0 -15
  149. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-2.json +0 -15
  150. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-3.json +0 -15
  151. package/src/steps/table/__tests__/__fixtures__/basic/remove-column-at-0.json +0 -9
  152. package/src/steps/table/__tests__/__fixtures__/basic/remove-column-at-1.json +0 -9
  153. package/src/steps/table/__tests__/__fixtures__/basic/remove-column-at-2.json +0 -9
  154. package/src/steps/table/__tests__/__fixtures__/basic/remove-table/remove-last-row-inverted.json +0 -98
  155. package/src/steps/table/__tests__/__fixtures__/basic/remove-table/remove-last-row.json +0 -71
  156. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-0-inverted.json +0 -19
  157. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-0.json +0 -19
  158. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-1-inverted.json +0 -21
  159. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-1.json +0 -21
  160. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-2-inverted.json +0 -21
  161. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-2.json +0 -21
  162. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-3-inverted.json +0 -19
  163. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-3.json +0 -19
  164. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-0-inverted.json +0 -63
  165. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-0.json +0 -21
  166. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-1-inverted.json +0 -64
  167. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-1.json +0 -22
  168. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-2-inverted.json +0 -63
  169. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-2.json +0 -21
  170. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-0-inverted.json +0 -19
  171. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-0.json +0 -19
  172. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-1-inverted.json +0 -19
  173. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-1.json +0 -19
  174. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-2-inverted.json +0 -19
  175. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-2.json +0 -19
  176. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-3-inverted.json +0 -19
  177. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-3.json +0 -19
  178. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-0-inverted.json +0 -52
  179. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-0.json +0 -38
  180. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-1-inverted.json +0 -52
  181. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-1.json +0 -38
  182. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-2-inverted.json +0 -25
  183. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-2.json +0 -11
  184. package/src/steps/table/__tests__/_utils.ts +0 -102
  185. package/src/steps/table/__tests__/add-column-merge-columns.ts +0 -509
  186. package/src/steps/table/__tests__/add-column-merge-rows.ts +0 -466
  187. package/src/steps/table/__tests__/add-column.ts +0 -638
  188. package/src/steps/table/add-column.ts +0 -443
  189. package/src/steps/table/constants.ts +0 -4
  190. package/src/steps/table/sort-column.ts +0 -57
  191. package/src/steps/table/types.ts +0 -48
  192. package/src/steps/table/utils/cell-step.ts +0 -239
  193. package/src/steps/table/utils/cells-at-column.ts +0 -75
  194. package/src/steps/table/utils/find-column.ts +0 -90
  195. package/src/steps/table/utils/get-table-rect-from-doc.ts +0 -37
  196. package/src/steps/table/utils/side-effects/rows.ts +0 -327
  197. package/src/steps/table/utils/side-effects/side-effects.ts +0 -90
  198. package/src/steps/table/utils/side-effects/table.ts +0 -112
  199. package/src/steps/table/utils/side-effects/types.ts +0 -34
  200. package/src/steps/table/utils/table-map.ts +0 -28
  201. package/src/steps/type-ahead.ts +0 -100
  202. package/src/steps.ts +0 -16
  203. package/src/utils/colors.ts +0 -171
  204. package/src/utils/confluence/emoji.ts +0 -99
  205. package/src/utils/extensions.ts +0 -32
  206. package/src/utils/parseDOM.ts +0 -2
  207. package/src/utils/url.ts +0 -173
  208. package/src/utils/uuid.ts +0 -19
  209. package/src/version.json +0 -6
@@ -1,18 +0,0 @@
1
- import { AnnotationTypes, buildDataAttributes } from '../../annotation';
2
-
3
- describe('marks/annotations', () => {
4
- describe('#buildDataAttributes', () => {
5
- it('should return an object with the data attributes', () => {
6
- const result = buildDataAttributes({
7
- id: '999',
8
- annotationType: AnnotationTypes.INLINE_COMMENT,
9
- });
10
-
11
- expect(result).toEqual({
12
- 'data-mark-type': 'annotation',
13
- 'data-mark-annotation-type': 'inlineComment',
14
- 'data-id': '999',
15
- });
16
- });
17
- });
18
- });
@@ -1,48 +0,0 @@
1
- import { MarkSpec } from '@atlaskit/editor-prosemirror/model';
2
- import { ALIGNMENT, INDENTATION } from '../groups';
3
-
4
- /** TODO: Flip these positions for RTL */
5
- export const alignmentPositionMap: { [key: string]: string } = {
6
- end: 'right',
7
- right: 'end',
8
- center: 'center',
9
- };
10
-
11
- export interface AlignmentAttributes {
12
- align: 'center' | 'end';
13
- }
14
-
15
- /**
16
- * @name alignment_mark
17
- */
18
- export interface AlignmentMarkDefinition {
19
- type: 'alignment';
20
- attrs: AlignmentAttributes;
21
- }
22
-
23
- export const alignment: MarkSpec = {
24
- excludes: `alignment ${INDENTATION}`,
25
- group: ALIGNMENT,
26
- attrs: {
27
- align: {},
28
- },
29
- parseDOM: [
30
- {
31
- tag: 'div.fabric-editor-block-mark',
32
- getAttrs: (dom) => {
33
- const align = (dom as Element).getAttribute('data-align');
34
- return align ? { align } : false;
35
- },
36
- },
37
- ],
38
- toDOM(mark) {
39
- return [
40
- 'div',
41
- {
42
- class: `fabric-editor-block-mark fabric-editor-alignment fabric-editor-align-${mark.attrs.align}`,
43
- 'data-align': mark.attrs.align,
44
- },
45
- 0,
46
- ];
47
- },
48
- };
@@ -1,107 +0,0 @@
1
- import { MarkSpec } from '@atlaskit/editor-prosemirror/model';
2
-
3
- /**
4
- * @name annotation_mark
5
- */
6
- export interface AnnotationMarkDefinition {
7
- type: 'annotation';
8
- attrs: AnnotationMarkAttributes;
9
- }
10
-
11
- export interface AnnotationMarkAttributes {
12
- id: AnnotationId;
13
- annotationType: AnnotationTypes;
14
- }
15
-
16
- export type AnnotationId = string;
17
- export enum AnnotationTypes {
18
- INLINE_COMMENT = 'inlineComment',
19
- }
20
- export enum AnnotationMarkStates {
21
- RESOLVED = 'resolved',
22
- ACTIVE = 'active',
23
- }
24
-
25
- export type AnnotationDataAttributes = {
26
- 'data-mark-type': string;
27
- 'data-mark-annotation-type': AnnotationTypes;
28
- 'data-id': AnnotationId;
29
- 'data-mark-annotation-state'?: AnnotationMarkStates;
30
- };
31
-
32
- type BuildDataAttributesProps = AnnotationMarkAttributes & {
33
- state?: AnnotationMarkStates | undefined | null;
34
- };
35
- export function buildDataAttributes({
36
- id,
37
- annotationType,
38
- state,
39
- }: BuildDataAttributesProps): AnnotationDataAttributes {
40
- const data = {
41
- 'data-mark-type': 'annotation',
42
- 'data-mark-annotation-type': annotationType,
43
- 'data-id': id,
44
- };
45
-
46
- if (state) {
47
- return {
48
- ...data,
49
- 'data-mark-annotation-state': state,
50
- };
51
- }
52
-
53
- return data;
54
- }
55
-
56
- export const annotation: MarkSpec = {
57
- inclusive: true,
58
- group: 'annotation',
59
- excludes: '',
60
- attrs: {
61
- id: {
62
- default: '',
63
- },
64
- annotationType: {
65
- default: AnnotationTypes.INLINE_COMMENT,
66
- },
67
- },
68
- parseDOM: [
69
- {
70
- tag: 'span[data-mark-type="annotation"]',
71
- mark: 'annotation',
72
- getAttrs: (domNode) => {
73
- const dom = domNode as HTMLElement;
74
- let attrs: AnnotationMarkAttributes = {
75
- id: dom.getAttribute('data-id') as string,
76
- annotationType: dom.getAttribute(
77
- 'data-mark-annotation-type',
78
- ) as AnnotationTypes,
79
- };
80
-
81
- return attrs;
82
- },
83
- },
84
- ],
85
- toDOM(node) {
86
- /*
87
- Data attributes on the DOM node are a temporary means of
88
- incrementally switching over to the Annotation mark. Once renderer
89
- provides native support for inline comments the data attributes on the
90
- DOM nodes will be removed.
91
- */
92
- return [
93
- 'span',
94
- {
95
- // Prettier will remove the quotes around class. This would cause some browsers
96
- // to not add this attribute properly, as its a reserved word.
97
- // prettier-ignore
98
- 'class': 'fabric-editor-annotation',
99
- ...buildDataAttributes({
100
- id: node.attrs.id as AnnotationId,
101
- annotationType: node.attrs.annotationType as AnnotationTypes,
102
- }),
103
- } as any,
104
- 0,
105
- ];
106
- },
107
- };
@@ -1,74 +0,0 @@
1
- import { MarkSpec } from '@atlaskit/editor-prosemirror/model';
2
- import { hexToEditorBorderPaletteColor } from '@atlaskit/editor-palette';
3
- import { N300A, N600, N1000 } from '../../utils/colors';
4
-
5
- export type BorderMarkAttributes = {
6
- /**
7
- * @minimum 1
8
- * @maximum 3
9
- */
10
- size: number;
11
- /**
12
- * @pattern "^#[0-9a-fA-F]{8}$|^#[0-9a-fA-F]{6}$"
13
- */
14
- color: string;
15
- };
16
-
17
- /**
18
- * @name border_mark
19
- * @description This mark adds decoration to an element, and any element decorated with it will also have a border style.
20
- */
21
- export interface BorderMarkDefinition {
22
- type: 'border';
23
- attrs: BorderMarkAttributes;
24
- }
25
-
26
- export type BorderColorKey = 'Subtle gray' | 'Gray' | 'Bold gray';
27
-
28
- const borderColorArrayPalette: Array<[string, BorderColorKey]> = [
29
- [N300A, 'Subtle gray'],
30
- [N600, 'Gray'],
31
- [N1000, 'Bold gray'],
32
- ];
33
-
34
- export const borderColorPalette = new Map<string, BorderColorKey>();
35
-
36
- borderColorArrayPalette.forEach(([color, label]) =>
37
- borderColorPalette.set(color.toLowerCase(), label),
38
- );
39
-
40
- export const border: MarkSpec = {
41
- inclusive: false,
42
- parseDOM: [
43
- {
44
- tag: 'div[data-mark-type="border"]',
45
- getAttrs: (domNode) => {
46
- const dom = domNode as HTMLElement;
47
- const color = (dom.getAttribute('data-color') ?? '').toLowerCase();
48
- const size = +(dom.getAttribute('data-size') ?? '0');
49
-
50
- return {
51
- size: size > 3 ? 3 : size < 1 ? false : size,
52
- color: borderColorPalette.has(color) ? color : false,
53
- };
54
- },
55
- },
56
- ],
57
- attrs: { color: {}, size: {} },
58
- toDOM(mark) {
59
- // Note -- while there is no way to create custom colors using default tooling
60
- // the editor does supported ad hoc color values -- and there may be content
61
- // which has been migrated or created via apis which use such values.
62
- const paletteColorValue =
63
- hexToEditorBorderPaletteColor(mark.attrs.color) || mark.attrs.color;
64
- return [
65
- 'div',
66
- {
67
- 'data-mark-type': 'border',
68
- 'data-color': mark.attrs.color,
69
- 'data-size': mark.attrs.size,
70
- style: `--custom-palette-color: ${paletteColorValue}`,
71
- },
72
- ];
73
- },
74
- };
@@ -1,42 +0,0 @@
1
- import { MarkSpec } from '@atlaskit/editor-prosemirror/model';
2
-
3
- const allowedTypes = ['wide', 'full-width'];
4
-
5
- export type BreakoutMarkAttrs = {
6
- mode: 'wide' | 'full-width';
7
- };
8
-
9
- /**
10
- * @name breakout_mark
11
- */
12
- export interface BreakoutMarkDefinition {
13
- type: 'breakout';
14
- attrs: BreakoutMarkAttrs;
15
- }
16
-
17
- export const breakout: MarkSpec = {
18
- spanning: false,
19
- inclusive: false,
20
- parseDOM: [
21
- {
22
- tag: 'div.fabric-editor-breakout-mark',
23
- getAttrs(dom) {
24
- const mode = (dom as HTMLElement).getAttribute('data-mode');
25
-
26
- return {
27
- mode: allowedTypes.indexOf(mode || '') === -1 ? 'wide' : mode,
28
- };
29
- },
30
- },
31
- ],
32
- attrs: {
33
- mode: { default: 'wide' },
34
- },
35
- toDOM(mark) {
36
- return [
37
- 'div',
38
- { class: 'fabric-editor-breakout-mark', 'data-mode': mark.attrs.mode },
39
- 0,
40
- ];
41
- },
42
- };
@@ -1,45 +0,0 @@
1
- import { MarkSpec } from '@atlaskit/editor-prosemirror/model';
2
- import { COLOR, FONT_STYLE, LINK, SEARCH_QUERY } from '../groups';
3
-
4
- /**
5
- * @name code_mark
6
- */
7
- export interface CodeDefinition {
8
- type: 'code';
9
- }
10
-
11
- export const code: MarkSpec = {
12
- excludes: `${FONT_STYLE} ${LINK} ${SEARCH_QUERY} ${COLOR}`,
13
- inclusive: true,
14
- parseDOM: [
15
- { tag: 'span.code', preserveWhitespace: true },
16
- { tag: 'code', preserveWhitespace: true },
17
- { tag: 'tt', preserveWhitespace: true },
18
- {
19
- tag: 'span',
20
- preserveWhitespace: true,
21
- getAttrs: (domNode) => {
22
- let dom = domNode as HTMLSpanElement;
23
- if (dom.style.whiteSpace === 'pre') {
24
- return {};
25
- }
26
- if (
27
- dom.style.fontFamily &&
28
- dom.style.fontFamily.toLowerCase().indexOf('monospace') >= 0
29
- ) {
30
- return {};
31
- }
32
- return false;
33
- },
34
- },
35
- ],
36
- toDOM() {
37
- return [
38
- 'span',
39
- {
40
- class: 'code',
41
- spellcheck: 'false',
42
- },
43
- ];
44
- },
45
- };
@@ -1,32 +0,0 @@
1
- import { MarkSpec } from '@atlaskit/editor-prosemirror/model';
2
-
3
- /**
4
- * @name inline_comment_marker
5
- * @description This temporary mark represents a Confluence-backed inline comment that wraps a piece of text. It will be replaced with a cross-product inline comment solution at later date.
6
- */
7
- export interface ConfluenceInlineCommentDefinition {
8
- type: 'confluenceInlineComment';
9
- attrs: {
10
- reference: string;
11
- };
12
- }
13
-
14
- export const confluenceInlineComment: MarkSpec = {
15
- inclusive: false,
16
- excludes: '',
17
- attrs: {
18
- reference: {
19
- default: '',
20
- },
21
- },
22
- parseDOM: [{ tag: 'span[data-mark-type="confluenceInlineComment"]' }],
23
- toDOM(node) {
24
- return [
25
- 'span',
26
- {
27
- 'data-mark-type': 'confluenceInlineComment',
28
- 'data-reference': node.attrs.reference,
29
- },
30
- ];
31
- },
32
- };
@@ -1,100 +0,0 @@
1
- import { Mark, MarkSpec } from '@atlaskit/editor-prosemirror/model';
2
- import { isDOMElement } from '../../utils/parseDOM';
3
-
4
- /**
5
- * This annotation is purely for reference, & does _nothing_ given annotating
6
- * `minLength` on an array of strings is not supported with our schema+spec
7
- * generator.
8
- *
9
- * We're keeping it to signal that data consumer `sources` shouldn't be empty
10
- * strings
11
- *
12
- * // @minLength 1
13
- */
14
- type DataConsumerSource = string;
15
-
16
- export interface DataConsumerAttributes {
17
- /**
18
- * @minItems 1
19
- */
20
- sources: Array<DataConsumerSource>;
21
- }
22
-
23
- /**
24
- * @name dataConsumer_mark
25
- * @description This mark is used for metadata surrounding a node consuming data
26
- * from a given source node
27
- */
28
- export interface DataConsumerDefinition {
29
- type: 'dataConsumer';
30
- attrs: DataConsumerAttributes;
31
- }
32
-
33
- export interface DataConsumerMark extends Mark {
34
- attrs: DataConsumerAttributes;
35
- }
36
-
37
- const parseDataConsumer = (maybeValue: string | Node) => {
38
- const sources =
39
- isDOMElement(maybeValue) && maybeValue.getAttribute('data-sources');
40
- try {
41
- return sources ? { sources: JSON.parse(sources) } : false;
42
- } catch {
43
- return false;
44
- }
45
- };
46
-
47
- export const dataConsumer: MarkSpec = {
48
- attrs: { sources: { default: [] } },
49
- parseDOM: [
50
- {
51
- tag: '[data-mark-type="dataConsumer"]',
52
- getAttrs: (maybeValue) => parseDataConsumer(maybeValue),
53
- },
54
- ],
55
- toDOM(mark: Mark, inline) {
56
- const wrapperStyle = inline ? 'span' : 'div';
57
-
58
- return [
59
- wrapperStyle,
60
- {
61
- 'data-mark-type': 'dataConsumer',
62
- 'data-sources': JSON.stringify(mark.attrs.sources),
63
- },
64
- ];
65
- },
66
- };
67
-
68
- /**
69
- * We want to ensure any "invalid ADF" doesn't get serialised, but the entire
70
- * mark itself is not valid without a non-empty `sources`.
71
- *
72
- * We _almost could_ simply return `null` if sources length is < 0 & would fit
73
- * the type signature of prosemirror-model's `fragment` but not `mark`'s toJSON.
74
- *
75
- * So we'll leave any extra transformation checks in
76
- * `editor-json-transformer`(?)
77
- */
78
- export const toJSON = (mark: Mark) => {
79
- // // Remove intemediary state if we don't have any sources on data consumer
80
- // if (mark.attrs?.sources?.length < 1) {
81
- // return null;
82
- // }
83
-
84
- return {
85
- type: mark.type.name,
86
- attrs: Object.keys(mark.attrs)
87
- .filter(
88
- (key) =>
89
- key === 'sources' &&
90
- mark.attrs[key].length > 0 &&
91
- mark.attrs[key] !== null,
92
- )
93
- .reduce<typeof mark.attrs>((acc, key) => {
94
- return {
95
- ...acc,
96
- [key]: mark.attrs[key],
97
- };
98
- }, {}),
99
- };
100
- };
@@ -1,19 +0,0 @@
1
- import { MarkSpec, DOMOutputSpec } from '@atlaskit/editor-prosemirror/model';
2
- import { FONT_STYLE } from '../groups';
3
-
4
- /**
5
- * @name em_mark
6
- */
7
- export interface EmDefinition {
8
- type: 'em';
9
- }
10
-
11
- const emDOM: DOMOutputSpec = ['em'];
12
- export const em: MarkSpec = {
13
- inclusive: true,
14
- group: FONT_STYLE,
15
- parseDOM: [{ tag: 'i' }, { tag: 'em' }, { style: 'font-style=italic' }],
16
- toDOM() {
17
- return emDOM;
18
- },
19
- };
@@ -1,77 +0,0 @@
1
- import { Mark, MarkSpec } from '@atlaskit/editor-prosemirror/model';
2
- import { isDOMElement } from '../../utils/parseDOM';
3
-
4
- export type LocalId = string;
5
-
6
- export interface FragmentAttributes {
7
- /**
8
- * @minLength 1
9
- */
10
- localId: LocalId;
11
- name?: string;
12
- }
13
-
14
- /**
15
- * @name fragment_mark
16
- * @description Indicates that the elements decorated with this mark belong to a "fragment" entity, which represents a collection of ADF nodes.
17
- * This entity can be referred to later by its `localId` attribute.
18
- */
19
- export interface FragmentDefinition {
20
- type: 'fragment';
21
- attrs: FragmentAttributes;
22
- }
23
-
24
- export interface FragmentMark extends Mark {
25
- attrs: FragmentAttributes;
26
- }
27
-
28
- const parseFragment = (
29
- maybeValue: string | Node,
30
- ): FragmentAttributes | false => {
31
- if (!isDOMElement(maybeValue)) {
32
- return false;
33
- }
34
-
35
- const name = maybeValue.getAttribute('data-name') ?? undefined;
36
- const localId = maybeValue.getAttribute('data-localId');
37
-
38
- if (!localId) {
39
- return false;
40
- }
41
-
42
- return { localId, name };
43
- };
44
-
45
- export const fragment: MarkSpec = {
46
- inclusive: false,
47
- excludes: '',
48
- attrs: { localId: { default: '' }, name: { default: null } },
49
- parseDOM: [
50
- {
51
- tag: '[data-mark-type="fragment"]',
52
- getAttrs: (maybeValue) => parseFragment(maybeValue),
53
- },
54
- ],
55
- toDOM(mark: Mark, inline) {
56
- const wrapperStyle = inline ? 'span' : 'div';
57
-
58
- return [
59
- wrapperStyle,
60
- {
61
- 'data-mark-type': 'fragment',
62
- 'data-name': mark.attrs.name,
63
- 'data-localId': mark.attrs.localId,
64
- },
65
- ];
66
- },
67
- };
68
-
69
- export const toJSON = (mark: Mark) => {
70
- return {
71
- type: mark.type.name,
72
- attrs: {
73
- localId: mark.attrs.localId,
74
- ...(mark.attrs.name ? { name: mark.attrs.name } : {}),
75
- },
76
- };
77
- };
@@ -1,47 +0,0 @@
1
- import { MarkSpec } from '@atlaskit/editor-prosemirror/model';
2
- import { ALIGNMENT, INDENTATION } from '../groups';
3
-
4
- export interface IndentationMarkAttributes {
5
- /**
6
- * @minimum 1
7
- * @maximum 6
8
- */
9
- level: number;
10
- }
11
-
12
- /**
13
- * @name indentation_mark
14
- */
15
- export interface IndentationMarkDefinition {
16
- type: 'indentation';
17
- attrs: IndentationMarkAttributes;
18
- }
19
-
20
- export const indentation: MarkSpec = {
21
- excludes: `indentation ${ALIGNMENT}`,
22
- group: INDENTATION,
23
- attrs: {
24
- level: {},
25
- },
26
- parseDOM: [
27
- {
28
- tag: 'div.fabric-editor-indentation-mark',
29
- getAttrs(dom) {
30
- const level = +((dom as HTMLElement).getAttribute('data-level') || '0');
31
- return {
32
- level: level > 6 ? 6 : level < 1 ? false : level,
33
- };
34
- },
35
- },
36
- ],
37
- toDOM(mark) {
38
- return [
39
- 'div',
40
- {
41
- class: 'fabric-editor-block-mark fabric-editor-indentation-mark',
42
- 'data-level': mark.attrs.level,
43
- },
44
- 0,
45
- ];
46
- },
47
- };