@atlaskit/adf-schema 25.1.0 → 25.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 (249) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/index.js +0 -2
  3. package/dist/cjs/json-schema/index.js +0 -3
  4. package/dist/cjs/schema/bitbucket-schema.js +0 -2
  5. package/dist/cjs/schema/confluence-schema.js +1 -4
  6. package/dist/cjs/schema/create-schema.js +12 -38
  7. package/dist/cjs/schema/default-schema.js +3 -16
  8. package/dist/cjs/schema/groups.js +13 -6
  9. package/dist/cjs/schema/index.js +0 -5
  10. package/dist/cjs/schema/inline-nodes.js +0 -5
  11. package/dist/cjs/schema/jira-schema.js +0 -36
  12. package/dist/cjs/schema/marks/alignment.js +0 -2
  13. package/dist/cjs/schema/marks/annotation.js +2 -14
  14. package/dist/cjs/schema/marks/code.js +0 -5
  15. package/dist/cjs/schema/marks/confluence-inline-comment.js +1 -1
  16. package/dist/cjs/schema/marks/data-consumer.js +2 -7
  17. package/dist/cjs/schema/marks/em.js +0 -2
  18. package/dist/cjs/schema/marks/fragment.js +0 -13
  19. package/dist/cjs/schema/marks/indentation.js +0 -2
  20. package/dist/cjs/schema/marks/index.js +0 -18
  21. package/dist/cjs/schema/marks/link.js +0 -17
  22. package/dist/cjs/schema/marks/strike.js +0 -2
  23. package/dist/cjs/schema/marks/strong.js +2 -3
  24. package/dist/cjs/schema/marks/subsup.js +0 -5
  25. package/dist/cjs/schema/marks/text-color.js +46 -37
  26. package/dist/cjs/schema/marks/type-ahead-query.js +0 -3
  27. package/dist/cjs/schema/marks/underline.js +0 -2
  28. package/dist/cjs/schema/nodes/block-card.js +1 -2
  29. package/dist/cjs/schema/nodes/blockquote.js +1 -1
  30. package/dist/cjs/schema/nodes/bodied-extension.js +0 -3
  31. package/dist/cjs/schema/nodes/caption.js +1 -1
  32. package/dist/cjs/schema/nodes/code-block.js +11 -29
  33. package/dist/cjs/schema/nodes/date.js +1 -1
  34. package/dist/cjs/schema/nodes/decision-item.js +2 -4
  35. package/dist/cjs/schema/nodes/decision-list.js +0 -2
  36. package/dist/cjs/schema/nodes/doc.js +1 -1
  37. package/dist/cjs/schema/nodes/embed-card.js +6 -6
  38. package/dist/cjs/schema/nodes/emoji.js +11 -9
  39. package/dist/cjs/schema/nodes/expand.js +1 -4
  40. package/dist/cjs/schema/nodes/extension.js +0 -3
  41. package/dist/cjs/schema/nodes/hard-break.js +1 -1
  42. package/dist/cjs/schema/nodes/heading.js +2 -2
  43. package/dist/cjs/schema/nodes/index.js +0 -45
  44. package/dist/cjs/schema/nodes/inline-card.js +4 -4
  45. package/dist/cjs/schema/nodes/inline-extension.js +0 -3
  46. package/dist/cjs/schema/nodes/layout-column.js +4 -5
  47. package/dist/cjs/schema/nodes/layout-section.js +1 -1
  48. package/dist/cjs/schema/nodes/media-group.js +1 -1
  49. package/dist/cjs/schema/nodes/media-inline.js +0 -2
  50. package/dist/cjs/schema/nodes/media-single.js +3 -14
  51. package/dist/cjs/schema/nodes/media.js +10 -28
  52. package/dist/cjs/schema/nodes/mention.js +4 -14
  53. package/dist/cjs/schema/nodes/nested-expand.js +1 -1
  54. package/dist/cjs/schema/nodes/ordered-list.js +3 -17
  55. package/dist/cjs/schema/nodes/panel.js +1 -13
  56. package/dist/cjs/schema/nodes/paragraph.js +1 -6
  57. package/dist/cjs/schema/nodes/placeholder.js +1 -1
  58. package/dist/cjs/schema/nodes/rule.js +1 -1
  59. package/dist/cjs/schema/nodes/status.js +4 -6
  60. package/dist/cjs/schema/nodes/tableNodes.js +12 -39
  61. package/dist/cjs/schema/nodes/task-item.js +2 -4
  62. package/dist/cjs/schema/nodes/task-list.js +0 -2
  63. package/dist/cjs/schema/nodes/text.js +1 -1
  64. package/dist/cjs/steps/analytics.js +4 -38
  65. package/dist/cjs/steps/set-attrs.js +0 -26
  66. package/dist/cjs/steps/table/add-column.js +33 -105
  67. package/dist/cjs/steps/table/constants.js +0 -1
  68. package/dist/cjs/steps/table/sort-column.js +0 -19
  69. package/dist/cjs/steps/table/utils/cell-step.js +18 -49
  70. package/dist/cjs/steps/table/utils/cells-at-column.js +2 -21
  71. package/dist/cjs/steps/table/utils/find-column.js +13 -17
  72. package/dist/cjs/steps/table/utils/get-table-rect-from-doc.js +6 -8
  73. package/dist/cjs/steps/table/utils/side-effects/rows.js +23 -78
  74. package/dist/cjs/steps/table/utils/side-effects/side-effects.js +0 -23
  75. package/dist/cjs/steps/table/utils/side-effects/table.js +2 -18
  76. package/dist/cjs/steps/table/utils/table-map.js +0 -6
  77. package/dist/cjs/steps/type-ahead.js +5 -25
  78. package/dist/cjs/steps.js +0 -6
  79. package/dist/cjs/utils/colors.js +13 -36
  80. package/dist/cjs/utils/confluence/emoji.js +6 -13
  81. package/dist/cjs/utils/extensions.js +0 -8
  82. package/dist/cjs/utils/index.js +0 -4
  83. package/dist/cjs/utils/parseDOM.js +0 -2
  84. package/dist/cjs/utils/url.js +3 -20
  85. package/dist/cjs/utils/uuid.js +0 -3
  86. package/dist/cjs/version.json +1 -1
  87. package/dist/es2019/index.js +1 -2
  88. package/dist/es2019/schema/bitbucket-schema.js +1 -1
  89. package/dist/es2019/schema/confluence-schema.js +1 -2
  90. package/dist/es2019/schema/create-schema.js +12 -25
  91. package/dist/es2019/schema/default-schema.js +3 -11
  92. package/dist/es2019/schema/groups.js +13 -6
  93. package/dist/es2019/schema/index.js +1 -2
  94. package/dist/es2019/schema/jira-schema.js +0 -24
  95. package/dist/es2019/schema/marks/alignment.js +1 -3
  96. package/dist/es2019/schema/marks/annotation.js +3 -9
  97. package/dist/es2019/schema/marks/breakout.js +0 -4
  98. package/dist/es2019/schema/marks/code.js +1 -5
  99. package/dist/es2019/schema/marks/confluence-inline-comment.js +1 -2
  100. package/dist/es2019/schema/marks/data-consumer.js +3 -5
  101. package/dist/es2019/schema/marks/em.js +1 -2
  102. package/dist/es2019/schema/marks/fragment.js +0 -8
  103. package/dist/es2019/schema/marks/indentation.js +0 -4
  104. package/dist/es2019/schema/marks/link.js +2 -11
  105. package/dist/es2019/schema/marks/strike.js +1 -2
  106. package/dist/es2019/schema/marks/strong.js +3 -7
  107. package/dist/es2019/schema/marks/subsup.js +0 -6
  108. package/dist/es2019/schema/marks/text-color.js +44 -29
  109. package/dist/es2019/schema/marks/type-ahead-query.js +0 -2
  110. package/dist/es2019/schema/marks/underline.js +1 -2
  111. package/dist/es2019/schema/marks/unsupported-mark.js +0 -1
  112. package/dist/es2019/schema/marks/unsupported-node-attributes.js +0 -1
  113. package/dist/es2019/schema/nodes/block-card.js +1 -3
  114. package/dist/es2019/schema/nodes/blockquote.js +1 -2
  115. package/dist/es2019/schema/nodes/bodied-extension.js +0 -4
  116. package/dist/es2019/schema/nodes/bullet-list.js +0 -2
  117. package/dist/es2019/schema/nodes/caption.js +1 -2
  118. package/dist/es2019/schema/nodes/code-block.js +11 -28
  119. package/dist/es2019/schema/nodes/confluence-jira-issue.js +0 -2
  120. package/dist/es2019/schema/nodes/confluence-unsupported-block.js +0 -4
  121. package/dist/es2019/schema/nodes/confluence-unsupported-inline.js +0 -4
  122. package/dist/es2019/schema/nodes/date.js +1 -2
  123. package/dist/es2019/schema/nodes/decision-item.js +0 -2
  124. package/dist/es2019/schema/nodes/decision-list.js +1 -2
  125. package/dist/es2019/schema/nodes/doc.js +1 -0
  126. package/dist/es2019/schema/nodes/embed-card.js +1 -2
  127. package/dist/es2019/schema/nodes/emoji.js +9 -6
  128. package/dist/es2019/schema/nodes/expand.js +1 -3
  129. package/dist/es2019/schema/nodes/extension.js +0 -4
  130. package/dist/es2019/schema/nodes/hard-break.js +1 -2
  131. package/dist/es2019/schema/nodes/heading.js +2 -3
  132. package/dist/es2019/schema/nodes/image.js +0 -4
  133. package/dist/es2019/schema/nodes/inline-card.js +4 -5
  134. package/dist/es2019/schema/nodes/inline-extension.js +0 -4
  135. package/dist/es2019/schema/nodes/layout-column.js +4 -6
  136. package/dist/es2019/schema/nodes/layout-section.js +1 -4
  137. package/dist/es2019/schema/nodes/list-item.js +0 -2
  138. package/dist/es2019/schema/nodes/media-group.js +1 -2
  139. package/dist/es2019/schema/nodes/media-single.js +3 -6
  140. package/dist/es2019/schema/nodes/media.js +10 -20
  141. package/dist/es2019/schema/nodes/mention.js +0 -11
  142. package/dist/es2019/schema/nodes/nested-expand.js +1 -2
  143. package/dist/es2019/schema/nodes/ordered-list.js +4 -14
  144. package/dist/es2019/schema/nodes/panel.js +3 -10
  145. package/dist/es2019/schema/nodes/paragraph.js +1 -7
  146. package/dist/es2019/schema/nodes/placeholder.js +1 -2
  147. package/dist/es2019/schema/nodes/rule.js +1 -2
  148. package/dist/es2019/schema/nodes/status.js +1 -2
  149. package/dist/es2019/schema/nodes/tableNodes.js +10 -26
  150. package/dist/es2019/schema/nodes/task-item.js +0 -2
  151. package/dist/es2019/schema/nodes/task-list.js +0 -2
  152. package/dist/es2019/schema/nodes/text.js +1 -0
  153. package/dist/es2019/schema/nodes/unknown-block.js +0 -2
  154. package/dist/es2019/schema/nodes/unsupported-block.js +0 -2
  155. package/dist/es2019/schema/nodes/unsupported-inline.js +0 -2
  156. package/dist/es2019/steps/analytics.js +13 -30
  157. package/dist/es2019/steps/set-attrs.js +3 -12
  158. package/dist/es2019/steps/table/add-column.js +33 -76
  159. package/dist/es2019/steps/table/constants.js +0 -1
  160. package/dist/es2019/steps/table/sort-column.js +1 -8
  161. package/dist/es2019/steps/table/utils/cell-step.js +15 -32
  162. package/dist/es2019/steps/table/utils/cells-at-column.js +6 -11
  163. package/dist/es2019/steps/table/utils/find-column.js +12 -15
  164. package/dist/es2019/steps/table/utils/get-table-rect-from-doc.js +7 -6
  165. package/dist/es2019/steps/table/utils/side-effects/rows.js +19 -59
  166. package/dist/es2019/steps/table/utils/side-effects/side-effects.js +0 -21
  167. package/dist/es2019/steps/table/utils/side-effects/table.js +0 -17
  168. package/dist/es2019/steps/type-ahead.js +3 -15
  169. package/dist/es2019/utils/colors.js +8 -18
  170. package/dist/es2019/utils/confluence/emoji.js +5 -8
  171. package/dist/es2019/utils/extensions.js +0 -4
  172. package/dist/es2019/utils/url.js +2 -12
  173. package/dist/es2019/utils/uuid.js +0 -2
  174. package/dist/es2019/version.json +1 -1
  175. package/dist/esm/index.js +1 -2
  176. package/dist/esm/schema/bitbucket-schema.js +1 -1
  177. package/dist/esm/schema/confluence-schema.js +1 -2
  178. package/dist/esm/schema/create-schema.js +12 -31
  179. package/dist/esm/schema/default-schema.js +3 -11
  180. package/dist/esm/schema/groups.js +13 -6
  181. package/dist/esm/schema/index.js +1 -2
  182. package/dist/esm/schema/jira-schema.js +0 -24
  183. package/dist/esm/schema/marks/alignment.js +1 -1
  184. package/dist/esm/schema/marks/annotation.js +3 -11
  185. package/dist/esm/schema/marks/code.js +1 -3
  186. package/dist/esm/schema/marks/confluence-inline-comment.js +1 -0
  187. package/dist/esm/schema/marks/data-consumer.js +3 -3
  188. package/dist/esm/schema/marks/em.js +1 -0
  189. package/dist/esm/schema/marks/fragment.js +0 -9
  190. package/dist/esm/schema/marks/link.js +0 -12
  191. package/dist/esm/schema/marks/strike.js +1 -0
  192. package/dist/esm/schema/marks/strong.js +3 -1
  193. package/dist/esm/schema/marks/subsup.js +0 -4
  194. package/dist/esm/schema/marks/text-color.js +46 -30
  195. package/dist/esm/schema/marks/underline.js +1 -0
  196. package/dist/esm/schema/nodes/block-card.js +1 -1
  197. package/dist/esm/schema/nodes/blockquote.js +1 -0
  198. package/dist/esm/schema/nodes/bodied-extension.js +0 -2
  199. package/dist/esm/schema/nodes/caption.js +1 -0
  200. package/dist/esm/schema/nodes/code-block.js +11 -26
  201. package/dist/esm/schema/nodes/date.js +1 -0
  202. package/dist/esm/schema/nodes/decision-item.js +2 -2
  203. package/dist/esm/schema/nodes/decision-list.js +1 -0
  204. package/dist/esm/schema/nodes/doc.js +1 -0
  205. package/dist/esm/schema/nodes/embed-card.js +6 -5
  206. package/dist/esm/schema/nodes/emoji.js +12 -7
  207. package/dist/esm/schema/nodes/expand.js +1 -1
  208. package/dist/esm/schema/nodes/extension.js +0 -2
  209. package/dist/esm/schema/nodes/hard-break.js +1 -0
  210. package/dist/esm/schema/nodes/heading.js +2 -1
  211. package/dist/esm/schema/nodes/inline-card.js +4 -3
  212. package/dist/esm/schema/nodes/inline-extension.js +0 -2
  213. package/dist/esm/schema/nodes/layout-column.js +4 -4
  214. package/dist/esm/schema/nodes/layout-section.js +1 -0
  215. package/dist/esm/schema/nodes/media-group.js +1 -0
  216. package/dist/esm/schema/nodes/media-single.js +3 -8
  217. package/dist/esm/schema/nodes/media.js +10 -18
  218. package/dist/esm/schema/nodes/mention.js +4 -13
  219. package/dist/esm/schema/nodes/nested-expand.js +1 -0
  220. package/dist/esm/schema/nodes/ordered-list.js +3 -13
  221. package/dist/esm/schema/nodes/panel.js +1 -10
  222. package/dist/esm/schema/nodes/paragraph.js +1 -5
  223. package/dist/esm/schema/nodes/placeholder.js +1 -0
  224. package/dist/esm/schema/nodes/rule.js +1 -0
  225. package/dist/esm/schema/nodes/status.js +5 -4
  226. package/dist/esm/schema/nodes/tableNodes.js +12 -25
  227. package/dist/esm/schema/nodes/task-item.js +2 -2
  228. package/dist/esm/schema/nodes/text.js +1 -0
  229. package/dist/esm/steps/analytics.js +5 -31
  230. package/dist/esm/steps/set-attrs.js +1 -17
  231. package/dist/esm/steps/table/add-column.js +33 -91
  232. package/dist/esm/steps/table/constants.js +0 -1
  233. package/dist/esm/steps/table/sort-column.js +1 -10
  234. package/dist/esm/steps/table/utils/cell-step.js +18 -42
  235. package/dist/esm/steps/table/utils/cells-at-column.js +2 -18
  236. package/dist/esm/steps/table/utils/find-column.js +13 -16
  237. package/dist/esm/steps/table/utils/get-table-rect-from-doc.js +7 -6
  238. package/dist/esm/steps/table/utils/side-effects/rows.js +23 -76
  239. package/dist/esm/steps/table/utils/side-effects/side-effects.js +0 -18
  240. package/dist/esm/steps/table/utils/side-effects/table.js +2 -13
  241. package/dist/esm/steps/type-ahead.js +6 -18
  242. package/dist/esm/utils/colors.js +12 -23
  243. package/dist/esm/utils/confluence/emoji.js +6 -10
  244. package/dist/esm/utils/extensions.js +0 -4
  245. package/dist/esm/utils/url.js +2 -12
  246. package/dist/esm/version.json +1 -1
  247. package/dist/types/schema/default-schema.d.ts +1 -1
  248. package/dist/types/utils/colors.d.ts +1 -1
  249. package/package.json +2 -2
