@atlaskit/adf-schema 19.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 (430) hide show
  1. package/CHANGELOG.md +1524 -0
  2. package/LICENSE +13 -0
  3. package/build/tsconfig.json +17 -0
  4. package/dist/cjs/index.js +1089 -0
  5. package/dist/cjs/schema/bitbucket-schema.js +14 -0
  6. package/dist/cjs/schema/confluence-schema.js +21 -0
  7. package/dist/cjs/schema/create-schema.js +354 -0
  8. package/dist/cjs/schema/default-schema.js +52 -0
  9. package/dist/cjs/schema/groups.js +35 -0
  10. package/dist/cjs/schema/index.js +755 -0
  11. package/dist/cjs/schema/inline-nodes.js +20 -0
  12. package/dist/cjs/schema/jira-schema.js +118 -0
  13. package/dist/cjs/schema/marks/alignment.js +39 -0
  14. package/dist/cjs/schema/marks/annotation.js +96 -0
  15. package/dist/cjs/schema/marks/breakout.js +32 -0
  16. package/dist/cjs/schema/marks/code.js +46 -0
  17. package/dist/cjs/schema/marks/confluence-inline-comment.js +30 -0
  18. package/dist/cjs/schema/marks/data-consumer.js +71 -0
  19. package/dist/cjs/schema/marks/em.js +25 -0
  20. package/dist/cjs/schema/marks/indentation.js +32 -0
  21. package/dist/cjs/schema/marks/index.js +189 -0
  22. package/dist/cjs/schema/marks/link.js +128 -0
  23. package/dist/cjs/schema/marks/strike.js +29 -0
  24. package/dist/cjs/schema/marks/strong.js +37 -0
  25. package/dist/cjs/schema/marks/subsup.js +61 -0
  26. package/dist/cjs/schema/marks/text-color.js +93 -0
  27. package/dist/cjs/schema/marks/type-ahead-query.js +31 -0
  28. package/dist/cjs/schema/marks/underline.js +25 -0
  29. package/dist/cjs/schema/marks/unsupported-mark.js +15 -0
  30. package/dist/cjs/schema/marks/unsupported-node-attributes.js +16 -0
  31. package/dist/cjs/schema/nodes/block-card.js +56 -0
  32. package/dist/cjs/schema/nodes/blockquote.js +23 -0
  33. package/dist/cjs/schema/nodes/bodied-extension.js +66 -0
  34. package/dist/cjs/schema/nodes/bullet-list.js +29 -0
  35. package/dist/cjs/schema/nodes/caption.js +27 -0
  36. package/dist/cjs/schema/nodes/code-block.js +160 -0
  37. package/dist/cjs/schema/nodes/confluence-jira-issue.js +54 -0
  38. package/dist/cjs/schema/nodes/confluence-unsupported-block.js +33 -0
  39. package/dist/cjs/schema/nodes/confluence-unsupported-inline.js +34 -0
  40. package/dist/cjs/schema/nodes/date.js +36 -0
  41. package/dist/cjs/schema/nodes/decision-item.js +45 -0
  42. package/dist/cjs/schema/nodes/decision-list.js +45 -0
  43. package/dist/cjs/schema/nodes/doc.js +15 -0
  44. package/dist/cjs/schema/nodes/embed-card.js +62 -0
  45. package/dist/cjs/schema/nodes/emoji.js +73 -0
  46. package/dist/cjs/schema/nodes/expand.js +86 -0
  47. package/dist/cjs/schema/nodes/extension.js +59 -0
  48. package/dist/cjs/schema/nodes/hard-break.js +22 -0
  49. package/dist/cjs/schema/nodes/heading.js +69 -0
  50. package/dist/cjs/schema/nodes/image.js +40 -0
  51. package/dist/cjs/schema/nodes/index.js +539 -0
  52. package/dist/cjs/schema/nodes/inline-card.js +64 -0
  53. package/dist/cjs/schema/nodes/inline-extension.js +54 -0
  54. package/dist/cjs/schema/nodes/layout-column.js +53 -0
  55. package/dist/cjs/schema/nodes/layout-section.js +61 -0
  56. package/dist/cjs/schema/nodes/list-item.js +25 -0
  57. package/dist/cjs/schema/nodes/media-group.js +29 -0
  58. package/dist/cjs/schema/nodes/media-inline.js +11 -0
  59. package/dist/cjs/schema/nodes/media-single.js +101 -0
  60. package/dist/cjs/schema/nodes/media.js +196 -0
  61. package/dist/cjs/schema/nodes/mention.js +90 -0
  62. package/dist/cjs/schema/nodes/nested-expand.js +64 -0
  63. package/dist/cjs/schema/nodes/ordered-list.js +29 -0
  64. package/dist/cjs/schema/nodes/panel.js +85 -0
  65. package/dist/cjs/schema/nodes/paragraph.js +45 -0
  66. package/dist/cjs/schema/nodes/placeholder.js +39 -0
  67. package/dist/cjs/schema/nodes/rule.js +21 -0
  68. package/dist/cjs/schema/nodes/status.js +56 -0
  69. package/dist/cjs/schema/nodes/tableNodes.js +276 -0
  70. package/dist/cjs/schema/nodes/task-item.js +46 -0
  71. package/dist/cjs/schema/nodes/task-list.js +45 -0
  72. package/dist/cjs/schema/nodes/text.js +17 -0
  73. package/dist/cjs/schema/nodes/types/block-content.js +5 -0
  74. package/dist/cjs/schema/nodes/types/extensions.js +5 -0
  75. package/dist/cjs/schema/nodes/types/inline-content.js +5 -0
  76. package/dist/cjs/schema/nodes/types/mark.js +5 -0
  77. package/dist/cjs/schema/nodes/types/non-nestable-block-content.js +5 -0
  78. package/dist/cjs/schema/nodes/types/rich-media-common.js +5 -0
  79. package/dist/cjs/schema/nodes/unknown-block.js +21 -0
  80. package/dist/cjs/schema/nodes/unsupported-block.js +33 -0
  81. package/dist/cjs/schema/nodes/unsupported-inline.js +32 -0
  82. package/dist/cjs/schema/unsupported.js +8 -0
  83. package/dist/cjs/steps/analytics.js +183 -0
  84. package/dist/cjs/steps/set-attrs.js +106 -0
  85. package/dist/cjs/steps/table/add-column.js +453 -0
  86. package/dist/cjs/steps/table/constants.js +13 -0
  87. package/dist/cjs/steps/table/sort-column.js +87 -0
  88. package/dist/cjs/steps/table/types.js +5 -0
  89. package/dist/cjs/steps/table/utils/cell-step.js +233 -0
  90. package/dist/cjs/steps/table/utils/cells-at-column.js +94 -0
  91. package/dist/cjs/steps/table/utils/find-column.js +94 -0
  92. package/dist/cjs/steps/table/utils/get-table-rect-from-doc.js +38 -0
  93. package/dist/cjs/steps/table/utils/side-effects/rows.js +370 -0
  94. package/dist/cjs/steps/table/utils/side-effects/side-effects.js +106 -0
  95. package/dist/cjs/steps/table/utils/side-effects/table.js +126 -0
  96. package/dist/cjs/steps/table/utils/side-effects/types.js +5 -0
  97. package/dist/cjs/steps/table/utils/table-map.js +36 -0
  98. package/dist/cjs/steps/type-ahead.js +134 -0
  99. package/dist/cjs/steps.js +59 -0
  100. package/dist/cjs/utils/colors.js +234 -0
  101. package/dist/cjs/utils/confluence/emoji.js +97 -0
  102. package/dist/cjs/utils/extensions.js +39 -0
  103. package/dist/cjs/utils/index.js +373 -0
  104. package/dist/cjs/utils/parseDOM.js +12 -0
  105. package/dist/cjs/utils/url.js +38 -0
  106. package/dist/cjs/utils/uuid.js +28 -0
  107. package/dist/cjs/version.json +5 -0
  108. package/dist/es2019/index.js +2 -0
  109. package/dist/es2019/schema/bitbucket-schema.js +5 -0
  110. package/dist/es2019/schema/confluence-schema.js +11 -0
  111. package/dist/es2019/schema/create-schema.js +325 -0
  112. package/dist/es2019/schema/default-schema.js +35 -0
  113. package/dist/es2019/schema/groups.js +23 -0
  114. package/dist/es2019/schema/index.js +9 -0
  115. package/dist/es2019/schema/inline-nodes.js +3 -0
  116. package/dist/es2019/schema/jira-schema.js +88 -0
  117. package/dist/es2019/schema/marks/alignment.js +32 -0
  118. package/dist/es2019/schema/marks/annotation.js +80 -0
  119. package/dist/es2019/schema/marks/breakout.js +29 -0
  120. package/dist/es2019/schema/marks/code.js +43 -0
  121. package/dist/es2019/schema/marks/confluence-inline-comment.js +24 -0
  122. package/dist/es2019/schema/marks/data-consumer.js +61 -0
  123. package/dist/es2019/schema/marks/em.js +22 -0
  124. package/dist/es2019/schema/marks/indentation.js +27 -0
  125. package/dist/es2019/schema/marks/index.js +17 -0
  126. package/dist/es2019/schema/marks/link.js +105 -0
  127. package/dist/es2019/schema/marks/strike.js +24 -0
  128. package/dist/es2019/schema/marks/strong.js +40 -0
  129. package/dist/es2019/schema/marks/subsup.js +51 -0
  130. package/dist/es2019/schema/marks/text-color.js +67 -0
  131. package/dist/es2019/schema/marks/type-ahead-query.js +23 -0
  132. package/dist/es2019/schema/marks/underline.js +20 -0
  133. package/dist/es2019/schema/marks/unsupported-mark.js +9 -0
  134. package/dist/es2019/schema/marks/unsupported-node-attributes.js +10 -0
  135. package/dist/es2019/schema/nodes/block-card.js +50 -0
  136. package/dist/es2019/schema/nodes/blockquote.js +17 -0
  137. package/dist/es2019/schema/nodes/bodied-extension.js +58 -0
  138. package/dist/es2019/schema/nodes/bullet-list.js +23 -0
  139. package/dist/es2019/schema/nodes/caption.js +21 -0
  140. package/dist/es2019/schema/nodes/code-block.js +143 -0
  141. package/dist/es2019/schema/nodes/confluence-jira-issue.js +49 -0
  142. package/dist/es2019/schema/nodes/confluence-unsupported-block.js +30 -0
  143. package/dist/es2019/schema/nodes/confluence-unsupported-inline.js +31 -0
  144. package/dist/es2019/schema/nodes/date.js +28 -0
  145. package/dist/es2019/schema/nodes/decision-item.js +37 -0
  146. package/dist/es2019/schema/nodes/decision-list.js +41 -0
  147. package/dist/es2019/schema/nodes/doc.js +7 -0
  148. package/dist/es2019/schema/nodes/embed-card.js +55 -0
  149. package/dist/es2019/schema/nodes/emoji.js +67 -0
  150. package/dist/es2019/schema/nodes/expand.js +73 -0
  151. package/dist/es2019/schema/nodes/extension.js +51 -0
  152. package/dist/es2019/schema/nodes/hard-break.js +16 -0
  153. package/dist/es2019/schema/nodes/heading.js +63 -0
  154. package/dist/es2019/schema/nodes/image.js +37 -0
  155. package/dist/es2019/schema/nodes/index.js +44 -0
  156. package/dist/es2019/schema/nodes/inline-card.js +58 -0
  157. package/dist/es2019/schema/nodes/inline-extension.js +46 -0
  158. package/dist/es2019/schema/nodes/layout-column.js +49 -0
  159. package/dist/es2019/schema/nodes/layout-section.js +56 -0
  160. package/dist/es2019/schema/nodes/list-item.js +20 -0
  161. package/dist/es2019/schema/nodes/media-group.js +23 -0
  162. package/dist/es2019/schema/nodes/media-inline.js +2 -0
  163. package/dist/es2019/schema/nodes/media-single.js +77 -0
  164. package/dist/es2019/schema/nodes/media.js +165 -0
  165. package/dist/es2019/schema/nodes/mention.js +81 -0
  166. package/dist/es2019/schema/nodes/nested-expand.js +58 -0
  167. package/dist/es2019/schema/nodes/ordered-list.js +23 -0
  168. package/dist/es2019/schema/nodes/panel.js +79 -0
  169. package/dist/es2019/schema/nodes/paragraph.js +39 -0
  170. package/dist/es2019/schema/nodes/placeholder.js +33 -0
  171. package/dist/es2019/schema/nodes/rule.js +15 -0
  172. package/dist/es2019/schema/nodes/status.js +54 -0
  173. package/dist/es2019/schema/nodes/tableNodes.js +222 -0
  174. package/dist/es2019/schema/nodes/task-item.js +38 -0
  175. package/dist/es2019/schema/nodes/task-list.js +37 -0
  176. package/dist/es2019/schema/nodes/text.js +7 -0
  177. package/dist/es2019/schema/nodes/types/block-content.js +1 -0
  178. package/dist/es2019/schema/nodes/types/extensions.js +1 -0
  179. package/dist/es2019/schema/nodes/types/inline-content.js +1 -0
  180. package/dist/es2019/schema/nodes/types/mark.js +1 -0
  181. package/dist/es2019/schema/nodes/types/non-nestable-block-content.js +1 -0
  182. package/dist/es2019/schema/nodes/types/rich-media-common.js +1 -0
  183. package/dist/es2019/schema/nodes/unknown-block.js +16 -0
  184. package/dist/es2019/schema/nodes/unsupported-block.js +26 -0
  185. package/dist/es2019/schema/nodes/unsupported-inline.js +25 -0
  186. package/dist/es2019/schema/unsupported.js +1 -0
  187. package/dist/es2019/steps/analytics.js +122 -0
  188. package/dist/es2019/steps/set-attrs.js +57 -0
  189. package/dist/es2019/steps/table/add-column.js +349 -0
  190. package/dist/es2019/steps/table/constants.js +6 -0
  191. package/dist/es2019/steps/table/sort-column.js +41 -0
  192. package/dist/es2019/steps/table/types.js +1 -0
  193. package/dist/es2019/steps/table/utils/cell-step.js +204 -0
  194. package/dist/es2019/steps/table/utils/cells-at-column.js +57 -0
  195. package/dist/es2019/steps/table/utils/find-column.js +86 -0
  196. package/dist/es2019/steps/table/utils/get-table-rect-from-doc.js +30 -0
  197. package/dist/es2019/steps/table/utils/side-effects/rows.js +297 -0
  198. package/dist/es2019/steps/table/utils/side-effects/side-effects.js +81 -0
  199. package/dist/es2019/steps/table/utils/side-effects/table.js +99 -0
  200. package/dist/es2019/steps/table/utils/side-effects/types.js +1 -0
  201. package/dist/es2019/steps/table/utils/table-map.js +19 -0
  202. package/dist/es2019/steps/type-ahead.js +85 -0
  203. package/dist/es2019/steps.js +6 -0
  204. package/dist/es2019/utils/colors.js +148 -0
  205. package/dist/es2019/utils/confluence/emoji.js +83 -0
  206. package/dist/es2019/utils/extensions.js +26 -0
  207. package/dist/es2019/utils/index.js +4 -0
  208. package/dist/es2019/utils/parseDOM.js +1 -0
  209. package/dist/es2019/utils/url.js +19 -0
  210. package/dist/es2019/utils/uuid.js +18 -0
  211. package/dist/es2019/version.json +5 -0
  212. package/dist/esm/index.js +2 -0
  213. package/dist/esm/schema/bitbucket-schema.js +5 -0
  214. package/dist/esm/schema/confluence-schema.js +11 -0
  215. package/dist/esm/schema/create-schema.js +338 -0
  216. package/dist/esm/schema/default-schema.js +36 -0
  217. package/dist/esm/schema/groups.js +23 -0
  218. package/dist/esm/schema/index.js +9 -0
  219. package/dist/esm/schema/inline-nodes.js +5 -0
  220. package/dist/esm/schema/jira-schema.js +88 -0
  221. package/dist/esm/schema/marks/alignment.js +30 -0
  222. package/dist/esm/schema/marks/annotation.js +82 -0
  223. package/dist/esm/schema/marks/breakout.js +25 -0
  224. package/dist/esm/schema/marks/code.js +41 -0
  225. package/dist/esm/schema/marks/confluence-inline-comment.js +22 -0
  226. package/dist/esm/schema/marks/data-consumer.js +63 -0
  227. package/dist/esm/schema/marks/em.js +20 -0
  228. package/dist/esm/schema/marks/indentation.js +23 -0
  229. package/dist/esm/schema/marks/index.js +17 -0
  230. package/dist/esm/schema/marks/link.js +113 -0
  231. package/dist/esm/schema/marks/strike.js +24 -0
  232. package/dist/esm/schema/marks/strong.js +32 -0
  233. package/dist/esm/schema/marks/subsup.js +53 -0
  234. package/dist/esm/schema/marks/text-color.js +78 -0
  235. package/dist/esm/schema/marks/type-ahead-query.js +21 -0
  236. package/dist/esm/schema/marks/underline.js +20 -0
  237. package/dist/esm/schema/marks/unsupported-mark.js +8 -0
  238. package/dist/esm/schema/marks/unsupported-node-attributes.js +9 -0
  239. package/dist/esm/schema/nodes/block-card.js +48 -0
  240. package/dist/esm/schema/nodes/blockquote.js +15 -0
  241. package/dist/esm/schema/nodes/bodied-extension.js +58 -0
  242. package/dist/esm/schema/nodes/bullet-list.js +21 -0
  243. package/dist/esm/schema/nodes/caption.js +19 -0
  244. package/dist/esm/schema/nodes/code-block.js +149 -0
  245. package/dist/esm/schema/nodes/confluence-jira-issue.js +47 -0
  246. package/dist/esm/schema/nodes/confluence-unsupported-block.js +26 -0
  247. package/dist/esm/schema/nodes/confluence-unsupported-inline.js +27 -0
  248. package/dist/esm/schema/nodes/date.js +28 -0
  249. package/dist/esm/schema/nodes/decision-item.js +36 -0
  250. package/dist/esm/schema/nodes/decision-list.js +39 -0
  251. package/dist/esm/schema/nodes/doc.js +7 -0
  252. package/dist/esm/schema/nodes/embed-card.js +54 -0
  253. package/dist/esm/schema/nodes/emoji.js +68 -0
  254. package/dist/esm/schema/nodes/expand.js +75 -0
  255. package/dist/esm/schema/nodes/extension.js +51 -0
  256. package/dist/esm/schema/nodes/hard-break.js +14 -0
  257. package/dist/esm/schema/nodes/heading.js +61 -0
  258. package/dist/esm/schema/nodes/image.js +33 -0
  259. package/dist/esm/schema/nodes/index.js +44 -0
  260. package/dist/esm/schema/nodes/inline-card.js +56 -0
  261. package/dist/esm/schema/nodes/inline-extension.js +46 -0
  262. package/dist/esm/schema/nodes/layout-column.js +45 -0
  263. package/dist/esm/schema/nodes/layout-section.js +52 -0
  264. package/dist/esm/schema/nodes/list-item.js +18 -0
  265. package/dist/esm/schema/nodes/media-group.js +21 -0
  266. package/dist/esm/schema/nodes/media-inline.js +2 -0
  267. package/dist/esm/schema/nodes/media-single.js +84 -0
  268. package/dist/esm/schema/nodes/media.js +174 -0
  269. package/dist/esm/schema/nodes/mention.js +80 -0
  270. package/dist/esm/schema/nodes/nested-expand.js +56 -0
  271. package/dist/esm/schema/nodes/ordered-list.js +21 -0
  272. package/dist/esm/schema/nodes/panel.js +76 -0
  273. package/dist/esm/schema/nodes/paragraph.js +37 -0
  274. package/dist/esm/schema/nodes/placeholder.js +31 -0
  275. package/dist/esm/schema/nodes/rule.js +13 -0
  276. package/dist/esm/schema/nodes/status.js +51 -0
  277. package/dist/esm/schema/nodes/tableNodes.js +238 -0
  278. package/dist/esm/schema/nodes/task-item.js +37 -0
  279. package/dist/esm/schema/nodes/task-list.js +35 -0
  280. package/dist/esm/schema/nodes/text.js +9 -0
  281. package/dist/esm/schema/nodes/types/block-content.js +1 -0
  282. package/dist/esm/schema/nodes/types/extensions.js +1 -0
  283. package/dist/esm/schema/nodes/types/inline-content.js +1 -0
  284. package/dist/esm/schema/nodes/types/mark.js +1 -0
  285. package/dist/esm/schema/nodes/types/non-nestable-block-content.js +1 -0
  286. package/dist/esm/schema/nodes/types/rich-media-common.js +1 -0
  287. package/dist/esm/schema/nodes/unknown-block.js +14 -0
  288. package/dist/esm/schema/nodes/unsupported-block.js +26 -0
  289. package/dist/esm/schema/nodes/unsupported-inline.js +25 -0
  290. package/dist/esm/schema/unsupported.js +1 -0
  291. package/dist/esm/steps/analytics.js +166 -0
  292. package/dist/esm/steps/set-attrs.js +89 -0
  293. package/dist/esm/steps/table/add-column.js +431 -0
  294. package/dist/esm/steps/table/constants.js +6 -0
  295. package/dist/esm/steps/table/sort-column.js +69 -0
  296. package/dist/esm/steps/table/types.js +1 -0
  297. package/dist/esm/steps/table/utils/cell-step.js +216 -0
  298. package/dist/esm/steps/table/utils/cells-at-column.js +84 -0
  299. package/dist/esm/steps/table/utils/find-column.js +87 -0
  300. package/dist/esm/steps/table/utils/get-table-rect-from-doc.js +30 -0
  301. package/dist/esm/steps/table/utils/side-effects/rows.js +360 -0
  302. package/dist/esm/steps/table/utils/side-effects/side-effects.js +93 -0
  303. package/dist/esm/steps/table/utils/side-effects/table.js +113 -0
  304. package/dist/esm/steps/table/utils/side-effects/types.js +1 -0
  305. package/dist/esm/steps/table/utils/table-map.js +19 -0
  306. package/dist/esm/steps/type-ahead.js +117 -0
  307. package/dist/esm/steps.js +6 -0
  308. package/dist/esm/utils/colors.js +160 -0
  309. package/dist/esm/utils/confluence/emoji.js +85 -0
  310. package/dist/esm/utils/extensions.js +27 -0
  311. package/dist/esm/utils/index.js +4 -0
  312. package/dist/esm/utils/parseDOM.js +3 -0
  313. package/dist/esm/utils/url.js +21 -0
  314. package/dist/esm/utils/uuid.js +18 -0
  315. package/dist/esm/version.json +5 -0
  316. package/dist/json-schema/v1/full.json +2536 -0
  317. package/dist/json-schema/v1/stage-0.json +2737 -0
  318. package/dist/types/index.d.ts +4 -0
  319. package/dist/types/schema/bitbucket-schema.d.ts +2 -0
  320. package/dist/types/schema/confluence-schema.d.ts +3 -0
  321. package/dist/types/schema/create-schema.d.ts +31 -0
  322. package/dist/types/schema/default-schema.d.ts +7 -0
  323. package/dist/types/schema/groups.d.ts +6 -0
  324. package/dist/types/schema/index.d.ts +11 -0
  325. package/dist/types/schema/inline-nodes.d.ts +1 -0
  326. package/dist/types/schema/jira-schema.d.ts +26 -0
  327. package/dist/types/schema/marks/alignment.d.ts +16 -0
  328. package/dist/types/schema/marks/annotation.d.ts +32 -0
  329. package/dist/types/schema/marks/breakout.d.ts +12 -0
  330. package/dist/types/schema/marks/code.d.ts +8 -0
  331. package/dist/types/schema/marks/confluence-inline-comment.d.ts +12 -0
  332. package/dist/types/schema/marks/data-consumer.d.ts +41 -0
  333. package/dist/types/schema/marks/em.d.ts +8 -0
  334. package/dist/types/schema/marks/indentation.d.ts +16 -0
  335. package/dist/types/schema/marks/index.d.ts +30 -0
  336. package/dist/types/schema/marks/link.d.ts +32 -0
  337. package/dist/types/schema/marks/strike.d.ts +8 -0
  338. package/dist/types/schema/marks/strong.d.ts +8 -0
  339. package/dist/types/schema/marks/subsup.d.ts +15 -0
  340. package/dist/types/schema/marks/text-color.d.ts +21 -0
  341. package/dist/types/schema/marks/type-ahead-query.d.ts +2 -0
  342. package/dist/types/schema/marks/underline.d.ts +8 -0
  343. package/dist/types/schema/marks/unsupported-mark.d.ts +2 -0
  344. package/dist/types/schema/marks/unsupported-node-attributes.d.ts +2 -0
  345. package/dist/types/schema/nodes/block-card.d.ts +19 -0
  346. package/dist/types/schema/nodes/blockquote.d.ts +14 -0
  347. package/dist/types/schema/nodes/bodied-extension.d.ts +27 -0
  348. package/dist/types/schema/nodes/bullet-list.d.ts +14 -0
  349. package/dist/types/schema/nodes/caption.d.ts +21 -0
  350. package/dist/types/schema/nodes/code-block.d.ts +31 -0
  351. package/dist/types/schema/nodes/confluence-jira-issue.d.ts +2 -0
  352. package/dist/types/schema/nodes/confluence-unsupported-block.d.ts +2 -0
  353. package/dist/types/schema/nodes/confluence-unsupported-inline.d.ts +2 -0
  354. package/dist/types/schema/nodes/date.d.ts +14 -0
  355. package/dist/types/schema/nodes/decision-item.d.ts +17 -0
  356. package/dist/types/schema/nodes/decision-list.d.ts +18 -0
  357. package/dist/types/schema/nodes/doc.d.ts +18 -0
  358. package/dist/types/schema/nodes/embed-card.d.ts +15 -0
  359. package/dist/types/schema/nodes/emoji.d.ts +14 -0
  360. package/dist/types/schema/nodes/expand.d.ts +33 -0
  361. package/dist/types/schema/nodes/extension.d.ts +21 -0
  362. package/dist/types/schema/nodes/hard-break.d.ts +11 -0
  363. package/dist/types/schema/nodes/heading.d.ts +36 -0
  364. package/dist/types/schema/nodes/image.d.ts +2 -0
  365. package/dist/types/schema/nodes/index.d.ts +93 -0
  366. package/dist/types/schema/nodes/inline-card.d.ts +19 -0
  367. package/dist/types/schema/nodes/inline-extension.d.ts +21 -0
  368. package/dist/types/schema/nodes/layout-column.d.ts +21 -0
  369. package/dist/types/schema/nodes/layout-section.d.ts +44 -0
  370. package/dist/types/schema/nodes/list-item.d.ts +20 -0
  371. package/dist/types/schema/nodes/media-group.d.ts +14 -0
  372. package/dist/types/schema/nodes/media-inline.d.ts +16 -0
  373. package/dist/types/schema/nodes/media-single.d.ts +59 -0
  374. package/dist/types/schema/nodes/media.d.ts +60 -0
  375. package/dist/types/schema/nodes/mention.d.ts +26 -0
  376. package/dist/types/schema/nodes/nested-expand.d.ts +27 -0
  377. package/dist/types/schema/nodes/ordered-list.d.ts +20 -0
  378. package/dist/types/schema/nodes/panel.d.ts +46 -0
  379. package/dist/types/schema/nodes/paragraph.d.ts +37 -0
  380. package/dist/types/schema/nodes/placeholder.d.ts +11 -0
  381. package/dist/types/schema/nodes/rule.d.ts +8 -0
  382. package/dist/types/schema/nodes/status.d.ts +20 -0
  383. package/dist/types/schema/nodes/tableNodes.d.ts +111 -0
  384. package/dist/types/schema/nodes/task-item.d.ts +17 -0
  385. package/dist/types/schema/nodes/task-list.d.ts +21 -0
  386. package/dist/types/schema/nodes/text.d.ts +15 -0
  387. package/dist/types/schema/nodes/types/block-content.d.ts +22 -0
  388. package/dist/types/schema/nodes/types/extensions.d.ts +34 -0
  389. package/dist/types/schema/nodes/types/inline-content.d.ts +32 -0
  390. package/dist/types/schema/nodes/types/mark.d.ts +15 -0
  391. package/dist/types/schema/nodes/types/non-nestable-block-content.d.ts +20 -0
  392. package/dist/types/schema/nodes/types/rich-media-common.d.ts +9 -0
  393. package/dist/types/schema/nodes/unknown-block.d.ts +3 -0
  394. package/dist/types/schema/nodes/unsupported-block.d.ts +2 -0
  395. package/dist/types/schema/nodes/unsupported-inline.d.ts +2 -0
  396. package/dist/types/schema/unsupported.d.ts +1 -0
  397. package/dist/types/steps/analytics.d.ts +59 -0
  398. package/dist/types/steps/set-attrs.d.ts +23 -0
  399. package/dist/types/steps/table/add-column.d.ts +88 -0
  400. package/dist/types/steps/table/constants.d.ts +4 -0
  401. package/dist/types/steps/table/sort-column.d.ts +18 -0
  402. package/dist/types/steps/table/types.d.ts +39 -0
  403. package/dist/types/steps/table/utils/cell-step.d.ts +47 -0
  404. package/dist/types/steps/table/utils/cells-at-column.d.ts +20 -0
  405. package/dist/types/steps/table/utils/find-column.d.ts +8 -0
  406. package/dist/types/steps/table/utils/get-table-rect-from-doc.d.ts +8 -0
  407. package/dist/types/steps/table/utils/side-effects/rows.d.ts +25 -0
  408. package/dist/types/steps/table/utils/side-effects/side-effects.d.ts +15 -0
  409. package/dist/types/steps/table/utils/side-effects/table.d.ts +16 -0
  410. package/dist/types/steps/table/utils/side-effects/types.d.ts +33 -0
  411. package/dist/types/steps/table/utils/table-map.d.ts +6 -0
  412. package/dist/types/steps/type-ahead.d.ts +35 -0
  413. package/dist/types/steps.d.ts +8 -0
  414. package/dist/types/utils/colors.d.ts +71 -0
  415. package/dist/types/utils/confluence/emoji.d.ts +50 -0
  416. package/dist/types/utils/extensions.d.ts +3 -0
  417. package/dist/types/utils/index.d.ts +6 -0
  418. package/dist/types/utils/parseDOM.d.ts +1 -0
  419. package/dist/types/utils/url.d.ts +15 -0
  420. package/dist/types/utils/uuid.d.ts +5 -0
  421. package/document-fixtures/unsupported-content.json +526 -0
  422. package/json-schema/v1/full.json +2536 -0
  423. package/json-schema/v1/stage-0.json +2737 -0
  424. package/package.json +63 -0
  425. package/steps/package.json +7 -0
  426. package/test-helpers/html-helpers.ts +40 -0
  427. package/test-helpers/matches.ts +8 -0
  428. package/test-helpers/schema-builder.ts +329 -0
  429. package/test-helpers/schema.ts +79 -0
  430. package/tsconfig.json +18 -0
