@atlaskit/editor-core 179.1.2 → 180.1.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 (457) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/codemods/180.1.0-update-to-editor-migration-component.ts +8 -0
  3. package/codemods/__tests__/rename-editor-to-editor-migration-component.ts +156 -0
  4. package/codemods/migrates/rename-editor-to-editor-migration-component.ts +34 -0
  5. package/dist/cjs/actions/index.js +1 -1
  6. package/dist/cjs/create-editor/ReactEditorView.js +12 -762
  7. package/dist/cjs/create-editor/ReactEditorViewInternal.js +783 -0
  8. package/dist/cjs/create-editor/ReactEditorViewNext.js +16 -0
  9. package/dist/cjs/create-editor/create-plugins-list.js +1 -0
  10. package/dist/cjs/create-editor/feature-flags-from-props.js +3 -2
  11. package/dist/cjs/editor-next/editor-internal.js +147 -0
  12. package/dist/cjs/editor-next/editor-migration-component.js +35 -0
  13. package/dist/cjs/editor-next/hooks/useEditorMeasuresConstructor.js +36 -0
  14. package/dist/cjs/editor-next/hooks/useMeasureEditorMountTime.js +42 -0
  15. package/dist/cjs/editor-next/hooks/useProviderFactory.js +72 -0
  16. package/dist/cjs/editor-next/index.js +139 -0
  17. package/dist/cjs/editor-next/utils/deprecationWarnings.js +45 -0
  18. package/dist/cjs/editor-next/utils/editorMeasureTTICallback.js +44 -0
  19. package/dist/cjs/editor-next/utils/editorPropTypes.js +36 -0
  20. package/dist/cjs/editor-next/utils/getBaseFontSize.js +17 -0
  21. package/dist/cjs/editor-next/utils/handleProviders.js +56 -0
  22. package/dist/cjs/editor-next/utils/onEditorCreated.js +28 -0
  23. package/dist/cjs/editor-next/utils/sendDurationAnalytics.js +68 -0
  24. package/dist/cjs/editor-next/utils/trackEditorActions.js +101 -0
  25. package/dist/cjs/editor.js +130 -443
  26. package/dist/cjs/index.js +7 -0
  27. package/dist/cjs/labs/next/internal/hooks/use-analytics/index.js +4 -4
  28. package/dist/cjs/labs/next/internal/hooks/use-editor/create-dispatch-transaction.js +6 -6
  29. package/dist/cjs/labs/next/presets/create-stub-internal-apis.js +117 -0
  30. package/dist/cjs/labs/next/presets/preset.js +0 -5
  31. package/dist/cjs/labs/next/presets/universal.js +11 -2
  32. package/dist/cjs/plugins/alignment/ui/ToolbarAlignment/index.js +48 -13
  33. package/dist/cjs/plugins/analytics/index.js +2 -3
  34. package/dist/cjs/plugins/analytics/plugin.js +5 -6
  35. package/dist/cjs/plugins/analytics/utils.js +0 -11
  36. package/dist/cjs/plugins/base/pm-plugins/filter-steps.js +1 -1
  37. package/dist/cjs/plugins/base/pm-plugins/frozen-editor.js +98 -56
  38. package/dist/cjs/plugins/base/utils/input-latency-tracking.js +24 -25
  39. package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +1 -0
  40. package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/index.js +36 -9
  41. package/dist/cjs/plugins/card/nodeviews/blockCard.js +2 -1
  42. package/dist/cjs/plugins/card/nodeviews/genericCard.js +16 -2
  43. package/dist/cjs/plugins/card/pm-plugins/main.js +4 -2
  44. package/dist/cjs/plugins/clipboard/pm-plugins/main.js +4 -1
  45. package/dist/cjs/plugins/collab-edit/plugin.js +2 -3
  46. package/dist/cjs/plugins/extension/toolbar.js +7 -1
  47. package/dist/cjs/plugins/find-replace/ui/FindReplaceToolbarButton.js +5 -1
  48. package/dist/cjs/plugins/floating-toolbar/ui/Button.js +2 -0
  49. package/dist/cjs/plugins/floating-toolbar/ui/CheckboxModal.js +5 -3
  50. package/dist/cjs/plugins/floating-toolbar/ui/Dropdown.js +38 -9
  51. package/dist/cjs/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +23 -21
  52. package/dist/cjs/plugins/floating-toolbar/ui/ScrollButtons.js +12 -7
  53. package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +11 -0
  54. package/dist/cjs/plugins/fragment/pm-plugins/fragment-consistency.js +1 -0
  55. package/dist/cjs/plugins/hyperlink/analytics.js +5 -5
  56. package/dist/cjs/plugins/hyperlink/index.js +1 -1
  57. package/dist/cjs/plugins/hyperlink/pm-plugins/main.js +9 -5
  58. package/dist/cjs/plugins/hyperlink/ui/EditorLinkPicker/index.js +10 -4
  59. package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +1 -1
  60. package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +4 -3
  61. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +1 -0
  62. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.js +1 -0
  63. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.js +3 -0
  64. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.js +1 -0
  65. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +22 -0
  66. package/dist/cjs/plugins/media/commands/helpers.js +12 -40
  67. package/dist/cjs/plugins/media/commands/index.js +4 -4
  68. package/dist/cjs/plugins/media/nodeviews/mediaGroup.js +14 -12
  69. package/dist/cjs/plugins/media/nodeviews/mediaInline.js +1 -1
  70. package/dist/cjs/plugins/media/nodeviews/mediaNodeUpdater.js +310 -205
  71. package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +1 -1
  72. package/dist/cjs/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +1 -1
  73. package/dist/cjs/plugins/media/pm-plugins/main.js +2 -27
  74. package/dist/cjs/plugins/media/toolbar/filePreviewItem.js +1 -4
  75. package/dist/cjs/plugins/panel/utils.js +4 -1
  76. package/dist/cjs/plugins/paste/handlers.js +128 -13
  77. package/dist/cjs/plugins/paste/pm-plugins/analytics.js +15 -6
  78. package/dist/cjs/plugins/paste/pm-plugins/main.js +12 -3
  79. package/dist/cjs/plugins/placeholder-text/index.js +2 -2
  80. package/dist/cjs/plugins/status/index.js +9 -3
  81. package/dist/cjs/plugins/status/ui/statusPicker.js +8 -2
  82. package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/index.js +42 -8
  83. package/dist/cjs/plugins/text-formatting/ui/Toolbar/dropdown-menu.js +22 -2
  84. package/dist/cjs/plugins/text-formatting/ui/Toolbar/index.js +3 -1
  85. package/dist/cjs/plugins/text-formatting/ui/Toolbar/more-button.js +3 -1
  86. package/dist/cjs/plugins/text-formatting/utils.js +1 -10
  87. package/dist/cjs/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +19 -1
  88. package/dist/cjs/plugins/type-ahead/index.js +1 -1
  89. package/dist/cjs/plugins/type-ahead/ui/InputQuery.js +79 -106
  90. package/dist/cjs/types/get-editor-props.js +5 -0
  91. package/dist/cjs/ui/ChromeCollapsed/index.js +1 -0
  92. package/dist/cjs/ui/CollapsedEditor/index.js +7 -13
  93. package/dist/cjs/ui/ColorPickerButton/index.js +68 -6
  94. package/dist/cjs/ui/ConfigPanel/ConfigPanel.js +1 -1
  95. package/dist/cjs/ui/ContextPanel/context.js +13 -12
  96. package/dist/cjs/ui/Dropdown/index.js +7 -2
  97. package/dist/cjs/ui/DropdownMenu/index.js +7 -2
  98. package/dist/cjs/ui/ElementBrowser/components/CategoryList.js +1 -1
  99. package/dist/cjs/ui/ElementBrowser/components/ElementList/ElementList.js +1 -1
  100. package/dist/cjs/ui/ElementBrowser/components/StatelessElementBrowser.js +1 -1
  101. package/dist/cjs/ui/PanelTextInput/index.js +4 -4
  102. package/dist/cjs/ui/PortalProvider/index.js +5 -5
  103. package/dist/cjs/ui/WidthEmitter/index.js +29 -35
  104. package/dist/cjs/utils/document.js +15 -0
  105. package/dist/cjs/utils/extensions.js +6 -7
  106. package/dist/cjs/utils/get-editor-plugins.js +32 -0
  107. package/dist/cjs/utils/linking-utils.js +1 -1
  108. package/dist/cjs/utils/performance/components/RenderTracking.js +1 -1
  109. package/dist/cjs/utils/performance/safer-transactions.js +1 -1
  110. package/dist/cjs/utils/prepare-extension-provider.js +25 -0
  111. package/dist/cjs/version-wrapper.js +1 -1
  112. package/dist/cjs/version.json +1 -1
  113. package/dist/es2019/actions/index.js +2 -2
  114. package/dist/es2019/create-editor/ReactEditorView.js +6 -708
  115. package/dist/es2019/create-editor/ReactEditorViewInternal.js +712 -0
  116. package/dist/es2019/create-editor/ReactEditorViewNext.js +7 -0
  117. package/dist/es2019/create-editor/create-plugins-list.js +1 -0
  118. package/dist/es2019/create-editor/feature-flags-from-props.js +3 -2
  119. package/dist/es2019/editor-next/editor-internal.js +142 -0
  120. package/dist/es2019/editor-next/editor-migration-component.js +10 -0
  121. package/dist/es2019/editor-next/hooks/useEditorMeasuresConstructor.js +30 -0
  122. package/dist/es2019/editor-next/hooks/useMeasureEditorMountTime.js +35 -0
  123. package/dist/es2019/editor-next/hooks/useProviderFactory.js +61 -0
  124. package/dist/es2019/editor-next/index.js +90 -0
  125. package/dist/es2019/editor-next/utils/deprecationWarnings.js +39 -0
  126. package/dist/es2019/editor-next/utils/editorMeasureTTICallback.js +40 -0
  127. package/dist/es2019/editor-next/utils/editorPropTypes.js +29 -0
  128. package/dist/es2019/editor-next/utils/getBaseFontSize.js +11 -0
  129. package/dist/es2019/editor-next/utils/handleProviders.js +52 -0
  130. package/dist/es2019/editor-next/utils/onEditorCreated.js +21 -0
  131. package/dist/es2019/editor-next/utils/sendDurationAnalytics.js +40 -0
  132. package/dist/es2019/editor-next/utils/trackEditorActions.js +78 -0
  133. package/dist/es2019/editor.js +111 -396
  134. package/dist/es2019/index.js +2 -1
  135. package/dist/es2019/labs/next/internal/hooks/use-analytics/index.js +2 -2
  136. package/dist/es2019/labs/next/internal/hooks/use-editor/create-dispatch-transaction.js +2 -3
  137. package/dist/es2019/labs/next/presets/create-stub-internal-apis.js +105 -0
  138. package/dist/es2019/labs/next/presets/preset.js +0 -3
  139. package/dist/es2019/labs/next/presets/universal.js +13 -2
  140. package/dist/es2019/plugins/alignment/ui/ToolbarAlignment/index.js +41 -12
  141. package/dist/es2019/plugins/analytics/index.js +3 -4
  142. package/dist/es2019/plugins/analytics/plugin.js +1 -2
  143. package/dist/es2019/plugins/analytics/utils.js +0 -4
  144. package/dist/es2019/plugins/base/pm-plugins/filter-steps.js +1 -1
  145. package/dist/es2019/plugins/base/pm-plugins/frozen-editor.js +96 -58
  146. package/dist/es2019/plugins/base/utils/input-latency-tracking.js +23 -23
  147. package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +1 -0
  148. package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/index.js +31 -5
  149. package/dist/es2019/plugins/card/nodeviews/blockCard.js +4 -1
  150. package/dist/es2019/plugins/card/nodeviews/genericCard.js +16 -2
  151. package/dist/es2019/plugins/card/pm-plugins/main.js +3 -1
  152. package/dist/es2019/plugins/clipboard/pm-plugins/main.js +3 -1
  153. package/dist/es2019/plugins/collab-edit/plugin.js +1 -2
  154. package/dist/es2019/plugins/extension/toolbar.js +7 -1
  155. package/dist/es2019/plugins/find-replace/ui/FindReplaceToolbarButton.js +5 -1
  156. package/dist/es2019/plugins/floating-toolbar/ui/Button.js +2 -0
  157. package/dist/es2019/plugins/floating-toolbar/ui/CheckboxModal.js +5 -3
  158. package/dist/es2019/plugins/floating-toolbar/ui/Dropdown.js +35 -7
  159. package/dist/es2019/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +2 -2
  160. package/dist/es2019/plugins/floating-toolbar/ui/ScrollButtons.js +12 -7
  161. package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +11 -0
  162. package/dist/es2019/plugins/fragment/pm-plugins/fragment-consistency.js +1 -0
  163. package/dist/es2019/plugins/hyperlink/analytics.js +1 -1
  164. package/dist/es2019/plugins/hyperlink/index.js +1 -1
  165. package/dist/es2019/plugins/hyperlink/pm-plugins/main.js +8 -4
  166. package/dist/es2019/plugins/hyperlink/ui/EditorLinkPicker/index.js +9 -3
  167. package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +1 -1
  168. package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +3 -2
  169. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +1 -0
  170. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.js +1 -0
  171. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.js +3 -0
  172. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.js +1 -0
  173. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +24 -0
  174. package/dist/es2019/plugins/media/commands/helpers.js +9 -35
  175. package/dist/es2019/plugins/media/commands/index.js +1 -1
  176. package/dist/es2019/plugins/media/nodeviews/mediaGroup.js +3 -3
  177. package/dist/es2019/plugins/media/nodeviews/mediaInline.js +1 -1
  178. package/dist/es2019/plugins/media/nodeviews/mediaNodeUpdater.js +70 -37
  179. package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +1 -1
  180. package/dist/es2019/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +1 -1
  181. package/dist/es2019/plugins/media/pm-plugins/main.js +3 -30
  182. package/dist/es2019/plugins/media/toolbar/filePreviewItem.js +1 -4
  183. package/dist/es2019/plugins/panel/utils.js +4 -1
  184. package/dist/es2019/plugins/paste/handlers.js +127 -5
  185. package/dist/es2019/plugins/paste/pm-plugins/analytics.js +10 -4
  186. package/dist/es2019/plugins/paste/pm-plugins/main.js +13 -4
  187. package/dist/es2019/plugins/placeholder-text/index.js +1 -1
  188. package/dist/es2019/plugins/status/index.js +8 -2
  189. package/dist/es2019/plugins/status/ui/statusPicker.js +8 -2
  190. package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/index.js +42 -8
  191. package/dist/es2019/plugins/text-formatting/ui/Toolbar/dropdown-menu.js +20 -3
  192. package/dist/es2019/plugins/text-formatting/ui/Toolbar/index.js +4 -2
  193. package/dist/es2019/plugins/text-formatting/ui/Toolbar/more-button.js +3 -1
  194. package/dist/es2019/plugins/text-formatting/utils.js +0 -8
  195. package/dist/es2019/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +16 -1
  196. package/dist/es2019/plugins/type-ahead/index.js +1 -1
  197. package/dist/es2019/plugins/type-ahead/ui/InputQuery.js +73 -92
  198. package/dist/es2019/types/get-editor-props.js +1 -0
  199. package/dist/es2019/ui/ChromeCollapsed/index.js +1 -0
  200. package/dist/es2019/ui/CollapsedEditor/index.js +7 -11
  201. package/dist/es2019/ui/ColorPickerButton/index.js +61 -8
  202. package/dist/es2019/ui/ConfigPanel/ConfigPanel.js +1 -1
  203. package/dist/es2019/ui/ContextPanel/context.js +5 -4
  204. package/dist/es2019/ui/Dropdown/index.js +5 -2
  205. package/dist/es2019/ui/DropdownMenu/index.js +5 -2
  206. package/dist/es2019/ui/ElementBrowser/components/CategoryList.js +1 -1
  207. package/dist/es2019/ui/ElementBrowser/components/ElementList/ElementList.js +1 -1
  208. package/dist/es2019/ui/ElementBrowser/components/StatelessElementBrowser.js +1 -1
  209. package/dist/es2019/ui/PanelTextInput/index.js +3 -3
  210. package/dist/es2019/ui/PortalProvider/index.js +1 -1
  211. package/dist/es2019/ui/WidthEmitter/index.js +25 -29
  212. package/dist/es2019/utils/document.js +11 -1
  213. package/dist/es2019/utils/extensions.js +1 -3
  214. package/dist/es2019/utils/get-editor-plugins.js +25 -0
  215. package/dist/es2019/utils/linking-utils.js +1 -1
  216. package/dist/es2019/utils/performance/components/RenderTracking.js +1 -1
  217. package/dist/es2019/utils/performance/safer-transactions.js +1 -1
  218. package/dist/es2019/utils/prepare-extension-provider.js +13 -0
  219. package/dist/es2019/version-wrapper.js +1 -1
  220. package/dist/es2019/version.json +1 -1
  221. package/dist/esm/actions/index.js +2 -2
  222. package/dist/esm/create-editor/ReactEditorView.js +12 -763
  223. package/dist/esm/create-editor/ReactEditorViewInternal.js +776 -0
  224. package/dist/esm/create-editor/ReactEditorViewNext.js +7 -0
  225. package/dist/esm/create-editor/create-plugins-list.js +1 -0
  226. package/dist/esm/create-editor/feature-flags-from-props.js +3 -2
  227. package/dist/esm/editor-next/editor-internal.js +141 -0
  228. package/dist/esm/editor-next/editor-migration-component.js +28 -0
  229. package/dist/esm/editor-next/hooks/useEditorMeasuresConstructor.js +30 -0
  230. package/dist/esm/editor-next/hooks/useMeasureEditorMountTime.js +35 -0
  231. package/dist/esm/editor-next/hooks/useProviderFactory.js +65 -0
  232. package/dist/esm/editor-next/index.js +134 -0
  233. package/dist/esm/editor-next/utils/deprecationWarnings.js +39 -0
  234. package/dist/esm/editor-next/utils/editorMeasureTTICallback.js +38 -0
  235. package/dist/esm/editor-next/utils/editorPropTypes.js +28 -0
  236. package/dist/esm/editor-next/utils/getBaseFontSize.js +11 -0
  237. package/dist/esm/editor-next/utils/handleProviders.js +50 -0
  238. package/dist/esm/editor-next/utils/onEditorCreated.js +21 -0
  239. package/dist/esm/editor-next/utils/sendDurationAnalytics.js +61 -0
  240. package/dist/esm/editor-next/utils/trackEditorActions.js +94 -0
  241. package/dist/esm/editor.js +130 -440
  242. package/dist/esm/index.js +2 -1
  243. package/dist/esm/labs/next/internal/hooks/use-analytics/index.js +2 -2
  244. package/dist/esm/labs/next/internal/hooks/use-editor/create-dispatch-transaction.js +2 -3
  245. package/dist/esm/labs/next/presets/create-stub-internal-apis.js +110 -0
  246. package/dist/esm/labs/next/presets/preset.js +0 -5
  247. package/dist/esm/labs/next/presets/universal.js +11 -2
  248. package/dist/esm/plugins/alignment/ui/ToolbarAlignment/index.js +48 -13
  249. package/dist/esm/plugins/analytics/index.js +3 -4
  250. package/dist/esm/plugins/analytics/plugin.js +1 -2
  251. package/dist/esm/plugins/analytics/utils.js +0 -9
  252. package/dist/esm/plugins/base/pm-plugins/filter-steps.js +1 -1
  253. package/dist/esm/plugins/base/pm-plugins/frozen-editor.js +98 -56
  254. package/dist/esm/plugins/base/utils/input-latency-tracking.js +24 -25
  255. package/dist/esm/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +1 -0
  256. package/dist/esm/plugins/block-type/ui/ToolbarBlockType/index.js +36 -9
  257. package/dist/esm/plugins/card/nodeviews/blockCard.js +2 -1
  258. package/dist/esm/plugins/card/nodeviews/genericCard.js +16 -2
  259. package/dist/esm/plugins/card/pm-plugins/main.js +4 -2
  260. package/dist/esm/plugins/clipboard/pm-plugins/main.js +4 -1
  261. package/dist/esm/plugins/collab-edit/plugin.js +1 -2
  262. package/dist/esm/plugins/extension/toolbar.js +7 -1
  263. package/dist/esm/plugins/find-replace/ui/FindReplaceToolbarButton.js +5 -1
  264. package/dist/esm/plugins/floating-toolbar/ui/Button.js +2 -0
  265. package/dist/esm/plugins/floating-toolbar/ui/CheckboxModal.js +5 -3
  266. package/dist/esm/plugins/floating-toolbar/ui/Dropdown.js +38 -9
  267. package/dist/esm/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +23 -21
  268. package/dist/esm/plugins/floating-toolbar/ui/ScrollButtons.js +12 -7
  269. package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +11 -0
  270. package/dist/esm/plugins/fragment/pm-plugins/fragment-consistency.js +1 -0
  271. package/dist/esm/plugins/hyperlink/analytics.js +1 -1
  272. package/dist/esm/plugins/hyperlink/index.js +1 -1
  273. package/dist/esm/plugins/hyperlink/pm-plugins/main.js +9 -5
  274. package/dist/esm/plugins/hyperlink/ui/EditorLinkPicker/index.js +10 -4
  275. package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +1 -1
  276. package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +3 -2
  277. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +1 -0
  278. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.js +1 -0
  279. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.js +3 -0
  280. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.js +1 -0
  281. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +22 -0
  282. package/dist/esm/plugins/media/commands/helpers.js +9 -35
  283. package/dist/esm/plugins/media/commands/index.js +1 -1
  284. package/dist/esm/plugins/media/nodeviews/mediaGroup.js +14 -12
  285. package/dist/esm/plugins/media/nodeviews/mediaInline.js +1 -1
  286. package/dist/esm/plugins/media/nodeviews/mediaNodeUpdater.js +311 -206
  287. package/dist/esm/plugins/media/nodeviews/mediaSingle.js +1 -1
  288. package/dist/esm/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +1 -1
  289. package/dist/esm/plugins/media/pm-plugins/main.js +3 -28
  290. package/dist/esm/plugins/media/toolbar/filePreviewItem.js +1 -4
  291. package/dist/esm/plugins/panel/utils.js +4 -1
  292. package/dist/esm/plugins/paste/handlers.js +127 -13
  293. package/dist/esm/plugins/paste/pm-plugins/analytics.js +13 -5
  294. package/dist/esm/plugins/paste/pm-plugins/main.js +13 -4
  295. package/dist/esm/plugins/placeholder-text/index.js +2 -2
  296. package/dist/esm/plugins/status/index.js +9 -3
  297. package/dist/esm/plugins/status/ui/statusPicker.js +8 -2
  298. package/dist/esm/plugins/text-color/ui/ToolbarTextColor/index.js +42 -8
  299. package/dist/esm/plugins/text-formatting/ui/Toolbar/dropdown-menu.js +23 -3
  300. package/dist/esm/plugins/text-formatting/ui/Toolbar/index.js +4 -2
  301. package/dist/esm/plugins/text-formatting/ui/Toolbar/more-button.js +3 -1
  302. package/dist/esm/plugins/text-formatting/utils.js +0 -8
  303. package/dist/esm/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +19 -1
  304. package/dist/esm/plugins/type-ahead/index.js +1 -1
  305. package/dist/esm/plugins/type-ahead/ui/InputQuery.js +79 -106
  306. package/dist/esm/types/get-editor-props.js +1 -0
  307. package/dist/esm/ui/ChromeCollapsed/index.js +1 -0
  308. package/dist/esm/ui/CollapsedEditor/index.js +7 -13
  309. package/dist/esm/ui/ColorPickerButton/index.js +69 -7
  310. package/dist/esm/ui/ConfigPanel/ConfigPanel.js +1 -1
  311. package/dist/esm/ui/ContextPanel/context.js +8 -8
  312. package/dist/esm/ui/Dropdown/index.js +7 -2
  313. package/dist/esm/ui/DropdownMenu/index.js +7 -2
  314. package/dist/esm/ui/ElementBrowser/components/CategoryList.js +1 -1
  315. package/dist/esm/ui/ElementBrowser/components/ElementList/ElementList.js +1 -1
  316. package/dist/esm/ui/ElementBrowser/components/StatelessElementBrowser.js +1 -1
  317. package/dist/esm/ui/PanelTextInput/index.js +4 -4
  318. package/dist/esm/ui/PortalProvider/index.js +1 -1
  319. package/dist/esm/ui/WidthEmitter/index.js +28 -37
  320. package/dist/esm/utils/document.js +15 -1
  321. package/dist/esm/utils/extensions.js +1 -3
  322. package/dist/esm/utils/get-editor-plugins.js +25 -0
  323. package/dist/esm/utils/linking-utils.js +1 -1
  324. package/dist/esm/utils/performance/components/RenderTracking.js +1 -1
  325. package/dist/esm/utils/performance/safer-transactions.js +1 -1
  326. package/dist/esm/utils/prepare-extension-provider.js +17 -0
  327. package/dist/esm/version-wrapper.js +1 -1
  328. package/dist/esm/version.json +1 -1
  329. package/dist/types/actions/index.d.ts +2 -2
  330. package/dist/types/create-editor/ReactEditorView.d.ts +7 -109
  331. package/dist/types/create-editor/ReactEditorViewInternal.d.ts +112 -0
  332. package/dist/types/create-editor/ReactEditorViewNext.d.ts +9 -0
  333. package/dist/types/editor-next/editor-internal.d.ts +44 -0
  334. package/dist/types/editor-next/editor-migration-component.d.ts +5 -0
  335. package/dist/types/editor-next/hooks/useEditorMeasuresConstructor.d.ts +17 -0
  336. package/dist/types/editor-next/hooks/useMeasureEditorMountTime.d.ts +13 -0
  337. package/dist/types/editor-next/hooks/useProviderFactory.d.ts +21 -0
  338. package/dist/types/editor-next/index.d.ts +34 -0
  339. package/dist/types/editor-next/utils/deprecationWarnings.d.ts +2 -0
  340. package/dist/types/editor-next/utils/editorMeasureTTICallback.d.ts +5 -0
  341. package/dist/types/editor-next/utils/editorPropTypes.d.ts +19 -0
  342. package/dist/types/editor-next/utils/getBaseFontSize.d.ts +6 -0
  343. package/dist/types/editor-next/utils/handleProviders.d.ts +14 -0
  344. package/dist/types/editor-next/utils/onEditorCreated.d.ts +12 -0
  345. package/dist/types/editor-next/utils/sendDurationAnalytics.d.ts +15 -0
  346. package/dist/types/editor-next/utils/trackEditorActions.d.ts +29 -0
  347. package/dist/types/editor.d.ts +47 -25
  348. package/dist/types/index.d.ts +1 -0
  349. package/dist/types/labs/next/internal/hooks/use-analytics/index.d.ts +1 -1
  350. package/dist/types/labs/next/presets/create-stub-internal-apis.d.ts +16 -0
  351. package/dist/types/labs/next/presets/preset.d.ts +6 -6
  352. package/dist/types/labs/next/presets/universal.d.ts +1 -1
  353. package/dist/types/plugins/alignment/index.d.ts +1 -1
  354. package/dist/types/plugins/alignment/ui/ToolbarAlignment/index.d.ts +3 -1
  355. package/dist/types/plugins/analytics/index.d.ts +3 -6
  356. package/dist/types/plugins/analytics/plugin.d.ts +3 -1
  357. package/dist/types/plugins/analytics/utils.d.ts +2 -3
  358. package/dist/types/plugins/annotation/index.d.ts +3 -1
  359. package/dist/types/plugins/avatar-group/index.d.ts +3 -1
  360. package/dist/types/plugins/base/index.d.ts +3 -1
  361. package/dist/types/plugins/base/pm-plugins/filter-steps.d.ts +1 -1
  362. package/dist/types/plugins/base/utils/input-latency-tracking.d.ts +1 -3
  363. package/dist/types/plugins/before-primaryToolbar/index.d.ts +3 -1
  364. package/dist/types/plugins/block-type/index.d.ts +3 -1
  365. package/dist/types/plugins/block-type/ui/ToolbarBlockType/blocktype-button.d.ts +1 -0
  366. package/dist/types/plugins/block-type/ui/ToolbarBlockType/index.d.ts +1 -0
  367. package/dist/types/plugins/breakout/index.d.ts +3 -1
  368. package/dist/types/plugins/card/index.d.ts +3 -1
  369. package/dist/types/plugins/card/nodeviews/genericCard.d.ts +1 -1
  370. package/dist/types/plugins/card/pm-plugins/util/state.d.ts +1 -0
  371. package/dist/types/plugins/card/types.d.ts +3 -0
  372. package/dist/types/plugins/code-bidi-warning/index.d.ts +3 -1
  373. package/dist/types/plugins/code-block/index.d.ts +3 -1
  374. package/dist/types/plugins/collab-edit/index.d.ts +3 -1
  375. package/dist/types/plugins/context-panel/index.d.ts +1 -1
  376. package/dist/types/plugins/emoji/index.d.ts +3 -1
  377. package/dist/types/plugins/expand/index.d.ts +3 -1
  378. package/dist/types/plugins/extension/index.d.ts +3 -1
  379. package/dist/types/plugins/extension/toolbar.d.ts +5 -0
  380. package/dist/types/plugins/feature-flags-context/index.d.ts +3 -1
  381. package/dist/types/plugins/feedback-dialog/index.d.ts +3 -1
  382. package/dist/types/plugins/find-replace/index.d.ts +3 -1
  383. package/dist/types/plugins/floating-toolbar/ui/Button.d.ts +2 -1
  384. package/dist/types/plugins/floating-toolbar/ui/Dropdown.d.ts +5 -2
  385. package/dist/types/plugins/grid/index.d.ts +3 -1
  386. package/dist/types/plugins/help-dialog/index.d.ts +3 -1
  387. package/dist/types/plugins/hyperlink/analytics.d.ts +1 -1
  388. package/dist/types/plugins/hyperlink/index.d.ts +3 -1
  389. package/dist/types/plugins/hyperlink/pm-plugins/main.d.ts +4 -2
  390. package/dist/types/plugins/hyperlink/types.d.ts +3 -1
  391. package/dist/types/plugins/hyperlink/ui/EditorLinkPicker/index.d.ts +3 -1
  392. package/dist/types/plugins/insert-block/index.d.ts +3 -1
  393. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.d.ts +1 -0
  394. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.d.ts +1 -0
  395. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.d.ts +1 -0
  396. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.d.ts +1 -0
  397. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/index.d.ts +1 -0
  398. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +1 -0
  399. package/dist/types/plugins/layout/index.d.ts +3 -1
  400. package/dist/types/plugins/list/index.d.ts +3 -1
  401. package/dist/types/plugins/max-content-size/index.d.ts +3 -1
  402. package/dist/types/plugins/media/commands/helpers.d.ts +5 -12
  403. package/dist/types/plugins/media/commands/index.d.ts +1 -1
  404. package/dist/types/plugins/media/index.d.ts +3 -1
  405. package/dist/types/plugins/media/nodeviews/__mocks__/mediaNodeUpdater.d.ts +3 -1
  406. package/dist/types/plugins/media/nodeviews/mediaNodeUpdater.d.ts +4 -1
  407. package/dist/types/plugins/media/pm-plugins/main.d.ts +1 -4
  408. package/dist/types/plugins/media/pm-plugins/types.d.ts +1 -4
  409. package/dist/types/plugins/mentions/index.d.ts +3 -1
  410. package/dist/types/plugins/panel/index.d.ts +3 -1
  411. package/dist/types/plugins/paste/handlers.d.ts +2 -1
  412. package/dist/types/plugins/paste/index.d.ts +3 -1
  413. package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +4 -1
  414. package/dist/types/plugins/placeholder/index.d.ts +3 -1
  415. package/dist/types/plugins/placeholder-text/index.d.ts +3 -1
  416. package/dist/types/plugins/quick-insert/index.d.ts +3 -1
  417. package/dist/types/plugins/save-on-enter/index.d.ts +3 -1
  418. package/dist/types/plugins/selection/index.d.ts +3 -1
  419. package/dist/types/plugins/status/index.d.ts +3 -1
  420. package/dist/types/plugins/status/ui/statusPicker.d.ts +3 -0
  421. package/dist/types/plugins/submit-editor/index.d.ts +3 -1
  422. package/dist/types/plugins/tasks-and-decisions/index.d.ts +3 -1
  423. package/dist/types/plugins/text-color/index.d.ts +3 -1
  424. package/dist/types/plugins/text-color/ui/ToolbarTextColor/index.d.ts +2 -0
  425. package/dist/types/plugins/text-formatting/index.d.ts +3 -1
  426. package/dist/types/plugins/text-formatting/ui/Toolbar/more-button.d.ts +2 -1
  427. package/dist/types/plugins/text-formatting/utils.d.ts +0 -1
  428. package/dist/types/plugins/toolbar-lists-indentation/index.d.ts +3 -1
  429. package/dist/types/plugins/type-ahead/index.d.ts +3 -1
  430. package/dist/types/types/get-editor-props.d.ts +12 -0
  431. package/dist/types/types/performance-tracking.d.ts +10 -0
  432. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +29 -29
  433. package/dist/types/ui/CollapsedEditor/index.d.ts +4 -3
  434. package/dist/types/ui/ColorPickerButton/index.d.ts +2 -1
  435. package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
  436. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  437. package/dist/types/ui/ContextPanel/context.d.ts +2 -1
  438. package/dist/types/ui/PanelTextInput/index.d.ts +1 -1
  439. package/dist/types/ui/PortalProvider/index.d.ts +1 -1
  440. package/dist/types/utils/document.d.ts +4 -3
  441. package/dist/types/utils/get-editor-plugins.d.ts +10 -0
  442. package/dist/types/utils/linking-utils.d.ts +1 -1
  443. package/dist/types/utils/performance/components/RenderTracking.d.ts +1 -1
  444. package/dist/types/utils/performance/instrumented-plugin.d.ts +1 -1
  445. package/dist/types/utils/performance/safer-transactions.d.ts +1 -1
  446. package/dist/types/utils/prepare-extension-provider.d.ts +5 -0
  447. package/docs/0-intro.tsx +0 -1
  448. package/package.json +27 -26
  449. package/report.api.md +193 -139
  450. package/dist/cjs/plugins/analytics/analytics-queue.js +0 -79
  451. package/dist/cjs/plugins/analytics/fire-analytics-event.js +0 -35
  452. package/dist/es2019/plugins/analytics/analytics-queue.js +0 -53
  453. package/dist/es2019/plugins/analytics/fire-analytics-event.js +0 -26
  454. package/dist/esm/plugins/analytics/analytics-queue.js +0 -71
  455. package/dist/esm/plugins/analytics/fire-analytics-event.js +0 -28
  456. package/dist/types/plugins/analytics/analytics-queue.d.ts +0 -10
  457. package/dist/types/plugins/analytics/fire-analytics-event.d.ts +0 -9