@@ -12,20 +12,19 @@ export const getCellAttrs = (dom, defaultValues = {}) => {
12
12
  const colspan = Number(dom.getAttribute('colspan') || 1);
13
13
  let {
14
14
  backgroundColor
15
- } = dom.style; // ignore setting background attr if ds neutral token is detected
15
+ } = dom.style;
16
16
 
17
+ // ignore setting background attr if ds neutral token is detected
17
18
  if (backgroundColor.includes('--ds-background-neutral')) {
18
19
  backgroundColor = '';
19
20
  } else {
20
21
  if (backgroundColor && isRgb(backgroundColor)) {
21
22
  const result = rgbToHex(backgroundColor);
22
-
23
23
  if (result !== null) {
24
24
  backgroundColor = result;
25
25
  }
26
26
  }
27
27
  }
28
-
29
28
  return {
30
29
  colspan,
31
30
  rowspan: Number(dom.getAttribute('rowspan') || 1),
@@ -33,7 +32,6 @@ export const getCellAttrs = (dom, defaultValues = {}) => {
33
32
  background: backgroundColor && backgroundColor !== defaultValues['background'] ? backgroundColor : null
34
33
  };
35
34
  };
36
-
37
35
  /**
38
36
  * gets cell dom attributes based on node attributes
39
37
  * @returns CellDomAttrs
@@ -41,29 +39,25 @@ export const getCellAttrs = (dom, defaultValues = {}) => {
41
39
  export const getCellDomAttrs = node => {
42
40
  const attrs = {};
43
41
  const nodeType = node.type.name;
44
-
45
42
  if (node.attrs.colspan !== 1) {
46
43
  attrs.colspan = node.attrs.colspan;
47
44
  }
48
-
49
45
  if (node.attrs.rowspan !== 1) {
50
46
  attrs.rowspan = node.attrs.rowspan;
51
47
  }
52
-
53
48
  if (node.attrs.colwidth) {
54
49
  attrs['data-colwidth'] = node.attrs.colwidth.join(',');
55
50
  }
56
-
57
51
  if (node.attrs.background) {
58
52
  const {
59
53
  background
60
- } = node.attrs; // to ensure that we don't overwrite product's style:
54
+ } = node.attrs;
55
+
56
+ // to ensure that we don't overwrite product's style:
61
57
  // - it clears background color for <th> if its set to gray
62
58
  // - it clears background color for <td> if its set to white
63
59
  // - it clears background color for <th> if ds neutral token is detected
64
-
65
60
  const ignored = nodeType === 'tableHeader' && background === tableBackgroundColorNames.get('light gray') || nodeType === 'tableCell' && background === tableBackgroundColorNames.get('white') || nodeType === 'tableHeader' && background.includes('--ds-background-neutral');
66
-
67
61
  if (ignored) {
68
62
  attrs.style = '';
69
63
  } else {
@@ -72,13 +66,11 @@ export const getCellDomAttrs = node => {
72
66
  attrs.colorname = tableBackgroundColorPalette.get(color);
73
67
  }
74
68
  }
75
-
76
69
  if (nodeType === 'tableHeader') {
77
70
  attrs.class = tableHeaderSelector;
78
71
  } else {
79
72
  attrs.class = tableCellSelector;
80
73
  }
81
-
82
74
  return attrs;
83
75
  };
84
76
  export const tableBackgroundColorPalette = new Map();
@@ -88,7 +80,6 @@ export const tableBackgroundColorNames = new Map();
88
80
  tableBackgroundColorPalette.set(colorValue.toLowerCase(), colorName);
89
81
  tableBackgroundColorNames.set(colorName.toLowerCase(), colorValue.toLowerCase());
90
82
  });
91
-
92
83
  // TODO: Fix any, potential issue. ED-5048
93
84
  const createTableSpec = () => {
94
85
  const attrs = {
@@ -111,18 +102,18 @@ const createTableSpec = () => {
111
102
  marks: 'unsupportedMark unsupportedNodeAttribute',
112
103
  tableRole: 'table',
113
104
  isolating: true,
114
- selectable: false,
105
+ selectable: true,
115
106
  group: 'block',
116
107
  parseDOM: [{
117
108
  tag: 'table',
118
109
  getAttrs: node => {
119
110
  var _dom$parentElement;
120
-
121
111
  const dom = node;
122
112
  const breakoutWrapper = (_dom$parentElement = dom.parentElement) === null || _dom$parentElement === void 0 ? void 0 : _dom$parentElement.parentElement;
123
113
  return {
124
114
  isNumberColumnEnabled: dom.getAttribute('data-number-column') === 'true' ? true : false,
125
- layout: // copying from editor
115
+ layout:
116
+ // copying from editor
126
117
  dom.getAttribute('data-layout') || ( // copying from renderer
127
118
  breakoutWrapper === null || breakoutWrapper === void 0 ? void 0 : breakoutWrapper.getAttribute('data-layout')) || 'default',
128
119
  __autoSize: dom.getAttribute('data-autosize') === 'true' ? true : false,
@@ -130,7 +121,6 @@ const createTableSpec = () => {
130
121
  };
131
122
  }
132
123
  }],
133
-
134
124
  toDOM(node) {
135
125
  const attrs = {
136
126
  'data-number-column': node.attrs.isNumberColumnEnabled,
@@ -140,15 +130,11 @@ const createTableSpec = () => {
140
130
  };
141
131
  return ['table', attrs, ['tbody', 0]];
142
132
  }
143
-
144
133
  };
145
134
  return tableNodeSpec;
146
135
  };
147
-
148
136
  export const table = createTableSpec();
149
-
150
137
  const shouldIncludeAttribute = (key, value) => !key.startsWith('__') && (key !== 'localId' || !!value);
151
-
152
138
  export const tableToJSON = node => ({
153
139
  attrs: Object.keys(node.attrs).filter(key => shouldIncludeAttribute(key, node.attrs[key])).reduce((obj, key) => {
154
140
  obj[key] = node.attrs[key];
@@ -163,11 +149,9 @@ export const tableRow = {
163
149
  parseDOM: [{
164
150
  tag: 'tr'
165
151
  }],
166
-
167
152
  toDOM() {
168
153
  return ['tr', 0];
169
154
  }
170
-
171
155
  };
172
156
  const cellAttrs = {
173
157
  colspan: {
@@ -190,7 +174,8 @@ export const tableCell = {
190
174
  tableRole: 'cell',
191
175
  marks: 'alignment dataConsumer fragment unsupportedMark unsupportedNodeAttribute',
192
176
  isolating: true,
193
- parseDOM: [// Ignore number cell copied from renderer
177
+ parseDOM: [
178
+ // Ignore number cell copied from renderer
194
179
  {
195
180
  tag: '.ak-renderer-table-number-column',
196
181
  ignore: true
@@ -205,7 +190,6 @@ export const toJSONTableCell = node => ({
205
190
  if (cellAttrs[key].default !== node.attrs[key]) {
206
191
  obj[key] = node.attrs[key];
207
192
  }
208
-
209
193
  return obj;
210
194
  }, {})
211
195
  });
@@ -22,7 +22,6 @@ export const taskItem = {
22
22
  state: dom.getAttribute('data-task-state') || 'TODO'
23
23
  })
24
24
  }],
25
-
26
25
  toDOM(node) {
27
26
  const {
28
27
  localId,
@@ -34,5 +33,4 @@ export const taskItem = {
34
33
  };
35
34
  return ['div', attrs, 0];
36
35
  }
37
-
38
36
  };
@@ -21,7 +21,6 @@ export const taskList = {
21
21
  localId: uuid.generate()
22
22
  })
23
23
  }],
24
-
25
24
  toDOM(node) {
26
25
  const {
27
26
  localId
@@ -33,5 +32,4 @@ export const taskList = {
33
32
  };
34
33
  return ['div', attrs, 0];
35
34
  }
36
-
37
35
  };
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @name text_node
3
3
  */
