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