@@ -0,0 +1,712 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import React from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import { EditorState, Selection } from 'prosemirror-state';
5
+ import { EditorView } from 'prosemirror-view';
6
+ import { editorMessages } from './messages';
7
+ import { browser, getAnalyticsEventSeverity, getResponseEndTime, measureRender, startMeasure, stopMeasure, shouldForceTracking } from '@atlaskit/editor-common/utils';
8
+ import { ExperienceStore, EditorExperience, RELIABILITY_INTERVAL } from '@atlaskit/editor-common/ufo';
9
+ import { createDispatch, EventDispatcher } from '../event-dispatcher';
10
+ import { processRawValue } from '../utils';
11
+ import { freezeUnsafeTransactionProperties } from '../utils/performance/safer-transactions';
12
+ import { RenderTracking } from '../utils/performance/components/RenderTracking';
13
+ import { findChangedNodesFromTransaction, validateNodes, validNode } from '../utils/nodes';
14
+ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, fireAnalyticsEvent, FULL_WIDTH_MODE, PLATFORMS, getAnalyticsEventsFromTransaction } from '@atlaskit/editor-common/analytics';
15
+ import { createFeatureFlagsFromProps } from './feature-flags-from-props';
16
+ import { getEnabledFeatureFlagKeys } from '../plugins/feature-flags-context/get-enabled-feature-flag-keys';
17
+ import { createErrorReporter, createPMPlugins, processPluginsList } from './create-editor';
18
+ import { getDocStructure } from '../utils/document-logger';
19
+ import { isFullPage } from '../utils/is-full-page';
20
+ import measurements from '../utils/performance/measure-enum';
21
+ import { getNodesCount } from '../utils/document';
22
+ import { analyticsEventKey } from '@atlaskit/editor-common/utils';
23
+ import { createSchema } from './create-schema';
24
+ import { PluginPerformanceObserver } from '../utils/performance/plugin-performance-observer';
25
+ import { getParticipantsCount } from '../plugins/collab-edit/get-participants-count';
26
+ import { countNodes } from '../utils/count-nodes';
27
+ import { TransactionTracker } from '../utils/performance/track-transactions';
28
+ import { EVENT_NAME_DISPATCH_TRANSACTION, EVENT_NAME_STATE_APPLY, EVENT_NAME_UPDATE_STATE, EVENT_NAME_VIEW_STATE_UPDATED, EVENT_NAME_ON_CHANGE } from '../utils/performance/track-transactions';
29
+ import { PROSEMIRROR_RENDERED_NORMAL_SEVERITY_THRESHOLD, PROSEMIRROR_RENDERED_DEGRADED_SEVERITY_THRESHOLD, DEFAULT_SAMPLING_RATE_VALID_TRANSACTIONS } from './consts';
30
+ import { getContextIdentifier } from '../plugins/base/pm-plugins/context-identifier';
31
+ import ReactEditorViewContext from './ReactEditorViewContext';
32
+ import { createInsertNodeAPI } from '../insert-api/api';
33
+ import { createEditorAnalyticsAPI } from '../analytics-api/api';
34
+ function handleEditorFocus(view) {
35
+ if (view.hasFocus()) {
36
+ return;
37
+ }
38
+ return window.setTimeout(() => {
39
+ view.focus();
40
+ }, 0);
41
+ }
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
+ export class ReactEditorView extends React.Component {
55
+ // ProseMirror is instantiated prior to the initial React render cycle,
56
+ // so we allow transactions by default, to avoid discarding the initial one.
57
+
58
+ get transactionTracking() {
59
+ var _this$props$editorPro, _this$props$editorPro2;
60
+ return (_this$props$editorPro = (_this$props$editorPro2 = this.props.editorProps.performanceTracking) === null || _this$props$editorPro2 === void 0 ? void 0 : _this$props$editorPro2.transactionTracking) !== null && _this$props$editorPro !== void 0 ? _this$props$editorPro : {
61
+ enabled: false
62
+ };
63
+ }
64
+ getPluginNames() {
65
+ return this.editorState.plugins.map(p => p.key);
66
+ }
67
+ countNodes() {
68
+ return countNodes(this.editorState);
69
+ }
70
+ constructor(_props, context) {
71
+ super(_props, context);
72
+ _defineProperty(this, "editorRef", /*#__PURE__*/React.createRef());
73
+ _defineProperty(this, "canDispatchTransactions", true);
74
+ _defineProperty(this, "onPluginObservation", (report, editorState) => {
75
+ this.dispatchAnalyticsEvent({
76
+ action: ACTION.TRANSACTION_DISPATCHED,
77
+ actionSubject: ACTION_SUBJECT.EDITOR,
78
+ eventType: EVENT_TYPE.OPERATIONAL,
79
+ attributes: {
80
+ report,
81
+ participants: getParticipantsCount(editorState)
82
+ }
83
+ });
84
+ });
85
+ _defineProperty(this, "formatFullWidthAppearance", appearance => {
86
+ if (appearance === 'full-width') {
87
+ return FULL_WIDTH_MODE.FULL_WIDTH;
88
+ }
89
+ return FULL_WIDTH_MODE.FIXED_WIDTH;
90
+ });
91
+ _defineProperty(this, "resetEditorState", ({
92
+ doc,
93
+ shouldScrollToBottom
94
+ }) => {
95
+ var _this$props$editorPro3, _this$props$editorPro4;
96
+ if (!this.view) {
97
+ return;
98
+ }
99
+
100
+ // We cannot currently guarentee when all the portals will have re-rendered during a reconfigure
101
+ // so we blur here to stop ProseMirror from trying to apply selection to detached nodes or
102
+ // nodes that haven't been re-rendered to the document yet.
103
+ this.blur();
104
+ this.featureFlags = createFeatureFlagsFromProps(this.props.editorProps);
105
+ this.editorState = this.createEditorState({
106
+ props: this.props,
107
+ context: this.context,
108
+ doc: doc,
109
+ resetting: true,
110
+ selectionAtStart: !shouldScrollToBottom
111
+ });
112
+ this.view.updateState(this.editorState);
113
+ (_this$props$editorPro3 = (_this$props$editorPro4 = this.props.editorProps).onChange) === null || _this$props$editorPro3 === void 0 ? void 0 : _this$props$editorPro3.call(_this$props$editorPro4, this.view, {
114
+ source: 'local'
115
+ });
116
+ });
117
+ _defineProperty(this, "blur", () => {
118
+ if (!this.view) {
119
+ return;
120
+ }
121
+ if (this.view.dom instanceof HTMLElement && this.view.hasFocus()) {
122
+ this.view.dom.blur();
123
+ }
124
+
125
+ // The selectionToDOM method uses the document selection to determine currently selected node
126
+ // We need to mimic blurring this as it seems doing the above is not enough.
127
+ // @ts-expect-error
128
+ const sel = this.view.root.getSelection();
129
+ if (sel) {
130
+ sel.removeAllRanges();
131
+ }
132
+ });
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
+ _defineProperty(this, "handleAnalyticsEvent", payload => {
173
+ if (!this.props.allowAnalyticsGASV3) {
174
+ return;
175
+ }
176
+ fireAnalyticsEvent(this.props.createAnalyticsEvent)(payload);
177
+ });
178
+ _defineProperty(this, "editorPlugins", []);
179
+ _defineProperty(this, "createEditorState", options => {
180
+ let schema;
181
+ if (this.view) {
182
+ if (options.resetting) {
183
+ /**
184
+ * ReactEditorView currently does NOT handle dynamic schema,
185
+ * We are reusing the existing schema, and rely on #reconfigureState
186
+ * to update `this.config`
187
+ */
188
+ schema = this.view.state.schema;
189
+ } else {
190
+ /**
191
+ * There's presently a number of issues with changing the schema of a
192
+ * editor inflight. A significant issue is that we lose the ability
193
+ * to keep track of a user's history as the internal plugin state
194
+ * keeps a list of Steps to undo/redo (which are tied to the schema).
195
+ * Without a good way to do work around this, we prevent this for now.
196
+ */
197
+ // eslint-disable-next-line no-console
198
+ console.warn('The editor does not support changing the schema dynamically.');
199
+ return this.editorState;
200
+ }
201
+ } else {
202
+ this.config = processPluginsList(this.getPlugins(options.props.editorProps, undefined, options.props.createAnalyticsEvent));
203
+ schema = createSchema(this.config);
204
+ }
205
+ const {
206
+ contentTransformerProvider
207
+ } = options.props.editorProps;
208
+ const plugins = createPMPlugins({
209
+ schema,
210
+ dispatch: this.dispatch,
211
+ errorReporter: this.errorReporter,
212
+ editorConfig: this.config,
213
+ eventDispatcher: this.eventDispatcher,
214
+ providerFactory: options.props.providerFactory,
215
+ portalProviderAPI: this.props.portalProviderAPI,
216
+ reactContext: () => options.context,
217
+ dispatchAnalyticsEvent: this.dispatchAnalyticsEvent,
218
+ performanceTracking: this.props.editorProps.performanceTracking,
219
+ transactionTracker: this.transactionTracker,
220
+ featureFlags: this.featureFlags,
221
+ getIntl: () => this.props.intl
222
+ });
223
+ this.contentTransformer = contentTransformerProvider ? contentTransformerProvider(schema) : undefined;
224
+ let doc;
225
+ if (options.doc) {
226
+ doc = processRawValue(schema, options.doc, options.props.providerFactory, options.props.editorProps.sanitizePrivateContent, this.contentTransformer, this.dispatchAnalyticsEvent);
227
+ }
228
+ let selection;
229
+ if (doc) {
230
+ selection = options.selectionAtStart ? Selection.atStart(doc) : Selection.atEnd(doc);
231
+ }
232
+ // Workaround for ED-3507: When media node is the last element, scrollIntoView throws an error
233
+ const patchedSelection = selection ? Selection.findFrom(selection.$head, -1, true) || undefined : undefined;
234
+ return EditorState.create({
235
+ schema,
236
+ plugins: plugins,
237
+ doc,
238
+ selection: patchedSelection
239
+ });
240
+ });
241
+ _defineProperty(this, "onEditorViewStateUpdated", ({
242
+ originalTransaction,
243
+ transactions,
244
+ oldEditorState,
245
+ newEditorState
246
+ }) => {
247
+ const {
248
+ enabled: trackinEnabled
249
+ } = this.transactionTracking;
250
+ this.config.onEditorViewStateUpdatedCallbacks.forEach(entry => {
251
+ trackinEnabled && startMeasure(`🦉 ${entry.pluginName}::onEditorViewStateUpdated`);
252
+ entry.callback({
253
+ originalTransaction,
254
+ transactions,
255
+ oldEditorState,
256
+ newEditorState
257
+ });
258
+ trackinEnabled && stopMeasure(`🦉 ${entry.pluginName}::onEditorViewStateUpdated`);
259
+ });
260
+ });
261
+ _defineProperty(this, "trackValidTransactions", () => {
262
+ const {
263
+ editorProps
264
+ } = this.props;
265
+ if (editorProps !== null && editorProps !== void 0 && editorProps.trackValidTransactions) {
266
+ this.validTransactionCount++;
267
+ const samplingRate = typeof editorProps.trackValidTransactions === 'object' && editorProps.trackValidTransactions.samplingRate || DEFAULT_SAMPLING_RATE_VALID_TRANSACTIONS;
268
+ if (this.validTransactionCount >= samplingRate) {
269
+ this.dispatchAnalyticsEvent({
270
+ action: ACTION.DISPATCHED_VALID_TRANSACTION,
271
+ actionSubject: ACTION_SUBJECT.EDITOR,
272
+ eventType: EVENT_TYPE.OPERATIONAL
273
+ });
274
+ this.validTransactionCount = 0;
275
+ }
276
+ }
277
+ });
278
+ _defineProperty(this, "dispatchTransaction", unsafeTransaction => {
279
+ if (!this.view) {
280
+ return;
281
+ }
282
+ this.transactionTracker.bumpDispatchCounter(this.transactionTracking);
283
+ const {
284
+ startMeasure,
285
+ stopMeasure
286
+ } = this.transactionTracker.getMeasureHelpers(this.transactionTracking);
287
+ startMeasure(EVENT_NAME_DISPATCH_TRANSACTION);
288
+ if (this.transactionTracker.shouldTrackTransaction(this.transactionTracking)) {
289
+ var _this$experienceStore;
290
+ (_this$experienceStore = this.experienceStore) === null || _this$experienceStore === void 0 ? void 0 : _this$experienceStore.start(EditorExperience.interaction);
291
+ }
292
+ const nodes = findChangedNodesFromTransaction(unsafeTransaction);
293
+ const changedNodesValid = validateNodes(nodes);
294
+ const transaction = this.featureFlags.saferDispatchedTransactions || this.featureFlags.saferDispatchedTransactionsAnalyticsOnly ? new Proxy(unsafeTransaction, freezeUnsafeTransactionProperties({
295
+ dispatchAnalyticsEvent: this.dispatchAnalyticsEvent,
296
+ pluginKey: 'unknown-reacteditorview',
297
+ analyticsOnly: this.featureFlags.saferDispatchedTransactionsAnalyticsOnly
298
+ })) : unsafeTransaction;
299
+ if (changedNodesValid) {
300
+ const oldEditorState = this.view.state;
301
+
302
+ // go ahead and update the state now we know the transaction is good
303
+ startMeasure(EVENT_NAME_STATE_APPLY);
304
+ const {
305
+ state: editorState,
306
+ transactions
307
+ } = this.view.state.applyTransaction(transaction);
308
+ stopMeasure(EVENT_NAME_STATE_APPLY, (duration, startTime) => {
309
+ var _this$experienceStore2;
310
+ (_this$experienceStore2 = this.experienceStore) === null || _this$experienceStore2 === void 0 ? void 0 : _this$experienceStore2.mark(EditorExperience.interaction, 'stateApply', startTime + duration);
311
+ });
312
+ this.trackValidTransactions();
313
+ if (editorState === oldEditorState) {
314
+ return;
315
+ }
316
+ startMeasure(EVENT_NAME_UPDATE_STATE);
317
+ this.view.updateState(editorState);
318
+ stopMeasure(EVENT_NAME_UPDATE_STATE, (duration, startTime) => {
319
+ var _this$experienceStore3;
320
+ (_this$experienceStore3 = this.experienceStore) === null || _this$experienceStore3 === void 0 ? void 0 : _this$experienceStore3.mark(EditorExperience.interaction, 'viewUpdateState', startTime + duration);
321
+ });
322
+ startMeasure(EVENT_NAME_VIEW_STATE_UPDATED);
323
+ this.onEditorViewStateUpdated({
324
+ originalTransaction: transaction,
325
+ transactions,
326
+ oldEditorState,
327
+ newEditorState: editorState
328
+ });
329
+ stopMeasure(EVENT_NAME_VIEW_STATE_UPDATED, (duration, startTime) => {
330
+ var _this$experienceStore4;
331
+ (_this$experienceStore4 = this.experienceStore) === null || _this$experienceStore4 === void 0 ? void 0 : _this$experienceStore4.mark(EditorExperience.interaction, 'onEditorViewStateUpdated', startTime + duration);
332
+ });
333
+ if (this.props.editorProps.onChange && transaction.docChanged) {
334
+ const source = transaction.getMeta('isRemote') ? 'remote' : 'local';
335
+ startMeasure(EVENT_NAME_ON_CHANGE);
336
+ this.props.editorProps.onChange(this.view, {
337
+ source
338
+ });
339
+ stopMeasure(EVENT_NAME_ON_CHANGE, (duration, startTime) => {
340
+ var _this$experienceStore5, _this$props$editorPro5, _this$props$editorPro6;
341
+ (_this$experienceStore5 = this.experienceStore) === null || _this$experienceStore5 === void 0 ? void 0 : _this$experienceStore5.mark(EditorExperience.interaction, 'onChange', startTime + duration);
342
+ if (((_this$props$editorPro5 = this.props.editorProps.performanceTracking) === null || _this$props$editorPro5 === void 0 ? void 0 : (_this$props$editorPro6 = _this$props$editorPro5.onChangeCallbackTracking) === null || _this$props$editorPro6 === void 0 ? void 0 : _this$props$editorPro6.enabled) !== true) {
343
+ return;
344
+ }
345
+ this.dispatchAnalyticsEvent({
346
+ action: ACTION.ON_CHANGE_CALLBACK,
347
+ actionSubject: ACTION_SUBJECT.EDITOR,
348
+ eventType: EVENT_TYPE.OPERATIONAL,
349
+ attributes: {
350
+ duration,
351
+ startTime
352
+ }
353
+ });
354
+ });
355
+ }
356
+ this.editorState = editorState;
357
+ stopMeasure(EVENT_NAME_DISPATCH_TRANSACTION, (duration, startTime) => {
358
+ var _this$experienceStore6, _this$experienceStore7;
359
+ (_this$experienceStore6 = this.experienceStore) === null || _this$experienceStore6 === void 0 ? void 0 : _this$experienceStore6.mark(EditorExperience.interaction, 'dispatchTransaction', startTime + duration);
360
+ (_this$experienceStore7 = this.experienceStore) === null || _this$experienceStore7 === void 0 ? void 0 : _this$experienceStore7.success(EditorExperience.interaction);
361
+ });
362
+ } else {
363
+ var _this$experienceStore8;
364
+ const invalidNodes = nodes.filter(node => !validNode(node)).map(node => getDocStructure(node, {
365
+ compact: true
366
+ }));
367
+ this.dispatchAnalyticsEvent({
368
+ action: ACTION.DISPATCHED_INVALID_TRANSACTION,
369
+ actionSubject: ACTION_SUBJECT.EDITOR,
370
+ eventType: EVENT_TYPE.OPERATIONAL,
371
+ attributes: {
372
+ analyticsEventPayloads: getAnalyticsEventsFromTransaction(transaction),
373
+ invalidNodes
374
+ }
375
+ });
376
+ (_this$experienceStore8 = this.experienceStore) === null || _this$experienceStore8 === void 0 ? void 0 : _this$experienceStore8.fail(EditorExperience.interaction, {
377
+ reason: 'invalid transaction',
378
+ invalidNodes: invalidNodes.toString()
379
+ });
380
+ }
381
+ });
382
+ _defineProperty(this, "getDirectEditorProps", state => {
383
+ return {
384
+ state: state || this.editorState,
385
+ dispatchTransaction: tr => {
386
+ // Block stale transactions:
387
+ // Prevent runtime exeptions from async transactions that would attempt to
388
+ // update the DOM after React has unmounted the Editor.
389
+ if (this.canDispatchTransactions) {
390
+ this.dispatchTransaction(tr);
391
+ }
392
+ },
393
+ // Disables the contentEditable attribute of the editor if the editor is disabled
394
+ editable: _state => !this.props.editorProps.disabled,
395
+ attributes: {
396
+ 'data-gramm': 'false'
397
+ }
398
+ };
399
+ });
400
+ _defineProperty(this, "createEditorView", node => {
401
+ measureRender(measurements.PROSEMIRROR_RENDERED, ({
402
+ duration,
403
+ startTime,
404
+ distortedDuration
405
+ }) => {
406
+ var _this$props$editorPro7, _this$props$editorPro8, _proseMirrorRenderedT, _proseMirrorRenderedT2;
407
+ const proseMirrorRenderedTracking = (_this$props$editorPro7 = this.props.editorProps) === null || _this$props$editorPro7 === void 0 ? void 0 : (_this$props$editorPro8 = _this$props$editorPro7.performanceTracking) === null || _this$props$editorPro8 === void 0 ? void 0 : _this$props$editorPro8.proseMirrorRenderedTracking;
408
+ const forceSeverityTracking = typeof proseMirrorRenderedTracking === 'undefined' && shouldForceTracking();
409
+ this.proseMirrorRenderedSeverity = !!forceSeverityTracking || proseMirrorRenderedTracking !== null && proseMirrorRenderedTracking !== void 0 && proseMirrorRenderedTracking.trackSeverity ? getAnalyticsEventSeverity(duration, (_proseMirrorRenderedT = proseMirrorRenderedTracking === null || proseMirrorRenderedTracking === void 0 ? void 0 : proseMirrorRenderedTracking.severityNormalThreshold) !== null && _proseMirrorRenderedT !== void 0 ? _proseMirrorRenderedT : PROSEMIRROR_RENDERED_NORMAL_SEVERITY_THRESHOLD, (_proseMirrorRenderedT2 = proseMirrorRenderedTracking === null || proseMirrorRenderedTracking === void 0 ? void 0 : proseMirrorRenderedTracking.severityDegradedThreshold) !== null && _proseMirrorRenderedT2 !== void 0 ? _proseMirrorRenderedT2 : PROSEMIRROR_RENDERED_DEGRADED_SEVERITY_THRESHOLD) : undefined;
410
+ if (this.view) {
411
+ var _getContextIdentifier, _this$experienceStore10;
412
+ const nodes = getNodesCount(this.view.state.doc);
413
+ const ttfb = getResponseEndTime();
414
+ this.dispatchAnalyticsEvent({
415
+ action: ACTION.PROSEMIRROR_RENDERED,
416
+ actionSubject: ACTION_SUBJECT.EDITOR,
417
+ attributes: {
418
+ duration,
419
+ startTime,
420
+ nodes,
421
+ ttfb,
422
+ severity: this.proseMirrorRenderedSeverity,
423
+ objectId: (_getContextIdentifier = getContextIdentifier(this.editorState)) === null || _getContextIdentifier === void 0 ? void 0 : _getContextIdentifier.objectId,
424
+ distortedDuration
425
+ },
426
+ eventType: EVENT_TYPE.OPERATIONAL
427
+ });
428
+ if (!distortedDuration) {
429
+ var _this$experienceStore9;
430
+ (_this$experienceStore9 = this.experienceStore) === null || _this$experienceStore9 === void 0 ? void 0 : _this$experienceStore9.mark(EditorExperience.loadEditor, ACTION.PROSEMIRROR_RENDERED, startTime + duration);
431
+ }
432
+ (_this$experienceStore10 = this.experienceStore) === null || _this$experienceStore10 === void 0 ? void 0 : _this$experienceStore10.addMetadata(EditorExperience.loadEditor, {
433
+ nodes,
434
+ ttfb
435
+ });
436
+ }
437
+ });
438
+
439
+ // Creates the editor-view from this.editorState. If an editor has been mounted
440
+ // previously, this will contain the previous state of the editor.
441
+ this.view = new EditorView({
442
+ mount: node
443
+ }, this.getDirectEditorProps());
444
+ });
445
+ _defineProperty(this, "handleEditorViewRef", node => {
446
+ if (!this.view && node) {
447
+ this.createEditorView(node);
448
+ const view = this.view;
449
+ this.props.onEditorCreated({
450
+ view,
451
+ config: this.config,
452
+ eventDispatcher: this.eventDispatcher,
453
+ transformer: this.contentTransformer
454
+ });
455
+ if (this.props.editorProps.shouldFocus && view.props.editable && view.props.editable(view.state)) {
456
+ this.focusTimeoutId = handleEditorFocus(view);
457
+ }
458
+ if (this.featureFlags.ufo) {
459
+ this.experienceStore = ExperienceStore.getInstance(view);
460
+ this.experienceStore.start(EditorExperience.editSession);
461
+ this.experienceStore.addMetadata(EditorExperience.editSession, {
462
+ reliabilityInterval: RELIABILITY_INTERVAL
463
+ });
464
+ this.reliabilityInterval = window.setInterval(() => {
465
+ var _this$experienceStore11, _this$experienceStore12;
466
+ (_this$experienceStore11 = this.experienceStore) === null || _this$experienceStore11 === void 0 ? void 0 : (_this$experienceStore12 = _this$experienceStore11.success(EditorExperience.editSession)) === null || _this$experienceStore12 === void 0 ? void 0 : _this$experienceStore12.finally(() => {
467
+ var _this$experienceStore13, _this$experienceStore14;
468
+ (_this$experienceStore13 = this.experienceStore) === null || _this$experienceStore13 === void 0 ? void 0 : _this$experienceStore13.start(EditorExperience.editSession);
469
+ (_this$experienceStore14 = this.experienceStore) === null || _this$experienceStore14 === void 0 ? void 0 : _this$experienceStore14.addMetadata(EditorExperience.editSession, {
470
+ reliabilityInterval: RELIABILITY_INTERVAL
471
+ });
472
+ });
473
+ const reliabilityEvent = {
474
+ action: ACTION.UFO_SESSION_COMPLETE,
475
+ actionSubject: ACTION_SUBJECT.EDITOR,
476
+ attributes: {
477
+ interval: RELIABILITY_INTERVAL
478
+ },
479
+ eventType: EVENT_TYPE.OPERATIONAL
480
+ };
481
+ this.dispatchAnalyticsEvent(reliabilityEvent);
482
+ }, RELIABILITY_INTERVAL);
483
+ }
484
+
485
+ // Force React to re-render so consumers get a reference to the editor view
486
+ this.forceUpdate();
487
+ } else if (this.view && !node) {
488
+ // When the appearance is changed, React will call handleEditorViewRef with node === null
489
+ // to destroy the old EditorView, before calling this method again with node === div to
490
+ // create the new EditorView
491
+ this.props.onEditorDestroyed({
492
+ view: this.view,
493
+ config: this.config,
494
+ eventDispatcher: this.eventDispatcher,
495
+ transformer: this.contentTransformer
496
+ });
497
+
498
+ // Allows us to dispatch analytics within the plugin view.destory methods
499
+ const analyticsConnected = this.eventDispatcher.has(analyticsEventKey, this.handleAnalyticsEvent);
500
+ if (!analyticsConnected) {
501
+ this.eventDispatcher.on(analyticsEventKey, this.handleAnalyticsEvent);
502
+ }
503
+ this.view.destroy(); // Destroys the dom node & all node views
504
+
505
+ if (!analyticsConnected) {
506
+ this.eventDispatcher.off(analyticsEventKey, this.handleAnalyticsEvent);
507
+ }
508
+ this.view = undefined;
509
+ }
510
+ });
511
+ _defineProperty(this, "dispatchAnalyticsEvent", payload => {
512
+ if (this.props.allowAnalyticsGASV3 && this.eventDispatcher) {
513
+ const dispatch = createDispatch(this.eventDispatcher);
514
+ dispatch(analyticsEventKey, {
515
+ payload
516
+ });
517
+ }
518
+ });
519
+ _defineProperty(this, "editor", /*#__PURE__*/React.createElement("div", {
520
+ className: getUAPrefix(),
521
+ key: "ProseMirror",
522
+ ref: this.handleEditorViewRef,
523
+ "aria-label": this.props.intl.formatMessage(editorMessages.editorAssistiveLabel),
524
+ role: "textbox"
525
+ }));
526
+ this.eventDispatcher = new EventDispatcher();
527
+ this.dispatch = createDispatch(this.eventDispatcher);
528
+ this.errorReporter = createErrorReporter(_props.editorProps.errorReporterHandler);
529
+ this.transactionTracker = new TransactionTracker();
530
+ this.pluginPerformanceObserver = new PluginPerformanceObserver(report => this.onPluginObservation(report, this.editorState)).withPlugins(() => this.getPluginNames()).withNodeCounts(() => this.countNodes()).withOptions(() => this.transactionTracking).withTransactionTracker(() => this.transactionTracker);
531
+ this.validTransactionCount = 0;
532
+ this.featureFlags = createFeatureFlagsFromProps(this.props.editorProps);
533
+ const featureFlagsEnabled = this.featureFlags ? getEnabledFeatureFlagKeys(this.featureFlags) : [];
534
+
535
+ // START TEMPORARY CODE ED-10584
536
+ if (this.props.createAnalyticsEvent) {
537
+ this.props.createAnalyticsEvent.__queueAnalytics = this.featureFlags.queueAnalytics;
538
+ }
539
+ // END TEMPORARY CODE ED-10584
540
+
541
+ // This needs to be before initialising editorState because
542
+ // we dispatch analytics events in plugin initialisation
543
+ this.eventDispatcher.on(analyticsEventKey, this.handleAnalyticsEvent);
544
+ this.eventDispatcher.on('resetEditorState', this.resetEditorState);
545
+ this.editorState = this.createEditorState({
546
+ props: _props,
547
+ context,
548
+ doc: _props.editorProps.defaultValue,
549
+ // ED-4759: Don't set selection at end for full-page editor - should be at start.
550
+ selectionAtStart: isFullPage(_props.editorProps.appearance)
551
+ });
552
+ this.dispatchAnalyticsEvent({
553
+ action: ACTION.STARTED,
554
+ actionSubject: ACTION_SUBJECT.EDITOR,
555
+ attributes: {
556
+ platform: PLATFORMS.WEB,
557
+ featureFlags: featureFlagsEnabled
558
+ },
559
+ eventType: EVENT_TYPE.UI
560
+ });
561
+ }
562
+ UNSAFE_componentWillReceiveProps(nextProps) {
563
+ // START TEMPORARY CODE ED-10584
564
+ if (nextProps.createAnalyticsEvent && nextProps.createAnalyticsEvent !== this.props.createAnalyticsEvent) {
565
+ const featureFlags = createFeatureFlagsFromProps(nextProps.editorProps);
566
+ nextProps.createAnalyticsEvent.__queueAnalytics = featureFlags.queueAnalytics;
567
+ }
568
+ // END TEMPORARY CODE ED-10584
569
+
570
+ if (this.view && this.props.editorProps.disabled !== nextProps.editorProps.disabled) {
571
+ // Disables the contentEditable attribute of the editor if the editor is disabled
572
+ this.view.setProps({
573
+ editable: _state => !nextProps.editorProps.disabled
574
+ });
575
+ if (!nextProps.editorProps.disabled && nextProps.editorProps.shouldFocus) {
576
+ this.focusTimeoutId = handleEditorFocus(this.view);
577
+ }
578
+ }
579
+ const {
580
+ appearance
581
+ } = this.props.editorProps;
582
+ const {
583
+ appearance: nextAppearance
584
+ } = nextProps.editorProps;
585
+ if (shouldReconfigureState(this.props.editorProps, nextProps.editorProps)) {
586
+ this.reconfigureState(nextProps);
587
+ }
588
+ if (nextAppearance !== appearance) {
589
+ if (nextAppearance === 'full-width' || appearance === 'full-width') {
590
+ this.dispatchAnalyticsEvent({
591
+ action: ACTION.CHANGED_FULL_WIDTH_MODE,
592
+ actionSubject: ACTION_SUBJECT.EDITOR,
593
+ eventType: EVENT_TYPE.TRACK,
594
+ attributes: {
595
+ previousMode: this.formatFullWidthAppearance(appearance),
596
+ newMode: this.formatFullWidthAppearance(nextAppearance)
597
+ }
598
+ });
599
+ }
600
+ }
601
+ if (!this.transactionTracking.enabled) {
602
+ this.pluginPerformanceObserver.disconnect();
603
+ }
604
+ }
605
+ componentDidMount() {
606
+ // Transaction dispatching is already enabled by default prior to
607
+ // mounting, but we reset it here, just in case the editor view
608
+ // instance is ever recycled (mounted again after unmounting) with
609
+ // the same key.
610
+ // Although storing mounted state is an anti-pattern in React,
611
+ // we do so here so that we can intercept and abort asynchronous
612
+ // ProseMirror transactions when a dismount is imminent.
613
+ this.canDispatchTransactions = true;
614
+ if (this.transactionTracking.enabled) {
615
+ this.pluginPerformanceObserver.observe();
616
+ }
617
+ }
618
+
619
+ /**
620
+ * Clean up any non-PM resources when the editor is unmounted
621
+ */
622
+ componentWillUnmount() {
623
+ // We can ignore any transactions from this point onwards.
624
+ // This serves to avoid potential runtime exceptions which could arise
625
+ // from an async dispatched transaction after it's unmounted.
626
+ this.canDispatchTransactions = false;
627
+ clearTimeout(this.focusTimeoutId);
628
+ if (this.reliabilityInterval) {
629
+ clearInterval(this.reliabilityInterval);
630
+ }
631
+ this.pluginPerformanceObserver.disconnect();
632
+ if (this.view) {
633
+ // Destroy the state if the Editor is being unmounted
634
+ const editorState = this.view.state;
635
+ editorState.plugins.forEach(plugin => {
636
+ const state = plugin.getState(editorState);
637
+ if (state && state.destroy) {
638
+ state.destroy();
639
+ }
640
+ });
641
+ }
642
+ this.eventDispatcher.destroy();
643
+ // this.view will be destroyed when React unmounts in handleEditorViewRef
644
+ }
645
+
646
+ // 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
656
+ });
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 : [];
669
+ return this.editorPlugins;
670
+ }
671
+ render() {
672
+ var _this$props$editorPro9, _this$props$editorPro10;
673
+ const renderTracking = (_this$props$editorPro9 = this.props.editorProps.performanceTracking) === null || _this$props$editorPro9 === void 0 ? void 0 : (_this$props$editorPro10 = _this$props$editorPro9.renderTracking) === null || _this$props$editorPro10 === void 0 ? void 0 : _this$props$editorPro10.reactEditorView;
674
+ const renderTrackingEnabled = renderTracking === null || renderTracking === void 0 ? void 0 : renderTracking.enabled;
675
+ const useShallow = renderTracking === null || renderTracking === void 0 ? void 0 : renderTracking.useShallow;
676
+ return /*#__PURE__*/React.createElement(ReactEditorViewContext.Provider, {
677
+ value: {
678
+ editorRef: this.editorRef,
679
+ editorView: this.view
680
+ }
681
+ }, renderTrackingEnabled && /*#__PURE__*/React.createElement(RenderTracking, {
682
+ componentProps: this.props,
683
+ action: ACTION.RE_RENDERED,
684
+ actionSubject: ACTION_SUBJECT.REACT_EDITOR_VIEW,
685
+ handleAnalyticsEvent: this.handleAnalyticsEvent,
686
+ useShallow: useShallow
687
+ }), this.props.render ? this.props.render({
688
+ editor: this.editor,
689
+ view: this.view,
690
+ config: this.config,
691
+ eventDispatcher: this.eventDispatcher,
692
+ transformer: this.contentTransformer,
693
+ dispatchAnalyticsEvent: this.dispatchAnalyticsEvent,
694
+ editorRef: this.editorRef
695
+ }) : this.editor);
696
+ }
697
+ }
698
+ _defineProperty(ReactEditorView, "contextTypes", {
699
+ getAtlaskitAnalyticsEventHandlers: PropTypes.func
700
+ });
701
+ function getUAPrefix() {
702
+ if (browser.chrome) {
703
+ return 'ua-chrome';
704
+ } else if (browser.ie) {
705
+ return 'ua-ie';
706
+ } else if (browser.gecko) {
707
+ return 'ua-firefox';
708
+ } else if (browser.safari) {
709
+ return 'ua-safari';
710
+ }
711
+ return '';
712
+ }