@@ -0,0 +1,37 @@
1
+ import { uuid } from '../../utils/uuid';
2
+ export var taskItem = {
3
+ content: 'inline*',
4
+ defining: true,
5
+ selectable: false,
6
+ marks: '_',
7
+ attrs: {
8
+ localId: {
9
+ default: ''
10
+ },
11
+ state: {
12
+ default: 'TODO'
13
+ }
14
+ },
15
+ parseDOM: [{
16
+ tag: 'div[data-task-local-id]',
17
+ // Default priority is 50. We normally don't change this but since this node type is
18
+ // also used by list-item we need to make sure that we run this parser first.
19
+ priority: 100,
20
+ getAttrs: function getAttrs(dom) {
21
+ return {
22
+ localId: uuid.generate(),
23
+ state: dom.getAttribute('data-task-state') || 'TODO'
24
+ };
25
+ }
26
+ }],
27
+ toDOM: function toDOM(node) {
28
+ var _node$attrs = node.attrs,
29
+ localId = _node$attrs.localId,
30
+ state = _node$attrs.state;
31
+ var attrs = {
32
+ 'data-task-local-id': localId || 'local-task',
33
+ 'data-task-state': state || 'TODO'
34
+ };
35
+ return ['div', attrs, 0];
36
+ }
37
+ };
@@ -0,0 +1,35 @@
1
+ import { uuid } from '../../utils/uuid';
2
+ var name = 'actionList';
3
+ export var taskListSelector = "[data-node-type=\"".concat(name, "\"]");
4
+ export var taskList = {
5
+ group: 'block',
6
+ defining: true,
7
+ selectable: false,
8
+ content: '(taskItem|unsupportedBlock)+ (taskItem|taskList|unsupportedBlock)*',
9
+ marks: 'unsupportedMark unsupportedNodeAttribute',
10
+ attrs: {
11
+ localId: {
12
+ default: ''
13
+ }
14
+ },
15
+ parseDOM: [{
16
+ tag: "div".concat(taskListSelector),
17
+ // Default priority is 50. We normally don't change this but since this node type is
18
+ // also used by ordered-list we need to make sure that we run this parser first.
19
+ priority: 100,
20
+ getAttrs: function getAttrs() {
21
+ return {
22
+ localId: uuid.generate()
23
+ };
24
+ }
25
+ }],
26
+ toDOM: function toDOM(node) {
27
+ var localId = node.attrs.localId;
28
+ var attrs = {
29
+ 'data-node-type': name,
30
+ 'data-task-list-local-id': localId || 'local-task-list',
31
+ style: 'list-style: none; padding-left: 0'
32
+ };
33
+ return ['div', attrs, 0];
34
+ }
35
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @name text_node
3
+ */
4
+ export var text = {
5
+ group: 'inline',
6
+ toDebugString: process.env.NODE_ENV !== 'production' ? undefined : function () {
7
+ return 'text_node';
8
+ }
9
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ var name = 'unknownBlock';
2
+ export default {
3
+ group: 'block',
4
+ content: 'inline+',
5
+ marks: '_',
6
+ toDOM: function toDOM() {
7
+ return ['div', {
8
+ 'data-node-type': name
9
+ }, 0];
10
+ },
11
+ parseDOM: [{
12
+ tag: "div[data-node-type=\"".concat(name, "\"]")
13
+ }]
14
+ };
@@ -0,0 +1,26 @@
1
+ export var unsupportedBlock = {
2
+ inline: false,
3
+ group: 'block',
4
+ atom: true,
5
+ selectable: true,
6
+ attrs: {
7
+ originalValue: {
8
+ default: {}
9
+ }
10
+ },
11
+ parseDOM: [{
12
+ tag: '[data-node-type="unsupportedBlock"]',
13
+ getAttrs: function getAttrs(dom) {
14
+ return {
15
+ originalValue: JSON.parse(dom.getAttribute('data-original-value') || '{}')
16
+ };
17
+ }
18
+ }],
19
+ toDOM: function toDOM(node) {
20
+ var attrs = {
21
+ 'data-node-type': 'unsupportedBlock',
22
+ 'data-original-value': JSON.stringify(node.attrs.originalValue)
23
+ };
24
+ return ['div', attrs, 'Unsupported content'];
25
+ }
26
+ };
@@ -0,0 +1,25 @@
1
+ export var unsupportedInline = {
2
+ inline: true,
3
+ group: 'inline',
4
+ selectable: true,
5
+ attrs: {
6
+ originalValue: {
7
+ default: {}
8
+ }
9
+ },
10
+ parseDOM: [{
11
+ tag: '[data-node-type="unsupportedInline"]',
12
+ getAttrs: function getAttrs(dom) {
13
+ return {
14
+ originalValue: JSON.parse(dom.getAttribute('data-original-value') || '{}')
15
+ };
16
+ }
17
+ }],
18
+ toDOM: function toDOM(node) {
19
+ var attrs = {
20
+ 'data-node-type': 'unsupportedInline',
21
+ 'data-original-value': JSON.stringify(node.attrs.originalValue)
22
+ };
23
+ return ['span', attrs, 'Unsupported content'];
24
+ }
25
+ };
@@ -0,0 +1 @@
1
+ export var unsupportedNodeTypesForMediaCards = new Set(['decisionItem', 'taskItem']);
@@ -0,0 +1,166 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/createClass";
4
+ import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
5
+ import _inherits from "@babel/runtime/helpers/inherits";
6
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
+
10
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11
+
12
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
13
+
14
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
15
+
16
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
17
+
18
+ import { Step, StepResult, StepMap, ReplaceStep } from 'prosemirror-transform';
19
+ import { Slice } from 'prosemirror-model';
20
+ export var analyticsStepType = 'atlaskit-analytics';
21
+ export var analyticsInvertStepType = 'atlaskit-analytics-invert';
22
+ var HISTORY_ACTIONS;
23
+
24
+ (function (HISTORY_ACTIONS) {
25
+ HISTORY_ACTIONS["UNDID"] = "undid";
26
+ HISTORY_ACTIONS["REDID"] = "redid";
27
+ })(HISTORY_ACTIONS || (HISTORY_ACTIONS = {}));
28
+
29
+ /** Creates undo event from a normal analytics event */
30
+ function createUndoEvent(analyticsEvent) {
31
+ var _analyticsEvent$paylo;
32
+
33
+ return _objectSpread(_objectSpread({}, analyticsEvent), {}, {
34
+ payload: {
35
+ action: HISTORY_ACTIONS.UNDID,
36
+ actionSubject: analyticsEvent.payload.actionSubject,
37
+ actionSubjectId: analyticsEvent.payload.action,
38
+ attributes: _objectSpread(_objectSpread({}, analyticsEvent.payload.attributes), {}, {
39
+ actionSubjectId: analyticsEvent.payload.actionSubjectId,
40
+ inputMethod: ((_analyticsEvent$paylo = analyticsEvent.payload.attributes) === null || _analyticsEvent$paylo === void 0 ? void 0 : _analyticsEvent$paylo.inputMethod) || ''
41
+ }),
42
+ eventType: 'track'
43
+ }
44
+ });
45
+ }
46
+ /** Toggles event action between undo & redo */
47
+
48
+
49
+ var toggleEventAction = function toggleEventAction(analyticsEvent) {
50
+ return _objectSpread(_objectSpread({}, analyticsEvent), {}, {
51
+ payload: _objectSpread(_objectSpread({}, analyticsEvent.payload), {}, {
52
+ action: analyticsEvent.payload.action === HISTORY_ACTIONS.UNDID ? HISTORY_ACTIONS.REDID : HISTORY_ACTIONS.UNDID
53
+ })
54
+ });
55
+ };
56
+
57
+ function isHistoryAnalyticsEvent(event) {
58
+ return event.payload.action === HISTORY_ACTIONS.UNDID || event.payload.action === HISTORY_ACTIONS.REDID;
59
+ }
60
+
61
+ /**
62
+ * Custom Prosemirror Step to fire our GAS V3 analytics events
63
+ * Using a Step means that it will work with prosemirror-history and we get
64
+ * undo/redo events for free
65
+ */
66
+ export var AnalyticsStep = /*#__PURE__*/function (_Step) {
67
+ _inherits(AnalyticsStep, _Step);
68
+
69
+ var _super = _createSuper(AnalyticsStep);
70
+
71
+ function AnalyticsStep(analyticsEvents) {
72
+ var _this;
73
+
74
+ var actionsToIgnore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
75
+ var pos // Used to create the map, prevent splitting history.
76
+ = arguments.length > 2 ? arguments[2] : undefined;
77
+
78
+ _classCallCheck(this, AnalyticsStep);
79
+
80
+ _this = _super.call(this);
81
+
82
+ _defineProperty(_assertThisInitialized(_this), "analyticsEvents", []);
83
+
84
+ _defineProperty(_assertThisInitialized(_this), "actionsToIgnore", []);
85
+
86
+ _this.analyticsEvents = analyticsEvents;
87
+ _this.actionsToIgnore = actionsToIgnore;
88
+ _this.pos = pos;
89
+ return _this;
90
+ }
91
+ /**
92
+ * Generate new undo/redo analytics event when step is inverted
93
+ */
94
+
95
+
96
+ _createClass(AnalyticsStep, [{
97
+ key: "invert",
98
+ value: function invert() {
99
+ var _this2 = this;
100
+
101
+ var analyticsEvents = this.analyticsEvents.filter(function (analyticsEvent) {
102
+ return _this2.actionsToIgnore.indexOf(analyticsEvent.payload.action) === -1;
103
+ }).map(function (analyticsEvent) {
104
+ if (isHistoryAnalyticsEvent(analyticsEvent)) {
105
+ return toggleEventAction(analyticsEvent);
106
+ } else {
107
+ return createUndoEvent(analyticsEvent);
108
+ }
109
+ });
110
+ return new AnalyticsStep(analyticsEvents, []);
111
+ }
112
+ }, {
113
+ key: "apply",
114
+ value: function apply(doc) {
115
+ return StepResult.ok(doc);
116
+ }
117
+ }, {
118
+ key: "map",
119
+ value: function map(mapping) {
120
+ var newPos = this.pos;
121
+
122
+ if (typeof newPos === 'number') {
123
+ newPos = mapping.map(newPos);
124
+ } // Return the same events, this step will never be removed
125
+
126
+
127
+ return new AnalyticsStep(this.analyticsEvents, this.actionsToIgnore, newPos);
128
+ }
129
+ }, {
130
+ key: "getMap",
131
+ value: function getMap() {
132
+ if (typeof this.pos === 'number') {
133
+ return new StepMap([this.pos, 0, 0]);
134
+ }
135
+
136
+ return new StepMap([]);
137
+ }
138
+ }, {
139
+ key: "merge",
140
+ value: function merge(other) {
141
+ if (other instanceof AnalyticsStep) {
142
+ var otherAnalyticsEvents = other.analyticsEvents;
143
+ return new AnalyticsStep([].concat(_toConsumableArray(otherAnalyticsEvents), _toConsumableArray(this.analyticsEvents)));
144
+ }
145
+
146
+ return null;
147
+ }
148
+ }, {
149
+ key: "toJSON",
150
+ value: function toJSON() {
151
+ return {
152
+ stepType: analyticsStepType
153
+ };
154
+ }
155
+ }], [{
156
+ key: "fromJSON",
157
+ value: function fromJSON() {
158
+ return new ReplaceStep(0, 0, Slice.empty);
159
+ }
160
+ }]);
161
+
162
+ return AnalyticsStep;
163
+ }(Step);
164
+ /** Register this step with Prosemirror */
165
+
166
+ Step.jsonID(analyticsStepType, AnalyticsStep);
@@ -0,0 +1,89 @@
1
+ import _typeof from "@babel/runtime/helpers/typeof";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
+ import _createClass from "@babel/runtime/helpers/createClass";
5
+ import _inherits from "@babel/runtime/helpers/inherits";
6
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
+
9
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
10
+
11
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
12
+
13
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
14
+
15
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
16
+
17
+ import { Step, StepResult } from 'prosemirror-transform';
18
+ import { Slice, Fragment } from 'prosemirror-model';
19
+ /**
20
+ * For more context on what this is about:
21
+ * @see https://discuss.prosemirror.net/t/preventing-image-placeholder-replacement-from-being-undone/1394
22
+ */
23
+
24
+ export var SetAttrsStep = /*#__PURE__*/function (_Step) {
25
+ _inherits(SetAttrsStep, _Step);
26
+
27
+ var _super = _createSuper(SetAttrsStep);
28
+
29
+ function SetAttrsStep(pos, attrs) {
30
+ var _this;
31
+
32
+ _classCallCheck(this, SetAttrsStep);
33
+
34
+ _this = _super.call(this);
35
+ _this.pos = pos;
36
+ _this.attrs = attrs;
37
+ return _this;
38
+ }
39
+
40
+ _createClass(SetAttrsStep, [{
41
+ key: "apply",
42
+ value: function apply(doc) {
43
+ var target = doc.nodeAt(this.pos);
44
+
45
+ if (!target) {
46
+ return StepResult.fail('No node at given position');
47
+ }
48
+
49
+ var attrs = _objectSpread(_objectSpread({}, target.attrs || {}), this.attrs || {});
50
+
51
+ var newNode = target.type.create(attrs, Fragment.empty, target.marks);
52
+ var slice = new Slice(Fragment.from(newNode), 0, target.isLeaf ? 0 : 1);
53
+ return StepResult.fromReplace(doc, this.pos, this.pos + 1, slice);
54
+ }
55
+ }, {
56
+ key: "invert",
57
+ value: function invert(doc) {
58
+ var target = doc.nodeAt(this.pos);
59
+ return new SetAttrsStep(this.pos, target ? target.attrs : {});
60
+ }
61
+ }, {
62
+ key: "map",
63
+ value: function map(mapping) {
64
+ var result = mapping.mapResult(this.pos, 1);
65
+ return result.deleted ? null : new SetAttrsStep(result.pos, this.attrs);
66
+ }
67
+ }, {
68
+ key: "toJSON",
69
+ value: function toJSON() {
70
+ return {
71
+ stepType: 'setAttrs',
72
+ pos: this.pos,
73
+ attrs: this.attrs
74
+ };
75
+ }
76
+ }], [{
77
+ key: "fromJSON",
78
+ value: function fromJSON(_schema, json) {
79
+ if (typeof json.pos !== 'number' || json.attrs !== null && _typeof(json.attrs) !== 'object') {
80
+ throw new RangeError('Invalid input for SetAttrsStep.fromJSON');
81
+ }
82
+
83
+ return new SetAttrsStep(json.pos, json.attrs);
84
+ }
85
+ }]);
86
+
87
+ return SetAttrsStep;
88
+ }(Step);
89
+ Step.jsonID('setAttrs', SetAttrsStep);
@@ -0,0 +1,431 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
+ import _createClass from "@babel/runtime/helpers/createClass";
5
+ import _inherits from "@babel/runtime/helpers/inherits";
6
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
+
9
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
10
+
11
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
12
+
13
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
14
+
15
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
16
+
17
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
18
+
19
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
20
+
21
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
22
+
23
+ import { Step, StepMap, StepResult, Transform } from 'prosemirror-transform';
24
+ import { cellsAtColumn } from './utils/cells-at-column';
25
+ import { findColumn } from './utils/find-column';
26
+ import { getTableRectFromDoc } from './utils/get-table-rect-from-doc';
27
+ import { applyCellStep, createCellStep, getMapFromCellStep, invertCellStep } from './utils/cell-step';
28
+ import { SideEffectsHandler } from './utils/side-effects/side-effects';
29
+ import memoizeOne from 'memoize-one';
30
+ var ADD_COLUMN_STEP = 'ak-add-column';
31
+
32
+ function printColumnInfo(columnInfo) {
33
+ var cellsFrom = [];
34
+
35
+ var _iterator = _createForOfIteratorHelper(columnInfo.values()),
36
+ _step;
37
+
38
+ try {
39
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
40
+ var cellInfo = _step.value;
41
+ cellsFrom.push(cellInfo.from);
42
+ }
43
+ } catch (err) {
44
+ _iterator.e(err);
45
+ } finally {
46
+ _iterator.f();
47
+ }
48
+
49
+ return "[".concat(cellsFrom.join(','), "]");
50
+ }
51
+
52
+ function createColumnInfo(cellsInfo) {
53
+ return new Map(cellsInfo.map(function (cellInfo) {
54
+ return [cellInfo.from, cellInfo];
55
+ }));
56
+ }
57
+
58
+ var getTableRectAndColumnFactory = function getTableRectAndColumnFactory(doc, pos, columnInfo) {
59
+ return memoizeOne(function () {
60
+ var rect = getTableRectFromDoc(doc, pos);
61
+ var column = findColumn(columnInfo, rect);
62
+
63
+ if (column === null) {
64
+ throw new Error('no column');
65
+ }
66
+
67
+ return {
68
+ rect: rect,
69
+ column: column
70
+ };
71
+ });
72
+ };
73
+ /**
74
+ * Index and positions looks like
75
+ * 0 1 2 3 -> Add Column Index
76
+ * | 5 | 10 | 15 | -> Table with Positions
77
+ * | 20 | 25 | 30 |
78
+ * 0 1 2 x -> Remove Column Index
79
+ *
80
+ */
81
+
82
+
83
+ export var AddColumnStep = /*#__PURE__*/function (_Step) {
84
+ _inherits(AddColumnStep, _Step);
85
+
86
+ var _super = _createSuper(AddColumnStep);
87
+
88
+ function AddColumnStep(tablePos, addColumnStepInfo) {
89
+ var _this;
90
+
91
+ var isDelete = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
92
+
93
+ _classCallCheck(this, AddColumnStep);
94
+
95
+ _this = _super.call(this);
96
+ _this.tablePos = tablePos;
97
+ _this.isDelete = isDelete;
98
+ _this.sideEffectsHandler = new SideEffectsHandler(addColumnStepInfo.sideEffects);
99
+ _this.columnInfo = createColumnInfo(addColumnStepInfo.cells);
100
+ return _this;
101
+ }
102
+ /**
103
+ * Detect the column based on all the cells step in column info.
104
+ * Recreate columnInfo based on the current document. We might need to add new cells added by insert row or unmerge cells.
105
+ * If isDelete
106
+ * Decrease colspan if one row has merged cell
107
+ * Remove all the cells using columnInfo.cellStep[].from
108
+ * else
109
+ * Increase colspan if one row had merged cell
110
+ * Add all new cells at columnInfo.cellStep[].from,
111
+ * if there is columnInfo.cellStep[].newCell use it
112
+ * else create an empty cell
113
+ *
114
+ * @param doc Current document
115
+ */
116
+
117
+
118
+ _createClass(AddColumnStep, [{
119
+ key: "apply",
120
+ value: function apply(doc) {
121
+ var tablePos = this.tablePos; // Create transform base on the doc
122
+
123
+ var tr = new Transform(doc);
124
+
125
+ if (this.sideEffectsHandler.table.handleAddTable(tr, this.isDelete)) {
126
+ return StepResult.ok(tr.doc);
127
+ }
128
+
129
+ var tableRect;
130
+
131
+ try {
132
+ tableRect = getTableRectFromDoc(doc, tablePos);
133
+ } catch (e) {
134
+ return StepResult.fail(e.message);
135
+ }
136
+
137
+ var column = findColumn(this.columnInfo, tableRect);
138
+
139
+ if (column === null) {
140
+ return StepResult.fail("No column for this cells \"".concat(printColumnInfo(this.columnInfo), "\" in table at position \"").concat(tablePos, "\"."));
141
+ }
142
+
143
+ if (this.sideEffectsHandler.table.handleRemoveTable(tr, this.tablePos, tableRect, column, this.isDelete)) {
144
+ return StepResult.ok(tr.doc);
145
+ }
146
+
147
+ this.columnInfo = this.applyCellSteps(tr, tableRect, column, this.isDelete); // Return the document modified.
148
+
149
+ return StepResult.ok(tr.doc);
150
+ }
151
+ /**
152
+ * Update tablePos with the new position. If tablePos doesnt exist any more remove the step
153
+ * Update all the cellStep inside columnInfo. If cellStep.from position gets deleted removed it from column info
154
+ * if cellStep.length === 0 remove the step
155
+ * Create a new step with all the position updated
156
+ * @param mapping
157
+ */
158
+
159
+ }, {
160
+ key: "map",
161
+ value: function map(mapping) {
162
+ var tablePosResult = mapping.mapResult(this.tablePos);
163
+
164
+ if (tablePosResult.deleted) {
165
+ // If table was deleted remove the step
166
+ return null;
167
+ }
168
+
169
+ var cellSteps = [];
170
+
171
+ var _iterator2 = _createForOfIteratorHelper(this.columnInfo.values()),
172
+ _step2;
173
+
174
+ try {
175
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
176
+ var oldCellStep = _step2.value;
177
+ var fromResult = mapping.mapResult(oldCellStep.from);
178
+ var toResult = mapping.mapResult(oldCellStep.to);
179
+
180
+ if (fromResult.deleted && toResult.deleted) {
181
+ continue;
182
+ }
183
+
184
+ var cellStep = _objectSpread(_objectSpread({}, oldCellStep), {}, {
185
+ from: fromResult.pos,
186
+ to: toResult.pos
187
+ });
188
+
189
+ if (oldCellStep.mergeWith !== undefined) {
190
+ cellStep.mergeWith = mapping.map(oldCellStep.mergeWith);
191
+ }
192
+
193
+ cellSteps.push(cellStep);
194
+ }
195
+ } catch (err) {
196
+ _iterator2.e(err);
197
+ } finally {
198
+ _iterator2.f();
199
+ }
200
+
201
+ if (cellSteps.length === 0) {
202
+ return null;
203
+ }
204
+
205
+ var sideEffects = this.sideEffectsHandler.map(mapping);
206
+ return new AddColumnStep(tablePosResult.pos, {
207
+ cells: cellSteps,
208
+ sideEffects: sideEffects
209
+ }, this.isDelete);
210
+ }
211
+ /**
212
+ * if isDelete
213
+ * Get the original cell node at columnInfo.cellStep[].from to columnInfo.cellStep[].to
214
+ * Create a copy of the node
215
+ * Create a new cellStep with the same positions but with the clone node as a content
216
+ * return new step inverted
217
+ * else
218
+ * Remove the content from each columnInfo.cellStep[].content
219
+ * return new step inverted
220
+ * @param originalDoc
221
+ */
222
+
223
+ }, {
224
+ key: "invert",
225
+ value: function invert(originalDoc) {
226
+ var _this2 = this;
227
+
228
+ var stepMap = this.getMap(); // Memoize function to be called only on delete scenarios
229
+
230
+ var getTableRectAndColumn = getTableRectAndColumnFactory(originalDoc, this.tablePos, this.columnInfo); // This is needed because the real pos of the cell in the generated document is affected by the previous operations.
231
+
232
+ var newCellSteps = Array.from(this.columnInfo.values(), function (oldCellStep) {
233
+ var newCellStep = invertCellStep(originalDoc, getTableRectAndColumn, oldCellStep, _this2.isDelete, stepMap);
234
+ return newCellStep;
235
+ });
236
+ var sideEffects = this.sideEffectsHandler.invert(originalDoc, this.isDelete, stepMap);
237
+ return new AddColumnStep(this.tablePos, {
238
+ cells: newCellSteps,
239
+ sideEffects: sideEffects
240
+ }, !this.isDelete);
241
+ }
242
+ /**
243
+ * StepMap is created based on columnInfo.
244
+ * ColumnInfo is created on constructor and once is applied (the document could have new cells that weren't part of the original set)
245
+ * if isDelete
246
+ * Create range array based on cell info where each range is [cellStep.from, cellStep.from - cellStep.to, 0]
247
+ * else
248
+ * Create range array base on cell info where each range is [cellStep.from, 0, cellStep.content ? cellStep.content.nodeSize : defaultEmptyCellNodeSize]
249
+ *
250
+ * Ranges in ProseMirror are represented by each 3 elements in an array.
251
+ * As [pos, currentSize, newSize, pos2, currentSize2, newSize2] where:
252
+ * pos: Position in the document
253
+ * currentSize: Represent the affected range, this will be pos + currentSize
254
+ * newSize: Represent the new values, pos + newSize
255
+ */
256
+
257
+ }, {
258
+ key: "getMap",
259
+ value: function getMap() {
260
+ var tableMap = this.sideEffectsHandler.getTableMap(this.isDelete);
261
+
262
+ if (tableMap) {
263
+ return tableMap;
264
+ }
265
+
266
+ var ranges = [];
267
+
268
+ var _iterator3 = _createForOfIteratorHelper(this.columnInfo.values()),
269
+ _step3;
270
+
271
+ try {
272
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
273
+ var _ranges;
274
+
275
+ var cellStep = _step3.value;
276
+
277
+ (_ranges = ranges).push.apply(_ranges, _toConsumableArray(getMapFromCellStep(cellStep, this.isDelete)));
278
+ }
279
+ } catch (err) {
280
+ _iterator3.e(err);
281
+ } finally {
282
+ _iterator3.f();
283
+ }
284
+
285
+ ranges = this.sideEffectsHandler.rows.addRowRanges(ranges, this.isDelete); // If no steps, I create am empty stepMap
286
+
287
+ return new StepMap(ranges);
288
+ }
289
+ /**
290
+ * Try to merge this step with another one, to be applied directly
291
+ * after it. Returns the merged step when possible, null if the
292
+ * steps can't be merged.
293
+ */
294
+
295
+ }, {
296
+ key: "merge",
297
+ value: function merge(other) {
298
+ // We cannot merge add column step at the moment
299
+ return null;
300
+ }
301
+ /**
302
+ * Create a JSON-serializeable representation of this step. When
303
+ * defining this for a custom subclass, make sure the result object
304
+ * includes the step type's [JSON id](#transform.Step^jsonID) under
305
+ * the `stepType` property.
306
+ */
307
+
308
+ }, {
309
+ key: "toJSON",
310
+ value: function toJSON() {
311
+ var addColumnStepJson = {
312
+ stepType: ADD_COLUMN_STEP,
313
+ tablePos: this.tablePos,
314
+ cells: Array.from(this.columnInfo.values(), function (cellStep) {
315
+ var cellStepJson = {
316
+ from: cellStep.from,
317
+ to: cellStep.to
318
+ };
319
+
320
+ if (cellStep.mergeWith !== undefined) {
321
+ cellStepJson.mergeWith = cellStep.mergeWith;
322
+ }
323
+
324
+ if (cellStep.newCell !== undefined) {
325
+ cellStepJson.newCell = cellStep.newCell.toJSON();
326
+ }
327
+
328
+ return cellStepJson;
329
+ }),
330
+ isDelete: this.isDelete
331
+ };
332
+ var sideEffectsJSON = this.sideEffectsHandler.toJSON();
333
+
334
+ if (sideEffectsJSON) {
335
+ addColumnStepJson.sideEffects = sideEffectsJSON;
336
+ }
337
+
338
+ return addColumnStepJson;
339
+ }
340
+ /**
341
+ * Deserialize a step from its JSON representation. Will call
342
+ * through to the step class' own implementation of this method.
343
+ */
344
+
345
+ }, {
346
+ key: "applyCellSteps",
347
+ value: function applyCellSteps(tr, tableRect, column, isDelete) {
348
+ var newColumnInfo = new Map();
349
+ var rowsHandler = this.sideEffectsHandler.rows.start(this.isDelete);
350
+ var iter = cellsAtColumn(tableRect, column);
351
+ var next = iter.next(); // Iterate for all the cells in the current document
352
+
353
+ while (!next.done) {
354
+ var cell = next.value;
355
+ var previousCellStep = this.columnInfo.get(cell.from);
356
+ var newCellStep = createCellStep(cell, column, isDelete, previousCellStep); // If is the last cell in the row and doesnt have colspan I need to remove the whole row.
357
+
358
+ var removeRowResult = rowsHandler.handle(tr, tableRect, cell.row, column, cell);
359
+
360
+ if (removeRowResult.handled) {
361
+ next = iter.next(removeRowResult.skipRows);
362
+ continue;
363
+ } // Apply the step, to the pseudo document, get rows to skip, and the cellstep (might be modified, for example, a merge cell that remove the cell instead)
364
+
365
+
366
+ var _applyCellStep = applyCellStep(tr, tableRect, cell, newCellStep, isDelete, column),
367
+ skipRows = _applyCellStep.skipRows,
368
+ cellStep = _applyCellStep.cellStep; // Store the new cell step. This could be an existing one or a new cell.
369
+
370
+
371
+ newColumnInfo.set(newCellStep.from, cellStep);
372
+ next = iter.next(skipRows);
373
+ }
374
+
375
+ rowsHandler.end(tr, tableRect, column);
376
+ return newColumnInfo;
377
+ }
378
+ }], [{
379
+ key: "fromJSON",
380
+ value: function fromJSON(schema, json) {
381
+ // TODO: Add validation. Return null if it is invalid. Check in review if this is necessary
382
+ var cells = json.cells.map(function (cellsJson) {
383
+ var cell = _objectSpread(_objectSpread({}, cellsJson), {}, {
384
+ newCell: cellsJson.newCell ? schema.nodeFromJSON(cellsJson.newCell) : undefined
385
+ });
386
+
387
+ return cell;
388
+ });
389
+ var sideEffects;
390
+
391
+ if (json.sideEffects) {
392
+ sideEffects = SideEffectsHandler.fromJSON(schema, json.sideEffects);
393
+ }
394
+
395
+ return new AddColumnStep(json.tablePos, {
396
+ cells: cells,
397
+ sideEffects: sideEffects
398
+ }, json.isDelete);
399
+ }
400
+ }, {
401
+ key: "create",
402
+ value: function create(doc, tablePos, column) {
403
+ var isDelete = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
404
+ var tableRect = getTableRectFromDoc(doc, tablePos); // By default add column will rely on default behaviour (add empty cell).
405
+ // There is no need to add content
406
+
407
+ var cells = [];
408
+ var iter = cellsAtColumn(tableRect, column);
409
+ var next = iter.next();
410
+
411
+ while (!next.done) {
412
+ var cell = next.value;
413
+ cells.push(createCellStep(cell, column, isDelete));
414
+ var skipRows = 0;
415
+
416
+ if (cell.attrs && cell.attrs.rowspan) {
417
+ skipRows = cell.attrs.rowspan - 1;
418
+ }
419
+
420
+ next = iter.next(skipRows);
421
+ }
422
+
423
+ return new AddColumnStep(tablePos, {
424
+ cells: cells
425
+ }, isDelete);
426
+ }
427
+ }]);
428
+
429
+ return AddColumnStep;
430
+ }(Step);
431
+ Step.jsonID(ADD_COLUMN_STEP, AddColumnStep);