@atlaskit/editor-core 180.1.0 → 181.0.1

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 (426) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/dist/cjs/actions/index.js +25 -10
  3. package/dist/cjs/analytics-api/attach-payload-into-transaction.js +1 -1
  4. package/dist/cjs/create-editor/ReactEditorView.js +0 -5
  5. package/dist/cjs/create-editor/ReactEditorViewInternal.js +73 -103
  6. package/dist/cjs/create-editor/create-plugins-list.js +37 -5
  7. package/dist/cjs/create-editor/feature-flags-from-props.js +31 -26
  8. package/dist/cjs/create-editor/preset-utils.js +27 -0
  9. package/dist/cjs/editor-next/editor-internal.js +2 -2
  10. package/dist/cjs/editor-next/editor-migration-component.js +18 -2
  11. package/dist/cjs/editor-next/hooks/useProviderFactory.js +4 -3
  12. package/dist/cjs/editor-next/index.js +13 -9
  13. package/dist/cjs/editor-next/utils/getProvidersFromEditorProps.js +41 -0
  14. package/dist/cjs/editor-next/utils/handleProviders.js +17 -22
  15. package/dist/cjs/editor.js +20 -13
  16. package/dist/cjs/keymaps/consts.js +1 -16
  17. package/dist/cjs/labs/next/presets/cxhtml.js +56 -55
  18. package/dist/cjs/labs/next/presets/default.js +15 -42
  19. package/dist/cjs/labs/next/presets/mobile.js +76 -89
  20. package/dist/cjs/labs/next/presets/universal.js +330 -257
  21. package/dist/cjs/labs/next/presets/useUniversalPreset.js +36 -0
  22. package/dist/cjs/plugins/analytics/plugin.js +6 -0
  23. package/dist/cjs/plugins/annotation/utils.js +2 -36
  24. package/dist/cjs/plugins/base/pm-plugins/react-nodeview.js +2 -7
  25. package/dist/cjs/plugins/block-type/pm-plugins/input-rule.js +0 -10
  26. package/dist/cjs/plugins/caption/index.js +0 -7
  27. package/dist/cjs/plugins/card/nodeviews/blockCard.js +9 -4
  28. package/dist/cjs/plugins/card/nodeviews/inlineCard.js +6 -2
  29. package/dist/cjs/plugins/card/pm-plugins/main.js +6 -3
  30. package/dist/cjs/plugins/card/pm-plugins/util/resolve.js +4 -0
  31. package/dist/cjs/plugins/code-block/pm-plugins/main-state.js +2 -14
  32. package/dist/cjs/plugins/collab-edit/provider/index.js +1 -8
  33. package/dist/cjs/plugins/collab-edit/provider/types.js +1 -12
  34. package/dist/cjs/plugins/context-panel/index.js +1 -6
  35. package/dist/cjs/plugins/data-consumer/index.js +0 -8
  36. package/dist/cjs/plugins/date/utils/internal.js +0 -4
  37. package/dist/cjs/plugins/extension/commands.js +1 -8
  38. package/dist/cjs/plugins/extension/ui/Extension/Extension/index.js +9 -2
  39. package/dist/cjs/plugins/extension/ui/Extension/Extension/styles.js +2 -2
  40. package/dist/cjs/plugins/extension/ui/Extension/Lozenge.js +1 -0
  41. package/dist/cjs/plugins/feedback-dialog/index.js +1 -4
  42. package/dist/cjs/plugins/floating-toolbar/ui/Button.js +7 -3
  43. package/dist/cjs/plugins/floating-toolbar/ui/Dropdown.js +10 -5
  44. package/dist/cjs/plugins/floating-toolbar/ui/EmojiPickerButton.js +2 -9
  45. package/dist/cjs/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +1 -0
  46. package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +24 -8
  47. package/dist/cjs/plugins/floating-toolbar/utils.js +0 -12
  48. package/dist/cjs/plugins/fragment/index.js +0 -8
  49. package/dist/cjs/plugins/help-dialog/commands.js +2 -6
  50. package/dist/cjs/plugins/image-upload/pm-plugins/main.js +50 -12
  51. package/dist/cjs/plugins/layout/styles.js +10 -1
  52. package/dist/cjs/plugins/list/utils/find.js +0 -28
  53. package/dist/cjs/plugins/list/utils/indentation.js +1 -25
  54. package/dist/cjs/plugins/list/utils/node.js +0 -5
  55. package/dist/cjs/plugins/list/utils/selection.js +2 -15
  56. package/dist/cjs/plugins/media/utils/media-common.js +1 -20
  57. package/dist/cjs/plugins/mentions/nodeviews/mention.js +100 -16
  58. package/dist/cjs/plugins/mentions/type-ahead/index.js +1 -18
  59. package/dist/cjs/plugins/mentions/ui/InviteItem/index.js +1 -3
  60. package/dist/cjs/plugins/mobile-dimensions/index.js +1 -4
  61. package/dist/cjs/plugins/paste/index.js +1 -2
  62. package/dist/cjs/plugins/paste/pm-plugins/analytics.js +123 -87
  63. package/dist/cjs/plugins/paste/util/index.js +0 -46
  64. package/dist/cjs/plugins/quick-insert/assets/index.js +1 -27
  65. package/dist/cjs/plugins/selection/gap-cursor/actions.js +49 -44
  66. package/dist/cjs/plugins/status/utils.js +1 -15
  67. package/dist/cjs/plugins/text-color/pm-plugins/main.js +0 -1
  68. package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/index.js +7 -5
  69. package/dist/cjs/plugins/text-formatting/pm-plugins/smart-input-rule.js +8 -2
  70. package/dist/cjs/plugins/text-formatting/utils.js +1 -26
  71. package/dist/cjs/plugins/type-ahead/constants.js +1 -7
  72. package/dist/cjs/plugins/type-ahead/index.js +4 -1
  73. package/dist/cjs/plugins/type-ahead/pm-plugins/decorations.js +6 -37
  74. package/dist/cjs/plugins/type-ahead/pm-plugins/main.js +4 -2
  75. package/dist/cjs/plugins/type-ahead/ui/InputQuery.js +41 -4
  76. package/dist/cjs/plugins/type-ahead/ui/TypeAheadList.js +2 -0
  77. package/dist/cjs/plugins/type-ahead/ui/WrapperTypeAhead.js +9 -5
  78. package/dist/cjs/plugins/type-ahead/utils.js +25 -24
  79. package/dist/cjs/test-utils.js +4 -12
  80. package/dist/cjs/ui/Appearance/Comment/Toolbar.js +43 -8
  81. package/dist/cjs/ui/ColorPalette/index.js +18 -0
  82. package/dist/cjs/ui/ColorPickerButton/index.js +6 -2
  83. package/dist/cjs/ui/ConfigPanel/Fields/Expand.js +1 -0
  84. package/dist/cjs/ui/ConfigPanel/utils.js +4 -17
  85. package/dist/cjs/ui/ContentStyles/index.js +1 -1
  86. package/dist/cjs/ui/ElementBrowser/ModalElementBrowser.js +1 -1
  87. package/dist/cjs/ui/ElementBrowser/constants.js +1 -3
  88. package/dist/cjs/ui/Resizer/utils.js +1 -3
  89. package/dist/cjs/ui/styles.js +3 -7
  90. package/dist/cjs/utils/get-editor-plugins.js +1 -3
  91. package/dist/cjs/utils/index.js +9 -269
  92. package/dist/cjs/utils/input-rules.js +1 -15
  93. package/dist/cjs/version-wrapper.js +1 -1
  94. package/dist/cjs/version.json +1 -1
  95. package/dist/es2019/actions/index.js +23 -9
  96. package/dist/es2019/analytics-api/attach-payload-into-transaction.js +1 -1
  97. package/dist/es2019/create-editor/ReactEditorView.js +0 -5
  98. package/dist/es2019/create-editor/ReactEditorViewInternal.js +67 -82
  99. package/dist/es2019/create-editor/create-plugins-list.js +32 -5
  100. package/dist/es2019/create-editor/feature-flags-from-props.js +31 -26
  101. package/dist/es2019/create-editor/preset-utils.js +15 -0
  102. package/dist/es2019/editor-next/editor-internal.js +2 -2
  103. package/dist/es2019/editor-next/editor-migration-component.js +19 -2
  104. package/dist/es2019/editor-next/hooks/useProviderFactory.js +4 -3
  105. package/dist/es2019/editor-next/index.js +13 -7
  106. package/dist/es2019/editor-next/utils/getProvidersFromEditorProps.js +36 -0
  107. package/dist/es2019/editor-next/utils/handleProviders.js +18 -24
  108. package/dist/es2019/editor.js +20 -11
  109. package/dist/es2019/keymaps/consts.js +7 -11
  110. package/dist/es2019/labs/next/presets/cxhtml.js +56 -53
  111. package/dist/es2019/labs/next/presets/default.js +18 -38
  112. package/dist/es2019/labs/next/presets/mobile.js +88 -88
  113. package/dist/es2019/labs/next/presets/universal.js +338 -265
  114. package/dist/es2019/labs/next/presets/useUniversalPreset.js +25 -0
  115. package/dist/es2019/plugins/analytics/plugin.js +7 -0
  116. package/dist/es2019/plugins/annotation/utils.js +2 -30
  117. package/dist/es2019/plugins/base/pm-plugins/react-nodeview.js +1 -3
  118. package/dist/es2019/plugins/block-type/pm-plugins/input-rule.js +3 -9
  119. package/dist/es2019/plugins/caption/index.js +0 -2
  120. package/dist/es2019/plugins/card/nodeviews/blockCard.js +8 -4
  121. package/dist/es2019/plugins/card/nodeviews/inlineCard.js +6 -2
  122. package/dist/es2019/plugins/card/pm-plugins/main.js +6 -3
  123. package/dist/es2019/plugins/card/pm-plugins/util/resolve.js +4 -0
  124. package/dist/es2019/plugins/code-block/pm-plugins/main-state.js +1 -9
  125. package/dist/es2019/plugins/collab-edit/provider/index.js +1 -1
  126. package/dist/es2019/plugins/collab-edit/provider/types.js +1 -10
  127. package/dist/es2019/plugins/context-panel/index.js +0 -3
  128. package/dist/es2019/plugins/data-consumer/index.js +0 -7
  129. package/dist/es2019/plugins/date/utils/internal.js +0 -3
  130. package/dist/es2019/plugins/extension/commands.js +0 -6
  131. package/dist/es2019/plugins/extension/ui/Extension/Extension/index.js +12 -2
  132. package/dist/es2019/plugins/extension/ui/Extension/Extension/styles.js +3 -0
  133. package/dist/es2019/plugins/extension/ui/Extension/Lozenge.js +1 -0
  134. package/dist/es2019/plugins/feedback-dialog/index.js +0 -2
  135. package/dist/es2019/plugins/floating-toolbar/ui/Button.js +7 -3
  136. package/dist/es2019/plugins/floating-toolbar/ui/Dropdown.js +10 -5
  137. package/dist/es2019/plugins/floating-toolbar/ui/EmojiPickerButton.js +1 -11
  138. package/dist/es2019/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +1 -0
  139. package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +21 -4
  140. package/dist/es2019/plugins/floating-toolbar/utils.js +0 -10
  141. package/dist/es2019/plugins/fragment/index.js +0 -7
  142. package/dist/es2019/plugins/help-dialog/commands.js +1 -2
  143. package/dist/es2019/plugins/image-upload/pm-plugins/main.js +47 -5
  144. package/dist/es2019/plugins/layout/styles.js +12 -4
  145. package/dist/es2019/plugins/list/utils/find.js +0 -27
  146. package/dist/es2019/plugins/list/utils/indentation.js +0 -23
  147. package/dist/es2019/plugins/list/utils/node.js +1 -4
  148. package/dist/es2019/plugins/list/utils/selection.js +2 -15
  149. package/dist/es2019/plugins/media/utils/media-common.js +1 -19
  150. package/dist/es2019/plugins/mentions/nodeviews/mention.js +64 -16
  151. package/dist/es2019/plugins/mentions/type-ahead/index.js +1 -14
  152. package/dist/es2019/plugins/mentions/ui/InviteItem/index.js +1 -2
  153. package/dist/es2019/plugins/mobile-dimensions/index.js +0 -3
  154. package/dist/es2019/plugins/paste/index.js +1 -2
  155. package/dist/es2019/plugins/paste/pm-plugins/analytics.js +126 -94
  156. package/dist/es2019/plugins/paste/util/index.js +5 -45
  157. package/dist/es2019/plugins/quick-insert/assets/index.js +0 -8
  158. package/dist/es2019/plugins/selection/gap-cursor/actions.js +56 -56
  159. package/dist/es2019/plugins/status/utils.js +1 -11
  160. package/dist/es2019/plugins/text-color/pm-plugins/main.js +1 -1
  161. package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/index.js +7 -5
  162. package/dist/es2019/plugins/text-formatting/pm-plugins/smart-input-rule.js +8 -2
  163. package/dist/es2019/plugins/text-formatting/utils.js +0 -19
  164. package/dist/es2019/plugins/type-ahead/constants.js +0 -5
  165. package/dist/es2019/plugins/type-ahead/index.js +4 -1
  166. package/dist/es2019/plugins/type-ahead/pm-plugins/decorations.js +4 -37
  167. package/dist/es2019/plugins/type-ahead/pm-plugins/main.js +4 -2
  168. package/dist/es2019/plugins/type-ahead/ui/InputQuery.js +41 -4
  169. package/dist/es2019/plugins/type-ahead/ui/TypeAheadList.js +2 -0
  170. package/dist/es2019/plugins/type-ahead/ui/WrapperTypeAhead.js +9 -5
  171. package/dist/es2019/plugins/type-ahead/utils.js +22 -25
  172. package/dist/es2019/test-utils.js +4 -7
  173. package/dist/es2019/ui/Appearance/Comment/Toolbar.js +40 -6
  174. package/dist/es2019/ui/ColorPalette/index.js +2 -1
  175. package/dist/es2019/ui/ColorPickerButton/index.js +6 -2
  176. package/dist/es2019/ui/ConfigPanel/Fields/Expand.js +1 -0
  177. package/dist/es2019/ui/ConfigPanel/utils.js +0 -6
  178. package/dist/es2019/ui/ContentStyles/index.js +1 -1
  179. package/dist/es2019/ui/ElementBrowser/ModalElementBrowser.js +1 -1
  180. package/dist/es2019/ui/ElementBrowser/constants.js +0 -1
  181. package/dist/es2019/ui/Resizer/utils.js +0 -1
  182. package/dist/es2019/ui/styles.js +0 -6
  183. package/dist/es2019/utils/get-editor-plugins.js +1 -3
  184. package/dist/es2019/utils/index.js +13 -199
  185. package/dist/es2019/utils/input-rules.js +0 -14
  186. package/dist/es2019/version-wrapper.js +1 -1
  187. package/dist/es2019/version.json +1 -1
  188. package/dist/esm/actions/index.js +23 -9
  189. package/dist/esm/analytics-api/attach-payload-into-transaction.js +1 -1
  190. package/dist/esm/create-editor/ReactEditorView.js +0 -5
  191. package/dist/esm/create-editor/ReactEditorViewInternal.js +73 -102
  192. package/dist/esm/create-editor/create-plugins-list.js +36 -5
  193. package/dist/esm/create-editor/feature-flags-from-props.js +31 -26
  194. package/dist/esm/create-editor/preset-utils.js +21 -0
  195. package/dist/esm/editor-next/editor-internal.js +2 -2
  196. package/dist/esm/editor-next/editor-migration-component.js +18 -2
  197. package/dist/esm/editor-next/hooks/useProviderFactory.js +4 -3
  198. package/dist/esm/editor-next/index.js +13 -9
  199. package/dist/esm/editor-next/utils/getProvidersFromEditorProps.js +35 -0
  200. package/dist/esm/editor-next/utils/handleProviders.js +17 -22
  201. package/dist/esm/editor.js +20 -13
  202. package/dist/esm/keymaps/consts.js +7 -11
  203. package/dist/esm/labs/next/presets/cxhtml.js +56 -55
  204. package/dist/esm/labs/next/presets/default.js +18 -41
  205. package/dist/esm/labs/next/presets/mobile.js +88 -90
  206. package/dist/esm/labs/next/presets/universal.js +330 -257
  207. package/dist/esm/labs/next/presets/useUniversalPreset.js +29 -0
  208. package/dist/esm/plugins/analytics/plugin.js +6 -0
  209. package/dist/esm/plugins/annotation/utils.js +2 -32
  210. package/dist/esm/plugins/base/pm-plugins/react-nodeview.js +1 -5
  211. package/dist/esm/plugins/block-type/pm-plugins/input-rule.js +3 -9
  212. package/dist/esm/plugins/caption/index.js +0 -2
  213. package/dist/esm/plugins/card/nodeviews/blockCard.js +9 -4
  214. package/dist/esm/plugins/card/nodeviews/inlineCard.js +6 -2
  215. package/dist/esm/plugins/card/pm-plugins/main.js +6 -3
  216. package/dist/esm/plugins/card/pm-plugins/util/resolve.js +4 -0
  217. package/dist/esm/plugins/code-block/pm-plugins/main-state.js +0 -10
  218. package/dist/esm/plugins/collab-edit/provider/index.js +1 -1
  219. package/dist/esm/plugins/collab-edit/provider/types.js +1 -10
  220. package/dist/esm/plugins/context-panel/index.js +0 -3
  221. package/dist/esm/plugins/data-consumer/index.js +0 -7
  222. package/dist/esm/plugins/date/utils/internal.js +0 -3
  223. package/dist/esm/plugins/extension/commands.js +0 -6
  224. package/dist/esm/plugins/extension/ui/Extension/Extension/index.js +9 -2
  225. package/dist/esm/plugins/extension/ui/Extension/Extension/styles.js +2 -2
  226. package/dist/esm/plugins/extension/ui/Extension/Lozenge.js +1 -0
  227. package/dist/esm/plugins/feedback-dialog/index.js +0 -2
  228. package/dist/esm/plugins/floating-toolbar/ui/Button.js +7 -3
  229. package/dist/esm/plugins/floating-toolbar/ui/Dropdown.js +10 -5
  230. package/dist/esm/plugins/floating-toolbar/ui/EmojiPickerButton.js +2 -9
  231. package/dist/esm/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +1 -0
  232. package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +24 -8
  233. package/dist/esm/plugins/floating-toolbar/utils.js +0 -10
  234. package/dist/esm/plugins/fragment/index.js +0 -7
  235. package/dist/esm/plugins/help-dialog/commands.js +0 -3
  236. package/dist/esm/plugins/image-upload/pm-plugins/main.js +51 -12
  237. package/dist/esm/plugins/layout/styles.js +11 -2
  238. package/dist/esm/plugins/list/utils/find.js +0 -27
  239. package/dist/esm/plugins/list/utils/indentation.js +0 -23
  240. package/dist/esm/plugins/list/utils/node.js +1 -4
  241. package/dist/esm/plugins/list/utils/selection.js +2 -12
  242. package/dist/esm/plugins/media/utils/media-common.js +1 -17
  243. package/dist/esm/plugins/mentions/nodeviews/mention.js +97 -16
  244. package/dist/esm/plugins/mentions/type-ahead/index.js +1 -18
  245. package/dist/esm/plugins/mentions/ui/InviteItem/index.js +1 -2
  246. package/dist/esm/plugins/mobile-dimensions/index.js +0 -3
  247. package/dist/esm/plugins/paste/index.js +1 -2
  248. package/dist/esm/plugins/paste/pm-plugins/analytics.js +122 -86
  249. package/dist/esm/plugins/paste/util/index.js +5 -45
  250. package/dist/esm/plugins/quick-insert/assets/index.js +0 -20
  251. package/dist/esm/plugins/selection/gap-cursor/actions.js +52 -45
  252. package/dist/esm/plugins/status/utils.js +1 -13
  253. package/dist/esm/plugins/text-color/pm-plugins/main.js +1 -1
  254. package/dist/esm/plugins/text-color/ui/ToolbarTextColor/index.js +7 -5
  255. package/dist/esm/plugins/text-formatting/pm-plugins/smart-input-rule.js +8 -2
  256. package/dist/esm/plugins/text-formatting/utils.js +0 -21
  257. package/dist/esm/plugins/type-ahead/constants.js +0 -5
  258. package/dist/esm/plugins/type-ahead/index.js +4 -1
  259. package/dist/esm/plugins/type-ahead/pm-plugins/decorations.js +4 -33
  260. package/dist/esm/plugins/type-ahead/pm-plugins/main.js +4 -2
  261. package/dist/esm/plugins/type-ahead/ui/InputQuery.js +41 -4
  262. package/dist/esm/plugins/type-ahead/ui/TypeAheadList.js +2 -0
  263. package/dist/esm/plugins/type-ahead/ui/WrapperTypeAhead.js +9 -5
  264. package/dist/esm/plugins/type-ahead/utils.js +24 -22
  265. package/dist/esm/test-utils.js +4 -7
  266. package/dist/esm/ui/Appearance/Comment/Toolbar.js +41 -6
  267. package/dist/esm/ui/ColorPalette/index.js +2 -1
  268. package/dist/esm/ui/ColorPickerButton/index.js +6 -2
  269. package/dist/esm/ui/ConfigPanel/Fields/Expand.js +1 -0
  270. package/dist/esm/ui/ConfigPanel/utils.js +3 -14
  271. package/dist/esm/ui/ContentStyles/index.js +1 -1
  272. package/dist/esm/ui/ElementBrowser/ModalElementBrowser.js +1 -1
  273. package/dist/esm/ui/ElementBrowser/constants.js +0 -1
  274. package/dist/esm/ui/Resizer/utils.js +0 -1
  275. package/dist/esm/ui/styles.js +2 -5
  276. package/dist/esm/utils/get-editor-plugins.js +1 -3
  277. package/dist/esm/utils/index.js +13 -196
  278. package/dist/esm/utils/input-rules.js +0 -13
  279. package/dist/esm/version-wrapper.js +1 -1
  280. package/dist/esm/version.json +1 -1
  281. package/dist/types/actions/index.d.ts +4 -4
  282. package/dist/types/create-editor/ReactEditorView.d.ts +0 -3
  283. package/dist/types/create-editor/ReactEditorViewInternal.d.ts +9 -7
  284. package/dist/types/create-editor/ReactEditorViewNext.d.ts +3 -4
  285. package/dist/types/create-editor/create-plugins-list.d.ts +3 -5
  286. package/dist/types/create-editor/preset-utils.d.ts +2 -0
  287. package/dist/types/editor-next/editor-internal.d.ts +9 -9
  288. package/dist/types/editor-next/hooks/useMeasureEditorMountTime.d.ts +2 -2
  289. package/dist/types/editor-next/hooks/useProviderFactory.d.ts +2 -2
  290. package/dist/types/editor-next/index.d.ts +6 -6
  291. package/dist/types/editor-next/utils/deprecationWarnings.d.ts +2 -2
  292. package/dist/types/editor-next/utils/editorPropTypes.d.ts +1 -1
  293. package/dist/types/editor-next/utils/getProvidersFromEditorProps.d.ts +9 -0
  294. package/dist/types/editor-next/utils/handleProviders.d.ts +2 -2
  295. package/dist/types/editor-next/utils/onEditorCreated.d.ts +2 -2
  296. package/dist/types/editor-next/utils/sendDurationAnalytics.d.ts +1 -1
  297. package/dist/types/editor.d.ts +7 -4
  298. package/dist/types/keymaps/consts.d.ts +0 -11
  299. package/dist/types/labs/next/presets/cxhtml.d.ts +33 -1
  300. package/dist/types/labs/next/presets/default.d.ts +67 -10
  301. package/dist/types/labs/next/presets/mobile.d.ts +33 -1
  302. package/dist/types/labs/next/presets/universal.d.ts +5 -13
  303. package/dist/types/labs/next/presets/useUniversalPreset.d.ts +7 -0
  304. package/dist/types/nodeviews/context-adapter.d.ts +0 -1
  305. package/dist/types/nodeviews/index.d.ts +0 -1
  306. package/dist/types/plugins/alignment/pm-plugins/types.d.ts +0 -11
  307. package/dist/types/plugins/annotation/utils.d.ts +0 -17
  308. package/dist/types/plugins/base/pm-plugins/react-nodeview.d.ts +2 -3
  309. package/dist/types/plugins/block-type/pm-plugins/input-rule.d.ts +2 -6
  310. package/dist/types/plugins/caption/index.d.ts +0 -2
  311. package/dist/types/plugins/card/nodeviews/blockCard.d.ts +2 -10
  312. package/dist/types/plugins/card/nodeviews/genericCard.d.ts +1 -0
  313. package/dist/types/plugins/card/nodeviews/inlineCard.d.ts +1 -1
  314. package/dist/types/plugins/code-block/actions.d.ts +0 -4
  315. package/dist/types/plugins/code-block/pm-plugins/main-state.d.ts +0 -3
  316. package/dist/types/plugins/collab-edit/provider/index.d.ts +1 -2
  317. package/dist/types/plugins/collab-edit/provider/types.d.ts +1 -36
  318. package/dist/types/plugins/context-panel/index.d.ts +2 -3
  319. package/dist/types/plugins/data-consumer/index.d.ts +0 -2
  320. package/dist/types/plugins/date/utils/internal.d.ts +0 -1
  321. package/dist/types/plugins/extension/commands.d.ts +0 -1
  322. package/dist/types/plugins/extension/nodeviews/extension.d.ts +0 -5
  323. package/dist/types/plugins/feedback-dialog/index.d.ts +0 -2
  324. package/dist/types/plugins/floating-toolbar/ui/Button.d.ts +3 -1
  325. package/dist/types/plugins/floating-toolbar/ui/Dropdown.d.ts +1 -0
  326. package/dist/types/plugins/floating-toolbar/utils.d.ts +0 -2
  327. package/dist/types/plugins/fragment/index.d.ts +0 -2
  328. package/dist/types/plugins/help-dialog/commands.d.ts +0 -1
  329. package/dist/types/plugins/history/actions.d.ts +1 -2
  330. package/dist/types/plugins/layout/styles.d.ts +2 -1
  331. package/dist/types/plugins/list/utils/find.d.ts +0 -1
  332. package/dist/types/plugins/list/utils/indentation.d.ts +0 -1
  333. package/dist/types/plugins/list/utils/node.d.ts +0 -2
  334. package/dist/types/plugins/list/utils/selection.d.ts +0 -3
  335. package/dist/types/plugins/media/utils/media-common.d.ts +0 -5
  336. package/dist/types/plugins/mentions/types.d.ts +1 -2
  337. package/dist/types/plugins/mentions/ui/InviteItem/index.d.ts +2 -3
  338. package/dist/types/plugins/mentions/ui/InviteItem/styles.d.ts +0 -6
  339. package/dist/types/plugins/mentions/ui/ToolbarMention/index.d.ts +1 -4
  340. package/dist/types/plugins/mobile-dimensions/index.d.ts +0 -1
  341. package/dist/types/plugins/paste/index.d.ts +0 -1
  342. package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +6 -3
  343. package/dist/types/plugins/paste/util/index.d.ts +0 -6
  344. package/dist/types/plugins/quick-insert/assets/index.d.ts +0 -2
  345. package/dist/types/plugins/status/utils.d.ts +0 -3
  346. package/dist/types/plugins/tasks-and-decisions/pm-plugins/main.d.ts +0 -6
  347. package/dist/types/plugins/text-color/pm-plugins/main.d.ts +2 -12
  348. package/dist/types/plugins/text-formatting/pm-plugins/clear-formatting.d.ts +0 -1
  349. package/dist/types/plugins/text-formatting/utils.d.ts +0 -4
  350. package/dist/types/plugins/type-ahead/constants.d.ts +0 -4
  351. package/dist/types/plugins/type-ahead/index.d.ts +1 -0
  352. package/dist/types/plugins/type-ahead/pm-plugins/decorations.d.ts +2 -11
  353. package/dist/types/plugins/type-ahead/pm-plugins/main.d.ts +2 -1
  354. package/dist/types/plugins/type-ahead/ui/InputQuery.d.ts +1 -0
  355. package/dist/types/plugins/type-ahead/ui/WrapperTypeAhead.d.ts +1 -0
  356. package/dist/types/plugins/type-ahead/utils.d.ts +3 -3
  357. package/dist/types/test-utils.d.ts +4 -5
  358. package/dist/types/types/editor-appearance-component.d.ts +2 -2
  359. package/dist/types/types/editor-props.d.ts +55 -42
  360. package/dist/types/ui/Appearance/Chromeless.d.ts +0 -5
  361. package/dist/types/ui/Appearance/Comment/Comment.d.ts +0 -7
  362. package/dist/types/ui/Appearance/Comment/Toolbar.d.ts +3 -2
  363. package/dist/types/ui/Appearance/FullPage/MainToolbar.d.ts +0 -4
  364. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +3 -3
  365. package/dist/types/ui/AppearanceComponents/Mobile.d.ts +2 -5
  366. package/dist/types/ui/ColorPalette/Palettes/index.d.ts +1 -1
  367. package/dist/types/ui/ColorPalette/Palettes/type.d.ts +1 -1
  368. package/dist/types/ui/ColorPalette/index.d.ts +2 -1
  369. package/dist/types/ui/ColorPickerButton/index.d.ts +4 -2
  370. package/dist/types/ui/ConfigPanel/types.d.ts +0 -3
  371. package/dist/types/ui/ConfigPanel/utils.d.ts +2 -3
  372. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  373. package/dist/types/ui/ElementBrowser/ModalElementBrowser.d.ts +0 -3
  374. package/dist/types/ui/ElementBrowser/constants.d.ts +0 -1
  375. package/dist/types/ui/ElementBrowser/types.d.ts +0 -5
  376. package/dist/types/ui/Resizer/utils.d.ts +0 -1
  377. package/dist/types/ui/styles.d.ts +0 -1
  378. package/dist/types/utils/index.d.ts +6 -65
  379. package/dist/types/utils/input-rules.d.ts +1 -2
  380. package/dist/types/utils/table.d.ts +0 -1
  381. package/package.json +23 -24
  382. package/report.api.md +155 -146
  383. package/dist/cjs/labs/next/presets/preset.js +0 -101
  384. package/dist/cjs/plugins/analytics/types/type-ahead.js +0 -5
  385. package/dist/cjs/plugins/collab-edit/provider/channel.js +0 -313
  386. package/dist/cjs/plugins/collab-edit/provider/logger.js +0 -17
  387. package/dist/cjs/plugins/collab-edit/provider/mock-users.js +0 -19
  388. package/dist/cjs/plugins/data-consumer/plugin-key.js +0 -9
  389. package/dist/cjs/plugins/media/toolbar/toolbar-messages.js +0 -15
  390. package/dist/cjs/profiler/render-count.js +0 -60
  391. package/dist/cjs/ui/ColorPalette/Color/index.js +0 -9
  392. package/dist/cjs/ui/ConfigPanel/FieldDescription.js +0 -19
  393. package/dist/cjs/ui/WithPluginState/types.js +0 -5
  394. package/dist/es2019/labs/next/presets/preset.js +0 -68
  395. package/dist/es2019/plugins/analytics/types/type-ahead.js +0 -1
  396. package/dist/es2019/plugins/collab-edit/provider/channel.js +0 -179
  397. package/dist/es2019/plugins/collab-edit/provider/logger.js +0 -8
  398. package/dist/es2019/plugins/collab-edit/provider/mock-users.js +0 -12
  399. package/dist/es2019/plugins/data-consumer/plugin-key.js +0 -2
  400. package/dist/es2019/plugins/media/toolbar/toolbar-messages.js +0 -8
  401. package/dist/es2019/profiler/render-count.js +0 -53
  402. package/dist/es2019/ui/ColorPalette/Color/index.js +0 -2
  403. package/dist/es2019/ui/ConfigPanel/FieldDescription.js +0 -12
  404. package/dist/es2019/ui/WithPluginState/types.js +0 -1
  405. package/dist/esm/labs/next/presets/preset.js +0 -93
  406. package/dist/esm/plugins/analytics/types/type-ahead.js +0 -1
  407. package/dist/esm/plugins/collab-edit/provider/channel.js +0 -305
  408. package/dist/esm/plugins/collab-edit/provider/logger.js +0 -10
  409. package/dist/esm/plugins/collab-edit/provider/mock-users.js +0 -12
  410. package/dist/esm/plugins/data-consumer/plugin-key.js +0 -2
  411. package/dist/esm/plugins/media/toolbar/toolbar-messages.js +0 -8
  412. package/dist/esm/profiler/render-count.js +0 -49
  413. package/dist/esm/ui/ColorPalette/Color/index.js +0 -2
  414. package/dist/esm/ui/ConfigPanel/FieldDescription.js +0 -11
  415. package/dist/esm/ui/WithPluginState/types.js +0 -1
  416. package/dist/types/labs/next/presets/preset.d.ts +0 -46
  417. package/dist/types/plugins/analytics/types/type-ahead.d.ts +0 -1
  418. package/dist/types/plugins/collab-edit/provider/channel.d.ts +0 -48
  419. package/dist/types/plugins/collab-edit/provider/logger.d.ts +0 -1
  420. package/dist/types/plugins/collab-edit/provider/mock-users.d.ts +0 -6
  421. package/dist/types/plugins/data-consumer/plugin-key.d.ts +0 -2
  422. package/dist/types/plugins/media/toolbar/toolbar-messages.d.ts +0 -7
  423. package/dist/types/profiler/render-count.d.ts +0 -14
  424. package/dist/types/ui/ColorPalette/Color/index.d.ts +0 -2
  425. package/dist/types/ui/ConfigPanel/FieldDescription.d.ts +0 -6
  426. package/dist/types/ui/WithPluginState/types.d.ts +0 -10
