@atlaskit/editor-core 185.16.1 → 185.16.5

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 (389) hide show
  1. package/.eslintrc.js +1 -0
  2. package/CHANGELOG.md +14 -0
  3. package/dist/cjs/i18n/cs.js +0 -35
  4. package/dist/cjs/i18n/da.js +0 -35
  5. package/dist/cjs/i18n/de.js +0 -35
  6. package/dist/cjs/i18n/en.js +0 -35
  7. package/dist/cjs/i18n/en_GB.js +0 -35
  8. package/dist/cjs/i18n/en_ZZ.js +0 -35
  9. package/dist/cjs/i18n/es.js +1 -35
  10. package/dist/cjs/i18n/fi.js +0 -35
  11. package/dist/cjs/i18n/fr.js +1 -35
  12. package/dist/cjs/i18n/hu.js +1 -35
  13. package/dist/cjs/i18n/it.js +1 -35
  14. package/dist/cjs/i18n/ja.js +1 -35
  15. package/dist/cjs/i18n/ko.js +0 -35
  16. package/dist/cjs/i18n/nb.js +1 -35
  17. package/dist/cjs/i18n/nl.js +1 -35
  18. package/dist/cjs/i18n/pl.js +1 -35
  19. package/dist/cjs/i18n/pt_BR.js +1 -35
  20. package/dist/cjs/i18n/ru.js +1 -35
  21. package/dist/cjs/i18n/sv.js +0 -35
  22. package/dist/cjs/i18n/th.js +0 -35
  23. package/dist/cjs/i18n/tr.js +1 -35
  24. package/dist/cjs/i18n/uk.js +1 -35
  25. package/dist/cjs/i18n/vi.js +0 -35
  26. package/dist/cjs/i18n/zh.js +1 -35
  27. package/dist/cjs/i18n/zh_TW.js +1 -35
  28. package/dist/cjs/labs/next/presets/mobile.js +1 -1
  29. package/dist/cjs/labs/next/presets/universal.js +2 -2
  30. package/dist/cjs/plugins/deprecated-card/doc.js +111 -0
  31. package/dist/cjs/plugins/deprecated-hyperlink/commands.js +1 -1
  32. package/dist/cjs/plugins/index.js +0 -7
  33. package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +14 -25
  34. package/dist/cjs/plugins/media/ui/ResizableMediaSingle/index.js +39 -27
  35. package/dist/cjs/plugins/text-formatting/commands/clear-formatting.js +5 -6
  36. package/dist/cjs/plugins/text-formatting/index.js +6 -2
  37. package/dist/cjs/plugins/text-formatting/pm-plugins/clear-formatting-keymap.js +2 -2
  38. package/dist/cjs/plugins/text-formatting/ui/Toolbar/hooks/clear-formatting-icon.js +6 -3
  39. package/dist/cjs/plugins/text-formatting/ui/Toolbar/index.js +8 -4
  40. package/dist/cjs/version-wrapper.js +1 -1
  41. package/dist/cjs/version.json +1 -1
  42. package/dist/es2019/i18n/cs.js +0 -35
  43. package/dist/es2019/i18n/da.js +0 -35
  44. package/dist/es2019/i18n/de.js +0 -35
  45. package/dist/es2019/i18n/en.js +0 -35
  46. package/dist/es2019/i18n/en_GB.js +0 -35
  47. package/dist/es2019/i18n/en_ZZ.js +0 -35
  48. package/dist/es2019/i18n/es.js +1 -35
  49. package/dist/es2019/i18n/fi.js +0 -35
  50. package/dist/es2019/i18n/fr.js +1 -35
  51. package/dist/es2019/i18n/hu.js +1 -35
  52. package/dist/es2019/i18n/it.js +1 -35
  53. package/dist/es2019/i18n/ja.js +1 -35
  54. package/dist/es2019/i18n/ko.js +0 -35
  55. package/dist/es2019/i18n/nb.js +1 -35
  56. package/dist/es2019/i18n/nl.js +1 -35
  57. package/dist/es2019/i18n/pl.js +1 -35
  58. package/dist/es2019/i18n/pt_BR.js +1 -35
  59. package/dist/es2019/i18n/ru.js +1 -35
  60. package/dist/es2019/i18n/sv.js +0 -35
  61. package/dist/es2019/i18n/th.js +0 -35
  62. package/dist/es2019/i18n/tr.js +1 -35
  63. package/dist/es2019/i18n/uk.js +1 -35
  64. package/dist/es2019/i18n/vi.js +0 -35
  65. package/dist/es2019/i18n/zh.js +1 -35
  66. package/dist/es2019/i18n/zh_TW.js +1 -35
  67. package/dist/es2019/labs/next/presets/mobile.js +1 -1
  68. package/dist/es2019/labs/next/presets/universal.js +1 -1
  69. package/dist/es2019/plugins/deprecated-card/doc.js +97 -0
  70. package/dist/es2019/plugins/deprecated-hyperlink/commands.js +1 -1
  71. package/dist/es2019/plugins/index.js +0 -1
  72. package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +2 -14
  73. package/dist/es2019/plugins/media/ui/ResizableMediaSingle/index.js +13 -0
  74. package/dist/es2019/plugins/text-formatting/commands/clear-formatting.js +5 -6
  75. package/dist/es2019/plugins/text-formatting/index.js +8 -3
  76. package/dist/es2019/plugins/text-formatting/pm-plugins/clear-formatting-keymap.js +2 -2
  77. package/dist/es2019/plugins/text-formatting/ui/Toolbar/hooks/clear-formatting-icon.js +5 -4
  78. package/dist/es2019/plugins/text-formatting/ui/Toolbar/index.js +8 -4
  79. package/dist/es2019/version-wrapper.js +1 -1
  80. package/dist/es2019/version.json +1 -1
  81. package/dist/esm/i18n/cs.js +0 -35
  82. package/dist/esm/i18n/da.js +0 -35
  83. package/dist/esm/i18n/de.js +0 -35
  84. package/dist/esm/i18n/en.js +0 -35
  85. package/dist/esm/i18n/en_GB.js +0 -35
  86. package/dist/esm/i18n/en_ZZ.js +0 -35
  87. package/dist/esm/i18n/es.js +1 -35
  88. package/dist/esm/i18n/fi.js +0 -35
  89. package/dist/esm/i18n/fr.js +1 -35
  90. package/dist/esm/i18n/hu.js +1 -35
  91. package/dist/esm/i18n/it.js +1 -35
  92. package/dist/esm/i18n/ja.js +1 -35
  93. package/dist/esm/i18n/ko.js +0 -35
  94. package/dist/esm/i18n/nb.js +1 -35
  95. package/dist/esm/i18n/nl.js +1 -35
  96. package/dist/esm/i18n/pl.js +1 -35
  97. package/dist/esm/i18n/pt_BR.js +1 -35
  98. package/dist/esm/i18n/ru.js +1 -35
  99. package/dist/esm/i18n/sv.js +0 -35
  100. package/dist/esm/i18n/th.js +0 -35
  101. package/dist/esm/i18n/tr.js +1 -35
  102. package/dist/esm/i18n/uk.js +1 -35
  103. package/dist/esm/i18n/vi.js +0 -35
  104. package/dist/esm/i18n/zh.js +1 -35
  105. package/dist/esm/i18n/zh_TW.js +1 -35
  106. package/dist/esm/labs/next/presets/mobile.js +1 -1
  107. package/dist/esm/labs/next/presets/universal.js +1 -1
  108. package/dist/esm/plugins/deprecated-card/doc.js +105 -0
  109. package/dist/esm/plugins/deprecated-hyperlink/commands.js +1 -1
  110. package/dist/esm/plugins/index.js +0 -1
  111. package/dist/esm/plugins/media/nodeviews/mediaSingle.js +14 -25
  112. package/dist/esm/plugins/media/ui/ResizableMediaSingle/index.js +39 -27
  113. package/dist/esm/plugins/text-formatting/commands/clear-formatting.js +5 -6
  114. package/dist/esm/plugins/text-formatting/index.js +6 -2
  115. package/dist/esm/plugins/text-formatting/pm-plugins/clear-formatting-keymap.js +2 -2
  116. package/dist/esm/plugins/text-formatting/ui/Toolbar/hooks/clear-formatting-icon.js +7 -4
  117. package/dist/esm/plugins/text-formatting/ui/Toolbar/index.js +8 -4
  118. package/dist/esm/version-wrapper.js +1 -1
  119. package/dist/esm/version.json +1 -1
  120. package/dist/types/i18n/cs.d.ts +0 -35
  121. package/dist/types/i18n/da.d.ts +0 -35
  122. package/dist/types/i18n/de.d.ts +0 -35
  123. package/dist/types/i18n/en.d.ts +0 -35
  124. package/dist/types/i18n/en_GB.d.ts +0 -35
  125. package/dist/types/i18n/en_ZZ.d.ts +0 -35
  126. package/dist/types/i18n/es.d.ts +1 -35
  127. package/dist/types/i18n/fi.d.ts +0 -35
  128. package/dist/types/i18n/fr.d.ts +1 -35
  129. package/dist/types/i18n/hu.d.ts +1 -35
  130. package/dist/types/i18n/it.d.ts +1 -35
  131. package/dist/types/i18n/ja.d.ts +1 -35
  132. package/dist/types/i18n/ko.d.ts +0 -35
  133. package/dist/types/i18n/nb.d.ts +1 -35
  134. package/dist/types/i18n/nl.d.ts +1 -35
  135. package/dist/types/i18n/pl.d.ts +1 -35
  136. package/dist/types/i18n/pt_BR.d.ts +1 -35
  137. package/dist/types/i18n/ru.d.ts +1 -35
  138. package/dist/types/i18n/sv.d.ts +0 -35
  139. package/dist/types/i18n/th.d.ts +0 -35
  140. package/dist/types/i18n/tr.d.ts +1 -35
  141. package/dist/types/i18n/uk.d.ts +1 -35
  142. package/dist/types/i18n/vi.d.ts +0 -35
  143. package/dist/types/i18n/zh.d.ts +1 -35
  144. package/dist/types/i18n/zh_TW.d.ts +1 -35
  145. package/dist/types/labs/next/presets/cxhtml.d.ts +58 -0
  146. package/dist/types/labs/next/presets/default.d.ts +116 -0
  147. package/dist/types/labs/next/presets/mobile.d.ts +58 -0
  148. package/dist/types/plugins/deprecated-card/doc.d.ts +20 -0
  149. package/dist/types/plugins/index.d.ts +0 -1
  150. package/dist/types/plugins/media/nodeviews/mediaSingle.d.ts +0 -1
  151. package/dist/types/plugins/media/ui/ResizableMediaSingle/index.d.ts +1 -0
  152. package/dist/types/plugins/media/ui/ResizableMediaSingle/types.d.ts +3 -2
  153. package/dist/types/plugins/paste/index.d.ts +1 -1
  154. package/dist/types/plugins/text-formatting/commands/clear-formatting.d.ts +3 -3
  155. package/dist/types/plugins/text-formatting/index.d.ts +3 -1
  156. package/dist/types/plugins/text-formatting/pm-plugins/clear-formatting-keymap.d.ts +2 -1
  157. package/dist/types/plugins/text-formatting/ui/Toolbar/hooks/clear-formatting-icon.d.ts +6 -1
  158. package/dist/types/plugins/text-formatting/ui/Toolbar/index.d.ts +2 -0
  159. package/dist/types-ts4.5/i18n/cs.d.ts +0 -35
  160. package/dist/types-ts4.5/i18n/da.d.ts +0 -35
  161. package/dist/types-ts4.5/i18n/de.d.ts +0 -35
  162. package/dist/types-ts4.5/i18n/en.d.ts +0 -35
  163. package/dist/types-ts4.5/i18n/en_GB.d.ts +0 -35
  164. package/dist/types-ts4.5/i18n/en_ZZ.d.ts +0 -35
  165. package/dist/types-ts4.5/i18n/es.d.ts +1 -35
  166. package/dist/types-ts4.5/i18n/fi.d.ts +0 -35
  167. package/dist/types-ts4.5/i18n/fr.d.ts +1 -35
  168. package/dist/types-ts4.5/i18n/hu.d.ts +1 -35
  169. package/dist/types-ts4.5/i18n/it.d.ts +1 -35
  170. package/dist/types-ts4.5/i18n/ja.d.ts +1 -35
  171. package/dist/types-ts4.5/i18n/ko.d.ts +0 -35
  172. package/dist/types-ts4.5/i18n/nb.d.ts +1 -35
  173. package/dist/types-ts4.5/i18n/nl.d.ts +1 -35
  174. package/dist/types-ts4.5/i18n/pl.d.ts +1 -35
  175. package/dist/types-ts4.5/i18n/pt_BR.d.ts +1 -35
  176. package/dist/types-ts4.5/i18n/ru.d.ts +1 -35
  177. package/dist/types-ts4.5/i18n/sv.d.ts +0 -35
  178. package/dist/types-ts4.5/i18n/th.d.ts +0 -35
  179. package/dist/types-ts4.5/i18n/tr.d.ts +1 -35
  180. package/dist/types-ts4.5/i18n/uk.d.ts +1 -35
  181. package/dist/types-ts4.5/i18n/vi.d.ts +0 -35
  182. package/dist/types-ts4.5/i18n/zh.d.ts +1 -35
  183. package/dist/types-ts4.5/i18n/zh_TW.d.ts +1 -35
  184. package/dist/types-ts4.5/labs/next/presets/cxhtml.d.ts +70 -0
  185. package/dist/types-ts4.5/labs/next/presets/default.d.ts +140 -0
  186. package/dist/types-ts4.5/labs/next/presets/mobile.d.ts +70 -0
  187. package/dist/types-ts4.5/plugins/deprecated-card/doc.d.ts +20 -0
  188. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  189. package/dist/types-ts4.5/plugins/media/nodeviews/mediaSingle.d.ts +0 -1
  190. package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/index.d.ts +1 -0
  191. package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/types.d.ts +3 -2
  192. package/dist/types-ts4.5/plugins/paste/index.d.ts +1 -1
  193. package/dist/types-ts4.5/plugins/text-formatting/commands/clear-formatting.d.ts +3 -3
  194. package/dist/types-ts4.5/plugins/text-formatting/index.d.ts +5 -1
  195. package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/clear-formatting-keymap.d.ts +2 -1
  196. package/dist/types-ts4.5/plugins/text-formatting/ui/Toolbar/hooks/clear-formatting-icon.d.ts +6 -1
  197. package/dist/types-ts4.5/plugins/text-formatting/ui/Toolbar/index.d.ts +2 -0
  198. package/package.json +6 -5
  199. package/tmp/api-report-tmp.d.ts +2307 -0
  200. package/dist/cjs/plugins/card/index.js +0 -139
  201. package/dist/cjs/plugins/card/messages.js +0 -20
  202. package/dist/cjs/plugins/card/nodeviews/blockCard.js +0 -163
  203. package/dist/cjs/plugins/card/nodeviews/datasource.js +0 -172
  204. package/dist/cjs/plugins/card/nodeviews/embedCard.js +0 -396
  205. package/dist/cjs/plugins/card/nodeviews/genericCard.js +0 -118
  206. package/dist/cjs/plugins/card/nodeviews/inlineCard.js +0 -131
  207. package/dist/cjs/plugins/card/pm-plugins/actions.js +0 -122
  208. package/dist/cjs/plugins/card/pm-plugins/analytics/create-analytics-queue.js +0 -48
  209. package/dist/cjs/plugins/card/pm-plugins/analytics/events-from-tr.js +0 -353
  210. package/dist/cjs/plugins/card/pm-plugins/analytics/index.js +0 -19
  211. package/dist/cjs/plugins/card/pm-plugins/analytics/types.js +0 -5
  212. package/dist/cjs/plugins/card/pm-plugins/analytics/utils.js +0 -178
  213. package/dist/cjs/plugins/card/pm-plugins/doc.js +0 -478
  214. package/dist/cjs/plugins/card/pm-plugins/keymap.js +0 -64
  215. package/dist/cjs/plugins/card/pm-plugins/main.js +0 -212
  216. package/dist/cjs/plugins/card/pm-plugins/mountHyperlink.js +0 -47
  217. package/dist/cjs/plugins/card/pm-plugins/plugin-key.js +0 -9
  218. package/dist/cjs/plugins/card/pm-plugins/reducers.js +0 -111
  219. package/dist/cjs/plugins/card/pm-plugins/shouldReplaceLink.js +0 -35
  220. package/dist/cjs/plugins/card/pm-plugins/util/resolve.js +0 -58
  221. package/dist/cjs/plugins/card/pm-plugins/util/state.js +0 -49
  222. package/dist/cjs/plugins/card/toolbar.js +0 -364
  223. package/dist/cjs/plugins/card/types.js +0 -5
  224. package/dist/cjs/plugins/card/ui/DatasourceModal/ModalWithState.js +0 -25
  225. package/dist/cjs/plugins/card/ui/DatasourceModal/index.js +0 -60
  226. package/dist/cjs/plugins/card/ui/EditLinkToolbar.js +0 -256
  227. package/dist/cjs/plugins/card/ui/EditorSmartCardEvents.js +0 -21
  228. package/dist/cjs/plugins/card/ui/EditorSmartCardEventsNext.js +0 -213
  229. package/dist/cjs/plugins/card/ui/HyperlinkToolbarAppearance.js +0 -173
  230. package/dist/cjs/plugins/card/ui/LayoutButton/index.js +0 -113
  231. package/dist/cjs/plugins/card/ui/LayoutButton/styled.js +0 -17
  232. package/dist/cjs/plugins/card/ui/LayoutButton/types.js +0 -5
  233. package/dist/cjs/plugins/card/ui/LayoutButton/utils.js +0 -19
  234. package/dist/cjs/plugins/card/ui/LinkToolbarAppearance.js +0 -151
  235. package/dist/cjs/plugins/card/ui/ResizableEmbedCard.js +0 -360
  236. package/dist/cjs/plugins/card/ui/SmallerEditIcon.js +0 -20
  237. package/dist/cjs/plugins/card/utils.js +0 -60
  238. package/dist/es2019/plugins/card/index.js +0 -131
  239. package/dist/es2019/plugins/card/messages.js +0 -13
  240. package/dist/es2019/plugins/card/nodeviews/blockCard.js +0 -130
  241. package/dist/es2019/plugins/card/nodeviews/datasource.js +0 -136
  242. package/dist/es2019/plugins/card/nodeviews/embedCard.js +0 -368
  243. package/dist/es2019/plugins/card/nodeviews/genericCard.js +0 -92
  244. package/dist/es2019/plugins/card/nodeviews/inlineCard.js +0 -112
  245. package/dist/es2019/plugins/card/pm-plugins/actions.js +0 -57
  246. package/dist/es2019/plugins/card/pm-plugins/analytics/create-analytics-queue.js +0 -38
  247. package/dist/es2019/plugins/card/pm-plugins/analytics/events-from-tr.js +0 -333
  248. package/dist/es2019/plugins/card/pm-plugins/analytics/index.js +0 -2
  249. package/dist/es2019/plugins/card/pm-plugins/analytics/types.js +0 -1
  250. package/dist/es2019/plugins/card/pm-plugins/analytics/utils.js +0 -160
  251. package/dist/es2019/plugins/card/pm-plugins/doc.js +0 -451
  252. package/dist/es2019/plugins/card/pm-plugins/keymap.js +0 -59
  253. package/dist/es2019/plugins/card/pm-plugins/main.js +0 -208
  254. package/dist/es2019/plugins/card/pm-plugins/mountHyperlink.js +0 -37
  255. package/dist/es2019/plugins/card/pm-plugins/plugin-key.js +0 -2
  256. package/dist/es2019/plugins/card/pm-plugins/reducers.js +0 -110
  257. package/dist/es2019/plugins/card/pm-plugins/shouldReplaceLink.js +0 -25
  258. package/dist/es2019/plugins/card/pm-plugins/util/resolve.js +0 -48
  259. package/dist/es2019/plugins/card/pm-plugins/util/state.js +0 -26
  260. package/dist/es2019/plugins/card/toolbar.js +0 -362
  261. package/dist/es2019/plugins/card/types.js +0 -1
  262. package/dist/es2019/plugins/card/ui/DatasourceModal/ModalWithState.js +0 -19
  263. package/dist/es2019/plugins/card/ui/DatasourceModal/index.js +0 -48
  264. package/dist/es2019/plugins/card/ui/EditLinkToolbar.js +0 -225
  265. package/dist/es2019/plugins/card/ui/EditorSmartCardEvents.js +0 -15
  266. package/dist/es2019/plugins/card/ui/EditorSmartCardEventsNext.js +0 -198
  267. package/dist/es2019/plugins/card/ui/HyperlinkToolbarAppearance.js +0 -86
  268. package/dist/es2019/plugins/card/ui/LayoutButton/index.js +0 -106
  269. package/dist/es2019/plugins/card/ui/LayoutButton/styled.js +0 -10
  270. package/dist/es2019/plugins/card/ui/LayoutButton/types.js +0 -1
  271. package/dist/es2019/plugins/card/ui/LayoutButton/utils.js +0 -15
  272. package/dist/es2019/plugins/card/ui/LinkToolbarAppearance.js +0 -117
  273. package/dist/es2019/plugins/card/ui/ResizableEmbedCard.js +0 -332
  274. package/dist/es2019/plugins/card/ui/SmallerEditIcon.js +0 -11
  275. package/dist/es2019/plugins/card/utils.js +0 -46
  276. package/dist/esm/plugins/card/index.js +0 -132
  277. package/dist/esm/plugins/card/messages.js +0 -13
  278. package/dist/esm/plugins/card/nodeviews/blockCard.js +0 -155
  279. package/dist/esm/plugins/card/nodeviews/datasource.js +0 -164
  280. package/dist/esm/plugins/card/nodeviews/embedCard.js +0 -387
  281. package/dist/esm/plugins/card/nodeviews/genericCard.js +0 -111
  282. package/dist/esm/plugins/card/nodeviews/inlineCard.js +0 -123
  283. package/dist/esm/plugins/card/pm-plugins/actions.js +0 -102
  284. package/dist/esm/plugins/card/pm-plugins/analytics/create-analytics-queue.js +0 -41
  285. package/dist/esm/plugins/card/pm-plugins/analytics/events-from-tr.js +0 -344
  286. package/dist/esm/plugins/card/pm-plugins/analytics/index.js +0 -2
  287. package/dist/esm/plugins/card/pm-plugins/analytics/types.js +0 -1
  288. package/dist/esm/plugins/card/pm-plugins/analytics/utils.js +0 -160
  289. package/dist/esm/plugins/card/pm-plugins/doc.js +0 -460
  290. package/dist/esm/plugins/card/pm-plugins/keymap.js +0 -58
  291. package/dist/esm/plugins/card/pm-plugins/main.js +0 -199
  292. package/dist/esm/plugins/card/pm-plugins/mountHyperlink.js +0 -39
  293. package/dist/esm/plugins/card/pm-plugins/plugin-key.js +0 -2
  294. package/dist/esm/plugins/card/pm-plugins/reducers.js +0 -103
  295. package/dist/esm/plugins/card/pm-plugins/shouldReplaceLink.js +0 -29
  296. package/dist/esm/plugins/card/pm-plugins/util/resolve.js +0 -50
  297. package/dist/esm/plugins/card/pm-plugins/util/state.js +0 -40
  298. package/dist/esm/plugins/card/toolbar.js +0 -353
  299. package/dist/esm/plugins/card/types.js +0 -1
  300. package/dist/esm/plugins/card/ui/DatasourceModal/ModalWithState.js +0 -17
  301. package/dist/esm/plugins/card/ui/DatasourceModal/index.js +0 -49
  302. package/dist/esm/plugins/card/ui/EditLinkToolbar.js +0 -243
  303. package/dist/esm/plugins/card/ui/EditorSmartCardEvents.js +0 -14
  304. package/dist/esm/plugins/card/ui/EditorSmartCardEventsNext.js +0 -202
  305. package/dist/esm/plugins/card/ui/HyperlinkToolbarAppearance.js +0 -163
  306. package/dist/esm/plugins/card/ui/LayoutButton/index.js +0 -102
  307. package/dist/esm/plugins/card/ui/LayoutButton/styled.js +0 -10
  308. package/dist/esm/plugins/card/ui/LayoutButton/types.js +0 -1
  309. package/dist/esm/plugins/card/ui/LayoutButton/utils.js +0 -12
  310. package/dist/esm/plugins/card/ui/LinkToolbarAppearance.js +0 -140
  311. package/dist/esm/plugins/card/ui/ResizableEmbedCard.js +0 -355
  312. package/dist/esm/plugins/card/ui/SmallerEditIcon.js +0 -11
  313. package/dist/esm/plugins/card/utils.js +0 -48
  314. package/dist/types/plugins/card/index.d.ts +0 -26
  315. package/dist/types/plugins/card/messages.d.ts +0 -12
  316. package/dist/types/plugins/card/nodeviews/blockCard.d.ts +0 -26
  317. package/dist/types/plugins/card/nodeviews/datasource.d.ts +0 -42
  318. package/dist/types/plugins/card/nodeviews/embedCard.d.ts +0 -46
  319. package/dist/types/plugins/card/nodeviews/genericCard.d.ts +0 -37
  320. package/dist/types/plugins/card/nodeviews/inlineCard.d.ts +0 -23
  321. package/dist/types/plugins/card/pm-plugins/actions.d.ts +0 -23
  322. package/dist/types/plugins/card/pm-plugins/analytics/create-analytics-queue.d.ts +0 -10
  323. package/dist/types/plugins/card/pm-plugins/analytics/events-from-tr.d.ts +0 -17
  324. package/dist/types/plugins/card/pm-plugins/analytics/index.d.ts +0 -2
  325. package/dist/types/plugins/card/pm-plugins/analytics/types.d.ts +0 -12
  326. package/dist/types/plugins/card/pm-plugins/analytics/utils.d.ts +0 -32
  327. package/dist/types/plugins/card/pm-plugins/doc.d.ts +0 -23
  328. package/dist/types/plugins/card/pm-plugins/keymap.d.ts +0 -3
  329. package/dist/types/plugins/card/pm-plugins/main.d.ts +0 -6
  330. package/dist/types/plugins/card/pm-plugins/mountHyperlink.d.ts +0 -5
  331. package/dist/types/plugins/card/pm-plugins/plugin-key.d.ts +0 -3
  332. package/dist/types/plugins/card/pm-plugins/reducers.d.ts +0 -3
  333. package/dist/types/plugins/card/pm-plugins/shouldReplaceLink.d.ts +0 -2
  334. package/dist/types/plugins/card/pm-plugins/util/resolve.d.ts +0 -8
  335. package/dist/types/plugins/card/pm-plugins/util/state.d.ts +0 -31
  336. package/dist/types/plugins/card/toolbar.d.ts +0 -12
  337. package/dist/types/plugins/card/types.d.ts +0 -165
  338. package/dist/types/plugins/card/ui/DatasourceModal/ModalWithState.d.ts +0 -9
  339. package/dist/types/plugins/card/ui/DatasourceModal/index.d.ts +0 -11
  340. package/dist/types/plugins/card/ui/EditLinkToolbar.d.ts +0 -47
  341. package/dist/types/plugins/card/ui/EditorSmartCardEvents.d.ts +0 -5
  342. package/dist/types/plugins/card/ui/EditorSmartCardEventsNext.d.ts +0 -18
  343. package/dist/types/plugins/card/ui/HyperlinkToolbarAppearance.d.ts +0 -32
  344. package/dist/types/plugins/card/ui/LayoutButton/index.d.ts +0 -9
  345. package/dist/types/plugins/card/ui/LayoutButton/styled.d.ts +0 -1
  346. package/dist/types/plugins/card/ui/LayoutButton/types.d.ts +0 -19
  347. package/dist/types/plugins/card/ui/LayoutButton/utils.d.ts +0 -5
  348. package/dist/types/plugins/card/ui/LinkToolbarAppearance.d.ts +0 -29
  349. package/dist/types/plugins/card/ui/ResizableEmbedCard.d.ts +0 -61
  350. package/dist/types/plugins/card/ui/SmallerEditIcon.d.ts +0 -3
  351. package/dist/types/plugins/card/utils.d.ts +0 -19
  352. package/dist/types-ts4.5/plugins/card/index.d.ts +0 -26
  353. package/dist/types-ts4.5/plugins/card/messages.d.ts +0 -12
  354. package/dist/types-ts4.5/plugins/card/nodeviews/blockCard.d.ts +0 -26
  355. package/dist/types-ts4.5/plugins/card/nodeviews/datasource.d.ts +0 -42
  356. package/dist/types-ts4.5/plugins/card/nodeviews/embedCard.d.ts +0 -46
  357. package/dist/types-ts4.5/plugins/card/nodeviews/genericCard.d.ts +0 -37
  358. package/dist/types-ts4.5/plugins/card/nodeviews/inlineCard.d.ts +0 -23
  359. package/dist/types-ts4.5/plugins/card/pm-plugins/actions.d.ts +0 -23
  360. package/dist/types-ts4.5/plugins/card/pm-plugins/analytics/create-analytics-queue.d.ts +0 -10
  361. package/dist/types-ts4.5/plugins/card/pm-plugins/analytics/events-from-tr.d.ts +0 -17
  362. package/dist/types-ts4.5/plugins/card/pm-plugins/analytics/index.d.ts +0 -2
  363. package/dist/types-ts4.5/plugins/card/pm-plugins/analytics/types.d.ts +0 -12
  364. package/dist/types-ts4.5/plugins/card/pm-plugins/analytics/utils.d.ts +0 -32
  365. package/dist/types-ts4.5/plugins/card/pm-plugins/doc.d.ts +0 -23
  366. package/dist/types-ts4.5/plugins/card/pm-plugins/keymap.d.ts +0 -3
  367. package/dist/types-ts4.5/plugins/card/pm-plugins/main.d.ts +0 -6
  368. package/dist/types-ts4.5/plugins/card/pm-plugins/mountHyperlink.d.ts +0 -5
  369. package/dist/types-ts4.5/plugins/card/pm-plugins/plugin-key.d.ts +0 -3
  370. package/dist/types-ts4.5/plugins/card/pm-plugins/reducers.d.ts +0 -3
  371. package/dist/types-ts4.5/plugins/card/pm-plugins/shouldReplaceLink.d.ts +0 -2
  372. package/dist/types-ts4.5/plugins/card/pm-plugins/util/resolve.d.ts +0 -8
  373. package/dist/types-ts4.5/plugins/card/pm-plugins/util/state.d.ts +0 -31
  374. package/dist/types-ts4.5/plugins/card/toolbar.d.ts +0 -12
  375. package/dist/types-ts4.5/plugins/card/types.d.ts +0 -165
  376. package/dist/types-ts4.5/plugins/card/ui/DatasourceModal/ModalWithState.d.ts +0 -9
  377. package/dist/types-ts4.5/plugins/card/ui/DatasourceModal/index.d.ts +0 -11
  378. package/dist/types-ts4.5/plugins/card/ui/EditLinkToolbar.d.ts +0 -47
  379. package/dist/types-ts4.5/plugins/card/ui/EditorSmartCardEvents.d.ts +0 -5
  380. package/dist/types-ts4.5/plugins/card/ui/EditorSmartCardEventsNext.d.ts +0 -18
  381. package/dist/types-ts4.5/plugins/card/ui/HyperlinkToolbarAppearance.d.ts +0 -32
  382. package/dist/types-ts4.5/plugins/card/ui/LayoutButton/index.d.ts +0 -9
  383. package/dist/types-ts4.5/plugins/card/ui/LayoutButton/styled.d.ts +0 -1
  384. package/dist/types-ts4.5/plugins/card/ui/LayoutButton/types.d.ts +0 -19
  385. package/dist/types-ts4.5/plugins/card/ui/LayoutButton/utils.d.ts +0 -5
  386. package/dist/types-ts4.5/plugins/card/ui/LinkToolbarAppearance.d.ts +0 -29
  387. package/dist/types-ts4.5/plugins/card/ui/ResizableEmbedCard.d.ts +0 -61
  388. package/dist/types-ts4.5/plugins/card/ui/SmallerEditIcon.d.ts +0 -3
  389. package/dist/types-ts4.5/plugins/card/utils.d.ts +0 -19
