@atlaskit/editor-core 179.1.2 → 180.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +80 -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 +1 -1
- package/dist/cjs/create-editor/ReactEditorView.js +12 -762
- package/dist/cjs/create-editor/ReactEditorViewInternal.js +783 -0
- package/dist/cjs/create-editor/ReactEditorViewNext.js +16 -0
- package/dist/cjs/create-editor/create-plugins-list.js +1 -0
- package/dist/cjs/create-editor/feature-flags-from-props.js +3 -2
- package/dist/cjs/editor-next/editor-internal.js +147 -0
- package/dist/cjs/editor-next/editor-migration-component.js +35 -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 +72 -0
- package/dist/cjs/editor-next/index.js +139 -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/handleProviders.js +56 -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 +130 -443
- package/dist/cjs/index.js +7 -0
- 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/preset.js +0 -5
- package/dist/cjs/labs/next/presets/universal.js +11 -2
- 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 +5 -6
- package/dist/cjs/plugins/analytics/utils.js +0 -11
- 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/utils/input-latency-tracking.js +24 -25
- 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/card/nodeviews/blockCard.js +2 -1
- package/dist/cjs/plugins/card/nodeviews/genericCard.js +16 -2
- package/dist/cjs/plugins/card/pm-plugins/main.js +4 -2
- package/dist/cjs/plugins/clipboard/pm-plugins/main.js +4 -1
- package/dist/cjs/plugins/collab-edit/plugin.js +2 -3
- package/dist/cjs/plugins/extension/toolbar.js +7 -1
- package/dist/cjs/plugins/find-replace/ui/FindReplaceToolbarButton.js +5 -1
- package/dist/cjs/plugins/floating-toolbar/ui/Button.js +2 -0
- package/dist/cjs/plugins/floating-toolbar/ui/CheckboxModal.js +5 -3
- package/dist/cjs/plugins/floating-toolbar/ui/Dropdown.js +38 -9
- package/dist/cjs/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +23 -21
- package/dist/cjs/plugins/floating-toolbar/ui/ScrollButtons.js +12 -7
- package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +11 -0
- package/dist/cjs/plugins/fragment/pm-plugins/fragment-consistency.js +1 -0
- 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/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/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/panel/utils.js +4 -1
- package/dist/cjs/plugins/paste/handlers.js +128 -13
- package/dist/cjs/plugins/paste/pm-plugins/analytics.js +15 -6
- package/dist/cjs/plugins/paste/pm-plugins/main.js +12 -3
- package/dist/cjs/plugins/placeholder-text/index.js +2 -2
- package/dist/cjs/plugins/status/index.js +9 -3
- package/dist/cjs/plugins/status/ui/statusPicker.js +8 -2
- package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/index.js +42 -8
- 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 -10
- package/dist/cjs/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +19 -1
- package/dist/cjs/plugins/type-ahead/index.js +1 -1
- package/dist/cjs/plugins/type-ahead/ui/InputQuery.js +79 -106
- package/dist/cjs/types/get-editor-props.js +5 -0
- package/dist/cjs/ui/ChromeCollapsed/index.js +1 -0
- package/dist/cjs/ui/CollapsedEditor/index.js +7 -13
- package/dist/cjs/ui/ColorPickerButton/index.js +68 -6
- package/dist/cjs/ui/ConfigPanel/ConfigPanel.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/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/PanelTextInput/index.js +4 -4
- package/dist/cjs/ui/PortalProvider/index.js +5 -5
- package/dist/cjs/ui/WidthEmitter/index.js +29 -35
- package/dist/cjs/utils/document.js +15 -0
- package/dist/cjs/utils/extensions.js +6 -7
- package/dist/cjs/utils/get-editor-plugins.js +32 -0
- 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 +2 -2
- package/dist/es2019/create-editor/ReactEditorView.js +6 -708
- package/dist/es2019/create-editor/ReactEditorViewInternal.js +712 -0
- package/dist/es2019/create-editor/ReactEditorViewNext.js +7 -0
- package/dist/es2019/create-editor/create-plugins-list.js +1 -0
- package/dist/es2019/create-editor/feature-flags-from-props.js +3 -2
- package/dist/es2019/editor-next/editor-internal.js +142 -0
- package/dist/es2019/editor-next/editor-migration-component.js +10 -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 +61 -0
- package/dist/es2019/editor-next/index.js +90 -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/handleProviders.js +52 -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 +111 -396
- package/dist/es2019/index.js +2 -1
- 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/preset.js +0 -3
- package/dist/es2019/labs/next/presets/universal.js +13 -2
- 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 +1 -2
- package/dist/es2019/plugins/analytics/utils.js +0 -4
- 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/utils/input-latency-tracking.js +23 -23
- 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/card/nodeviews/blockCard.js +4 -1
- package/dist/es2019/plugins/card/nodeviews/genericCard.js +16 -2
- package/dist/es2019/plugins/card/pm-plugins/main.js +3 -1
- package/dist/es2019/plugins/clipboard/pm-plugins/main.js +3 -1
- package/dist/es2019/plugins/collab-edit/plugin.js +1 -2
- package/dist/es2019/plugins/extension/toolbar.js +7 -1
- package/dist/es2019/plugins/find-replace/ui/FindReplaceToolbarButton.js +5 -1
- package/dist/es2019/plugins/floating-toolbar/ui/Button.js +2 -0
- package/dist/es2019/plugins/floating-toolbar/ui/CheckboxModal.js +5 -3
- package/dist/es2019/plugins/floating-toolbar/ui/Dropdown.js +35 -7
- package/dist/es2019/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +2 -2
- package/dist/es2019/plugins/floating-toolbar/ui/ScrollButtons.js +12 -7
- package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +11 -0
- package/dist/es2019/plugins/fragment/pm-plugins/fragment-consistency.js +1 -0
- 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/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/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/panel/utils.js +4 -1
- package/dist/es2019/plugins/paste/handlers.js +127 -5
- package/dist/es2019/plugins/paste/pm-plugins/analytics.js +10 -4
- package/dist/es2019/plugins/paste/pm-plugins/main.js +13 -4
- package/dist/es2019/plugins/placeholder-text/index.js +1 -1
- package/dist/es2019/plugins/status/index.js +8 -2
- package/dist/es2019/plugins/status/ui/statusPicker.js +8 -2
- package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/index.js +42 -8
- 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 -8
- package/dist/es2019/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +16 -1
- package/dist/es2019/plugins/type-ahead/index.js +1 -1
- package/dist/es2019/plugins/type-ahead/ui/InputQuery.js +73 -92
- package/dist/es2019/types/get-editor-props.js +1 -0
- package/dist/es2019/ui/ChromeCollapsed/index.js +1 -0
- package/dist/es2019/ui/CollapsedEditor/index.js +7 -11
- package/dist/es2019/ui/ColorPickerButton/index.js +61 -8
- package/dist/es2019/ui/ConfigPanel/ConfigPanel.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/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/PanelTextInput/index.js +3 -3
- package/dist/es2019/ui/PortalProvider/index.js +1 -1
- package/dist/es2019/ui/WidthEmitter/index.js +25 -29
- package/dist/es2019/utils/document.js +11 -1
- package/dist/es2019/utils/extensions.js +1 -3
- package/dist/es2019/utils/get-editor-plugins.js +25 -0
- 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 +2 -2
- package/dist/esm/create-editor/ReactEditorView.js +12 -763
- package/dist/esm/create-editor/ReactEditorViewInternal.js +776 -0
- package/dist/esm/create-editor/ReactEditorViewNext.js +7 -0
- package/dist/esm/create-editor/create-plugins-list.js +1 -0
- package/dist/esm/create-editor/feature-flags-from-props.js +3 -2
- package/dist/esm/editor-next/editor-internal.js +141 -0
- package/dist/esm/editor-next/editor-migration-component.js +28 -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 +65 -0
- package/dist/esm/editor-next/index.js +134 -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/handleProviders.js +50 -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 +130 -440
- package/dist/esm/index.js +2 -1
- 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/preset.js +0 -5
- package/dist/esm/labs/next/presets/universal.js +11 -2
- 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 +1 -2
- package/dist/esm/plugins/analytics/utils.js +0 -9
- 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/utils/input-latency-tracking.js +24 -25
- 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/card/nodeviews/blockCard.js +2 -1
- package/dist/esm/plugins/card/nodeviews/genericCard.js +16 -2
- package/dist/esm/plugins/card/pm-plugins/main.js +4 -2
- package/dist/esm/plugins/clipboard/pm-plugins/main.js +4 -1
- package/dist/esm/plugins/collab-edit/plugin.js +1 -2
- package/dist/esm/plugins/extension/toolbar.js +7 -1
- package/dist/esm/plugins/find-replace/ui/FindReplaceToolbarButton.js +5 -1
- package/dist/esm/plugins/floating-toolbar/ui/Button.js +2 -0
- package/dist/esm/plugins/floating-toolbar/ui/CheckboxModal.js +5 -3
- package/dist/esm/plugins/floating-toolbar/ui/Dropdown.js +38 -9
- package/dist/esm/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +23 -21
- package/dist/esm/plugins/floating-toolbar/ui/ScrollButtons.js +12 -7
- package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +11 -0
- package/dist/esm/plugins/fragment/pm-plugins/fragment-consistency.js +1 -0
- 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/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/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/panel/utils.js +4 -1
- package/dist/esm/plugins/paste/handlers.js +127 -13
- package/dist/esm/plugins/paste/pm-plugins/analytics.js +13 -5
- package/dist/esm/plugins/paste/pm-plugins/main.js +13 -4
- package/dist/esm/plugins/placeholder-text/index.js +2 -2
- package/dist/esm/plugins/status/index.js +9 -3
- package/dist/esm/plugins/status/ui/statusPicker.js +8 -2
- package/dist/esm/plugins/text-color/ui/ToolbarTextColor/index.js +42 -8
- 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 -8
- package/dist/esm/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +19 -1
- package/dist/esm/plugins/type-ahead/index.js +1 -1
- package/dist/esm/plugins/type-ahead/ui/InputQuery.js +79 -106
- package/dist/esm/types/get-editor-props.js +1 -0
- package/dist/esm/ui/ChromeCollapsed/index.js +1 -0
- package/dist/esm/ui/CollapsedEditor/index.js +7 -13
- package/dist/esm/ui/ColorPickerButton/index.js +69 -7
- package/dist/esm/ui/ConfigPanel/ConfigPanel.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/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/PanelTextInput/index.js +4 -4
- package/dist/esm/ui/PortalProvider/index.js +1 -1
- package/dist/esm/ui/WidthEmitter/index.js +28 -37
- package/dist/esm/utils/document.js +15 -1
- package/dist/esm/utils/extensions.js +1 -3
- package/dist/esm/utils/get-editor-plugins.js +25 -0
- 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 +2 -2
- package/dist/types/create-editor/ReactEditorView.d.ts +7 -109
- package/dist/types/create-editor/ReactEditorViewInternal.d.ts +112 -0
- package/dist/types/create-editor/ReactEditorViewNext.d.ts +9 -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/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 +47 -25
- package/dist/types/index.d.ts +1 -0
- 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/preset.d.ts +6 -6
- package/dist/types/labs/next/presets/universal.d.ts +1 -1
- package/dist/types/plugins/alignment/index.d.ts +1 -1
- 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/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/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/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/card/index.d.ts +3 -1
- package/dist/types/plugins/card/nodeviews/genericCard.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/index.d.ts +3 -1
- package/dist/types/plugins/collab-edit/index.d.ts +3 -1
- package/dist/types/plugins/context-panel/index.d.ts +1 -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/index.d.ts +3 -1
- 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 -1
- package/dist/types/plugins/find-replace/index.d.ts +3 -1
- package/dist/types/plugins/floating-toolbar/ui/Button.d.ts +2 -1
- package/dist/types/plugins/floating-toolbar/ui/Dropdown.d.ts +5 -2
- package/dist/types/plugins/grid/index.d.ts +3 -1
- package/dist/types/plugins/help-dialog/index.d.ts +3 -1
- 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/list/index.d.ts +3 -1
- 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/mentions/index.d.ts +3 -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 -1
- package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +4 -1
- 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/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/submit-editor/index.d.ts +3 -1
- package/dist/types/plugins/tasks-and-decisions/index.d.ts +3 -1
- package/dist/types/plugins/text-color/index.d.ts +3 -1
- 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/ui/Toolbar/more-button.d.ts +2 -1
- package/dist/types/plugins/text-formatting/utils.d.ts +0 -1
- package/dist/types/plugins/toolbar-lists-indentation/index.d.ts +3 -1
- package/dist/types/plugins/type-ahead/index.d.ts +3 -1
- 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/FullPage/StyledComponents.d.ts +29 -29
- package/dist/types/ui/CollapsedEditor/index.d.ts +4 -3
- package/dist/types/ui/ColorPickerButton/index.d.ts +2 -1
- package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
- package/dist/types/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types/ui/ContextPanel/context.d.ts +2 -1
- package/dist/types/ui/PanelTextInput/index.d.ts +1 -1
- package/dist/types/ui/PortalProvider/index.d.ts +1 -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/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/docs/0-intro.tsx +0 -1
- package/package.json +27 -26
- package/report.api.md +193 -139
- package/dist/cjs/plugins/analytics/analytics-queue.js +0 -79
- package/dist/cjs/plugins/analytics/fire-analytics-event.js +0 -35
- package/dist/es2019/plugins/analytics/analytics-queue.js +0 -53
- package/dist/es2019/plugins/analytics/fire-analytics-event.js +0 -26
- package/dist/esm/plugins/analytics/analytics-queue.js +0 -71
- package/dist/esm/plugins/analytics/fire-analytics-event.js +0 -28
- package/dist/types/plugins/analytics/analytics-queue.d.ts +0 -10
- package/dist/types/plugins/analytics/fire-analytics-event.d.ts +0 -9
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
3
|
+
import { tablesPlugin } from '@atlaskit/editor-plugin-table';
|
|
4
|
+
import { createEditorSelectionAPI } from '../../../selection-api/api';
|
|
5
|
+
import { createInsertNodeAPI } from '../../../insert-api/api';
|
|
6
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
7
|
+
import { attachPayloadIntoTransaction } from '../../../analytics-api/attach-payload-into-transaction';
|
|
8
|
+
import { FabricChannel } from '@atlaskit/analytics-listeners';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* DO NOT USE THIS FUNCTION
|
|
12
|
+
*
|
|
13
|
+
* IT IS A TEMPORARY PLACEHOLDER UNTIL THOSE TICKETS XX-11111 XX-22222 are done
|
|
14
|
+
**/
|
|
15
|
+
export const createStubInternalApis = () => {
|
|
16
|
+
const editorViewRef = {
|
|
17
|
+
current: null
|
|
18
|
+
};
|
|
19
|
+
const createAnalyticsEventRef = {
|
|
20
|
+
current: null
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
const createAnalyticsEvent = payload => {
|
|
25
|
+
// That means the AnalyticsNext context is being used
|
|
26
|
+
if (createAnalyticsEventRef.current) {
|
|
27
|
+
return createAnalyticsEventRef.current(payload);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// That means, there is no createAnalyticsEvent available at all.
|
|
31
|
+
// This should not happen, but if it does, we will send a mock function to avoid
|
|
32
|
+
// regression on SmartLinks (they are the only one using this function directly)
|
|
33
|
+
// eslint-disable-next-line no-console
|
|
34
|
+
console.error('This should never be called, if it does we have a problem');
|
|
35
|
+
return {
|
|
36
|
+
fire: () => {}
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
const editorSelectionAPI = createEditorSelectionAPI();
|
|
40
|
+
const editorAnalyticsAPI = {
|
|
41
|
+
attachAnalyticsEvent: payload => tr => {
|
|
42
|
+
const editorView = editorViewRef.current;
|
|
43
|
+
if (!tr || !createAnalyticsEvent || !editorView) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
attachPayloadIntoTransaction({
|
|
47
|
+
tr,
|
|
48
|
+
editorState: editorView.state,
|
|
49
|
+
payload,
|
|
50
|
+
channel: FabricChannel.editor
|
|
51
|
+
});
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const insertNodeAPI = createInsertNodeAPI({
|
|
56
|
+
getEditorView: () => {
|
|
57
|
+
return editorViewRef.current;
|
|
58
|
+
},
|
|
59
|
+
getEditorPlugins: () => {
|
|
60
|
+
const fakeTablePlugin = tablesPlugin();
|
|
61
|
+
if (!(fakeTablePlugin !== null && fakeTablePlugin !== void 0 && fakeTablePlugin.pluginsOptions)) {
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
return [fakeTablePlugin];
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
const MountCreateAnalyticsEventRef = () => {
|
|
68
|
+
const {
|
|
69
|
+
createAnalyticsEvent
|
|
70
|
+
} = useAnalyticsEvents();
|
|
71
|
+
React.useLayoutEffect(() => {
|
|
72
|
+
createAnalyticsEventRef.current = createAnalyticsEvent;
|
|
73
|
+
}, [createAnalyticsEvent]);
|
|
74
|
+
return null;
|
|
75
|
+
};
|
|
76
|
+
const stubInternalApisPlugin = () => ({
|
|
77
|
+
name: 'stubInternalApisPlugin',
|
|
78
|
+
pmPlugins() {
|
|
79
|
+
return [{
|
|
80
|
+
name: 'stubInternalApisPMPlugin',
|
|
81
|
+
plugin: () => new SafePlugin({
|
|
82
|
+
view: editorView => {
|
|
83
|
+
editorViewRef.current = editorView;
|
|
84
|
+
return {
|
|
85
|
+
destroy() {
|
|
86
|
+
editorViewRef.current = null;
|
|
87
|
+
createAnalyticsEventRef.current = null;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
}];
|
|
93
|
+
},
|
|
94
|
+
contentComponent: () => {
|
|
95
|
+
return /*#__PURE__*/React.createElement(MountCreateAnalyticsEventRef);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
return {
|
|
99
|
+
editorSelectionAPI,
|
|
100
|
+
insertNodeAPI,
|
|
101
|
+
editorAnalyticsAPI,
|
|
102
|
+
createAnalyticsEvent,
|
|
103
|
+
stubInternalApisPlugin
|
|
104
|
+
};
|
|
105
|
+
};
|
|
@@ -57,9 +57,6 @@ export class Preset {
|
|
|
57
57
|
cache.forEach((options, fn) => {
|
|
58
58
|
plugins.push(fn(options));
|
|
59
59
|
});
|
|
60
|
-
if (plugins.some(plugin => typeof plugin === 'function')) {
|
|
61
|
-
throw new Error("!!! NextEditorPluginWithDependencies detected in presets. That's an unsupported runtime use case right now.");
|
|
62
|
-
}
|
|
63
60
|
return plugins;
|
|
64
61
|
}
|
|
65
62
|
removeExcludedPlugins(plugins, excludes) {
|
|
@@ -4,6 +4,7 @@ import { isFullPage as fullPageCheck } from '../../../utils/is-full-page';
|
|
|
4
4
|
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
5
5
|
import { createDefaultPreset } from './default';
|
|
6
6
|
import { shouldForceTracking } from '@atlaskit/editor-common/utils';
|
|
7
|
+
import { createStubInternalApis } from './create-stub-internal-apis';
|
|
7
8
|
/**
|
|
8
9
|
* Creates a preset with all of the available plugins.
|
|
9
10
|
* Basis for create-plugins-list and can be used to migrate from Editor -> EditorNext (Presets project)
|
|
@@ -20,13 +21,22 @@ import { shouldForceTracking } from '@atlaskit/editor-common/utils';
|
|
|
20
21
|
* @param getEditorContainerWidth
|
|
21
22
|
* @returns a full featured preset configured according to the provided props - basis for create-plugins-list
|
|
22
23
|
*/
|
|
23
|
-
export default function createUniversalPreset(appearance, props, featureFlags, prevAppearance,
|
|
24
|
+
export default function createUniversalPreset(appearance, props, featureFlags, prevAppearance, maybeCreateAnalyticsEvent, _insertNodeAPI, _editorAnalyticsAPI, _editorSelectionAPI, _getEditorContainerWidth) {
|
|
24
25
|
var _props$linking;
|
|
25
26
|
const isMobile = appearance === 'mobile';
|
|
26
27
|
const isComment = appearance === 'comment';
|
|
27
28
|
const isFullPage = fullPageCheck(appearance);
|
|
28
29
|
const preset = createDefaultPreset(props);
|
|
29
30
|
const getEditorFeatureFlags = () => featureFlags;
|
|
31
|
+
const stubs = createStubInternalApis();
|
|
32
|
+
const {
|
|
33
|
+
editorSelectionAPI,
|
|
34
|
+
insertNodeAPI,
|
|
35
|
+
editorAnalyticsAPI,
|
|
36
|
+
stubInternalApisPlugin
|
|
37
|
+
} = stubs;
|
|
38
|
+
const createAnalyticsEvent = maybeCreateAnalyticsEvent ? maybeCreateAnalyticsEvent : stubs.createAnalyticsEvent;
|
|
39
|
+
preset.add(stubInternalApisPlugin);
|
|
30
40
|
if (props.allowAnalyticsGASV3) {
|
|
31
41
|
const {
|
|
32
42
|
performanceTracking
|
|
@@ -226,7 +236,8 @@ export default function createUniversalPreset(appearance, props, featureFlags, p
|
|
|
226
236
|
platform: isMobile ? 'mobile' : 'web',
|
|
227
237
|
fullWidthMode,
|
|
228
238
|
createAnalyticsEvent,
|
|
229
|
-
linkPicker: (_props$linking3 = props.linking) === null || _props$linking3 === void 0 ? void 0 : _props$linking3.linkPicker
|
|
239
|
+
linkPicker: (_props$linking3 = props.linking) === null || _props$linking3 === void 0 ? void 0 : _props$linking3.linkPicker,
|
|
240
|
+
editorAppearance: appearance
|
|
230
241
|
}]);
|
|
231
242
|
}
|
|
232
243
|
if (props.autoformattingProvider) {
|
|
@@ -15,7 +15,8 @@ export class AlignmentToolbar extends React.Component {
|
|
|
15
15
|
super(...args);
|
|
16
16
|
_defineProperty(this, "toolbarItemRef", /*#__PURE__*/React.createRef());
|
|
17
17
|
_defineProperty(this, "state", {
|
|
18
|
-
isOpen: false
|
|
18
|
+
isOpen: false,
|
|
19
|
+
isOpenedByKeyboard: false
|
|
19
20
|
});
|
|
20
21
|
_defineProperty(this, "changeAlignment", (align, togglePopup) => {
|
|
21
22
|
if (togglePopup) {
|
|
@@ -24,17 +25,20 @@ export class AlignmentToolbar extends React.Component {
|
|
|
24
25
|
return this.props.changeAlignment(align);
|
|
25
26
|
});
|
|
26
27
|
_defineProperty(this, "toggleOpen", () => {
|
|
27
|
-
this.handleOpenChange({
|
|
28
|
-
isOpen: !this.state.isOpen
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
_defineProperty(this, "handleOpenChange", ({
|
|
32
|
-
isOpen
|
|
33
|
-
}) => {
|
|
34
28
|
this.setState({
|
|
35
|
-
isOpen
|
|
29
|
+
isOpen: !this.state.isOpen,
|
|
30
|
+
isOpenedByKeyboard: false
|
|
36
31
|
});
|
|
37
32
|
});
|
|
33
|
+
_defineProperty(this, "toggleOpenByKeyboard", event => {
|
|
34
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
this.setState({
|
|
37
|
+
isOpen: !this.state.isOpen,
|
|
38
|
+
isOpenedByKeyboard: true
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
});
|
|
38
42
|
_defineProperty(this, "hide", attrs => {
|
|
39
43
|
if (this.state.isOpen) {
|
|
40
44
|
this.setState({
|
|
@@ -54,7 +58,8 @@ export class AlignmentToolbar extends React.Component {
|
|
|
54
58
|
}
|
|
55
59
|
render() {
|
|
56
60
|
const {
|
|
57
|
-
isOpen
|
|
61
|
+
isOpen,
|
|
62
|
+
isOpenedByKeyboard
|
|
58
63
|
} = this.state;
|
|
59
64
|
const {
|
|
60
65
|
popupsMountPoint,
|
|
@@ -73,14 +78,21 @@ export class AlignmentToolbar extends React.Component {
|
|
|
73
78
|
boundariesElement: popupsBoundariesElement,
|
|
74
79
|
scrollableElement: popupsScrollableElement,
|
|
75
80
|
isOpen: isOpen,
|
|
81
|
+
shouldFocusFirstItem: () => {
|
|
82
|
+
if (isOpenedByKeyboard) {
|
|
83
|
+
this.setState({
|
|
84
|
+
...this.state,
|
|
85
|
+
isOpenedByKeyboard: false
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return isOpenedByKeyboard;
|
|
89
|
+
},
|
|
76
90
|
onOpenChange: ({
|
|
77
91
|
isOpen
|
|
78
92
|
}) => {
|
|
79
|
-
var _this$toolbarItemRef4, _this$toolbarItemRef5;
|
|
80
93
|
this.setState({
|
|
81
94
|
isOpen
|
|
82
95
|
});
|
|
83
|
-
(_this$toolbarItemRef4 = this.toolbarItemRef) === null || _this$toolbarItemRef4 === void 0 ? void 0 : (_this$toolbarItemRef5 = _this$toolbarItemRef4.current) === null || _this$toolbarItemRef5 === void 0 ? void 0 : _this$toolbarItemRef5.focus();
|
|
84
96
|
},
|
|
85
97
|
handleClickOutside: event => {
|
|
86
98
|
if (event instanceof MouseEvent) {
|
|
@@ -104,6 +116,7 @@ export class AlignmentToolbar extends React.Component {
|
|
|
104
116
|
"aria-expanded": isOpen,
|
|
105
117
|
"aria-haspopup": true,
|
|
106
118
|
onClick: this.toggleOpen,
|
|
119
|
+
onKeyDown: this.toggleOpenByKeyboard,
|
|
107
120
|
iconBefore: jsx("div", {
|
|
108
121
|
css: triggerWrapper
|
|
109
122
|
}, jsx(IconMap, {
|
|
@@ -122,6 +135,22 @@ export class AlignmentToolbar extends React.Component {
|
|
|
122
135
|
css: separator
|
|
123
136
|
}));
|
|
124
137
|
}
|
|
138
|
+
componentDidUpdate(prevProps) {
|
|
139
|
+
if (this.state.isOpen && this.state.isOpenedByKeyboard) {
|
|
140
|
+
// by triggering the keyboard event with a setTimeout, we ensure that the tooltip
|
|
141
|
+
// associated with the alignment button doesn't render until the next render cycle
|
|
142
|
+
// where the popup will be correctly positioned and the relative position of the tooltip
|
|
143
|
+
// will not overlap with the button.
|
|
144
|
+
setTimeout(() => {
|
|
145
|
+
var _this$toolbarItemRef$2;
|
|
146
|
+
const keyboardEvent = new KeyboardEvent('keydown', {
|
|
147
|
+
bubbles: true,
|
|
148
|
+
key: 'ArrowDown'
|
|
149
|
+
});
|
|
150
|
+
(_this$toolbarItemRef$2 = this.toolbarItemRef.current) === null || _this$toolbarItemRef$2 === void 0 ? void 0 : _this$toolbarItemRef$2.dispatchEvent(keyboardEvent);
|
|
151
|
+
}, 0);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
125
154
|
}
|
|
126
155
|
_defineProperty(AlignmentToolbar, "displayName", 'AlignmentToolbar');
|
|
127
156
|
export default injectIntl(AlignmentToolbar);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import analyticsPlugin from './plugin';
|
|
2
2
|
import { analyticsPluginKey as pluginKey } from './plugin-key';
|
|
3
|
-
export { ACTION_SUBJECT_ID, ACTION_SUBJECT, ACTION, BROWSER_FREEZE_INTERACTION_TYPE, EVENT_TYPE, FULL_WIDTH_MODE, INDENT_DIRECTION, INDENT_TYPE, INPUT_METHOD, LINK_REPRESENTATION, LINK_RESOURCE, LINK_STATUS, MODE, PasteContents, PasteSources, PasteTypes, PLATFORMS, PUNC, SYMBOL, TABLE_ACTION, TABLE_BREAKOUT, TRIGGER_METHOD, USER_CONTEXT, DELETE_DIRECTION, LIST_TEXT_SCENARIOS } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
export { withAnalytics, addAnalytics, findInsertLocation,
|
|
3
|
+
export { ACTION_SUBJECT_ID, ACTION_SUBJECT, ACTION, BROWSER_FREEZE_INTERACTION_TYPE, EVENT_TYPE, FULL_WIDTH_MODE, INDENT_DIRECTION, INDENT_TYPE, INPUT_METHOD, LINK_REPRESENTATION, LINK_RESOURCE, LINK_STATUS, MODE, PasteContents, PasteSources, PasteTypes, PLATFORMS, PUNC, SYMBOL, TABLE_ACTION, TABLE_BREAKOUT, TRIGGER_METHOD, USER_CONTEXT, DELETE_DIRECTION, LIST_TEXT_SCENARIOS, fireAnalyticsEvent, getAnalyticsEventsFromTransaction } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
export { withAnalytics, addAnalytics, findInsertLocation, getSelectionType, getStateContext, mapActionSubjectIdToAttributes } from './utils';
|
|
5
5
|
export const analyticsPluginKey = pluginKey;
|
|
6
|
-
export default analyticsPlugin;
|
|
7
|
-
export { fireAnalyticsEvent } from './fire-analytics-event';
|
|
6
|
+
export default analyticsPlugin;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
2
|
import { isPerformanceAPIAvailable, measureRender } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { ACTION, EVENT_TYPE } from './types';
|
|
4
|
-
import { getAnalyticsEventsFromTransaction } from './utils';
|
|
5
4
|
import { analyticsPluginKey } from './plugin-key';
|
|
6
|
-
import { fireAnalyticsEvent } from '
|
|
5
|
+
import { fireAnalyticsEvent, getAnalyticsEventsFromTransaction } from '@atlaskit/editor-common/analytics';
|
|
7
6
|
import { getFeatureFlags } from '../feature-flags-context';
|
|
8
7
|
import { AnalyticsStep } from '@atlaskit/adf-schema/steps';
|
|
9
8
|
import { generateUndoRedoInputSoucePayload } from '../undo-redo/undo-redo-input-source';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { AnalyticsStep } from '@atlaskit/adf-schema/steps';
|
|
2
1
|
import { editorAnalyticsChannel } from './consts';
|
|
3
2
|
import { analyticsPluginKey } from './plugin-key';
|
|
4
3
|
function getCreateUIAnalyticsEvent(editorState) {
|
|
@@ -35,7 +34,4 @@ export function withAnalytics(payload, channel) {
|
|
|
35
34
|
}
|
|
36
35
|
}
|
|
37
36
|
}, view);
|
|
38
|
-
}
|
|
39
|
-
export function getAnalyticsEventsFromTransaction(tr) {
|
|
40
|
-
return tr.steps.filter(step => step instanceof AnalyticsStep).reduce((acc, step) => [...acc, ...step.analyticsEvents], []);
|
|
41
37
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { ACTION_SUBJECT, ACTION, EVENT_TYPE, getAnalyticsEventsFromTransaction } from '
|
|
2
|
+
import { ACTION_SUBJECT, ACTION, EVENT_TYPE, getAnalyticsEventsFromTransaction } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
const hasInvalidSteps = tr => (tr.steps || []).some(step => step.from > step.to);
|
|
4
4
|
export default (dispatchAnalyticsEvent => {
|
|
5
5
|
return new SafePlugin({
|
|
@@ -41,6 +41,8 @@ const dispatchLongTaskEvent = (dispatchAnalyticsEvent, view, time, getNodeCount,
|
|
|
41
41
|
export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, ufo) => {
|
|
42
42
|
let interactionType;
|
|
43
43
|
let inputLatencyTracker = null;
|
|
44
|
+
let inputLatencySingleKeyTracker = null;
|
|
45
|
+
let inputLatencyRenderedTracker = null;
|
|
44
46
|
if (browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType) {
|
|
45
47
|
interactionType = setInteractionType(BROWSER_FREEZE_INTERACTION_TYPE.LOADING);
|
|
46
48
|
}
|
|
@@ -64,19 +66,81 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
|
|
|
64
66
|
const shouldTrackSeverity = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.trackSeverity) || DEFAULT_TRACK_SEVERITY_ENABLED;
|
|
65
67
|
const severityThresholdNormal = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.severityNormalThreshold) || DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL;
|
|
66
68
|
const severityThresholdDegraded = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.severityDegradedThreshold) || DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED;
|
|
69
|
+
const createDispatchSample = (action, view) => (time, severity) => {
|
|
70
|
+
var _getContextIdentifier2;
|
|
71
|
+
const {
|
|
72
|
+
state
|
|
73
|
+
} = view;
|
|
74
|
+
const nodesCount = getNodeCount(state);
|
|
75
|
+
const samplePayload = {
|
|
76
|
+
action,
|
|
77
|
+
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
78
|
+
attributes: {
|
|
79
|
+
time,
|
|
80
|
+
nodeSize: state.doc.nodeSize,
|
|
81
|
+
...nodesCount,
|
|
82
|
+
participants: getParticipantsCount(state),
|
|
83
|
+
objectId: (_getContextIdentifier2 = getContextIdentifier(state)) === null || _getContextIdentifier2 === void 0 ? void 0 : _getContextIdentifier2.objectId,
|
|
84
|
+
severity: shouldTrackSeverity ? severity : undefined
|
|
85
|
+
},
|
|
86
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
87
|
+
};
|
|
88
|
+
dispatchAnalyticsEvent(samplePayload);
|
|
89
|
+
};
|
|
90
|
+
const createDispatchAverage = (action, view) => ({
|
|
91
|
+
mean,
|
|
92
|
+
median,
|
|
93
|
+
sampleSize
|
|
94
|
+
}, severity) => {
|
|
95
|
+
var _getContextIdentifier3;
|
|
96
|
+
const {
|
|
97
|
+
state
|
|
98
|
+
} = view;
|
|
99
|
+
const nodeCount = getNodeCount(state);
|
|
100
|
+
const averagePayload = {
|
|
101
|
+
action,
|
|
102
|
+
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
103
|
+
attributes: {
|
|
104
|
+
mean,
|
|
105
|
+
median,
|
|
106
|
+
sampleSize,
|
|
107
|
+
...nodeCount,
|
|
108
|
+
nodeSize: state.doc.nodeSize,
|
|
109
|
+
severity: shouldTrackSeverity ? severity : undefined,
|
|
110
|
+
participants: getParticipantsCount(state),
|
|
111
|
+
objectId: (_getContextIdentifier3 = getContextIdentifier(state)) === null || _getContextIdentifier3 === void 0 ? void 0 : _getContextIdentifier3.objectId
|
|
112
|
+
},
|
|
113
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
114
|
+
};
|
|
115
|
+
dispatchAnalyticsEvent(averagePayload);
|
|
116
|
+
};
|
|
67
117
|
return new SafePlugin({
|
|
68
118
|
key: frozenEditorPluginKey,
|
|
69
119
|
props: isPerformanceAPIAvailable() ? {
|
|
70
120
|
handleTextInput(view) {
|
|
71
|
-
var _inputLatencyTracker;
|
|
72
|
-
(_inputLatencyTracker = inputLatencyTracker) === null || _inputLatencyTracker === void 0 ? void 0 : _inputLatencyTracker.start();
|
|
73
121
|
if (browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType) {
|
|
74
122
|
interactionType = BROWSER_FREEZE_INTERACTION_TYPE.TYPING;
|
|
75
123
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
124
|
+
if (inputLatencyTracker) {
|
|
125
|
+
const end = inputLatencyTracker.start();
|
|
126
|
+
|
|
127
|
+
// This is called after all handleTextInput events are executed which means first handleTextInput time incorporates following handleTextInput processing time
|
|
128
|
+
// Also this is called before browser rendering so it doesn't count it.
|
|
129
|
+
requestAnimationFrame(end);
|
|
130
|
+
}
|
|
131
|
+
if (inputLatencySingleKeyTracker) {
|
|
132
|
+
const end = inputLatencySingleKeyTracker.start();
|
|
133
|
+
|
|
134
|
+
// This is executed before next handleTextInput when multiple keypress events are in one animation frame
|
|
135
|
+
// so it tracks individual keypress processing time
|
|
136
|
+
Promise.resolve().then(end);
|
|
137
|
+
}
|
|
138
|
+
if (inputLatencyRenderedTracker) {
|
|
139
|
+
const end = inputLatencyRenderedTracker.start();
|
|
140
|
+
|
|
141
|
+
// This is called at the next event loop so it counts browser rendering time.
|
|
142
|
+
setTimeout(end);
|
|
143
|
+
}
|
|
80
144
|
return false;
|
|
81
145
|
},
|
|
82
146
|
handleDOMEvents: browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType ? {
|
|
@@ -108,7 +172,7 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
|
|
|
108
172
|
isSlow,
|
|
109
173
|
severity
|
|
110
174
|
}) => {
|
|
111
|
-
var
|
|
175
|
+
var _getContextIdentifier4;
|
|
112
176
|
const {
|
|
113
177
|
state
|
|
114
178
|
} = view;
|
|
@@ -122,59 +186,13 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
|
|
|
122
186
|
nodeSize: state.doc.nodeSize,
|
|
123
187
|
...nodesCount,
|
|
124
188
|
participants: getParticipantsCount(state),
|
|
125
|
-
objectId: (
|
|
189
|
+
objectId: (_getContextIdentifier4 = getContextIdentifier(state)) === null || _getContextIdentifier4 === void 0 ? void 0 : _getContextIdentifier4.objectId,
|
|
126
190
|
time,
|
|
127
191
|
severity: shouldTrackSeverity ? severity : undefined
|
|
128
192
|
});
|
|
129
193
|
},
|
|
130
|
-
dispatchSample: (
|
|
131
|
-
|
|
132
|
-
const {
|
|
133
|
-
state
|
|
134
|
-
} = view;
|
|
135
|
-
const nodesCount = getNodeCount(state);
|
|
136
|
-
const samplePayload = {
|
|
137
|
-
action: ACTION.INPUT_PERF_SAMPLING,
|
|
138
|
-
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
139
|
-
attributes: {
|
|
140
|
-
time,
|
|
141
|
-
nodeSize: state.doc.nodeSize,
|
|
142
|
-
...nodesCount,
|
|
143
|
-
participants: getParticipantsCount(state),
|
|
144
|
-
objectId: (_getContextIdentifier3 = getContextIdentifier(state)) === null || _getContextIdentifier3 === void 0 ? void 0 : _getContextIdentifier3.objectId,
|
|
145
|
-
severity: shouldTrackSeverity ? severity : undefined
|
|
146
|
-
},
|
|
147
|
-
eventType: EVENT_TYPE.OPERATIONAL
|
|
148
|
-
};
|
|
149
|
-
dispatchAnalyticsEvent(samplePayload);
|
|
150
|
-
},
|
|
151
|
-
dispatchAverage: ({
|
|
152
|
-
mean,
|
|
153
|
-
median,
|
|
154
|
-
sampleSize
|
|
155
|
-
}, severity) => {
|
|
156
|
-
var _getContextIdentifier4;
|
|
157
|
-
const {
|
|
158
|
-
state
|
|
159
|
-
} = view;
|
|
160
|
-
const nodeCount = getNodeCount(state);
|
|
161
|
-
const averagePayload = {
|
|
162
|
-
action: ACTION.INPUT_PERF_SAMPLING_AVG,
|
|
163
|
-
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
164
|
-
attributes: {
|
|
165
|
-
mean,
|
|
166
|
-
median,
|
|
167
|
-
sampleSize,
|
|
168
|
-
...nodeCount,
|
|
169
|
-
nodeSize: state.doc.nodeSize,
|
|
170
|
-
severity: shouldTrackSeverity ? severity : undefined,
|
|
171
|
-
participants: getParticipantsCount(state),
|
|
172
|
-
objectId: (_getContextIdentifier4 = getContextIdentifier(state)) === null || _getContextIdentifier4 === void 0 ? void 0 : _getContextIdentifier4.objectId
|
|
173
|
-
},
|
|
174
|
-
eventType: EVENT_TYPE.OPERATIONAL
|
|
175
|
-
};
|
|
176
|
-
dispatchAnalyticsEvent(averagePayload);
|
|
177
|
-
},
|
|
194
|
+
dispatchSample: createDispatchSample(ACTION.INPUT_PERF_SAMPLING, view),
|
|
195
|
+
dispatchAverage: createDispatchAverage(ACTION.INPUT_PERF_SAMPLING_AVG, view),
|
|
178
196
|
onSlowInput: time => {
|
|
179
197
|
var _getContextIdentifier5;
|
|
180
198
|
const {
|
|
@@ -196,6 +214,26 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
|
|
|
196
214
|
}
|
|
197
215
|
});
|
|
198
216
|
}
|
|
217
|
+
if (inputTracking !== null && inputTracking !== void 0 && inputTracking.trackSingleKeypress) {
|
|
218
|
+
inputLatencySingleKeyTracker = new InputLatencyTracker({
|
|
219
|
+
samplingRate,
|
|
220
|
+
slowThreshold,
|
|
221
|
+
normalThreshold: severityThresholdNormal,
|
|
222
|
+
degradedThreshold: severityThresholdDegraded,
|
|
223
|
+
dispatchSample: createDispatchSample(ACTION.INPUT_PERF_SAMPLING_SINGLE_KEYPRESS, view),
|
|
224
|
+
dispatchAverage: createDispatchAverage(ACTION.INPUT_PERF_SAMPLING_SINGLE_KEYPRESS_AVG, view)
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
if (inputTracking !== null && inputTracking !== void 0 && inputTracking.trackRenderingTime) {
|
|
228
|
+
inputLatencyRenderedTracker = new InputLatencyTracker({
|
|
229
|
+
samplingRate,
|
|
230
|
+
slowThreshold,
|
|
231
|
+
normalThreshold: severityThresholdNormal,
|
|
232
|
+
degradedThreshold: severityThresholdDegraded,
|
|
233
|
+
dispatchSample: createDispatchSample(ACTION.INPUT_PERF_SAMPLING_RENDERED, view),
|
|
234
|
+
dispatchAverage: createDispatchAverage(ACTION.INPUT_PERF_SAMPLING_RENDERED_AVG, view)
|
|
235
|
+
});
|
|
236
|
+
}
|
|
199
237
|
let observer;
|
|
200
238
|
try {
|
|
201
239
|
const observer = new PerformanceObserver(list => {
|
|
@@ -217,8 +255,8 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
|
|
|
217
255
|
} catch (e) {}
|
|
218
256
|
return {
|
|
219
257
|
destroy: () => {
|
|
220
|
-
var
|
|
221
|
-
(
|
|
258
|
+
var _inputLatencyTracker;
|
|
259
|
+
(_inputLatencyTracker = inputLatencyTracker) === null || _inputLatencyTracker === void 0 ? void 0 : _inputLatencyTracker.flush();
|
|
222
260
|
observer === null || observer === void 0 ? void 0 : observer.disconnect();
|
|
223
261
|
}
|
|
224
262
|
};
|
|
@@ -15,7 +15,6 @@ export default class InputLatencyTracker {
|
|
|
15
15
|
}) {
|
|
16
16
|
_defineProperty(this, "samples", []);
|
|
17
17
|
_defineProperty(this, "total", 0);
|
|
18
|
-
this.currentStart = null;
|
|
19
18
|
this.samplingRate = samplingRate;
|
|
20
19
|
this.slowThreshold = slowThreshold;
|
|
21
20
|
this.normalThreshold = normalThreshold;
|
|
@@ -27,32 +26,33 @@ export default class InputLatencyTracker {
|
|
|
27
26
|
this.onSlowInput = onSlowInput;
|
|
28
27
|
}
|
|
29
28
|
start() {
|
|
30
|
-
|
|
29
|
+
const currentStart = performance.now();
|
|
31
30
|
if (this.samples.length + 1 === this.samplingRate) {
|
|
32
31
|
var _this$onSampleStart;
|
|
33
32
|
(_this$onSampleStart = this.onSampleStart) === null || _this$onSampleStart === void 0 ? void 0 : _this$onSampleStart.call(this);
|
|
34
33
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
}
|
|
34
|
+
const end = () => {
|
|
35
|
+
if (currentStart === null) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
let isSlow = false;
|
|
39
|
+
const time = getTimeSince(currentStart);
|
|
40
|
+
this.push(time);
|
|
41
|
+
if (time > this.slowThreshold) {
|
|
42
|
+
var _this$onSlowInput;
|
|
43
|
+
(_this$onSlowInput = this.onSlowInput) === null || _this$onSlowInput === void 0 ? void 0 : _this$onSlowInput.call(this, time);
|
|
44
|
+
isSlow = true;
|
|
45
|
+
}
|
|
46
|
+
if (this.samples.length === this.samplingRate) {
|
|
47
|
+
var _this$onSampleEnd;
|
|
48
|
+
this.flush();
|
|
49
|
+
(_this$onSampleEnd = this.onSampleEnd) === null || _this$onSampleEnd === void 0 ? void 0 : _this$onSampleEnd.call(this, time, {
|
|
50
|
+
isSlow,
|
|
51
|
+
severity: this.severity(time)
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
return end;
|
|
56
56
|
}
|
|
57
57
|
flush() {
|
|
58
58
|
if (this.samples.length === 0) {
|
|
@@ -15,18 +15,31 @@ class ToolbarBlockType extends React.PureComponent {
|
|
|
15
15
|
constructor(...args) {
|
|
16
16
|
super(...args);
|
|
17
17
|
_defineProperty(this, "state", {
|
|
18
|
-
active: false
|
|
18
|
+
active: false,
|
|
19
|
+
isOpenedByKeyboard: false
|
|
19
20
|
});
|
|
20
21
|
_defineProperty(this, "onOpenChange", attrs => {
|
|
21
22
|
this.setState({
|
|
22
|
-
|
|
23
|
+
...this.state,
|
|
24
|
+
active: attrs.isOpen,
|
|
25
|
+
isOpenedByKeyboard: attrs.isOpenedByKeyboard
|
|
23
26
|
});
|
|
24
27
|
});
|
|
25
28
|
_defineProperty(this, "handleTriggerClick", () => {
|
|
26
29
|
this.onOpenChange({
|
|
27
|
-
isOpen: !this.state.active
|
|
30
|
+
isOpen: !this.state.active,
|
|
31
|
+
isOpenedByKeyboard: false
|
|
28
32
|
});
|
|
29
33
|
});
|
|
34
|
+
_defineProperty(this, "handleTriggerByKeyboard", event => {
|
|
35
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
36
|
+
event.preventDefault();
|
|
37
|
+
this.onOpenChange({
|
|
38
|
+
isOpen: !this.state.active,
|
|
39
|
+
isOpenedByKeyboard: true
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
30
43
|
_defineProperty(this, "createItems", () => {
|
|
31
44
|
const {
|
|
32
45
|
intl: {
|
|
@@ -69,6 +82,7 @@ class ToolbarBlockType extends React.PureComponent {
|
|
|
69
82
|
this.props.setBlockType(blockType.name);
|
|
70
83
|
if (shouldCloseMenu) {
|
|
71
84
|
this.setState({
|
|
85
|
+
...this.state,
|
|
72
86
|
active: false
|
|
73
87
|
});
|
|
74
88
|
}
|
|
@@ -76,7 +90,8 @@ class ToolbarBlockType extends React.PureComponent {
|
|
|
76
90
|
}
|
|
77
91
|
render() {
|
|
78
92
|
const {
|
|
79
|
-
active
|
|
93
|
+
active,
|
|
94
|
+
isOpenedByKeyboard
|
|
80
95
|
} = this.state;
|
|
81
96
|
const {
|
|
82
97
|
popupsMountPoint,
|
|
@@ -117,7 +132,16 @@ class ToolbarBlockType extends React.PureComponent {
|
|
|
117
132
|
zIndex: akEditorMenuZIndex,
|
|
118
133
|
fitHeight: 360,
|
|
119
134
|
fitWidth: 106,
|
|
120
|
-
shouldUseDefaultRole: true
|
|
135
|
+
shouldUseDefaultRole: true,
|
|
136
|
+
shouldFocusFirstItem: () => {
|
|
137
|
+
if (isOpenedByKeyboard) {
|
|
138
|
+
this.setState({
|
|
139
|
+
...this.state,
|
|
140
|
+
isOpenedByKeyboard: false
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
return isOpenedByKeyboard;
|
|
144
|
+
}
|
|
121
145
|
}, jsx(BlockTypeButton, {
|
|
122
146
|
isSmall: isSmall,
|
|
123
147
|
isReducedSpacing: isReducedSpacing,
|
|
@@ -125,6 +149,7 @@ class ToolbarBlockType extends React.PureComponent {
|
|
|
125
149
|
disabled: false,
|
|
126
150
|
title: blockTypeTitles[0],
|
|
127
151
|
onClick: this.handleTriggerClick,
|
|
152
|
+
onKeyDown: this.handleTriggerByKeyboard,
|
|
128
153
|
formatMessage: formatMessage,
|
|
129
154
|
"aria-expanded": active
|
|
130
155
|
}, longestDropdownMenuItem)), jsx("span", {
|
|
@@ -140,6 +165,7 @@ class ToolbarBlockType extends React.PureComponent {
|
|
|
140
165
|
disabled: true,
|
|
141
166
|
title: blockTypeTitles[0],
|
|
142
167
|
onClick: this.handleTriggerClick,
|
|
168
|
+
onKeyDown: this.handleTriggerByKeyboard,
|
|
143
169
|
formatMessage: formatMessage,
|
|
144
170
|
"aria-expanded": active
|
|
145
171
|
}, longestDropdownMenuItem), jsx("span", {
|