@atlaskit/adf-schema 28.1.12 → 28.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/types/index.d.ts +1 -1
  3. package/package.json +1 -1
  4. package/src/__tests__/unit/json-schema/v1.ts +0 -55
  5. package/src/__tests__/unit/schema/create-schema.ts +0 -214
  6. package/src/__tests__/unit/schema/default-schema.ts +0 -192
  7. package/src/__tests__/unit/schema/marks/annotation.ts +0 -46
  8. package/src/__tests__/unit/schema/marks/border.ts +0 -76
  9. package/src/__tests__/unit/schema/marks/breakout.ts +0 -24
  10. package/src/__tests__/unit/schema/marks/code.ts +0 -44
  11. package/src/__tests__/unit/schema/marks/confluence-inline-comment.ts +0 -25
  12. package/src/__tests__/unit/schema/marks/data-consumer.ts +0 -52
  13. package/src/__tests__/unit/schema/marks/em.ts +0 -37
  14. package/src/__tests__/unit/schema/marks/link.ts +0 -188
  15. package/src/__tests__/unit/schema/marks/strike.ts +0 -37
  16. package/src/__tests__/unit/schema/marks/strong.ts +0 -43
  17. package/src/__tests__/unit/schema/marks/subsup.ts +0 -50
  18. package/src/__tests__/unit/schema/marks/text-color.ts +0 -61
  19. package/src/__tests__/unit/schema/marks/underline.ts +0 -36
  20. package/src/__tests__/unit/schema/nodes/_consts.ts +0 -964
  21. package/src/__tests__/unit/schema/nodes/block-card.ts +0 -184
  22. package/src/__tests__/unit/schema/nodes/blockquote.ts +0 -44
  23. package/src/__tests__/unit/schema/nodes/bodied-extension.ts +0 -101
  24. package/src/__tests__/unit/schema/nodes/code-block.ts +0 -221
  25. package/src/__tests__/unit/schema/nodes/confluence-unsupported-block.ts +0 -32
  26. package/src/__tests__/unit/schema/nodes/confluence-unsupported-inline.ts +0 -35
  27. package/src/__tests__/unit/schema/nodes/date.ts +0 -51
  28. package/src/__tests__/unit/schema/nodes/decision-item.ts +0 -46
  29. package/src/__tests__/unit/schema/nodes/decision-list.ts +0 -52
  30. package/src/__tests__/unit/schema/nodes/embed-card.ts +0 -60
  31. package/src/__tests__/unit/schema/nodes/emoji.ts +0 -71
  32. package/src/__tests__/unit/schema/nodes/expand.ts +0 -51
  33. package/src/__tests__/unit/schema/nodes/extension.ts +0 -101
  34. package/src/__tests__/unit/schema/nodes/hard-break.ts +0 -24
  35. package/src/__tests__/unit/schema/nodes/heading.ts +0 -56
  36. package/src/__tests__/unit/schema/nodes/image.ts +0 -32
  37. package/src/__tests__/unit/schema/nodes/inline-card.ts +0 -106
  38. package/src/__tests__/unit/schema/nodes/inline-extension.ts +0 -79
  39. package/src/__tests__/unit/schema/nodes/layout-column.ts +0 -54
  40. package/src/__tests__/unit/schema/nodes/layout-section.ts +0 -95
  41. package/src/__tests__/unit/schema/nodes/list-item.ts +0 -49
  42. package/src/__tests__/unit/schema/nodes/media-group.ts +0 -67
  43. package/src/__tests__/unit/schema/nodes/media-single.ts +0 -171
  44. package/src/__tests__/unit/schema/nodes/media.ts +0 -384
  45. package/src/__tests__/unit/schema/nodes/mention.ts +0 -115
  46. package/src/__tests__/unit/schema/nodes/nestedExpand.ts +0 -72
  47. package/src/__tests__/unit/schema/nodes/ordered-list.ts +0 -49
  48. package/src/__tests__/unit/schema/nodes/panel.ts +0 -180
  49. package/src/__tests__/unit/schema/nodes/paragraph.ts +0 -25
  50. package/src/__tests__/unit/schema/nodes/placeholder.ts +0 -46
  51. package/src/__tests__/unit/schema/nodes/rule.ts +0 -24
  52. package/src/__tests__/unit/schema/nodes/status.ts +0 -120
  53. package/src/__tests__/unit/schema/nodes/tableNodes.ts +0 -555
  54. package/src/__tests__/unit/schema/nodes/task-item.ts +0 -39
  55. package/src/__tests__/unit/schema/nodes/task-list.ts +0 -45
  56. package/src/__tests__/unit/schema/nodes/unknown-block.ts +0 -42
  57. package/src/__tests__/unit/schema/nodes/unsupported-block.ts +0 -42
  58. package/src/__tests__/unit/schema/nodes/unsupported-inline.ts +0 -38
  59. package/src/__tests__/unit/utils/colors.ts +0 -42
  60. package/src/__tests__/unit/utils/url.ts +0 -209
  61. package/src/schema/bitbucket-schema.ts +0 -43
  62. package/src/schema/confluence-schema.ts +0 -76
  63. package/src/schema/create-schema.ts +0 -337
  64. package/src/schema/default-schema.ts +0 -180
  65. package/src/schema/groups.ts +0 -30
  66. package/src/schema/inline-nodes.ts +0 -9
  67. package/src/schema/jira-schema.ts +0 -158
  68. package/src/schema/marks/__tests__/unit/annotation.ts +0 -18
  69. package/src/schema/marks/alignment.ts +0 -48
  70. package/src/schema/marks/annotation.ts +0 -107
  71. package/src/schema/marks/border.ts +0 -74
  72. package/src/schema/marks/breakout.ts +0 -42
  73. package/src/schema/marks/code.ts +0 -45
  74. package/src/schema/marks/confluence-inline-comment.ts +0 -32
  75. package/src/schema/marks/data-consumer.ts +0 -100
  76. package/src/schema/marks/em.ts +0 -19
  77. package/src/schema/marks/fragment.ts +0 -77
  78. package/src/schema/marks/indentation.ts +0 -47
  79. package/src/schema/marks/link.ts +0 -139
  80. package/src/schema/marks/strike.ts +0 -26
  81. package/src/schema/marks/strong.ts +0 -45
  82. package/src/schema/marks/subsup.ts +0 -53
  83. package/src/schema/marks/text-color.ts +0 -172
  84. package/src/schema/marks/type-ahead-query.ts +0 -22
  85. package/src/schema/marks/underline.ts +0 -24
  86. package/src/schema/marks/unsupported-mark.ts +0 -9
  87. package/src/schema/marks/unsupported-node-attributes.ts +0 -8
  88. package/src/schema/nodes/block-card.ts +0 -121
  89. package/src/schema/nodes/blockquote.ts +0 -25
  90. package/src/schema/nodes/bodied-extension.ts +0 -75
  91. package/src/schema/nodes/bullet-list.ts +0 -17
  92. package/src/schema/nodes/caption.ts +0 -51
  93. package/src/schema/nodes/code-block.ts +0 -176
  94. package/src/schema/nodes/confluence-jira-issue.ts +0 -43
  95. package/src/schema/nodes/confluence-unsupported-block.ts +0 -29
  96. package/src/schema/nodes/confluence-unsupported-inline.ts +0 -30
  97. package/src/schema/nodes/date.ts +0 -38
  98. package/src/schema/nodes/decision-item.ts +0 -50
  99. package/src/schema/nodes/decision-list.ts +0 -56
  100. package/src/schema/nodes/doc.ts +0 -30
  101. package/src/schema/nodes/embed-card.ts +0 -62
  102. package/src/schema/nodes/emoji.ts +0 -89
  103. package/src/schema/nodes/expand.ts +0 -101
  104. package/src/schema/nodes/extension.ts +0 -60
  105. package/src/schema/nodes/hard-break.ts +0 -21
  106. package/src/schema/nodes/heading.ts +0 -64
  107. package/src/schema/nodes/image.ts +0 -32
  108. package/src/schema/nodes/inline-card.ts +0 -70
  109. package/src/schema/nodes/inline-extension.ts +0 -57
  110. package/src/schema/nodes/layout-column.ts +0 -68
  111. package/src/schema/nodes/layout-section.ts +0 -93
  112. package/src/schema/nodes/list-item.ts +0 -13
  113. package/src/schema/nodes/media-group.ts +0 -44
  114. package/src/schema/nodes/media-inline.ts +0 -19
  115. package/src/schema/nodes/media-single.ts +0 -179
  116. package/src/schema/nodes/media.ts +0 -253
  117. package/src/schema/nodes/mention.ts +0 -86
  118. package/src/schema/nodes/nested-expand.ts +0 -77
  119. package/src/schema/nodes/ordered-list.ts +0 -62
  120. package/src/schema/nodes/panel.ts +0 -133
  121. package/src/schema/nodes/paragraph.ts +0 -79
  122. package/src/schema/nodes/placeholder.ts +0 -40
  123. package/src/schema/nodes/rule.ts +0 -17
  124. package/src/schema/nodes/status.ts +0 -58
  125. package/src/schema/nodes/tableNodes.ts +0 -478
  126. package/src/schema/nodes/task-item.ts +0 -51
  127. package/src/schema/nodes/task-list.ts +0 -61
  128. package/src/schema/nodes/text.ts +0 -19
  129. package/src/schema/nodes/types/block-content.ts +0 -51
  130. package/src/schema/nodes/types/extensions.ts +0 -36
  131. package/src/schema/nodes/types/inline-content.ts +0 -56
  132. package/src/schema/nodes/types/list.ts +0 -54
  133. package/src/schema/nodes/types/mark.ts +0 -16
  134. package/src/schema/nodes/types/non-nestable-block-content.ts +0 -39
  135. package/src/schema/nodes/types/rich-media-common.ts +0 -51
  136. package/src/schema/nodes/unknown-block.ts +0 -13
  137. package/src/schema/nodes/unsupported-block.ts +0 -28
  138. package/src/schema/nodes/unsupported-inline.ts +0 -27
  139. package/src/schema/unsupported.ts +0 -4
  140. package/src/steps/__tests__/unit/analytics.ts +0 -72
  141. package/src/steps/__tests__/unit/link-meta-step.ts +0 -64
  142. package/src/steps/__tests__/unit/override-document-step.ts +0 -174
  143. package/src/steps/__tests__/unit/set-attrs.ts +0 -71
  144. package/src/steps/analytics.ts +0 -189
  145. package/src/steps/link-meta-step.ts +0 -105
  146. package/src/steps/override-document-step.ts +0 -97
  147. package/src/steps/set-attrs.tsx +0 -74
  148. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-0.json +0 -15
  149. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-1.json +0 -15
  150. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-2.json +0 -15
  151. package/src/steps/table/__tests__/__fixtures__/basic/add-column-at-3.json +0 -15
  152. package/src/steps/table/__tests__/__fixtures__/basic/remove-column-at-0.json +0 -9
  153. package/src/steps/table/__tests__/__fixtures__/basic/remove-column-at-1.json +0 -9
  154. package/src/steps/table/__tests__/__fixtures__/basic/remove-column-at-2.json +0 -9
  155. package/src/steps/table/__tests__/__fixtures__/basic/remove-table/remove-last-row-inverted.json +0 -98
  156. package/src/steps/table/__tests__/__fixtures__/basic/remove-table/remove-last-row.json +0 -71
  157. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-0-inverted.json +0 -19
  158. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-0.json +0 -19
  159. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-1-inverted.json +0 -21
  160. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-1.json +0 -21
  161. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-2-inverted.json +0 -21
  162. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-2.json +0 -21
  163. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-3-inverted.json +0 -19
  164. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/add-column-at-3.json +0 -19
  165. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-0-inverted.json +0 -63
  166. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-0.json +0 -21
  167. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-1-inverted.json +0 -64
  168. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-1.json +0 -22
  169. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-2-inverted.json +0 -63
  170. package/src/steps/table/__tests__/__fixtures__/merge-cells/columns/remove-column-at-2.json +0 -21
  171. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-0-inverted.json +0 -19
  172. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-0.json +0 -19
  173. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-1-inverted.json +0 -19
  174. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-1.json +0 -19
  175. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-2-inverted.json +0 -19
  176. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-2.json +0 -19
  177. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-3-inverted.json +0 -19
  178. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/add-column-at-3.json +0 -19
  179. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-0-inverted.json +0 -52
  180. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-0.json +0 -38
  181. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-1-inverted.json +0 -52
  182. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-1.json +0 -38
  183. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-2-inverted.json +0 -25
  184. package/src/steps/table/__tests__/__fixtures__/merge-cells/rows/remove-column-at-2.json +0 -11
  185. package/src/steps/table/__tests__/_utils.ts +0 -102
  186. package/src/steps/table/__tests__/add-column-merge-columns.ts +0 -509
  187. package/src/steps/table/__tests__/add-column-merge-rows.ts +0 -466
  188. package/src/steps/table/__tests__/add-column.ts +0 -638
  189. package/src/steps/table/add-column.ts +0 -443
  190. package/src/steps/table/constants.ts +0 -4
  191. package/src/steps/table/sort-column.ts +0 -57
  192. package/src/steps/table/types.ts +0 -48
  193. package/src/steps/table/utils/cell-step.ts +0 -239
  194. package/src/steps/table/utils/cells-at-column.ts +0 -75
  195. package/src/steps/table/utils/find-column.ts +0 -90
  196. package/src/steps/table/utils/get-table-rect-from-doc.ts +0 -37
  197. package/src/steps/table/utils/side-effects/rows.ts +0 -327
  198. package/src/steps/table/utils/side-effects/side-effects.ts +0 -90
  199. package/src/steps/table/utils/side-effects/table.ts +0 -112
  200. package/src/steps/table/utils/side-effects/types.ts +0 -34
  201. package/src/steps/table/utils/table-map.ts +0 -28
  202. package/src/steps/type-ahead.ts +0 -100
  203. package/src/steps.ts +0 -16
  204. package/src/utils/colors.ts +0 -171
  205. package/src/utils/confluence/emoji.ts +0 -99
  206. package/src/utils/extensions.ts +0 -32
  207. package/src/utils/parseDOM.ts +0 -2
  208. package/src/utils/url.ts +0 -173
  209. package/src/utils/uuid.ts +0 -19
  210. package/src/version.json +0 -6
