@atlaskit/editor-core 180.1.0 → 181.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 (404) hide show
  1. package/CHANGELOG.md +43 -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 +30 -3
  7. package/dist/cjs/create-editor/preset-utils.js +27 -0
  8. package/dist/cjs/editor-next/editor-internal.js +2 -2
  9. package/dist/cjs/editor-next/editor-migration-component.js +18 -2
  10. package/dist/cjs/editor-next/hooks/useProviderFactory.js +4 -3
  11. package/dist/cjs/editor-next/index.js +13 -9
  12. package/dist/cjs/editor-next/utils/getProvidersFromEditorProps.js +41 -0
  13. package/dist/cjs/editor-next/utils/handleProviders.js +17 -22
  14. package/dist/cjs/editor.js +20 -13
  15. package/dist/cjs/keymaps/consts.js +1 -16
  16. package/dist/cjs/labs/next/presets/cxhtml.js +56 -55
  17. package/dist/cjs/labs/next/presets/default.js +15 -42
  18. package/dist/cjs/labs/next/presets/mobile.js +76 -89
  19. package/dist/cjs/labs/next/presets/universal.js +330 -257
  20. package/dist/cjs/labs/next/presets/useUniversalPreset.js +36 -0
  21. package/dist/cjs/plugins/analytics/plugin.js +6 -0
  22. package/dist/cjs/plugins/annotation/utils.js +2 -36
  23. package/dist/cjs/plugins/base/pm-plugins/react-nodeview.js +2 -7
  24. package/dist/cjs/plugins/block-type/pm-plugins/input-rule.js +0 -10
  25. package/dist/cjs/plugins/caption/index.js +0 -7
  26. package/dist/cjs/plugins/card/nodeviews/blockCard.js +9 -4
  27. package/dist/cjs/plugins/card/nodeviews/inlineCard.js +6 -2
  28. package/dist/cjs/plugins/card/pm-plugins/main.js +6 -3
  29. package/dist/cjs/plugins/card/pm-plugins/util/resolve.js +4 -0
  30. package/dist/cjs/plugins/code-block/pm-plugins/main-state.js +2 -14
  31. package/dist/cjs/plugins/collab-edit/provider/index.js +1 -8
  32. package/dist/cjs/plugins/collab-edit/provider/types.js +1 -12
  33. package/dist/cjs/plugins/context-panel/index.js +1 -6
  34. package/dist/cjs/plugins/data-consumer/index.js +0 -8
  35. package/dist/cjs/plugins/date/utils/internal.js +0 -4
  36. package/dist/cjs/plugins/extension/commands.js +1 -8
  37. package/dist/cjs/plugins/extension/ui/Extension/Extension/index.js +9 -2
  38. package/dist/cjs/plugins/extension/ui/Extension/Extension/styles.js +2 -2
  39. package/dist/cjs/plugins/extension/ui/Extension/Lozenge.js +1 -0
  40. package/dist/cjs/plugins/feedback-dialog/index.js +1 -4
  41. package/dist/cjs/plugins/floating-toolbar/ui/Button.js +7 -3
  42. package/dist/cjs/plugins/floating-toolbar/ui/Dropdown.js +10 -5
  43. package/dist/cjs/plugins/floating-toolbar/ui/EmojiPickerButton.js +2 -9
  44. package/dist/cjs/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +1 -0
  45. package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +24 -8
  46. package/dist/cjs/plugins/floating-toolbar/utils.js +0 -12
  47. package/dist/cjs/plugins/fragment/index.js +0 -8
  48. package/dist/cjs/plugins/help-dialog/commands.js +2 -6
  49. package/dist/cjs/plugins/image-upload/pm-plugins/main.js +50 -12
  50. package/dist/cjs/plugins/layout/styles.js +10 -1
  51. package/dist/cjs/plugins/list/utils/find.js +0 -28
  52. package/dist/cjs/plugins/list/utils/indentation.js +1 -25
  53. package/dist/cjs/plugins/list/utils/node.js +0 -5
  54. package/dist/cjs/plugins/list/utils/selection.js +2 -15
  55. package/dist/cjs/plugins/media/utils/media-common.js +1 -20
  56. package/dist/cjs/plugins/mentions/nodeviews/mention.js +100 -16
  57. package/dist/cjs/plugins/mentions/type-ahead/index.js +1 -18
  58. package/dist/cjs/plugins/mentions/ui/InviteItem/index.js +1 -3
  59. package/dist/cjs/plugins/mobile-dimensions/index.js +1 -4
  60. package/dist/cjs/plugins/paste/index.js +1 -2
  61. package/dist/cjs/plugins/paste/pm-plugins/analytics.js +123 -87
  62. package/dist/cjs/plugins/paste/util/index.js +0 -46
  63. package/dist/cjs/plugins/quick-insert/assets/index.js +1 -27
  64. package/dist/cjs/plugins/selection/gap-cursor/actions.js +49 -44
  65. package/dist/cjs/plugins/status/utils.js +1 -15
  66. package/dist/cjs/plugins/text-color/pm-plugins/main.js +0 -1
  67. package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/index.js +7 -5
  68. package/dist/cjs/plugins/text-formatting/pm-plugins/smart-input-rule.js +8 -2
  69. package/dist/cjs/plugins/text-formatting/utils.js +1 -26
  70. package/dist/cjs/plugins/type-ahead/constants.js +1 -7
  71. package/dist/cjs/plugins/type-ahead/pm-plugins/decorations.js +2 -35
  72. package/dist/cjs/plugins/type-ahead/utils.js +3 -22
  73. package/dist/cjs/test-utils.js +4 -12
  74. package/dist/cjs/ui/Appearance/Comment/Toolbar.js +43 -8
  75. package/dist/cjs/ui/ColorPalette/index.js +18 -0
  76. package/dist/cjs/ui/ColorPickerButton/index.js +6 -2
  77. package/dist/cjs/ui/ConfigPanel/Fields/Expand.js +1 -0
  78. package/dist/cjs/ui/ConfigPanel/utils.js +4 -17
  79. package/dist/cjs/ui/ContentStyles/index.js +1 -1
  80. package/dist/cjs/ui/ElementBrowser/ModalElementBrowser.js +1 -1
  81. package/dist/cjs/ui/ElementBrowser/constants.js +1 -3
  82. package/dist/cjs/ui/Resizer/utils.js +1 -3
  83. package/dist/cjs/ui/styles.js +3 -7
  84. package/dist/cjs/utils/get-editor-plugins.js +1 -3
  85. package/dist/cjs/utils/index.js +9 -269
  86. package/dist/cjs/utils/input-rules.js +1 -15
  87. package/dist/cjs/version-wrapper.js +1 -1
  88. package/dist/cjs/version.json +1 -1
  89. package/dist/es2019/actions/index.js +23 -9
  90. package/dist/es2019/analytics-api/attach-payload-into-transaction.js +1 -1
  91. package/dist/es2019/create-editor/ReactEditorView.js +0 -5
  92. package/dist/es2019/create-editor/ReactEditorViewInternal.js +67 -82
  93. package/dist/es2019/create-editor/create-plugins-list.js +25 -3
  94. package/dist/es2019/create-editor/preset-utils.js +15 -0
  95. package/dist/es2019/editor-next/editor-internal.js +2 -2
  96. package/dist/es2019/editor-next/editor-migration-component.js +19 -2
  97. package/dist/es2019/editor-next/hooks/useProviderFactory.js +4 -3
  98. package/dist/es2019/editor-next/index.js +13 -7
  99. package/dist/es2019/editor-next/utils/getProvidersFromEditorProps.js +36 -0
  100. package/dist/es2019/editor-next/utils/handleProviders.js +18 -24
  101. package/dist/es2019/editor.js +20 -11
  102. package/dist/es2019/keymaps/consts.js +7 -11
  103. package/dist/es2019/labs/next/presets/cxhtml.js +56 -53
  104. package/dist/es2019/labs/next/presets/default.js +18 -38
  105. package/dist/es2019/labs/next/presets/mobile.js +88 -88
  106. package/dist/es2019/labs/next/presets/universal.js +338 -265
  107. package/dist/es2019/labs/next/presets/useUniversalPreset.js +25 -0
  108. package/dist/es2019/plugins/analytics/plugin.js +7 -0
  109. package/dist/es2019/plugins/annotation/utils.js +2 -30
  110. package/dist/es2019/plugins/base/pm-plugins/react-nodeview.js +1 -3
  111. package/dist/es2019/plugins/block-type/pm-plugins/input-rule.js +3 -9
  112. package/dist/es2019/plugins/caption/index.js +0 -2
  113. package/dist/es2019/plugins/card/nodeviews/blockCard.js +8 -4
  114. package/dist/es2019/plugins/card/nodeviews/inlineCard.js +6 -2
  115. package/dist/es2019/plugins/card/pm-plugins/main.js +6 -3
  116. package/dist/es2019/plugins/card/pm-plugins/util/resolve.js +4 -0
  117. package/dist/es2019/plugins/code-block/pm-plugins/main-state.js +1 -9
  118. package/dist/es2019/plugins/collab-edit/provider/index.js +1 -1
  119. package/dist/es2019/plugins/collab-edit/provider/types.js +1 -10
  120. package/dist/es2019/plugins/context-panel/index.js +0 -3
  121. package/dist/es2019/plugins/data-consumer/index.js +0 -7
  122. package/dist/es2019/plugins/date/utils/internal.js +0 -3
  123. package/dist/es2019/plugins/extension/commands.js +0 -6
  124. package/dist/es2019/plugins/extension/ui/Extension/Extension/index.js +12 -2
  125. package/dist/es2019/plugins/extension/ui/Extension/Extension/styles.js +3 -0
  126. package/dist/es2019/plugins/extension/ui/Extension/Lozenge.js +1 -0
  127. package/dist/es2019/plugins/feedback-dialog/index.js +0 -2
  128. package/dist/es2019/plugins/floating-toolbar/ui/Button.js +7 -3
  129. package/dist/es2019/plugins/floating-toolbar/ui/Dropdown.js +10 -5
  130. package/dist/es2019/plugins/floating-toolbar/ui/EmojiPickerButton.js +1 -11
  131. package/dist/es2019/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +1 -0
  132. package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +21 -4
  133. package/dist/es2019/plugins/floating-toolbar/utils.js +0 -10
  134. package/dist/es2019/plugins/fragment/index.js +0 -7
  135. package/dist/es2019/plugins/help-dialog/commands.js +1 -2
  136. package/dist/es2019/plugins/image-upload/pm-plugins/main.js +47 -5
  137. package/dist/es2019/plugins/layout/styles.js +12 -4
  138. package/dist/es2019/plugins/list/utils/find.js +0 -27
  139. package/dist/es2019/plugins/list/utils/indentation.js +0 -23
  140. package/dist/es2019/plugins/list/utils/node.js +1 -4
  141. package/dist/es2019/plugins/list/utils/selection.js +2 -15
  142. package/dist/es2019/plugins/media/utils/media-common.js +1 -19
  143. package/dist/es2019/plugins/mentions/nodeviews/mention.js +64 -16
  144. package/dist/es2019/plugins/mentions/type-ahead/index.js +1 -14
  145. package/dist/es2019/plugins/mentions/ui/InviteItem/index.js +1 -2
  146. package/dist/es2019/plugins/mobile-dimensions/index.js +0 -3
  147. package/dist/es2019/plugins/paste/index.js +1 -2
  148. package/dist/es2019/plugins/paste/pm-plugins/analytics.js +126 -94
  149. package/dist/es2019/plugins/paste/util/index.js +5 -45
  150. package/dist/es2019/plugins/quick-insert/assets/index.js +0 -8
  151. package/dist/es2019/plugins/selection/gap-cursor/actions.js +56 -56
  152. package/dist/es2019/plugins/status/utils.js +1 -11
  153. package/dist/es2019/plugins/text-color/pm-plugins/main.js +1 -1
  154. package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/index.js +7 -5
  155. package/dist/es2019/plugins/text-formatting/pm-plugins/smart-input-rule.js +8 -2
  156. package/dist/es2019/plugins/text-formatting/utils.js +0 -19
  157. package/dist/es2019/plugins/type-ahead/constants.js +0 -5
  158. package/dist/es2019/plugins/type-ahead/pm-plugins/decorations.js +0 -35
  159. package/dist/es2019/plugins/type-ahead/utils.js +0 -23
  160. package/dist/es2019/test-utils.js +4 -7
  161. package/dist/es2019/ui/Appearance/Comment/Toolbar.js +40 -6
  162. package/dist/es2019/ui/ColorPalette/index.js +2 -1
  163. package/dist/es2019/ui/ColorPickerButton/index.js +6 -2
  164. package/dist/es2019/ui/ConfigPanel/Fields/Expand.js +1 -0
  165. package/dist/es2019/ui/ConfigPanel/utils.js +0 -6
  166. package/dist/es2019/ui/ContentStyles/index.js +1 -1
  167. package/dist/es2019/ui/ElementBrowser/ModalElementBrowser.js +1 -1
  168. package/dist/es2019/ui/ElementBrowser/constants.js +0 -1
  169. package/dist/es2019/ui/Resizer/utils.js +0 -1
  170. package/dist/es2019/ui/styles.js +0 -6
  171. package/dist/es2019/utils/get-editor-plugins.js +1 -3
  172. package/dist/es2019/utils/index.js +13 -199
  173. package/dist/es2019/utils/input-rules.js +0 -14
  174. package/dist/es2019/version-wrapper.js +1 -1
  175. package/dist/es2019/version.json +1 -1
  176. package/dist/esm/actions/index.js +23 -9
  177. package/dist/esm/analytics-api/attach-payload-into-transaction.js +1 -1
  178. package/dist/esm/create-editor/ReactEditorView.js +0 -5
  179. package/dist/esm/create-editor/ReactEditorViewInternal.js +73 -102
  180. package/dist/esm/create-editor/create-plugins-list.js +29 -3
  181. package/dist/esm/create-editor/preset-utils.js +21 -0
  182. package/dist/esm/editor-next/editor-internal.js +2 -2
  183. package/dist/esm/editor-next/editor-migration-component.js +18 -2
  184. package/dist/esm/editor-next/hooks/useProviderFactory.js +4 -3
  185. package/dist/esm/editor-next/index.js +13 -9
  186. package/dist/esm/editor-next/utils/getProvidersFromEditorProps.js +35 -0
  187. package/dist/esm/editor-next/utils/handleProviders.js +17 -22
  188. package/dist/esm/editor.js +20 -13
  189. package/dist/esm/keymaps/consts.js +7 -11
  190. package/dist/esm/labs/next/presets/cxhtml.js +56 -55
  191. package/dist/esm/labs/next/presets/default.js +18 -41
  192. package/dist/esm/labs/next/presets/mobile.js +88 -90
  193. package/dist/esm/labs/next/presets/universal.js +330 -257
  194. package/dist/esm/labs/next/presets/useUniversalPreset.js +29 -0
  195. package/dist/esm/plugins/analytics/plugin.js +6 -0
  196. package/dist/esm/plugins/annotation/utils.js +2 -32
  197. package/dist/esm/plugins/base/pm-plugins/react-nodeview.js +1 -5
  198. package/dist/esm/plugins/block-type/pm-plugins/input-rule.js +3 -9
  199. package/dist/esm/plugins/caption/index.js +0 -2
  200. package/dist/esm/plugins/card/nodeviews/blockCard.js +9 -4
  201. package/dist/esm/plugins/card/nodeviews/inlineCard.js +6 -2
  202. package/dist/esm/plugins/card/pm-plugins/main.js +6 -3
  203. package/dist/esm/plugins/card/pm-plugins/util/resolve.js +4 -0
  204. package/dist/esm/plugins/code-block/pm-plugins/main-state.js +0 -10
  205. package/dist/esm/plugins/collab-edit/provider/index.js +1 -1
  206. package/dist/esm/plugins/collab-edit/provider/types.js +1 -10
  207. package/dist/esm/plugins/context-panel/index.js +0 -3
  208. package/dist/esm/plugins/data-consumer/index.js +0 -7
  209. package/dist/esm/plugins/date/utils/internal.js +0 -3
  210. package/dist/esm/plugins/extension/commands.js +0 -6
  211. package/dist/esm/plugins/extension/ui/Extension/Extension/index.js +9 -2
  212. package/dist/esm/plugins/extension/ui/Extension/Extension/styles.js +2 -2
  213. package/dist/esm/plugins/extension/ui/Extension/Lozenge.js +1 -0
  214. package/dist/esm/plugins/feedback-dialog/index.js +0 -2
  215. package/dist/esm/plugins/floating-toolbar/ui/Button.js +7 -3
  216. package/dist/esm/plugins/floating-toolbar/ui/Dropdown.js +10 -5
  217. package/dist/esm/plugins/floating-toolbar/ui/EmojiPickerButton.js +2 -9
  218. package/dist/esm/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +1 -0
  219. package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +24 -8
  220. package/dist/esm/plugins/floating-toolbar/utils.js +0 -10
  221. package/dist/esm/plugins/fragment/index.js +0 -7
  222. package/dist/esm/plugins/help-dialog/commands.js +0 -3
  223. package/dist/esm/plugins/image-upload/pm-plugins/main.js +51 -12
  224. package/dist/esm/plugins/layout/styles.js +11 -2
  225. package/dist/esm/plugins/list/utils/find.js +0 -27
  226. package/dist/esm/plugins/list/utils/indentation.js +0 -23
  227. package/dist/esm/plugins/list/utils/node.js +1 -4
  228. package/dist/esm/plugins/list/utils/selection.js +2 -12
  229. package/dist/esm/plugins/media/utils/media-common.js +1 -17
  230. package/dist/esm/plugins/mentions/nodeviews/mention.js +97 -16
  231. package/dist/esm/plugins/mentions/type-ahead/index.js +1 -18
  232. package/dist/esm/plugins/mentions/ui/InviteItem/index.js +1 -2
  233. package/dist/esm/plugins/mobile-dimensions/index.js +0 -3
  234. package/dist/esm/plugins/paste/index.js +1 -2
  235. package/dist/esm/plugins/paste/pm-plugins/analytics.js +122 -86
  236. package/dist/esm/plugins/paste/util/index.js +5 -45
  237. package/dist/esm/plugins/quick-insert/assets/index.js +0 -20
  238. package/dist/esm/plugins/selection/gap-cursor/actions.js +52 -45
  239. package/dist/esm/plugins/status/utils.js +1 -13
  240. package/dist/esm/plugins/text-color/pm-plugins/main.js +1 -1
  241. package/dist/esm/plugins/text-color/ui/ToolbarTextColor/index.js +7 -5
  242. package/dist/esm/plugins/text-formatting/pm-plugins/smart-input-rule.js +8 -2
  243. package/dist/esm/plugins/text-formatting/utils.js +0 -21
  244. package/dist/esm/plugins/type-ahead/constants.js +0 -5
  245. package/dist/esm/plugins/type-ahead/pm-plugins/decorations.js +0 -31
  246. package/dist/esm/plugins/type-ahead/utils.js +2 -20
  247. package/dist/esm/test-utils.js +4 -7
  248. package/dist/esm/ui/Appearance/Comment/Toolbar.js +41 -6
  249. package/dist/esm/ui/ColorPalette/index.js +2 -1
  250. package/dist/esm/ui/ColorPickerButton/index.js +6 -2
  251. package/dist/esm/ui/ConfigPanel/Fields/Expand.js +1 -0
  252. package/dist/esm/ui/ConfigPanel/utils.js +3 -14
  253. package/dist/esm/ui/ContentStyles/index.js +1 -1
  254. package/dist/esm/ui/ElementBrowser/ModalElementBrowser.js +1 -1
  255. package/dist/esm/ui/ElementBrowser/constants.js +0 -1
  256. package/dist/esm/ui/Resizer/utils.js +0 -1
  257. package/dist/esm/ui/styles.js +2 -5
  258. package/dist/esm/utils/get-editor-plugins.js +1 -3
  259. package/dist/esm/utils/index.js +13 -196
  260. package/dist/esm/utils/input-rules.js +0 -13
  261. package/dist/esm/version-wrapper.js +1 -1
  262. package/dist/esm/version.json +1 -1
  263. package/dist/types/actions/index.d.ts +4 -4
  264. package/dist/types/create-editor/ReactEditorView.d.ts +0 -3
  265. package/dist/types/create-editor/ReactEditorViewInternal.d.ts +9 -7
  266. package/dist/types/create-editor/ReactEditorViewNext.d.ts +3 -4
  267. package/dist/types/create-editor/create-plugins-list.d.ts +3 -5
  268. package/dist/types/create-editor/preset-utils.d.ts +2 -0
  269. package/dist/types/editor-next/editor-internal.d.ts +9 -9
  270. package/dist/types/editor-next/hooks/useMeasureEditorMountTime.d.ts +2 -2
  271. package/dist/types/editor-next/hooks/useProviderFactory.d.ts +2 -2
  272. package/dist/types/editor-next/index.d.ts +6 -6
  273. package/dist/types/editor-next/utils/deprecationWarnings.d.ts +2 -2
  274. package/dist/types/editor-next/utils/editorPropTypes.d.ts +1 -1
  275. package/dist/types/editor-next/utils/getProvidersFromEditorProps.d.ts +9 -0
  276. package/dist/types/editor-next/utils/handleProviders.d.ts +2 -2
  277. package/dist/types/editor-next/utils/onEditorCreated.d.ts +2 -2
  278. package/dist/types/editor-next/utils/sendDurationAnalytics.d.ts +1 -1
  279. package/dist/types/editor.d.ts +7 -4
  280. package/dist/types/keymaps/consts.d.ts +0 -11
  281. package/dist/types/labs/next/presets/cxhtml.d.ts +33 -1
  282. package/dist/types/labs/next/presets/default.d.ts +67 -10
  283. package/dist/types/labs/next/presets/mobile.d.ts +33 -1
  284. package/dist/types/labs/next/presets/universal.d.ts +5 -13
  285. package/dist/types/labs/next/presets/useUniversalPreset.d.ts +7 -0
  286. package/dist/types/nodeviews/context-adapter.d.ts +0 -1
  287. package/dist/types/nodeviews/index.d.ts +0 -1
  288. package/dist/types/plugins/alignment/pm-plugins/types.d.ts +0 -11
  289. package/dist/types/plugins/annotation/utils.d.ts +0 -17
  290. package/dist/types/plugins/base/pm-plugins/react-nodeview.d.ts +2 -3
  291. package/dist/types/plugins/block-type/pm-plugins/input-rule.d.ts +2 -6
  292. package/dist/types/plugins/caption/index.d.ts +0 -2
  293. package/dist/types/plugins/card/nodeviews/blockCard.d.ts +2 -10
  294. package/dist/types/plugins/card/nodeviews/genericCard.d.ts +1 -0
  295. package/dist/types/plugins/card/nodeviews/inlineCard.d.ts +1 -1
  296. package/dist/types/plugins/code-block/actions.d.ts +0 -4
  297. package/dist/types/plugins/code-block/pm-plugins/main-state.d.ts +0 -3
  298. package/dist/types/plugins/collab-edit/provider/index.d.ts +1 -2
  299. package/dist/types/plugins/collab-edit/provider/types.d.ts +1 -36
  300. package/dist/types/plugins/context-panel/index.d.ts +2 -3
  301. package/dist/types/plugins/data-consumer/index.d.ts +0 -2
  302. package/dist/types/plugins/date/utils/internal.d.ts +0 -1
  303. package/dist/types/plugins/extension/commands.d.ts +0 -1
  304. package/dist/types/plugins/extension/nodeviews/extension.d.ts +0 -5
  305. package/dist/types/plugins/feedback-dialog/index.d.ts +0 -2
  306. package/dist/types/plugins/floating-toolbar/ui/Button.d.ts +3 -1
  307. package/dist/types/plugins/floating-toolbar/ui/Dropdown.d.ts +1 -0
  308. package/dist/types/plugins/floating-toolbar/utils.d.ts +0 -2
  309. package/dist/types/plugins/fragment/index.d.ts +0 -2
  310. package/dist/types/plugins/help-dialog/commands.d.ts +0 -1
  311. package/dist/types/plugins/history/actions.d.ts +1 -2
  312. package/dist/types/plugins/layout/styles.d.ts +2 -1
  313. package/dist/types/plugins/list/utils/find.d.ts +0 -1
  314. package/dist/types/plugins/list/utils/indentation.d.ts +0 -1
  315. package/dist/types/plugins/list/utils/node.d.ts +0 -2
  316. package/dist/types/plugins/list/utils/selection.d.ts +0 -3
  317. package/dist/types/plugins/media/utils/media-common.d.ts +0 -5
  318. package/dist/types/plugins/mentions/types.d.ts +1 -2
  319. package/dist/types/plugins/mentions/ui/InviteItem/index.d.ts +2 -3
  320. package/dist/types/plugins/mentions/ui/InviteItem/styles.d.ts +0 -6
  321. package/dist/types/plugins/mentions/ui/ToolbarMention/index.d.ts +1 -4
  322. package/dist/types/plugins/mobile-dimensions/index.d.ts +0 -1
  323. package/dist/types/plugins/paste/index.d.ts +0 -1
  324. package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +6 -3
  325. package/dist/types/plugins/paste/util/index.d.ts +0 -6
  326. package/dist/types/plugins/quick-insert/assets/index.d.ts +0 -2
  327. package/dist/types/plugins/status/utils.d.ts +0 -3
  328. package/dist/types/plugins/tasks-and-decisions/pm-plugins/main.d.ts +0 -6
  329. package/dist/types/plugins/text-color/pm-plugins/main.d.ts +2 -12
  330. package/dist/types/plugins/text-formatting/pm-plugins/clear-formatting.d.ts +0 -1
  331. package/dist/types/plugins/text-formatting/utils.d.ts +0 -4
  332. package/dist/types/plugins/type-ahead/constants.d.ts +0 -4
  333. package/dist/types/plugins/type-ahead/pm-plugins/decorations.d.ts +0 -10
  334. package/dist/types/plugins/type-ahead/utils.d.ts +1 -2
  335. package/dist/types/test-utils.d.ts +4 -5
  336. package/dist/types/types/editor-appearance-component.d.ts +2 -2
  337. package/dist/types/types/editor-props.d.ts +55 -42
  338. package/dist/types/ui/Appearance/Chromeless.d.ts +0 -5
  339. package/dist/types/ui/Appearance/Comment/Comment.d.ts +0 -7
  340. package/dist/types/ui/Appearance/Comment/Toolbar.d.ts +3 -2
  341. package/dist/types/ui/Appearance/FullPage/MainToolbar.d.ts +0 -4
  342. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +3 -3
  343. package/dist/types/ui/AppearanceComponents/Mobile.d.ts +2 -5
  344. package/dist/types/ui/ColorPalette/Palettes/index.d.ts +1 -1
  345. package/dist/types/ui/ColorPalette/Palettes/type.d.ts +1 -1
  346. package/dist/types/ui/ColorPalette/index.d.ts +2 -1
  347. package/dist/types/ui/ColorPickerButton/index.d.ts +4 -2
  348. package/dist/types/ui/ConfigPanel/types.d.ts +0 -3
  349. package/dist/types/ui/ConfigPanel/utils.d.ts +2 -3
  350. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  351. package/dist/types/ui/ElementBrowser/ModalElementBrowser.d.ts +0 -3
  352. package/dist/types/ui/ElementBrowser/constants.d.ts +0 -1
  353. package/dist/types/ui/ElementBrowser/types.d.ts +0 -5
  354. package/dist/types/ui/Resizer/utils.d.ts +0 -1
  355. package/dist/types/ui/styles.d.ts +0 -1
  356. package/dist/types/utils/index.d.ts +6 -65
  357. package/dist/types/utils/input-rules.d.ts +1 -2
  358. package/dist/types/utils/table.d.ts +0 -1
  359. package/package.json +23 -24
  360. package/report.api.md +155 -146
  361. package/dist/cjs/labs/next/presets/preset.js +0 -101
  362. package/dist/cjs/plugins/analytics/types/type-ahead.js +0 -5
  363. package/dist/cjs/plugins/collab-edit/provider/channel.js +0 -313
  364. package/dist/cjs/plugins/collab-edit/provider/logger.js +0 -17
  365. package/dist/cjs/plugins/collab-edit/provider/mock-users.js +0 -19
  366. package/dist/cjs/plugins/data-consumer/plugin-key.js +0 -9
  367. package/dist/cjs/plugins/media/toolbar/toolbar-messages.js +0 -15
  368. package/dist/cjs/profiler/render-count.js +0 -60
  369. package/dist/cjs/ui/ColorPalette/Color/index.js +0 -9
  370. package/dist/cjs/ui/ConfigPanel/FieldDescription.js +0 -19
  371. package/dist/cjs/ui/WithPluginState/types.js +0 -5
  372. package/dist/es2019/labs/next/presets/preset.js +0 -68
  373. package/dist/es2019/plugins/analytics/types/type-ahead.js +0 -1
  374. package/dist/es2019/plugins/collab-edit/provider/channel.js +0 -179
  375. package/dist/es2019/plugins/collab-edit/provider/logger.js +0 -8
  376. package/dist/es2019/plugins/collab-edit/provider/mock-users.js +0 -12
  377. package/dist/es2019/plugins/data-consumer/plugin-key.js +0 -2
  378. package/dist/es2019/plugins/media/toolbar/toolbar-messages.js +0 -8
  379. package/dist/es2019/profiler/render-count.js +0 -53
  380. package/dist/es2019/ui/ColorPalette/Color/index.js +0 -2
  381. package/dist/es2019/ui/ConfigPanel/FieldDescription.js +0 -12
  382. package/dist/es2019/ui/WithPluginState/types.js +0 -1
  383. package/dist/esm/labs/next/presets/preset.js +0 -93
  384. package/dist/esm/plugins/analytics/types/type-ahead.js +0 -1
  385. package/dist/esm/plugins/collab-edit/provider/channel.js +0 -305
  386. package/dist/esm/plugins/collab-edit/provider/logger.js +0 -10
  387. package/dist/esm/plugins/collab-edit/provider/mock-users.js +0 -12
  388. package/dist/esm/plugins/data-consumer/plugin-key.js +0 -2
  389. package/dist/esm/plugins/media/toolbar/toolbar-messages.js +0 -8
  390. package/dist/esm/profiler/render-count.js +0 -49
  391. package/dist/esm/ui/ColorPalette/Color/index.js +0 -2
  392. package/dist/esm/ui/ConfigPanel/FieldDescription.js +0 -11
  393. package/dist/esm/ui/WithPluginState/types.js +0 -1
  394. package/dist/types/labs/next/presets/preset.d.ts +0 -46
  395. package/dist/types/plugins/analytics/types/type-ahead.d.ts +0 -1
  396. package/dist/types/plugins/collab-edit/provider/channel.d.ts +0 -48
  397. package/dist/types/plugins/collab-edit/provider/logger.d.ts +0 -1
  398. package/dist/types/plugins/collab-edit/provider/mock-users.d.ts +0 -6
  399. package/dist/types/plugins/data-consumer/plugin-key.d.ts +0 -2
  400. package/dist/types/plugins/media/toolbar/toolbar-messages.d.ts +0 -7
  401. package/dist/types/profiler/render-count.d.ts +0 -14
  402. package/dist/types/ui/ColorPalette/Color/index.d.ts +0 -2
  403. package/dist/types/ui/ConfigPanel/FieldDescription.d.ts +0 -6
  404. package/dist/types/ui/WithPluginState/types.d.ts +0 -10