@@ -1,23 +1,17 @@
1
1
  import { toggleMark } from 'prosemirror-commands';
2
- import { Fragment, Slice } from 'prosemirror-model';
3
2
  import { NodeSelection, TextSelection } from 'prosemirror-state';
4
- import { findWrapping, liftTarget } from 'prosemirror-transform';
5
3
  import { JSONTransformer } from '@atlaskit/editor-json-transformer';
6
4
  import { FakeTextCursorSelection } from '../plugins/fake-text-cursor/cursor';
7
5
  import { hasParentNodeOfType } from 'prosemirror-utils';
8
6
  import { isNodeEmpty } from './document';
9
7
  import { atTheBeginningOfDoc, atTheEndOfDoc } from './prosemirror/position';
8
+ import { isMediaNode } from '@atlaskit/editor-common/utils';
10
9
  export { insideTable } from '@atlaskit/editor-common/core-utils';
11
10
  export { isEmptyParagraph, hasVisibleContent, isNodeEmpty, isEmptyDocument, processRawValue, getStepRange, findFarthestParentNode, isSelectionEndOfParagraph, nodesBetweenChanged, getNodesCount } from './document';
12
- export { cascadeCommands, getEditorValueWithMedia } from './action';
13
- export { isMarkAllowedInRange, isMarkExcluded, removeBlockMarks, sanitiseSelectionMarksForWrapping, sanitiseMarksInSelection } from './mark';
14
- export { isParagraph, isText, isLinkMark, validateNodes } from './nodes';
15
- export { normaliseNestedLayout, setNodeSelection, setAllSelection, setGapCursorSelection, setCellSelection, setTextSelection, isValidPosition } from './selection';
16
- export { containsClassName } from './dom';
11
+ export { sanitiseMarksInSelection } from './mark';
12
+ export { isParagraph, isText, isLinkMark } from './nodes';
13
+ export { normaliseNestedLayout, setNodeSelection, setGapCursorSelection, setTextSelection } from './selection';
17
14
  export { default as measurements } from './performance/measure-enum';
