@atlaskit/editor-core 161.0.0 → 162.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (295) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/cjs/actions/index.js +76 -48
  3. package/dist/cjs/extensibility.js +2 -2
  4. package/dist/cjs/labs/next/full-page.js +1 -1
  5. package/dist/cjs/plugins/block-type/styles.js +5 -2
  6. package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/index.js +13 -11
  7. package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/styled.js +11 -7
  8. package/dist/cjs/plugins/card/messages.js +4 -4
  9. package/dist/cjs/plugins/card/ui/LinkToolbarAppearance.js +29 -11
  10. package/dist/cjs/plugins/card/ui/LinkToolbarButtonGroup.js +66 -7
  11. package/dist/cjs/plugins/card/ui/LinkToolbarIconDropdown.js +166 -7
  12. package/dist/cjs/plugins/card/ui/ResizableEmbedCard.js +9 -6
  13. package/dist/cjs/plugins/card/ui/assets/card.js +1 -1
  14. package/dist/cjs/plugins/card/ui/assets/embed.js +1 -1
  15. package/dist/cjs/plugins/card/ui/assets/inline.js +1 -1
  16. package/dist/cjs/plugins/card/ui/assets/url.js +1 -1
  17. package/dist/cjs/plugins/card/ui/link-toolbar-button-group-options.js +60 -0
  18. package/dist/cjs/plugins/card/ui/link-toolbar-icon-dropdown-options.js +66 -0
  19. package/dist/cjs/plugins/card/ui/styled.js +5 -13
  20. package/dist/cjs/plugins/card/ui/types.js +5 -0
  21. package/dist/cjs/plugins/clipboard/pm-plugins/main.js +99 -3
  22. package/dist/cjs/plugins/code-block/styles.js +45 -38
  23. package/dist/cjs/plugins/extension/plugin-factory.js +4 -1
  24. package/dist/cjs/plugins/extension/pm-plugins/main.js +34 -11
  25. package/dist/cjs/plugins/extension/utils.js +57 -12
  26. package/dist/cjs/plugins/find-replace/ui/Find.js +12 -12
  27. package/dist/cjs/plugins/find-replace/ui/FindReplace.js +5 -5
  28. package/dist/cjs/plugins/find-replace/ui/Replace.js +5 -5
  29. package/dist/cjs/plugins/find-replace/ui/styles.js +12 -15
  30. package/dist/cjs/plugins/layout/styles.js +2 -2
  31. package/dist/cjs/plugins/list/actions/wrap-and-join-lists.js +180 -0
  32. package/dist/cjs/plugins/list/commands/index.js +35 -38
  33. package/dist/cjs/plugins/list/utils/replace-content.js +31 -0
  34. package/dist/cjs/plugins/media/nodeviews/mediaNodeUpdater.js +3 -3
  35. package/dist/cjs/plugins/media/styles.js +2 -2
  36. package/dist/cjs/plugins/media/utils/media-single.js +15 -2
  37. package/dist/cjs/plugins/paste/handlers.js +19 -5
  38. package/dist/cjs/plugins/paste/pm-plugins/analytics.js +1 -1
  39. package/dist/cjs/plugins/placeholder-text/index.js +45 -1
  40. package/dist/cjs/plugins/placeholder-text/placeholder-text-nodeview.js +66 -22
  41. package/dist/cjs/plugins/placeholder-text/selection-utils.js +19 -0
  42. package/dist/cjs/plugins/placeholder-text/styles.js +3 -1
  43. package/dist/cjs/plugins/table/commands/index.js +0 -6
  44. package/dist/cjs/plugins/table/commands/insert.js +1 -1
  45. package/dist/cjs/plugins/table/commands/misc.js +5 -18
  46. package/dist/cjs/plugins/table/commands-with-analytics.js +1 -1
  47. package/dist/cjs/plugins/table/handlers.js +6 -2
  48. package/dist/cjs/plugins/table/index.js +7 -13
  49. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +2 -2
  50. package/dist/cjs/plugins/table/nodeviews/table.js +7 -38
  51. package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +2 -2
  52. package/dist/cjs/plugins/table/pm-plugins/main.js +3 -1
  53. package/dist/cjs/plugins/table/pm-plugins/plugin-factory.js +4 -7
  54. package/dist/cjs/plugins/table/pm-plugins/plugin-key.js +11 -0
  55. package/dist/cjs/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +2 -0
  56. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +3 -3
  57. package/dist/cjs/plugins/table/reducer.js +0 -7
  58. package/dist/cjs/plugins/table/toolbar.js +5 -15
  59. package/dist/cjs/plugins/table/transforms/metadata.js +2 -2
  60. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/index.js +3 -1
  61. package/dist/cjs/plugins/table/ui/FloatingInsertButton/index.js +1 -1
  62. package/dist/cjs/plugins/table/ui/LayoutButton/index.js +1 -2
  63. package/dist/cjs/plugins/table/ui/common-styles.css.js +17 -8
  64. package/dist/cjs/plugins/table/ui/ui-styles.css.js +39 -25
  65. package/dist/cjs/plugins/table/utils/nodes.js +15 -15
  66. package/dist/cjs/plugins/tasks-and-decisions/commands.js +15 -1
  67. package/dist/cjs/plugins/text-formatting/styles.js +5 -2
  68. package/dist/cjs/plugins/text-formatting/ui/Toolbar/index.js +71 -1
  69. package/dist/cjs/plugins/text-formatting/ui/Toolbar/toolbar-messages.js +30 -0
  70. package/dist/cjs/plugins/text-formatting/utils.js +30 -2
  71. package/dist/cjs/plugins/type-ahead/api.js +32 -1
  72. package/dist/cjs/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +20 -5
  73. package/dist/cjs/plugins/type-ahead/utils.js +22 -4
  74. package/dist/cjs/ui/Appearance/Comment/Comment.js +1 -1
  75. package/dist/cjs/ui/Appearance/FullPage/StyledComponents.js +1 -1
  76. package/dist/cjs/ui/ContentStyles/index.js +32 -9
  77. package/dist/cjs/utils/index.js +1 -8
  78. package/dist/cjs/utils/insert.js +1 -9
  79. package/dist/cjs/utils/selection.js +2 -9
  80. package/dist/cjs/version-wrapper.js +1 -1
  81. package/dist/cjs/version.json +1 -1
  82. package/dist/es2019/actions/index.js +20 -23
  83. package/dist/es2019/extensibility.js +1 -1
  84. package/dist/es2019/labs/next/full-page.js +2 -2
  85. package/dist/es2019/plugins/block-type/styles.js +3 -3
  86. package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/index.js +15 -12
  87. package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/styled.js +19 -14
  88. package/dist/es2019/plugins/card/messages.js +4 -4
  89. package/dist/es2019/plugins/card/ui/LinkToolbarAppearance.js +21 -9
  90. package/dist/es2019/plugins/card/ui/LinkToolbarButtonGroup.js +54 -3
  91. package/dist/es2019/plugins/card/ui/LinkToolbarIconDropdown.js +145 -3
  92. package/dist/es2019/plugins/card/ui/ResizableEmbedCard.js +10 -6
  93. package/dist/es2019/plugins/card/ui/assets/card.js +1 -1
  94. package/dist/es2019/plugins/card/ui/assets/embed.js +1 -1
  95. package/dist/es2019/plugins/card/ui/assets/inline.js +1 -1
  96. package/dist/es2019/plugins/card/ui/assets/url.js +1 -1
  97. package/dist/es2019/plugins/card/ui/link-toolbar-button-group-options.js +45 -0
  98. package/dist/es2019/plugins/card/ui/link-toolbar-icon-dropdown-options.js +51 -0
  99. package/dist/es2019/plugins/card/ui/styled.js +2 -2
  100. package/dist/es2019/plugins/card/ui/types.js +1 -0
  101. package/dist/es2019/plugins/clipboard/pm-plugins/main.js +91 -9
  102. package/dist/es2019/plugins/code-block/styles.js +14 -14
  103. package/dist/es2019/plugins/extension/plugin-factory.js +3 -1
  104. package/dist/es2019/plugins/extension/pm-plugins/main.js +38 -12
  105. package/dist/es2019/plugins/extension/utils.js +37 -2
  106. package/dist/es2019/plugins/find-replace/ui/Find.js +1 -1
  107. package/dist/es2019/plugins/find-replace/ui/FindReplace.js +1 -1
  108. package/dist/es2019/plugins/find-replace/ui/Replace.js +1 -1
  109. package/dist/es2019/plugins/find-replace/ui/styles.js +14 -9
  110. package/dist/es2019/plugins/layout/styles.js +5 -1
  111. package/dist/es2019/plugins/list/actions/wrap-and-join-lists.js +163 -0
  112. package/dist/es2019/plugins/list/commands/index.js +29 -28
  113. package/dist/es2019/plugins/list/utils/replace-content.js +22 -0
  114. package/dist/es2019/plugins/media/nodeviews/mediaNodeUpdater.js +3 -3
  115. package/dist/es2019/plugins/media/styles.js +1 -1
  116. package/dist/es2019/plugins/media/utils/media-single.js +14 -1
  117. package/dist/es2019/plugins/paste/handlers.js +19 -5
  118. package/dist/es2019/plugins/paste/pm-plugins/analytics.js +2 -2
  119. package/dist/es2019/plugins/placeholder-text/index.js +46 -1
  120. package/dist/es2019/plugins/placeholder-text/placeholder-text-nodeview.js +66 -20
  121. package/dist/es2019/plugins/placeholder-text/selection-utils.js +9 -0
  122. package/dist/es2019/plugins/placeholder-text/styles.js +22 -0
  123. package/dist/es2019/plugins/table/commands/index.js +1 -1
  124. package/dist/es2019/plugins/table/commands/insert.js +1 -1
  125. package/dist/es2019/plugins/table/commands/misc.js +5 -11
  126. package/dist/es2019/plugins/table/commands-with-analytics.js +1 -1
  127. package/dist/es2019/plugins/table/handlers.js +6 -2
  128. package/dist/es2019/plugins/table/index.js +4 -8
  129. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +2 -2
  130. package/dist/es2019/plugins/table/nodeviews/table.js +2 -16
  131. package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +1 -1
  132. package/dist/es2019/plugins/table/pm-plugins/main.js +2 -1
  133. package/dist/es2019/plugins/table/pm-plugins/plugin-factory.js +1 -2
  134. package/dist/es2019/plugins/table/pm-plugins/plugin-key.js +2 -0
  135. package/dist/es2019/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +2 -0
  136. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +1 -1
  137. package/dist/es2019/plugins/table/reducer.js +0 -9
  138. package/dist/es2019/plugins/table/toolbar.js +1 -4
  139. package/dist/es2019/plugins/table/transforms/metadata.js +1 -1
  140. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/index.js +2 -1
  141. package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +1 -1
  142. package/dist/es2019/plugins/table/ui/LayoutButton/index.js +1 -2
  143. package/dist/es2019/plugins/table/ui/common-styles.css.js +51 -26
  144. package/dist/es2019/plugins/table/ui/ui-styles.css.js +57 -56
  145. package/dist/es2019/plugins/table/utils/nodes.js +11 -11
  146. package/dist/es2019/plugins/tasks-and-decisions/commands.js +13 -1
  147. package/dist/es2019/plugins/text-formatting/styles.js +3 -3
  148. package/dist/es2019/plugins/text-formatting/ui/Toolbar/index.js +61 -2
  149. package/dist/es2019/plugins/text-formatting/ui/Toolbar/toolbar-messages.js +30 -0
  150. package/dist/es2019/plugins/text-formatting/utils.js +13 -1
  151. package/dist/es2019/plugins/type-ahead/api.js +31 -2
  152. package/dist/es2019/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +17 -5
  153. package/dist/es2019/plugins/type-ahead/utils.js +15 -0
  154. package/dist/es2019/ui/Appearance/Comment/Comment.js +2 -2
  155. package/dist/es2019/ui/Appearance/FullPage/StyledComponents.js +2 -2
  156. package/dist/es2019/ui/ContentStyles/index.js +45 -23
  157. package/dist/es2019/utils/index.js +1 -1
  158. package/dist/es2019/utils/insert.js +2 -10
  159. package/dist/es2019/utils/selection.js +1 -6
  160. package/dist/es2019/version-wrapper.js +1 -1
  161. package/dist/es2019/version.json +1 -1
  162. package/dist/esm/actions/index.js +76 -48
  163. package/dist/esm/extensibility.js +1 -1
  164. package/dist/esm/labs/next/full-page.js +2 -2
  165. package/dist/esm/plugins/block-type/styles.js +4 -2
  166. package/dist/esm/plugins/block-type/ui/ToolbarBlockType/index.js +14 -12
  167. package/dist/esm/plugins/block-type/ui/ToolbarBlockType/styled.js +9 -5
  168. package/dist/esm/plugins/card/messages.js +4 -4
  169. package/dist/esm/plugins/card/ui/LinkToolbarAppearance.js +25 -9
  170. package/dist/esm/plugins/card/ui/LinkToolbarButtonGroup.js +57 -5
  171. package/dist/esm/plugins/card/ui/LinkToolbarIconDropdown.js +154 -5
  172. package/dist/esm/plugins/card/ui/ResizableEmbedCard.js +9 -6
  173. package/dist/esm/plugins/card/ui/assets/card.js +1 -1
  174. package/dist/esm/plugins/card/ui/assets/embed.js +1 -1
  175. package/dist/esm/plugins/card/ui/assets/inline.js +1 -1
  176. package/dist/esm/plugins/card/ui/assets/url.js +1 -1
  177. package/dist/esm/plugins/card/ui/link-toolbar-button-group-options.js +45 -0
  178. package/dist/esm/plugins/card/ui/link-toolbar-icon-dropdown-options.js +51 -0
  179. package/dist/esm/plugins/card/ui/styled.js +2 -2
  180. package/dist/esm/plugins/card/ui/types.js +1 -0
  181. package/dist/esm/plugins/clipboard/pm-plugins/main.js +91 -2
  182. package/dist/esm/plugins/code-block/styles.js +42 -38
  183. package/dist/esm/plugins/extension/plugin-factory.js +3 -1
  184. package/dist/esm/plugins/extension/pm-plugins/main.js +34 -11
  185. package/dist/esm/plugins/extension/utils.js +51 -9
  186. package/dist/esm/plugins/find-replace/ui/Find.js +1 -1
  187. package/dist/esm/plugins/find-replace/ui/FindReplace.js +1 -1
  188. package/dist/esm/plugins/find-replace/ui/Replace.js +1 -1
  189. package/dist/esm/plugins/find-replace/ui/styles.js +6 -10
  190. package/dist/esm/plugins/layout/styles.js +2 -2
  191. package/dist/esm/plugins/list/actions/wrap-and-join-lists.js +168 -0
  192. package/dist/esm/plugins/list/commands/index.js +33 -34
  193. package/dist/esm/plugins/list/utils/replace-content.js +21 -0
  194. package/dist/esm/plugins/media/nodeviews/mediaNodeUpdater.js +3 -3
  195. package/dist/esm/plugins/media/styles.js +1 -1
  196. package/dist/esm/plugins/media/utils/media-single.js +12 -1
  197. package/dist/esm/plugins/paste/handlers.js +19 -5
  198. package/dist/esm/plugins/paste/pm-plugins/analytics.js +2 -2
  199. package/dist/esm/plugins/placeholder-text/index.js +44 -1
  200. package/dist/esm/plugins/placeholder-text/placeholder-text-nodeview.js +67 -20
  201. package/dist/esm/plugins/placeholder-text/selection-utils.js +9 -0
  202. package/dist/esm/plugins/placeholder-text/styles.js +2 -1
  203. package/dist/esm/plugins/table/commands/index.js +1 -1
  204. package/dist/esm/plugins/table/commands/insert.js +1 -1
  205. package/dist/esm/plugins/table/commands/misc.js +5 -15
  206. package/dist/esm/plugins/table/commands-with-analytics.js +1 -1
  207. package/dist/esm/plugins/table/handlers.js +6 -2
  208. package/dist/esm/plugins/table/index.js +6 -11
  209. package/dist/esm/plugins/table/nodeviews/TableComponent.js +2 -2
  210. package/dist/esm/plugins/table/nodeviews/table.js +6 -37
  211. package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +1 -1
  212. package/dist/esm/plugins/table/pm-plugins/main.js +2 -1
  213. package/dist/esm/plugins/table/pm-plugins/plugin-factory.js +1 -2
  214. package/dist/esm/plugins/table/pm-plugins/plugin-key.js +2 -0
  215. package/dist/esm/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +2 -0
  216. package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +1 -1
  217. package/dist/esm/plugins/table/reducer.js +0 -7
  218. package/dist/esm/plugins/table/toolbar.js +1 -10
  219. package/dist/esm/plugins/table/transforms/metadata.js +1 -1
  220. package/dist/esm/plugins/table/ui/FloatingContextualMenu/index.js +2 -1
  221. package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +1 -1
  222. package/dist/esm/plugins/table/ui/LayoutButton/index.js +1 -2
  223. package/dist/esm/plugins/table/ui/common-styles.css.js +10 -6
  224. package/dist/esm/plugins/table/ui/ui-styles.css.js +20 -11
  225. package/dist/esm/plugins/table/utils/nodes.js +14 -14
  226. package/dist/esm/plugins/tasks-and-decisions/commands.js +13 -1
  227. package/dist/esm/plugins/text-formatting/styles.js +4 -2
  228. package/dist/esm/plugins/text-formatting/ui/Toolbar/index.js +69 -2
  229. package/dist/esm/plugins/text-formatting/ui/Toolbar/toolbar-messages.js +30 -0
  230. package/dist/esm/plugins/text-formatting/utils.js +18 -0
  231. package/dist/esm/plugins/type-ahead/api.js +30 -2
  232. package/dist/esm/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +16 -4
  233. package/dist/esm/plugins/type-ahead/utils.js +17 -3
  234. package/dist/esm/ui/Appearance/Comment/Comment.js +2 -2
  235. package/dist/esm/ui/Appearance/FullPage/StyledComponents.js +2 -2
  236. package/dist/esm/ui/ContentStyles/index.js +27 -9
  237. package/dist/esm/utils/index.js +1 -1
  238. package/dist/esm/utils/insert.js +2 -10
  239. package/dist/esm/utils/selection.js +1 -6
  240. package/dist/esm/version-wrapper.js +1 -1
  241. package/dist/esm/version.json +1 -1
  242. package/dist/types/actions/index.d.ts +2 -2
  243. package/dist/types/extensibility.d.ts +1 -1
  244. package/dist/types/plugins/analytics/types/list-events.d.ts +0 -1
  245. package/dist/types/plugins/block-type/styles.d.ts +2 -1
  246. package/dist/types/plugins/block-type/ui/ToolbarBlockType/index.d.ts +1 -0
  247. package/dist/types/plugins/block-type/ui/ToolbarBlockType/styled.d.ts +2 -7
  248. package/dist/types/plugins/card/messages.d.ts +2 -2
  249. package/dist/types/plugins/card/ui/LinkToolbarButtonGroup.d.ts +18 -2
  250. package/dist/types/plugins/card/ui/LinkToolbarIconDropdown.d.ts +23 -3
  251. package/dist/types/plugins/card/ui/ResizableEmbedCard.d.ts +3 -1
  252. package/dist/types/plugins/card/ui/link-toolbar-button-group-options.d.ts +5 -0
  253. package/dist/types/plugins/card/ui/link-toolbar-icon-dropdown-options.d.ts +5 -0
  254. package/dist/types/plugins/card/ui/styled.d.ts +2 -3
  255. package/dist/types/plugins/card/ui/types.d.ts +12 -0
  256. package/dist/types/plugins/clipboard/pm-plugins/main.d.ts +10 -1
  257. package/dist/types/plugins/code-block/styles.d.ts +3 -2
  258. package/dist/types/plugins/extension/pm-plugins/main.d.ts +2 -1
  259. package/dist/types/plugins/extension/types.d.ts +1 -0
  260. package/dist/types/plugins/extension/utils.d.ts +3 -1
  261. package/dist/types/plugins/find-replace/ui/FindReplace.d.ts +2 -1
  262. package/dist/types/plugins/find-replace/ui/styles.d.ts +5 -5
  263. package/dist/types/plugins/layout/styles.d.ts +1 -1
  264. package/dist/types/plugins/list/actions/wrap-and-join-lists.d.ts +25 -0
  265. package/dist/types/plugins/list/commands/index.d.ts +0 -1
  266. package/dist/types/plugins/list/utils/replace-content.d.ts +8 -0
  267. package/dist/types/plugins/media/nodeviews/mediaNodeUpdater.d.ts +2 -2
  268. package/dist/types/plugins/media/styles.d.ts +1 -1
  269. package/dist/types/plugins/media/utils/media-single.d.ts +1 -0
  270. package/dist/types/plugins/panel/styles.d.ts +1 -1
  271. package/dist/types/plugins/paste/handlers.d.ts +1 -1
  272. package/dist/types/plugins/placeholder-text/placeholder-text-nodeview.d.ts +3 -2
  273. package/dist/types/plugins/placeholder-text/selection-utils.d.ts +2 -0
  274. package/dist/types/plugins/rule/styles.d.ts +1 -1
  275. package/dist/types/plugins/table/commands/index.d.ts +1 -1
  276. package/dist/types/plugins/table/commands/misc.d.ts +0 -1
  277. package/dist/types/plugins/table/nodeviews/table.d.ts +0 -1
  278. package/dist/types/plugins/table/pm-plugins/plugin-factory.d.ts +1 -4
  279. package/dist/types/plugins/table/pm-plugins/plugin-key.d.ts +3 -0
  280. package/dist/types/plugins/table/types.d.ts +1 -8
  281. package/dist/types/plugins/table/ui/LayoutButton/index.d.ts +0 -1
  282. package/dist/types/plugins/table/ui/common-styles.css.d.ts +6 -3
  283. package/dist/types/plugins/table/ui/ui-styles.css.d.ts +15 -14
  284. package/dist/types/plugins/table/utils/nodes.d.ts +6 -6
  285. package/dist/types/plugins/text-formatting/pm-plugins/smart-input-rule.d.ts +1 -1
  286. package/dist/types/plugins/text-formatting/styles.d.ts +2 -1
  287. package/dist/types/plugins/text-formatting/ui/Toolbar/toolbar-messages.d.ts +30 -0
  288. package/dist/types/plugins/text-formatting/utils.d.ts +4 -0
  289. package/dist/types/plugins/type-ahead/api.d.ts +11 -1
  290. package/dist/types/plugins/type-ahead/transforms/open-typeahead-at-cursor.d.ts +1 -0
  291. package/dist/types/plugins/type-ahead/utils.d.ts +4 -0
  292. package/dist/types/ui/ContentStyles/index.d.ts +1 -0
  293. package/dist/types/utils/index.d.ts +1 -1
  294. package/dist/types/utils/selection.d.ts +0 -1
  295. package/package.json +28 -26