@@ -1,92 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- import React from 'react';
4
- import PropTypes from 'prop-types';
5
- import { isSafeUrl } from '@atlaskit/adf-schema';
6
- import { titleUrlPairFromNode } from '../utils';
7
- import { changeSelectedCardToLinkFallback } from '../pm-plugins/doc';
8
- import { AnalyticsContext } from '@atlaskit/analytics-next';
9
- import { getPluginState } from '../pm-plugins/util/state';
10
- import { getAnalyticsEditorAppearance } from '@atlaskit/editor-common/utils';
11
- export function Card(SmartCardComponent, UnsupportedComponent) {
12
- var _class;
13
- return _class = class extends React.Component {
14
- constructor(...args) {
15
- super(...args);
16
- _defineProperty(this, "state", {
17
- isError: false
18
- });
19
- }
20
- render() {
21
- var _getPluginState;
22
- const {
23
- url
24
- } = titleUrlPairFromNode(this.props.node);
25
- if (url && !isSafeUrl(url)) {
26
- return /*#__PURE__*/React.createElement(UnsupportedComponent, null);
27
- }
28
- if (this.state.isError) {
29
- if (url) {
30
- return /*#__PURE__*/React.createElement("a", {
31
- href: url,
32
- onClick: e => {
33
- e.preventDefault();
34
- }
35
- }, url);
36
- } else {
37
- return /*#__PURE__*/React.createElement(UnsupportedComponent, null);
38
- }
39
- }
40
- const cardContext = this.context.contextAdapter ? this.context.contextAdapter.card : undefined;
41
- const editorAppearance = (_getPluginState = getPluginState(this.props.view.state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.editorAppearance;
42
- const analyticsEditorAppearance = getAnalyticsEditorAppearance(editorAppearance);
43
- return /*#__PURE__*/React.createElement(AnalyticsContext, {
44
- data: {
45
- attributes: {
46
- location: analyticsEditorAppearance
47
- },
48
- // Below is added for the future implementation of Linking Platform namespaced analytics context
49
- location: analyticsEditorAppearance
50
- }
51
- }, /*#__PURE__*/React.createElement(SmartCardComponent, _extends({
52
- key: url,
53
- cardContext: cardContext
54
- }, this.props)));
55
- }
56
- componentDidCatch(error) {
57
- const maybeAPIError = error;
58
- // NB: errors received in this component are propagated by the `@atlaskit/smart-card` component.
59
- // Depending on the kind of error, the expectation for this component is to either:
60
- // (1) Render a blue link whilst retaining `inlineCard` in the ADF (non-fatal errs);
61
- // (2) Render a blue link whilst downgrading to `link` in the ADF (fatal errs).
62
-
63
- if (maybeAPIError.kind && maybeAPIError.kind === 'fatal') {
64
- var _pluginInjectionApi$d;
65
- this.setState({
66
- isError: true
67
- });
68
- const {
69
- view,
70
- node,
71
- getPos,
72
- pluginInjectionApi
73
- } = this.props;
74
- const {
75
- url
76
- } = titleUrlPairFromNode(node);
77
- if (!getPos || typeof getPos === 'boolean') {
78
- return;
79
- }
80
- changeSelectedCardToLinkFallback(undefined, url, true, node, getPos(), pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.actions)(view.state, view.dispatch);
81
- return null;
82
- } else {
83
- // Otherwise, render a blue link as fallback (above in render()).
84
- this.setState({
85
- isError: true
86
- });
87
- }
88
- }
89
- }, _defineProperty(_class, "contextTypes", {
90
- contextAdapter: PropTypes.object
91
- }), _class;
92
- }
@@ -1,112 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import React from 'react';
3
- import PropTypes from 'prop-types';
4
- import { Card as SmartCard } from '@atlaskit/smart-card';
5
- import { UnsupportedInline } from '@atlaskit/editor-common/ui';
6
- import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
7
- import rafSchedule from 'raf-schd';
8
- import { Card } from './genericCard';
9
- import { registerCard } from '../pm-plugins/actions';
10
- export class InlineCardComponent extends React.PureComponent {
11
- constructor(...args) {
12
- super(...args);
13
- _defineProperty(this, "onClick", () => {});
14
- _defineProperty(this, "onResolve", data => {
15
- const {
16
- getPos,
17
- view
18
- } = this.props;
19
- if (!getPos || typeof getPos === 'boolean') {
20
- return;
21
- }
22
- const {
23
- title,
24
- url
25
- } = data;
26
- // don't dispatch immediately since we might be in the middle of
27
- // rendering a nodeview
28
- rafSchedule(() => {
29
- // prosemirror-bump-fix
30
- const pos = getPos();
31
- if (typeof pos !== 'number') {
32
- return;
33
- }
34
- view.dispatch(registerCard({
35
- title,
36
- url,
37
- pos
38
- })(view.state.tr));
39
- })();
40
- });
41
- _defineProperty(this, "onError", data => {
42
- const {
43
- url,
44
- err
45
- } = data;
46
- if (err) {
47
- throw err;
48
- }
49
- this.onResolve({
50
- url
51
- });
52
- });
53
- }
54
- UNSAFE_componentWillMount() {
55
- const {
56
- view
57
- } = this.props;
58
- const scrollContainer = findOverflowScrollParent(view.dom);
59
- this.scrollContainer = scrollContainer || undefined;
60
- }
61
- render() {
62
- const {
63
- node,
64
- cardContext,
65
- showServerActions,
66
- useAlternativePreloader
67
- } = this.props;
68
- const {
69
- url,
70
- data
71
- } = node.attrs;
72
- const card = /*#__PURE__*/React.createElement("span", {
73
- className: "card"
74
- }, /*#__PURE__*/React.createElement(SmartCard, {
75
- key: url,
76
- url: url,
77
- data: data,
78
- appearance: "inline",
79
- onClick: this.onClick,
80
- container: this.scrollContainer,
81
- onResolve: this.onResolve,
82
- onError: this.onError,
83
- inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
84
- showServerActions: showServerActions
85
- }));
86
- // [WS-2307]: we only render card wrapped into a Provider when the value is ready,
87
- // otherwise if we got data, we can render the card directly since it doesn't need the Provider
88
- return cardContext && cardContext.value ? /*#__PURE__*/React.createElement(cardContext.Provider, {
89
- value: cardContext.value
90
- }, card) : data ? card : null;
91
- }
92
- }
93
- _defineProperty(InlineCardComponent, "contextTypes", {
94
- contextAdapter: PropTypes.object
95
- });
96
- const WrappedInlineCard = Card(InlineCardComponent, UnsupportedInline);
97
- export function InlineCardNodeView(props) {
98
- const {
99
- useAlternativePreloader,
100
- node,
101
- view,
102
- getPos,
103
- showServerActions
104
- } = props;
105
- return /*#__PURE__*/React.createElement(WrappedInlineCard, {
106
- node: node,
107
- view: view,
108
- getPos: getPos,
109
- showServerActions: showServerActions,
110
- useAlternativePreloader: useAlternativePreloader
111
- });
112
- }
@@ -1,57 +0,0 @@
1
- import { pluginKey } from './plugin-key';
2
- export const cardAction = (tr, action) => {
3
- return tr.setMeta(pluginKey, action);
4
- };
5
- export const resolveCard = url => tr => cardAction(tr, {
6
- type: 'RESOLVE',
7
- url
8
- });
9
- export const queueCards = requests => tr => cardAction(tr, {
10
- type: 'QUEUE',
11
- requests: requests
12
- });
13
- export const registerCard = info => tr => cardAction(tr, {
14
- type: 'REGISTER',
15
- info
16
- });
17
- export const registerSmartCardEvents = smartLinkEvents => tr => cardAction(tr, {
18
- type: 'REGISTER_EVENTS',
19
- smartLinkEvents
20
- });
21
- export const registerSmartCardEventsNext = smartLinkEvents => tr => cardAction(tr, {
22
- type: 'REGISTER_EVENTS_NEXT',
23
- smartLinkEvents
24
- });
25
- export const setProvider = cardProvider => tr => cardAction(tr, {
26
- type: 'SET_PROVIDER',
27
- provider: cardProvider
28
- });
29
- export const setDatasourceTableRef = datasourceTableRef => tr => cardAction(tr, {
30
- type: 'SET_DATASOURCE_TABLE_REF',
31
- datasourceTableRef
32
- });
33
- export const setCardLayout = layout => tr => cardAction(tr, {
34
- type: 'SET_CARD_LAYOUT',
35
- layout
36
- });
37
- export const setCardLayoutAndDatasourceTableRef = ({
38
- layout,
39
- datasourceTableRef
40
- }) => tr => cardAction(tr, {
41
- type: 'SET_CARD_LAYOUT_AND_DATASOURCE_TABLE_REF',
42
- layout,
43
- datasourceTableRef
44
- });
45
- export const showLinkToolbar = tr => cardAction(tr, {
46
- type: 'SHOW_LINK_TOOLBAR'
47
- });
48
- export const hideLinkToolbar = tr => cardAction(tr, {
49
- type: 'HIDE_LINK_TOOLBAR'
50
- });
51
- export const showDatasourceModal = modalType => tr => cardAction(tr, {
52
- type: 'SHOW_DATASOURCE_MODAL',
53
- modalType
54
- });
55
- export const hideDatasourceModal = tr => cardAction(tr, {
56
- type: 'HIDE_DATASOURCE_MODAL'
57
- });
@@ -1,38 +0,0 @@
1
- /**
2
- * Simple mechanism to defer analytics related callbacks
3
- */
4
- export const createAnalyticsQueue = (enabled = true) => {
5
- const queue = [];
6
- const callbacksRef = {
7
- current: null
8
- };
9
- const setCallbacks = callbacks => {
10
- callbacksRef.current = callbacks;
11
- };
12
- const push = (...events) => {
13
- const callbacks = callbacksRef.current;
14
- if (!enabled || !callbacks) {
15
- return;
16
- }
17
- queue.push(...events);
18
- };
19
- const flush = () => {
20
- const callbacks = callbacksRef.current;
21
- if (!enabled || !callbacks) {
22
- return;
23
- }
24
- while (queue.length) {
25
- const event = queue.pop();
26
- if (event) {
27
- callbacks[event.type](event.data);
28
- }
29
- }
30
- };
31
- const getSize = () => queue.length;
32
- return {
33
- push,
34
- flush,
35
- setCallbacks,
36
- getSize
37
- };
38
- };
@@ -1,333 +0,0 @@
1
- import { AddMarkStep, RemoveMarkStep } from 'prosemirror-transform';
2
- import { ACTION } from '@atlaskit/editor-common/analytics';
3
- import { isLinkMark, pmHistoryPluginKey } from '@atlaskit/editor-common/utils';
4
- import { getLinkMetadataFromTransaction } from '@atlaskit/editor-common/card';
5
- import { LinkMetaStep } from '@atlaskit/adf-schema/steps';
6
- import { getPluginState } from '../util/state';
7
- import { pluginKey } from '../plugin-key';
8
- import { isLink, linkObjectFromNode, getLinkUrl, getLinkNodeContext, appearanceForLink, findLinksAtPositions, areSameLinks } from './utils';
9
- const findLinksInNodeRange = (doc, schema, from, to) => {
10
- const links = [];
11
- doc.nodesBetween(from, to, (node, pos) => {
12
- if (isLink(schema, node)) {
13
- const entireLinkInRange = pos >= from && pos + node.nodeSize <= to;
14
- if (entireLinkInRange) {
15
- const link = linkObjectFromNode(doc, schema, node, pos);
16
- if (link) {
17
- links.push(link);
18
- }
19
- }
20
- }
21
- });
22
- return links;
23
- };
24
- export const findChangedLinks = (tr, state) => {
25
- const schema = tr.doc.type.schema;
26
- const removed = [];
27
- const inserted = [];
28
- const updated = [];
29
- const queuedForUpgrade = isTransactionQueuedForUpgrade(tr);
30
- const isResolveReplace = isTransactionResolveReplace(tr);
31
-
32
- // History
33
- const historyMeta = tr.getMeta(pmHistoryPluginKey);
34
- const isUndo = isHistoryMeta(historyMeta) && historyMeta.redo === false;
35
- const isRedo = isHistoryMeta(historyMeta) && historyMeta.redo === true;
36
- const isUpdate = isUpdateTr(tr, isUndo || isRedo);
37
- for (let i = 0; i < tr.steps.length; i++) {
38
- var _tr$docs$i, _tr$docs;
39
- const step = tr.steps[i];
40
- const stepMap = step.getMap();
41
- const removedInStep = [];
42
- const insertedInStep = [];
43
- const before = (_tr$docs$i = tr.docs[i]) !== null && _tr$docs$i !== void 0 ? _tr$docs$i : tr.before;
44
- const after = (_tr$docs = tr.docs[i + 1]) !== null && _tr$docs !== void 0 ? _tr$docs : tr.doc;
45
-
46
- /**
47
- * AddMarkStep and RemoveMarkSteps don't produce stepMap ranges
48
- * because there are no "changed tokens" only marks added/removed
49
- * So have to check these manually
50
- */
51
- if (step instanceof AddMarkStep) {
52
- const addMarkStep = step;
53
- if (isLinkMark(addMarkStep.mark, schema)) {
54
- /**
55
- * For url text pasted on plain text
56
- */
57
- insertedInStep.push({
58
- type: 'mark',
59
- pos: addMarkStep.from,
60
- mark: addMarkStep.mark,
61
- nodeContext: getLinkNodeContext(after, addMarkStep.from)
62
- });
63
- }
64
- }
65
- if (step instanceof RemoveMarkStep) {
66
- const removeMarkStep = step;
67
- if (isLinkMark(removeMarkStep.mark, schema)) {
68
- removedInStep.push({
69
- type: 'mark',
70
- pos: removeMarkStep.from,
71
- mark: removeMarkStep.mark,
72
- nodeContext: getLinkNodeContext(before, removeMarkStep.from)
73
- });
74
- }
75
- }
76
- stepMap.forEach((oldStart, oldEnd, newStart, newEnd) => {
77
- var _tr$docs2;
78
- const before = tr.docs[i];
79
- const after = (_tr$docs2 = tr.docs[i + 1]) !== null && _tr$docs2 !== void 0 ? _tr$docs2 : tr.doc;
80
- const removedInRange = [];
81
- const insertedInRange = [];
82
-
83
- // Removed
84
- removedInRange.push(...findLinksInNodeRange(before, schema, oldStart, oldEnd));
85
- // Inserted
86
- insertedInRange.push(...findLinksInNodeRange(after, schema, newStart, newEnd));
87
- removedInStep.push(...removedInRange);
88
- insertedInStep.push(...insertedInRange);
89
- });
90
- const omitQueuedLinks = links => {
91
- if (!queuedForUpgrade) {
92
- return links;
93
- }
94
- /**
95
- * Skip/filter out links that have been queued, they will be tracked later
96
- */
97
- const queuedPositions = getQueuedPositions(tr);
98
- return links.filter(link => !queuedPositions.includes(link.pos));
99
- };
100
-
101
- /**
102
- * Skip "deletions" when the transaction is relating to
103
- * replacing links queued for upgrade to cards,
104
- * because the "deleted" link has not actually been
105
- * tracked as "created" yet
106
- */
107
- if (!isResolveReplace) {
108
- removed.push(...removedInStep);
109
- }
110
- inserted.push(...omitQueuedLinks(insertedInStep));
111
- }
112
-
113
- /**
114
- * If there are no links changed but the transaction is a "resolve" action
115
- * Then this means we have resolved a link but it has failed to upgrade
116
- * We should track all resolved links as now being created
117
- */
118
- if (inserted.length === 0 && isResolveReplace) {
119
- const positions = getResolvePositions(tr, state);
120
- inserted.push(...findLinksAtPositions(tr, positions));
121
- }
122
- if (!isUpdate) {
123
- const {
124
- inputMethod
125
- } = getLinkMetadataFromTransaction(tr);
126
- /**
127
- * If there is no identifiable input method, and the links inserted and removed appear to be the same,
128
- * then this transaction likely is not intended to be consided to be the insertion and removal of links
129
- */
130
- if (!inputMethod && areSameLinks(removed, inserted)) {
131
- return {
132
- removed: [],
133
- inserted: [],
134
- updated
135
- };
136
- }
137
- return {
138
- removed,
139
- inserted,
140
- updated
141
- };
142
- }
143
- for (let i = 0; i < inserted.length; i++) {
144
- if (isResolveReplace) {
145
- const newLink = inserted[i];
146
-
147
- // what is the 2nd argument 'assoc = -1' doing here exactly?
148
- const mappedPos = tr.mapping.map(newLink.pos, -1);
149
- const previousDisplay = getResolveLinkPrevDisplay(state, mappedPos);
150
- updated.push({
151
- inserted: inserted[i],
152
- previous: {
153
- display: previousDisplay
154
- }
155
- });
156
- continue;
157
- }
158
- if (inserted.length === removed.length) {
159
- updated.push({
160
- removed: removed[i],
161
- inserted: inserted[i]
162
- });
163
- }
164
- }
165
- return {
166
- inserted: [],
167
- removed: [],
168
- updated
169
- };
170
- };
171
-
172
- /**
173
- * List of actions to be considered link "updates"
174
- */
175
- const UPDATE_ACTIONS = [ACTION.CHANGED_TYPE, ACTION.UPDATED];
176
-
177
- /**
178
- * Returns true if the transaction has LinkMetaSteps that indicate the transaction is
179
- * intended to be perceived as an update to links, rather than insertion+deletion
180
- */
181
- const isUpdateTr = (tr, isUndoOrRedo) => {
182
- return !!tr.steps.find(step => {
183
- if (!(step instanceof LinkMetaStep)) {
184
- return false;
185
- }
186
- const {
187
- action,
188
- cardAction
189
- } = step.getMetadata();
190
-
191
- /**
192
- * Undo of a resolve step should be considered an update
193
- * because the user is choosing to update the url back to the un-upgraded display
194
- */
195
- if (cardAction === 'RESOLVE' && isUndoOrRedo) {
196
- return true;
197
- }
198
- if (!action) {
199
- return false;
200
- }
201
- return UPDATE_ACTIONS.includes(action);
202
- });
203
- };
204
- const hasType = pluginMeta => {
205
- return typeof pluginMeta === 'object' && pluginMeta !== null && 'type' in pluginMeta;
206
- };
207
- const isTransactionQueuedForUpgrade = tr => {
208
- const pluginMeta = tr.getMeta(pluginKey);
209
- return hasType(pluginMeta) && pluginMeta.type === 'QUEUE';
210
- };
211
- const isTransactionResolveReplace = tr => {
212
- const pluginMeta = tr.getMeta(pluginKey);
213
- return hasType(pluginMeta) && pluginMeta.type === 'RESOLVE';
214
- };
215
- const isHistoryMeta = meta => {
216
- return typeof meta === 'object' && meta !== null && 'redo' in meta;
217
- };
218
- const getQueuedPositions = tr => {
219
- const pluginMeta = tr.getMeta(pluginKey);
220
- if (!isTransactionQueuedForUpgrade(tr)) {
221
- return [];
222
- }
223
- return pluginMeta.requests.map(({
224
- pos
225
- }) => pos);
226
- };
227
- const getResolvePositions = (tr, state) => {
228
- const cardState = getPluginState(state);
229
- if (!cardState) {
230
- return [];
231
- }
232
- const pluginMeta = tr.getMeta(pluginKey);
233
- if (!isTransactionResolveReplace(tr)) {
234
- return [];
235
- }
236
- return cardState.requests.filter(request => request.url === pluginMeta.url).map(request => request.pos);
237
- };
238
- const getResolveLinkPrevDisplay = (state, pos) => {
239
- var _cardState$requests$f;
240
- const cardState = getPluginState(state);
241
- if (!cardState) {
242
- return undefined;
243
- }
244
- return (_cardState$requests$f = cardState.requests.find(request => request.pos === pos)) === null || _cardState$requests$f === void 0 ? void 0 : _cardState$requests$f.previousAppearance;
245
- };
246
- export function eventsFromTransaction(tr, state) {
247
- const events = [];
248
- try {
249
- /**
250
- * Skip transactions sent by collab (identified by 'isRemote' key)
251
- * Skip entire document replace steps
252
- * We are only concerned with transactions performed on the document directly by the user
253
- */
254
- const isRemote = tr.getMeta('isRemote');
255
- const isReplaceDocument = tr.getMeta('replaceDocument');
256
- if (isRemote || isReplaceDocument) {
257
- return events;
258
- }
259
- const historyMeta = tr.getMeta(pmHistoryPluginKey);
260
- const isUndo = isHistoryMeta(historyMeta) && historyMeta.redo === false;
261
- const isRedo = isHistoryMeta(historyMeta) && historyMeta.redo === true;
262
-
263
- /**
264
- * Retrieve metadata from the LinkMetaStep(s) in the transaction
265
- */
266
- const {
267
- action,
268
- inputMethod,
269
- sourceEvent
270
- } = getLinkMetadataFromTransaction(tr);
271
- const contextualData = {
272
- action,
273
- inputMethod,
274
- sourceEvent,
275
- isUndo,
276
- isRedo
277
- };
278
- const {
279
- removed,
280
- inserted,
281
- updated
282
- } = findChangedLinks(tr, state);
283
- const MAX_LINK_EVENTS = 50;
284
- if ([removed, inserted, updated].some(arr => arr.length > MAX_LINK_EVENTS)) {
285
- return [];
286
- }
287
- for (let i = 0; i < updated.length; i++) {
288
- var _update$previous$disp;
289
- const update = updated[i];
290
- const {
291
- inserted: link
292
- } = update;
293
- const url = getLinkUrl(link);
294
- const display = appearanceForLink(link);
295
- const previousDisplay = 'removed' in update ? appearanceForLink(update.removed) : (_update$previous$disp = update.previous.display) !== null && _update$previous$disp !== void 0 ? _update$previous$disp : 'unknown';
296
- if (url) {
297
- events.push({
298
- type: 'updated',
299
- data: {
300
- ...contextualData,
301
- url,
302
- display,
303
- previousDisplay,
304
- nodeContext: link.nodeContext
305
- }
306
- });
307
- }
308
- }
309
- const pushEvents = (links, type) => {
310
- for (let i = 0; i < links.length; i++) {
311
- const link = links[i];
312
- const url = getLinkUrl(link);
313
- const display = appearanceForLink(link);
314
- if (url) {
315
- events.push({
316
- type,
317
- data: {
318
- ...contextualData,
319
- url,
320
- display,
321
- nodeContext: link.nodeContext
322
- }
323
- });
324
- }
325
- }
326
- };
327
- pushEvents(removed, 'deleted');
328
- pushEvents(inserted, 'created');
329
- return events;
330
- } catch (err) {
331
- return events;
332
- }
333
- }
@@ -1,2 +0,0 @@
1
- export { createAnalyticsQueue } from './create-analytics-queue';
2
- export { eventsFromTransaction } from './events-from-tr';