@atlaskit/editor-core 185.16.3 → 185.16.6

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 (366) 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/expand/commands.js +15 -12
  33. package/dist/cjs/plugins/expand/nodeviews/index.js +4 -1
  34. package/dist/cjs/plugins/index.js +0 -7
  35. package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +14 -25
  36. package/dist/cjs/plugins/media/ui/ResizableMediaSingle/index.js +39 -27
  37. package/dist/cjs/version-wrapper.js +1 -1
  38. package/dist/cjs/version.json +1 -1
  39. package/dist/es2019/i18n/cs.js +0 -35
  40. package/dist/es2019/i18n/da.js +0 -35
  41. package/dist/es2019/i18n/de.js +0 -35
  42. package/dist/es2019/i18n/en.js +0 -35
  43. package/dist/es2019/i18n/en_GB.js +0 -35
  44. package/dist/es2019/i18n/en_ZZ.js +0 -35
  45. package/dist/es2019/i18n/es.js +1 -35
  46. package/dist/es2019/i18n/fi.js +0 -35
  47. package/dist/es2019/i18n/fr.js +1 -35
  48. package/dist/es2019/i18n/hu.js +1 -35
  49. package/dist/es2019/i18n/it.js +1 -35
  50. package/dist/es2019/i18n/ja.js +1 -35
  51. package/dist/es2019/i18n/ko.js +0 -35
  52. package/dist/es2019/i18n/nb.js +1 -35
  53. package/dist/es2019/i18n/nl.js +1 -35
  54. package/dist/es2019/i18n/pl.js +1 -35
  55. package/dist/es2019/i18n/pt_BR.js +1 -35
  56. package/dist/es2019/i18n/ru.js +1 -35
  57. package/dist/es2019/i18n/sv.js +0 -35
  58. package/dist/es2019/i18n/th.js +0 -35
  59. package/dist/es2019/i18n/tr.js +1 -35
  60. package/dist/es2019/i18n/uk.js +1 -35
  61. package/dist/es2019/i18n/vi.js +0 -35
  62. package/dist/es2019/i18n/zh.js +1 -35
  63. package/dist/es2019/i18n/zh_TW.js +1 -35
  64. package/dist/es2019/labs/next/presets/mobile.js +1 -1
  65. package/dist/es2019/labs/next/presets/universal.js +1 -1
  66. package/dist/es2019/plugins/deprecated-card/doc.js +97 -0
  67. package/dist/es2019/plugins/deprecated-hyperlink/commands.js +1 -1
  68. package/dist/es2019/plugins/expand/commands.js +13 -14
  69. package/dist/es2019/plugins/expand/nodeviews/index.js +4 -1
  70. package/dist/es2019/plugins/index.js +0 -1
  71. package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +2 -14
  72. package/dist/es2019/plugins/media/ui/ResizableMediaSingle/index.js +13 -0
  73. package/dist/es2019/version-wrapper.js +1 -1
  74. package/dist/es2019/version.json +1 -1
  75. package/dist/esm/i18n/cs.js +0 -35
  76. package/dist/esm/i18n/da.js +0 -35
  77. package/dist/esm/i18n/de.js +0 -35
  78. package/dist/esm/i18n/en.js +0 -35
  79. package/dist/esm/i18n/en_GB.js +0 -35
  80. package/dist/esm/i18n/en_ZZ.js +0 -35
  81. package/dist/esm/i18n/es.js +1 -35
  82. package/dist/esm/i18n/fi.js +0 -35
  83. package/dist/esm/i18n/fr.js +1 -35
  84. package/dist/esm/i18n/hu.js +1 -35
  85. package/dist/esm/i18n/it.js +1 -35
  86. package/dist/esm/i18n/ja.js +1 -35
  87. package/dist/esm/i18n/ko.js +0 -35
  88. package/dist/esm/i18n/nb.js +1 -35
  89. package/dist/esm/i18n/nl.js +1 -35
  90. package/dist/esm/i18n/pl.js +1 -35
  91. package/dist/esm/i18n/pt_BR.js +1 -35
  92. package/dist/esm/i18n/ru.js +1 -35
  93. package/dist/esm/i18n/sv.js +0 -35
  94. package/dist/esm/i18n/th.js +0 -35
  95. package/dist/esm/i18n/tr.js +1 -35
  96. package/dist/esm/i18n/uk.js +1 -35
  97. package/dist/esm/i18n/vi.js +0 -35
  98. package/dist/esm/i18n/zh.js +1 -35
  99. package/dist/esm/i18n/zh_TW.js +1 -35
  100. package/dist/esm/labs/next/presets/mobile.js +1 -1
  101. package/dist/esm/labs/next/presets/universal.js +1 -1
  102. package/dist/esm/plugins/deprecated-card/doc.js +105 -0
  103. package/dist/esm/plugins/deprecated-hyperlink/commands.js +1 -1
  104. package/dist/esm/plugins/expand/commands.js +16 -13
  105. package/dist/esm/plugins/expand/nodeviews/index.js +4 -1
  106. package/dist/esm/plugins/index.js +0 -1
  107. package/dist/esm/plugins/media/nodeviews/mediaSingle.js +14 -25
  108. package/dist/esm/plugins/media/ui/ResizableMediaSingle/index.js +39 -27
  109. package/dist/esm/version-wrapper.js +1 -1
  110. package/dist/esm/version.json +1 -1
  111. package/dist/types/i18n/cs.d.ts +0 -35
  112. package/dist/types/i18n/da.d.ts +0 -35
  113. package/dist/types/i18n/de.d.ts +0 -35
  114. package/dist/types/i18n/en.d.ts +0 -35
  115. package/dist/types/i18n/en_GB.d.ts +0 -35
  116. package/dist/types/i18n/en_ZZ.d.ts +0 -35
  117. package/dist/types/i18n/es.d.ts +1 -35
  118. package/dist/types/i18n/fi.d.ts +0 -35
  119. package/dist/types/i18n/fr.d.ts +1 -35
  120. package/dist/types/i18n/hu.d.ts +1 -35
  121. package/dist/types/i18n/it.d.ts +1 -35
  122. package/dist/types/i18n/ja.d.ts +1 -35
  123. package/dist/types/i18n/ko.d.ts +0 -35
  124. package/dist/types/i18n/nb.d.ts +1 -35
  125. package/dist/types/i18n/nl.d.ts +1 -35
  126. package/dist/types/i18n/pl.d.ts +1 -35
  127. package/dist/types/i18n/pt_BR.d.ts +1 -35
  128. package/dist/types/i18n/ru.d.ts +1 -35
  129. package/dist/types/i18n/sv.d.ts +0 -35
  130. package/dist/types/i18n/th.d.ts +0 -35
  131. package/dist/types/i18n/tr.d.ts +1 -35
  132. package/dist/types/i18n/uk.d.ts +1 -35
  133. package/dist/types/i18n/vi.d.ts +0 -35
  134. package/dist/types/i18n/zh.d.ts +1 -35
  135. package/dist/types/i18n/zh_TW.d.ts +1 -35
  136. package/dist/types/plugins/deprecated-card/doc.d.ts +20 -0
  137. package/dist/types/plugins/expand/commands.d.ts +1 -1
  138. package/dist/types/plugins/index.d.ts +0 -1
  139. package/dist/types/plugins/media/nodeviews/mediaSingle.d.ts +0 -1
  140. package/dist/types/plugins/media/ui/ResizableMediaSingle/index.d.ts +1 -0
  141. package/dist/types/plugins/media/ui/ResizableMediaSingle/types.d.ts +3 -2
  142. package/dist/types/plugins/paste/index.d.ts +1 -1
  143. package/dist/types-ts4.5/i18n/cs.d.ts +0 -35
  144. package/dist/types-ts4.5/i18n/da.d.ts +0 -35
  145. package/dist/types-ts4.5/i18n/de.d.ts +0 -35
  146. package/dist/types-ts4.5/i18n/en.d.ts +0 -35
  147. package/dist/types-ts4.5/i18n/en_GB.d.ts +0 -35
  148. package/dist/types-ts4.5/i18n/en_ZZ.d.ts +0 -35
  149. package/dist/types-ts4.5/i18n/es.d.ts +1 -35
  150. package/dist/types-ts4.5/i18n/fi.d.ts +0 -35
  151. package/dist/types-ts4.5/i18n/fr.d.ts +1 -35
  152. package/dist/types-ts4.5/i18n/hu.d.ts +1 -35
  153. package/dist/types-ts4.5/i18n/it.d.ts +1 -35
  154. package/dist/types-ts4.5/i18n/ja.d.ts +1 -35
  155. package/dist/types-ts4.5/i18n/ko.d.ts +0 -35
  156. package/dist/types-ts4.5/i18n/nb.d.ts +1 -35
  157. package/dist/types-ts4.5/i18n/nl.d.ts +1 -35
  158. package/dist/types-ts4.5/i18n/pl.d.ts +1 -35
  159. package/dist/types-ts4.5/i18n/pt_BR.d.ts +1 -35
  160. package/dist/types-ts4.5/i18n/ru.d.ts +1 -35
  161. package/dist/types-ts4.5/i18n/sv.d.ts +0 -35
  162. package/dist/types-ts4.5/i18n/th.d.ts +0 -35
  163. package/dist/types-ts4.5/i18n/tr.d.ts +1 -35
  164. package/dist/types-ts4.5/i18n/uk.d.ts +1 -35
  165. package/dist/types-ts4.5/i18n/vi.d.ts +0 -35
  166. package/dist/types-ts4.5/i18n/zh.d.ts +1 -35
  167. package/dist/types-ts4.5/i18n/zh_TW.d.ts +1 -35
  168. package/dist/types-ts4.5/plugins/deprecated-card/doc.d.ts +20 -0
  169. package/dist/types-ts4.5/plugins/expand/commands.d.ts +1 -1
  170. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  171. package/dist/types-ts4.5/plugins/media/nodeviews/mediaSingle.d.ts +0 -1
  172. package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/index.d.ts +1 -0
  173. package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/types.d.ts +3 -2
  174. package/dist/types-ts4.5/plugins/paste/index.d.ts +1 -1
  175. package/package.json +6 -5
  176. package/tmp/api-report-tmp.d.ts +2307 -0
  177. package/dist/cjs/plugins/card/index.js +0 -139
  178. package/dist/cjs/plugins/card/messages.js +0 -20
  179. package/dist/cjs/plugins/card/nodeviews/blockCard.js +0 -163
  180. package/dist/cjs/plugins/card/nodeviews/datasource.js +0 -172
  181. package/dist/cjs/plugins/card/nodeviews/embedCard.js +0 -396
  182. package/dist/cjs/plugins/card/nodeviews/genericCard.js +0 -118
  183. package/dist/cjs/plugins/card/nodeviews/inlineCard.js +0 -131
  184. package/dist/cjs/plugins/card/pm-plugins/actions.js +0 -122
  185. package/dist/cjs/plugins/card/pm-plugins/analytics/create-analytics-queue.js +0 -48
  186. package/dist/cjs/plugins/card/pm-plugins/analytics/events-from-tr.js +0 -353
  187. package/dist/cjs/plugins/card/pm-plugins/analytics/index.js +0 -19
  188. package/dist/cjs/plugins/card/pm-plugins/analytics/types.js +0 -5
  189. package/dist/cjs/plugins/card/pm-plugins/analytics/utils.js +0 -178
  190. package/dist/cjs/plugins/card/pm-plugins/doc.js +0 -478
  191. package/dist/cjs/plugins/card/pm-plugins/keymap.js +0 -64
  192. package/dist/cjs/plugins/card/pm-plugins/main.js +0 -212
  193. package/dist/cjs/plugins/card/pm-plugins/mountHyperlink.js +0 -47
  194. package/dist/cjs/plugins/card/pm-plugins/plugin-key.js +0 -9
  195. package/dist/cjs/plugins/card/pm-plugins/reducers.js +0 -111
  196. package/dist/cjs/plugins/card/pm-plugins/shouldReplaceLink.js +0 -35
  197. package/dist/cjs/plugins/card/pm-plugins/util/resolve.js +0 -58
  198. package/dist/cjs/plugins/card/pm-plugins/util/state.js +0 -49
  199. package/dist/cjs/plugins/card/toolbar.js +0 -364
  200. package/dist/cjs/plugins/card/types.js +0 -5
  201. package/dist/cjs/plugins/card/ui/DatasourceModal/ModalWithState.js +0 -25
  202. package/dist/cjs/plugins/card/ui/DatasourceModal/index.js +0 -60
  203. package/dist/cjs/plugins/card/ui/EditLinkToolbar.js +0 -256
  204. package/dist/cjs/plugins/card/ui/EditorSmartCardEvents.js +0 -21
  205. package/dist/cjs/plugins/card/ui/EditorSmartCardEventsNext.js +0 -213
  206. package/dist/cjs/plugins/card/ui/HyperlinkToolbarAppearance.js +0 -173
  207. package/dist/cjs/plugins/card/ui/LayoutButton/index.js +0 -113
  208. package/dist/cjs/plugins/card/ui/LayoutButton/styled.js +0 -17
  209. package/dist/cjs/plugins/card/ui/LayoutButton/types.js +0 -5
  210. package/dist/cjs/plugins/card/ui/LayoutButton/utils.js +0 -19
  211. package/dist/cjs/plugins/card/ui/LinkToolbarAppearance.js +0 -151
  212. package/dist/cjs/plugins/card/ui/ResizableEmbedCard.js +0 -360
  213. package/dist/cjs/plugins/card/ui/SmallerEditIcon.js +0 -20
  214. package/dist/cjs/plugins/card/utils.js +0 -60
  215. package/dist/es2019/plugins/card/index.js +0 -131
  216. package/dist/es2019/plugins/card/messages.js +0 -13
  217. package/dist/es2019/plugins/card/nodeviews/blockCard.js +0 -130
  218. package/dist/es2019/plugins/card/nodeviews/datasource.js +0 -136
  219. package/dist/es2019/plugins/card/nodeviews/embedCard.js +0 -368
  220. package/dist/es2019/plugins/card/nodeviews/genericCard.js +0 -92
  221. package/dist/es2019/plugins/card/nodeviews/inlineCard.js +0 -112
  222. package/dist/es2019/plugins/card/pm-plugins/actions.js +0 -57
  223. package/dist/es2019/plugins/card/pm-plugins/analytics/create-analytics-queue.js +0 -38
  224. package/dist/es2019/plugins/card/pm-plugins/analytics/events-from-tr.js +0 -333
  225. package/dist/es2019/plugins/card/pm-plugins/analytics/index.js +0 -2
  226. package/dist/es2019/plugins/card/pm-plugins/analytics/types.js +0 -1
  227. package/dist/es2019/plugins/card/pm-plugins/analytics/utils.js +0 -160
  228. package/dist/es2019/plugins/card/pm-plugins/doc.js +0 -451
  229. package/dist/es2019/plugins/card/pm-plugins/keymap.js +0 -59
  230. package/dist/es2019/plugins/card/pm-plugins/main.js +0 -208
  231. package/dist/es2019/plugins/card/pm-plugins/mountHyperlink.js +0 -37
  232. package/dist/es2019/plugins/card/pm-plugins/plugin-key.js +0 -2
  233. package/dist/es2019/plugins/card/pm-plugins/reducers.js +0 -110
  234. package/dist/es2019/plugins/card/pm-plugins/shouldReplaceLink.js +0 -25
  235. package/dist/es2019/plugins/card/pm-plugins/util/resolve.js +0 -48
  236. package/dist/es2019/plugins/card/pm-plugins/util/state.js +0 -26
  237. package/dist/es2019/plugins/card/toolbar.js +0 -362
  238. package/dist/es2019/plugins/card/types.js +0 -1
  239. package/dist/es2019/plugins/card/ui/DatasourceModal/ModalWithState.js +0 -19
  240. package/dist/es2019/plugins/card/ui/DatasourceModal/index.js +0 -48
  241. package/dist/es2019/plugins/card/ui/EditLinkToolbar.js +0 -225
  242. package/dist/es2019/plugins/card/ui/EditorSmartCardEvents.js +0 -15
  243. package/dist/es2019/plugins/card/ui/EditorSmartCardEventsNext.js +0 -198
  244. package/dist/es2019/plugins/card/ui/HyperlinkToolbarAppearance.js +0 -86
  245. package/dist/es2019/plugins/card/ui/LayoutButton/index.js +0 -106
  246. package/dist/es2019/plugins/card/ui/LayoutButton/styled.js +0 -10
  247. package/dist/es2019/plugins/card/ui/LayoutButton/types.js +0 -1
  248. package/dist/es2019/plugins/card/ui/LayoutButton/utils.js +0 -15
  249. package/dist/es2019/plugins/card/ui/LinkToolbarAppearance.js +0 -117
  250. package/dist/es2019/plugins/card/ui/ResizableEmbedCard.js +0 -332
  251. package/dist/es2019/plugins/card/ui/SmallerEditIcon.js +0 -11
  252. package/dist/es2019/plugins/card/utils.js +0 -46
  253. package/dist/esm/plugins/card/index.js +0 -132
  254. package/dist/esm/plugins/card/messages.js +0 -13
  255. package/dist/esm/plugins/card/nodeviews/blockCard.js +0 -155
  256. package/dist/esm/plugins/card/nodeviews/datasource.js +0 -164
  257. package/dist/esm/plugins/card/nodeviews/embedCard.js +0 -387
  258. package/dist/esm/plugins/card/nodeviews/genericCard.js +0 -111
  259. package/dist/esm/plugins/card/nodeviews/inlineCard.js +0 -123
  260. package/dist/esm/plugins/card/pm-plugins/actions.js +0 -102
  261. package/dist/esm/plugins/card/pm-plugins/analytics/create-analytics-queue.js +0 -41
  262. package/dist/esm/plugins/card/pm-plugins/analytics/events-from-tr.js +0 -344
  263. package/dist/esm/plugins/card/pm-plugins/analytics/index.js +0 -2
  264. package/dist/esm/plugins/card/pm-plugins/analytics/types.js +0 -1
  265. package/dist/esm/plugins/card/pm-plugins/analytics/utils.js +0 -160
  266. package/dist/esm/plugins/card/pm-plugins/doc.js +0 -460
  267. package/dist/esm/plugins/card/pm-plugins/keymap.js +0 -58
  268. package/dist/esm/plugins/card/pm-plugins/main.js +0 -199
  269. package/dist/esm/plugins/card/pm-plugins/mountHyperlink.js +0 -39
  270. package/dist/esm/plugins/card/pm-plugins/plugin-key.js +0 -2
  271. package/dist/esm/plugins/card/pm-plugins/reducers.js +0 -103
  272. package/dist/esm/plugins/card/pm-plugins/shouldReplaceLink.js +0 -29
  273. package/dist/esm/plugins/card/pm-plugins/util/resolve.js +0 -50
  274. package/dist/esm/plugins/card/pm-plugins/util/state.js +0 -40
  275. package/dist/esm/plugins/card/toolbar.js +0 -353
  276. package/dist/esm/plugins/card/types.js +0 -1
  277. package/dist/esm/plugins/card/ui/DatasourceModal/ModalWithState.js +0 -17
  278. package/dist/esm/plugins/card/ui/DatasourceModal/index.js +0 -49
  279. package/dist/esm/plugins/card/ui/EditLinkToolbar.js +0 -243
  280. package/dist/esm/plugins/card/ui/EditorSmartCardEvents.js +0 -14
  281. package/dist/esm/plugins/card/ui/EditorSmartCardEventsNext.js +0 -202
  282. package/dist/esm/plugins/card/ui/HyperlinkToolbarAppearance.js +0 -163
  283. package/dist/esm/plugins/card/ui/LayoutButton/index.js +0 -102
  284. package/dist/esm/plugins/card/ui/LayoutButton/styled.js +0 -10
  285. package/dist/esm/plugins/card/ui/LayoutButton/types.js +0 -1
  286. package/dist/esm/plugins/card/ui/LayoutButton/utils.js +0 -12
  287. package/dist/esm/plugins/card/ui/LinkToolbarAppearance.js +0 -140
  288. package/dist/esm/plugins/card/ui/ResizableEmbedCard.js +0 -355
  289. package/dist/esm/plugins/card/ui/SmallerEditIcon.js +0 -11
  290. package/dist/esm/plugins/card/utils.js +0 -48
  291. package/dist/types/plugins/card/index.d.ts +0 -26
  292. package/dist/types/plugins/card/messages.d.ts +0 -12
  293. package/dist/types/plugins/card/nodeviews/blockCard.d.ts +0 -26
  294. package/dist/types/plugins/card/nodeviews/datasource.d.ts +0 -42
  295. package/dist/types/plugins/card/nodeviews/embedCard.d.ts +0 -46
  296. package/dist/types/plugins/card/nodeviews/genericCard.d.ts +0 -37
  297. package/dist/types/plugins/card/nodeviews/inlineCard.d.ts +0 -23
  298. package/dist/types/plugins/card/pm-plugins/actions.d.ts +0 -23
  299. package/dist/types/plugins/card/pm-plugins/analytics/create-analytics-queue.d.ts +0 -10
  300. package/dist/types/plugins/card/pm-plugins/analytics/events-from-tr.d.ts +0 -17
  301. package/dist/types/plugins/card/pm-plugins/analytics/index.d.ts +0 -2
  302. package/dist/types/plugins/card/pm-plugins/analytics/types.d.ts +0 -12
  303. package/dist/types/plugins/card/pm-plugins/analytics/utils.d.ts +0 -32
  304. package/dist/types/plugins/card/pm-plugins/doc.d.ts +0 -23
  305. package/dist/types/plugins/card/pm-plugins/keymap.d.ts +0 -3
  306. package/dist/types/plugins/card/pm-plugins/main.d.ts +0 -6
  307. package/dist/types/plugins/card/pm-plugins/mountHyperlink.d.ts +0 -5
  308. package/dist/types/plugins/card/pm-plugins/plugin-key.d.ts +0 -3
  309. package/dist/types/plugins/card/pm-plugins/reducers.d.ts +0 -3
  310. package/dist/types/plugins/card/pm-plugins/shouldReplaceLink.d.ts +0 -2
  311. package/dist/types/plugins/card/pm-plugins/util/resolve.d.ts +0 -8
  312. package/dist/types/plugins/card/pm-plugins/util/state.d.ts +0 -31
  313. package/dist/types/plugins/card/toolbar.d.ts +0 -12
  314. package/dist/types/plugins/card/types.d.ts +0 -165
  315. package/dist/types/plugins/card/ui/DatasourceModal/ModalWithState.d.ts +0 -9
  316. package/dist/types/plugins/card/ui/DatasourceModal/index.d.ts +0 -11
  317. package/dist/types/plugins/card/ui/EditLinkToolbar.d.ts +0 -47
  318. package/dist/types/plugins/card/ui/EditorSmartCardEvents.d.ts +0 -5
  319. package/dist/types/plugins/card/ui/EditorSmartCardEventsNext.d.ts +0 -18
  320. package/dist/types/plugins/card/ui/HyperlinkToolbarAppearance.d.ts +0 -32
  321. package/dist/types/plugins/card/ui/LayoutButton/index.d.ts +0 -9
  322. package/dist/types/plugins/card/ui/LayoutButton/styled.d.ts +0 -1
  323. package/dist/types/plugins/card/ui/LayoutButton/types.d.ts +0 -19
  324. package/dist/types/plugins/card/ui/LayoutButton/utils.d.ts +0 -5
  325. package/dist/types/plugins/card/ui/LinkToolbarAppearance.d.ts +0 -29
  326. package/dist/types/plugins/card/ui/ResizableEmbedCard.d.ts +0 -61
  327. package/dist/types/plugins/card/ui/SmallerEditIcon.d.ts +0 -3
  328. package/dist/types/plugins/card/utils.d.ts +0 -19
  329. package/dist/types-ts4.5/plugins/card/index.d.ts +0 -26
  330. package/dist/types-ts4.5/plugins/card/messages.d.ts +0 -12
  331. package/dist/types-ts4.5/plugins/card/nodeviews/blockCard.d.ts +0 -26
  332. package/dist/types-ts4.5/plugins/card/nodeviews/datasource.d.ts +0 -42
  333. package/dist/types-ts4.5/plugins/card/nodeviews/embedCard.d.ts +0 -46
  334. package/dist/types-ts4.5/plugins/card/nodeviews/genericCard.d.ts +0 -37
  335. package/dist/types-ts4.5/plugins/card/nodeviews/inlineCard.d.ts +0 -23
  336. package/dist/types-ts4.5/plugins/card/pm-plugins/actions.d.ts +0 -23
  337. package/dist/types-ts4.5/plugins/card/pm-plugins/analytics/create-analytics-queue.d.ts +0 -10
  338. package/dist/types-ts4.5/plugins/card/pm-plugins/analytics/events-from-tr.d.ts +0 -17
  339. package/dist/types-ts4.5/plugins/card/pm-plugins/analytics/index.d.ts +0 -2
  340. package/dist/types-ts4.5/plugins/card/pm-plugins/analytics/types.d.ts +0 -12
  341. package/dist/types-ts4.5/plugins/card/pm-plugins/analytics/utils.d.ts +0 -32
  342. package/dist/types-ts4.5/plugins/card/pm-plugins/doc.d.ts +0 -23
  343. package/dist/types-ts4.5/plugins/card/pm-plugins/keymap.d.ts +0 -3
  344. package/dist/types-ts4.5/plugins/card/pm-plugins/main.d.ts +0 -6
  345. package/dist/types-ts4.5/plugins/card/pm-plugins/mountHyperlink.d.ts +0 -5
  346. package/dist/types-ts4.5/plugins/card/pm-plugins/plugin-key.d.ts +0 -3
  347. package/dist/types-ts4.5/plugins/card/pm-plugins/reducers.d.ts +0 -3
  348. package/dist/types-ts4.5/plugins/card/pm-plugins/shouldReplaceLink.d.ts +0 -2
  349. package/dist/types-ts4.5/plugins/card/pm-plugins/util/resolve.d.ts +0 -8
  350. package/dist/types-ts4.5/plugins/card/pm-plugins/util/state.d.ts +0 -31
  351. package/dist/types-ts4.5/plugins/card/toolbar.d.ts +0 -12
  352. package/dist/types-ts4.5/plugins/card/types.d.ts +0 -165
  353. package/dist/types-ts4.5/plugins/card/ui/DatasourceModal/ModalWithState.d.ts +0 -9
  354. package/dist/types-ts4.5/plugins/card/ui/DatasourceModal/index.d.ts +0 -11
  355. package/dist/types-ts4.5/plugins/card/ui/EditLinkToolbar.d.ts +0 -47
  356. package/dist/types-ts4.5/plugins/card/ui/EditorSmartCardEvents.d.ts +0 -5
  357. package/dist/types-ts4.5/plugins/card/ui/EditorSmartCardEventsNext.d.ts +0 -18
  358. package/dist/types-ts4.5/plugins/card/ui/HyperlinkToolbarAppearance.d.ts +0 -32
  359. package/dist/types-ts4.5/plugins/card/ui/LayoutButton/index.d.ts +0 -9
  360. package/dist/types-ts4.5/plugins/card/ui/LayoutButton/styled.d.ts +0 -1
  361. package/dist/types-ts4.5/plugins/card/ui/LayoutButton/types.d.ts +0 -19
  362. package/dist/types-ts4.5/plugins/card/ui/LayoutButton/utils.d.ts +0 -5
  363. package/dist/types-ts4.5/plugins/card/ui/LinkToolbarAppearance.d.ts +0 -29
  364. package/dist/types-ts4.5/plugins/card/ui/ResizableEmbedCard.d.ts +0 -61
  365. package/dist/types-ts4.5/plugins/card/ui/SmallerEditIcon.d.ts +0 -3
  366. package/dist/types-ts4.5/plugins/card/utils.d.ts +0 -19