@@ -251,6 +251,7 @@ var createPlugin = function createPlugin(dispatch, providerFactory, extensionHan
251
251
  var useLongPressSelection = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
252
252
  var options = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : {};
253
253
  var state = createPluginState(dispatch, {
254
+ shouldRefreshEditButton: false,
254
255
  showEditButton: false,
255
256
  showContextPanel: false
256
257
  });
@@ -274,25 +275,45 @@ var createPlugin = function createPlugin(dispatch, providerFactory, extensionHan
274
275
  element = _getPluginState.element,
275
276
  localId = _getPluginState.localId,
276
277
  extensionProvider = _getPluginState.extensionProvider,
277
- showContextPanel = _getPluginState.showContextPanel; // This fetches the selected extension node, either by keyboard selection or click for all types of extensions
278
+ showContextPanel = _getPluginState.showContextPanel,
279
+ shouldRefreshEditButton = _getPluginState.shouldRefreshEditButton;
278
280
 
281
+ if (!shouldRefreshEditButton) {
282
+ return false;
283
+ } // This fetches the selected extension node, either by keyboard selection or click for all types of extensions
279
284
 
280
- var selectedExtension = getSelectedExtension(state, true);
285
+
286
+ var selectedExtension = getSelectedExtension(state, true); // If our selection isn't on an extension node, clear some state and hide the config panel
281
287
 
282
288
  if (!selectedExtension) {
283
289
  if (showContextPanel) {
284
290
  clearEditingContext(state, dispatch);
285
291
  }
286
292
 
293
+ updateState({
294
+ shouldRefreshEditButton: false,
295
+ localId: undefined,
296
+ element: undefined,
297
+ showEditButton: false,
298
+ updateExtension: undefined
299
+ })(state, dispatch);
287
300
  return;
288
- }
301
+ } // By this point we're certain we've selected an extension node.
302
+ // But we need to determine if the selection has changed to another
303
+ // extension node or remained on the same node.
304
+
289
305
 
290
306
  var node = selectedExtension.node;
291
307
  var newElement = getSelectedDomElement(state.schema, domAtPos, selectedExtension); // New node is selection
292
308
 
293
- if (node.attrs.localId ? localId !== node.attrs.localId : // This is the current assumption and it's wrong but we are keeping it
309
+ var hasSelectedNodeChanged = node.attrs.localId ? localId !== node.attrs.localId : // This is the current assumption and it's wrong but we are keeping it
294
310
  // as fallback in case we need to turn off `allowLocalIdGeneration`
295
- element !== newElement) {
311
+ element !== newElement;
312
+ var nextState = {
313
+ shouldRefreshEditButton: false
314
+ };
315
+
316
+ if (hasSelectedNodeChanged) {
296
317
  if (showContextPanel) {
297
318
  clearEditingContext(state, dispatch);
298
319
  }
@@ -303,20 +324,20 @@ var createPlugin = function createPlugin(dispatch, providerFactory, extensionHan
303
324
  var showEditButton = shouldShowEditButton(extensionHandler, extensionProvider);
304
325
  var updateExtension = getUpdateExtensionPromise(view, extensionHandler, extensionProvider).catch(function () {// do nothing;
305
326
  });
306
- updateState({
327
+ Object.assign(nextState, {
307
328
  localId: node.attrs.localId,
308
- showContextPanel: false,
309
329
  element: newElement,
310
330
  showEditButton: showEditButton,
311
331
  updateExtension: updateExtension
312
- })(state, dispatch);
332
+ });
313
333
  } // New DOM element doesn't necessarily mean it's a new Node
314
334
  else if (element !== newElement) {
315
- updateState({
335
+ Object.assign(nextState, {
316
336
  element: newElement
317
- })(state, dispatch);
337
+ });
318
338
  }
319
339
 
340
+ updateState(nextState)(state, dispatch);
320
341
  return true;
321
342
  },
322
343
  destroy: function destroy() {
@@ -333,7 +354,9 @@ var createPlugin = function createPlugin(dispatch, providerFactory, extensionHan
333
354
  inlineExtension: ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions)
334
355
  },
335
356
  handleClickOn: createSelectionClickHandler(['extension', 'bodiedExtension'], function (target) {
336
- return !target.closest('.extension-content');
357
+ // Clicked on anything around the extension content
358
+ // or specifically on the content border of a bodied extension
359
+ return !target.closest('.extension-content') || target.classList.contains('extension-content');
337
360
  }, {
338
361
  useLongPressSelection: useLongPressSelection
339
362
  })
@@ -1,15 +1,32 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
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
+
5
+ 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; }
6
+
1
7
  import { findParentNodeOfType, findSelectedNodeOfType, findDomRefAtPos } from 'prosemirror-utils';
2
8
  import { closestElement } from '../../utils/dom';
3
9
  import { findNodePosByLocalIds } from '../../utils/nodes-by-localIds';
10
+
11
+ var getSelectedExtensionByTransaction = function getSelectedExtensionByTransaction(transaction) {
12
+ var searchParent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
13
+ return _getSelectedExtension(transaction.doc.type.schema, transaction.selection, searchParent);
14
+ };
15
+
4
16
  export var getSelectedExtension = function getSelectedExtension(state) {
5
17
  var searchParent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
6
- var _state$schema$nodes = state.schema.nodes,
7
- inlineExtension = _state$schema$nodes.inlineExtension,
8
- extension = _state$schema$nodes.extension,
9
- bodiedExtension = _state$schema$nodes.bodiedExtension;
18
+ return _getSelectedExtension(state.schema, state.selection, searchParent);
19
+ };
20
+
21
+ var _getSelectedExtension = function _getSelectedExtension(schema, selection, searchParent) {
22
+ var _schema$nodes = schema.nodes,
23
+ inlineExtension = _schema$nodes.inlineExtension,
24
+ extension = _schema$nodes.extension,
25
+ bodiedExtension = _schema$nodes.bodiedExtension;
10
26
  var nodeTypes = [extension, bodiedExtension, inlineExtension];
11
- return findSelectedNodeOfType(nodeTypes)(state.selection) || searchParent && findParentNodeOfType(nodeTypes)(state.selection) || undefined;
27
+ return findSelectedNodeOfType(nodeTypes)(selection) || searchParent && findParentNodeOfType(nodeTypes)(selection) || undefined;
12
28
  };
29
+
13
30
  export var findExtensionWithLocalId = function findExtensionWithLocalId(state, localId) {
14
31
  var selectedExtension = getSelectedExtension(state, true);
15
32
 
@@ -21,10 +38,10 @@ export var findExtensionWithLocalId = function findExtensionWithLocalId(state, l
21
38
  return selectedExtension;
22
39
  }
23
40
 
24
- var _state$schema$nodes2 = state.schema.nodes,
25
- inlineExtension = _state$schema$nodes2.inlineExtension,
26
- extension = _state$schema$nodes2.extension,
27
- bodiedExtension = _state$schema$nodes2.bodiedExtension;
41
+ var _state$schema$nodes = state.schema.nodes,
42
+ inlineExtension = _state$schema$nodes.inlineExtension,
43
+ extension = _state$schema$nodes.extension,
44
+ bodiedExtension = _state$schema$nodes.bodiedExtension;
28
45
  var nodeTypes = [extension, bodiedExtension, inlineExtension];
29
46
  var matched;
30
47
  state.doc.descendants(function (node, pos) {
@@ -64,4 +81,29 @@ export var getNodeTypesReferenced = function getNodeTypesReferenced(ids, state)
64
81
  export var findNodePosWithLocalId = function findNodePosWithLocalId(state, localId) {
65
82
  var nodes = findNodePosByLocalIds(state, [localId]);
66
83
  return nodes.length >= 1 ? nodes[0] : undefined;
84
+ };
85
+ export var onSelectionChanged = function onSelectionChanged(tr, state) {
86
+ var selectedExtension = getSelectedExtensionByTransaction(tr, true);
87
+ var hasUnselectedExtension = !!state.element && !selectedExtension;
88
+ /*
89
+ * We use this to indicate to our plugin that the selection has changed.
90
+ *
91
+ * - ignore if shouldRefreshEditButton already set
92
+ * - restrict to scenarios when an extension is
93
+ * - a) actually selected
94
+ * - b) or un-selected (not accounting for selection extensionA -> extensionB)
95
+ *
96
+ * The rest of the logic will be handled in Extension main plugin view update().
97
+ *
98
+ * Known issue: typing inside of a bodiedExtension will trigger state changes each keystroke
99
+ * as the toolbar always being open while it is focused.
100
+ */
101
+
102
+ if (!state.shouldRefreshEditButton && (selectedExtension || hasUnselectedExtension)) {
103
+ return _objectSpread(_objectSpread({}, state), {}, {
104
+ shouldRefreshEditButton: true
105
+ });
106
+ }
107
+
108
+ return state;
67
109
  };
@@ -12,7 +12,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
12
12
 
13
13
  /** @jsx jsx */
14
14
  import React from 'react';
15
- import { jsx } from '@emotion/core';
15
+ import { jsx } from '@emotion/react';
16
16
  import { defineMessages, injectIntl } from 'react-intl-next';
17
17
  import EditorCloseIcon from '@atlaskit/icon/glyph/editor/close';
18
18
  import ChevronDownIcon from '@atlaskit/icon/glyph/hipchat/chevron-down';
@@ -12,7 +12,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
12
12
 
13
13
  /** @jsx jsx */
14
14
  import React from 'react';
15
- import { jsx } from '@emotion/core';
15
+ import { jsx } from '@emotion/react';
16
16
  import Find from './Find';
17
17
  import Replace from './Replace';
18
18
  import { ruleStyles, wrapperStyles } from './styles';
@@ -12,7 +12,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
12
12
 
13
13
  /** @jsx jsx */
14
14
  import React from 'react';
15
- import { jsx } from '@emotion/core';
15
+ import { jsx } from '@emotion/react';
16
16
  import Button from '@atlaskit/button/standard-button';
17
17
  import { defineMessages, injectIntl } from 'react-intl-next';
18
18
  import Textfield from '@atlaskit/textfield';
@@ -1,5 +1,9 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+
3
+ var _templateObject;
4
+
1
5
  /** @jsx jsx */
2
- import { css } from '@emotion/core';
6
+ import { css } from '@emotion/react';
3
7
  import { N60, N30A } from '@atlaskit/theme/colors';
4
8
  import { relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
5
9
  export var replaceSectionButtonStyles = css({
@@ -20,15 +24,7 @@ export var wrapperStyles = css({
20
24
  margin: '0px 4px'
21
25
  }
22
26
  });
23
- export var sectionWrapperStyles = css({
24
- display: 'flex',
25
- alignItems: 'column',
26
- '> *': {
27
- display: 'inline-flex',
28
- height: '32px',
29
- flex: '0 0 auto'
30
- }
31
- });
27
+ export var sectionWrapperStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n\n & > * {\n display: inline-flex;\n height: 32px;\n flex: 0 0 auto;\n }\n\n & > [data-ds--text-field--container] {\n display: flex;\n flex: 1 1 auto;\n }\n"])));
32
28
  export var countStyles = css({
33
29
  color: "".concat(N60),
34
30
  fontSize: "".concat(relativeFontSizeToBase16(12)),
@@ -2,7 +2,7 @@ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral
2
2
 
3
3
  var _templateObject;
4
4
 
5
- import { css } from 'styled-components';
5
+ import { css } from '@emotion/react';
6
6
  import { gridSize } from '@atlaskit/theme/constants';
7
7
  import { N40A, N50A } from '@atlaskit/theme/colors';
8
8
  import { columnLayoutSharedStyle } from '@atlaskit/editor-common/styles';
@@ -11,4 +11,4 @@ import { TableCssClassName } from '../table/types';
11
11
  import { tableMarginFullWidthMode } from '../table/ui/consts';
12
12
  export var LAYOUT_SECTION_MARGIN = gridSize();
13
13
  export var LAYOUT_COLUMN_PADDING = gridSize() * 1.5;
14
- export var layoutStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ProseMirror {\n ", " [data-layout-section] {\n margin: ", "px -", "px 0;\n transition: border-color 0.3s ", ";\n cursor: pointer;\n\n /* Inner cursor located 26px from left */\n [data-layout-column] {\n flex: 1;\n min-width: 0;\n border: ", "px solid ", ";\n border-radius: 4px;\n padding: ", "px;\n box-sizing: border-box;\n\n > div {\n > *:first-child {\n margin-top: 0;\n }\n\n > .ProseMirror-gapcursor.-right:first-child + * {\n margin-top: 0;\n }\n\n > .ProseMirror-gapcursor:first-child + span + * {\n margin-top: 0;\n }\n\n > .mediaSingleView-content-wrap:first-child .rich-media-item {\n margin-top: 0;\n }\n\n > .ProseMirror-gapcursor.-right:first-child\n + .mediaSingleView-content-wrap\n .rich-media-item {\n margin-top: 0;\n }\n\n > .ProseMirror-gapcursor:first-child\n + span\n + .mediaSingleView-content-wrap\n .rich-media-item {\n margin-top: 0;\n }\n\n /* Prevent first DecisionWrapper's margin-top: 8px from shifting decisions down\n and shrinking layout's node selectable area (leniency margin) */\n > [data-node-type='decisionList'] {\n li:first-of-type [data-decision-wrapper] {\n margin-top: 0;\n }\n }\n }\n\n /* Make the 'content' fill the entire height of the layout column to allow click\n handler of layout section nodeview to target only data-layout-column */\n [data-layout-content] {\n height: 100%;\n cursor: text;\n }\n }\n\n [data-layout-column] + [data-layout-column] {\n margin-left: ", "px;\n }\n\n @media screen and (max-width: ", "px) {\n [data-layout-column] + [data-layout-column] {\n margin-left: 0;\n }\n }\n\n /* Shows the border when cursor is inside a layout */\n &.selected [data-layout-column],\n &:hover [data-layout-column] {\n border-color: ", ";\n }\n\n &.selected.danger > [data-layout-column] {\n background-color: ", ";\n border-color: ", ";\n }\n\n &.", ":not(.danger) {\n [data-layout-column] {\n ", "\n }\n }\n }\n }\n\n .fabric-editor--full-width-mode .ProseMirror {\n [data-layout-section] {\n .", " {\n margin: 0 ", "px;\n }\n }\n }\n"])), columnLayoutSharedStyle, gridSize() - 1, akLayoutGutterOffset, akEditorSwoopCubicBezier, akEditorSelectedBorderSize, N40A, LAYOUT_COLUMN_PADDING, LAYOUT_SECTION_MARGIN, gridMediumMaxWidth, N50A, akEditorDeleteBackground, akEditorDeleteBorder, akEditorSelectedNodeClassName, getSelectionStyles([SelectionStyle.Border, SelectionStyle.Blanket]), TableCssClassName.TABLE_CONTAINER, tableMarginFullWidthMode);
14
+ export var layoutStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ProseMirror {\n ", " [data-layout-section] {\n margin: ", "px -", "px 0;\n transition: border-color 0.3s ", ";\n cursor: pointer;\n\n /* Inner cursor located 26px from left */\n [data-layout-column] {\n flex: 1;\n min-width: 0;\n border: ", "px solid ", ";\n border-radius: 4px;\n padding: ", "px;\n box-sizing: border-box;\n\n > div {\n > *:first-child {\n margin-top: 0;\n }\n\n > .ProseMirror-gapcursor.-right:first-child + * {\n margin-top: 0;\n }\n\n > .ProseMirror-gapcursor:first-child + span + * {\n margin-top: 0;\n }\n\n .rich-media-item {\n margin-top: 0;\n }\n\n > .mediaSingleView-content-wrap:first-child .rich-media-item {\n margin-top: 0;\n }\n\n > .ProseMirror-gapcursor.-right:first-child\n + .mediaSingleView-content-wrap\n .rich-media-item {\n margin-top: 0;\n }\n\n > .ProseMirror-gapcursor:first-child\n + span\n + .mediaSingleView-content-wrap\n .rich-media-item {\n margin-top: 0;\n }\n\n /* Prevent first DecisionWrapper's margin-top: 8px from shifting decisions down\n and shrinking layout's node selectable area (leniency margin) */\n > [data-node-type='decisionList'] {\n li:first-of-type [data-decision-wrapper] {\n margin-top: 0;\n }\n }\n }\n\n /* Make the 'content' fill the entire height of the layout column to allow click\n handler of layout section nodeview to target only data-layout-column */\n [data-layout-content] {\n height: 100%;\n cursor: text;\n }\n }\n\n [data-layout-column] + [data-layout-column] {\n margin-left: ", "px;\n }\n\n @media screen and (max-width: ", "px) {\n [data-layout-column] + [data-layout-column] {\n margin-left: 0;\n }\n }\n\n /* Shows the border when cursor is inside a layout */\n &.selected [data-layout-column],\n &:hover [data-layout-column] {\n border-color: ", ";\n }\n\n &.selected.danger > [data-layout-column] {\n background-color: ", ";\n border-color: ", ";\n }\n\n &.", ":not(.danger) {\n [data-layout-column] {\n ", "\n }\n }\n }\n }\n\n .fabric-editor--full-width-mode .ProseMirror {\n [data-layout-section] {\n .", " {\n margin: 0 ", "px;\n }\n }\n }\n"])), columnLayoutSharedStyle, gridSize() - 1, akLayoutGutterOffset, akEditorSwoopCubicBezier, akEditorSelectedBorderSize, N40A, LAYOUT_COLUMN_PADDING, LAYOUT_SECTION_MARGIN, gridMediumMaxWidth, N50A, akEditorDeleteBackground, akEditorDeleteBorder, akEditorSelectedNodeClassName, getSelectionStyles([SelectionStyle.Border, SelectionStyle.Blanket]), TableCssClassName.TABLE_CONTAINER, tableMarginFullWidthMode);
@@ -0,0 +1,168 @@
1
+ import { Fragment, Slice, NodeRange } from 'prosemirror-model';
2
+ import { ReplaceAroundStep, findWrapping, canSplit, canJoin } from 'prosemirror-transform';
3
+ /**
4
+ * Wraps the selection in a list with the given type. If this results in
5
+ * two adjacent lists of the same type, those will be joined together.
6
+ */
7
+
8
+ export function wrapInListAndJoin(nodeType, tr) {
9
+ wrapInList(nodeType)(tr);
10
+ autoJoin(tr, function (before, after) {
11
+ return before.type === after.type && before.type === nodeType;
12
+ });
13
+ }
14
+ /**
15
+ * Wraps the selection in a list with the given type and attributes.
16
+ *
17
+ * Adapted from https://github.com/ProseMirror/prosemirror-schema-list/blob/master/src/schema-list.js#L64-L89
18
+ */
19
+
20
+ export function wrapInList(listType, attrs) {
21
+ return function (tr) {
22
+ var _tr$selection = tr.selection,
23
+ $from = _tr$selection.$from,
24
+ $to = _tr$selection.$to;
25
+ var range = $from.blockRange($to);
26
+ var doJoin = false;
27
+ var outerRange = range;
28
+
29
+ if (!range) {
30
+ return false;
31
+ } // This is at the top of an existing list item
32
+
33
+
34
+ if (range.depth >= 2 && // @ts-ignore - missing type for compatibleContent
35
+ $from.node(range.depth - 1).type.compatibleContent(listType) && range.startIndex === 0) {
36
+ // Don't do anything if this is the top of the list
37
+ if ($from.index(range.depth - 1) === 0) {
38
+ return false;
39
+ }
40
+
41
+ var $insert = tr.doc.resolve(range.start - 2);
42
+ outerRange = new NodeRange($insert, $insert, range.depth);
43
+
44
+ if (range.endIndex < range.parent.childCount) {
45
+ range = new NodeRange($from, tr.doc.resolve($to.end(range.depth)), range.depth);
46
+ }
47
+
48
+ doJoin = true;
49
+ }
50
+
51
+ var wrap = findWrapping(outerRange, listType, attrs, range);
52
+
53
+ if (!wrap) {
54
+ return false;
55
+ }
56
+
57
+ tr = doWrapInList(tr, range, wrap, doJoin, listType);
58
+ return true;
59
+ };
60
+ }
61
+ /**
62
+ * Internal function used by wrapInList
63
+ *
64
+ * Adapted from https://github.com/ProseMirror/prosemirror-schema-list/blob/master/src/schema-list.js#L91-L112
65
+ */
66
+
67
+ function doWrapInList(tr, range, wrappers, joinBefore, listType) {
68
+ var content = Fragment.empty;
69
+
70
+ for (var i = wrappers.length - 1; i >= 0; i--) {
71
+ content = Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content));
72
+ }
73
+
74
+ tr.step(new ReplaceAroundStep(range.start - (joinBefore ? 2 : 0), range.end, range.start, range.end, new Slice(content, 0, 0), wrappers.length, true));
75
+ var found = 0;
76
+
77
+ for (var _i = 0; _i < wrappers.length; _i++) {
78
+ if (wrappers[_i].type === listType) {
79
+ found = _i + 1;
80
+ }
81
+ }
82
+
83
+ var splitDepth = wrappers.length - found;
84
+ var splitPos = range.start + wrappers.length - (joinBefore ? 2 : 0);
85
+ var parent = range.parent;
86
+
87
+ for (var _i2 = range.startIndex, e = range.endIndex, first = true; _i2 < e; _i2++, first = false) {
88
+ if (!first && canSplit(tr.doc, splitPos, splitDepth)) {
89
+ tr.split(splitPos, splitDepth);
90
+ splitPos += 2 * splitDepth;
91
+ }
92
+
93
+ splitPos += parent.child(_i2).nodeSize;
94
+ }
95
+
96
+ return tr;
97
+ }
98
+ /**
99
+ * Checks whether two adjacent nodes can be joined. If so, the document
100
+ * will be updated to join those nodes. If not, the original transaction
101
+ * remains untouched.
102
+ *
103
+ * Nodes are considered joinable if the `isJoinable` predicate returns true.
104
+ *
105
+ * Adapted from https://github.com/ProseMirror/prosemirror-commands/blob/master/src/commands.js#L597-L610
106
+ */
107
+
108
+
109
+ export function autoJoin(tr, isJoinable) {
110
+ if (!tr.isGeneric) {
111
+ return;
112
+ }
113
+
114
+ var ranges = [];
115
+
116
+ for (var i = 0; i < tr.mapping.maps.length; i++) {
117
+ var map = tr.mapping.maps[i];
118
+
119
+ for (var j = 0; j < ranges.length; j++) {
120
+ ranges[j] = map.map(ranges[j]);
121
+ }
122
+
123
+ map.forEach(function (_s, _e, from, to) {
124
+ return ranges.push(from, to);
125
+ });
126
+ } // Figure out which joinable points exist inside those ranges,
127
+ // by checking all node boundaries in their parent nodes.
128
+
129
+
130
+ var joinable = [];
131
+
132
+ for (var _i3 = 0; _i3 < ranges.length; _i3 += 2) {
133
+ var from = ranges[_i3];
134
+ var to = ranges[_i3 + 1];
135
+ var $from = tr.doc.resolve(from);
136
+ var depth = $from.sharedDepth(to);
137
+ var parent = $from.node(depth);
138
+
139
+ for (var index = $from.indexAfter(depth), pos = $from.after(depth + 1); pos <= to; ++index) {
140
+ var _after = parent.maybeChild(index);
141
+
142
+ if (!_after) {
143
+ break;
144
+ }
145
+
146
+ if (index && joinable.indexOf(pos) === -1) {
147
+ var _before = parent.child(index - 1);
148
+
149
+ if (_before.type === _after.type && isJoinable(_before, _after)) {
150
+ joinable.push(pos);
151
+ }
152
+ }
153
+
154
+ pos += _after.nodeSize;
155
+ }
156
+ } // Join the joinable points
157
+
158
+
159
+ joinable.sort(function (a, b) {
160
+ return a - b;
161
+ });
162
+
163
+ for (var _i4 = joinable.length - 1; _i4 >= 0; _i4--) {
164
+ if (canJoin(tr.doc, joinable[_i4])) {
165
+ tr.join(joinable[_i4]);
166
+ }
167
+ }
168
+ }
@@ -5,9 +5,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
5
5
  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; }
6
6
 
7
7
  import { Fragment, Slice } from 'prosemirror-model';
8
- import { ReplaceAroundStep } from 'prosemirror-transform';
9
8
  import * as baseCommand from 'prosemirror-commands';
10
- import * as baseListCommand from 'prosemirror-schema-list';
11
9
  import { hasParentNodeOfType, findPositionOfNodeBefore } from 'prosemirror-utils';
12
10
  import { hasVisibleContent, isNodeEmpty } from '../../../utils/document';
13
11
  import { findCutBefore, isEmptySelectionAtStart, isFirstChildOfParent, filter } from '../../../utils/commands';
@@ -20,8 +18,10 @@ import { getCommonListAnalyticsAttributes } from '../utils/analytics';
20
18
  import { listBackspace } from './listBackspace';
21
19
  import { joinListItemForward } from './join-list-item-forward';
22
20
  import { convertListType } from '../actions/conversions';
21
+ import { wrapInListAndJoin } from '../actions/wrap-and-join-lists';
23
22
  import { outdentList } from './outdent-list';
24
23
  import { indentList } from './indent-list';
24
+ import { moveTargetIntoList } from '../utils/replace-content';
25
25
  export { outdentList, indentList };
26
26
  export var enterKeyCommand = function enterKeyCommand(state, dispatch) {
27
27
  var selection = state.selection;
@@ -89,8 +89,8 @@ function untoggleSelectedList(tr) {
89
89
 
90
90
  export function toggleList(inputMethod, listType) {
91
91
  return function (state, dispatch) {
92
- var customTr = state.tr;
93
- var listInsideSelection = selectionContainsList(customTr);
92
+ var tr = state.tr;
93
+ var listInsideSelection = selectionContainsList(tr);
94
94
  var listNodeType = state.schema.nodes[listType];
95
95
  var actionSubjectId = listType === 'bulletList' ? ACTION_SUBJECT_ID.FORMAT_LIST_BULLET : ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER;
96
96
 
@@ -101,9 +101,9 @@ export function toggleList(inputMethod, listType) {
101
101
  var transformedFrom = listInsideSelection.type.name === 'bulletList' ? ACTION_SUBJECT_ID.FORMAT_LIST_BULLET : ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER;
102
102
 
103
103
  if ((fromNode === null || fromNode === void 0 ? void 0 : fromNode.type.name) === listType && (toNode === null || toNode === void 0 ? void 0 : toNode.type.name) === listType) {
104
- var tr = state.tr;
105
- untoggleSelectedList(tr);
106
- addAnalytics(state, tr, {
104
+ var _tr2 = state.tr;
105
+ untoggleSelectedList(_tr2);
106
+ addAnalytics(state, _tr2, {
107
107
  action: ACTION.CONVERTED,
108
108
  actionSubject: ACTION_SUBJECT.LIST,
109
109
  actionSubjectId: ACTION_SUBJECT_ID.TEXT,
@@ -115,17 +115,17 @@ export function toggleList(inputMethod, listType) {
115
115
  });
116
116
 
117
117
  if (dispatch) {
118
- dispatch(tr);
118
+ dispatch(_tr2);
119
119
  }
120
120
 
121
121
  return true;
122
122
  }
123
123
 
124
124
  convertListType({
125
- tr: customTr,
125
+ tr: tr,
126
126
  nextListNodeType: listNodeType
127
127
  });
128
- addAnalytics(state, customTr, {
128
+ addAnalytics(state, tr, {
129
129
  action: ACTION.CONVERTED,
130
130
  actionSubject: ACTION_SUBJECT.LIST,
131
131
  actionSubjectId: actionSubjectId,
@@ -136,17 +136,11 @@ export function toggleList(inputMethod, listType) {
136
136
  })
137
137
  });
138
138
  } else {
139
- var replaceCurrentTr = function replaceCurrentTr(tr) {
140
- customTr = tr;
141
- }; // NOTE: replaceCurrentTr is supplied here instead of the usual dispatch function
142
- // to 'mutate' the transaction without actually dispatching (as it is more performant
143
- // if we only dispatch once at the end). This means customTr should not be modified
144
- // until after wrapInList, since any changes made to it will be discarded when it
145
- // gets replaced with the transaction generated by wrapInList.
146
-
147
-
148
- wrapInList(listNodeType)(state, replaceCurrentTr);
149
- addAnalytics(state, customTr, {
139
+ // Need to have this before wrapInList so the wrapping is done with valid content
140
+ // For example, if trying to convert centre or right aligned paragraphs to lists
141
+ sanitiseMarksInSelection(tr, listNodeType);
142
+ wrapInListAndJoin(listNodeType, tr);
143
+ addAnalytics(state, tr, {
150
144
  action: ACTION.INSERTED,
151
145
  actionSubject: ACTION_SUBJECT.LIST,
152
146
  actionSubjectId: actionSubjectId,
@@ -155,18 +149,16 @@ export function toggleList(inputMethod, listType) {
155
149
  inputMethod: inputMethod
156
150
  }
157
151
  });
158
- } // if document wasn't changed, that means setNodeMarkup step didn't work, so
159
- // return false from the command to indicate that the editing action failed
152
+ } // If document wasn't changed, return false from the command to indicate that the
153
+ // editing action failed
160
154
 
161
155
 
162
- if (!customTr.docChanged) {
156
+ if (!tr.docChanged) {
163
157
  return false;
164
158
  }
165
159
 
166
- sanitiseMarksInSelection(customTr, listNodeType);
167
-
168
160
  if (dispatch) {
169
- dispatch(customTr);
161
+ dispatch(tr);
170
162
  }
171
163
 
172
164
  return true;
@@ -180,11 +172,6 @@ export function toggleOrderedList(view) {
180
172
  var inputMethod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : INPUT_METHOD.TOOLBAR;
181
173
  return toggleList(inputMethod, 'orderedList')(view.state, view.dispatch);
182
174
  }
183
- export function wrapInList(nodeType) {
184
- return baseCommand.autoJoin(baseListCommand.wrapInList(nodeType), function (before, after) {
185
- return before.type === after.type && before.type === nodeType;
186
- });
187
- }
188
175
  /**
189
176
  * Implementation taken and modified for our needs from PM
190
177
  * @param itemType Node
@@ -315,8 +302,20 @@ var joinToPreviousListItem = function joinToPreviousListItem(state, dispatch) {
315
302
  var list = $cut.nodeBefore.copy($cut.nodeBefore.content.append(Fragment.from(listItem.createChecked({}, $cut.nodeAfter))));
316
303
  tr.replaceWith(nodeBeforePos, $from.pos + $cut.nodeAfter.nodeSize, list);
317
304
  } else {
318
- // take the text content of the paragraph and insert after the paragraph up until before the the cut
319
- tr = state.tr.step(new ReplaceAroundStep($lastNode.pos, $cut.pos + $cut.nodeAfter.nodeSize, $cut.pos + 1, $cut.pos + $cut.nodeAfter.nodeSize - 1, state.tr.doc.slice($lastNode.pos, $cut.pos), 0, true));
305
+ var step = moveTargetIntoList({
306
+ insertPosition: $lastNode.pos,
307
+ $target: $cut
308
+ }); // ED-13966: check if the step will cause an ProseMirror error
309
+ // if there's an error don't apply the step as it will might lead into a data loss.
310
+ // It doesn't play well with media being a leaf node.
311
+
312
+ var stepResult = state.tr.maybeStep(step);
313
+
314
+ if (stepResult.failed) {
315
+ return false;
316
+ } else {
317
+ tr = state.tr.step(step);
318
+ }
320
319
  } // find out if there's now another list following and join them
321
320
  // as in, [list, p, list] => [list with p, list], and we want [joined list]
322
321
 
@@ -0,0 +1,21 @@
1
+ import { ReplaceAroundStep, ReplaceStep } from 'prosemirror-transform';
2
+ export var moveTargetIntoList = function moveTargetIntoList(_ref) {
3
+ var _$target$nodeAfter;
4
+
5
+ var insertPosition = _ref.insertPosition,
6
+ $target = _ref.$target;
7
+ // take the text content of the paragraph and insert after the paragraph up until before the the cut
8
+ var from = insertPosition;
9
+ var to = $target.pos + (((_$target$nodeAfter = $target.nodeAfter) === null || _$target$nodeAfter === void 0 ? void 0 : _$target$nodeAfter.nodeSize) || 0); //$cut.pos + $cut.nodeAfter.nodeSize;
10
+
11
+ var gapFrom = $target.posAtIndex(0, $target.depth + 1); // start pos of the child
12
+
13
+ var gapTo = $target.doc.resolve(gapFrom).end(); // end pos of the paragraph
14
+
15
+ if (gapTo - gapFrom === 0) {
16
+ return new ReplaceStep(from, to, $target.doc.slice(insertPosition, $target.pos));
17
+ }
18
+
19
+ var step = new ReplaceAroundStep(from, to, gapFrom, gapTo, $target.doc.slice(insertPosition, $target.pos), 0, true);
20
+ return step;
21
+ };
@@ -178,7 +178,7 @@ export var MediaNodeUpdater = /*#__PURE__*/function () {
178
178
 
179
179
  case 2:
180
180
  contextIdentifierProvider = _context3.sent;
181
- return _context3.abrupt("return", contextIdentifierProvider && contextIdentifierProvider.objectId);
181
+ return _context3.abrupt("return", (contextIdentifierProvider === null || contextIdentifierProvider === void 0 ? void 0 : contextIdentifierProvider.objectId) || null);
182
182
 
183
183
  case 4:
184
184
  case "end":
@@ -266,10 +266,10 @@ export var MediaNodeUpdater = /*#__PURE__*/function () {
266
266
  var attrs = _this.getAttrs();
267
267
 
268
268
  if (!attrs || attrs.type !== 'file') {
269
- return undefined;
269
+ return null;
270
270
  }
271
271
 
272
- return attrs.__contextId;
272
+ return attrs.__contextId || null;
273
273
  });
274
274
 
275
275
  _defineProperty(this, "updateDimensions", function (dimensions) {
@@ -2,7 +2,7 @@ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral
2
2
 
3
3
  var _templateObject;
4
4
 
5
- import { css } from 'styled-components';
5
+ import { css } from '@emotion/react';
6
6
  import { mediaSingleSharedStyle, richMediaClassName } from '@atlaskit/editor-common/styles';
7
7
  import { akEditorDeleteBorder, akEditorDeleteBackground, akEditorSelectedBorderBoldSize, akEditorMediaResizeHandlerPaddingWide, akEditorMediaResizeHandlerPadding, akEditorSelectedNodeClassName, akEditorDeleteIconColor } from '@atlaskit/editor-shared-styles';
8
8
  import { N60, B200 } from '@atlaskit/theme/colors';
@@ -252,4 +252,15 @@ export var calcMediaPxWidth = function calcMediaPxWidth(opts) {
252
252
 
253
253
  var calcPctWidth = function calcPctWidth(containerWidth, pctWidth, origWidth, origHeight) {
254
254
  return pctWidth && origWidth && origHeight && Math.ceil(calcPxFromPct(pctWidth / 100, containerWidth.lineLength || containerWidth.width));
255
- };
255
+ };
256
+
257
+ export function isCaptionNode(editorView) {
258
+ var $from = editorView.state.selection.$from;
259
+ var immediateWrapperParentNode = editorView.state.doc.nodeAt($from.before(Math.max($from.depth, 1)));
260
+
261
+ if (immediateWrapperParentNode && immediateWrapperParentNode.type.name === 'caption') {
262
+ return true;
263
+ }
264
+
265
+ return false;
266
+ }