@@ -1,139 +0,0 @@
1
- import { MarkSpec, Mark } from '@atlaskit/editor-prosemirror/model';
2
- import { LINK } from '../groups';
3
- import { isRootRelative, isSafeUrl, normalizeUrl } from '../../utils/url';
4
-
5
- export interface ConfluenceLinkMetadata {
6
- linkType: string;
7
- versionAtSave?: string | null;
8
- fileName?: string | null;
9
- spaceKey?: string | null;
10
- contentTitle?: string | null;
11
- isRenamedTitle?: boolean;
12
- anchorName?: string | null;
13
- contentId?: string | null;
14
- container?: ConfluenceLinkMetadata;
15
- }
16
-
17
- export interface LinkAttributes {
18
- /**
19
- * @validatorFn safeUrl
20
- */
21
- href: string;
22
- title?: string;
23
- id?: string;
24
- collection?: string;
25
- occurrenceKey?: string;
26
-
27
- __confluenceMetadata?: ConfluenceLinkMetadata;
28
- }
29
-
30
- /**
31
- * @name link_mark
32
- */
33
- export interface LinkDefinition {
34
- type: 'link';
35
- attrs: LinkAttributes;
36
- }
37
-
38
- const getLinkAttrs = (attribute: string) => (domNode: Node | string) => {
39
- const dom = domNode as HTMLLinkElement;
40
-
41
- const href = dom.getAttribute(attribute) || '';
42
- const attrs: { __confluenceMetadata: string; href?: string } = {
43
- __confluenceMetadata: dom.hasAttribute('__confluenceMetadata')
44
- ? JSON.parse(dom.getAttribute('__confluenceMetadata') || '')
45
- : undefined,
46
- };
47
-
48
- if (!isSafeUrl(href)) {
49
- return false;
50
- }
51
-
52
- if (isRootRelative(href)) {
53
- attrs.href = href;
54
- return attrs;
55
- }
56
-
57
- attrs.href = normalizeUrl(href);
58
- return attrs;
59
- };
60
-
61
- export const link: MarkSpec = {
62
- excludes: `${LINK}`, // ED-5844 No multiple links in media node
63
- group: LINK,
64
- attrs: {
65
- href: {},
66
- __confluenceMetadata: {
67
- default: null,
68
- },
69
- },
70
- inclusive: false,
71
- parseDOM: [
72
- {
73
- tag: '[data-block-link]',
74
- getAttrs: getLinkAttrs('data-block-link'),
75
- contentElement: (node) => {
76
- const clone = node.cloneNode(true);
77
- (clone as HTMLElement).removeAttribute('data-block-link');
78
- (clone as HTMLElement).setAttribute('data-skip-paste', 'true');
79
- const wrapper = document.createElement('div');
80
- wrapper.appendChild(clone);
81
- return wrapper;
82
- },
83
- },
84
- {
85
- tag: 'a[href]',
86
- getAttrs: getLinkAttrs('href'),
87
- },
88
- ],
89
- toDOM(node, isInline) {
90
- const attrs = Object.keys(node.attrs).reduce<any>((attrs, key) => {
91
- if (key === '__confluenceMetadata') {
92
- if (node.attrs[key] !== null) {
93
- attrs[key] = JSON.stringify(node.attrs[key]);
94
- }
95
- } else if (key === 'href') {
96
- attrs[key] = isSafeUrl(node.attrs[key]) ? node.attrs[key] : undefined;
97
- } else {
98
- attrs[key] = node.attrs[key];
99
- }
100
-
101
- return attrs;
102
- }, {});
103
-
104
- if (isInline) {
105
- return ['a', attrs];
106
- }
107
-
108
- return [
109
- 'a',
110
- {
111
- ...attrs,
112
- ['data-block-link']: 'true',
113
- class: 'blockLink',
114
- },
115
- 0,
116
- ];
117
- },
118
- };
119
-
120
- const OPTIONAL_ATTRS = [
121
- 'title',
122
- 'id',
123
- 'collection',
124
- 'occurrenceKey',
125
- '__confluenceMetadata',
126
- ];
127
-
128
- export const toJSON = (mark: Mark) => ({
129
- type: mark.type.name,
130
- attrs: Object.keys(mark.attrs).reduce<Record<string, string>>(
131
- (attrs, key) => {
132
- if (OPTIONAL_ATTRS.indexOf(key) === -1 || mark.attrs[key] !== null) {
133
- attrs[key] = mark.attrs[key];
134
- }
135
- return attrs;
136
- },
137
- {},
138
- ),
139
- });
@@ -1,26 +0,0 @@
1
- import { MarkSpec } from '@atlaskit/editor-prosemirror/model';
2
- import { FONT_STYLE } from '../groups';
3
-
4
- /**
5
- * @name strike_mark
6
- */
7
- export interface StrikeDefinition {
8
- type: 'strike';
9
- }
10
-
11
- export const strike: MarkSpec = {
12
- inclusive: true,
13
- group: FONT_STYLE,
14
- parseDOM: [
15
- { tag: 'strike' },
16
- { tag: 's' },
17
- { tag: 'del' },
18
- {
19
- style: 'text-decoration',
20
- getAttrs: (value) => value === 'line-through' && null,
21
- },
22
- ],
23
- toDOM(): [string] {
24
- return ['s'];
25
- },
26
- };
@@ -1,45 +0,0 @@
1
- import { MarkSpec, DOMOutputSpec } from '@atlaskit/editor-prosemirror/model';
2
- import { FONT_STYLE } from '../groups';
3
-
4
- /**
5
- * @name strong_mark
6
- */
7
- export interface StrongDefinition {
8
- type: 'strong';
9
- }
10
-
11
- const strongDOM: DOMOutputSpec = ['strong'];
12
- export const strong: MarkSpec = {
13
- inclusive: true,
14
- group: FONT_STYLE,
15
- parseDOM: [
16
- { tag: 'strong' },
17
- // This works around a Google Docs misbehavior where
18
- // pasted content will be inexplicably wrapped in `<b>`
19
- // tags with a font-weight normal.
20
- {
21
- tag: 'b',
22
- getAttrs(node) {
23
- const element = node as HTMLElement;
24
- return element.style.fontWeight !== 'normal' && null;
25
- },
26
- },
27
- {
28
- tag: 'span',
29
- getAttrs(node) {
30
- const element = node as HTMLElement;
31
- const { fontWeight } = element.style;
32
- return (
33
- typeof fontWeight === 'string' &&
34
- (fontWeight === 'bold' ||
35
- fontWeight === 'bolder' ||
36
- /^(bold(er)?|[5-9]\d{2,})$/.test(fontWeight)) &&
37
- null
38
- );
39
- },
40
- },
41
- ],
42
- toDOM() {
43
- return strongDOM;
44
- },
45
- };
@@ -1,53 +0,0 @@
1
- import { MarkSpec, Mark } from '@atlaskit/editor-prosemirror/model';
2
- import { FONT_STYLE } from '../groups';
3
-
4
- export interface SubSupAttributes {
5
- type: 'sub' | 'sup';
6
- }
7
-
8
- /**
9
- * @name subsup_mark
10
- */
11
- export interface SubSupDefinition {
12
- type: 'subsup';
13
- attrs: SubSupAttributes;
14
- }
15
-
16
- export interface SubSupMark extends Mark {
17
- attrs: SubSupAttributes;
18
- }
19
-
20
- function getAttrFromVerticalAlign(node: HTMLElement) {
21
- if (node.style.verticalAlign) {
22
- const type = node.style.verticalAlign.slice(0, 3);
23
- if (type === 'sub' || type === 'sup') {
24
- return { type };
25
- }
26
- }
27
- return false;
28
- }
29
-
30
- export const subsup: MarkSpec = {
31
- inclusive: true,
32
- group: FONT_STYLE,
33
- attrs: { type: { default: 'sub' } },
34
- parseDOM: [
35
- { tag: 'sub', attrs: { type: 'sub' } },
36
- { tag: 'sup', attrs: { type: 'sup' } },
37
- {
38
- // Special case for pasting from Google Docs
39
- // Google Docs uses vertical align to denote subscript and super script
40
- tag: 'span',
41
- style: 'vertical-align=super',
42
- getAttrs: (node) => getAttrFromVerticalAlign(node as HTMLElement),
43
- },
44
- {
45
- tag: 'span',
46
- style: 'vertical-align=sub',
47
- getAttrs: (node) => getAttrFromVerticalAlign(node as HTMLElement),
48
- },
49
- ],
50
- toDOM(mark) {
51
- return [mark.attrs.type];
52
- },
53
- };
@@ -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
- };