@@ -1,160 +0,0 @@
1
- import { isLinkMark } from '@atlaskit/editor-common/utils';
2
- import { appearanceForNodeType } from '../../utils';
3
- /**
4
- * Whether a node is a "link" node, ie inline card, block card, embed card
5
- * (but not a text node with a link mark)
6
- */
7
- export function isLinkNode(node) {
8
- return !!appearanceForNodeType(node.type);
9
- }
10
-
11
- /**
12
- * Analytics appearance for link object
13
- */
14
- export function appearanceForLink(link) {
15
- if (link.type === 'node') {
16
- var appearance = appearanceForNodeType(link.node.type);
17
- if (appearance) {
18
- return appearance;
19
- }
20
- }
21
- return 'url';
22
- }
23
- var nodeHasLinkMark = function nodeHasLinkMark(schema, node) {
24
- if (node.marks) {
25
- for (var i = 0; i < node.marks.length; i++) {
26
- var mark = node.marks[i];
27
- if (isLinkMark(mark, schema)) {
28
- return true;
29
- }
30
- }
31
- }
32
- return false;
33
- };
34
-
35
- /**
36
- * Determine if a node is considered to be a link
37
- */
38
- export var isLink = function isLink(schema, node) {
39
- if (isLinkNode(node)) {
40
- return true;
41
- }
42
- return nodeHasLinkMark(schema, node);
43
- };
44
-
45
- /**
46
- * Given a node, find all nodes and marks that are considered "links"
47
- * @param state EditorState
48
- * @param fragment Fragment to search
49
- * @returns Array of nodes and marks found in the fragment that are "links"
50
- */
51
- export function findLinksInNode(doc, schema, node, offset) {
52
- var links = [];
53
- node.descendants(function (node, pos) {
54
- var nodeContext = getLinkNodeContext(doc, pos);
55
-
56
- // Nodes
57
- if (isLinkNode(node)) {
58
- links.push({
59
- type: 'node',
60
- pos: pos + offset,
61
- node: node,
62
- nodeContext: nodeContext
63
- });
64
- }
65
-
66
- // Marks
67
- if (node.marks) {
68
- for (var i = 0; i < node.marks.length; i++) {
69
- var mark = node.marks[i];
70
- if (isLinkMark(mark, schema)) {
71
- links.push({
72
- type: 'mark',
73
- pos: pos + offset,
74
- mark: mark,
75
- nodeContext: nodeContext
76
- });
77
- }
78
- }
79
- }
80
- });
81
- return links;
82
- }
83
- export function getLinkUrl(link) {
84
- var _link$mark$attrs;
85
- if (link.type === 'node') {
86
- var _link$node$attrs;
87
- return (_link$node$attrs = link.node.attrs) === null || _link$node$attrs === void 0 ? void 0 : _link$node$attrs.url;
88
- }
89
- return (_link$mark$attrs = link.mark.attrs) === null || _link$mark$attrs === void 0 ? void 0 : _link$mark$attrs.href;
90
- }
91
- export var getLinkNodeContext = function getLinkNodeContext(doc, pos) {
92
- var $pos = doc.resolve(pos);
93
- var maxDepth = 3;
94
- for (var i = 0; i <= maxDepth; i++) {
95
- var node = $pos.node($pos.depth - i);
96
- if (node && node.type.name !== 'paragraph') {
97
- return node.type.name;
98
- }
99
- }
100
- return 'unknown';
101
- };
102
- export var linkObjectFromNode = function linkObjectFromNode(doc, schema, node, pos) {
103
- var nodeContext = getLinkNodeContext(doc, pos);
104
- if (isLinkNode(node)) {
105
- return {
106
- type: 'node',
107
- pos: pos,
108
- node: node,
109
- nodeContext: nodeContext
110
- };
111
- }
112
- if (node.marks) {
113
- for (var i = 0; i < node.marks.length; i++) {
114
- var mark = node.marks[i];
115
- if (isLinkMark(mark, schema)) {
116
- return {
117
- type: 'mark',
118
- pos: pos,
119
- mark: mark,
120
- nodeContext: nodeContext
121
- };
122
- }
123
- }
124
- }
125
- };
126
- export var findLinksAtPositions = function findLinksAtPositions(tr, positions) {
127
- var schema = tr.doc.type.schema;
128
- var links = [];
129
- for (var i = 0; i < positions.length; i++) {
130
- var pos = positions[i];
131
- var node = tr.doc.nodeAt(pos);
132
- if (!node) {
133
- continue;
134
- }
135
- var link = linkObjectFromNode(tr.doc, schema, node, pos);
136
- if (!link) {
137
- continue;
138
- }
139
- links.push(link);
140
- }
141
- return links;
142
- };
143
-
144
- /**
145
- * Returns whether or not two sets of links appear to likely be the same set of links
146
- * That they are in the same order and that both their hrefs and appearances match
147
- */
148
- export var areSameLinks = function areSameLinks(linksA, linksB) {
149
- if (linksA.length !== linksB.length) {
150
- return false;
151
- }
152
- for (var i = 0; i < linksA.length; i++) {
153
- var linkA = linksA[i];
154
- var linkB = linksB[i];
155
- if (getLinkUrl(linkA) !== getLinkUrl(linkB) || appearanceForLink(linkA) !== appearanceForLink(linkB)) {
156
- return false;
157
- }
158
- }
159
- return true;
160
- };
@@ -1,460 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
5
- import isEqual from 'lodash/isEqual';
6
- import { NodeSelection, TextSelection } from 'prosemirror-state';
7
- import { closeHistory } from 'prosemirror-history';
8
- import { isSafeUrl } from '@atlaskit/adf-schema';
9
- import { addLinkMetadata } from '@atlaskit/editor-common/card';
10
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, SMART_LINK_TYPE, unlinkPayload } from '@atlaskit/editor-common/analytics';
11
- import { nodesBetweenChanged, processRawValue } from '@atlaskit/editor-common/utils';
12
- import { isFromCurrentDomain, getLinkCreationAnalyticsEvent } from '@atlaskit/editor-common/utils';
13
- import { appearanceForNodeType, selectedCardAppearance } from '../utils';
14
- import { queueCards, resolveCard, hideDatasourceModal } from './actions';
15
- import { pluginKey } from './plugin-key';
16
- import { shouldReplaceLink } from './shouldReplaceLink';
17
- /**
18
- * Attempt to replace the link into the respective card.
19
- */
20
- function replaceLinksToCards(tr, cardAdf, schema, request) {
21
- var inlineCard = schema.nodes.inlineCard;
22
- var url = request.url;
23
- if (!isSafeUrl(url)) {
24
- return;
25
- }
26
-
27
- // replace all the outstanding links with their cards
28
- var pos = tr.mapping.map(request.pos);
29
- var $pos = tr.doc.resolve(pos);
30
- var node = tr.doc.nodeAt(pos);
31
- if (!node || !node.type.isText) {
32
- return;
33
- }
34
- var replaceLink = request.shouldReplaceLink || shouldReplaceLink(node, request.compareLinkText, url);
35
- if (!replaceLink) {
36
- return;
37
- }
38
-
39
- // ED-5638: add an extra space after inline cards to avoid re-rendering them
40
- var nodes = [cardAdf];
41
- if (cardAdf.type === inlineCard) {
42
- nodes.push(schema.text(' '));
43
- }
44
- tr.replaceWith(pos, pos + (node.text || url).length, nodes);
45
- return $pos.node($pos.depth - 1).type.name;
46
- }
47
- export var replaceQueuedUrlWithCard = function replaceQueuedUrlWithCard(url, cardData, analyticsAction, editorAnalyticsApi, createAnalyticsEvent) {
48
- return function (editorState, dispatch) {
49
- var state = pluginKey.getState(editorState);
50
- if (!state) {
51
- return false;
52
- }
53
-
54
- // find the requests for this URL
55
- var requests = state.requests.filter(function (req) {
56
- return req.url === url;
57
- });
58
-
59
- // try to transform response to ADF
60
- var schema = editorState.schema;
61
- var cardAdf = processRawValue(schema, cardData);
62
- var tr = editorState.tr;
63
- if (cardAdf) {
64
- // Should prevent any other node than cards? [inlineCard, blockCard].includes(cardAdf.type)
65
- var nodeContexts = requests.map(function (request) {
66
- return replaceLinksToCards(tr, cardAdf, schema, request);
67
- }).filter(function (context) {
68
- return !!context;
69
- }); // context exist
70
-
71
- // Send analytics information
72
- if (nodeContexts.length) {
73
- var nodeContext = nodeContexts.every(function (context) {
74
- return context === nodeContexts[0];
75
- }) ? nodeContexts[0] : 'mixed';
76
-
77
- /** For block links v1, default to inline links */
78
- var nodeType = 'inlineCard';
79
- var _url$split = url.split('/'),
80
- _url$split2 = _slicedToArray(_url$split, 3),
81
- domainName = _url$split2[2];
82
- if (state.smartLinkEvents) {
83
- state.smartLinkEvents.insertSmartLink(domainName, 'inline', createAnalyticsEvent);
84
- }
85
-
86
- /**
87
- * TODO:
88
- * What if each request has a different source?
89
- * Unlikely, but need to define behaviour.
90
- * Ignore analytics event? take first? provide 'mixed' as well?
91
- */
92
- var inputMethod = requests[0].source;
93
- var sourceEvent = requests[0].sourceEvent;
94
- editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent({
95
- action: analyticsAction || ACTION.INSERTED,
96
- actionSubject: ACTION_SUBJECT.DOCUMENT,
97
- actionSubjectId: ACTION_SUBJECT_ID.SMART_LINK,
98
- eventType: EVENT_TYPE.TRACK,
99
- attributes: {
100
- inputMethod: inputMethod,
101
- nodeType: nodeType,
102
- nodeContext: nodeContext,
103
- fromCurrentDomain: isFromCurrentDomain(url)
104
- },
105
- nonPrivacySafeAttributes: {
106
- domainName: domainName
107
- }
108
- })(tr);
109
- addLinkMetadata(editorState.selection, tr, {
110
- action: analyticsAction,
111
- inputMethod: inputMethod,
112
- cardAction: 'RESOLVE',
113
- sourceEvent: sourceEvent
114
- });
115
- }
116
- }
117
- if (dispatch) {
118
- dispatch(resolveCard(url)(closeHistory(tr)));
119
- }
120
- return true;
121
- };
122
- };
123
- export var handleFallbackWithAnalytics = function handleFallbackWithAnalytics(request, editorAnalyticsApi) {
124
- return function (state, dispatch) {
125
- var cardState = pluginKey.getState(state);
126
- if (!cardState) {
127
- return false;
128
- }
129
- var tr = state.tr;
130
- if (request.source !== INPUT_METHOD.FLOATING_TB) {
131
- editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent(getLinkCreationAnalyticsEvent(request.source, request.url))(tr);
132
- }
133
- addLinkMetadata(state.selection, tr, {
134
- action: request.analyticsAction,
135
- inputMethod: request.source
136
- });
137
- if (dispatch) {
138
- dispatch(resolveCard(request.url)(tr));
139
- }
140
- return true;
141
- };
142
- };
143
- export var queueCardsFromChangedTr = function queueCardsFromChangedTr(state, tr, source, analyticsAction) {
144
- var normalizeLinkText = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
145
- var sourceEvent = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : undefined;
146
- var schema = state.schema;
147
- var link = schema.marks.link;
148
- var requests = [];
149
- nodesBetweenChanged(tr, function (node, pos) {
150
- if (!node.isText) {
151
- return true;
152
- }
153
- var linkMark = node.marks.find(function (mark) {
154
- return mark.type === link;
155
- });
156
- if (linkMark) {
157
- if (!shouldReplaceLink(node, normalizeLinkText)) {
158
- return false;
159
- }
160
- requests.push({
161
- url: linkMark.attrs.href,
162
- pos: pos,
163
- appearance: 'inline',
164
- compareLinkText: normalizeLinkText,
165
- source: source,
166
- analyticsAction: analyticsAction,
167
- sourceEvent: sourceEvent
168
- });
169
- }
170
- return false;
171
- });
172
- if (analyticsAction) {
173
- addLinkMetadata(state.selection, tr, {
174
- action: analyticsAction
175
- });
176
- }
177
- return queueCards(requests)(tr);
178
- };
179
- export var queueCardFromChangedTr = function queueCardFromChangedTr(state, tr, source, analyticsAction) {
180
- var normalizeLinkText = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
181
- var sourceEvent = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : undefined;
182
- var previousAppearance = arguments.length > 6 ? arguments[6] : undefined;
183
- var schema = state.schema;
184
- var link = schema.marks.link;
185
- var requests = [];
186
- nodesBetweenChanged(tr, function (node, pos) {
187
- if (!node.isText) {
188
- return true;
189
- }
190
- var linkMark = node.marks.find(function (mark) {
191
- return mark.type === link;
192
- });
193
- if (linkMark) {
194
- if (!shouldReplaceLink(node, normalizeLinkText)) {
195
- return false;
196
- }
197
- requests.push({
198
- url: linkMark.attrs.href,
199
- pos: pos,
200
- appearance: 'inline',
201
- previousAppearance: previousAppearance,
202
- compareLinkText: normalizeLinkText,
203
- source: source,
204
- analyticsAction: analyticsAction,
205
- sourceEvent: sourceEvent
206
- });
207
- }
208
- return false;
209
- });
210
- addLinkMetadata(state.selection, tr, {
211
- action: analyticsAction
212
- });
213
- return queueCards(requests)(tr);
214
- };
215
- export var convertHyperlinkToSmartCard = function convertHyperlinkToSmartCard(state, source, appearance) {
216
- var normalizeLinkText = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
217
- var schema = state.schema;
218
- var link = schema.marks.link;
219
- var requests = [];
220
- state.tr.doc.nodesBetween(state.selection.from, state.selection.to, function (node, pos) {
221
- var linkMark = node.marks.find(function (mark) {
222
- return mark.type === link;
223
- });
224
- if (linkMark) {
225
- requests.push({
226
- url: linkMark.attrs.href,
227
- pos: pos,
228
- appearance: appearance,
229
- previousAppearance: 'url',
230
- compareLinkText: normalizeLinkText,
231
- source: source,
232
- analyticsAction: ACTION.CHANGED_TYPE,
233
- shouldReplaceLink: true
234
- });
235
- }
236
- });
237
- addLinkMetadata(state.selection, state.tr, {
238
- action: ACTION.CHANGED_TYPE
239
- });
240
- return queueCards(requests)(state.tr);
241
- };
242
- export var changeSelectedCardToLink = function changeSelectedCardToLink(text, href, sendAnalytics, node, pos, editorAnalyticsApi) {
243
- return function (state, dispatch) {
244
- var tr;
245
- if (node && pos) {
246
- tr = cardNodeToLinkWithTransaction(state, text, href, node, pos);
247
- } else {
248
- tr = cardToLinkWithTransaction(state, text, href);
249
- }
250
- var selectedNode = state.selection instanceof NodeSelection && state.selection.node;
251
- if (sendAnalytics) {
252
- if (selectedNode) {
253
- editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent({
254
- action: ACTION.CHANGED_TYPE,
255
- actionSubject: ACTION_SUBJECT.SMART_LINK,
256
- eventType: EVENT_TYPE.TRACK,
257
- attributes: {
258
- newType: SMART_LINK_TYPE.URL,
259
- previousType: appearanceForNodeType(selectedNode.type)
260
- }
261
- })(tr);
262
- }
263
- }
264
- if (dispatch) {
265
- dispatch(tr.scrollIntoView());
266
- }
267
- return true;
268
- };
269
- };
270
- export var changeSelectedCardToLinkFallback = function changeSelectedCardToLinkFallback(text, href, sendAnalytics, node, pos, editorAnalyticsApi) {
271
- return function (state, dispatch) {
272
- var tr;
273
- if (node && pos) {
274
- tr = cardNodeToLinkWithTransaction(state, text, href, node, pos);
275
- } else {
276
- tr = cardToLinkWithTransaction(state, text, href);
277
- }
278
- if (sendAnalytics) {
279
- editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent({
280
- action: ACTION.ERRORED,
281
- actionSubject: ACTION_SUBJECT.SMART_LINK,
282
- eventType: EVENT_TYPE.OPERATIONAL,
283
- attributes: {
284
- error: 'Smart card falling back to link.'
285
- }
286
- })(tr);
287
- }
288
- if (dispatch) {
289
- dispatch(tr.scrollIntoView());
290
- }
291
- return true;
292
- };
293
- };
294
- export var updateCard = function updateCard(href, sourceEvent) {
295
- return function (state, dispatch) {
296
- var selectedNode = state.selection instanceof NodeSelection && state.selection.node;
297
- if (!selectedNode) {
298
- return false;
299
- }
300
- var cardAppearance = selectedCardAppearance(state);
301
- var tr = cardToLinkWithTransaction(state, href, href);
302
- queueCardFromChangedTr(state, tr, INPUT_METHOD.MANUAL, ACTION.UPDATED, undefined, sourceEvent, cardAppearance);
303
- if (dispatch) {
304
- dispatch(tr.scrollIntoView());
305
- }
306
- return true;
307
- };
308
- };
309
- function cardToLinkWithTransaction(state, text, href) {
310
- var selectedNode = state.selection instanceof NodeSelection && state.selection.node;
311
- if (!selectedNode) {
312
- return state.tr;
313
- }
314
- var link = state.schema.marks.link;
315
- var url = selectedNode.attrs.url || selectedNode.attrs.data.url;
316
- var tr = state.tr.replaceSelectionWith(state.schema.text(text || url, [link.create({
317
- href: href || url
318
- })]), false);
319
- return tr;
320
- }
321
- function cardNodeToLinkWithTransaction(state, text, href, node, pos) {
322
- var link = state.schema.marks.link;
323
- var url = node.attrs.url || node.attrs.data.url;
324
- return state.tr.replaceWith(pos, pos + node.nodeSize, state.schema.text(text || url, [link.create({
325
- href: href || url
326
- })]));
327
- }
328
- export var changeSelectedCardToText = function changeSelectedCardToText(text, editorAnalyticsApi) {
329
- return function (state, dispatch) {
330
- var selectedNode = state.selection instanceof NodeSelection && state.selection.node;
331
- if (!selectedNode) {
332
- return false;
333
- }
334
- var tr = state.tr.replaceSelectionWith(state.schema.text(text), false);
335
- if (dispatch) {
336
- addLinkMetadata(state.selection, tr, {
337
- action: ACTION.UNLINK
338
- });
339
- tr.scrollIntoView();
340
- editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent(unlinkPayload(ACTION_SUBJECT_ID.CARD_INLINE))(tr);
341
- dispatch(tr);
342
- }
343
- return true;
344
- };
345
- };
346
- export var setSelectedCardAppearance = function setSelectedCardAppearance(appearance, editorAnalyticsApi) {
347
- return function (state, dispatch) {
348
- var _previousNode$type;
349
- var selectedNode = state.selection instanceof NodeSelection && state.selection.node;
350
- if (!selectedNode) {
351
- // When there is no selected node, we insert a new one
352
- // and replace the existing blue link
353
- var _tr = convertHyperlinkToSmartCard(state, INPUT_METHOD.FLOATING_TB, appearance);
354
- if (dispatch) {
355
- addLinkMetadata(state.selection, _tr, {
356
- action: ACTION.CHANGED_TYPE
357
- });
358
- dispatch(_tr.scrollIntoView());
359
- }
360
- return false;
361
- }
362
- if (appearanceForNodeType(selectedNode.type) === appearance) {
363
- return false;
364
- }
365
- var isEmbed = appearance === 'embed';
366
- var attrs = isEmbed ? _objectSpread(_objectSpread({}, selectedNode.attrs), {}, {
367
- layout: 'center'
368
- }) : selectedNode.attrs;
369
- var _state$selection = state.selection,
370
- from = _state$selection.from,
371
- to = _state$selection.to;
372
- var nodeType = getLinkNodeType(appearance, state.schema.nodes);
373
- var tr = state.tr.setNodeMarkup(from, nodeType, attrs, selectedNode.marks);
374
-
375
- // When the selected card is the last element in the doc we add a new paragraph after it for consistent replacement
376
- if (tr.doc.nodeSize - 2 === to) {
377
- tr.insertText(' ', to);
378
- }
379
- tr.setSelection(TextSelection.create(tr.doc, to + 1));
380
- var previousNodePos = from - 1 > 0 ? from - 1 : 0;
381
- var previousNode = tr.doc.nodeAt(previousNodePos);
382
- if ((previousNode === null || previousNode === void 0 ? void 0 : (_previousNode$type = previousNode.type) === null || _previousNode$type === void 0 ? void 0 : _previousNode$type.name) === 'paragraph') {
383
- tr.delete(previousNodePos, from);
384
- }
385
- editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent({
386
- action: ACTION.CHANGED_TYPE,
387
- actionSubject: ACTION_SUBJECT.SMART_LINK,
388
- eventType: EVENT_TYPE.TRACK,
389
- attributes: {
390
- newType: appearance,
391
- previousType: appearanceForNodeType(selectedNode.type)
392
- }
393
- })(tr);
394
- addLinkMetadata(state.selection, tr, {
395
- action: ACTION.CHANGED_TYPE
396
- });
397
- if (dispatch) {
398
- dispatch(tr.scrollIntoView());
399
- }
400
- return true;
401
- };
402
- };
403
- var getLinkNodeType = function getLinkNodeType(appearance, linkNodes) {
404
- switch (appearance) {
405
- case 'inline':
406
- return linkNodes.inlineCard;
407
- case 'block':
408
- return linkNodes.blockCard;
409
- case 'embed':
410
- return linkNodes.embedCard;
411
- }
412
- };
413
-
414
- // Apply an update to a datasource (aka blockCard) node
415
- export var updateExistingDatasource = function updateExistingDatasource(state, node, newAdf, view) {
416
- var tr = state.tr,
417
- from = state.selection.from,
418
- schemaNodes = state.schema.nodes;
419
-
420
- // datasource to datasource
421
- if (newAdf.type === 'blockCard' && newAdf.attrs.datasource && node.attrs.datasource) {
422
- var _ref3, _ref6, _newViews$properties, _oldViews$properties, _newAdf$attrs, _node$attrs;
423
- var _ref = (_ref3 = newAdf.attrs.datasource.views) !== null && _ref3 !== void 0 ? _ref3 : [],
424
- _ref2 = _slicedToArray(_ref, 1),
425
- newViews = _ref2[0];
426
- var _ref4 = (_ref6 = node.attrs.datasource.views) !== null && _ref6 !== void 0 ? _ref6 : [],
427
- _ref5 = _slicedToArray(_ref4, 1),
428
- oldViews = _ref5[0];
429
- var newColumnKeys = newViews === null || newViews === void 0 ? void 0 : (_newViews$properties = newViews.properties) === null || _newViews$properties === void 0 ? void 0 : _newViews$properties.columns.map(function (column) {
430
- return column.key;
431
- });
432
- var oldColumnKeys = oldViews === null || oldViews === void 0 ? void 0 : (_oldViews$properties = oldViews.properties) === null || _oldViews$properties === void 0 ? void 0 : _oldViews$properties.columns.map(function (column) {
433
- return column.key;
434
- });
435
- var isColumnChange = !isEqual(oldColumnKeys, newColumnKeys);
436
- var isUrlChange = ((_newAdf$attrs = newAdf.attrs) === null || _newAdf$attrs === void 0 ? void 0 : _newAdf$attrs.url) !== ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.url);
437
- if (isColumnChange || isUrlChange) {
438
- tr.setNodeMarkup(from, schemaNodes.blockCard, _objectSpread(_objectSpread({}, node.attrs), newAdf.attrs));
439
- }
440
- } else if (newAdf.type === 'inlineCard') {
441
- // datasource to inline
442
- tr.setNodeMarkup(from, schemaNodes.inlineCard, newAdf.attrs);
443
- }
444
- hideDatasourceModal(tr);
445
- view.dispatch(tr.scrollIntoView());
446
- };
447
- export var insertDatasource = function insertDatasource(state, adf, view) {
448
- var tr = state.tr,
449
- from = state.selection.from,
450
- schemaNodes = state.schema.nodes;
451
- var attrs = adf.attrs,
452
- type = adf.type;
453
- var schemaNode = type === 'inlineCard' ? schemaNodes.inlineCard : schemaNodes.blockCard;
454
- var newNode = schemaNode.createChecked(attrs);
455
- // in future, if we decide to do datasource insertion from the main toolbar, we should probably consider editor-plugin-content-insertion instead of tr.insert
456
- // this will allow us to deal with insertions from multiple paths in a more consistent way
457
- newNode && tr.insert(from, newNode);
458
- hideDatasourceModal(tr);
459
- view.dispatch(tr.scrollIntoView());
460
- };
@@ -1,58 +0,0 @@
1
- import { keymap } from 'prosemirror-keymap';
2
- import { NodeSelection } from 'prosemirror-state';
3
- import { bindKeymapWithCommand, moveDown, moveUp } from '@atlaskit/editor-common/keymaps';
4
- import { findChildren, flatten } from 'prosemirror-utils';
5
- import { browser } from '@atlaskit/editor-common/utils';
6
- var lookupPixel = 10;
7
- var getClosestInlineCardPos = function getClosestInlineCardPos(state, editorView, direction) {
8
- var _editorView$posAtCoor;
9
- var selection = state.selection;
10
- var parent = selection.$from.parent;
11
- var inlineCardType = state.schema.nodes.inlineCard;
12
- if (!flatten(parent, false).some(function (_ref) {
13
- var node = _ref.node;
14
- return node.type === inlineCardType;
15
- })) {
16
- return null;
17
- }
18
- var coord = editorView.coordsAtPos(selection.$anchor.pos);
19
- var nearPos = (_editorView$posAtCoor = editorView.posAtCoords({
20
- left: coord.left,
21
- top: direction === 'up' ? coord.top - lookupPixel : coord.bottom + lookupPixel
22
- })) === null || _editorView$posAtCoor === void 0 ? void 0 : _editorView$posAtCoor.pos;
23
- if (nearPos) {
24
- var newNode = state.doc.nodeAt(nearPos);
25
- if (newNode) {
26
- if (newNode.type !== inlineCardType || findChildren(parent, function (node) {
27
- return node === newNode;
28
- }, false).length === 0 || newNode === selection.node) {
29
- return null;
30
- }
31
- return nearPos;
32
- }
33
- }
34
- return null;
35
- };
36
- var selectAboveBelowInlineCard = function selectAboveBelowInlineCard(direction) {
37
- return function (state, dispatch, editorView) {
38
- if (!editorView || !dispatch) {
39
- return false;
40
- }
41
- var pos = getClosestInlineCardPos(state, editorView, direction);
42
- if (pos) {
43
- dispatch(state.tr.setSelection(new NodeSelection(state.doc.resolve(pos))));
44
- return true;
45
- }
46
- return false;
47
- };
48
- };
49
- export function cardKeymap(featureFlags) {
50
- var list = {};
51
-
52
- // https://bugs.chromium.org/p/chromium/issues/detail?id=1227468 introduced since Chrome 91
53
- if (browser.chrome && browser.chrome_version > 90 && featureFlags.chromeCursorHandlerFixedVersion && browser.chrome_version < featureFlags.chromeCursorHandlerFixedVersion) {
54
- bindKeymapWithCommand(moveUp.common, selectAboveBelowInlineCard('up'), list);
55
- bindKeymapWithCommand(moveDown.common, selectAboveBelowInlineCard('down'), list);
56
- }
57
- return keymap(list);
58
- }