@atlaskit/editor-core 180.0.0 → 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 +74 -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 +23 -22
  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
@@ -5,779 +5,29 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = exports.ReactEditorView = void 0;
8
- exports.shouldReconfigureState = shouldReconfigureState;
9
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
12
8
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
9
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
14
10
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
15
11
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
16
12
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
17
13
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
18
- var _react = _interopRequireDefault(require("react"));
19
- var _propTypes = _interopRequireDefault(require("prop-types"));
20
- var _prosemirrorState = require("prosemirror-state");
21
- var _prosemirrorView = require("prosemirror-view");
14
+ var _ReactEditorViewInternal = require("./ReactEditorViewInternal");
15
+ var _getEditorPlugins = _interopRequireDefault(require("../utils/get-editor-plugins"));
22
16
  var _reactIntlNext = require("react-intl-next");
23
- var _messages = require("./messages");
24
- var _utils = require("@atlaskit/editor-common/utils");
25
- var _ufo = require("@atlaskit/editor-common/ufo");
26
- var _eventDispatcher = require("../event-dispatcher");
27
- var _utils2 = require("../utils");
28
- var _saferTransactions = require("../utils/performance/safer-transactions");
29
- var _RenderTracking = require("../utils/performance/components/RenderTracking");
30
- var _nodes = require("../utils/nodes");
31
- var _createPluginsList = _interopRequireDefault(require("./create-plugins-list"));
32
- var _analytics = require("../plugins/analytics");
33
- var _featureFlagsFromProps = require("./feature-flags-from-props");
34
- var _getEnabledFeatureFlagKeys = require("../plugins/feature-flags-context/get-enabled-feature-flag-keys");
35
- var _createEditor = require("./create-editor");
36
- var _documentLogger = require("../utils/document-logger");
37
- var _isFullPage = require("../utils/is-full-page");
38
- var _measureEnum = _interopRequireDefault(require("../utils/performance/measure-enum"));
39
- var _document = require("../utils/document");
40
- var _createSchema = require("./create-schema");
41
- var _pluginPerformanceObserver = require("../utils/performance/plugin-performance-observer");
42
- var _getParticipantsCount = require("../plugins/collab-edit/get-participants-count");
43
- var _countNodes2 = require("../utils/count-nodes");
44
- var _trackTransactions = require("../utils/performance/track-transactions");
45
- var _consts = require("./consts");
46
- var _contextIdentifier = require("../plugins/base/pm-plugins/context-identifier");
47
- var _ReactEditorViewContext = _interopRequireDefault(require("./ReactEditorViewContext"));
48
- var _api = require("../insert-api/api");
49
- var _api2 = require("../analytics-api/api");
50
- var _api3 = require("../selection-api/api");
51
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
52
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
53
17
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
54
18
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
55
- function handleEditorFocus(view) {
56
- if (view.hasFocus()) {
57
- return;
58
- }
59
- return window.setTimeout(function () {
60
- view.focus();
61
- }, 0);
62
- }
63
- var EMPTY = [];
64
- function shouldReconfigureState(props, nextProps) {
65
- var _props$dangerouslyApp, _props$dangerouslyApp2, _nextProps$dangerousl, _nextProps$dangerousl2;
66
- var prevPlugins = (_props$dangerouslyApp = (_props$dangerouslyApp2 = props.dangerouslyAppendPlugins) === null || _props$dangerouslyApp2 === void 0 ? void 0 : _props$dangerouslyApp2.__plugins) !== null && _props$dangerouslyApp !== void 0 ? _props$dangerouslyApp : EMPTY;
67
- var nextPlugins = (_nextProps$dangerousl = (_nextProps$dangerousl2 = nextProps.dangerouslyAppendPlugins) === null || _nextProps$dangerousl2 === void 0 ? void 0 : _nextProps$dangerousl2.__plugins) !== null && _nextProps$dangerousl !== void 0 ? _nextProps$dangerousl : EMPTY;
68
- if (nextPlugins.length !== prevPlugins.length || prevPlugins.some(function (p) {
69
- return nextPlugins.some(function (n) {
70
- return n.name === p.name && n !== p;
71
- });
72
- })) {
73
- return true;
74
- }
75
- var mobileProperties = props.appearance === 'mobile' ? ['featureFlags', 'quickInsert'] : [];
76
- var properties = ['appearance', 'persistScrollGutter', 'allowUndoRedoButtons', 'placeholder', 'sanitizePrivateContent'].concat(mobileProperties);
77
- return properties.reduce(function (acc, curr) {
78
- return acc || props[curr] !== nextProps[curr];
79
- }, false);
80
- }
81
- var ReactEditorView = /*#__PURE__*/function (_React$Component) {
82
- (0, _inherits2.default)(ReactEditorView, _React$Component);
19
+ var ReactEditorView = /*#__PURE__*/function (_BaseReactEditorView) {
20
+ (0, _inherits2.default)(ReactEditorView, _BaseReactEditorView);
83
21
  var _super = _createSuper(ReactEditorView);
84
- function ReactEditorView(_props, context) {
85
- var _this;
22
+ function ReactEditorView() {
86
23
  (0, _classCallCheck2.default)(this, ReactEditorView);
87
- _this = _super.call(this, _props, context);
88
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "editorRef", /*#__PURE__*/_react.default.createRef());
89
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "canDispatchTransactions", true);
90
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onPluginObservation", function (report, editorState) {
91
- _this.dispatchAnalyticsEvent({
92
- action: _analytics.ACTION.TRANSACTION_DISPATCHED,
93
- actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
94
- eventType: _analytics.EVENT_TYPE.OPERATIONAL,
95
- attributes: {
96
- report: report,
97
- participants: (0, _getParticipantsCount.getParticipantsCount)(editorState)
98
- }
99
- });
100
- });
101
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "formatFullWidthAppearance", function (appearance) {
102
- if (appearance === 'full-width') {
103
- return _analytics.FULL_WIDTH_MODE.FULL_WIDTH;
104
- }
105
- return _analytics.FULL_WIDTH_MODE.FIXED_WIDTH;
106
- });
107
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "resetEditorState", function (_ref) {
108
- var _this$props$editorPro, _this$props$editorPro2;
109
- var doc = _ref.doc,
110
- shouldScrollToBottom = _ref.shouldScrollToBottom;
111
- if (!_this.view) {
112
- return;
113
- }
114
-
115
- // We cannot currently guarentee when all the portals will have re-rendered during a reconfigure
116
- // so we blur here to stop ProseMirror from trying to apply selection to detached nodes or
117
- // nodes that haven't been re-rendered to the document yet.
118
- _this.blur();
119
- _this.featureFlags = (0, _featureFlagsFromProps.createFeatureFlagsFromProps)(_this.props.editorProps);
120
- _this.editorState = _this.createEditorState({
121
- props: _this.props,
122
- context: _this.context,
123
- doc: doc,
124
- resetting: true,
125
- selectionAtStart: !shouldScrollToBottom
126
- });
127
- _this.view.updateState(_this.editorState);
128
- (_this$props$editorPro = (_this$props$editorPro2 = _this.props.editorProps).onChange) === null || _this$props$editorPro === void 0 ? void 0 : _this$props$editorPro.call(_this$props$editorPro2, _this.view, {
129
- source: 'local'
130
- });
131
- });
132
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "blur", function () {
133
- if (!_this.view) {
134
- return;
135
- }
136
- if (_this.view.dom instanceof HTMLElement && _this.view.hasFocus()) {
137
- _this.view.dom.blur();
138
- }
139
-
140
- // The selectionToDOM method uses the document selection to determine currently selected node
141
- // We need to mimic blurring this as it seems doing the above is not enough.
142
- // @ts-expect-error
143
- var sel = _this.view.root.getSelection();
144
- if (sel) {
145
- sel.removeAllRanges();
146
- }
147
- });
148
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "reconfigureState", function (props) {
149
- if (!_this.view) {
150
- return;
151
- }
152
-
153
- // We cannot currently guarentee when all the portals will have re-rendered during a reconfigure
154
- // so we blur here to stop ProseMirror from trying to apply selection to detached nodes or
155
- // nodes that haven't been re-rendered to the document yet.
156
- _this.blur();
157
- var editorPlugins = _this.getPlugins(props.editorProps, _this.props.editorProps, _this.props.createAnalyticsEvent);
158
- _this.config = (0, _createEditor.processPluginsList)(editorPlugins);
159
- var state = _this.editorState;
160
- var plugins = (0, _createEditor.createPMPlugins)({
161
- schema: state.schema,
162
- dispatch: _this.dispatch,
163
- errorReporter: _this.errorReporter,
164
- editorConfig: _this.config,
165
- eventDispatcher: _this.eventDispatcher,
166
- providerFactory: props.providerFactory,
167
- portalProviderAPI: props.portalProviderAPI,
168
- reactContext: function reactContext() {
169
- return _this.context;
170
- },
171
- dispatchAnalyticsEvent: _this.dispatchAnalyticsEvent,
172
- performanceTracking: props.editorProps.performanceTracking,
173
- transactionTracker: _this.transactionTracker,
174
- featureFlags: (0, _featureFlagsFromProps.createFeatureFlagsFromProps)(props.editorProps),
175
- getIntl: function getIntl() {
176
- return _this.props.intl;
177
- }
178
- });
179
- var newState = state.reconfigure({
180
- plugins: plugins
181
- });
182
-
183
- // need to update the state first so when the view builds the nodeviews it is
184
- // using the latest plugins
185
- _this.view.updateState(newState);
186
- return _this.view.update(_objectSpread(_objectSpread({}, _this.view.props), {}, {
187
- state: newState
188
- }));
189
- });
190
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleAnalyticsEvent", function (payload) {
191
- if (!_this.props.allowAnalyticsGASV3) {
192
- return;
193
- }
194
- (0, _analytics.fireAnalyticsEvent)(_this.props.createAnalyticsEvent)(payload);
195
- });
196
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "editorPlugins", []);
197
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "createEditorState", function (options) {
198
- var schema;
199
- if (_this.view) {
200
- if (options.resetting) {
201
- /**
202
- * ReactEditorView currently does NOT handle dynamic schema,
203
- * We are reusing the existing schema, and rely on #reconfigureState
204
- * to update `this.config`
205
- */
206
- schema = _this.view.state.schema;
207
- } else {
208
- /**
209
- * There's presently a number of issues with changing the schema of a
210
- * editor inflight. A significant issue is that we lose the ability
211
- * to keep track of a user's history as the internal plugin state
212
- * keeps a list of Steps to undo/redo (which are tied to the schema).
213
- * Without a good way to do work around this, we prevent this for now.
214
- */
215
- // eslint-disable-next-line no-console
216
- console.warn('The editor does not support changing the schema dynamically.');
217
- return _this.editorState;
218
- }
219
- } else {
220
- _this.config = (0, _createEditor.processPluginsList)(_this.getPlugins(options.props.editorProps, undefined, options.props.createAnalyticsEvent));
221
- schema = (0, _createSchema.createSchema)(_this.config);
222
- }
223
- var contentTransformerProvider = options.props.editorProps.contentTransformerProvider;
224
- var plugins = (0, _createEditor.createPMPlugins)({
225
- schema: schema,
226
- dispatch: _this.dispatch,
227
- errorReporter: _this.errorReporter,
228
- editorConfig: _this.config,
229
- eventDispatcher: _this.eventDispatcher,
230
- providerFactory: options.props.providerFactory,
231
- portalProviderAPI: _this.props.portalProviderAPI,
232
- reactContext: function reactContext() {
233
- return options.context;
234
- },
235
- dispatchAnalyticsEvent: _this.dispatchAnalyticsEvent,
236
- performanceTracking: _this.props.editorProps.performanceTracking,
237
- transactionTracker: _this.transactionTracker,
238
- featureFlags: _this.featureFlags,
239
- getIntl: function getIntl() {
240
- return _this.props.intl;
241
- }
242
- });
243
- _this.contentTransformer = contentTransformerProvider ? contentTransformerProvider(schema) : undefined;
244
- var doc;
245
- if (options.doc) {
246
- doc = (0, _utils2.processRawValue)(schema, options.doc, options.props.providerFactory, options.props.editorProps.sanitizePrivateContent, _this.contentTransformer, _this.dispatchAnalyticsEvent);
247
- }
248
- var selection;
249
- if (doc) {
250
- selection = options.selectionAtStart ? _prosemirrorState.Selection.atStart(doc) : _prosemirrorState.Selection.atEnd(doc);
251
- }
252
- // Workaround for ED-3507: When media node is the last element, scrollIntoView throws an error
253
- var patchedSelection = selection ? _prosemirrorState.Selection.findFrom(selection.$head, -1, true) || undefined : undefined;
254
- return _prosemirrorState.EditorState.create({
255
- schema: schema,
256
- plugins: plugins,
257
- doc: doc,
258
- selection: patchedSelection
259
- });
260
- });
261
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onEditorViewStateUpdated", function (_ref2) {
262
- var originalTransaction = _ref2.originalTransaction,
263
- transactions = _ref2.transactions,
264
- oldEditorState = _ref2.oldEditorState,
265
- newEditorState = _ref2.newEditorState;
266
- var trackinEnabled = _this.transactionTracking.enabled;
267
- _this.config.onEditorViewStateUpdatedCallbacks.forEach(function (entry) {
268
- trackinEnabled && (0, _utils.startMeasure)("\uD83E\uDD89 ".concat(entry.pluginName, "::onEditorViewStateUpdated"));
269
- entry.callback({
270
- originalTransaction: originalTransaction,
271
- transactions: transactions,
272
- oldEditorState: oldEditorState,
273
- newEditorState: newEditorState
274
- });
275
- trackinEnabled && (0, _utils.stopMeasure)("\uD83E\uDD89 ".concat(entry.pluginName, "::onEditorViewStateUpdated"));
276
- });
277
- });
278
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "trackValidTransactions", function () {
279
- var editorProps = _this.props.editorProps;
280
- if (editorProps !== null && editorProps !== void 0 && editorProps.trackValidTransactions) {
281
- _this.validTransactionCount++;
282
- var samplingRate = (0, _typeof2.default)(editorProps.trackValidTransactions) === 'object' && editorProps.trackValidTransactions.samplingRate || _consts.DEFAULT_SAMPLING_RATE_VALID_TRANSACTIONS;
283
- if (_this.validTransactionCount >= samplingRate) {
284
- _this.dispatchAnalyticsEvent({
285
- action: _analytics.ACTION.DISPATCHED_VALID_TRANSACTION,
286
- actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
287
- eventType: _analytics.EVENT_TYPE.OPERATIONAL
288
- });
289
- _this.validTransactionCount = 0;
290
- }
291
- }
292
- });
293
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "dispatchTransaction", function (unsafeTransaction) {
294
- if (!_this.view) {
295
- return;
296
- }
297
- _this.transactionTracker.bumpDispatchCounter(_this.transactionTracking);
298
- var _this$transactionTrac = _this.transactionTracker.getMeasureHelpers(_this.transactionTracking),
299
- startMeasure = _this$transactionTrac.startMeasure,
300
- stopMeasure = _this$transactionTrac.stopMeasure;
301
- startMeasure(_trackTransactions.EVENT_NAME_DISPATCH_TRANSACTION);
302
- if (_this.transactionTracker.shouldTrackTransaction(_this.transactionTracking)) {
303
- var _this$experienceStore;
304
- (_this$experienceStore = _this.experienceStore) === null || _this$experienceStore === void 0 ? void 0 : _this$experienceStore.start(_ufo.EditorExperience.interaction);
305
- }
306
- var nodes = (0, _nodes.findChangedNodesFromTransaction)(unsafeTransaction);
307
- var changedNodesValid = (0, _nodes.validateNodes)(nodes);
308
- var transaction = _this.featureFlags.saferDispatchedTransactions || _this.featureFlags.saferDispatchedTransactionsAnalyticsOnly ? new Proxy(unsafeTransaction, (0, _saferTransactions.freezeUnsafeTransactionProperties)({
309
- dispatchAnalyticsEvent: _this.dispatchAnalyticsEvent,
310
- pluginKey: 'unknown-reacteditorview',
311
- analyticsOnly: _this.featureFlags.saferDispatchedTransactionsAnalyticsOnly
312
- })) : unsafeTransaction;
313
- if (changedNodesValid) {
314
- var oldEditorState = _this.view.state;
315
-
316
- // go ahead and update the state now we know the transaction is good
317
- startMeasure(_trackTransactions.EVENT_NAME_STATE_APPLY);
318
- var _this$view$state$appl = _this.view.state.applyTransaction(transaction),
319
- editorState = _this$view$state$appl.state,
320
- transactions = _this$view$state$appl.transactions;
321
- stopMeasure(_trackTransactions.EVENT_NAME_STATE_APPLY, function (duration, startTime) {
322
- var _this$experienceStore2;
323
- (_this$experienceStore2 = _this.experienceStore) === null || _this$experienceStore2 === void 0 ? void 0 : _this$experienceStore2.mark(_ufo.EditorExperience.interaction, 'stateApply', startTime + duration);
324
- });
325
- _this.trackValidTransactions();
326
- if (editorState === oldEditorState) {
327
- return;
328
- }
329
- startMeasure(_trackTransactions.EVENT_NAME_UPDATE_STATE);
330
- _this.view.updateState(editorState);
331
- stopMeasure(_trackTransactions.EVENT_NAME_UPDATE_STATE, function (duration, startTime) {
332
- var _this$experienceStore3;
333
- (_this$experienceStore3 = _this.experienceStore) === null || _this$experienceStore3 === void 0 ? void 0 : _this$experienceStore3.mark(_ufo.EditorExperience.interaction, 'viewUpdateState', startTime + duration);
334
- });
335
- startMeasure(_trackTransactions.EVENT_NAME_VIEW_STATE_UPDATED);
336
- _this.onEditorViewStateUpdated({
337
- originalTransaction: transaction,
338
- transactions: transactions,
339
- oldEditorState: oldEditorState,
340
- newEditorState: editorState
341
- });
342
- stopMeasure(_trackTransactions.EVENT_NAME_VIEW_STATE_UPDATED, function (duration, startTime) {
343
- var _this$experienceStore4;
344
- (_this$experienceStore4 = _this.experienceStore) === null || _this$experienceStore4 === void 0 ? void 0 : _this$experienceStore4.mark(_ufo.EditorExperience.interaction, 'onEditorViewStateUpdated', startTime + duration);
345
- });
346
- if (_this.props.editorProps.onChange && transaction.docChanged) {
347
- var source = transaction.getMeta('isRemote') ? 'remote' : 'local';
348
- startMeasure(_trackTransactions.EVENT_NAME_ON_CHANGE);
349
- _this.props.editorProps.onChange(_this.view, {
350
- source: source
351
- });
352
- stopMeasure(_trackTransactions.EVENT_NAME_ON_CHANGE, function (duration, startTime) {
353
- var _this$experienceStore5, _this$props$editorPro3, _this$props$editorPro4;
354
- (_this$experienceStore5 = _this.experienceStore) === null || _this$experienceStore5 === void 0 ? void 0 : _this$experienceStore5.mark(_ufo.EditorExperience.interaction, 'onChange', startTime + duration);
355
- if (((_this$props$editorPro3 = _this.props.editorProps.performanceTracking) === null || _this$props$editorPro3 === void 0 ? void 0 : (_this$props$editorPro4 = _this$props$editorPro3.onChangeCallbackTracking) === null || _this$props$editorPro4 === void 0 ? void 0 : _this$props$editorPro4.enabled) !== true) {
356
- return;
357
- }
358
- _this.dispatchAnalyticsEvent({
359
- action: _analytics.ACTION.ON_CHANGE_CALLBACK,
360
- actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
361
- eventType: _analytics.EVENT_TYPE.OPERATIONAL,
362
- attributes: {
363
- duration: duration,
364
- startTime: startTime
365
- }
366
- });
367
- });
368
- }
369
- _this.editorState = editorState;
370
- stopMeasure(_trackTransactions.EVENT_NAME_DISPATCH_TRANSACTION, function (duration, startTime) {
371
- var _this$experienceStore6, _this$experienceStore7;
372
- (_this$experienceStore6 = _this.experienceStore) === null || _this$experienceStore6 === void 0 ? void 0 : _this$experienceStore6.mark(_ufo.EditorExperience.interaction, 'dispatchTransaction', startTime + duration);
373
- (_this$experienceStore7 = _this.experienceStore) === null || _this$experienceStore7 === void 0 ? void 0 : _this$experienceStore7.success(_ufo.EditorExperience.interaction);
374
- });
375
- } else {
376
- var _this$experienceStore8;
377
- var invalidNodes = nodes.filter(function (node) {
378
- return !(0, _nodes.validNode)(node);
379
- }).map(function (node) {
380
- return (0, _documentLogger.getDocStructure)(node, {
381
- compact: true
382
- });
383
- });
384
- _this.dispatchAnalyticsEvent({
385
- action: _analytics.ACTION.DISPATCHED_INVALID_TRANSACTION,
386
- actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
387
- eventType: _analytics.EVENT_TYPE.OPERATIONAL,
388
- attributes: {
389
- analyticsEventPayloads: (0, _analytics.getAnalyticsEventsFromTransaction)(transaction),
390
- invalidNodes: invalidNodes
391
- }
392
- });
393
- (_this$experienceStore8 = _this.experienceStore) === null || _this$experienceStore8 === void 0 ? void 0 : _this$experienceStore8.fail(_ufo.EditorExperience.interaction, {
394
- reason: 'invalid transaction',
395
- invalidNodes: invalidNodes.toString()
396
- });
397
- }
398
- });
399
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getDirectEditorProps", function (state) {
400
- return {
401
- state: state || _this.editorState,
402
- dispatchTransaction: function dispatchTransaction(tr) {
403
- // Block stale transactions:
404
- // Prevent runtime exeptions from async transactions that would attempt to
405
- // update the DOM after React has unmounted the Editor.
406
- if (_this.canDispatchTransactions) {
407
- _this.dispatchTransaction(tr);
408
- }
409
- },
410
- // Disables the contentEditable attribute of the editor if the editor is disabled
411
- editable: function editable(_state) {
412
- return !_this.props.editorProps.disabled;
413
- },
414
- attributes: {
415
- 'data-gramm': 'false'
416
- }
417
- };
418
- });
419
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "createEditorView", function (node) {
420
- (0, _utils.measureRender)(_measureEnum.default.PROSEMIRROR_RENDERED, function (_ref3) {
421
- var _this$props$editorPro5, _this$props$editorPro6, _proseMirrorRenderedT, _proseMirrorRenderedT2;
422
- var duration = _ref3.duration,
423
- startTime = _ref3.startTime,
424
- distortedDuration = _ref3.distortedDuration;
425
- var proseMirrorRenderedTracking = (_this$props$editorPro5 = _this.props.editorProps) === null || _this$props$editorPro5 === void 0 ? void 0 : (_this$props$editorPro6 = _this$props$editorPro5.performanceTracking) === null || _this$props$editorPro6 === void 0 ? void 0 : _this$props$editorPro6.proseMirrorRenderedTracking;
426
- var forceSeverityTracking = typeof proseMirrorRenderedTracking === 'undefined' && (0, _utils.shouldForceTracking)();
427
- _this.proseMirrorRenderedSeverity = !!forceSeverityTracking || proseMirrorRenderedTracking !== null && proseMirrorRenderedTracking !== void 0 && proseMirrorRenderedTracking.trackSeverity ? (0, _utils.getAnalyticsEventSeverity)(duration, (_proseMirrorRenderedT = proseMirrorRenderedTracking === null || proseMirrorRenderedTracking === void 0 ? void 0 : proseMirrorRenderedTracking.severityNormalThreshold) !== null && _proseMirrorRenderedT !== void 0 ? _proseMirrorRenderedT : _consts.PROSEMIRROR_RENDERED_NORMAL_SEVERITY_THRESHOLD, (_proseMirrorRenderedT2 = proseMirrorRenderedTracking === null || proseMirrorRenderedTracking === void 0 ? void 0 : proseMirrorRenderedTracking.severityDegradedThreshold) !== null && _proseMirrorRenderedT2 !== void 0 ? _proseMirrorRenderedT2 : _consts.PROSEMIRROR_RENDERED_DEGRADED_SEVERITY_THRESHOLD) : undefined;
428
- if (_this.view) {
429
- var _getContextIdentifier, _this$experienceStore10;
430
- var nodes = (0, _document.getNodesCount)(_this.view.state.doc);
431
- var ttfb = (0, _utils.getResponseEndTime)();
432
- _this.dispatchAnalyticsEvent({
433
- action: _analytics.ACTION.PROSEMIRROR_RENDERED,
434
- actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
435
- attributes: {
436
- duration: duration,
437
- startTime: startTime,
438
- nodes: nodes,
439
- ttfb: ttfb,
440
- severity: _this.proseMirrorRenderedSeverity,
441
- objectId: (_getContextIdentifier = (0, _contextIdentifier.getContextIdentifier)(_this.editorState)) === null || _getContextIdentifier === void 0 ? void 0 : _getContextIdentifier.objectId,
442
- distortedDuration: distortedDuration
443
- },
444
- eventType: _analytics.EVENT_TYPE.OPERATIONAL
445
- });
446
- if (!distortedDuration) {
447
- var _this$experienceStore9;
448
- (_this$experienceStore9 = _this.experienceStore) === null || _this$experienceStore9 === void 0 ? void 0 : _this$experienceStore9.mark(_ufo.EditorExperience.loadEditor, _analytics.ACTION.PROSEMIRROR_RENDERED, startTime + duration);
449
- }
450
- (_this$experienceStore10 = _this.experienceStore) === null || _this$experienceStore10 === void 0 ? void 0 : _this$experienceStore10.addMetadata(_ufo.EditorExperience.loadEditor, {
451
- nodes: nodes,
452
- ttfb: ttfb
453
- });
454
- }
455
- });
456
-
457
- // Creates the editor-view from this.editorState. If an editor has been mounted
458
- // previously, this will contain the previous state of the editor.
459
- _this.view = new _prosemirrorView.EditorView({
460
- mount: node
461
- }, _this.getDirectEditorProps());
462
- });
463
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleEditorViewRef", function (node) {
464
- if (!_this.view && node) {
465
- _this.createEditorView(node);
466
- var view = _this.view;
467
- _this.props.onEditorCreated({
468
- view: view,
469
- config: _this.config,
470
- eventDispatcher: _this.eventDispatcher,
471
- transformer: _this.contentTransformer
472
- });
473
- if (_this.props.editorProps.shouldFocus && view.props.editable && view.props.editable(view.state)) {
474
- _this.focusTimeoutId = handleEditorFocus(view);
475
- }
476
- if (_this.featureFlags.ufo) {
477
- _this.experienceStore = _ufo.ExperienceStore.getInstance(view);
478
- _this.experienceStore.start(_ufo.EditorExperience.editSession);
479
- _this.experienceStore.addMetadata(_ufo.EditorExperience.editSession, {
480
- reliabilityInterval: _ufo.RELIABILITY_INTERVAL
481
- });
482
- _this.reliabilityInterval = window.setInterval(function () {
483
- var _this$experienceStore11, _this$experienceStore12;
484
- (_this$experienceStore11 = _this.experienceStore) === null || _this$experienceStore11 === void 0 ? void 0 : (_this$experienceStore12 = _this$experienceStore11.success(_ufo.EditorExperience.editSession)) === null || _this$experienceStore12 === void 0 ? void 0 : _this$experienceStore12.finally(function () {
485
- var _this$experienceStore13, _this$experienceStore14;
486
- (_this$experienceStore13 = _this.experienceStore) === null || _this$experienceStore13 === void 0 ? void 0 : _this$experienceStore13.start(_ufo.EditorExperience.editSession);
487
- (_this$experienceStore14 = _this.experienceStore) === null || _this$experienceStore14 === void 0 ? void 0 : _this$experienceStore14.addMetadata(_ufo.EditorExperience.editSession, {
488
- reliabilityInterval: _ufo.RELIABILITY_INTERVAL
489
- });
490
- });
491
- var reliabilityEvent = {
492
- action: _analytics.ACTION.UFO_SESSION_COMPLETE,
493
- actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
494
- attributes: {
495
- interval: _ufo.RELIABILITY_INTERVAL
496
- },
497
- eventType: _analytics.EVENT_TYPE.OPERATIONAL
498
- };
499
- _this.dispatchAnalyticsEvent(reliabilityEvent);
500
- }, _ufo.RELIABILITY_INTERVAL);
501
- }
502
-
503
- // Force React to re-render so consumers get a reference to the editor view
504
- _this.forceUpdate();
505
- } else if (_this.view && !node) {
506
- // When the appearance is changed, React will call handleEditorViewRef with node === null
507
- // to destroy the old EditorView, before calling this method again with node === div to
508
- // create the new EditorView
509
- _this.props.onEditorDestroyed({
510
- view: _this.view,
511
- config: _this.config,
512
- eventDispatcher: _this.eventDispatcher,
513
- transformer: _this.contentTransformer
514
- });
515
-
516
- // Allows us to dispatch analytics within the plugin view.destory methods
517
- var analyticsConnected = _this.eventDispatcher.has(_utils.analyticsEventKey, _this.handleAnalyticsEvent);
518
- if (!analyticsConnected) {
519
- _this.eventDispatcher.on(_utils.analyticsEventKey, _this.handleAnalyticsEvent);
520
- }
521
- _this.view.destroy(); // Destroys the dom node & all node views
522
-
523
- if (!analyticsConnected) {
524
- _this.eventDispatcher.off(_utils.analyticsEventKey, _this.handleAnalyticsEvent);
525
- }
526
- _this.view = undefined;
527
- }
528
- });
529
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "dispatchAnalyticsEvent", function (payload) {
530
- if (_this.props.allowAnalyticsGASV3 && _this.eventDispatcher) {
531
- var dispatch = (0, _eventDispatcher.createDispatch)(_this.eventDispatcher);
532
- dispatch(_utils.analyticsEventKey, {
533
- payload: payload
534
- });
535
- }
536
- });
537
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "editor", /*#__PURE__*/_react.default.createElement("div", {
538
- className: getUAPrefix(),
539
- key: "ProseMirror",
540
- ref: _this.handleEditorViewRef,
541
- "aria-label": _this.props.intl.formatMessage(_messages.editorMessages.editorAssistiveLabel),
542
- role: "textbox"
543
- }));
544
- _this.eventDispatcher = new _eventDispatcher.EventDispatcher();
545
- _this.dispatch = (0, _eventDispatcher.createDispatch)(_this.eventDispatcher);
546
- _this.errorReporter = (0, _createEditor.createErrorReporter)(_props.editorProps.errorReporterHandler);
547
- _this.transactionTracker = new _trackTransactions.TransactionTracker();
548
- _this.pluginPerformanceObserver = new _pluginPerformanceObserver.PluginPerformanceObserver(function (report) {
549
- return _this.onPluginObservation(report, _this.editorState);
550
- }).withPlugins(function () {
551
- return _this.getPluginNames();
552
- }).withNodeCounts(function () {
553
- return _this.countNodes();
554
- }).withOptions(function () {
555
- return _this.transactionTracking;
556
- }).withTransactionTracker(function () {
557
- return _this.transactionTracker;
558
- });
559
- _this.validTransactionCount = 0;
560
- _this.featureFlags = (0, _featureFlagsFromProps.createFeatureFlagsFromProps)(_this.props.editorProps);
561
- var featureFlagsEnabled = _this.featureFlags ? (0, _getEnabledFeatureFlagKeys.getEnabledFeatureFlagKeys)(_this.featureFlags) : [];
562
-
563
- // START TEMPORARY CODE ED-10584
564
- if (_this.props.createAnalyticsEvent) {
565
- _this.props.createAnalyticsEvent.__queueAnalytics = _this.featureFlags.queueAnalytics;
566
- }
567
- // END TEMPORARY CODE ED-10584
568
-
569
- // This needs to be before initialising editorState because
570
- // we dispatch analytics events in plugin initialisation
571
- _this.eventDispatcher.on(_utils.analyticsEventKey, _this.handleAnalyticsEvent);
572
- _this.eventDispatcher.on('resetEditorState', _this.resetEditorState);
573
- _this.editorState = _this.createEditorState({
574
- props: _props,
575
- context: context,
576
- doc: _props.editorProps.defaultValue,
577
- // ED-4759: Don't set selection at end for full-page editor - should be at start.
578
- selectionAtStart: (0, _isFullPage.isFullPage)(_props.editorProps.appearance)
579
- });
580
- _this.dispatchAnalyticsEvent({
581
- action: _analytics.ACTION.STARTED,
582
- actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
583
- attributes: {
584
- platform: _analytics.PLATFORMS.WEB,
585
- featureFlags: featureFlagsEnabled
586
- },
587
- eventType: _analytics.EVENT_TYPE.UI
588
- });
589
- return _this;
24
+ return _super.apply(this, arguments);
590
25
  }
