@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,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
- };
@@ -1,61 +0,0 @@
1
- export { em } from './em';
2
- export type { EmDefinition } from './em';
3
- export { code } from './code';
4
- export type { CodeDefinition } from './code';
5
- export { strike } from './strike';
6
- export type { StrikeDefinition } from './strike';
7
- export { strong } from './strong';
8
- export type { StrongDefinition } from './strong';
9
- export { underline } from './underline';
10
- export type { UnderlineDefinition } from './underline';
11
- export { link, toJSON as linkToJSON } from './link';
12
- export type { LinkAttributes, LinkDefinition } from './link';
13
- export { typeAheadQuery } from './type-ahead-query';
14
- export { subsup } from './subsup';
15
- export type { SubSupDefinition, SubSupAttributes } from './subsup';
16
- export { textColor, colorPalette, colorPaletteExtended } from './text-color';
17
- export type { TextColorDefinition, TextColorAttributes } from './text-color';
18
- export { confluenceInlineComment } from './confluence-inline-comment';
19
- export { breakout } from './breakout';
20
- export type { BreakoutMarkAttrs, BreakoutMarkDefinition } from './breakout';
21
- export { alignment, alignmentPositionMap } from './alignment';
22
- export type { AlignmentAttributes, AlignmentMarkDefinition } from './alignment';
23
- export { indentation } from './indentation';
24
- export type {
25
- IndentationMarkAttributes,
26
- IndentationMarkDefinition,
27
- } from './indentation';
28
- export {
29
- annotation,
30
- AnnotationMarkStates,
31
- buildDataAttributes as buildAnnotationMarkDataAttributes,
32
- AnnotationTypes,
33
- } from './annotation';
34
- export type {
35
- AnnotationMarkDefinition,
36
- AnnotationMarkAttributes,
37
- AnnotationId,
38
- AnnotationDataAttributes,
39
- } from './annotation';
40
-
41
- export { unsupportedMark } from './unsupported-mark';
42
-
43
- export { unsupportedNodeAttribute } from './unsupported-node-attributes';
44
-
45
- export type {
46
- DataConsumerAttributes,
47
- DataConsumerDefinition,
48
- } from './data-consumer';
49
-
50
- export { dataConsumer, toJSON as dataConsumerToJSON } from './data-consumer';
51
-
52
- export type {
53
- FragmentAttributes,
54
- FragmentDefinition,
55
- LocalId,
56
- } from './fragment';
57
-
58
- export { fragment, toJSON as fragmentToJSON } from './fragment';
59
-
60
- export { border, borderColorPalette } from './border';
61
- export type { BorderMarkAttributes, BorderMarkDefinition } from './border';
@@ -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
- };