@@ -29,8 +29,7 @@ import { EVENT_NAME_DISPATCH_TRANSACTION, EVENT_NAME_STATE_APPLY, EVENT_NAME_UPD
29
29
  import { PROSEMIRROR_RENDERED_NORMAL_SEVERITY_THRESHOLD, PROSEMIRROR_RENDERED_DEGRADED_SEVERITY_THRESHOLD, DEFAULT_SAMPLING_RATE_VALID_TRANSACTIONS } from './consts';
30
30
  import { getContextIdentifier } from '../plugins/base/pm-plugins/context-identifier';
31
31
  import ReactEditorViewContext from './ReactEditorViewContext';
32
- import { createInsertNodeAPI } from '../insert-api/api';
33
- import { createEditorAnalyticsAPI } from '../analytics-api/api';
32
+ import { EditorPluginInjectionAPI } from '@atlaskit/editor-common/preset';
34
33
  function handleEditorFocus(view) {
35
34
  if (view.hasFocus()) {
36
35
  return;
@@ -39,18 +38,6 @@ function handleEditorFocus(view) {
39
38
  view.focus();
40
39
  }, 0);
41
40
  }
42
- const EMPTY = [];
43
- export function shouldReconfigureState(props, nextProps) {
44
- var _props$dangerouslyApp, _props$dangerouslyApp2, _nextProps$dangerousl, _nextProps$dangerousl2;
45
- const 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;
46
- const 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;
47
- if (nextPlugins.length !== prevPlugins.length || prevPlugins.some(p => nextPlugins.some(n => n.name === p.name && n !== p))) {
48
- return true;
49
- }
50
- const mobileProperties = props.appearance === 'mobile' ? ['featureFlags', 'quickInsert'] : [];
51
- const properties = ['appearance', 'persistScrollGutter', 'allowUndoRedoButtons', 'placeholder', 'sanitizePrivateContent', ...mobileProperties];
52
- return properties.reduce((acc, curr) => acc || props[curr] !== nextProps[curr], false);
53
- }
54
41
  export class ReactEditorView extends React.Component {
55
42
  // ProseMirror is instantiated prior to the initial React render cycle,
56
43
  // so we allow transactions by default, to avoid discarding the initial one.
@@ -67,8 +54,8 @@ export class ReactEditorView extends React.Component {
67
54
  countNodes() {
68
55
  return countNodes(this.editorState);
69
56
  }
70
- constructor(_props, context) {
71
- super(_props, context);
57
+ constructor(props, context) {
58
+ super(props, context);
72
59
  _defineProperty(this, "editorRef", /*#__PURE__*/React.createRef());
73
60
  _defineProperty(this, "canDispatchTransactions", true);
74
61
  _defineProperty(this, "onPluginObservation", (report, editorState) => {
@@ -82,6 +69,10 @@ export class ReactEditorView extends React.Component {
82
69
  }
83
70
  });
84
71
  });
72
+ _defineProperty(this, "getEditorState", () => {
73
+ var _this$view;
74
+ return (_this$view = this.view) === null || _this$view === void 0 ? void 0 : _this$view.state;
75
+ });
85
76
  _defineProperty(this, "formatFullWidthAppearance", appearance => {
86
77
  if (appearance === 'full-width') {
87
78
  return FULL_WIDTH_MODE.FULL_WIDTH;
@@ -130,45 +121,6 @@ export class ReactEditorView extends React.Component {
130
121
  sel.removeAllRanges();
131
122
  }
132
123
  });
133
- _defineProperty(this, "reconfigureState", props => {
134
- if (!this.view) {
135
- return;
136
- }
137
-
138
- // We cannot currently guarentee when all the portals will have re-rendered during a reconfigure
139
- // so we blur here to stop ProseMirror from trying to apply selection to detached nodes or
140
- // nodes that haven't been re-rendered to the document yet.
141
- this.blur();
142
- const editorPlugins = this.getPlugins(props.editorProps, this.props.editorProps, this.props.createAnalyticsEvent);
143
- this.config = processPluginsList(editorPlugins);
144
- const state = this.editorState;
145
- const plugins = createPMPlugins({
146
- schema: state.schema,
147
- dispatch: this.dispatch,
148
- errorReporter: this.errorReporter,
149
- editorConfig: this.config,
150
- eventDispatcher: this.eventDispatcher,
151
- providerFactory: props.providerFactory,
152
- portalProviderAPI: props.portalProviderAPI,
153
- reactContext: () => this.context,
154
- dispatchAnalyticsEvent: this.dispatchAnalyticsEvent,
155
- performanceTracking: props.editorProps.performanceTracking,
156
- transactionTracker: this.transactionTracker,
157
- featureFlags: createFeatureFlagsFromProps(props.editorProps),
158
- getIntl: () => this.props.intl
159
- });
160
- const newState = state.reconfigure({
161
- plugins: plugins
162
- });
163
-
164
- // need to update the state first so when the view builds the nodeviews it is
165
- // using the latest plugins
166
- this.view.updateState(newState);
167
- return this.view.update({
168
- ...this.view.props,
169
- state: newState
170
- });
171
- });
172
124
  _defineProperty(this, "handleAnalyticsEvent", payload => {
173
125
  if (!this.props.allowAnalyticsGASV3) {
174
126
  return;
@@ -199,7 +151,7 @@ export class ReactEditorView extends React.Component {
199
151
  return this.editorState;
200
152
  }
201
153
  } else {
202
- this.config = processPluginsList(this.getPlugins(options.props.editorProps, undefined, options.props.createAnalyticsEvent));
154
+ this.config = processPluginsList(this.getPlugins(options.props.preset));
203
155
  schema = createSchema(this.config);
204
156
  }
205
157
  const {
@@ -319,6 +271,10 @@ export class ReactEditorView extends React.Component {
319
271
  var _this$experienceStore3;
320
272
  (_this$experienceStore3 = this.experienceStore) === null || _this$experienceStore3 === void 0 ? void 0 : _this$experienceStore3.mark(EditorExperience.interaction, 'viewUpdateState', startTime + duration);
321
273
  });
274
+ this.pluginInjectionAPI.onEditorViewUpdated({
275
+ newEditorState: editorState,
276
+ oldEditorState
277
+ });
322
278
  startMeasure(EVENT_NAME_VIEW_STATE_UPDATED);
323
279
  this.onEditorViewStateUpdated({
324
280
  originalTransaction: transaction,
@@ -441,6 +397,10 @@ export class ReactEditorView extends React.Component {
441
397
  this.view = new EditorView({
442
398
  mount: node
443
399
  }, this.getDirectEditorProps());
400
+ this.pluginInjectionAPI.onEditorViewUpdated({
401
+ newEditorState: this.view.state,
402
+ oldEditorState: undefined
403
+ });
444
404
  });
445
405
  _defineProperty(this, "handleEditorViewRef", node => {
446
406
  if (!this.view && node) {
@@ -523,9 +483,12 @@ export class ReactEditorView extends React.Component {
523
483
  "aria-label": this.props.intl.formatMessage(editorMessages.editorAssistiveLabel),
524
484
  role: "textbox"
525
485
  }));
486
+ this.pluginInjectionAPI = new EditorPluginInjectionAPI({
487
+ getEditorState: this.getEditorState
488
+ });
526
489
  this.eventDispatcher = new EventDispatcher();
527
490
  this.dispatch = createDispatch(this.eventDispatcher);
528
- this.errorReporter = createErrorReporter(_props.editorProps.errorReporterHandler);
491
+ this.errorReporter = createErrorReporter(props.editorProps.errorReporterHandler);
529
492
  this.transactionTracker = new TransactionTracker();
530
493
  this.pluginPerformanceObserver = new PluginPerformanceObserver(report => this.onPluginObservation(report, this.editorState)).withPlugins(() => this.getPluginNames()).withNodeCounts(() => this.countNodes()).withOptions(() => this.transactionTracking).withTransactionTracker(() => this.transactionTracker);
531
494
  this.validTransactionCount = 0;
@@ -543,11 +506,11 @@ export class ReactEditorView extends React.Component {
543
506
  this.eventDispatcher.on(analyticsEventKey, this.handleAnalyticsEvent);
544
507
  this.eventDispatcher.on('resetEditorState', this.resetEditorState);
545
508
  this.editorState = this.createEditorState({
546
- props: _props,
509
+ props,
547
510
  context,
548
- doc: _props.editorProps.defaultValue,
511
+ doc: props.editorProps.defaultValue,
549
512
  // ED-4759: Don't set selection at end for full-page editor - should be at start.
550
- selectionAtStart: isFullPage(_props.editorProps.appearance)
513
+ selectionAtStart: isFullPage(props.editorProps.appearance)
551
514
  });
552
515
  this.dispatchAnalyticsEvent({
553
516
  action: ACTION.STARTED,
@@ -582,7 +545,7 @@ export class ReactEditorView extends React.Component {
582
545
  const {
583
546
  appearance: nextAppearance
584
547
  } = nextProps.editorProps;
585
- if (shouldReconfigureState(this.props.editorProps, nextProps.editorProps)) {
548
+ if (this.props.preset !== nextProps.preset) {
586
549
  this.reconfigureState(nextProps);
587
550
  }
588
551
  if (nextAppearance !== appearance) {
@@ -602,6 +565,45 @@ export class ReactEditorView extends React.Component {
602
565
  this.pluginPerformanceObserver.disconnect();
603
566
  }
604
567
  }
568
+ reconfigureState(props) {
569
+ if (!this.view) {
570
+ return;
571
+ }
572
+
573
+ // We cannot currently guarentee when all the portals will have re-rendered during a reconfigure
574
+ // so we blur here to stop ProseMirror from trying to apply selection to detached nodes or
575
+ // nodes that haven't been re-rendered to the document yet.
576
+ this.blur();
577
+ const editorPlugins = this.getPlugins(props.preset);
578
+ this.config = processPluginsList(editorPlugins);
579
+ const state = this.editorState;
580
+ const plugins = createPMPlugins({
581
+ schema: state.schema,
582
+ dispatch: this.dispatch,
583
+ errorReporter: this.errorReporter,
584
+ editorConfig: this.config,
585
+ eventDispatcher: this.eventDispatcher,
586
+ providerFactory: props.providerFactory,
587
+ portalProviderAPI: props.portalProviderAPI,
588
+ reactContext: () => this.context,
589
+ dispatchAnalyticsEvent: this.dispatchAnalyticsEvent,
590
+ performanceTracking: props.editorProps.performanceTracking,
591
+ transactionTracker: this.transactionTracker,
592
+ featureFlags: createFeatureFlagsFromProps(props.editorProps),
593
+ getIntl: () => this.props.intl
594
+ });
595
+ const newState = state.reconfigure({
596
+ plugins: plugins
597
+ });
598
+
599
+ // need to update the state first so when the view builds the nodeviews it is
600
+ // using the latest plugins
601
+ this.view.updateState(newState);
602
+ return this.view.update({
603
+ ...this.view.props,
604
+ state: newState
605
+ });
606
+ }
605
607
  componentDidMount() {
606
608
  // Transaction dispatching is already enabled by default prior to
607
609
  // mounting, but we reset it here, just in case the editor view
@@ -644,28 +646,11 @@ export class ReactEditorView extends React.Component {
644
646
  }
645
647
 
646
648
  // Helper to allow tests to inject plugins directly
647
- getPlugins(editorProps, prevEditorProps, createAnalyticsEvent) {
648
- var _this$props$getEditor, _this$props$getEditor2, _this$props;
649
- const insertNodeAPI = createInsertNodeAPI({
650
- getEditorView: () => this.view,
651
- getEditorPlugins: () => this.editorPlugins
652
- });
653
- const editorAnalyticsAPI = createEditorAnalyticsAPI({
654
- getEditorView: () => this.view,
655
- getCreateUIAnalyticsEvent: () => createAnalyticsEvent
649
+ getPlugins(preset) {
650
+ const plugins = preset.build({
651
+ pluginInjectionAPI: this.pluginInjectionAPI
656
652
  });
657
- const getPluginsProps = {
658
- props: editorProps,
659
- prevAppearance: prevEditorProps === null || prevEditorProps === void 0 ? void 0 : prevEditorProps.appearance,
660
- createAnalyticsEvent,
661
- insertNodeAPI,
662
- editorAnalyticsAPI
663
- };
664
- if (this.props.getEditorPlugins === undefined) {
665
- // eslint-disable-next-line no-console
666
- console.error('getEditorPlugins is undefined in ReactEditorViewInternal - no editor plugins will be added.');
667
- }
668
- 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 : [];
653
+ this.editorPlugins = plugins;
669
654
  return this.editorPlugins;
670
655
  }
671
656
  render() {
@@ -100,13 +100,35 @@ export function getDefaultPresetOptionsFromEditorProps(props, createAnalyticsEve
100
100
  * Note: The order that presets are added determines
101
101
  * their placement in the editor toolbar
102
102
  */
103
- export default function createPluginsList(props, prevProps, createAnalyticsEvent, insertNodeAPI, editorAnalyticsAPI, editorSelectionAPI, getEditorContainerWidth) {
104
- const preset = createUniversalPreset(props.appearance, getDefaultPresetOptionsFromEditorProps(props, createAnalyticsEvent), createFeatureFlagsFromProps(props), prevProps === null || prevProps === void 0 ? void 0 : prevProps.appearance, createAnalyticsEvent, insertNodeAPI, editorAnalyticsAPI, editorSelectionAPI, getEditorContainerWidth);
103
+ export default function createPluginsList(props, prevProps, createAnalyticsEvent) {
104
+ const preset = createUniversalPreset(props.appearance, getDefaultPresetOptionsFromEditorProps(props, createAnalyticsEvent), createFeatureFlagsFromProps(props), prevProps === null || prevProps === void 0 ? void 0 : prevProps.appearance, createAnalyticsEvent);
105
105
  const excludes = new Set();
106
106
  if (!isCodeBlockAllowed({
107
107
  allowBlockType: props.allowBlockType
108
108
  })) {
109
109
  excludes.add('codeBlock');
110
110
  }
111
- return preset.getEditorPlugins(excludes);
111
+ return preset.build({
112
+ excludePlugins: excludes
113
+ });
114
+ }
115
+ function withDangerouslyAppendPlugins(preset) {
116
+ function createEditorNextPluginsFromDangerouslyAppended(plugins) {
117
+ return plugins ? plugins.map(plugin => () => plugin) : [];
118
+ }
119
+ return editorPluginsToAppend => {
120
+ if (!editorPluginsToAppend || editorPluginsToAppend.length === 0) {
121
+ return preset;
122
+ }
123
+ const nextEditorPluginsToAppend = createEditorNextPluginsFromDangerouslyAppended(editorPluginsToAppend);
124
+ const presetWithAppendedPlugins = nextEditorPluginsToAppend.reduce((acc, plugin) => {
125
+ return acc.add(plugin);
126
+ }, preset);
127
+ return presetWithAppendedPlugins;
128
+ };
129
+ }
130
+ export function createPreset(props, prevProps, createAnalyticsEvent) {
131
+ var _props$dangerouslyApp;
132
+ const preset = createUniversalPreset(props.appearance, getDefaultPresetOptionsFromEditorProps(props, createAnalyticsEvent), createFeatureFlagsFromProps(props), prevProps === null || prevProps === void 0 ? void 0 : prevProps.appearance, createAnalyticsEvent);
133
+ return withDangerouslyAppendPlugins(preset)((_props$dangerouslyApp = props.dangerouslyAppendPlugins) === null || _props$dangerouslyApp === void 0 ? void 0 : _props$dangerouslyApp.__plugins);
112
134
  }
@@ -0,0 +1,15 @@
1
+ const EMPTY = [];
2
+ export function shouldRecreatePreset(props, nextProps) {
3
+ var _props$dangerouslyApp, _props$dangerouslyApp2, _nextProps$dangerousl, _nextProps$dangerousl2;
4
+ const 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;
5
+ const 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;
6
+ if (nextPlugins.length !== prevPlugins.length || prevPlugins.some(p => nextPlugins.some(n => n.name === p.name && n !== p))) {
7
+ return true;
8
+ }
9
+ return shouldReconfigureState(props, nextProps);
10
+ }
11
+ function shouldReconfigureState(props, nextProps) {
12
+ const mobileProperties = props.appearance === 'mobile' ? ['quickInsert', 'featureFlags'] : [];
13
+ const properties = ['appearance', 'persistScrollGutter', 'allowUndoRedoButtons', 'placeholder', 'sanitizePrivateContent', ...mobileProperties];
14
+ return properties.reduce((acc, curr) => acc || props[curr] !== nextProps[curr], false);
15
+ }
@@ -48,7 +48,7 @@ export function EditorInternalWithoutHooks({
48
48
  providerFactory,
49
49
  onEditorCreated,
50
50
  onEditorDestroyed,
51
- getEditorPlugins
51
+ preset
52
52
  }) {
53
53
  var _props$performanceTra, _props$performanceTra2;
54
54
  const Component = getUiComponent(props.appearance);
@@ -90,7 +90,7 @@ export function EditorInternalWithoutHooks({
90
90
  onEditorDestroyed: onEditorDestroyed,
91
91
  allowAnalyticsGASV3: props.allowAnalyticsGASV3,
92
92
  disabled: props.disabled,
93
- getEditorPlugins: getEditorPlugins,
93
+ preset: preset,
94
94
  render: ({
95
95
  editor,
96
96
  view,
@@ -1,10 +1,27 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import React from 'react';
3
+ import { createFeatureFlagsFromProps } from '../create-editor/feature-flags-from-props';
2
4
  import Editor from '../editor';
3
5
  import EditorNext from './index';
4
- import { createFeatureFlagsFromProps } from '../create-editor/feature-flags-from-props';
6
+ import useUniversalPreset from '../labs/next/presets/useUniversalPreset';
7
+ const EditorNextWrapper = ({
8
+ props
9
+ }) => {
10
+ const preset = useUniversalPreset({
11
+ props
12
+ });
13
+ return /*#__PURE__*/React.createElement(EditorNext, _extends({
14
+ preset: preset
15
+ }, props));
16
+ };
5
17
  export default class EditorMigrationComponent extends React.Component {
6
18
  render() {
7
19
  const featureFlags = createFeatureFlagsFromProps(this.props);
8
- return featureFlags.useEditorNext ? /*#__PURE__*/React.createElement(EditorNext, this.props) : /*#__PURE__*/React.createElement(Editor, this.props);
20
+ if (!featureFlags.useEditorNext) {
21
+ return /*#__PURE__*/React.createElement(Editor, this.props);
22
+ }
23
+ return /*#__PURE__*/React.createElement(EditorNextWrapper, {
24
+ props: this.props
25
+ });
9
26
  }
10
27
  }
@@ -4,6 +4,7 @@ import { usePreviousState } from '@atlaskit/editor-common/hooks';
4
4
  import prepareQuickInsertProvider from '../../utils/prepare-quick-insert-provider';
5
5
  import prepareExtensionProvider from '../../utils/prepare-extension-provider';
6
6
  import handleProviders from '../utils/handleProviders';
7
+ import getProvidersFromEditorProps from '../utils/getProvidersFromEditorProps';
7
8
  function createNewState(editorActions, quickInsert, extensionProviders, createAnalyticsEvent) {
8
9
  const extensionProvider = prepareExtensionProvider(() => editorActions)(extensionProviders);
9
10
  const quickInsertProvider = prepareQuickInsertProvider(editorActions, extensionProvider, quickInsert, createAnalyticsEvent);
@@ -42,11 +43,11 @@ export default function useProviderFactory(props, editorActions, createAnalytics
42
43
  quickInsert && quickInsert !== (prevProps === null || prevProps === void 0 ? void 0 : prevProps.quickInsert)) {
43
44
  const newState = createNewState(editorActions, quickInsert, extensionProviders, createAnalyticsEvent);
44
45
  setProviderState(newState);
45
- handleProviders(providerFactory.current, props, newState.extensionProvider, newState.quickInsertProvider);
46
+ handleProviders(providerFactory.current, getProvidersFromEditorProps(props), newState.extensionProvider, newState.quickInsertProvider);
46
47
  return;
47
48
  }
48
- handleProviders(providerFactory.current, props, providerState.extensionProvider, providerState.quickInsertProvider);
49
- }, [props, prevProps, createAnalyticsEvent, editorActions, providerState.extensionProvider, providerState.quickInsertProvider, extensionProviders, quickInsert]);
49
+ handleProviders(providerFactory.current, getProvidersFromEditorProps(props), providerState.extensionProvider, providerState.quickInsertProvider);
50
+ }, [props, prevProps === null || prevProps === void 0 ? void 0 : prevProps.quickInsert, prevProps === null || prevProps === void 0 ? void 0 : prevProps.extensionProviders, createAnalyticsEvent, editorActions, providerState.extensionProvider, providerState.quickInsertProvider, extensionProviders, quickInsert]);
50
51
 
51
52
  // componentWillUnmount equivalent
52
53
  useEffect(() => {
@@ -16,7 +16,7 @@ import { defaultProps, propTypes } from './utils/editorPropTypes';
16
16
  import trackEditorActions from './utils/trackEditorActions';
17
17
  import onEditorCreated from './utils/onEditorCreated';
18
18
  import deprecationWarnings from './utils/deprecationWarnings';
19
- import getEditorPlugins from '../utils/get-editor-plugins';
19
+ import { basePlugin } from '../plugins';
20
20
  export default class EditorNext extends React.Component {
21
21
  /**
22
22
  * WARNING: Code should be shared between Editor + EditorNext
@@ -39,7 +39,6 @@ export default class EditorNext extends React.Component {
39
39
  this.onEditorCreated = this.onEditorCreated.bind(this);
40
40
  this.onEditorDestroyed = this.onEditorDestroyed.bind(this);
41
41
  this.getExperienceStore = this.getExperienceStore.bind(this);
42
- this.getEditorPlugins = this.getEditorPlugins.bind(this);
43
42
  trackEditorActions(this.editorActions, props.performanceTracking, value => this.handleAnalyticsEvent(value));
44
43
  }
45
44
  onEditorCreated(instance) {
@@ -70,7 +69,7 @@ export default class EditorNext extends React.Component {
70
69
  props: this.props,
71
70
  handleAnalyticsEvent: this.handleAnalyticsEvent,
72
71
  createAnalyticsEvent: this.createAnalyticsEvent,
73
- getEditorPlugins: this.getEditorPlugins,
72
+ preset: this.props.preset,
74
73
  handleSave: this.handleSave,
75
74
  editorActions: this.editorActions,
76
75
  getExperienceStore: this.getExperienceStore,
@@ -79,12 +78,19 @@ export default class EditorNext extends React.Component {
79
78
  })
80
79
  }));
81
80
  }
82
- getEditorPlugins(props) {
83
- return getEditorPlugins(props);
84
- }
85
81
  }
86
82
  _defineProperty(EditorNext, "defaultProps", defaultProps);
87
83
  _defineProperty(EditorNext, "contextTypes", {
88
84
  editorActions: PropTypes.object
89
85
  });
90
- _defineProperty(EditorNext, "propTypes", propTypes('minHeight only supports editor appearance chromeless and comment for EditorNext'));
86
+ _defineProperty(EditorNext, "propTypes", {
87
+ ...propTypes('minHeight only supports editor appearance chromeless and comment for EditorNext'),
88
+ preset: ({
89
+ preset
90
+ }) => {
91
+ if (!preset.has(basePlugin)) {
92
+ return new Error('Presets must contain the base plugin');
93
+ }
94
+ return null;
95
+ }
96
+ });
@@ -0,0 +1,36 @@
1
+ export default function getProvidersFromEditorProps({
2
+ linking,
3
+ smartLinks,
4
+ UNSAFE_cards,
5
+ autoformattingProvider,
6
+ media,
7
+ emojiProvider,
8
+ mentionProvider,
9
+ legacyImageUploadProvider,
10
+ taskDecisionProvider,
11
+ contextIdentifierProvider,
12
+ searchProvider,
13
+ macroProvider,
14
+ activityProvider,
15
+ collabEdit,
16
+ collabEditProvider,
17
+ presenceProvider
18
+ }) {
19
+ var _linking$smartLinks;
20
+ const cardProvider = (linking === null || linking === void 0 ? void 0 : (_linking$smartLinks = linking.smartLinks) === null || _linking$smartLinks === void 0 ? void 0 : _linking$smartLinks.provider) || smartLinks && smartLinks.provider || UNSAFE_cards && UNSAFE_cards.provider;
21
+ return {
22
+ mediaProvider: media === null || media === void 0 ? void 0 : media.provider,
23
+ emojiProvider: emojiProvider,
24
+ mentionProvider: mentionProvider,
25
+ autoformattingProvider: autoformattingProvider,
26
+ cardProvider: cardProvider,
27
+ activityProvider: activityProvider,
28
+ imageUploadProvider: legacyImageUploadProvider,
29
+ taskDecisionProvider: taskDecisionProvider,
30
+ contextIdentifierProvider: contextIdentifierProvider,
31
+ searchProvider: searchProvider,
32
+ presenceProvider: presenceProvider,
33
+ macroProvider: macroProvider,
34
+ collabEditProvider: collabEdit && collabEdit.provider ? collabEdit.provider : collabEditProvider
35
+ };
36
+ }
@@ -7,38 +7,32 @@
7
7
  * @param extensionProvider
8
8
  * @param quickInsertProvider
9
9
  */
10
- export default function handleProviders(providerFactory, props, extensionProvider, quickInsertProvider) {
11
- var _linking$smartLinks;
12
- const {
13
- emojiProvider,
14
- mentionProvider,
15
- taskDecisionProvider,
16
- contextIdentifierProvider,
17
- collabEditProvider,
18
- activityProvider,
19
- presenceProvider,
20
- macroProvider,
21
- legacyImageUploadProvider,
22
- media,
23
- collabEdit,
24
- autoformattingProvider,
25
- searchProvider,
26
- UNSAFE_cards,
27
- smartLinks,
28
- linking
29
- } = props;
10
+ export default function handleProviders(providerFactory, {
11
+ emojiProvider,
12
+ mentionProvider,
13
+ taskDecisionProvider,
14
+ contextIdentifierProvider,
15
+ collabEditProvider,
16
+ activityProvider,
17
+ presenceProvider,
18
+ macroProvider,
19
+ imageUploadProvider,
20
+ mediaProvider,
21
+ autoformattingProvider,
22
+ searchProvider,
23
+ cardProvider
24
+ }, extensionProvider, quickInsertProvider) {
30
25
  providerFactory.setProvider('emojiProvider', emojiProvider);
31
26
  providerFactory.setProvider('mentionProvider', mentionProvider);
32
27
  providerFactory.setProvider('taskDecisionProvider', taskDecisionProvider);
33
28
  providerFactory.setProvider('contextIdentifierProvider', contextIdentifierProvider);
34
- providerFactory.setProvider('mediaProvider', media && media.provider);
35
- providerFactory.setProvider('imageUploadProvider', legacyImageUploadProvider);
36
- providerFactory.setProvider('collabEditProvider', collabEdit && collabEdit.provider ? collabEdit.provider : collabEditProvider);
29
+ providerFactory.setProvider('mediaProvider', mediaProvider);
30
+ providerFactory.setProvider('imageUploadProvider', imageUploadProvider);
31
+ providerFactory.setProvider('collabEditProvider', collabEditProvider);
37
32
  providerFactory.setProvider('activityProvider', activityProvider);
38
33
  providerFactory.setProvider('searchProvider', searchProvider);
39
34
  providerFactory.setProvider('presenceProvider', presenceProvider);
40
35
  providerFactory.setProvider('macroProvider', macroProvider);
41
- const cardProvider = (linking === null || linking === void 0 ? void 0 : (_linking$smartLinks = linking.smartLinks) === null || _linking$smartLinks === void 0 ? void 0 : _linking$smartLinks.provider) || smartLinks && smartLinks.provider || UNSAFE_cards && UNSAFE_cards.provider;
42
36
  if (cardProvider) {
43
37
  providerFactory.setProvider('cardProvider', cardProvider);
44
38
  }
@@ -19,12 +19,14 @@ import { fireAnalyticsEvent } from '@atlaskit/editor-common/analytics';
19
19
  import prepareQuickInsertProvider from './utils/prepare-quick-insert-provider';
20
20
  import prepareExtensionProvider from './utils/prepare-extension-provider';
21
21
  import handleProviders from './editor-next/utils/handleProviders';
22
+ import getProvidersFromEditorProps from './editor-next/utils/getProvidersFromEditorProps';
22
23
  import { startMeasure, clearMeasure, stopMeasure, measureTTI } from '@atlaskit/editor-common/utils';
23
24
  import measurements from './utils/performance/measure-enum';
24
25
  import editorMeasureTTICallback from './editor-next/utils/editorMeasureTTICallback';
25
26
  import { ACTION } from '@atlaskit/editor-common/analytics';
26
27
  import sendDurationAnalytics from './editor-next/utils/sendDurationAnalytics';
27
- import getEditorPlugins from './utils/get-editor-plugins';
28
+ import { createPreset } from './create-editor/create-plugins-list';
29
+ import { shouldRecreatePreset } from './create-editor/preset-utils';
28
30
  export default class Editor extends React.Component {
29
31
  /**
30
32
  * WARNING: Code should be shared between Editor + EditorNext
@@ -52,7 +54,6 @@ export default class Editor extends React.Component {
52
54
  this.startTime = performance.now();
53
55
  this.onEditorCreated = this.onEditorCreated.bind(this);
54
56
  this.onEditorDestroyed = this.onEditorDestroyed.bind(this);
55
- this.getEditorPlugins = this.getEditorPlugins.bind(this);
56
57
  this.getExperienceStore = this.getExperienceStore.bind(this);
57
58
  this.trackEditorActions(this.editorActions, props);
58
59
 
@@ -74,9 +75,11 @@ export default class Editor extends React.Component {
74
75
  */
75
76
  const _extensionProvider = this.prepareExtensionProvider(props.extensionProviders);
76
77
  const quickInsertProvider = this.prepareQuickInsertProvider(_extensionProvider, props.quickInsert);
78
+ const preset = createPreset(props, undefined, this.createAnalyticsEvent);
77
79
  this.state = {
78
80
  extensionProvider: _extensionProvider,
79
- quickInsertProvider
81
+ quickInsertProvider,
82
+ preset
80
83
  };
81
84
  }
82
85
 
@@ -87,7 +90,7 @@ export default class Editor extends React.Component {
87
90
  */
88
91
  componentDidMount() {
89
92
  stopMeasure(measurements.EDITOR_MOUNTED, sendDurationAnalytics(ACTION.EDITOR_MOUNTED, this.props, this.getExperienceStore, this.createAnalyticsEvent));
90
- handleProviders(this.providerFactory, this.props, this.state.extensionProvider, this.state.quickInsertProvider);
93
+ handleProviders(this.providerFactory, getProvidersFromEditorProps(this.props), this.state.extensionProvider, this.state.quickInsertProvider);
91
94
  }
92
95
 
93
96
  /**
@@ -95,6 +98,8 @@ export default class Editor extends React.Component {
95
98
  * `useProviderFactory` (editor-next/hooks/useProviderFactory.ts)
96
99
  */
97
100
  componentDidUpdate(prevProps) {
101
+ const needsANewPreset = shouldRecreatePreset(prevProps, this.props);
102
+ const preset = needsANewPreset ? createPreset(this.props, prevProps, this.createAnalyticsEvent) : this.state.preset;
98
103
  const {
99
104
  extensionProviders,
100
105
  quickInsert
@@ -108,11 +113,18 @@ export default class Editor extends React.Component {
108
113
  const quickInsertProvider = this.prepareQuickInsertProvider(extensionProvider, quickInsert);
109
114
  this.setState({
110
115
  extensionProvider,
111
- quickInsertProvider
112
- }, () => handleProviders(this.providerFactory, this.props, this.state.extensionProvider, this.state.quickInsertProvider));
116
+ quickInsertProvider,
117
+ preset
118
+ }, () => handleProviders(this.providerFactory, getProvidersFromEditorProps(this.props), this.state.extensionProvider, this.state.quickInsertProvider));
113
119
  return;
114
120
  }
115
- handleProviders(this.providerFactory, this.props, this.state.extensionProvider, this.state.quickInsertProvider);
121
+ if (needsANewPreset) {
122
+ this.setState({
123
+ preset
124
+ });
125
+ return;
126
+ }
127
+ handleProviders(this.providerFactory, getProvidersFromEditorProps(this.props), this.state.extensionProvider, this.state.quickInsertProvider);
116
128
  }
117
129
 
118
130
  /**
@@ -213,7 +225,7 @@ export default class Editor extends React.Component {
213
225
  props: this.props,
214
226
  handleAnalyticsEvent: this.handleAnalyticsEvent,
215
227
  createAnalyticsEvent: this.createAnalyticsEvent,
216
- getEditorPlugins: this.getEditorPlugins,
228
+ preset: this.state.preset,
217
229
  handleSave: this.handleSave,
218
230
  editorActions: this.editorActions,
219
231
  providerFactory: this.providerFactory,
@@ -222,9 +234,6 @@ export default class Editor extends React.Component {
222
234
  })
223
235
  }));
224
236
  }
225
- getEditorPlugins(props) {
226
- return getEditorPlugins(props);
227
- }
228
237
  }
229
238
  _defineProperty(Editor, "defaultProps", defaultProps);
230
239
  _defineProperty(Editor, "contextTypes", {
@@ -1,12 +1,8 @@
1
- export const LEFT = 37;
2
- export const RIGHT = 39;
3
- export const UP = 38;
4
- export const DOWN = 40;
5
- export const KEY_0 = 48;
6
- export const KEY_1 = 49;
7
- export const KEY_2 = 50;
8
- export const KEY_3 = 51;
9
- export const KEY_4 = 52;
10
- export const KEY_5 = 53;
11
- export const KEY_6 = 54;
1
+ const KEY_0 = 48;
2
+ const KEY_1 = 49;
3
+ const KEY_2 = 50;
4
+ const KEY_3 = 51;
5
+ const KEY_4 = 52;
6
+ const KEY_5 = 53;
7
+ const KEY_6 = 54;
12
8
  export const HEADING_KEYS = [KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6];