@atlaskit/editor-core 171.0.0 → 172.0.1
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 +96 -0
- package/codemods/172.0.0-transform-smartlinks-prop.ts +8 -0
- package/codemods/__tests__/rename-smartlinks-prop.ts +204 -0
- package/codemods/migrates/rename-smartlinks-prop.ts +56 -0
- package/dist/cjs/create-editor/ReactEditorView.js +13 -4
- package/dist/cjs/create-editor/create-plugins-list.js +21 -12
- package/dist/cjs/editor.js +8 -23
- package/dist/cjs/labs/next/internal/hooks/use-editor/index.js +6 -1
- package/dist/cjs/labs/next/presets/default.js +1 -1
- package/dist/cjs/nodeviews/context-adapter.js +2 -2
- package/dist/cjs/plugins/analytics/plugin.js +24 -11
- package/dist/cjs/plugins/base/index.js +3 -3
- package/dist/cjs/plugins/base/pm-plugins/disable-spell-checking.js +84 -0
- package/dist/cjs/plugins/card/index.js +1 -1
- package/dist/cjs/plugins/card/toolbar.js +11 -5
- package/dist/cjs/plugins/card/ui/EditLinkToolbar.js +5 -1
- package/dist/cjs/plugins/card/ui/LinkToolbarAppearance.js +7 -7
- package/dist/cjs/plugins/clipboard/pm-plugins/main.js +4 -2
- package/dist/cjs/plugins/code-block/actions.js +13 -0
- package/dist/cjs/plugins/code-block/index.js +7 -0
- package/dist/cjs/plugins/code-block/nodeviews/code-block.js +2 -4
- package/dist/cjs/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.js +132 -0
- package/dist/cjs/plugins/code-block/pm-plugins/main.js +1 -23
- package/dist/cjs/plugins/code-block/styles.js +3 -36
- package/dist/cjs/plugins/code-block/toolbar.js +9 -0
- package/dist/cjs/plugins/code-block/ui/class-names.js +1 -2
- package/dist/cjs/plugins/copy-button/commands.js +40 -20
- package/dist/cjs/plugins/copy-button/toolbar.js +51 -0
- package/dist/cjs/plugins/copy-button/utils.js +16 -38
- package/dist/cjs/plugins/expand/toolbar.js +8 -2
- package/dist/cjs/plugins/extension/toolbar.js +5 -1
- package/dist/cjs/plugins/extension/ui/Extension/Extension/styles.js +1 -1
- package/dist/cjs/plugins/extension/ui/Extension/InlineExtension/styles.js +1 -1
- package/dist/cjs/plugins/extension/ui/Extension/styles.js +2 -4
- package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +29 -18
- package/dist/cjs/plugins/feedback-dialog/index.js +2 -2
- package/dist/cjs/plugins/find-replace/ui/FindReplaceToolbarButton.js +0 -20
- package/dist/cjs/plugins/floating-toolbar/ui/DropdownMenu.js +7 -32
- package/dist/cjs/plugins/hyperlink/Toolbar.js +146 -135
- package/dist/cjs/plugins/hyperlink/index.js +4 -4
- package/dist/cjs/plugins/hyperlink/ui/EditorLinkPicker/index.js +50 -0
- package/dist/cjs/plugins/hyperlink/ui/EditorLinkPicker/useEscapeClickaway.js +38 -0
- package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +50 -5
- package/dist/cjs/plugins/indentation/commands/index.js +35 -7
- package/dist/cjs/plugins/indentation/commands/utils.js +11 -7
- package/dist/cjs/plugins/indentation/pm-plugins/keymap.js +5 -3
- package/dist/cjs/plugins/layout/toolbar.js +3 -1
- package/dist/cjs/plugins/media/toolbar/index.js +13 -5
- package/dist/cjs/plugins/mentions/analytics.js +5 -5
- package/dist/cjs/plugins/panel/toolbar.js +3 -3
- package/dist/cjs/plugins/paste/edge-cases/index.js +16 -3
- package/dist/cjs/plugins/paste/handlers.js +25 -2
- package/dist/cjs/plugins/paste/pm-plugins/analytics.js +16 -3
- package/dist/cjs/plugins/paste/pm-plugins/main.js +22 -3
- package/dist/cjs/plugins/status/analytics.js +3 -3
- package/dist/cjs/plugins/table/toolbar.js +2 -2
- package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/keymaps.js +43 -32
- package/dist/cjs/plugins/toolbar-lists-indentation/index.js +33 -13
- package/dist/cjs/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +122 -0
- package/dist/cjs/plugins/toolbar-lists-indentation/ui/Toolbar.js +18 -12
- package/dist/cjs/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +10 -10
- package/dist/cjs/plugins/toolbar-lists-indentation/ui/index.js +7 -1
- package/dist/cjs/plugins/toolbar-lists-indentation/ui/onItemActivated.js +40 -19
- package/dist/cjs/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +10 -0
- package/dist/cjs/types/browser.js +6 -0
- package/dist/cjs/ui/Addon/click-area-helper.js +40 -19
- package/dist/cjs/ui/Appearance/Comment/Comment.js +2 -2
- package/dist/cjs/ui/ContentStyles/index.js +1 -3
- package/dist/cjs/ui/DropList/index.js +215 -0
- package/dist/cjs/ui/Dropdown/index.js +2 -5
- package/dist/cjs/ui/DropdownMenu/index.js +140 -86
- package/dist/cjs/ui/ElementBrowser/components/ElementList/ElementList.js +25 -14
- package/dist/cjs/ui/ElementBrowser/components/ElementList/cellSizeAndPositionGetter.js +2 -2
- package/dist/cjs/ui/ElementBrowser/components/ElementList/utils.js +28 -1
- package/dist/cjs/ui/ElementBrowser/constants.js +2 -7
- package/dist/cjs/ui/Layer/index.js +245 -0
- package/dist/cjs/ui/Layer/internal/helpers.js +70 -0
- package/dist/cjs/ui/PortalProvider/index.js +7 -26
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/create-editor/ReactEditorView.js +15 -4
- package/dist/es2019/create-editor/create-plugins-list.js +21 -11
- package/dist/es2019/editor.js +9 -23
- package/dist/es2019/labs/next/internal/hooks/use-editor/index.js +6 -1
- package/dist/es2019/labs/next/presets/default.js +1 -1
- package/dist/es2019/nodeviews/context-adapter.js +2 -2
- package/dist/es2019/plugins/analytics/plugin.js +19 -4
- package/dist/es2019/plugins/base/index.js +3 -3
- package/dist/es2019/plugins/base/pm-plugins/disable-spell-checking.js +70 -0
- package/dist/es2019/plugins/card/index.js +1 -1
- package/dist/es2019/plugins/card/nodeviews/embedCard.js +1 -2
- package/dist/es2019/plugins/card/toolbar.js +10 -5
- package/dist/es2019/plugins/card/ui/EditLinkToolbar.js +5 -1
- package/dist/es2019/plugins/card/ui/LinkToolbarAppearance.js +7 -7
- package/dist/es2019/plugins/clipboard/pm-plugins/main.js +1 -2
- package/dist/es2019/plugins/code-block/actions.js +12 -0
- package/dist/es2019/plugins/code-block/index.js +4 -0
- package/dist/es2019/plugins/code-block/nodeviews/code-block.js +1 -1
- package/dist/es2019/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.js +112 -0
- package/dist/es2019/plugins/code-block/pm-plugins/main.js +1 -21
- package/dist/es2019/plugins/code-block/styles.js +2 -159
- package/dist/es2019/plugins/code-block/toolbar.js +8 -0
- package/dist/es2019/plugins/code-block/ui/class-names.js +1 -2
- package/dist/es2019/plugins/copy-button/commands.js +35 -15
- package/dist/es2019/plugins/copy-button/toolbar.js +29 -0
- package/dist/es2019/plugins/copy-button/utils.js +15 -27
- package/dist/es2019/plugins/expand/toolbar.js +4 -1
- package/dist/es2019/plugins/extension/toolbar.js +4 -1
- package/dist/es2019/plugins/extension/ui/Extension/Extension/styles.js +1 -1
- package/dist/es2019/plugins/extension/ui/Extension/InlineExtension/styles.js +1 -1
- package/dist/es2019/plugins/extension/ui/Extension/styles.js +1 -3
- package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +27 -15
- package/dist/es2019/plugins/feedback-dialog/index.js +1 -1
- package/dist/es2019/plugins/find-replace/ui/FindReplaceToolbarButton.js +0 -19
- package/dist/es2019/plugins/floating-toolbar/ui/DropdownMenu.js +14 -29
- package/dist/es2019/plugins/hyperlink/Toolbar.js +11 -5
- package/dist/es2019/plugins/hyperlink/index.js +4 -4
- package/dist/es2019/plugins/hyperlink/ui/EditorLinkPicker/index.js +24 -0
- package/dist/es2019/plugins/hyperlink/ui/EditorLinkPicker/useEscapeClickaway.js +28 -0
- package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +50 -9
- package/dist/es2019/plugins/indentation/commands/index.js +24 -9
- package/dist/es2019/plugins/indentation/commands/utils.js +8 -3
- package/dist/es2019/plugins/indentation/pm-plugins/keymap.js +5 -4
- package/dist/es2019/plugins/layout/toolbar.js +2 -1
- package/dist/es2019/plugins/media/toolbar/index.js +10 -3
- package/dist/es2019/plugins/mentions/analytics.js +1 -1
- package/dist/es2019/plugins/panel/toolbar.js +1 -1
- package/dist/es2019/plugins/paste/edge-cases/index.js +15 -3
- package/dist/es2019/plugins/paste/handlers.js +27 -2
- package/dist/es2019/plugins/paste/pm-plugins/analytics.js +12 -3
- package/dist/es2019/plugins/paste/pm-plugins/main.js +24 -4
- package/dist/es2019/plugins/status/analytics.js +1 -1
- package/dist/es2019/plugins/table/toolbar.js +1 -1
- package/dist/es2019/plugins/table/ui/common-styles.js +2 -0
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/keymaps.js +10 -10
- package/dist/es2019/plugins/toolbar-lists-indentation/index.js +23 -4
- package/dist/es2019/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +104 -0
- package/dist/es2019/plugins/toolbar-lists-indentation/ui/Toolbar.js +18 -12
- package/dist/es2019/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +10 -10
- package/dist/es2019/plugins/toolbar-lists-indentation/ui/index.js +7 -1
- package/dist/es2019/plugins/toolbar-lists-indentation/ui/onItemActivated.js +38 -16
- package/dist/es2019/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +9 -0
- package/dist/es2019/types/browser.js +2 -0
- package/dist/es2019/ui/Addon/click-area-helper.js +37 -18
- package/dist/es2019/ui/Appearance/Comment/Comment.js +2 -2
- package/dist/es2019/ui/ContentStyles/index.js +5 -9
- package/dist/es2019/ui/DropList/index.js +186 -0
- package/dist/es2019/ui/Dropdown/index.js +2 -6
- package/dist/es2019/ui/DropdownMenu/index.js +124 -75
- package/dist/es2019/ui/ElementBrowser/components/ElementList/ElementList.js +11 -22
- package/dist/es2019/ui/ElementBrowser/components/ElementList/cellSizeAndPositionGetter.js +3 -3
- package/dist/es2019/ui/ElementBrowser/components/ElementList/utils.js +26 -2
- package/dist/es2019/ui/ElementBrowser/constants.js +1 -4
- package/dist/es2019/ui/Layer/index.js +195 -0
- package/dist/es2019/ui/Layer/internal/helpers.js +62 -0
- package/dist/es2019/ui/PortalProvider/index.js +5 -23
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/create-editor/ReactEditorView.js +13 -4
- package/dist/esm/create-editor/create-plugins-list.js +21 -12
- package/dist/esm/editor.js +9 -23
- package/dist/esm/labs/next/internal/hooks/use-editor/index.js +6 -1
- package/dist/esm/labs/next/presets/default.js +1 -1
- package/dist/esm/nodeviews/context-adapter.js +2 -2
- package/dist/esm/plugins/analytics/plugin.js +24 -11
- package/dist/esm/plugins/base/index.js +3 -3
- package/dist/esm/plugins/base/pm-plugins/disable-spell-checking.js +72 -0
- package/dist/esm/plugins/card/index.js +1 -1
- package/dist/esm/plugins/card/nodeviews/embedCard.js +1 -2
- package/dist/esm/plugins/card/toolbar.js +11 -5
- package/dist/esm/plugins/card/ui/EditLinkToolbar.js +5 -1
- package/dist/esm/plugins/card/ui/LinkToolbarAppearance.js +7 -7
- package/dist/esm/plugins/clipboard/pm-plugins/main.js +1 -2
- package/dist/esm/plugins/code-block/actions.js +12 -0
- package/dist/esm/plugins/code-block/index.js +6 -0
- package/dist/esm/plugins/code-block/nodeviews/code-block.js +2 -4
- package/dist/esm/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.js +112 -0
- package/dist/esm/plugins/code-block/pm-plugins/main.js +1 -20
- package/dist/esm/plugins/code-block/styles.js +4 -32
- package/dist/esm/plugins/code-block/toolbar.js +8 -0
- package/dist/esm/plugins/code-block/ui/class-names.js +1 -2
- package/dist/esm/plugins/copy-button/commands.js +35 -15
- package/dist/esm/plugins/copy-button/toolbar.js +31 -0
- package/dist/esm/plugins/copy-button/utils.js +14 -29
- package/dist/esm/plugins/expand/toolbar.js +6 -2
- package/dist/esm/plugins/extension/toolbar.js +4 -1
- package/dist/esm/plugins/extension/ui/Extension/Extension/styles.js +1 -1
- package/dist/esm/plugins/extension/ui/Extension/InlineExtension/styles.js +1 -1
- package/dist/esm/plugins/extension/ui/Extension/styles.js +3 -4
- package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +28 -16
- package/dist/esm/plugins/feedback-dialog/index.js +1 -1
- package/dist/esm/plugins/find-replace/ui/FindReplaceToolbarButton.js +0 -21
- package/dist/esm/plugins/floating-toolbar/ui/DropdownMenu.js +8 -27
- package/dist/esm/plugins/hyperlink/Toolbar.js +144 -135
- package/dist/esm/plugins/hyperlink/index.js +4 -4
- package/dist/esm/plugins/hyperlink/ui/EditorLinkPicker/index.js +26 -0
- package/dist/esm/plugins/hyperlink/ui/EditorLinkPicker/useEscapeClickaway.js +28 -0
- package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +46 -5
- package/dist/esm/plugins/indentation/commands/index.js +30 -9
- package/dist/esm/plugins/indentation/commands/utils.js +12 -8
- package/dist/esm/plugins/indentation/pm-plugins/keymap.js +5 -4
- package/dist/esm/plugins/layout/toolbar.js +2 -1
- package/dist/esm/plugins/media/toolbar/index.js +12 -5
- package/dist/esm/plugins/mentions/analytics.js +1 -1
- package/dist/esm/plugins/panel/toolbar.js +1 -1
- package/dist/esm/plugins/paste/edge-cases/index.js +15 -3
- package/dist/esm/plugins/paste/handlers.js +23 -2
- package/dist/esm/plugins/paste/pm-plugins/analytics.js +13 -3
- package/dist/esm/plugins/paste/pm-plugins/main.js +23 -4
- package/dist/esm/plugins/status/analytics.js +1 -1
- package/dist/esm/plugins/table/toolbar.js +1 -1
- package/dist/esm/plugins/table/ui/common-styles.js +1 -1
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/keymaps.js +37 -31
- package/dist/esm/plugins/toolbar-lists-indentation/index.js +32 -13
- package/dist/esm/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +105 -0
- package/dist/esm/plugins/toolbar-lists-indentation/ui/Toolbar.js +18 -12
- package/dist/esm/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +10 -10
- package/dist/esm/plugins/toolbar-lists-indentation/ui/index.js +7 -1
- package/dist/esm/plugins/toolbar-lists-indentation/ui/onItemActivated.js +38 -20
- package/dist/esm/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +9 -0
- package/dist/esm/types/browser.js +2 -0
- package/dist/esm/ui/Addon/click-area-helper.js +37 -18
- package/dist/esm/ui/Appearance/Comment/Comment.js +2 -2
- package/dist/esm/ui/ContentStyles/index.js +2 -4
- package/dist/esm/ui/DropList/index.js +203 -0
- package/dist/esm/ui/Dropdown/index.js +2 -6
- package/dist/esm/ui/DropdownMenu/index.js +134 -88
- package/dist/esm/ui/ElementBrowser/components/ElementList/ElementList.js +27 -17
- package/dist/esm/ui/ElementBrowser/components/ElementList/cellSizeAndPositionGetter.js +3 -3
- package/dist/esm/ui/ElementBrowser/components/ElementList/utils.js +26 -2
- package/dist/esm/ui/ElementBrowser/constants.js +1 -4
- package/dist/esm/ui/Layer/index.js +228 -0
- package/dist/esm/ui/Layer/internal/helpers.js +62 -0
- package/dist/esm/ui/PortalProvider/index.js +7 -26
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/labs/next/presets/default.d.ts +2 -0
- package/dist/types/plugins/analytics/plugin.d.ts +5 -1
- package/dist/types/plugins/analytics/types/cut-copy-events.d.ts +2 -0
- package/dist/types/plugins/analytics/types/general-events.d.ts +1 -0
- package/dist/types/plugins/analytics/types/paste-events.d.ts +1 -0
- package/dist/types/plugins/base/index.d.ts +1 -1
- package/dist/types/plugins/base/pm-plugins/{fix-chrome-spell-checking.d.ts → disable-spell-checking.d.ts} +0 -0
- package/dist/types/plugins/card/index.d.ts +2 -7
- package/dist/types/plugins/card/nodeviews/genericCard.d.ts +2 -1
- package/dist/types/plugins/card/toolbar.d.ts +3 -5
- package/dist/types/plugins/card/types.d.ts +2 -0
- package/dist/types/plugins/card/ui/EditLinkToolbar.d.ts +4 -1
- package/dist/types/plugins/card/ui/LinkToolbarAppearance.d.ts +2 -1
- package/dist/types/plugins/clipboard/pm-plugins/main.d.ts +3 -0
- package/dist/types/plugins/code-block/nodeviews/code-block.d.ts +1 -1
- package/dist/types/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.d.ts +11 -0
- package/dist/types/plugins/code-block/styles.d.ts +0 -1
- package/dist/types/plugins/code-block/ui/class-names.d.ts +0 -1
- package/dist/types/plugins/copy-button/commands.d.ts +2 -2
- package/dist/types/plugins/copy-button/toolbar.d.ts +7 -0
- package/dist/types/plugins/copy-button/utils.d.ts +7 -6
- package/dist/types/plugins/floating-toolbar/types.d.ts +1 -2
- package/dist/types/plugins/hyperlink/Toolbar.d.ts +2 -1
- package/dist/types/plugins/hyperlink/index.d.ts +2 -2
- package/dist/types/plugins/hyperlink/types.d.ts +30 -0
- package/dist/types/plugins/hyperlink/ui/EditorLinkPicker/index.d.ts +7 -0
- package/dist/types/plugins/hyperlink/ui/EditorLinkPicker/useEscapeClickaway.d.ts +2 -0
- package/dist/types/plugins/hyperlink/ui/HyperlinkAddToolbar/index.d.ts +4 -3
- package/dist/types/plugins/indentation/commands/index.d.ts +6 -2
- package/dist/types/plugins/indentation/commands/utils.d.ts +8 -2
- package/dist/types/plugins/paste/edge-cases/index.d.ts +3 -2
- package/dist/types/plugins/paste/handlers.d.ts +1 -0
- package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +7 -1
- package/dist/types/plugins/tasks-and-decisions/pm-plugins/keymaps.d.ts +5 -0
- package/dist/types/plugins/toolbar-lists-indentation/index.d.ts +2 -1
- package/dist/types/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.d.ts +14 -0
- package/dist/types/plugins/toolbar-lists-indentation/types.d.ts +2 -0
- package/dist/types/plugins/toolbar-lists-indentation/ui/index.d.ts +2 -0
- package/dist/types/types/browser.d.ts +10 -0
- package/dist/types/types/editor-props.d.ts +6 -5
- package/dist/types/types/feature-flags.d.ts +29 -24
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/ui/Addon/click-area-helper.d.ts +10 -0
- package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +2 -2
- package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
- package/dist/types/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types/ui/DropList/index.d.ts +22 -0
- package/dist/types/ui/Dropdown/index.d.ts +2 -1
- package/dist/types/ui/DropdownMenu/index.d.ts +0 -1
- package/dist/types/ui/ElementBrowser/components/ElementList/cellSizeAndPositionGetter.d.ts +1 -1
- package/dist/types/ui/ElementBrowser/components/ElementList/utils.d.ts +1 -0
- package/dist/types/ui/ElementBrowser/constants.d.ts +1 -3
- package/dist/types/ui/Layer/index.d.ts +47 -0
- package/dist/types/ui/Layer/internal/helpers.d.ts +5 -0
- package/package.json +23 -18
- package/dist/cjs/plugins/base/pm-plugins/fix-chrome-spell-checking.js +0 -37
- package/dist/cjs/plugins/code-block/nodeviews/highlighting-code-block.js +0 -195
- package/dist/cjs/utils/check-if-mobile-bridge.js +0 -19
- package/dist/es2019/plugins/base/pm-plugins/fix-chrome-spell-checking.js +0 -22
- package/dist/es2019/plugins/code-block/nodeviews/highlighting-code-block.js +0 -152
- package/dist/es2019/utils/check-if-mobile-bridge.js +0 -12
- package/dist/esm/plugins/base/pm-plugins/fix-chrome-spell-checking.js +0 -24
- package/dist/esm/plugins/code-block/nodeviews/highlighting-code-block.js +0 -178
- package/dist/esm/utils/check-if-mobile-bridge.js +0 -12
- package/dist/types/plugins/code-block/nodeviews/highlighting-code-block.d.ts +0 -48
- package/dist/types/utils/check-if-mobile-bridge.d.ts +0 -1
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import { Component } from 'react';
|
|
5
|
+
import { css, jsx } from '@emotion/react';
|
|
6
|
+
import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
7
|
+
import Layer from '../Layer';
|
|
8
|
+
import { borderRadius, gridSize } from '@atlaskit/theme/constants';
|
|
9
|
+
import { N0, DN50, DN600, N50A, N60A, N900 } from '@atlaskit/theme/colors';
|
|
10
|
+
import { themed } from '@atlaskit/theme/components';
|
|
11
|
+
import { token } from '@atlaskit/tokens';
|
|
12
|
+
const packageName = "@atlaskit/editor-core";
|
|
13
|
+
const packageVersion = "172.0.1";
|
|
14
|
+
const halfFocusRing = 1;
|
|
15
|
+
const dropOffset = `0, ${gridSize()}px`;
|
|
16
|
+
|
|
17
|
+
class DropList extends Component {
|
|
18
|
+
constructor(...args) {
|
|
19
|
+
super(...args);
|
|
20
|
+
|
|
21
|
+
_defineProperty(this, "wrapperStyles", css`
|
|
22
|
+
${this.props.shouldFitContainer ? 'display: block; flex: 1 1 auto;' : 'display: inline-flex;'}
|
|
23
|
+
transition-duration: 0.2s;
|
|
24
|
+
transition: box-shadow 0.15s cubic-bezier(0.47, 0.03, 0.49, 1.38);
|
|
25
|
+
`);
|
|
26
|
+
|
|
27
|
+
_defineProperty(this, "triggerStyles", css`
|
|
28
|
+
transition-duration: 0.2s;
|
|
29
|
+
transition: box-shadow 0.15s cubic-bezier(0.47, 0.03, 0.49, 1.38);
|
|
30
|
+
${this.props.shouldFitContainer ? 'display: block; box-sizing: border-box;' : 'display: inline-flex;'}
|
|
31
|
+
`);
|
|
32
|
+
|
|
33
|
+
_defineProperty(this, "menuWrapper", theme => {
|
|
34
|
+
return css`
|
|
35
|
+
color: ${themed({
|
|
36
|
+
light: token('color.text', N900),
|
|
37
|
+
dark: token('color.text', DN600)
|
|
38
|
+
})(theme)};
|
|
39
|
+
background-color: ${themed({
|
|
40
|
+
light: token('elevation.surface.overlay', N0),
|
|
41
|
+
dark: token('elevation.surface.overlay', DN50)
|
|
42
|
+
})(theme)};
|
|
43
|
+
border-radius: ${borderRadius()}px;
|
|
44
|
+
box-shadow: 0 ${gridSize() / 2}px ${gridSize()}px -${gridSize() / 4}px ${N50A},
|
|
45
|
+
0 0 1px ${N60A};
|
|
46
|
+
box-sizing: border-box;
|
|
47
|
+
overflow: auto;
|
|
48
|
+
padding: ${gridSize() / 2}px 0;
|
|
49
|
+
max-height: 90vh;
|
|
50
|
+
`;
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
_defineProperty(this, "componentDidMount", () => {
|
|
54
|
+
this.setContentWidth(); // We use a captured event here to avoid a radio or checkbox dropdown item firing its
|
|
55
|
+
// click event first, which would cause a re-render of the element and prevent DropList
|
|
56
|
+
// from detecting the actual source of this original click event.
|
|
57
|
+
|
|
58
|
+
document.addEventListener('click', this.handleClickOutside, true);
|
|
59
|
+
document.addEventListener('keydown', this.handleEsc);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
_defineProperty(this, "componentDidUpdate", () => {
|
|
63
|
+
if (this.props.isOpen) {
|
|
64
|
+
this.setContentWidth();
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
_defineProperty(this, "componentWillUnmount", () => {
|
|
69
|
+
document.removeEventListener('click', this.handleClickOutside, true);
|
|
70
|
+
document.removeEventListener('keydown', this.handleEsc);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
_defineProperty(this, "setContentWidth", () => {
|
|
74
|
+
const {
|
|
75
|
+
dropContentRef,
|
|
76
|
+
triggerRef
|
|
77
|
+
} = this;
|
|
78
|
+
const {
|
|
79
|
+
shouldFitContainer
|
|
80
|
+
} = this.props; // We need to manually set the content width to match the trigger width
|
|
81
|
+
|
|
82
|
+
if (shouldFitContainer && dropContentRef && triggerRef) {
|
|
83
|
+
dropContentRef.style.width = `${triggerRef.offsetWidth - halfFocusRing * 2}px`;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
_defineProperty(this, "handleEsc", event => {
|
|
88
|
+
if ((event.key === 'Escape' || event.key === 'Esc') && this.props.isOpen) {
|
|
89
|
+
this.close(event);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
_defineProperty(this, "handleClickOutside", event => {
|
|
94
|
+
if (this.props.isOpen) {
|
|
95
|
+
if (event.target instanceof Node) {
|
|
96
|
+
// Rather than check for the target within the entire DropList, we specify the trigger/content.
|
|
97
|
+
// This aids with future effort in scroll-locking DropList when isMenuFixed is enabled; the scroll
|
|
98
|
+
// blanket which stretches to the viewport should not stop 'close' from being triggered.
|
|
99
|
+
const withinTrigger = this.triggerRef && this.triggerRef.contains(event.target);
|
|
100
|
+
const withinContent = this.dropContentRef && this.dropContentRef.contains(event.target);
|
|
101
|
+
|
|
102
|
+
if (!withinTrigger && !withinContent) {
|
|
103
|
+
this.close(event);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
_defineProperty(this, "close", event => {
|
|
110
|
+
if (this.props.onOpenChange) {
|
|
111
|
+
this.props.onOpenChange({
|
|
112
|
+
isOpen: false,
|
|
113
|
+
event
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
_defineProperty(this, "handleContentRef", ref => {
|
|
119
|
+
this.dropContentRef = ref; // If the dropdown has just been opened, we focus on the containing element so the
|
|
120
|
+
// user can tab to the first dropdown item. We will only receive this ref if isOpen
|
|
121
|
+
// is true or null, so no need to check for truthiness here.
|
|
122
|
+
|
|
123
|
+
if (ref) {
|
|
124
|
+
ref.focus();
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
_defineProperty(this, "handleTriggerRef", ref => {
|
|
129
|
+
this.triggerRef = ref;
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
getChildContext() {
|
|
134
|
+
return {
|
|
135
|
+
shouldAllowMultilineItems: false
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
render() {
|
|
140
|
+
const {
|
|
141
|
+
children,
|
|
142
|
+
isOpen,
|
|
143
|
+
position,
|
|
144
|
+
trigger,
|
|
145
|
+
onPositioned,
|
|
146
|
+
testId
|
|
147
|
+
} = this.props;
|
|
148
|
+
let layerContent = isOpen ? jsx("div", {
|
|
149
|
+
css: theme => this.menuWrapper({
|
|
150
|
+
theme: theme
|
|
151
|
+
}),
|
|
152
|
+
"data-role": "droplistContent",
|
|
153
|
+
"data-testid": testId && `${testId}--content`,
|
|
154
|
+
ref: this.handleContentRef
|
|
155
|
+
}, children) : null;
|
|
156
|
+
return jsx("div", {
|
|
157
|
+
css: this.wrapperStyles
|
|
158
|
+
}, jsx(Layer, {
|
|
159
|
+
content: layerContent,
|
|
160
|
+
offset: dropOffset,
|
|
161
|
+
position: position,
|
|
162
|
+
onPositioned: onPositioned
|
|
163
|
+
}, jsx("div", {
|
|
164
|
+
css: this.triggerStyles,
|
|
165
|
+
ref: this.handleTriggerRef
|
|
166
|
+
}, trigger)));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
|
|
172
|
+
export default withAnalyticsContext({
|
|
173
|
+
componentName: 'droplist',
|
|
174
|
+
packageName,
|
|
175
|
+
packageVersion
|
|
176
|
+
})(withAnalyticsEvents({
|
|
177
|
+
onOpenChange: createAndFireEventOnAtlaskit({
|
|
178
|
+
action: 'toggled',
|
|
179
|
+
actionSubject: 'droplist',
|
|
180
|
+
attributes: {
|
|
181
|
+
componentName: 'droplist',
|
|
182
|
+
packageName,
|
|
183
|
+
packageVersion
|
|
184
|
+
}
|
|
185
|
+
})
|
|
186
|
+
})(DropList));
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { PureComponent } from 'react';
|
|
4
|
-
|
|
5
|
-
import DropdownList from '@atlaskit/droplist';
|
|
3
|
+
import { PureComponent } from 'react';
|
|
4
|
+
import DropdownList from '../DropList';
|
|
6
5
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
7
6
|
import withOuterListeners from '../with-outer-listeners';
|
|
8
7
|
|
|
@@ -63,12 +62,9 @@ export class Dropdown extends PureComponent {
|
|
|
63
62
|
minWidth: fitWidth || 0
|
|
64
63
|
}
|
|
65
64
|
}, /*#__PURE__*/React.createElement(DropdownList, {
|
|
66
|
-
disabled: true,
|
|
67
65
|
isOpen: true,
|
|
68
66
|
onOpenChange: onOpenChange,
|
|
69
|
-
appearance: "tall",
|
|
70
67
|
position: popupPlacement.join(' '),
|
|
71
|
-
shouldFlip: false,
|
|
72
68
|
shouldFitContainer: true
|
|
73
69
|
}, children)));
|
|
74
70
|
}
|
|
@@ -1,42 +1,63 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
3
|
|
|
3
4
|
/** @jsx jsx */
|
|
4
|
-
import { PureComponent } from 'react';
|
|
5
|
-
import { css, jsx } from '@emotion/react';
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
import Item, { ItemGroup } from '@atlaskit/item';
|
|
5
|
+
import React, { PureComponent } from 'react';
|
|
6
|
+
import { css, jsx } from '@emotion/react';
|
|
7
|
+
import DropList from '../DropList';
|
|
8
|
+
import { CustomItem, MenuGroup } from '@atlaskit/menu';
|
|
10
9
|
import Tooltip from '@atlaskit/tooltip';
|
|
11
10
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
12
11
|
import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
13
12
|
import withOuterListeners from '../with-outer-listeners';
|
|
13
|
+
import { DN600, DN80, N70, N900 } from '@atlaskit/theme/colors';
|
|
14
|
+
import { themed } from '@atlaskit/theme/components';
|
|
15
|
+
import { token } from '@atlaskit/tokens';
|
|
14
16
|
const wrapper = css`
|
|
15
17
|
/* tooltip in ToolbarButton is display:block */
|
|
16
18
|
& > div > div {
|
|
17
19
|
display: flex;
|
|
18
20
|
}
|
|
19
21
|
`;
|
|
20
|
-
const DropListWithOutsideListeners = withOuterListeners(DropList);
|
|
21
|
-
/**
|
|
22
|
-
* Hack for item to imitate old dropdown-menu selected styles
|
|
23
|
-
*/
|
|
24
|
-
// TODO: https://product-fabric.atlassian.net/browse/DSP-4500
|
|
25
|
-
|
|
26
|
-
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
27
22
|
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
const buttonStyles = isActive => theme => {
|
|
24
|
+
if (isActive) {
|
|
25
|
+
/**
|
|
26
|
+
* Hack for item to imitate old dropdown-menu selected styles
|
|
27
|
+
*/
|
|
28
|
+
// TODO: https://product-fabric.atlassian.net/browse/DSP-4500
|
|
29
|
+
|
|
30
|
+
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
31
|
+
return css`
|
|
32
|
+
> span,
|
|
33
|
+
> span:hover {
|
|
34
|
+
background: #6c798f;
|
|
35
|
+
color: #fff;
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
} else {
|
|
39
|
+
return css`
|
|
40
|
+
> span:hover[aria-disabled='false'] {
|
|
41
|
+
color: ${themed({
|
|
42
|
+
light: token('color.text', N900),
|
|
43
|
+
dark: token('color.text', DN600)
|
|
44
|
+
})(theme)};
|
|
45
|
+
background-color: ${themed({
|
|
46
|
+
light: token('color.background.neutral.subtle.hovered', 'rgb(244, 245, 247)'),
|
|
47
|
+
dark: token('color.background.neutral.subtle.hovered', 'rgb(59, 71, 92)')
|
|
48
|
+
})(theme)};
|
|
49
|
+
}
|
|
50
|
+
> span[aria-disabled='true'] {
|
|
51
|
+
color: ${themed({
|
|
52
|
+
light: token('color.text.disabled', N70),
|
|
53
|
+
dark: token('color.text.disabled', DN80)
|
|
54
|
+
})(theme)};
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
33
57
|
}
|
|
34
|
-
|
|
35
|
-
/* eslint-enable @atlaskit/design-system/ensure-design-token-usage */
|
|
58
|
+
};
|
|
36
59
|
|
|
37
|
-
const
|
|
38
|
-
margin-left: 8px;
|
|
39
|
-
`;
|
|
60
|
+
const DropListWithOutsideListeners = withOuterListeners(DropList);
|
|
40
61
|
/**
|
|
41
62
|
* Wrapper around @atlaskit/droplist which uses Popup and Portal to render
|
|
42
63
|
* dropdown-menu outside of "overflow: hidden" containers when needed.
|
|
@@ -79,56 +100,6 @@ export default class DropdownMenuWrapper extends PureComponent {
|
|
|
79
100
|
});
|
|
80
101
|
}
|
|
81
102
|
|
|
82
|
-
renderItem(item) {
|
|
83
|
-
const {
|
|
84
|
-
onItemActivated,
|
|
85
|
-
onMouseEnter,
|
|
86
|
-
onMouseLeave,
|
|
87
|
-
shouldUseDefaultRole
|
|
88
|
-
} = this.props; // onClick and value.name are the action indicators in the handlers
|
|
89
|
-
// If neither are present, don't wrap in an Item.
|
|
90
|
-
|
|
91
|
-
if (!item.onClick && !item.value && !item.value.name) {
|
|
92
|
-
return jsx("span", {
|
|
93
|
-
key: String(item.content)
|
|
94
|
-
}, item.content);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const dropListItem = jsx("div", {
|
|
98
|
-
css: item.isActive ? itemWrapper : '',
|
|
99
|
-
key: item.key || item.content
|
|
100
|
-
}, jsx(Item, {
|
|
101
|
-
role: shouldUseDefaultRole ? 'button' : 'menuitem',
|
|
102
|
-
elemBefore: item.elemBefore,
|
|
103
|
-
elemAfter: item.elemAfter,
|
|
104
|
-
isDisabled: item.isDisabled,
|
|
105
|
-
onClick: () => onItemActivated && onItemActivated({
|
|
106
|
-
item
|
|
107
|
-
}),
|
|
108
|
-
onMouseEnter: () => onMouseEnter && onMouseEnter({
|
|
109
|
-
item
|
|
110
|
-
}),
|
|
111
|
-
onMouseLeave: () => onMouseLeave && onMouseLeave({
|
|
112
|
-
item
|
|
113
|
-
}),
|
|
114
|
-
className: item.className,
|
|
115
|
-
"aria-label": item.label || String(item.content),
|
|
116
|
-
"aria-pressed": shouldUseDefaultRole ? item.isActive : undefined
|
|
117
|
-
}, jsx("span", {
|
|
118
|
-
css: !!item.elemBefore ? itemContentWrapper : ''
|
|
119
|
-
}, item.content)));
|
|
120
|
-
|
|
121
|
-
if (item.tooltipDescription) {
|
|
122
|
-
return jsx(Tooltip, {
|
|
123
|
-
key: item.key || item.content,
|
|
124
|
-
content: item.tooltipDescription,
|
|
125
|
-
position: item.tooltipPosition
|
|
126
|
-
}, dropListItem);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return dropListItem;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
103
|
renderDropdownMenu() {
|
|
133
104
|
const {
|
|
134
105
|
target,
|
|
@@ -170,10 +141,21 @@ export default class DropdownMenuWrapper extends PureComponent {
|
|
|
170
141
|
height: 0,
|
|
171
142
|
minWidth: fitWidth || 0
|
|
172
143
|
}
|
|
173
|
-
}), items.map((group, index) => jsx(
|
|
144
|
+
}), items.map((group, index) => jsx(MenuGroup, {
|
|
174
145
|
key: index,
|
|
175
146
|
role: shouldUseDefaultRole ? 'group' : 'menu'
|
|
176
|
-
}, group.items.map(item =>
|
|
147
|
+
}, group.items.map(item => {
|
|
148
|
+
var _item$key;
|
|
149
|
+
|
|
150
|
+
return jsx(DropdownMenuItem, {
|
|
151
|
+
key: (_item$key = item.key) !== null && _item$key !== void 0 ? _item$key : String(item.content),
|
|
152
|
+
item: item,
|
|
153
|
+
onItemActivated: this.props.onItemActivated,
|
|
154
|
+
shouldUseDefaultRole: this.props.shouldUseDefaultRole,
|
|
155
|
+
onMouseEnter: this.props.onMouseEnter,
|
|
156
|
+
onMouseLeave: this.props.onMouseLeave
|
|
157
|
+
});
|
|
158
|
+
})))));
|
|
177
159
|
}
|
|
178
160
|
|
|
179
161
|
render() {
|
|
@@ -188,4 +170,71 @@ export default class DropdownMenuWrapper extends PureComponent {
|
|
|
188
170
|
}, children), isOpen ? this.renderDropdownMenu() : null);
|
|
189
171
|
}
|
|
190
172
|
|
|
173
|
+
}
|
|
174
|
+
const DropdownMenuItemCustomComponent = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
175
|
+
const {
|
|
176
|
+
children,
|
|
177
|
+
...rest
|
|
178
|
+
} = props;
|
|
179
|
+
return jsx("span", _extends({
|
|
180
|
+
ref: ref
|
|
181
|
+
}, rest), children);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
function DropdownMenuItem({
|
|
185
|
+
item,
|
|
186
|
+
onItemActivated,
|
|
187
|
+
shouldUseDefaultRole,
|
|
188
|
+
onMouseEnter,
|
|
189
|
+
onMouseLeave
|
|
190
|
+
}) {
|
|
191
|
+
var _item$key2;
|
|
192
|
+
|
|
193
|
+
// onClick and value.name are the action indicators in the handlers
|
|
194
|
+
// If neither are present, don't wrap in an Item.
|
|
195
|
+
if (!item.onClick && !(item.value && item.value.name)) {
|
|
196
|
+
return jsx("span", {
|
|
197
|
+
key: String(item.content)
|
|
198
|
+
}, item.content);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const dropListItem = jsx("div", {
|
|
202
|
+
css: theme => buttonStyles(item.isActive)({
|
|
203
|
+
theme
|
|
204
|
+
})
|
|
205
|
+
}, jsx(CustomItem, {
|
|
206
|
+
item: item,
|
|
207
|
+
key: (_item$key2 = item.key) !== null && _item$key2 !== void 0 ? _item$key2 : String(item.content),
|
|
208
|
+
role: shouldUseDefaultRole ? 'button' : 'menuitem',
|
|
209
|
+
iconBefore: item.elemBefore,
|
|
210
|
+
iconAfter: item.elemAfter,
|
|
211
|
+
isDisabled: item.isDisabled,
|
|
212
|
+
onClick: () => onItemActivated && onItemActivated({
|
|
213
|
+
item
|
|
214
|
+
}),
|
|
215
|
+
"aria-label": item['aria-label'] || String(item.content),
|
|
216
|
+
"aria-pressed": shouldUseDefaultRole ? item.isActive : undefined,
|
|
217
|
+
onMouseDown: e => {
|
|
218
|
+
e.preventDefault();
|
|
219
|
+
},
|
|
220
|
+
component: DropdownMenuItemCustomComponent,
|
|
221
|
+
onMouseEnter: () => onMouseEnter && onMouseEnter({
|
|
222
|
+
item
|
|
223
|
+
}),
|
|
224
|
+
onMouseLeave: () => onMouseLeave && onMouseLeave({
|
|
225
|
+
item
|
|
226
|
+
})
|
|
227
|
+
}, item.content));
|
|
228
|
+
|
|
229
|
+
if (item.tooltipDescription) {
|
|
230
|
+
var _item$key3;
|
|
231
|
+
|
|
232
|
+
return jsx(Tooltip, {
|
|
233
|
+
key: (_item$key3 = item.key) !== null && _item$key3 !== void 0 ? _item$key3 : String(item.content),
|
|
234
|
+
content: item.tooltipDescription,
|
|
235
|
+
position: item.tooltipPosition
|
|
236
|
+
}, dropListItem);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return dropListItem;
|
|
191
240
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
import React, { Fragment, memo, useCallback, useEffect, useMemo } from 'react';
|
|
4
|
+
import React, { Fragment, memo, useCallback, useEffect, useMemo, useState } from 'react';
|
|
5
5
|
import { css, jsx } from '@emotion/react';
|
|
6
6
|
import { AutoSizer } from 'react-virtualized/dist/commonjs/AutoSizer';
|
|
7
7
|
import { Collection } from 'react-virtualized/dist/commonjs/Collection';
|
|
@@ -15,13 +15,13 @@ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, fireAnalyticsEvent } from '../../..
|
|
|
15
15
|
import IconFallback from '../../../../plugins/quick-insert/assets/fallback';
|
|
16
16
|
import { itemIcon } from '../../../../plugins/type-ahead/ui/TypeAheadListItem';
|
|
17
17
|
import { shortcutStyle } from '../../../styles';
|
|
18
|
-
import { ELEMENT_LIST_PADDING,
|
|
18
|
+
import { ELEMENT_LIST_PADDING, SCROLLBAR_WIDTH } from '../../constants';
|
|
19
19
|
import useContainerWidth from '../../hooks/use-container-width';
|
|
20
20
|
import useFocus from '../../hooks/use-focus';
|
|
21
21
|
import { Modes } from '../../types';
|
|
22
22
|
import cellSizeAndPositionGetter from './cellSizeAndPositionGetter';
|
|
23
23
|
import EmptyState from './EmptyState';
|
|
24
|
-
import { getColumnCount } from './utils';
|
|
24
|
+
import { getColumnCount, getScrollbarWidth } from './utils';
|
|
25
25
|
|
|
26
26
|
function ElementList({
|
|
27
27
|
items,
|
|
@@ -39,6 +39,7 @@ function ElementList({
|
|
|
39
39
|
containerWidth,
|
|
40
40
|
ContainerWidthMonitor
|
|
41
41
|
} = useContainerWidth();
|
|
42
|
+
const [scrollbarWidth, setScrollbarWidth] = useState(SCROLLBAR_WIDTH);
|
|
42
43
|
const fullMode = mode === Modes.full;
|
|
43
44
|
useEffect(() => {
|
|
44
45
|
/**
|
|
@@ -47,8 +48,13 @@ function ElementList({
|
|
|
47
48
|
**/
|
|
48
49
|
if (fullMode && containerWidth > 0) {
|
|
49
50
|
setColumnCount(getColumnCount(containerWidth));
|
|
51
|
+
const updatedScrollbarWidth = getScrollbarWidth();
|
|
52
|
+
|
|
53
|
+
if (updatedScrollbarWidth > 0) {
|
|
54
|
+
setScrollbarWidth(updatedScrollbarWidth);
|
|
55
|
+
}
|
|
50
56
|
}
|
|
51
|
-
}, [fullMode, containerWidth, setColumnCount]);
|
|
57
|
+
}, [fullMode, containerWidth, setColumnCount, scrollbarWidth]);
|
|
52
58
|
const onExternalLinkClick = useCallback(() => {
|
|
53
59
|
fireAnalyticsEvent(createAnalyticsEvent)({
|
|
54
60
|
payload: {
|
|
@@ -96,7 +102,7 @@ function ElementList({
|
|
|
96
102
|
}) => jsx(Collection, {
|
|
97
103
|
cellCount: items.length,
|
|
98
104
|
cellRenderer: cellRenderer,
|
|
99
|
-
cellSizeAndPositionGetter: cellSizeAndPositionGetter(containerWidth),
|
|
105
|
+
cellSizeAndPositionGetter: cellSizeAndPositionGetter(containerWidth - ELEMENT_LIST_PADDING * 2, scrollbarWidth),
|
|
100
106
|
height: height,
|
|
101
107
|
width: containerWidth - ELEMENT_LIST_PADDING * 2 // containerWidth - padding on Left/Right (for focus outline)
|
|
102
108
|
|
|
@@ -218,22 +224,6 @@ const ItemContent = /*#__PURE__*/memo(({
|
|
|
218
224
|
}, keyshortcut))), description && jsx("p", {
|
|
219
225
|
css: itemDescription
|
|
220
226
|
}, description))));
|
|
221
|
-
const scrollbarStyle = css`
|
|
222
|
-
::-webkit-scrollbar {
|
|
223
|
-
width: ${SCROLLBAR_WIDTH}px;
|
|
224
|
-
}
|
|
225
|
-
::-webkit-scrollbar-track-piece {
|
|
226
|
-
background: ${SCROLLBAR_TRACK_COLOR};
|
|
227
|
-
}
|
|
228
|
-
::-webkit-scrollbar-thumb {
|
|
229
|
-
background: ${SCROLLBAR_THUMB_COLOR};
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/** Firefox **/
|
|
233
|
-
scrollbar-color: ${SCROLLBAR_THUMB_COLOR} ${SCROLLBAR_TRACK_COLOR};
|
|
234
|
-
|
|
235
|
-
-ms-overflow-style: -ms-autohiding-scrollbar;
|
|
236
|
-
`;
|
|
237
227
|
const elementItemsWrapper = css`
|
|
238
228
|
flex: 1;
|
|
239
229
|
flex-flow: row wrap;
|
|
@@ -243,7 +233,6 @@ const elementItemsWrapper = css`
|
|
|
243
233
|
padding: ${ELEMENT_LIST_PADDING}px; // For Focus outline
|
|
244
234
|
|
|
245
235
|
.ReactVirtualized__Collection {
|
|
246
|
-
${scrollbarStyle};
|
|
247
236
|
border-radius: 3px; // Standard border-radius across other components like Search or Item.
|
|
248
237
|
outline: none;
|
|
249
238
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ELEMENT_ITEM_HEIGHT
|
|
1
|
+
import { ELEMENT_ITEM_HEIGHT } from '../../constants';
|
|
2
2
|
import { generateVirtualizedContainerDatum } from './utils';
|
|
3
3
|
/**
|
|
4
4
|
* Callback responsible for returning size and offset/position information
|
|
@@ -6,7 +6,7 @@ import { generateVirtualizedContainerDatum } from './utils';
|
|
|
6
6
|
* https://github.com/bvaughn/react-virtualized/blob/master/docs/Collection.md
|
|
7
7
|
**/
|
|
8
8
|
|
|
9
|
-
export default function cellSizeAndPositionGetter(containerWidth) {
|
|
9
|
+
export default function cellSizeAndPositionGetter(containerWidth, scrollbarWidth) {
|
|
10
10
|
const GUTTER_SIZE = 4;
|
|
11
11
|
/**
|
|
12
12
|
* Save the currently rendered columnY positions.
|
|
@@ -22,7 +22,7 @@ export default function cellSizeAndPositionGetter(containerWidth) {
|
|
|
22
22
|
availableWidth
|
|
23
23
|
} = generateVirtualizedContainerDatum(containerWidth, {
|
|
24
24
|
gutterSize: GUTTER_SIZE,
|
|
25
|
-
scrollbarWidth
|
|
25
|
+
scrollbarWidth
|
|
26
26
|
});
|
|
27
27
|
const width = Math.floor(availableWidth / columnCount);
|
|
28
28
|
const height = ELEMENT_ITEM_HEIGHT;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ELEMENT_LIST_PADDING, FLEX_ITEMS_CONTAINER_BREAKPOINT_NUMBERS } from '../../constants';
|
|
1
|
+
import { ELEMENT_LIST_PADDING, FLEX_ITEMS_CONTAINER_BREAKPOINT_NUMBERS, SCROLLBAR_WIDTH } from '../../constants';
|
|
2
2
|
export function getColumnCount(clientWidth) {
|
|
3
3
|
const {
|
|
4
4
|
small,
|
|
@@ -25,9 +25,33 @@ export function generateVirtualizedContainerDatum(containerWidth, options) {
|
|
|
25
25
|
scrollbarWidth
|
|
26
26
|
} = options;
|
|
27
27
|
const columnCount = getColumnCount(containerWidth);
|
|
28
|
-
const availableWidth = containerWidth - (scrollbarWidth + ELEMENT_LIST_PADDING
|
|
28
|
+
const availableWidth = containerWidth - (scrollbarWidth + ELEMENT_LIST_PADDING);
|
|
29
29
|
return {
|
|
30
30
|
availableWidth,
|
|
31
31
|
columnCount
|
|
32
32
|
};
|
|
33
|
+
}
|
|
34
|
+
let CALCULATED_SCROLLBAR_WIDTH;
|
|
35
|
+
export function getScrollbarWidth() {
|
|
36
|
+
if (!CALCULATED_SCROLLBAR_WIDTH) {
|
|
37
|
+
var _container$parentNode;
|
|
38
|
+
|
|
39
|
+
const container = document.createElement('div');
|
|
40
|
+
container.style.visibility = 'hidden';
|
|
41
|
+
container.style.overflow = 'scroll';
|
|
42
|
+
document.body.appendChild(container);
|
|
43
|
+
const innerContainer = document.createElement('div');
|
|
44
|
+
container.appendChild(innerContainer);
|
|
45
|
+
const scrollbarWidth = container.offsetWidth - innerContainer.offsetWidth;
|
|
46
|
+
(_container$parentNode = container.parentNode) === null || _container$parentNode === void 0 ? void 0 : _container$parentNode.removeChild(container);
|
|
47
|
+
|
|
48
|
+
if (scrollbarWidth) {
|
|
49
|
+
CALCULATED_SCROLLBAR_WIDTH = scrollbarWidth;
|
|
50
|
+
return scrollbarWidth;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return SCROLLBAR_WIDTH;
|
|
54
|
+
} else {
|
|
55
|
+
return CALCULATED_SCROLLBAR_WIDTH;
|
|
56
|
+
}
|
|
33
57
|
}
|
|
@@ -17,10 +17,7 @@ export const SIDEBAR_HEADING_PADDING_LEFT = '12px';
|
|
|
17
17
|
export const INLINE_SIDEBAR_HEIGHT = '54px';
|
|
18
18
|
export const SEARCH_ITEM_MARGIN = '12px';
|
|
19
19
|
export const SEARCH_ITEM_HEIGHT_WIDTH = '20px';
|
|
20
|
-
export const SCROLLBAR_WIDTH =
|
|
21
|
-
|
|
22
|
-
export const SCROLLBAR_THUMB_COLOR = '#eeeeee';
|
|
23
|
-
export const SCROLLBAR_TRACK_COLOR = 'rgba(255, 255, 255, 0)';
|
|
20
|
+
export const SCROLLBAR_WIDTH = 15;
|
|
24
21
|
export const ELEMENT_LIST_PADDING = 2;
|
|
25
22
|
export const MODAL_WRAPPER_PADDING = 16;
|
|
26
23
|
export const ELEMENT_ITEM_HEIGHT = 75;
|