4
+
4
5
  export const text = {
5
6
  group: 'inline',
6
7
  toDebugString: process.env.NODE_ENV !== 'production' ? undefined : () => 'text_node'
@@ -3,13 +3,11 @@ export default {
3
3
  group: 'block',
4
4
  content: 'inline+',
5
5
  marks: '_',
6
-
7
6
  toDOM() {
8
7
  return ['div', {
9
8
  'data-node-type': name
10
9
  }, 0];
11
10
  },
12
-
13
11
  parseDOM: [{
14
12
  tag: `div[data-node-type="${name}"]`
15
13
  }]
@@ -14,7 +14,6 @@ export const unsupportedBlock = {
14
14
  originalValue: JSON.parse(dom.getAttribute('data-original-value') || '{}')
15
15
  })
16
16
  }],
17
-
18
17
  toDOM(node) {
19
18
  const attrs = {
20
19
  'data-node-type': 'unsupportedBlock',
@@ -22,5 +21,4 @@ export const unsupportedBlock = {
22
21
  };
23
22
  return ['div', attrs, 'Unsupported content'];
24
23
  }
25
-
26
24
  };
@@ -13,7 +13,6 @@ export const unsupportedInline = {
13
13
  originalValue: JSON.parse(dom.getAttribute('data-original-value') || '{}')
14
14
  })