18
- function validateNode(_node) {
19
- return false;
20
- }
21
15
  function isMarkTypeCompatibleWithMark(markType, mark) {
22
16
  return !mark.type.excludes(markType) && !markType.excludes(mark.type);
23
17
  }
@@ -26,24 +20,13 @@ function isMarkTypeAllowedInNode(markType, state) {
26
20
  }
27
21
  export function canMoveUp(state) {
28
22
  const {
29
- selection,
30
- doc
23
+ selection
31
24
  } = state;
32
-
33
25
  /**
34
- * If there's a media element on the selection,
35
- * add text blocks with arrow navigation.
36
- * Also, the selection could be media | mediaGroup.
26
+ * If there's a media element on the selection it will use a gap cursor to move
37
27
  */
38
- if (selection instanceof NodeSelection) {
39
- if (selection.node.type.name === 'media') {
40
- /** Weird way of checking if the previous element is a paragraph */
41
- const mediaAncestorNode = doc.nodeAt(selection.anchor - 3);
42
- return !!(mediaAncestorNode && mediaAncestorNode.type.name === 'paragraph');
43
- } else if (selection.node.type.name === 'mediaGroup') {
44
- const mediaGroupAncestorNode = selection.$anchor.nodeBefore;
45
- return !!(mediaGroupAncestorNode && mediaGroupAncestorNode.type.name === 'paragraph');
46
- }
28
+ if (selection instanceof NodeSelection && isMediaNode(selection.node)) {
29
+ return true;
47
30
  }
48
31
  if (selection instanceof TextSelection) {
49
32
  if (!selection.empty) {
@@ -54,22 +37,14 @@ export function canMoveUp(state) {
54
37
  }
55
38
  export function canMoveDown(state) {
56
39
  const {
57
- selection,
58
- doc
40
+ selection
59
41
  } = state;
60
42
 
61
43
  /**
62
- * If there's a media element on the selection,
63
- * add text blocks with arrow navigation.
64
- * Also, the selection could be media | mediaGroup.
44
+ * If there's a media element on the selection it will use a gap cursor to move
65
45
  */
66
- if (selection instanceof NodeSelection) {
67
- if (selection.node.type.name === 'media') {
68
- const nodeAfter = doc.nodeAt(selection.$head.after());
69
- return !!(nodeAfter && nodeAfter.type.name === 'paragraph');
70
- } else if (selection.node.type.name === 'mediaGroup') {
71
- return !(selection.$head.parentOffset === selection.$anchor.parent.content.size);
72
- }
46
+ if (selection instanceof NodeSelection && isMediaNode(selection.node)) {
47
+ return true;
73
48
  }
74
49
  if (selection instanceof TextSelection) {
75
50
  if (!selection.empty) {
@@ -130,17 +105,6 @@ export function isMarkTypeAllowedInCurrentSelection(markType, state) {
130
105
  return allowedInActiveMarks;
131
106
  });
132
107
  }
133
- export function createSliceWithContent(content, state) {
134
- return new Slice(Fragment.from(state.schema.text(content)), 0, 0);
135
- }
136
-
137
- /**
138
- * Determines if content inside a selection can be joined with the next block.
139
- * We need this check since the built-in method for "joinDown" will join a orderedList with bulletList.
140
- */
141
- export function canJoinDown(selection, doc, nodeType) {
142
- return checkNodeDown(selection, doc, node => node.type === nodeType);
143
- }
144
108
  export function checkNodeDown(selection, doc, filter) {
145
109
  const ancestorDepth = findAncestorPosition(doc, selection.$to).depth;
146
110
 
@@ -152,64 +116,10 @@ export function checkNodeDown(selection, doc, filter) {
152
116
  return res.nodeAfter ? filter(res.nodeAfter) : false;
153
117
  }
154
118
 
155
- /**
156
- * Determines if content inside a selection can be joined with the previous block.
157
- * We need this check since the built-in method for "joinUp" will join a orderedList with bulletList.
158
- */
159
- export function canJoinUp(selection, doc, nodeType) {
160
- const res = doc.resolve(selection.$from.before(findAncestorPosition(doc, selection.$from).depth));
161
- return res.nodeBefore && res.nodeBefore.type === nodeType;
162
- }
163
-
164
- /**
165
- * Finds all "selection-groups" within a range. A selection group is based on ancestors.
166
- *
167
- * Example:
168
- * Given the following document and selection ({<} = start of selection and {>} = end)
169
- * doc
170
- * blockquote
171
- * ul
172
- * li
173
- * li{<}
174
- * li
175
- * p
176
- * p{>}
177
- *
178
- * The output will be two selection-groups. One within the ul and one with the two paragraphs.
179
- */
180
- export function getGroupsInRange(doc, $from, $to, isNodeValid = validateNode) {
181
- const groups = Array();
182
- const commonAncestor = hasCommonAncestor(doc, $from, $to);
183
- const fromAncestor = findAncestorPosition(doc, $from);
184
- if (commonAncestor || fromAncestor.depth === 1 && isNodeValid($from.node(1))) {
185
- groups.push({
186
- $from,
187
- $to
188
- });
189
- } else {
190
- let current = $from;
191
- while (current.pos < $to.pos) {
192
- let ancestorPos = findAncestorPosition(doc, current);
193
- while (ancestorPos.depth > 1) {
194
- ancestorPos = findAncestorPosition(doc, ancestorPos);
195
- }
196
- const endPos = doc.resolve(Math.min(
197
- // should not be smaller then start position in case of an empty paragraph for example.
198
- Math.max(ancestorPos.start(ancestorPos.depth), ancestorPos.end(ancestorPos.depth) - 3), $to.pos));
199
- groups.push({
200
- $from: current,
201
- $to: endPos
202
- });
203
- current = doc.resolve(Math.min(endPos.after(1) + 1, doc.nodeSize - 2));
204
- }
205
- }
206
- return groups;
207
- }
208
-
209
119
  /**
210
120
  * Traverse the document until an "ancestor" is found. Any nestable block can be an ancestor.
211
121
  */
212
- export function findAncestorPosition(doc, pos) {
122
+ function findAncestorPosition(doc, pos) {
213
123
  const nestableBlocks = ['blockquote', 'bulletList', 'orderedList'];
214
124
  if (pos.depth === 1) {
215
125
  return pos;
@@ -225,102 +135,6 @@ export function findAncestorPosition(doc, pos) {
225
135
  }
226
136
  return newPos;
227
137
  }
228
-
229
- /**
230
- * Determine if two positions have a common ancestor.
231
- */
232
- export function hasCommonAncestor(doc, $from, $to) {
233
- let current;
234
- let target;
235
- if ($from.depth > $to.depth) {
236
- current = findAncestorPosition(doc, $from);
237
- target = findAncestorPosition(doc, $to);
238
- } else {
239
- current = findAncestorPosition(doc, $to);
240
- target = findAncestorPosition(doc, $from);
241
- }
242
- while (current.depth > target.depth && current.depth > 1) {
243
- current = findAncestorPosition(doc, current);
244
- }
245
- return current.node(current.depth) === target.node(target.depth);
246
- }
247
-
248
- /**
249
- * Takes a selection $from and $to and lift all text nodes from their parents to document-level
250
- */
251
- export function liftSelection(tr, doc, $from, $to) {
252
- let startPos = $from.start($from.depth);
253
- let endPos = $to.end($to.depth);
254
- const target = Math.max(0, findAncestorPosition(doc, $from).depth - 1);
255
- tr.doc.nodesBetween(startPos, endPos, (node, pos) => {
256
- if (node.isText ||
257
- // Text node
258
- node.isTextblock && !node.textContent // Empty paragraph
259
- ) {
260
- const res = tr.doc.resolve(tr.mapping.map(pos));
261
- const sel = new NodeSelection(res);
262
- const range = sel.$from.blockRange(sel.$to);
263
- if (liftTarget(range) !== undefined) {
264
- tr.lift(range, target);
265
- }
266
- }
267
- });
268
- startPos = tr.mapping.map(startPos);
269
- endPos = tr.mapping.map(endPos);
270
- endPos = tr.doc.resolve(endPos).end(tr.doc.resolve(endPos).depth); // We want to select the entire node
271
-
272
- tr.setSelection(new TextSelection(tr.doc.resolve(startPos), tr.doc.resolve(endPos)));
273
- return {
274
- tr: tr,
275
- $from: tr.doc.resolve(startPos),
276
- $to: tr.doc.resolve(endPos)
277
- };
278
- }
279
-
280
- /**
281
- * Lift nodes in block to one level above.
282
- */
283
- export function liftSiblingNodes(view) {
284
- const {
285
- tr
286
- } = view.state;
287
- const {
288
- $from,
289
- $to
290
- } = view.state.selection;
291
- const blockStart = tr.doc.resolve($from.start($from.depth - 1));
292
- const blockEnd = tr.doc.resolve($to.end($to.depth - 1));
293
- const range = blockStart.blockRange(blockEnd);
294
- view.dispatch(tr.lift(range, blockStart.depth - 1));
295
- }
296
-
297
- /**
298
- * Lift sibling nodes to document-level and select them.
299
- */
300
- export function liftAndSelectSiblingNodes(view) {
301
- const {
302
- tr
303
- } = view.state;
304
- const {
305
- $from,
306
- $to
307
- } = view.state.selection;
308
- const blockStart = tr.doc.resolve($from.start($from.depth - 1));
309
- const blockEnd = tr.doc.resolve($to.end($to.depth - 1));
310
- // TODO: [ts30] handle void and null properly
311
- const range = blockStart.blockRange(blockEnd);
312
- tr.setSelection(new TextSelection(blockStart, blockEnd));
313
- tr.lift(range, blockStart.depth - 1);
314
- return tr;
315
- }
316
- export function wrapIn(nodeType, tr, $from, $to) {
317
- const range = $from.blockRange($to);
318
- const wrapping = range && findWrapping(range, nodeType);
319
- if (wrapping) {
320
- tr = tr.wrap(range, wrapping).scrollIntoView();
321
- }
322
- return tr;
323
- }
324
138
  const transformer = new JSONTransformer();
325
139
  export function toJSON(node) {
326
140
  return transformer.encode(node);
@@ -22,20 +22,6 @@ export const ruleWithAnalytics = getPayload => {
22
22
  };
23
23
  };
24
24
  };
25
- export const ruleWithTransform = transform => {
26
- return originalRule => {
27
- const onHandlerApply = (state, tr, matchResult) => {
28
- transform(state, tr);
29
- if (originalRule.onHandlerApply) {
30
- originalRule.onHandlerApply(state, tr, matchResult);
31
- }
32
- };
33
- return {
34
- ...originalRule,
35
- onHandlerApply
36
- };
37
- };
38
- };
39
25
  export const createRule = (match, handler) => {
40
26
  return {
41
27
  match,
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "180.1.0";
2
+ export const version = "181.0.1";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "180.1.0",
3
+ "version": "181.0.1",
4
4
  "sideEffects": false
5
5
  }
@@ -4,18 +4,17 @@ import _createClass from "@babel/runtime/helpers/createClass";
4
4
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
5
  import _regeneratorRuntime from "@babel/runtime/regenerator";
6
6
  import { Node } from 'prosemirror-model';
7
- import { TextSelection, NodeSelection } from 'prosemirror-state';
8
- import { findParentNode } from 'prosemirror-utils';
9
- import { toJSON } from '../utils';
10
- import { processRawValue, isEmptyDocument, processRawFragmentValue } from '../utils/document';
11
- import { getEditorValueWithMedia, __temporaryFixForConfigPanel as _temporaryFixForConfigPanel } from '../utils/action';
12
- import { createDispatch } from '../event-dispatcher';
13
- import { safeInsert } from 'prosemirror-utils';
14
7
  import { analyticsEventKey } from '@atlaskit/editor-common/utils';
8
+ import { NodeSelection, TextSelection } from 'prosemirror-state';
9
+ import { findParentNode, safeInsert } from 'prosemirror-utils';
10
+ import { createDispatch } from '../event-dispatcher';
11
+ import { getCollabProvider } from '../plugins/collab-edit/native-collab-provider-plugin';
15
12
  import { findNodePosWithLocalId } from '../plugins/extension/utils';
16
13
  import { getFeatureFlags } from '../plugins/feature-flags-context/get-feature-flags';
17
- import { getCollabProvider } from '../plugins/collab-edit/native-collab-provider-plugin';
14
+ import { toJSON } from '../utils';
15
+ import { getEditorValueWithMedia, __temporaryFixForConfigPanel as _temporaryFixForConfigPanel } from '../utils/action';
18
16
  import deprecationWarnings from '../utils/deprecation-warnings';
17
+ import { isEmptyDocument, processRawFragmentValue, processRawValue } from '../utils/document';
19
18
  import { findNodePosByFragmentLocalIds } from '../utils/nodes-by-localIds';
20
19
  var EditorActions = /*#__PURE__*/function () {
21
20
  function EditorActions() {
@@ -143,7 +142,22 @@ var EditorActions = /*#__PURE__*/function () {
143
142
  if (!this.editorView || this.editorView.hasFocus()) {
144
143
  return false;
145
144
  }
146
- this.editorView.focus();
145
+
146
+ // If we focus on componentDidMount the editor can crash due to a prosemirror error.
147
+ // This is fixed in prosemirror-view@1.23.7
148
+ // See: https:github.com/ProseMirror/prosemirror-view/commit/735b88107d1cbe7575a188edb85f05c22fb56e35
149
+ //
150
+ // We don't want this error to crash the editor in the case we can't
151
+ // focus correctly.
152
+ // Revert workaround in: https://product-fabric.atlassian.net/browse/ED-17172
153
+ try {
154
+ this.editorView.focus();
155
+ } catch (err) {
156
+ if (process.env.NODE_ENV !== 'production') {
157
+ // eslint-disable-next-line no-console
158
+ console.error('EditorView focus failed with an error', err);
159
+ }
160
+ }
147
161
  this.editorView.dispatch(this.editorView.state.tr.scrollIntoView());
148
162
  return true;
149
163
  }
@@ -14,7 +14,7 @@ export var attachPayloadIntoTransaction = function attachPayloadIntoTransaction(
14
14
  tr.step(new AnalyticsStep([{
15
15
  payload: payload,
16
16
  channel: channel
17
- }], actionsToIgnore, tr.selection.$from.pos) // We need to create the step based on a position, this prevent split history for relative changes.
17
+ }], actionsToIgnore, editorState.selection.$from.pos) // We need to create the step based on a position, this prevent split history for relative changes.
18
18
  );
19
19
 
20
20
  // When you add a new step all the storedMarks are removed it
@@ -3,11 +3,9 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
3
  import _inherits from "@babel/runtime/helpers/inherits";
4
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
5
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
7
6
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
7
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
9
8
  import { ReactEditorView as BaseReactEditorView } from './ReactEditorViewInternal';
10
- import getEditorPlugins from '../utils/get-editor-plugins';
11
9
  import { injectIntl } from 'react-intl-next';
12
10
  export var ReactEditorView = /*#__PURE__*/function (_BaseReactEditorView) {
13
11
  _inherits(ReactEditorView, _BaseReactEditorView);
@@ -18,7 +16,4 @@ export var ReactEditorView = /*#__PURE__*/function (_BaseReactEditorView) {
18
16
  }
19
17
  return _createClass(ReactEditorView);
20
18
  }(BaseReactEditorView);
21
- _defineProperty(ReactEditorView, "defaultProps", {
22
- getEditorPlugins: getEditorPlugins
23
- });
24
19
  export default injectIntl(ReactEditorView);
@@ -40,8 +40,7 @@ import { EVENT_NAME_DISPATCH_TRANSACTION, EVENT_NAME_STATE_APPLY, EVENT_NAME_UPD
40
40
  import { PROSEMIRROR_RENDERED_NORMAL_SEVERITY_THRESHOLD, PROSEMIRROR_RENDERED_DEGRADED_SEVERITY_THRESHOLD, DEFAULT_SAMPLING_RATE_VALID_TRANSACTIONS } from './consts';
41
41
  import { getContextIdentifier } from '../plugins/base/pm-plugins/context-identifier';
42
42
  import ReactEditorViewContext from './ReactEditorViewContext';
43
- import { createInsertNodeAPI } from '../insert-api/api';
44
- import { createEditorAnalyticsAPI } from '../analytics-api/api';
43
+ import { EditorPluginInjectionAPI } from '@atlaskit/editor-common/preset';
45
44
  function handleEditorFocus(view) {
46
45
  if (view.hasFocus()) {
47
46
  return;
@@ -50,31 +49,13 @@ function handleEditorFocus(view) {
50
49
  view.focus();
51
50
  }, 0);
52
51
  }
53
- var EMPTY = [];
54
- export function shouldReconfigureState(props, nextProps) {
55
- var _props$dangerouslyApp, _props$dangerouslyApp2, _nextProps$dangerousl, _nextProps$dangerousl2;
56
- var prevPlugins = (_props$dangerouslyApp = (_props$dangerouslyApp2 = props.dangerouslyAppendPlugins) === null || _props$dangerouslyApp2 === void 0 ? void 0 : _props$dangerouslyApp2.__plugins) !== null && _props$dangerouslyApp !== void 0 ? _props$dangerouslyApp : EMPTY;
57
- var nextPlugins = (_nextProps$dangerousl = (_nextProps$dangerousl2 = nextProps.dangerouslyAppendPlugins) === null || _nextProps$dangerousl2 === void 0 ? void 0 : _nextProps$dangerousl2.__plugins) !== null && _nextProps$dangerousl !== void 0 ? _nextProps$dangerousl : EMPTY;
58
- if (nextPlugins.length !== prevPlugins.length || prevPlugins.some(function (p) {
59
- return nextPlugins.some(function (n) {
60
- return n.name === p.name && n !== p;
61
- });
62
- })) {
63
- return true;
64
- }
65
- var mobileProperties = props.appearance === 'mobile' ? ['featureFlags', 'quickInsert'] : [];
66
- var properties = ['appearance', 'persistScrollGutter', 'allowUndoRedoButtons', 'placeholder', 'sanitizePrivateContent'].concat(mobileProperties);
67
- return properties.reduce(function (acc, curr) {
68
- return acc || props[curr] !== nextProps[curr];
69
- }, false);
70
- }
71
52
  export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
72
53
  _inherits(ReactEditorView, _React$Component);
73
54
  var _super = _createSuper(ReactEditorView);
74
- function ReactEditorView(_props, context) {
55
+ function ReactEditorView(props, context) {
75
56
  var _this;
76
57
  _classCallCheck(this, ReactEditorView);
77
- _this = _super.call(this, _props, context);
58
+ _this = _super.call(this, props, context);
78
59
  _defineProperty(_assertThisInitialized(_this), "editorRef", /*#__PURE__*/React.createRef());
79
60
  _defineProperty(_assertThisInitialized(_this), "canDispatchTransactions", true);
80
61
  _defineProperty(_assertThisInitialized(_this), "onPluginObservation", function (report, editorState) {
@@ -88,6 +69,10 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
88
69
  }
89
70
  });
90
71
  });
72
+ _defineProperty(_assertThisInitialized(_this), "getEditorState", function () {
73
+ var _this$view;
74
+ return (_this$view = _this.view) === null || _this$view === void 0 ? void 0 : _this$view.state;
75
+ });
91
76
  _defineProperty(_assertThisInitialized(_this), "formatFullWidthAppearance", function (appearance) {
92
77
  if (appearance === 'full-width') {
93
78
  return FULL_WIDTH_MODE.FULL_WIDTH;
@@ -135,48 +120,6 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
135
120
  sel.removeAllRanges();
136
121
  }
137
122
  });
138
- _defineProperty(_assertThisInitialized(_this), "reconfigureState", function (props) {
139
- if (!_this.view) {
140
- return;
141
- }
142
-
143
- // We cannot currently guarentee when all the portals will have re-rendered during a reconfigure
144
- // so we blur here to stop ProseMirror from trying to apply selection to detached nodes or
145
- // nodes that haven't been re-rendered to the document yet.
146
- _this.blur();
147
- var editorPlugins = _this.getPlugins(props.editorProps, _this.props.editorProps, _this.props.createAnalyticsEvent);
148
- _this.config = processPluginsList(editorPlugins);
149
- var state = _this.editorState;
150
- var plugins = createPMPlugins({
151
- schema: state.schema,
152
- dispatch: _this.dispatch,
153
- errorReporter: _this.errorReporter,
154
- editorConfig: _this.config,
155
- eventDispatcher: _this.eventDispatcher,
156
- providerFactory: props.providerFactory,
157
- portalProviderAPI: props.portalProviderAPI,
158
- reactContext: function reactContext() {
159
- return _this.context;
160
- },
161
- dispatchAnalyticsEvent: _this.dispatchAnalyticsEvent,
162
- performanceTracking: props.editorProps.performanceTracking,
163
- transactionTracker: _this.transactionTracker,
164
- featureFlags: createFeatureFlagsFromProps(props.editorProps),
165
- getIntl: function getIntl() {
166
- return _this.props.intl;
167
- }
168
- });
169
- var newState = state.reconfigure({
170
- plugins: plugins
171
- });
172
-
173
- // need to update the state first so when the view builds the nodeviews it is
174
- // using the latest plugins
175
- _this.view.updateState(newState);
176
- return _this.view.update(_objectSpread(_objectSpread({}, _this.view.props), {}, {
177
- state: newState
178
- }));
179
- });
180
123
  _defineProperty(_assertThisInitialized(_this), "handleAnalyticsEvent", function (payload) {
181
124
  if (!_this.props.allowAnalyticsGASV3) {
182
125
  return;
@@ -207,7 +150,7 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
207
150
  return _this.editorState;
208
151
  }
209
152
  } else {
210
- _this.config = processPluginsList(_this.getPlugins(options.props.editorProps, undefined, options.props.createAnalyticsEvent));
153
+ _this.config = processPluginsList(_this.getPlugins(options.props.preset));
211
154
  schema = createSchema(_this.config);
212
155
  }
213
156
  var contentTransformerProvider = options.props.editorProps.contentTransformerProvider;
@@ -322,6 +265,10 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
322
265
  var _this$experienceStore3;
323
266
  (_this$experienceStore3 = _this.experienceStore) === null || _this$experienceStore3 === void 0 ? void 0 : _this$experienceStore3.mark(EditorExperience.interaction, 'viewUpdateState', startTime + duration);
324
267
  });
268
+ _this.pluginInjectionAPI.onEditorViewUpdated({
269
+ newEditorState: editorState,
270
+ oldEditorState: oldEditorState
271
+ });
325
272
  startMeasure(EVENT_NAME_VIEW_STATE_UPDATED);
326
273
  _this.onEditorViewStateUpdated({
327
274
  originalTransaction: transaction,
@@ -449,6 +396,10 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
449
396
  _this.view = new EditorView({
450
397
  mount: node
451
398
  }, _this.getDirectEditorProps());
399
+ _this.pluginInjectionAPI.onEditorViewUpdated({
400
+ newEditorState: _this.view.state,
401
+ oldEditorState: undefined
402
+ });
452
403
  });
453
404
  _defineProperty(_assertThisInitialized(_this), "handleEditorViewRef", function (node) {
454
405
  if (!_this.view && node) {
@@ -531,9 +482,12 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
531
482
  "aria-label": _this.props.intl.formatMessage(editorMessages.editorAssistiveLabel),
532
483
  role: "textbox"
533
484
  }));
485
+ _this.pluginInjectionAPI = new EditorPluginInjectionAPI({
486
+ getEditorState: _this.getEditorState
487
+ });
534
488
  _this.eventDispatcher = new EventDispatcher();
535
489
  _this.dispatch = createDispatch(_this.eventDispatcher);
536
- _this.errorReporter = createErrorReporter(_props.editorProps.errorReporterHandler);
490
+ _this.errorReporter = createErrorReporter(props.editorProps.errorReporterHandler);
537
491
  _this.transactionTracker = new TransactionTracker();
538
492
  _this.pluginPerformanceObserver = new PluginPerformanceObserver(function (report) {
539
493
  return _this.onPluginObservation(report, _this.editorState);
@@ -561,11 +515,11 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
561
515
  _this.eventDispatcher.on(analyticsEventKey, _this.handleAnalyticsEvent);
562
516
  _this.eventDispatcher.on('resetEditorState', _this.resetEditorState);
563
517
  _this.editorState = _this.createEditorState({
564
- props: _props,
518
+ props: props,
565
519
  context: context,
566
- doc: _props.editorProps.defaultValue,
520
+ doc: props.editorProps.defaultValue,
567
521
  // ED-4759: Don't set selection at end for full-page editor - should be at start.
568
- selectionAtStart: isFullPage(_props.editorProps.appearance)
522
+ selectionAtStart: isFullPage(props.editorProps.appearance)
569
523
  });
570
524
  _this.dispatchAnalyticsEvent({
571
525
  action: ACTION.STARTED,
@@ -625,7 +579,7 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
625
579
  }
626
580
  var appearance = this.props.editorProps.appearance;
627
581
  var nextAppearance = nextProps.editorProps.appearance;
628
- if (shouldReconfigureState(this.props.editorProps, nextProps.editorProps)) {
582
+ if (this.props.preset !== nextProps.preset) {
629
583
  this.reconfigureState(nextProps);
630
584
  }
631
585
  if (nextAppearance !== appearance) {
@@ -645,6 +599,51 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
645
599
  this.pluginPerformanceObserver.disconnect();
646
600
  }
647
601
  }
602
+ }, {
603
+ key: "reconfigureState",
604
+ value: function reconfigureState(props) {
605
+ var _this2 = this;
606
+ if (!this.view) {
607
+ return;
608
+ }
609
+
610
+ // We cannot currently guarentee when all the portals will have re-rendered during a reconfigure
611
+ // so we blur here to stop ProseMirror from trying to apply selection to detached nodes or
612
+ // nodes that haven't been re-rendered to the document yet.
613
+ this.blur();
614
+ var editorPlugins = this.getPlugins(props.preset);
615
+ this.config = processPluginsList(editorPlugins);
616
+ var state = this.editorState;
617
+ var plugins = createPMPlugins({
618
+ schema: state.schema,
619
+ dispatch: this.dispatch,
620
+ errorReporter: this.errorReporter,
621
+ editorConfig: this.config,
622
+ eventDispatcher: this.eventDispatcher,
623
+ providerFactory: props.providerFactory,
624
+ portalProviderAPI: props.portalProviderAPI,
625
+ reactContext: function reactContext() {
626
+ return _this2.context;
627
+ },
628
+ dispatchAnalyticsEvent: this.dispatchAnalyticsEvent,
629
+ performanceTracking: props.editorProps.performanceTracking,
630
+ transactionTracker: this.transactionTracker,
631
+ featureFlags: createFeatureFlagsFromProps(props.editorProps),
632
+ getIntl: function getIntl() {
633
+ return _this2.props.intl;
634
+ }
635
+ });
636
+ var newState = state.reconfigure({
637
+ plugins: plugins
638
+ });
639
+
640
+ // need to update the state first so when the view builds the nodeviews it is
641
+ // using the latest plugins
642
+ this.view.updateState(newState);
643
+ return this.view.update(_objectSpread(_objectSpread({}, this.view.props), {}, {
644
+ state: newState
645
+ }));
646
+ }
648
647
  }, {
649
648
  key: "componentDidMount",
650
649
  value: function componentDidMount() {
@@ -693,39 +692,11 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
693
692
  key: "getPlugins",
694
693
  value:
695
694
  // Helper to allow tests to inject plugins directly
696
- function getPlugins(editorProps, prevEditorProps, createAnalyticsEvent) {
697
- var _this2 = this,
698
- _this$props$getEditor,
699
- _this$props$getEditor2,
700
- _this$props;
701
- var insertNodeAPI = createInsertNodeAPI({
702
- getEditorView: function getEditorView() {
703
- return _this2.view;
704
- },
705
- getEditorPlugins: function getEditorPlugins() {
706
- return _this2.editorPlugins;
707
- }
695
+ function getPlugins(preset) {
696
+ var plugins = preset.build({
697
+ pluginInjectionAPI: this.pluginInjectionAPI
708
698
  });
709
- var editorAnalyticsAPI = createEditorAnalyticsAPI({
710
- getEditorView: function getEditorView() {
711
- return _this2.view;
712
- },
713
- getCreateUIAnalyticsEvent: function getCreateUIAnalyticsEvent() {
714
- return createAnalyticsEvent;
715
- }
716
- });
717
- var getPluginsProps = {
718
- props: editorProps,
719
- prevAppearance: prevEditorProps === null || prevEditorProps === void 0 ? void 0 : prevEditorProps.appearance,
720
- createAnalyticsEvent: createAnalyticsEvent,
721
- insertNodeAPI: insertNodeAPI,
722
- editorAnalyticsAPI: editorAnalyticsAPI
723
- };
724
- if (this.props.getEditorPlugins === undefined) {
725
- // eslint-disable-next-line no-console
726
- console.error('getEditorPlugins is undefined in ReactEditorViewInternal - no editor plugins will be added.');
727
- }
728
- this.editorPlugins = (_this$props$getEditor = (_this$props$getEditor2 = (_this$props = this.props).getEditorPlugins) === null || _this$props$getEditor2 === void 0 ? void 0 : _this$props$getEditor2.call(_this$props, getPluginsProps)) !== null && _this$props$getEditor !== void 0 ? _this$props$getEditor : [];
699
+ this.editorPlugins = plugins;
729
700
  return this.editorPlugins;
730
701
  }
731
702
  }, {