@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,75 +0,0 @@
1
- import { NodeSpec, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
- import { getExtensionAttrs } from '../../utils/extensions';
3
- import { ExtensionAttributes } from './types/extensions';
4
- import { MarksObject } from './types/mark';
5
- import { NonNestableBlockContent } from './types/non-nestable-block-content';
6
- import { DataConsumerDefinition } from '../marks/data-consumer';
7
- import { FragmentDefinition } from '../marks/fragment';
8
-
9
- /**
10
- * @name bodiedExtension_node
11
- */
12
- export interface BodiedExtensionBaseDefinition {
13
- type: 'bodiedExtension';
14
- attrs: ExtensionAttributes;
15
- marks?: Array<any>;
16
- /**
17
- * @minItems 1
18
- * @allowUnsupportedBlock true
19
- */
20
- content: Array<NonNestableBlockContent>;
21
- }
22
-
23
- /**
24
- * @name bodiedExtension_with_marks_node
25
- */
26
- export type BodiedExtensionDefinition = BodiedExtensionBaseDefinition &
27
- MarksObject<DataConsumerDefinition | FragmentDefinition>;
28
-
29
- const createBodiedExtensionNodeSpec = (): NodeSpec => {
30
- const nodeSpec: NodeSpec = {
31
- inline: false,
32
- group: 'block',
33
- marks: 'dataConsumer fragment',
34
- content:
35
- '(paragraph | panel | blockquote | orderedList | bulletList | rule | heading | codeBlock | mediaGroup | mediaSingle | decisionList | taskList | table | blockCard | extension | unsupportedBlock | embedCard)+',
36
- defining: true,
37
- selectable: true,
38
- isolating: true,
39
- attrs: {
40
- extensionType: { default: '' },
41
- extensionKey: { default: '' },
42
- parameters: { default: null },
43
- text: { default: null },
44
- layout: { default: 'default' },
45
- localId: { default: null },
46
- },
47
- parseDOM: [
48
- {
49
- context: 'bodiedExtension//',
50
- tag: '[data-node-type="bodied-extension"]',
51
- skip: true,
52
- },
53
- {
54
- tag: '[data-node-type="bodied-extension"]',
55
- getAttrs: (domNode) => getExtensionAttrs(domNode as HTMLElement),
56
- },
57
- ],
58
- toDOM(node: PMNode) {
59
- const attrs = {
60
- 'data-node-type': 'bodied-extension',
61
- 'data-extension-type': node.attrs.extensionType,
62
- 'data-extension-key': node.attrs.extensionKey,
63
- 'data-text': node.attrs.text,
64
- 'data-parameters': JSON.stringify(node.attrs.parameters),
65
- 'data-layout': node.attrs.layout,
66
- 'data-local-id:': node.attrs.localId,
67
- };
68
- return ['div', attrs, 0];
69
- },
70
- };
71
-
72
- return nodeSpec;
73
- };
74
-
75
- export const bodiedExtension = createBodiedExtensionNodeSpec();
@@ -1,17 +0,0 @@
1
- import { NodeSpec } from '@atlaskit/editor-prosemirror/model';
2
-
3
- export const bulletListSelector = '.ak-ul';
4
-
5
- export const bulletList: NodeSpec = {
6
- group: 'block',
7
- content: 'listItem+',
8
- selectable: false,
9
- parseDOM: [{ tag: 'ul' }],
10
- marks: 'unsupportedMark unsupportedNodeAttribute',
11
- toDOM() {
12
- const attrs = {
13
- class: bulletListSelector.substr(1),
14
- };
15
- return ['ul', attrs, 0];
16
- },
17
- };
@@ -1,51 +0,0 @@
1
- import { NodeSpec } from '@atlaskit/editor-prosemirror/model';
2
- import { InlineFormattedText, InlineCode } from './types/inline-content';
3
- import { HardBreakDefinition as HardBreak } from './hard-break';
4
- import { MentionDefinition as Mention } from './mention';
5
- import { EmojiDefinition as Emoji } from './emoji';
6
- import { DateDefinition as Date } from './date';
7
- import { PlaceholderDefinition as Placeholder } from './placeholder';
8
- import { InlineCardDefinition as InlineCard } from './inline-card';
9
- import { StatusDefinition as Status } from './status';
10
-
11
- /**
12
- * @name caption_node
13
- */
14
- export interface CaptionDefinition {
15
- type: 'caption';
16
- /**
17
- * @minItems 0
18
- * @allowUnsupportedInline true
19
- */
20
- content: Array<
21
- | InlineFormattedText
22
- | InlineCode
23
- | HardBreak
24
- | Mention
25
- | Emoji
26
- | Date
27
- | Placeholder
28
- | InlineCard
29
- | Status
30
- >;
31
- }
32
-
33
- export const caption: NodeSpec = {
34
- content:
35
- '(text|hardBreak|mention|emoji|date|placeholder|inlineCard|status|unsupportedInline)*',
36
- isolating: true,
37
- marks: '_',
38
- selectable: false,
39
- parseDOM: [
40
- {
41
- tag: 'figcaption[data-caption]',
42
- },
43
- ],
44
- toDOM(node) {
45
- const attrs: Record<string, string> = {
46
- 'data-caption': 'true',
47
- };
48
-
49
- return ['figcaption', attrs, 0];
50
- },
51
- };
@@ -1,176 +0,0 @@
1
- import {
2
- NodeSpec,
3
- Node as PMNode,
4
- Fragment,
5
- } from '@atlaskit/editor-prosemirror/model';
6
- import { TextDefinition as Text } from './text';
7
- import { BreakoutMarkDefinition } from '../marks/breakout';
8
- import { MarksObject, NoMark } from './types/mark';
9
-
10
- /**
11
- * @name codeBlock_node
12
- */
13
- export type CodeBlockBaseDefinition = {
14
- type: 'codeBlock';
15
- /**
16
- * @allowUnsupportedInline true
17
- */
18
- content?: Array<Text & NoMark>;
19
- marks?: Array<any>;
20
- attrs?: CodeBlockAttrs;
21
- };
22
-
23
- export type CodeBlockAttrs = {
24
- language?: string;
25
- };
26
-
27
- /**
28
- * @name codeBlock_with_no_marks_node
29
- */
30
- export type CodeBlockDefinition = CodeBlockBaseDefinition & NoMark;
31
-
32
- /**
33
- * @name codeBlock_with_marks_node
34
- */
35
- export type CodeBlockWithMarksDefinition = CodeBlockBaseDefinition &
36
- MarksObject<BreakoutMarkDefinition>;
37
-
38
- const getLanguageFromEditorStyle = (dom: HTMLElement): string | undefined => {
39
- return dom.getAttribute('data-language') || undefined;
40
- };
41
-
42
- // example of BB style:
43
- // <div class="codehilite language-javascript"><pre><span>hello world</span><span>\n</span></pre></div>
44
- const getLanguageFromBitbucketStyle = (
45
- dom: HTMLElement,
46
- ): string | undefined => {
47
- if (dom && dom.classList.contains('codehilite')) {
48
- // code block html from Bitbucket always contains an extra new line
49
- return extractLanguageFromClass(dom.className);
50
- }
51
- return;
52
- };
53
-
54
- // If there is a child code element, check that for data-language
55
- const getLanguageFromCode = (dom: HTMLElement): string | undefined => {
56
- const firstChild = dom.firstElementChild;
57
- if (firstChild && firstChild.nodeName === 'CODE') {
58
- return firstChild.getAttribute('data-language') || undefined;
59
- }
60
- };
61
-
62
- const extractLanguageFromClass = (className: string): string | undefined => {
63
- const languageRegex = /(?:^|\s)language-([^\s]+)/;
64
- const result = languageRegex.exec(className);
65
- if (result && result[1]) {
66
- return result[1];
67
- }
68
- return;
69
- };
70
-
71
- const removeLastNewLine = (dom: HTMLElement): HTMLElement => {
72
- const parent = dom && dom.parentElement;
73
- if (parent && parent.classList.contains('codehilite')) {
74
- dom.textContent = dom.textContent!.replace(/\n$/, '');
75
- }
76
- return dom;
77
- };
78
-
79
- export const codeBlock: NodeSpec = {
80
- attrs: { language: { default: null }, uniqueId: { default: null } },
81
- content: '(text | unsupportedInline)*',
82
- marks: 'unsupportedMark unsupportedNodeAttribute',
83
- group: 'block',
84
- code: true,
85
- defining: true,
86
- parseDOM: [
87
- {
88
- tag: 'pre',
89
- preserveWhitespace: 'full',
90
- getAttrs: (domNode) => {
91
- let dom = domNode as HTMLElement;
92
- const language =
93
- getLanguageFromBitbucketStyle(dom.parentElement!) ||
94
- getLanguageFromEditorStyle(dom.parentElement!) ||
95
- getLanguageFromCode(dom) ||
96
- dom.getAttribute('data-language')!;
97
- dom = removeLastNewLine(dom);
98
- return { language };
99
- },
100
- },
101
- // Handle VSCode paste
102
- // Checking `white-space: pre-wrap` is too aggressive @see ED-2627
103
- {
104
- tag: 'div[style]',
105
- preserveWhitespace: 'full',
106
- getAttrs: (domNode) => {
107
- const dom = domNode as HTMLElement;
108
- if (
109
- dom.style.whiteSpace === 'pre' ||
110
- (dom.style.fontFamily &&
111
- dom.style.fontFamily.toLowerCase().indexOf('monospace') > -1)
112
- ) {
113
- return {};
114
- }
115
- return false;
116
- },
117
- // @see ED-5682
118
- getContent: (domNode, schema) => {
119
- const dom = domNode as HTMLElement;
120
- const code = Array.from(dom.children)
121
- .map((child) => child.textContent)
122
- .filter((x) => x !== undefined)
123
- .join('\n');
124
- return code ? Fragment.from(schema.text(code)) : Fragment.empty;
125
- },
126
- },
127
- // Handle GitHub/Gist paste
128
- {
129
- tag: 'table[style]',
130
- preserveWhitespace: 'full',
131
- getAttrs: (dom) => {
132
- if ((dom as HTMLElement).querySelector('td[class*="blob-code"]')) {
133
- return {};
134
- }
135
- return false;
136
- },
137
- },
138
- {
139
- tag: 'div.code-block',
140
- preserveWhitespace: 'full',
141
- getAttrs: (domNode) => {
142
- const dom = domNode as HTMLElement;
143
- // TODO: ED-5604 Fix it inside `react-syntax-highlighter`
144
- // Remove line numbers
145
- const lineNumber = dom.querySelectorAll(
146
- '.react-syntax-highlighter-line-number',
147
- );
148
-
149
- if (lineNumber.length > 0) {
150
- // It's possible to copy without the line numbers too hence this
151
- // `react-syntax-highlighter-line-number` check, so that we don't remove real code
152
- lineNumber.forEach((line) => line.remove());
153
- }
154
- return {};
155
- },
156
- },
157
- ],
158
- toDOM(node) {
159
- return ['pre', ['code', { 'data-language': node.attrs.language }, 0]];
160
- },
161
- };
162
-
163
- export const toJSON = (node: PMNode) => ({
164
- attrs: Object.keys(node.attrs).reduce<Record<string, any>>((memo, key) => {
165
- if (key === 'uniqueId') {
166
- return memo;
167
- }
168
-
169
- if (key === 'language' && node.attrs.language === null) {
170
- return memo;
171
- }
172
-
173
- memo[key] = node.attrs[key];
174
- return memo;
175
- }, {}),
176
- });
@@ -1,43 +0,0 @@
1
- import { NodeSpec } from '@atlaskit/editor-prosemirror/model';
2
-
3
- const name = 'confluenceJiraIssue';
4
-
5
- export const confluenceJiraIssue: NodeSpec = {
6
- group: 'inline',
7
- inline: true,
8
- atom: true,
9
- attrs: {
10
- issueKey: { default: '' },
11
- macroId: { default: null },
12
- schemaVersion: { default: null },
13
- server: { default: null },
14
- serverId: { default: null },
15
- },
16
- parseDOM: [
17
- {
18
- tag: `span[data-node-type="${name}"]`,
19
- getAttrs: (domNode) => {
20
- const dom = domNode as HTMLElement;
21
- return {
22
- issueKey: dom.textContent,
23
- macroId: dom.dataset && dom.dataset.macroId,
24
- schemaVersion: dom.dataset && dom.dataset.schemaVersion,
25
- server: dom.dataset && dom.dataset.server,
26
- serverId: dom.dataset && dom.dataset.serverId,
27
- };
28
- },
29
- },
30
- ],
31
- toDOM(node) {
32
- const attrs = {
33
- 'data-node-type': name,
34
- 'data-macro-id': node.attrs.macroId,
35
- 'data-schema-version': node.attrs.schemaVersion,
36
- 'data-server': node.attrs.server,
37
- 'data-server-id': node.attrs.serverId,
38
- 'data-jira-issue': node.attrs.issueKey,
39
- };
40
-
41
- return ['span', attrs, node.attrs.issueKey];
42
- },
43
- };
@@ -1,29 +0,0 @@
1
- import { NodeSpec } from '@atlaskit/editor-prosemirror/model';
2
-
3
- const name = 'confluenceUnsupportedBlock';
4
-
5
- export const confluenceUnsupportedBlock: NodeSpec = {
6
- group: 'block',
7
- attrs: { cxhtml: { default: null } },
8
- toDOM(node) {
9
- // NOTE: This node cannot be "contenteditable: false". If it's the only node in a document, PM throws an error because there's nowhere to put the cursor.
10
- const attrs = {
11
- 'data-node-type': name,
12
- 'data-confluence-unsupported': 'block',
13
- 'data-confluence-unsupported-block-cxhtml': node.attrs['cxhtml'],
14
- };
15
- return ['div', attrs, 'Unsupported content'];
16
- },
17
- parseDOM: [
18
- {
19
- tag: `div[data-node-type="${name}"]`,
20
- getAttrs(dom) {
21
- return {
22
- cxhtml: (dom as HTMLElement).getAttribute(
23
- 'data-confluence-unsupported-block-cxhtml',
24
- )!,
25
- };
26
- },
27
- },
28
- ],
29
- };
@@ -1,30 +0,0 @@
1
- import { NodeSpec } from '@atlaskit/editor-prosemirror/model';
2
-
3
- const name = 'confluenceUnsupportedInline';
4
-
5
- export const confluenceUnsupportedInline: NodeSpec = {
6
- group: 'inline',
7
- inline: true,
8
- atom: true,
9
- attrs: { cxhtml: { default: null } },
10
- toDOM(node) {
11
- const attrs = {
12
- 'data-node-type': name,
13
- 'data-confluence-unsupported': 'inline',
14
- 'data-confluence-unsupported-inline-cxhtml': node.attrs['cxhtml'],
15
- };
16
- return ['div', attrs, 'Unsupported content'];
17
- },
18
- parseDOM: [
19
- {
20
- tag: `div[data-node-type="${name}"]`,
21
- getAttrs(dom) {
22
- return {
23
- cxhtml: (dom as HTMLElement).getAttribute(
24
- 'data-confluence-unsupported-inline-cxhtml',
25
- )!,
26
- };
27
- },
28
- },
29
- ],
30
- };
@@ -1,38 +0,0 @@
1
- import { NodeSpec, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
-
3
- /**
4
- * @name date_node
5
- */
6
- export interface DateDefinition {
7
- type: 'date';
8
- attrs: {
9
- /**
10
- * @minLength 1
11
- */
12
- timestamp: string;
13
- };
14
- }
15
-
16
- export const date: NodeSpec = {
17
- inline: true,
18
- group: 'inline',
19
- selectable: true,
20
- attrs: {
21
- timestamp: { default: '' },
22
- },
23
- parseDOM: [
24
- {
25
- tag: 'span[data-node-type="date"]',
26
- getAttrs: (dom) => ({
27
- timestamp: (dom as HTMLElement).getAttribute('data-timestamp'),
28
- }),
29
- },
30
- ],
31
- toDOM(node: PMNode) {
32
- const attrs = {
33
- 'data-node-type': 'date',
34
- 'data-timestamp': node.attrs.timestamp,
35
- };
36
- return ['span', attrs];
37
- },
38
- };
@@ -1,50 +0,0 @@
1
- import { Node, NodeSpec } from '@atlaskit/editor-prosemirror/model';
2
- import { uuid } from '../../utils/uuid';
3
- import { Inline } from './types/inline-content';
4
-
5
- /**
6
- * @name decisionItem_node
7
- */
8
- export interface DecisionItemDefinition {
9
- type: 'decisionItem';
10
- /**
11
- * @allowUnsupportedInline true
12
- */
13
- content?: Array<Inline>;
14
- attrs: {
15
- localId: string;
16
- state: string;
17
- };
18
- }
19
-
20
- export const decisionItem: NodeSpec = {
21
- content: 'inline*',
22
- defining: true,
23
- marks: '_',
24
- attrs: {
25
- localId: { default: '' },
26
- state: { default: 'DECIDED' },
27
- },
28
- parseDOM: [
29
- {
30
- tag: 'li[data-decision-local-id]',
31
-
32
- // Default priority is 50. We normally don't change this but since this node type is
33
- // also used by list-item we need to make sure that we run this parser first.
34
- priority: 100,
35
-
36
- getAttrs: (dom) => ({
37
- localId: uuid.generate(),
38
- state: (dom as HTMLElement).getAttribute('data-decision-state')!,
39
- }),
40
- },
41
- ],
42
- toDOM(node: Node) {
43
- const { localId, state } = node.attrs;
44
- const attrs = {
45
- 'data-decision-local-id': localId || 'local-decision',
46
- 'data-decision-state': state,
47
- };
48
- return ['li', attrs, 0];
49
- },
50
- };
@@ -1,56 +0,0 @@
1
- import { Node, NodeSpec } from '@atlaskit/editor-prosemirror/model';
2
- import { DecisionItemDefinition as DecisionItemNode } from './decision-item';
3
- import { uuid } from '../../utils/uuid';
4
-
5
- /**
6
- * @name decisionList_node
7
- */
8
- export interface DecisionListDefinition {
9
- type: 'decisionList';
10
- /**
11
- * @minItems 1
12
- * @allowUnsupportedBlock true
13
- */
14
- content: Array<DecisionItemNode>;
15
- attrs: {
16
- localId: string;
17
- };
18
- }
19
-
20
- const name = 'decisionList';
21
-
22
- export const decisionListSelector = `[data-node-type="${name}"]`;
23
-
24
- export const decisionList: NodeSpec = {
25
- group: 'block',
26
- defining: true,
27
- content: '(decisionItem|unsupportedBlock)+',
28
- marks: 'unsupportedMark unsupportedNodeAttribute',
29
- selectable: false,
30
- attrs: {
31
- localId: { default: '' },
32
- },
33
- parseDOM: [
34
- {
35
- tag: `ol${decisionListSelector}`,
36
-
37
- // Default priority is 50. We normally don't change this but since this node type is
38
- // also used by ordered-list we need to make sure that we run this parser first.
39
- priority: 100,
40
-
41
- getAttrs: () => ({
42
- localId: uuid.generate(),
43
- }),
44
- },
45
- ],
46
- toDOM(node: Node) {
47
- const { localId } = node.attrs;
48
- const attrs = {
49
- 'data-node-type': name,
50
- 'data-decision-list-local-id': localId || 'local-decision-list',
51
- style: 'list-style: none; padding-left: 0',
52
- };
53
-
54
- return ['ol', attrs, 0];
55
- },
56
- };
@@ -1,30 +0,0 @@
1
- import { NodeSpec } from '@atlaskit/editor-prosemirror/model';
2
- import { CodeBlockWithMarksDefinition as CodeBlockWithMarks } from './code-block';
3
- import { ExpandWithBreakoutDefinition as ExpandWithBreakout } from './expand';
4
- import { LayoutSectionDefinition as LayoutSection } from './layout-section';
5
- import { ParagraphWithIndentationDefinition } from './paragraph';
6
- import { BlockContent } from './types/block-content';
7
-
8
- /**
9
- * @name doc_node
10
- */
11
- export interface DocNode {
12
- version: 1;
13
- type: 'doc';
14
- /**
15
- * @allowUnsupportedBlock true
16
- */
17
- content: Array<
18
- | BlockContent
19
- | LayoutSection
20
- | CodeBlockWithMarks
21
- | ExpandWithBreakout
22
- | ParagraphWithIndentationDefinition
23
- >;
24
- }
25
-
26
- export const doc: NodeSpec = {
27
- content: '(block|layoutSection)+',
28
- marks:
29
- 'alignment breakout dataConsumer fragment indentation unsupportedMark unsupportedNodeAttribute',
30
- };
@@ -1,62 +0,0 @@
1
- import { NodeSpec, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
- import { RichMediaAttributes } from './types/rich-media-common';
3
-
4
- export interface EmbedCardAttributes extends RichMediaAttributes {
5
- originalWidth?: number;
6
- originalHeight?: number;
7
- /**
8
- * @validatorFn safeUrl
9
- */
10
- url: string;
11
- }
12
-
13
- /**
14
- * @name embedCard_node
15
- */
16
- export interface EmbedCardDefinition {
17
- type: 'embedCard';
18
- attrs: EmbedCardAttributes;
19
- }
20
-
21
- export const embedCard: NodeSpec = {
22
- inline: false,
23
- group: 'block',
24
- selectable: true,
25
- attrs: {
26
- url: { default: '' },
27
- layout: { default: 'center' },
28
- width: { default: 100 },
29
- originalWidth: { default: null },
30
- originalHeight: { default: null },
31
- },
32
- parseDOM: [
33
- {
34
- tag: 'div[data-embed-card]',
35
- getAttrs: (dom) => ({
36
- url: (dom as HTMLElement).getAttribute('data-card-url'),
37
- layout: (dom as HTMLElement).getAttribute('data-layout') || 'center',
38
- width: Number((dom as HTMLElement).getAttribute('data-width')) || null,
39
- originalWidth:
40
- Number(
41
- (dom as HTMLElement).getAttribute('data-card-original-width'),
42
- ) || null,
43
- originalHeight:
44
- Number(
45
- (dom as HTMLElement).getAttribute('data-card-original-height'),
46
- ) || null,
47
- }),
48
- },
49
- ],
50
- toDOM(node: PMNode) {
51
- const { url, layout, width, originalWidth, originalHeight } = node.attrs;
52
- const attrs = {
53
- 'data-embed-card': '',
54
- 'data-card-url': url,
55
- 'data-layout': layout,
56
- 'data-width': width,
57
- 'data-original-width': originalWidth,
58
- 'data-original-height': originalHeight,
59
- };
60
- return ['div', attrs];
61
- },
62
- };