591
- (0, _createClass2.default)(ReactEditorView, [{
592
- key: "transactionTracking",
593
- get:
594
- // ProseMirror is instantiated prior to the initial React render cycle,
595
- // so we allow transactions by default, to avoid discarding the initial one.
596
-
597
- function get() {
598
- var _this$props$editorPro7, _this$props$editorPro8;
599
- return (_this$props$editorPro7 = (_this$props$editorPro8 = this.props.editorProps.performanceTracking) === null || _this$props$editorPro8 === void 0 ? void 0 : _this$props$editorPro8.transactionTracking) !== null && _this$props$editorPro7 !== void 0 ? _this$props$editorPro7 : {
600
- enabled: false
601
- };
602
- }
603
- }, {
604
- key: "getPluginNames",
605
- value: function getPluginNames() {
606
- return this.editorState.plugins.map(function (p) {
607
- return p.key;
608
- });
609
- }
610
- }, {
611
- key: "countNodes",
612
- value: function countNodes() {
613
- return (0, _countNodes2.countNodes)(this.editorState);
614
- }
615
- }, {
616
- key: "UNSAFE_componentWillReceiveProps",
617
- value: function UNSAFE_componentWillReceiveProps(nextProps) {
618
- // START TEMPORARY CODE ED-10584
619
- if (nextProps.createAnalyticsEvent && nextProps.createAnalyticsEvent !== this.props.createAnalyticsEvent) {
620
- var featureFlags = (0, _featureFlagsFromProps.createFeatureFlagsFromProps)(nextProps.editorProps);
621
- nextProps.createAnalyticsEvent.__queueAnalytics = featureFlags.queueAnalytics;
622
- }
623
- // END TEMPORARY CODE ED-10584
624
-
625
- if (this.view && this.props.editorProps.disabled !== nextProps.editorProps.disabled) {
626
- // Disables the contentEditable attribute of the editor if the editor is disabled
627
- this.view.setProps({
628
- editable: function editable(_state) {
629
- return !nextProps.editorProps.disabled;
630
- }
631
- });
632
- if (!nextProps.editorProps.disabled && nextProps.editorProps.shouldFocus) {
633
- this.focusTimeoutId = handleEditorFocus(this.view);
634
- }
635
- }
636
- var appearance = this.props.editorProps.appearance;
637
- var nextAppearance = nextProps.editorProps.appearance;
638
- if (shouldReconfigureState(this.props.editorProps, nextProps.editorProps)) {
639
- this.reconfigureState(nextProps);
640
- }
641
- if (nextAppearance !== appearance) {
642
- if (nextAppearance === 'full-width' || appearance === 'full-width') {
643
- this.dispatchAnalyticsEvent({
644
- action: _analytics.ACTION.CHANGED_FULL_WIDTH_MODE,
645
- actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
646
- eventType: _analytics.EVENT_TYPE.TRACK,
647
- attributes: {
648
- previousMode: this.formatFullWidthAppearance(appearance),
649
- newMode: this.formatFullWidthAppearance(nextAppearance)
650
- }
651
- });
652
- }
653
- }
654
- if (!this.transactionTracking.enabled) {
655
- this.pluginPerformanceObserver.disconnect();
656
- }
657
- }
658
- }, {
659
- key: "componentDidMount",
660
- value: function componentDidMount() {
661
- // Transaction dispatching is already enabled by default prior to
662
- // mounting, but we reset it here, just in case the editor view
663
- // instance is ever recycled (mounted again after unmounting) with
664
- // the same key.
665
- // Although storing mounted state is an anti-pattern in React,
666
- // we do so here so that we can intercept and abort asynchronous
667
- // ProseMirror transactions when a dismount is imminent.
668
- this.canDispatchTransactions = true;
669
- if (this.transactionTracking.enabled) {
670
- this.pluginPerformanceObserver.observe();
671
- }
672
- }
673
-
674
- /**
675
- * Clean up any non-PM resources when the editor is unmounted
676
- */
677
- }, {
678
- key: "componentWillUnmount",
679
- value: function componentWillUnmount() {
680
- // We can ignore any transactions from this point onwards.
681
- // This serves to avoid potential runtime exceptions which could arise
682
- // from an async dispatched transaction after it's unmounted.
683
- this.canDispatchTransactions = false;
684
- clearTimeout(this.focusTimeoutId);
685
- if (this.reliabilityInterval) {
686
- clearInterval(this.reliabilityInterval);
687
- }
688
- this.pluginPerformanceObserver.disconnect();
689
- if (this.view) {
690
- // Destroy the state if the Editor is being unmounted
691
- var editorState = this.view.state;
692
- editorState.plugins.forEach(function (plugin) {
693
- var state = plugin.getState(editorState);
694
- if (state && state.destroy) {
695
- state.destroy();
696
- }
697
- });
698
- }
699
- this.eventDispatcher.destroy();
700
- // this.view will be destroyed when React unmounts in handleEditorViewRef
701
- }
702
- }, {
703
- key: "getPlugins",
704
- value:
705
- // Helper to allow tests to inject plugins directly
706
- function getPlugins(editorProps, prevEditorProps, createAnalyticsEvent) {
707
- var _editorProps$dangerou,
708
- _editorProps$dangerou2,
709
- _this2 = this;
710
- var editorPlugins = (_editorProps$dangerou = (_editorProps$dangerou2 = editorProps.dangerouslyAppendPlugins) === null || _editorProps$dangerou2 === void 0 ? void 0 : _editorProps$dangerou2.__plugins) !== null && _editorProps$dangerou !== void 0 ? _editorProps$dangerou : [];
711
- var insertNodeAPI = (0, _api.createInsertNodeAPI)({
712
- getEditorView: function getEditorView() {
713
- return _this2.view;
714
- },
715
- getEditorPlugins: function getEditorPlugins() {
716
- return _this2.editorPlugins;
717
- }
718
- });
719
- var editorAnalyticsAPI = (0, _api2.createEditorAnalyticsAPI)({
720
- getEditorView: function getEditorView() {
721
- return _this2.view;
722
- },
723
- getCreateUIAnalyticsEvent: function getCreateUIAnalyticsEvent() {
724
- return createAnalyticsEvent;
725
- }
726
- });
727
- var editorSelectionAPI = (0, _api3.createEditorSelectionAPI)();
728
- var builtinPlugins = (0, _createPluginsList.default)(editorProps, prevEditorProps, createAnalyticsEvent, insertNodeAPI, editorAnalyticsAPI, editorSelectionAPI);
729
- if (editorPlugins && editorPlugins.length > 0) {
730
- builtinPlugins.push.apply(builtinPlugins, (0, _toConsumableArray2.default)(editorPlugins));
731
- }
732
- this.editorPlugins = builtinPlugins;
733
- return builtinPlugins;
734
- }
735
- }, {
736
- key: "render",
737
- value: function render() {
738
- var _this$props$editorPro9, _this$props$editorPro10;
739
- var 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;
740
- var renderTrackingEnabled = renderTracking === null || renderTracking === void 0 ? void 0 : renderTracking.enabled;
741
- var useShallow = renderTracking === null || renderTracking === void 0 ? void 0 : renderTracking.useShallow;
742
- return /*#__PURE__*/_react.default.createElement(_ReactEditorViewContext.default.Provider, {
743
- value: {
744
- editorRef: this.editorRef,
745
- editorView: this.view
746
- }
747
- }, renderTrackingEnabled && /*#__PURE__*/_react.default.createElement(_RenderTracking.RenderTracking, {
748
- componentProps: this.props,
749
- action: _analytics.ACTION.RE_RENDERED,
750
- actionSubject: _analytics.ACTION_SUBJECT.REACT_EDITOR_VIEW,
751
- handleAnalyticsEvent: this.handleAnalyticsEvent,
752
- useShallow: useShallow
753
- }), this.props.render ? this.props.render({
754
- editor: this.editor,
755
- view: this.view,
756
- config: this.config,
757
- eventDispatcher: this.eventDispatcher,
758
- transformer: this.contentTransformer,
759
- dispatchAnalyticsEvent: this.dispatchAnalyticsEvent,
760
- editorRef: this.editorRef
761
- }) : this.editor);
762
- }
763
- }]);
764
- return ReactEditorView;
765
- }(_react.default.Component);
26
+ return (0, _createClass2.default)(ReactEditorView);
27
+ }(_ReactEditorViewInternal.ReactEditorView);
766
28
  exports.ReactEditorView = ReactEditorView;
767
- (0, _defineProperty2.default)(ReactEditorView, "contextTypes", {
768
- getAtlaskitAnalyticsEventHandlers: _propTypes.default.func
29
+ (0, _defineProperty2.default)(ReactEditorView, "defaultProps", {
30
+ getEditorPlugins: _getEditorPlugins.default
769
31
  });
770
32
  var _default = (0, _reactIntlNext.injectIntl)(ReactEditorView);
771
- exports.default = _default;
772
- function getUAPrefix() {
773
- if (_utils.browser.chrome) {
774
- return 'ua-chrome';
775
- } else if (_utils.browser.ie) {
776
- return 'ua-ie';
777
- } else if (_utils.browser.gecko) {
778
- return 'ua-firefox';
779
- } else if (_utils.browser.safari) {
780
- return 'ua-safari';
781
- }
782
- return '';
783
- }
33
+ exports.default = _default;