15
15
  }],
16
-
17
16
  toDOM(node) {
18
17
  const attrs = {
19
18
  'data-node-type': 'unsupportedInline',
@@ -21,5 +20,4 @@ export const unsupportedInline = {
21
20
  };
22
21
  return ['span', attrs, 'Unsupported content'];
23
22
  }
24
-
25
23
  };
@@ -4,22 +4,21 @@ import { Slice } from 'prosemirror-model';
4
4
  export const analyticsStepType = 'atlaskit-analytics';
5
5
  export const analyticsInvertStepType = 'atlaskit-analytics-invert';
6
6
  var HISTORY_ACTIONS;
7
-
8
7
  (function (HISTORY_ACTIONS) {
9
8
  HISTORY_ACTIONS["UNDID"] = "undid";
10
9
  HISTORY_ACTIONS["REDID"] = "redid";
11
10
  })(HISTORY_ACTIONS || (HISTORY_ACTIONS = {}));
12
-
13
11
  /** Creates undo event from a normal analytics event */
14
12
  function createUndoEvent(analyticsEvent) {
15
13
  var _analyticsEvent$paylo;
16
-
17
- return { ...analyticsEvent,
14
+ return {
15
+ ...analyticsEvent,
18
16
  payload: {
19
17
  action: HISTORY_ACTIONS.UNDID,
20
18
  actionSubject: analyticsEvent.payload.actionSubject,
21
19
  actionSubjectId: analyticsEvent.payload.action,
22
- attributes: { ...analyticsEvent.payload.attributes,
20
+ attributes: {
21
+ ...analyticsEvent.payload.attributes,
23
22
  actionSubjectId: analyticsEvent.payload.actionSubjectId,
24
23
  inputMethod: ((_analyticsEvent$paylo = analyticsEvent.payload.attributes) === null || _analyticsEvent$paylo === void 0 ? void 0 : _analyticsEvent$paylo.inputMethod) || ''
25
24
  },
@@ -27,19 +26,18 @@ function createUndoEvent(analyticsEvent) {
27
26
  }
28
27
  };
29
28
  }
30
- /** Toggles event action between undo & redo */
31
29
 
32
-
33
- const toggleEventAction = analyticsEvent => ({ ...analyticsEvent,
34
- payload: { ...analyticsEvent.payload,
30
+ /** Toggles event action between undo & redo */
31
+ const toggleEventAction = analyticsEvent => ({
32
+ ...analyticsEvent,
33
+ payload: {
34
+ ...analyticsEvent.payload,
35
35
  action: analyticsEvent.payload.action === HISTORY_ACTIONS.UNDID ? HISTORY_ACTIONS.REDID : HISTORY_ACTIONS.UNDID
36
36
  }
37
37
  });
38
-
39
38
  function isHistoryAnalyticsEvent(event) {
40
39
  return event.payload.action === HISTORY_ACTIONS.UNDID || event.payload.action === HISTORY_ACTIONS.REDID;
41
40
  }
42
-
43
41
  /**
44
42
  * Custom Prosemirror Step to fire our GAS V3 analytics events
45
43
  * Using a Step means that it will work with prosemirror-history and we get
@@ -49,20 +47,16 @@ export class AnalyticsStep extends Step {
49
47
  constructor(analyticsEvents, actionsToIgnore = [], pos // Used to create the map, prevent splitting history.
50
48
  ) {
51
49
  super();
52
-
53
50
  _defineProperty(this, "analyticsEvents", []);
54
-
55
51
  _defineProperty(this, "actionsToIgnore", []);
56
-
57
52
  this.analyticsEvents = analyticsEvents;
58
53
  this.actionsToIgnore = actionsToIgnore;
59
54
  this.pos = pos;
60
55
  }
56
+
61
57
  /**
62
58
  * Generate new undo/redo analytics event when step is inverted
63
59
  */
64
-
65
-
66
60
  invert() {
67
61
  const analyticsEvents = this.analyticsEvents.filter(analyticsEvent => this.actionsToIgnore.indexOf(analyticsEvent.payload.action) === -1).map(analyticsEvent => {
68
62
  if (isHistoryAnalyticsEvent(analyticsEvent)) {
@@ -73,50 +67,39 @@ export class AnalyticsStep extends Step {
73
67
  });
74
68
  return new AnalyticsStep(analyticsEvents, []);
75
69
  }
76
-
77
70
  apply(doc) {
78
71
  return StepResult.ok(doc);
79
72
  }
80
-
81
73
  map(mapping) {
82
74
  let newPos = this.pos;
83
-
84
75
  if (typeof newPos === 'number') {
85
76
  newPos = mapping.map(newPos);
86
- } // Return the same events, this step will never be removed
87
-
88
-
77
+ }
78
+ // Return the same events, this step will never be removed
89
79
  return new AnalyticsStep(this.analyticsEvents, this.actionsToIgnore, newPos);
90
80
  }
91
-
92
81
  getMap() {
93
82
  if (typeof this.pos === 'number') {
94
83
  return new StepMap([this.pos, 0, 0]);
95
84
  }
96
-
97
85
  return new StepMap([]);
98
86
  }
99
-
100
87
  merge(other) {
101
88
  if (other instanceof AnalyticsStep) {
102
89
  const otherAnalyticsEvents = other.analyticsEvents;
103
90
  return new AnalyticsStep([...otherAnalyticsEvents, ...this.analyticsEvents]);
104
91
  }
105
-
106
92
  return null;
107
93
  }
108
-
109
94
  toJSON() {
110
95
  return {
111
96
  stepType: analyticsStepType
112
97
  };
113
98
  }
114
-
115
99
  static fromJSON() {
116
100
  return new ReplaceStep(0, 0, Slice.empty);
117
101
  }
118
-
119
102
  }
120
- /** Register this step with Prosemirror */
121
103
 
104
+ /** Register this step with Prosemirror */
122
105
  Step.jsonID(analyticsStepType, AnalyticsStep);
@@ -1,46 +1,40 @@
1
1
  import { Step, StepResult } from 'prosemirror-transform';
2
2
  import { Slice, Fragment } from 'prosemirror-model';
3
+
3
4
  /**
4
5
  * For more context on what this is about:
5
6
  * @see https://discuss.prosemirror.net/t/preventing-image-placeholder-replacement-from-being-undone/1394
6
7
  */
7
-
8
8
  export class SetAttrsStep extends Step {
9
9
  constructor(pos, attrs) {
10
10
  super();
11
11
  this.pos = pos;
12
12
  this.attrs = attrs;
13
13
  }
14
-
15
14
  apply(doc) {
16
15
  let target = doc.nodeAt(this.pos);
17
-
18
16
  if (!target) {
19
17
  return StepResult.fail('No node at given position');
20
18
  }
21
-
22
19
  if (target.isText) {
23
20
  return StepResult.fail('Target is a text node. Attributes are not allowed.');
24
21
  }
25
-
26
- const attrs = { ...(target.attrs || {}),
22
+ const attrs = {
23
+ ...(target.attrs || {}),
27
24
  ...(this.attrs || {})
28
25
  };
29
26
  let newNode = target.type.create(attrs, Fragment.empty, target.marks);
30
27
  let slice = new Slice(Fragment.from(newNode), 0, target.isLeaf ? 0 : 1);
31
28
  return StepResult.fromReplace(doc, this.pos, this.pos + 1, slice);
32
29
  }
33
-
34
30
  invert(doc) {
35
31
  let target = doc.nodeAt(this.pos);
36
32
  return new SetAttrsStep(this.pos, target ? target.attrs : {});
37
33
  }
38
-
39
34
  map(mapping) {
40
35
  let result = mapping.mapResult(this.pos, 1);
41
36
  return result.deleted ? null : new SetAttrsStep(result.pos, this.attrs);
42
37
  }
43
-
44
38
  toJSON() {
45
39
  return {
46
40
  stepType: 'setAttrs',
@@ -48,14 +42,11 @@ export class SetAttrsStep extends Step {
48
42
  attrs: this.attrs
49
43
  };
50
44
  }
51
-
52
45
  static fromJSON(_schema, json) {
53
46
  if (typeof json.pos !== 'number' || json.attrs !== null && typeof json.attrs !== 'object') {
54
47
  throw new RangeError('Invalid input for SetAttrsStep.fromJSON');
55
48
  }
56
-
57
49
  return new SetAttrsStep(json.pos, json.attrs);
58
50
  }
59
-
60
51
  }
61
52
  Step.jsonID('setAttrs', SetAttrsStep);