@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,6 @@
1
+ export let SortOrder;
2
+
3
+ (function (SortOrder) {
4
+ SortOrder["ASC"] = "asc";
5
+ SortOrder["DESC"] = "desc";
6
+ })(SortOrder || (SortOrder = {}));
@@ -0,0 +1,41 @@
1
+ import { Slice } from 'prosemirror-model';
2
+ import { ReplaceStep, Step, StepMap, StepResult } from 'prosemirror-transform';
3
+ export const tableSortingStepType = 'atlaskit-table-sorting-ordering';
4
+ export class TableSortStep extends Step {
5
+ constructor(pos, prev, next) {
6
+ super();
7
+ this.prev = prev;
8
+ this.next = next;
9
+ this.pos = pos;
10
+ }
11
+
12
+ invert() {
13
+ return new TableSortStep(this.pos, this.next, this.prev);
14
+ }
15
+
16
+ apply(doc) {
17
+ return StepResult.ok(doc);
18
+ }
19
+
20
+ map() {
21
+ return null;
22
+ }
23
+
24
+ getMap() {
25
+ return new StepMap([0, 0, 0]);
26
+ }
27
+
28
+ toJSON() {
29
+ return {
30
+ stepType: tableSortingStepType
31
+ };
32
+ }
33
+
34
+ static fromJSON() {
35
+ return new ReplaceStep(0, 0, Slice.empty);
36
+ }
37
+
38
+ }
39
+ /** Register this step with Prosemirror */
40
+
41
+ Step.jsonID(tableSortingStepType, TableSortStep);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,204 @@
1
+ import { addColSpan, removeColSpan } from '@atlaskit/editor-tables/utils';
2
+ const EmptyCellNodeSize = 4;
3
+
4
+ function calculateRowsToSkip(attrs) {
5
+ if (attrs && attrs.rowspan) {
6
+ return attrs.rowspan - 1;
7
+ }
8
+
9
+ return 0;
10
+ }
11
+ /**
12
+ * Given a cell step, this function has to do the specific transformation to executed that step.
13
+ * It returns the applied cellStep and rows that needs to skip (because it was already handled).
14
+ * @param tr
15
+ * @param tableRect
16
+ * @param cell
17
+ * @param cellStep
18
+ * @param isDelete
19
+ * @param column
20
+ */
21
+
22
+
23
+ export function applyCellStep(tr, tableRect, cell, cellStep, isDelete, column) {
24
+ // Apply the merge actions,
25
+ if (cellStep.mergeWith !== undefined) {
26
+ let cellNode = tr.doc.nodeAt(tr.mapping.map(cellStep.mergeWith));
27
+ const columns = column - tableRect.map.colCount(cellStep.mergeWith - tableRect.tableStart);
28
+ const cellAttrs = isDelete ? removeColSpan(cellNode.attrs, columns) : addColSpan(cellNode.attrs, columns);
29
+
30
+ if (cellAttrs.colspan > 0) {
31
+ // When colspan is 0 should remove the cell
32
+ tr.setNodeMarkup(tr.mapping.map(cellStep.mergeWith), undefined, cellAttrs);
33
+ return {
34
+ tr,
35
+ skipRows: calculateRowsToSkip(cellAttrs),
36
+ cellStep
37
+ };
38
+ } // When the new colspan is 0, I need to change the operation to a delete operation
39
+ // Update cellStep with the proper data
40
+
41
+
42
+ cellStep.from = cellStep.mergeWith;
43
+ cellStep.to = cellStep.from + cellNode.nodeSize;
44
+ cellStep.mergeWith = undefined;
45
+ }
46
+
47
+ let skipRows = 0; // Modify temporary document
48
+
49
+ if (isDelete) {
50
+ let cellNode = tr.doc.nodeAt(tr.mapping.map(cellStep.from));
51
+ skipRows = calculateRowsToSkip(cellNode.attrs);
52
+ tr.delete(tr.mapping.map(cellStep.from), tr.mapping.map(cellStep.to));
53
+ } else {
54
+ if (cellStep.newCell) {
55
+ tr.insert(tr.mapping.map(cellStep.from), cellStep.newCell);
56
+ skipRows = calculateRowsToSkip(cellStep.newCell.attrs);
57
+ } else {
58
+ tr.insert(tr.mapping.map(cellStep.from), cell.type.createAndFill());
59
+ }
60
+ }
61
+
62
+ return {
63
+ tr,
64
+ skipRows,
65
+ cellStep
66
+ };
67
+ }
68
+ /**
69
+ * Given a cell step, this functions return un StepMap representing this action.
70
+ * [position, oldSize, newSize]
71
+ * @param cellStep
72
+ * @param isDelete
73
+ */
74
+
75
+ export function getMapFromCellStep(cellStep, isDelete) {
76
+ if (cellStep.mergeWith !== undefined) {
77
+ return [cellStep.mergeWith, 1, 1];
78
+ }
79
+
80
+ if (isDelete) {
81
+ return [cellStep.from, cellStep.to - cellStep.from, 0];
82
+ } else {
83
+ if (cellStep.newCell) {
84
+ return [cellStep.from, 0, cellStep.newCell.nodeSize];
85
+ }
86
+
87
+ return [cellStep.from, 0, EmptyCellNodeSize];
88
+ }
89
+ }
90
+ /**
91
+ * Helper to calculate the offset of the inverted cells.
92
+ * When you delete consecutive rows in a single step, the position in the generated document
93
+ * are skipped by the all the changes except your own. (StepMap.map is not valid)
94
+ * @param map
95
+ * @param cellStep
96
+ * @param isDelete
97
+ */
98
+
99
+ function getOffset(map, cellStep, isDelete) {
100
+ if (isDelete) {
101
+ return map.map(cellStep.from) - cellStep.from;
102
+ }
103
+
104
+ const [, oldSize, newSize] = getMapFromCellStep(cellStep, isDelete);
105
+ return map.map(cellStep.from) - cellStep.from - (newSize - oldSize);
106
+ }
107
+ /**
108
+ * Given a cell step, this function invert that step.
109
+ * @param doc
110
+ * @param getTableRectAndColumn
111
+ * @param cellStep
112
+ * @param isDelete
113
+ * @param stepMap
114
+ */
115
+
116
+
117
+ export function invertCellStep(doc, getTableRectAndColumn, cellStep, isDelete, stepMap) {
118
+ /**
119
+ * We need a correct map when a cell is added
120
+ * We need the normal map position minus the size of the cell you added it. Why?
121
+ * Having a table 3x3 and we add a new column at 2 creates this ranges
122
+ * [
123
+ * 10, 0, 4,
124
+ * 20, 0, 4,
125
+ * 30, 0, 4,
126
+ * ]
127
+ * Where:
128
+ * * [10, 20, 30] are the original cell positions where we add the cells
129
+ * * [0, 0, 0] are the old size. We are adding new cells, so it's always zero
130
+ * * [4, 4, 4] are the new size. In this case, we are adding empty cell and has size 4, this will be different for prefill cells.
131
+ * In the document generated the cells that I want to delete (if I invert this step) are [10, 24, 38]
132
+ * this is calculated in the given way
133
+ * * Map the position using this step mapping function, this will return the cell in the next column
134
+ * * Remove the diff (4 - 0 in this case) of the current position.
135
+ * For a delete action this not happen, it will always return the right value
136
+ */
137
+ const offset = getOffset(stepMap, cellStep, isDelete);
138
+ const newCellStepInfo = { ...cellStep,
139
+ // Map the position to position of the generated document
140
+ from: cellStep.from + offset,
141
+ to: cellStep.to + offset
142
+ };
143
+
144
+ if (cellStep.mergeWith !== undefined) {
145
+ newCellStepInfo.mergeWith = cellStep.mergeWith + offset;
146
+ }
147
+
148
+ if (isDelete) {
149
+ // Add the removed cell as the new cell of the inverted step
150
+ const removedCell = doc.nodeAt(cellStep.from);
151
+ newCellStepInfo.newCell = removedCell.copy(removedCell.content); // When we delete a column we can end in a position that doesnt represent the right column.
152
+ // This only happens on merged cell that ends in the deleted column.
153
+ // We need to remap this position to the "next" cell (AKA cellStep.to)
154
+
155
+ const {
156
+ column,
157
+ rect
158
+ } = getTableRectAndColumn();
159
+
160
+ if (column < rect.map.width) {
161
+ const isAtTheEnd = rect.map.colCount(cellStep.from - rect.tableStart) + removedCell.attrs.colspan - 1 === column;
162
+
163
+ if (cellStep.mergeWith !== undefined && isAtTheEnd) {
164
+ newCellStepInfo.mergeWith = newCellStepInfo.from;
165
+ newCellStepInfo.from = newCellStepInfo.to;
166
+ }
167
+ }
168
+ }
169
+
170
+ return newCellStepInfo;
171
+ }
172
+ /**
173
+ * Create a cell step based on the current cell and operation (add/delete)
174
+ * @param cell
175
+ * @param column
176
+ * @param isDelete
177
+ * @param previousCellStep
178
+ */
179
+
180
+ export function createCellStep(cell, column, isDelete, previousCellStep) {
181
+ const newCellStepInfo = {
182
+ from: cell.from,
183
+ to: cell.to
184
+ };
185
+
186
+ if (cell.hasMergedCells) {
187
+ // Check what column has to merge
188
+ if (column !== cell.col || isDelete) {
189
+ newCellStepInfo.mergeWith = cell.from;
190
+ }
191
+ }
192
+
193
+ if (previousCellStep) {
194
+ if (previousCellStep.mergeWith !== undefined) {
195
+ newCellStepInfo.mergeWith = previousCellStep.mergeWith;
196
+ }
197
+
198
+ if (previousCellStep.newCell) {
199
+ newCellStepInfo.newCell = previousCellStep.newCell;
200
+ }
201
+ }
202
+
203
+ return newCellStepInfo;
204
+ }
@@ -0,0 +1,57 @@
1
+ import { columnIsHeader, tableNodeTypes } from '@atlaskit/editor-tables/utils';
2
+ import { getCellIndex, hasMergedColumns, isRootRow } from './table-map';
3
+
4
+ /**
5
+ * Helper to have a consistent way to iterate for all the cells in a column.
6
+ * You can skip rows by passing the rows to skipped in the next arguments.
7
+ * For example: `iter.next(1)` to skip the next row
8
+ * @param rect
9
+ * @param col
10
+ */
11
+ export function* cellsAtColumn(rect, col) {
12
+ const {
13
+ map,
14
+ tableStart,
15
+ table
16
+ } = rect;
17
+ let refColumn = col > 0 ? -1 : 0;
18
+
19
+ if (columnIsHeader(map, table, col + refColumn)) {
20
+ refColumn = col === 0 || col === map.width ? null : 0;
21
+ }
22
+
23
+ for (let row = 0; row < map.height; row++) {
24
+ let index = getCellIndex(rect.map, row, col);
25
+ let pos = map.map[index]; // We only consider to has merged cell to the first cell in a rowspan.
26
+
27
+ const hasMergedCells = hasMergedColumns(rect.map, row, col) && isRootRow(rect.map, row, col); // If this position falls inside a col-spanning cell
28
+
29
+ let type = refColumn == null ? tableNodeTypes(table.type.schema).cell : table.nodeAt(map.map[index + refColumn]).type;
30
+
31
+ if (!hasMergedCells) {
32
+ pos = map.positionAt(row, col, table);
33
+ }
34
+
35
+ let cell = table.nodeAt(pos);
36
+ const cellInfo = {
37
+ from: tableStart + pos,
38
+ to: tableStart + pos,
39
+ row,
40
+ col: hasMergedCells ? map.colCount(pos) : col,
41
+ type,
42
+ hasMergedCells
43
+ };
44
+
45
+ if (cell) {
46
+ cellInfo.attrs = cell.attrs;
47
+ cellInfo.to = tableStart + pos + cell.nodeSize;
48
+ } // We let the consumer to pass the rows that we want to skip
49
+
50
+
51
+ const skippedRows = yield cellInfo;
52
+
53
+ if (skippedRows && skippedRows > 0) {
54
+ row += skippedRows;
55
+ }
56
+ }
57
+ }
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Try to find the right column based on the cell steps in column info..
3
+ * @param columnInfo - Map of cell positions sorted from lower to greather
4
+ * @param rect - map rect
5
+ */
6
+ export function findColumn(columnInfo, rect) {
7
+ /**
8
+ * Algorithm explained
9
+ * Given a table like this:
10
+ * | 5 | 10 |
11
+ * | 15 | 20 |
12
+ * | 25 | 30 | 35 |
13
+ * Represented by a table map like this:
14
+ * rect.map = [5, 10, 10,
15
+ * 15, 15, 20,
16
+ * 25, 30, 35]
17
+ * And a have this inputs:
18
+ * columnInfo[].from = [10, 15, 30]
19
+ *
20
+ * Algorithm:
21
+ * * Initial state
22
+ * start = 0;
23
+ * end = 2 (rect.width - 1 === 3 - 1)
24
+ * * Iterate until find first cell position
25
+ * start = 1
26
+ * end = 2 (min(start column + colspan - 1, start column + end column))
27
+ * * Iterate until find second cell position
28
+ * start = 1
29
+ * end = 1
30
+ * * Start === end return 1
31
+ */
32
+ // Initial range (start and end column) to search for each row
33
+ let [start, end] = [0, rect.map.width - 1];
34
+ const iter = columnInfo.values();
35
+ let next = iter.next(); // Iterate for each row
36
+
37
+ for (let row = 0; row < rect.map.height; row++) {
38
+ if (next.done) {
39
+ break;
40
+ } // Iterate for the column. Starting with the current start range
41
+
42
+
43
+ for (let col = start; col <= end; col++) {
44
+ const i = row * rect.map.width + col;
45
+ const cell = rect.map.map[i];
46
+ const cellInfo = next.value.from - rect.tableStart; // When cell is found update range with the new values
47
+
48
+ if (cell === cellInfo) {
49
+ start = col; // Start column will be the current column
50
+ // Try to find the end column. End column will be different that start when has merged cells.
51
+
52
+ const endIndex = end - start + i;
53
+
54
+ for (let j = i; j <= endIndex; j++) {
55
+ if (rect.map.map[j] !== cell) {
56
+ break;
57
+ } // merged columns
58
+
59
+
60
+ end = start + j - i; // Update the end column with the new position
61
+ }
62
+
63
+ if (start === end) {
64
+ // We found the right column only when start and end columns are the same.
65
+ return start;
66
+ }
67
+
68
+ next = iter.next();
69
+ break;
70
+ } // Sometimes I want to find a column at the end of the table (It doesn't exist, but we can add a new cell there).
71
+ // This is represented by the end position of the last cell in the column.
72
+ // In this case return, table width
73
+
74
+
75
+ if (col === rect.map.width - 1) {
76
+ const cellNode = rect.table.nodeAt(cell);
77
+
78
+ if (cell + cellNode.nodeSize === cellInfo) {
79
+ return rect.map.width;
80
+ }
81
+ }
82
+ }
83
+ }
84
+
85
+ return null;
86
+ }
@@ -0,0 +1,30 @@
1
+ import { TableMap } from '@atlaskit/editor-tables/table-map';
2
+ /**
3
+ * Util to get the table rect from the docs
4
+ * @param doc
5
+ * @param tablePos
6
+ */
7
+
8
+ export function getTableRectFromDoc(doc, tablePos) {
9
+ const table = doc.nodeAt(tablePos); // Check for table existence
10
+
11
+ if (!table || table.type.name !== 'table') {
12
+ throw new Error(`No table at position "${tablePos}".`);
13
+ } // Create transform base on the doc
14
+
15
+
16
+ const map = TableMap.get(table);
17
+ const $table = doc.resolve(tablePos); // Nested tables start position might differ from the original position
18
+
19
+ const start = $table.start($table.depth + 1);
20
+ return {
21
+ map,
22
+ table: table,
23
+ tableStart: start,
24
+ // Default to zero
25
+ bottom: 0,
26
+ left: 0,
27
+ right: 0,
28
+ top: 0
29
+ };
30
+ }
@@ -0,0 +1,297 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import { hasMergedColumns } from '../table-map';
3
+
4
+ function mergedRanges(first, second) {
5
+ const newRanges = [];
6
+ const firstLength = first.length;
7
+ const secondLength = second.length;
8
+ let i = 0;
9
+ let j = 0;
10
+
11
+ while (i < firstLength && j < secondLength) {
12
+ if (first[i] < second[j]) {
13
+ newRanges.push(first[i], first[i + 1], first[i + 2]);
14
+ i += 3;
15
+ } else {
16
+ newRanges.push(second[j], second[j + 1], second[j + 2]);
17
+ j += 3;
18
+ }
19
+ }
20
+
21
+ if (i < firstLength) {
22
+ newRanges.push(...first.slice(i));
23
+ }
24
+
25
+ if (j < secondLength) {
26
+ newRanges.push(...second.slice(i));
27
+ }
28
+
29
+ return newRanges;
30
+ }
31
+
32
+ function increaseRowSpan(tr, rect, row) {
33
+ const {
34
+ map,
35
+ tableStart
36
+ } = rect;
37
+
38
+ for (let col = 0; col < map.width; col++) {
39
+ let index = row * map.width + col;
40
+ let pos = map.map[index];
41
+ const mappedPos = tr.mapping.map(pos + tableStart);
42
+ let attrs = tr.doc.nodeAt(mappedPos).attrs;
43
+ tr.setNodeMarkup(mappedPos, undefined, { ...attrs,
44
+ rowspan: attrs.rowspan + 1
45
+ });
46
+ col += attrs.colspan - 1;
47
+ }
48
+ }
49
+
50
+ function decreaseRowspan(tr, rect, row, colToRemove) {
51
+ let skipRows = 0;
52
+ const {
53
+ map,
54
+ table,
55
+ tableStart
56
+ } = rect;
57
+
58
+ for (let col = 0; col < map.width; col++) {
59
+ let index = row * map.width + col;
60
+ let pos = map.map[index];
61
+
62
+ if (row > 0 && pos === map.map[index - map.width]) {
63
+ // If this cell starts in the row above, simply reduce its rowspan
64
+ const mappedPos = tr.mapping.map(pos + tableStart);
65
+ let attrs = tr.doc.nodeAt(mappedPos).attrs;
66
+ tr.setNodeMarkup(mappedPos, undefined, { ...attrs,
67
+ rowspan: attrs.rowspan - 1
68
+ });
69
+ col += attrs.colspan - 1;
70
+ } else if (col === colToRemove) {
71
+ skipRows = table.nodeAt(pos).attrs.rowspan - 1;
72
+ }
73
+ }
74
+
75
+ return skipRows;
76
+ }
77
+
78
+ function isLastCellInRow(rect, row, col) {
79
+ const rowNode = rect.table.child(row);
80
+
81
+ if (!rowNode) {
82
+ return false;
83
+ }
84
+
85
+ return rowNode.childCount === 1 && !hasMergedColumns(rect.map, row, col);
86
+ }
87
+
88
+ function removeRowWithLastCell(tr, rect, row, _col) {
89
+ // Get row pos
90
+ let from = rect.tableStart;
91
+
92
+ for (let i = 0; i < row; i++) {
93
+ from += rect.table.child(i).nodeSize;
94
+ }
95
+
96
+ const rowNode = rect.table.child(row);
97
+ let to = from + rowNode.nodeSize; // Create sideEffect and delete the row
98
+ // We store original row position before modifications
99
+
100
+ tr.delete(tr.mapping.map(from), tr.mapping.map(to)); // Change rowspan of all cells except current col and get the rows to skip
101
+
102
+ const skipRows = decreaseRowspan(tr, rect, row, _col);
103
+ return {
104
+ skipRows,
105
+ row: {
106
+ from,
107
+ to,
108
+ rowNode: rowNode.copy(rowNode.content)
109
+ }
110
+ };
111
+ }
112
+
113
+ function addRow(tr, rect, prevRow, rowSideEffect) {
114
+ const cellNode = rowSideEffect.rowNode.child(0);
115
+ tr.insert(tr.mapping.map(rowSideEffect.from), rowSideEffect.rowNode);
116
+ increaseRowSpan(tr, rect, prevRow);
117
+ return cellNode.attrs.rowspan - 1;
118
+ }
119
+
120
+ export class RowsSideEffectHandler {
121
+ constructor(rowsSideEffect) {
122
+ _defineProperty(this, "deleteHandler", () => {
123
+ const newRows = [];
124
+ return {
125
+ handle: (tr, rect, row, col, cell) => {
126
+ if (!isLastCellInRow(rect, row, col)) {
127
+ return {
128
+ handled: false
129
+ };
130
+ }
131
+
132
+ const {
133
+ row: rowSideEffect,
134
+ skipRows
135
+ } = removeRowWithLastCell(tr, rect, row, col);
136
+ newRows.push(rowSideEffect);
137
+ return {
138
+ handled: true,
139
+ skipRows: skipRows
140
+ };
141
+ },
142
+ end: () => {
143
+ if (newRows.length > 0) {
144
+ this.rows = newRows;
145
+ } else {
146
+ this.rows = undefined;
147
+ }
148
+ }
149
+ };
150
+ });
151
+
152
+ _defineProperty(this, "addHandler", () => {
153
+ let lastCellFrom = 0;
154
+ let i = 0;
155
+ return {
156
+ handle: (tr, rect, row, col, cell) => {
157
+ // // If not sideEffects stored return;
158
+ if (!this.rows || i >= this.rows.length) {
159
+ return {
160
+ handled: false
161
+ };
162
+ } // Next row to add;
163
+
164
+
165
+ let skipRows;
166
+ let nextRow;
167
+
168
+ while ((nextRow = this.rows[i]) && nextRow.from > lastCellFrom && nextRow.from < cell.from) {
169
+ // I am in between of the previous and next row in the table;
170
+ skipRows = addRow(tr, rect, row - 1, nextRow);
171
+ i++;
172
+ }
173
+
174
+ lastCellFrom = cell.from;
175
+
176
+ if (!skipRows || skipRows === 0) {
177
+ return {
178
+ handled: false
179
+ };
180
+ }
181
+
182
+ return {
183
+ handled: true,
184
+ skipRows: skipRows - 1
185
+ };
186
+ },
187
+ end: (tr, rect, col) => {
188
+ if (!this.rows || i >= this.rows.length) {
189
+ return;
190
+ } // Add rows at the end of the table
191
+
192
+
193
+ let nextRow;
194
+
195
+ while (nextRow = this.rows[i]) {
196
+ addRow(tr, rect, rect.map.height - 1, nextRow);
197
+ i++;
198
+ }
199
+ }
200
+ };
201
+ });
202
+
203
+ this.rows = rowsSideEffect;
204
+ }
205
+
206
+ start(isDelete) {
207
+ if (isDelete) {
208
+ return this.deleteHandler();
209
+ }
210
+
211
+ return this.addHandler();
212
+ }
213
+
214
+ addRowRanges(ranges, isDelete) {
215
+ if (!this.rows) {
216
+ return ranges;
217
+ }
218
+
219
+ const rowRanges = [];
220
+
221
+ for (const row of this.rows) {
222
+ const {
223
+ from,
224
+ to
225
+ } = row;
226
+
227
+ if (isDelete) {
228
+ rowRanges.push(from, to - from, 0);
229
+ } else {
230
+ rowRanges.push(from, 0, to - from);
231
+ }
232
+ } // Merged ranges
233
+
234
+
235
+ return mergedRanges(ranges, rowRanges);
236
+ }
237
+
238
+ map(mapping) {
239
+ return [];
240
+ }
241
+
242
+ invert(originalDoc, isDelete, map) {
243
+ if (!this.rows) {
244
+ return;
245
+ }
246
+
247
+ const invertedRows = [];
248
+
249
+ for (const row of this.rows) {
250
+ if (isDelete) {
251
+ // Moving from delete to add keep the inverted rows + offset
252
+ let offset = map.map(row.from) - row.from;
253
+ invertedRows.push({ ...row,
254
+ from: row.from + offset,
255
+ to: row.from + offset
256
+ });
257
+ } else {// Moving from add to delete keep
258
+ // TODO: I think we need to add the respective cell into the cellSteps...... not sure....
259
+ }
260
+ }
261
+
262
+ return invertedRows;
263
+ }
264
+
265
+ toJSON() {
266
+ if (!this.rows) {
267
+ return;
268
+ }
269
+
270
+ const rowsInJson = [];
271
+
272
+ for (const row of this.rows) {
273
+ rowsInJson.push({
274
+ from: row.from,
275
+ to: row.to,
276
+ rowNode: row.rowNode.toJSON()
277
+ });
278
+ }
279
+
280
+ return rowsInJson;
281
+ }
282
+
283
+ static fromJSON(schema, json) {
284
+ const rowSideEffects = [];
285
+
286
+ for (const row of json) {
287
+ rowSideEffects.push({
288
+ from: row.from,
289
+ to: row.to,
290
+ rowNode: schema.nodeFromJSON(row.rowNode)
291
+ });
292
+ }
293
+
294
+ return rowSideEffects;
295
+ }
296
+
297
+ }