@atlaskit/editor-core 148.0.0 → 149.0.3
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 +110 -0
- package/dist/cjs/create-editor/create-plugins-list.js +6 -1
- package/dist/cjs/editor.js +1 -4
- package/dist/cjs/index.js +24 -40
- package/dist/cjs/labs/next/presets/default.js +1 -1
- package/dist/cjs/messages.js +5 -0
- package/dist/cjs/nodeviews/SelectionBasedNodeView.js +1 -2
- package/dist/cjs/plugins/analytics/plugin.js +9 -7
- package/dist/cjs/plugins/analytics/types/enums.js +5 -0
- package/dist/cjs/plugins/analytics/types/type-ahead.js +5 -0
- package/dist/cjs/plugins/block-type/messages.js +10 -0
- package/dist/cjs/plugins/card/nodeviews/embedCard.js +1 -3
- package/dist/cjs/plugins/collab-edit/participants.js +15 -0
- package/dist/cjs/plugins/collab-edit/plugin-state.js +14 -0
- package/dist/cjs/plugins/collab-edit/ui/avatars-with-plugin-state.js +6 -4
- package/dist/cjs/plugins/collab-edit/ui/avatars.js +19 -2
- package/dist/cjs/plugins/collab-edit/utils.js +42 -2
- package/dist/cjs/plugins/date/actions.js +4 -2
- package/dist/cjs/plugins/date/index.js +1 -1
- package/dist/cjs/plugins/date/pm-plugins/utils.js +6 -1
- package/dist/cjs/plugins/emoji/index.js +143 -120
- package/dist/cjs/plugins/emoji/pm-plugins/ascii-input-rules.js +0 -14
- package/dist/cjs/plugins/expand/pm-plugins/keymap.js +3 -7
- package/dist/cjs/plugins/extension/actions.js +16 -16
- package/dist/cjs/plugins/extension/pm-plugins/main.js +4 -4
- package/dist/cjs/plugins/extension/ui/Extension/ExtensionComponent.js +5 -4
- package/dist/cjs/plugins/extension/ui/Extension/index.js +2 -2
- package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +3 -2
- package/dist/cjs/plugins/floating-toolbar/ui/ConfirmationModal.js +12 -14
- package/dist/cjs/plugins/floating-toolbar/ui/EditorEmojiAddIcon.js +35 -0
- package/dist/cjs/plugins/floating-toolbar/ui/EditorHideEmojiIcon.js +38 -0
- package/dist/cjs/plugins/floating-toolbar/ui/EmojiPickerButton.js +5 -7
- package/dist/cjs/plugins/help-dialog/ui/index.js +12 -18
- package/dist/cjs/plugins/help-dialog/ui/styles.js +2 -6
- package/dist/cjs/plugins/hyperlink/index.js +4 -10
- package/dist/cjs/plugins/insert-block/index.js +9 -8
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +7 -3
- package/dist/cjs/plugins/list/index.js +5 -0
- package/dist/cjs/plugins/macro/actions.js +14 -14
- package/dist/cjs/plugins/media/index.js +1 -0
- package/dist/cjs/plugins/media/nodeviews/mediaGroup.js +1 -0
- package/dist/cjs/plugins/media/pm-plugins/main.js +26 -14
- package/dist/cjs/plugins/media/styles.js +1 -1
- package/dist/cjs/plugins/media/toolbar/filePreviewItem.js +86 -0
- package/dist/cjs/plugins/media/toolbar/index.js +161 -44
- package/dist/cjs/plugins/media/toolbar/utils.js +77 -0
- package/dist/cjs/plugins/mentions/index.js +57 -602
- package/dist/cjs/plugins/mentions/pm-plugins/key.js +11 -0
- package/dist/cjs/plugins/mentions/pm-plugins/main.js +162 -0
- package/dist/cjs/plugins/mentions/pm-plugins/utils.js +12 -0
- package/dist/cjs/plugins/mentions/type-ahead/index.js +449 -0
- package/dist/cjs/plugins/mentions/ui/InviteItem/index.js +3 -1
- package/dist/cjs/plugins/mentions/ui/InviteItem/styles.js +8 -3
- package/dist/cjs/plugins/mentions/ui/ToolbarMention/index.js +3 -3
- package/dist/cjs/plugins/mentions/utils.js +24 -2
- package/dist/cjs/plugins/panel/index.js +46 -13
- package/dist/cjs/plugins/panel/nodeviews/panel.js +39 -25
- package/dist/cjs/plugins/panel/toolbar.js +94 -6
- package/dist/cjs/plugins/panel/toolbar.test.js +149 -16
- package/dist/cjs/plugins/paste/handlers.js +2 -2
- package/dist/cjs/plugins/paste/pm-plugins/analytics.js +6 -3
- package/dist/cjs/plugins/placeholder/index.js +6 -0
- package/dist/cjs/plugins/quick-insert/api.js +30 -0
- package/dist/cjs/plugins/quick-insert/assets/custom-panel.js +55 -0
- package/dist/cjs/plugins/quick-insert/assets/index.js +14 -1
- package/dist/cjs/plugins/quick-insert/index.js +10 -24
- package/dist/cjs/plugins/quick-insert/ui/ModalElementBrowser/index.js +1 -0
- package/dist/cjs/plugins/rank.js +1 -1
- package/dist/cjs/plugins/rule/index.js +1 -25
- package/dist/cjs/plugins/scroll-into-view/index.js +1 -4
- package/dist/cjs/plugins/selection/gap-cursor/actions.js +5 -6
- package/dist/cjs/plugins/selection/pm-plugins/selection-main.js +1 -3
- package/dist/cjs/plugins/status/actions.js +5 -2
- package/dist/cjs/plugins/status/plugin.js +1 -1
- package/dist/cjs/plugins/table/commands/selection.js +24 -24
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +8 -1
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +14 -15
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/decisionItem.js +3 -1
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/taskItem.js +3 -1
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -2
- package/dist/cjs/plugins/text-formatting/pm-plugins/cursor.js +1 -4
- package/dist/cjs/plugins/type-ahead/api.js +243 -0
- package/dist/cjs/plugins/type-ahead/commands/insert-type-ahead-item.js +238 -0
- package/dist/cjs/plugins/type-ahead/commands/update-list-items.js +30 -0
- package/dist/cjs/plugins/type-ahead/commands/update-query.js +16 -18
- package/dist/cjs/plugins/type-ahead/commands/update-selected-index.js +36 -0
- package/dist/cjs/plugins/type-ahead/constants.js +25 -0
- package/dist/cjs/plugins/type-ahead/index.js +183 -52
- package/dist/cjs/plugins/type-ahead/insert-utils.js +132 -0
- package/dist/cjs/plugins/type-ahead/pm-plugins/actions.js +12 -9
- package/dist/cjs/plugins/type-ahead/pm-plugins/decorations.js +238 -0
- package/dist/cjs/plugins/type-ahead/pm-plugins/input-rules.js +20 -40
- package/dist/cjs/plugins/type-ahead/pm-plugins/insert-item-plugin.js +28 -0
- package/dist/cjs/plugins/type-ahead/pm-plugins/{plugin-key.js → key.js} +0 -0
- package/dist/cjs/plugins/type-ahead/pm-plugins/main.js +79 -424
- package/dist/cjs/plugins/type-ahead/pm-plugins/reducer.js +188 -0
- package/dist/cjs/plugins/type-ahead/pm-plugins/utils.js +26 -0
- package/dist/cjs/plugins/type-ahead/stats-modifier.js +49 -0
- package/dist/cjs/plugins/type-ahead/transforms/close-type-ahead.js +18 -0
- package/dist/cjs/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +51 -0
- package/dist/cjs/plugins/type-ahead/transforms/set-selection-before-query.js +24 -0
- package/dist/cjs/plugins/type-ahead/ui/DynamicHeightListItem.js +77 -0
- package/dist/cjs/plugins/type-ahead/ui/InputQuery.js +325 -0
- package/dist/cjs/plugins/type-ahead/ui/TypeAheadList.js +195 -0
- package/dist/cjs/plugins/type-ahead/ui/TypeAheadListItem.js +141 -0
- package/dist/cjs/plugins/type-ahead/ui/TypeAheadPopup.js +141 -0
- package/dist/cjs/plugins/type-ahead/ui/WrapperTypeAhead.js +151 -0
- package/dist/cjs/plugins/type-ahead/ui/hooks/use-dynamic-list-height-calculation.js +118 -0
- package/dist/cjs/plugins/type-ahead/ui/hooks/use-item-insert.js +132 -0
- package/dist/cjs/plugins/type-ahead/ui/hooks/use-load-items.js +61 -0
- package/dist/cjs/plugins/type-ahead/ui/hooks/use-on-force-select.js +50 -0
- package/dist/cjs/plugins/type-ahead/ui/hooks/use-resize-observer.js +70 -0
- package/dist/cjs/plugins/type-ahead/utils.js +127 -0
- package/dist/cjs/plugins/undo-redo/ui/ToolbarUndoRedo/index.js +33 -2
- package/dist/cjs/plugins/view-update-subscription/index.js +19 -14
- package/dist/cjs/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.js +10 -3
- package/dist/cjs/plugins/view-update-subscription/subscribe/type-ahead-updates.js +46 -0
- package/dist/cjs/test-utils.js +17 -0
- package/dist/cjs/types/empty-state-handler.js +5 -0
- package/dist/cjs/ui/ConfigPanel/Fields/ColorPicker.js +4 -21
- package/dist/cjs/ui/ElementBrowser/ElementBrowser.js +4 -2
- package/dist/cjs/ui/ElementBrowser/InsertMenu.js +1 -0
- package/dist/cjs/ui/ElementBrowser/ModalElementBrowser.js +16 -23
- package/dist/cjs/ui/ElementBrowser/components/ElementList/ElementList.js +11 -4
- package/dist/cjs/ui/ElementBrowser/components/StatelessElementBrowser.js +12 -4
- package/dist/cjs/ui/PanelTextInput/index.js +1 -3
- package/dist/cjs/utils/compare.js +7 -7
- package/dist/cjs/utils/index.js +7 -8
- package/dist/cjs/utils/rich-media-utils.js +2 -2
- package/dist/cjs/utils/selection.js +6 -3
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/create-editor/create-plugins-list.js +6 -1
- package/dist/es2019/editor.js +1 -4
- package/dist/es2019/index.js +4 -6
- package/dist/es2019/labs/next/presets/default.js +2 -2
- package/dist/es2019/messages.js +5 -0
- package/dist/es2019/nodeviews/SelectionBasedNodeView.js +1 -2
- package/dist/es2019/plugins/analytics/plugin.js +5 -1
- package/dist/es2019/plugins/analytics/types/enums.js +5 -0
- package/dist/es2019/plugins/analytics/types/type-ahead.js +1 -0
- package/dist/es2019/plugins/block-type/messages.js +10 -0
- package/dist/es2019/plugins/card/nodeviews/embedCard.js +1 -3
- package/dist/es2019/plugins/collab-edit/participants.js +14 -0
- package/dist/es2019/plugins/collab-edit/plugin-state.js +17 -1
- package/dist/es2019/plugins/collab-edit/ui/avatars-with-plugin-state.js +6 -4
- package/dist/es2019/plugins/collab-edit/ui/avatars.js +17 -2
- package/dist/es2019/plugins/collab-edit/utils.js +34 -0
- package/dist/es2019/plugins/date/actions.js +4 -2
- package/dist/es2019/plugins/date/index.js +1 -1
- package/dist/es2019/plugins/date/pm-plugins/utils.js +6 -1
- package/dist/es2019/plugins/emoji/index.js +169 -146
- package/dist/es2019/plugins/emoji/pm-plugins/ascii-input-rules.js +0 -11
- package/dist/es2019/plugins/expand/pm-plugins/keymap.js +3 -6
- package/dist/es2019/plugins/extension/actions.js +16 -16
- package/dist/es2019/plugins/extension/pm-plugins/main.js +4 -4
- package/dist/es2019/plugins/extension/ui/Extension/ExtensionComponent.js +5 -4
- package/dist/es2019/plugins/extension/ui/Extension/index.js +2 -2
- package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +3 -2
- package/dist/es2019/plugins/floating-toolbar/ui/ConfirmationModal.js +12 -15
- package/dist/es2019/plugins/floating-toolbar/ui/EditorEmojiAddIcon.js +25 -0
- package/dist/es2019/plugins/floating-toolbar/ui/EditorHideEmojiIcon.js +28 -0
- package/dist/es2019/plugins/floating-toolbar/ui/EmojiPickerButton.js +3 -5
- package/dist/es2019/plugins/help-dialog/ui/index.js +20 -26
- package/dist/es2019/plugins/help-dialog/ui/styles.js +2 -2
- package/dist/es2019/plugins/hyperlink/index.js +4 -12
- package/dist/es2019/plugins/insert-block/index.js +4 -4
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +8 -4
- package/dist/es2019/plugins/list/index.js +20 -14
- package/dist/es2019/plugins/macro/actions.js +14 -14
- package/dist/es2019/plugins/media/index.js +1 -0
- package/dist/es2019/plugins/media/nodeviews/mediaGroup.js +1 -0
- package/dist/es2019/plugins/media/pm-plugins/main.js +27 -12
- package/dist/es2019/plugins/media/styles.js +7 -2
- package/dist/es2019/plugins/media/toolbar/filePreviewItem.js +59 -0
- package/dist/es2019/plugins/media/toolbar/index.js +158 -42
- package/dist/es2019/plugins/media/toolbar/utils.js +32 -0
- package/dist/es2019/plugins/mentions/index.js +34 -536
- package/dist/es2019/plugins/mentions/pm-plugins/key.js +2 -0
- package/dist/es2019/plugins/mentions/pm-plugins/main.js +138 -0
- package/dist/es2019/plugins/mentions/pm-plugins/utils.js +4 -0
- package/dist/es2019/plugins/mentions/type-ahead/index.js +394 -0
- package/dist/es2019/plugins/mentions/ui/InviteItem/index.js +2 -1
- package/dist/es2019/plugins/mentions/ui/InviteItem/styles.js +4 -2
- package/dist/es2019/plugins/mentions/ui/ToolbarMention/index.js +2 -2
- package/dist/es2019/plugins/mentions/utils.js +20 -1
- package/dist/es2019/plugins/panel/index.js +95 -62
- package/dist/es2019/plugins/panel/nodeviews/panel.js +7 -1
- package/dist/es2019/plugins/panel/toolbar.js +90 -6
- package/dist/es2019/plugins/panel/toolbar.test.js +131 -14
- package/dist/es2019/plugins/paste/handlers.js +2 -2
- package/dist/es2019/plugins/paste/pm-plugins/analytics.js +6 -3
- package/dist/es2019/plugins/placeholder/index.js +5 -0
- package/dist/es2019/plugins/quick-insert/api.js +18 -0
- package/dist/es2019/plugins/quick-insert/assets/custom-panel.js +45 -0
- package/dist/es2019/plugins/quick-insert/assets/index.js +6 -0
- package/dist/es2019/plugins/quick-insert/index.js +12 -23
- package/dist/es2019/plugins/quick-insert/search.js +1 -3
- package/dist/es2019/plugins/quick-insert/ui/ModalElementBrowser/index.js +1 -0
- package/dist/es2019/plugins/rank.js +1 -1
- package/dist/es2019/plugins/rule/index.js +1 -22
- package/dist/es2019/plugins/scroll-into-view/index.js +1 -3
- package/dist/es2019/plugins/selection/gap-cursor/actions.js +5 -6
- package/dist/es2019/plugins/selection/pm-plugins/selection-main.js +1 -3
- package/dist/es2019/plugins/status/actions.js +5 -2
- package/dist/es2019/plugins/status/plugin.js +1 -1
- package/dist/es2019/plugins/table/commands/selection.js +25 -25
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +8 -1
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +14 -15
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/decisionItem.js +2 -1
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/taskItem.js +2 -1
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -2
- package/dist/es2019/plugins/text-formatting/pm-plugins/cursor.js +1 -4
- package/dist/es2019/plugins/type-ahead/api.js +224 -0
- package/dist/es2019/plugins/type-ahead/commands/insert-type-ahead-item.js +222 -0
- package/dist/es2019/plugins/type-ahead/commands/update-list-items.js +19 -0
- package/dist/es2019/plugins/type-ahead/commands/update-query.js +17 -15
- package/dist/es2019/plugins/type-ahead/commands/update-selected-index.js +25 -0
- package/dist/es2019/plugins/type-ahead/constants.js +15 -0
- package/dist/es2019/plugins/type-ahead/index.js +203 -78
- package/dist/es2019/plugins/type-ahead/insert-utils.js +119 -0
- package/dist/es2019/plugins/type-ahead/pm-plugins/actions.js +11 -8
- package/dist/es2019/plugins/type-ahead/pm-plugins/decorations.js +211 -0
- package/dist/es2019/plugins/type-ahead/pm-plugins/input-rules.js +18 -32
- package/dist/es2019/plugins/type-ahead/pm-plugins/insert-item-plugin.js +19 -0
- package/dist/es2019/plugins/type-ahead/pm-plugins/{plugin-key.js → key.js} +0 -0
- package/dist/es2019/plugins/type-ahead/pm-plugins/main.js +81 -401
- package/dist/es2019/plugins/type-ahead/pm-plugins/reducer.js +165 -0
- package/dist/es2019/plugins/type-ahead/pm-plugins/utils.js +16 -0
- package/dist/es2019/plugins/type-ahead/stats-modifier.js +41 -0
- package/dist/es2019/plugins/type-ahead/transforms/close-type-ahead.js +7 -0
- package/dist/es2019/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +40 -0
- package/dist/es2019/plugins/type-ahead/transforms/set-selection-before-query.js +11 -0
- package/dist/es2019/plugins/type-ahead/ui/DynamicHeightListItem.js +51 -0
- package/dist/es2019/plugins/type-ahead/ui/InputQuery.js +307 -0
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadList.js +163 -0
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadListItem.js +136 -0
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadPopup.js +120 -0
- package/dist/es2019/plugins/type-ahead/ui/WrapperTypeAhead.js +110 -0
- package/dist/es2019/plugins/type-ahead/ui/hooks/use-dynamic-list-height-calculation.js +97 -0
- package/dist/es2019/plugins/type-ahead/ui/hooks/use-item-insert.js +126 -0
- package/dist/es2019/plugins/type-ahead/ui/hooks/use-load-items.js +43 -0
- package/dist/es2019/plugins/type-ahead/ui/hooks/use-on-force-select.js +41 -0
- package/dist/es2019/plugins/type-ahead/ui/hooks/use-resize-observer.js +53 -0
- package/dist/es2019/plugins/type-ahead/utils.js +93 -0
- package/dist/es2019/plugins/undo-redo/ui/ToolbarUndoRedo/index.js +29 -2
- package/dist/es2019/plugins/view-update-subscription/index.js +19 -14
- package/dist/es2019/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.js +9 -3
- package/dist/es2019/plugins/view-update-subscription/subscribe/type-ahead-updates.js +34 -0
- package/dist/es2019/test-utils.js +7 -0
- package/dist/es2019/types/empty-state-handler.js +1 -0
- package/dist/es2019/ui/ConfigPanel/Fields/ColorPicker.js +4 -8
- package/dist/es2019/ui/ConfigPanel/transformers.js +9 -9
- package/dist/es2019/ui/ElementBrowser/ElementBrowser.js +4 -2
- package/dist/es2019/ui/ElementBrowser/InsertMenu.js +1 -0
- package/dist/es2019/ui/ElementBrowser/ModalElementBrowser.js +20 -21
- package/dist/es2019/ui/ElementBrowser/components/ElementList/ElementList.js +9 -2
- package/dist/es2019/ui/ElementBrowser/components/StatelessElementBrowser.js +12 -4
- package/dist/es2019/ui/PanelTextInput/index.js +1 -3
- package/dist/es2019/utils/compare.js +7 -7
- package/dist/es2019/utils/index.js +7 -8
- package/dist/es2019/utils/rich-media-utils.js +2 -2
- package/dist/es2019/utils/selection.js +6 -3
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/create-editor/create-plugins-list.js +6 -1
- package/dist/esm/editor.js +1 -4
- package/dist/esm/index.js +4 -6
- package/dist/esm/labs/next/presets/default.js +2 -2
- package/dist/esm/messages.js +5 -0
- package/dist/esm/nodeviews/SelectionBasedNodeView.js +1 -2
- package/dist/esm/plugins/analytics/plugin.js +8 -6
- package/dist/esm/plugins/analytics/types/enums.js +5 -0
- package/dist/esm/plugins/analytics/types/type-ahead.js +1 -0
- package/dist/esm/plugins/block-type/messages.js +10 -0
- package/dist/esm/plugins/card/nodeviews/embedCard.js +1 -3
- package/dist/esm/plugins/collab-edit/participants.js +15 -0
- package/dist/esm/plugins/collab-edit/plugin-state.js +15 -1
- package/dist/esm/plugins/collab-edit/ui/avatars-with-plugin-state.js +6 -4
- package/dist/esm/plugins/collab-edit/ui/avatars.js +17 -2
- package/dist/esm/plugins/collab-edit/utils.js +32 -0
- package/dist/esm/plugins/date/actions.js +4 -2
- package/dist/esm/plugins/date/index.js +1 -1
- package/dist/esm/plugins/date/pm-plugins/utils.js +6 -1
- package/dist/esm/plugins/emoji/index.js +136 -112
- package/dist/esm/plugins/emoji/pm-plugins/ascii-input-rules.js +0 -13
- package/dist/esm/plugins/expand/pm-plugins/keymap.js +3 -6
- package/dist/esm/plugins/extension/actions.js +16 -16
- package/dist/esm/plugins/extension/pm-plugins/main.js +4 -4
- package/dist/esm/plugins/extension/ui/Extension/ExtensionComponent.js +5 -4
- package/dist/esm/plugins/extension/ui/Extension/index.js +2 -2
- package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +3 -2
- package/dist/esm/plugins/floating-toolbar/ui/ConfirmationModal.js +12 -15
- package/dist/esm/plugins/floating-toolbar/ui/EditorEmojiAddIcon.js +25 -0
- package/dist/esm/plugins/floating-toolbar/ui/EditorHideEmojiIcon.js +28 -0
- package/dist/esm/plugins/floating-toolbar/ui/EmojiPickerButton.js +3 -5
- package/dist/esm/plugins/help-dialog/ui/index.js +13 -19
- package/dist/esm/plugins/help-dialog/ui/styles.js +2 -6
- package/dist/esm/plugins/hyperlink/index.js +4 -10
- package/dist/esm/plugins/insert-block/index.js +5 -5
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +8 -4
- package/dist/esm/plugins/list/index.js +5 -0
- package/dist/esm/plugins/macro/actions.js +14 -14
- package/dist/esm/plugins/media/index.js +1 -0
- package/dist/esm/plugins/media/nodeviews/mediaGroup.js +1 -0
- package/dist/esm/plugins/media/pm-plugins/main.js +27 -14
- package/dist/esm/plugins/media/styles.js +2 -2
- package/dist/esm/plugins/media/toolbar/filePreviewItem.js +62 -0
- package/dist/esm/plugins/media/toolbar/index.js +154 -43
- package/dist/esm/plugins/media/toolbar/utils.js +60 -0
- package/dist/esm/plugins/mentions/index.js +45 -557
- package/dist/esm/plugins/mentions/pm-plugins/key.js +2 -0
- package/dist/esm/plugins/mentions/pm-plugins/main.js +145 -0
- package/dist/esm/plugins/mentions/pm-plugins/utils.js +4 -0
- package/dist/esm/plugins/mentions/type-ahead/index.js +415 -0
- package/dist/esm/plugins/mentions/ui/InviteItem/index.js +2 -1
- package/dist/esm/plugins/mentions/ui/InviteItem/styles.js +4 -2
- package/dist/esm/plugins/mentions/ui/ToolbarMention/index.js +2 -2
- package/dist/esm/plugins/mentions/utils.js +19 -0
- package/dist/esm/plugins/panel/index.js +44 -13
- package/dist/esm/plugins/panel/nodeviews/panel.js +36 -22
- package/dist/esm/plugins/panel/toolbar.js +92 -6
- package/dist/esm/plugins/panel/toolbar.test.js +148 -16
- package/dist/esm/plugins/paste/handlers.js +2 -2
- package/dist/esm/plugins/paste/pm-plugins/analytics.js +6 -3
- package/dist/esm/plugins/placeholder/index.js +5 -0
- package/dist/esm/plugins/quick-insert/api.js +20 -0
- package/dist/esm/plugins/quick-insert/assets/custom-panel.js +45 -0
- package/dist/esm/plugins/quick-insert/assets/index.js +12 -0
- package/dist/esm/plugins/quick-insert/index.js +10 -24
- package/dist/esm/plugins/quick-insert/search.js +1 -3
- package/dist/esm/plugins/quick-insert/ui/ModalElementBrowser/index.js +1 -0
- package/dist/esm/plugins/rank.js +1 -1
- package/dist/esm/plugins/rule/index.js +1 -22
- package/dist/esm/plugins/scroll-into-view/index.js +1 -3
- package/dist/esm/plugins/selection/gap-cursor/actions.js +5 -6
- package/dist/esm/plugins/selection/pm-plugins/selection-main.js +1 -3
- package/dist/esm/plugins/status/actions.js +5 -2
- package/dist/esm/plugins/status/plugin.js +1 -1
- package/dist/esm/plugins/table/commands/selection.js +24 -24
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +8 -1
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +14 -15
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/decisionItem.js +2 -1
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/taskItem.js +2 -1
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -2
- package/dist/esm/plugins/text-formatting/pm-plugins/cursor.js +1 -4
- package/dist/esm/plugins/type-ahead/api.js +228 -0
- package/dist/esm/plugins/type-ahead/commands/insert-type-ahead-item.js +217 -0
- package/dist/esm/plugins/type-ahead/commands/update-list-items.js +19 -0
- package/dist/esm/plugins/type-ahead/commands/update-query.js +13 -13
- package/dist/esm/plugins/type-ahead/commands/update-selected-index.js +25 -0
- package/dist/esm/plugins/type-ahead/constants.js +15 -0
- package/dist/esm/plugins/type-ahead/index.js +173 -53
- package/dist/esm/plugins/type-ahead/insert-utils.js +116 -0
- package/dist/esm/plugins/type-ahead/pm-plugins/actions.js +11 -8
- package/dist/esm/plugins/type-ahead/pm-plugins/decorations.js +204 -0
- package/dist/esm/plugins/type-ahead/pm-plugins/input-rules.js +18 -33
- package/dist/esm/plugins/type-ahead/pm-plugins/insert-item-plugin.js +18 -0
- package/dist/esm/plugins/type-ahead/pm-plugins/{plugin-key.js → key.js} +0 -0
- package/dist/esm/plugins/type-ahead/pm-plugins/main.js +80 -393
- package/dist/esm/plugins/type-ahead/pm-plugins/reducer.js +168 -0
- package/dist/esm/plugins/type-ahead/pm-plugins/utils.js +16 -0
- package/dist/esm/plugins/type-ahead/stats-modifier.js +43 -0
- package/dist/esm/plugins/type-ahead/transforms/close-type-ahead.js +7 -0
- package/dist/esm/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +39 -0
- package/dist/esm/plugins/type-ahead/transforms/set-selection-before-query.js +13 -0
- package/dist/esm/plugins/type-ahead/ui/DynamicHeightListItem.js +51 -0
- package/dist/esm/plugins/type-ahead/ui/InputQuery.js +302 -0
- package/dist/esm/plugins/type-ahead/ui/TypeAheadList.js +168 -0
- package/dist/esm/plugins/type-ahead/ui/TypeAheadListItem.js +105 -0
- package/dist/esm/plugins/type-ahead/ui/TypeAheadPopup.js +114 -0
- package/dist/esm/plugins/type-ahead/ui/WrapperTypeAhead.js +125 -0
- package/dist/esm/plugins/type-ahead/ui/hooks/use-dynamic-list-height-calculation.js +101 -0
- package/dist/esm/plugins/type-ahead/ui/hooks/use-item-insert.js +118 -0
- package/dist/esm/plugins/type-ahead/ui/hooks/use-load-items.js +46 -0
- package/dist/esm/plugins/type-ahead/ui/hooks/use-on-force-select.js +38 -0
- package/dist/esm/plugins/type-ahead/ui/hooks/use-resize-observer.js +48 -0
- package/dist/esm/plugins/type-ahead/utils.js +88 -0
- package/dist/esm/plugins/undo-redo/ui/ToolbarUndoRedo/index.js +33 -2
- package/dist/esm/plugins/view-update-subscription/index.js +19 -14
- package/dist/esm/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.js +10 -3
- package/dist/esm/plugins/view-update-subscription/subscribe/type-ahead-updates.js +33 -0
- package/dist/esm/test-utils.js +7 -0
- package/dist/esm/types/empty-state-handler.js +1 -0
- package/dist/esm/ui/ConfigPanel/Fields/ColorPicker.js +4 -14
- package/dist/esm/ui/ElementBrowser/ElementBrowser.js +4 -2
- package/dist/esm/ui/ElementBrowser/InsertMenu.js +1 -0
- package/dist/esm/ui/ElementBrowser/ModalElementBrowser.js +16 -23
- package/dist/esm/ui/ElementBrowser/components/ElementList/ElementList.js +10 -3
- package/dist/esm/ui/ElementBrowser/components/StatelessElementBrowser.js +12 -4
- package/dist/esm/ui/PanelTextInput/index.js +1 -3
- package/dist/esm/utils/compare.js +7 -7
- package/dist/esm/utils/index.js +7 -8
- package/dist/esm/utils/rich-media-utils.js +2 -2
- package/dist/esm/utils/selection.js +6 -3
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/commands/index.d.ts +1 -1
- package/dist/types/create-editor/ErrorBoundary.d.ts +1 -1
- package/dist/types/index.d.ts +3 -5
- package/dist/types/labs/next/full-page.d.ts +1 -1
- package/dist/types/labs/next/mobile.d.ts +1 -1
- package/dist/types/labs/next/presets/default.d.ts +2 -0
- package/dist/types/messages.d.ts +5 -0
- package/dist/types/plugins/alignment/commands/index.d.ts +2 -2
- package/dist/types/plugins/analytics/types/enums.d.ts +6 -1
- package/dist/types/plugins/analytics/types/events.d.ts +12 -2
- package/dist/types/plugins/analytics/types/general-events.d.ts +2 -23
- package/dist/types/plugins/analytics/types/type-ahead.d.ts +27 -0
- package/dist/types/plugins/block-type/messages.d.ts +10 -0
- package/dist/types/plugins/card/ui/ResizableEmbedCard.d.ts +1 -1
- package/dist/types/plugins/collab-edit/participants.d.ts +1 -0
- package/dist/types/plugins/collab-edit/ui/avatars.d.ts +3 -1
- package/dist/types/plugins/collab-edit/ui/invite-to-edit.d.ts +1 -1
- package/dist/types/plugins/collab-edit/utils.d.ts +4 -2
- package/dist/types/plugins/date/actions.d.ts +1 -1
- package/dist/types/plugins/date/pm-plugins/types.d.ts +1 -0
- package/dist/types/plugins/emoji/index.d.ts +2 -4
- package/dist/types/plugins/emoji/types.d.ts +2 -2
- package/dist/types/plugins/extension/ui/Extension/Extension/index.d.ts +2 -3
- package/dist/types/plugins/extension/ui/Extension/Extension/styles.d.ts +1 -1
- package/dist/types/plugins/extension/ui/Extension/ExtensionComponent.d.ts +2 -3
- package/dist/types/plugins/extension/ui/Extension/index.d.ts +2 -3
- package/dist/types/plugins/feature-flags-context/get-enabled-feature-flag-keys.d.ts +1 -1
- package/dist/types/plugins/find-replace/ui/styles.d.ts +3 -3
- package/dist/types/plugins/floating-toolbar/ui/EditorEmojiAddIcon.d.ts +1 -0
- package/dist/types/plugins/floating-toolbar/ui/EditorHideEmojiIcon.d.ts +1 -0
- package/dist/types/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.d.ts +1 -1
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +0 -1
- package/dist/types/plugins/media/pm-plugins/main.d.ts +1 -0
- package/dist/types/plugins/media/toolbar/filePreviewItem.d.ts +7 -0
- package/dist/types/plugins/media/toolbar/utils.d.ts +4 -0
- package/dist/types/plugins/media/types.d.ts +3 -0
- package/dist/types/plugins/media/ui/ResizableMediaSingle/index.d.ts +1 -1
- package/dist/types/plugins/media/utils/media-single.d.ts +1 -1
- package/dist/types/plugins/mentions/analytics.d.ts +1 -1
- package/dist/types/plugins/mentions/index.d.ts +4 -30
- package/dist/types/plugins/mentions/pm-plugins/key.d.ts +3 -0
- package/dist/types/plugins/mentions/pm-plugins/main.d.ts +8 -0
- package/dist/types/plugins/mentions/pm-plugins/utils.d.ts +3 -0
- package/dist/types/plugins/mentions/type-ahead/index.d.ts +17 -0
- package/dist/types/plugins/mentions/types.d.ts +2 -0
- package/dist/types/plugins/mentions/ui/InviteItem/index.d.ts +1 -0
- package/dist/types/plugins/mentions/ui/InviteItem/styles.d.ts +2 -0
- package/dist/types/plugins/mentions/utils.d.ts +4 -0
- package/dist/types/plugins/panel/nodeviews/panel.d.ts +19 -3
- package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +2 -0
- package/dist/types/plugins/quick-insert/api.d.ts +6 -0
- package/dist/types/plugins/quick-insert/assets/custom-panel.d.ts +1 -0
- package/dist/types/plugins/quick-insert/assets/index.d.ts +1 -0
- package/dist/types/plugins/quick-insert/search.d.ts +1 -1
- package/dist/types/plugins/quick-insert/types.d.ts +3 -0
- package/dist/types/plugins/status/actions.d.ts +3 -1
- package/dist/types/plugins/status/ui/statusPicker.d.ts +1 -1
- package/dist/types/plugins/type-ahead/api.d.ts +53 -0
- package/dist/types/plugins/type-ahead/commands/insert-type-ahead-item.d.ts +12 -0
- package/dist/types/plugins/type-ahead/commands/update-list-items.d.ts +3 -0
- package/dist/types/plugins/type-ahead/commands/update-query.d.ts +2 -2
- package/dist/types/plugins/type-ahead/commands/update-selected-index.d.ts +2 -0
- package/dist/types/plugins/type-ahead/constants.d.ts +10 -0
- package/dist/types/plugins/type-ahead/index.d.ts +5 -4
- package/dist/types/plugins/type-ahead/insert-utils.d.ts +18 -0
- package/dist/types/plugins/type-ahead/pm-plugins/actions.d.ts +9 -8
- package/dist/types/plugins/type-ahead/pm-plugins/decorations.d.ts +24 -0
- package/dist/types/plugins/type-ahead/pm-plugins/input-rules.d.ts +0 -1
- package/dist/types/plugins/type-ahead/pm-plugins/insert-item-plugin.d.ts +2 -0
- package/dist/types/plugins/type-ahead/pm-plugins/{plugin-key.d.ts → key.d.ts} +0 -0
- package/dist/types/plugins/type-ahead/pm-plugins/main.d.ts +12 -39
- package/dist/types/plugins/type-ahead/pm-plugins/reducer.d.ts +10 -0
- package/dist/types/plugins/type-ahead/pm-plugins/utils.d.ts +4 -0
- package/dist/types/plugins/type-ahead/stats-modifier.d.ts +20 -0
- package/dist/types/plugins/type-ahead/transforms/close-type-ahead.d.ts +2 -0
- package/dist/types/plugins/type-ahead/transforms/open-typeahead-at-cursor.d.ts +9 -0
- package/dist/types/plugins/type-ahead/transforms/set-selection-before-query.d.ts +2 -0
- package/dist/types/plugins/type-ahead/types.d.ts +95 -30
- package/dist/types/plugins/type-ahead/ui/DynamicHeightListItem.d.ts +21 -0
- package/dist/types/plugins/type-ahead/ui/InputQuery.d.ts +22 -0
- package/dist/types/plugins/type-ahead/ui/TypeAheadList.d.ts +11 -0
- package/dist/types/plugins/type-ahead/ui/TypeAheadListItem.d.ts +15 -0
- package/dist/types/plugins/type-ahead/ui/TypeAheadPopup.d.ts +22 -0
- package/dist/types/plugins/type-ahead/ui/WrapperTypeAhead.d.ts +20 -0
- package/dist/types/plugins/type-ahead/ui/hooks/use-dynamic-list-height-calculation.d.ts +25 -0
- package/dist/types/plugins/type-ahead/ui/hooks/use-item-insert.d.ts +3 -0
- package/dist/types/plugins/type-ahead/ui/hooks/use-load-items.d.ts +3 -0
- package/dist/types/plugins/type-ahead/ui/hooks/use-on-force-select.d.ts +11 -0
- package/dist/types/plugins/type-ahead/ui/hooks/use-resize-observer.d.ts +9 -0
- package/dist/types/plugins/type-ahead/utils.d.ts +18 -0
- package/dist/types/plugins/view-update-subscription/subscribe/type-ahead-updates.d.ts +9 -0
- package/dist/types/test-utils.d.ts +2 -0
- package/dist/types/types/editor-props.d.ts +2 -0
- package/dist/types/types/empty-state-handler.d.ts +7 -0
- package/dist/types/types/feature-flags.d.ts +8 -0
- package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types/ui/ColorPickerButton/index.d.ts +1 -1
- package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
- package/dist/types/ui/ConfigPanel/FormErrorBoundary.d.ts +1 -1
- package/dist/types/ui/ElementBrowser/ElementBrowser.d.ts +2 -0
- package/dist/types/ui/ElementBrowser/ModalElementBrowser.d.ts +2 -0
- package/dist/types/ui/ElementBrowser/components/CategoryList.d.ts +1 -1
- package/dist/types/ui/ElementBrowser/components/ElementList/ElementList.d.ts +5 -1
- package/dist/types/ui/ElementBrowser/components/StatelessElementBrowser.d.ts +3 -1
- package/dist/types/ui/LinkSearch/index.d.ts +20 -20
- package/dist/types/ui/PortalProvider/index.d.ts +1 -1
- package/dist/types/ui/ToolbarButton/index.d.ts +4 -4
- package/dist/types/ui/ToolbarButton/styles.d.ts +2 -2
- package/dist/types/utils/selection.d.ts +2 -2
- package/package.json +32 -29
- package/dist/cjs/plugins/emoji/commands/insert-emoji-query.js +0 -22
- package/dist/cjs/plugins/mentions/commands/insert-mention-query.js +0 -22
- package/dist/cjs/plugins/type-ahead/commands/dismiss.js +0 -44
- package/dist/cjs/plugins/type-ahead/commands/insert-query.js +0 -38
- package/dist/cjs/plugins/type-ahead/commands/items-list-updated.js +0 -25
- package/dist/cjs/plugins/type-ahead/commands/select-item.js +0 -163
- package/dist/cjs/plugins/type-ahead/commands/set-current-index.js +0 -25
- package/dist/cjs/plugins/type-ahead/pm-plugins/keymap.js +0 -115
- package/dist/cjs/plugins/type-ahead/ui/TypeAhead.js +0 -221
- package/dist/cjs/plugins/type-ahead/ui/TypeAheadItemsList.js +0 -239
- package/dist/cjs/plugins/type-ahead/utils/find-query-mark.js +0 -33
- package/dist/cjs/plugins/type-ahead/utils/is-query-active.js +0 -16
- package/dist/es2019/plugins/emoji/commands/insert-emoji-query.js +0 -13
- package/dist/es2019/plugins/mentions/commands/insert-mention-query.js +0 -13
- package/dist/es2019/plugins/type-ahead/commands/dismiss.js +0 -36
- package/dist/es2019/plugins/type-ahead/commands/insert-query.js +0 -26
- package/dist/es2019/plugins/type-ahead/commands/items-list-updated.js +0 -12
- package/dist/es2019/plugins/type-ahead/commands/select-item.js +0 -119
- package/dist/es2019/plugins/type-ahead/commands/set-current-index.js +0 -13
- package/dist/es2019/plugins/type-ahead/pm-plugins/keymap.js +0 -94
- package/dist/es2019/plugins/type-ahead/ui/TypeAhead.js +0 -175
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadItemsList.js +0 -196
- package/dist/es2019/plugins/type-ahead/utils/find-query-mark.js +0 -29
- package/dist/es2019/plugins/type-ahead/utils/is-query-active.js +0 -9
- package/dist/esm/plugins/emoji/commands/insert-emoji-query.js +0 -13
- package/dist/esm/plugins/mentions/commands/insert-mention-query.js +0 -13
- package/dist/esm/plugins/type-ahead/commands/dismiss.js +0 -33
- package/dist/esm/plugins/type-ahead/commands/insert-query.js +0 -26
- package/dist/esm/plugins/type-ahead/commands/items-list-updated.js +0 -14
- package/dist/esm/plugins/type-ahead/commands/select-item.js +0 -132
- package/dist/esm/plugins/type-ahead/commands/set-current-index.js +0 -15
- package/dist/esm/plugins/type-ahead/pm-plugins/keymap.js +0 -94
- package/dist/esm/plugins/type-ahead/ui/TypeAhead.js +0 -202
- package/dist/esm/plugins/type-ahead/ui/TypeAheadItemsList.js +0 -204
- package/dist/esm/plugins/type-ahead/utils/find-query-mark.js +0 -24
- package/dist/esm/plugins/type-ahead/utils/is-query-active.js +0 -9
- package/dist/types/plugins/emoji/commands/insert-emoji-query.d.ts +0 -2
- package/dist/types/plugins/mentions/commands/insert-mention-query.d.ts +0 -2
- package/dist/types/plugins/type-ahead/commands/dismiss.d.ts +0 -2
- package/dist/types/plugins/type-ahead/commands/insert-query.d.ts +0 -2
- package/dist/types/plugins/type-ahead/commands/items-list-updated.d.ts +0 -3
- package/dist/types/plugins/type-ahead/commands/select-item.d.ts +0 -9
- package/dist/types/plugins/type-ahead/commands/set-current-index.d.ts +0 -2
- package/dist/types/plugins/type-ahead/pm-plugins/keymap.d.ts +0 -3
- package/dist/types/plugins/type-ahead/ui/TypeAhead.d.ts +0 -37
- package/dist/types/plugins/type-ahead/ui/TypeAheadItemsList.d.ts +0 -32
- package/dist/types/plugins/type-ahead/utils/find-query-mark.d.ts +0 -10
- package/dist/types/plugins/type-ahead/utils/is-query-active.d.ts +0 -2
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.InputQuery = void 0;
|
|
11
|
+
|
|
12
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
|
|
16
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
17
|
+
|
|
18
|
+
var _w3cKeyname = require("w3c-keyname");
|
|
19
|
+
|
|
20
|
+
var _editorCommon = require("@atlaskit/editor-common");
|
|
21
|
+
|
|
22
|
+
var _constants = require("../constants");
|
|
23
|
+
|
|
24
|
+
var _typeAhead = require("@atlaskit/editor-common/type-ahead");
|
|
25
|
+
|
|
26
|
+
var _templateObject;
|
|
27
|
+
|
|
28
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
29
|
+
|
|
30
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
31
|
+
|
|
32
|
+
var QuerySpan = _styledComponents.default.span(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n outline: none;\n"])));
|
|
33
|
+
|
|
34
|
+
var isNavigationKey = function isNavigationKey(event) {
|
|
35
|
+
return ['Enter', 'Tab', 'ArrowDown', 'ArrowUp'].includes(event.key);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
var isUndoRedoShortcut = function isUndoRedoShortcut(event) {
|
|
39
|
+
var key = (0, _w3cKeyname.keyName)(event);
|
|
40
|
+
|
|
41
|
+
if (event.ctrlKey && key === 'y') {
|
|
42
|
+
return 'historyRedo';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if ((event.ctrlKey || event.metaKey) && event.shiftKey && key === 'Z') {
|
|
46
|
+
return 'historyRedo';
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if ((event.ctrlKey || event.metaKey) && key === 'z') {
|
|
50
|
+
return 'historyUndo';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return false;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
var InputQuery = /*#__PURE__*/_react.default.memo(function (_ref) {
|
|
57
|
+
var triggerQueryPrefix = _ref.triggerQueryPrefix,
|
|
58
|
+
cancel = _ref.cancel,
|
|
59
|
+
onQueryChange = _ref.onQueryChange,
|
|
60
|
+
onItemSelect = _ref.onItemSelect,
|
|
61
|
+
selectNextItem = _ref.selectNextItem,
|
|
62
|
+
selectPreviousItem = _ref.selectPreviousItem,
|
|
63
|
+
forceFocus = _ref.forceFocus,
|
|
64
|
+
reopenQuery = _ref.reopenQuery,
|
|
65
|
+
onQueryFocus = _ref.onQueryFocus,
|
|
66
|
+
onUndoRedo = _ref.onUndoRedo;
|
|
67
|
+
var ref = (0, _react.useRef)(document.createElement('span'));
|
|
68
|
+
var cleanedInputContent = (0, _react.useCallback)(function () {
|
|
69
|
+
var raw = ref.current.textContent || '';
|
|
70
|
+
return raw.replace(_editorCommon.ZERO_WIDTH_SPACE, '');
|
|
71
|
+
}, []);
|
|
72
|
+
var onKeyUp = (0, _react.useCallback)(function (event) {
|
|
73
|
+
var text = cleanedInputContent();
|
|
74
|
+
onQueryChange(text);
|
|
75
|
+
}, [onQueryChange, cleanedInputContent]);
|
|
76
|
+
var checkKeyEvent = (0, _react.useCallback)(function (event) {
|
|
77
|
+
var key = (0, _w3cKeyname.keyName)(event);
|
|
78
|
+
var sel = document.getSelection();
|
|
79
|
+
var raw = ref.current.textContent || '';
|
|
80
|
+
var text = cleanedInputContent();
|
|
81
|
+
var stopDefault = false;
|
|
82
|
+
|
|
83
|
+
switch (key) {
|
|
84
|
+
case ' ':
|
|
85
|
+
// space key
|
|
86
|
+
if (text.length === 0) {
|
|
87
|
+
cancel({
|
|
88
|
+
forceFocusOnEditor: true,
|
|
89
|
+
text: ' ',
|
|
90
|
+
addPrefixTrigger: true,
|
|
91
|
+
setSelectionAt: _constants.CloseSelectionOptions.AFTER_TEXT_INSERTED
|
|
92
|
+
});
|
|
93
|
+
stopDefault = true;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
break;
|
|
97
|
+
|
|
98
|
+
case 'Escape':
|
|
99
|
+
cancel({
|
|
100
|
+
text: text,
|
|
101
|
+
forceFocusOnEditor: true,
|
|
102
|
+
addPrefixTrigger: true,
|
|
103
|
+
setSelectionAt: _constants.CloseSelectionOptions.AFTER_TEXT_INSERTED
|
|
104
|
+
});
|
|
105
|
+
break;
|
|
106
|
+
|
|
107
|
+
case 'Backspace':
|
|
108
|
+
if (raw === _editorCommon.ZERO_WIDTH_SPACE || raw.length === 0 || (sel === null || sel === void 0 ? void 0 : sel.anchorOffset) === 0) {
|
|
109
|
+
event.stopPropagation();
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
cancel({
|
|
112
|
+
forceFocusOnEditor: true,
|
|
113
|
+
text: text,
|
|
114
|
+
addPrefixTrigger: false,
|
|
115
|
+
setSelectionAt: _constants.CloseSelectionOptions.BEFORE_TEXT_INSERTED
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
break;
|
|
120
|
+
|
|
121
|
+
case 'Enter':
|
|
122
|
+
onItemSelect(event.shiftKey ? _typeAhead.SelectItemMode.SHIFT_ENTER : _typeAhead.SelectItemMode.ENTER);
|
|
123
|
+
break;
|
|
124
|
+
|
|
125
|
+
case 'Tab':
|
|
126
|
+
onItemSelect(_typeAhead.SelectItemMode.TAB);
|
|
127
|
+
break;
|
|
128
|
+
|
|
129
|
+
case 'ArrowDown':
|
|
130
|
+
selectNextItem();
|
|
131
|
+
break;
|
|
132
|
+
|
|
133
|
+
case 'ArrowUp':
|
|
134
|
+
selectPreviousItem();
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
var undoRedoType = isUndoRedoShortcut(event);
|
|
139
|
+
|
|
140
|
+
if (onUndoRedo && undoRedoType && onUndoRedo(undoRedoType)) {
|
|
141
|
+
stopDefault = true;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (isNavigationKey(event) || stopDefault) {
|
|
145
|
+
event.stopPropagation();
|
|
146
|
+
event.preventDefault();
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
}, [onUndoRedo, onItemSelect, selectNextItem, cancel, selectPreviousItem, cleanedInputContent]);
|
|
150
|
+
var onClick = (0, _react.useCallback)(function (event) {
|
|
151
|
+
event.stopPropagation();
|
|
152
|
+
event.preventDefault();
|
|
153
|
+
onQueryFocus();
|
|
154
|
+
ref.current.focus();
|
|
155
|
+
return false;
|
|
156
|
+
}, [onQueryFocus]);
|
|
157
|
+
(0, _react.useEffect)(function () {
|
|
158
|
+
if (!ref.current) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
var element = ref.current;
|
|
163
|
+
|
|
164
|
+
var onFocusIn = function onFocusIn(event) {
|
|
165
|
+
onQueryFocus();
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
var keyDown = function keyDown(event) {
|
|
169
|
+
var key = (0, _w3cKeyname.keyName)(event);
|
|
170
|
+
|
|
171
|
+
if (['ArrowLeft', 'ArrowRight'].includes(key) && document.getSelection && document.getSelection()) {
|
|
172
|
+
var q = ref.current.textContent || '';
|
|
173
|
+
var sel = document.getSelection();
|
|
174
|
+
var isMovingRight = sel && 'ArrowRight' === key && sel.anchorOffset === q.length;
|
|
175
|
+
var isMovingLeft = sel && 'ArrowLeft' === key && sel.anchorOffset === 0;
|
|
176
|
+
|
|
177
|
+
if (!isMovingRight && !isMovingLeft) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
cancel({
|
|
182
|
+
forceFocusOnEditor: true,
|
|
183
|
+
addPrefixTrigger: true,
|
|
184
|
+
text: cleanedInputContent(),
|
|
185
|
+
setSelectionAt: isMovingRight ? _constants.CloseSelectionOptions.AFTER_TEXT_INSERTED : _constants.CloseSelectionOptions.BEFORE_TEXT_INSERTED
|
|
186
|
+
});
|
|
187
|
+
event.preventDefault();
|
|
188
|
+
event.stopPropagation();
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
checkKeyEvent(event);
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
var onFocusOut = function onFocusOut(event) {
|
|
196
|
+
cancel({
|
|
197
|
+
addPrefixTrigger: true,
|
|
198
|
+
text: cleanedInputContent(),
|
|
199
|
+
setSelectionAt: _constants.CloseSelectionOptions.BEFORE_TEXT_INSERTED,
|
|
200
|
+
forceFocusOnEditor: false
|
|
201
|
+
});
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
var close = function close() {
|
|
205
|
+
cancel({
|
|
206
|
+
addPrefixTrigger: false,
|
|
207
|
+
text: '',
|
|
208
|
+
forceFocusOnEditor: true,
|
|
209
|
+
setSelectionAt: _constants.CloseSelectionOptions.BEFORE_TEXT_INSERTED
|
|
210
|
+
});
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
var beforeinput = function beforeinput(e) {
|
|
214
|
+
var _target$textContent;
|
|
215
|
+
|
|
216
|
+
var target = e.target;
|
|
217
|
+
|
|
218
|
+
if (e.isComposing || !(target instanceof HTMLElement)) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (e.inputType === 'historyUndo' && (((_target$textContent = target.textContent) === null || _target$textContent === void 0 ? void 0 : _target$textContent.length) === 0 || target.textContent === _editorCommon.ZERO_WIDTH_SPACE)) {
|
|
223
|
+
e.preventDefault();
|
|
224
|
+
e.stopPropagation();
|
|
225
|
+
close();
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (e.data != null && target.textContent === _editorCommon.ZERO_WIDTH_SPACE) {
|
|
230
|
+
element.textContent = ''; // We need to change the content on Safari
|
|
231
|
+
// and set the cursor at the right place
|
|
232
|
+
|
|
233
|
+
if (_editorCommon.browser.safari) {
|
|
234
|
+
e.preventDefault();
|
|
235
|
+
var dataElement = document.createTextNode(e.data);
|
|
236
|
+
element.appendChild(dataElement);
|
|
237
|
+
var sel = window.getSelection();
|
|
238
|
+
var range = document.createRange();
|
|
239
|
+
range.setStart(dataElement, dataElement.length);
|
|
240
|
+
range.collapse(true);
|
|
241
|
+
sel === null || sel === void 0 ? void 0 : sel.removeAllRanges();
|
|
242
|
+
sel === null || sel === void 0 ? void 0 : sel.addRange(range);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
var onInput = null;
|
|
248
|
+
|
|
249
|
+
if (_editorCommon.browser.safari) {
|
|
250
|
+
// On Safari, for reasons beyond my understanding,
|
|
251
|
+
// The undo behavior is totally different from other browsers
|
|
252
|
+
// That why we need to have an specific branch only for Safari.
|
|
253
|
+
var _onInput = function _onInput(e) {
|
|
254
|
+
var _target$textContent2;
|
|
255
|
+
|
|
256
|
+
var target = e.target;
|
|
257
|
+
|
|
258
|
+
if (e.isComposing || !(target instanceof HTMLElement)) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (e.inputType === 'historyUndo' && ((_target$textContent2 = target.textContent) === null || _target$textContent2 === void 0 ? void 0 : _target$textContent2.length) === 1) {
|
|
263
|
+
e.preventDefault();
|
|
264
|
+
e.stopPropagation();
|
|
265
|
+
close();
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
element.addEventListener('input', _onInput);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
element.addEventListener('focusout', onFocusOut);
|
|
274
|
+
element.addEventListener('focusin', onFocusIn);
|
|
275
|
+
element.addEventListener('keydown', keyDown);
|
|
276
|
+
element.addEventListener('beforeinput', beforeinput);
|
|
277
|
+
return function () {
|
|
278
|
+
element.removeEventListener('focusout', onFocusOut);
|
|
279
|
+
element.removeEventListener('focusin', onFocusIn);
|
|
280
|
+
element.removeEventListener('keydown', keyDown);
|
|
281
|
+
element.removeEventListener('beforeinput', beforeinput);
|
|
282
|
+
|
|
283
|
+
if (_editorCommon.browser.safari) {
|
|
284
|
+
element.removeEventListener('input', onInput);
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
}, [triggerQueryPrefix, cleanedInputContent, onQueryFocus, cancel, checkKeyEvent]);
|
|
288
|
+
(0, _react.useEffect)(function () {
|
|
289
|
+
var hasReopenQuery = typeof reopenQuery === 'string' && reopenQuery.trim().length > 0;
|
|
290
|
+
|
|
291
|
+
if (ref.current && forceFocus) {
|
|
292
|
+
ref.current.textContent = hasReopenQuery ? reopenQuery : _editorCommon.ZERO_WIDTH_SPACE;
|
|
293
|
+
requestAnimationFrame(function () {
|
|
294
|
+
if (!(ref !== null && ref !== void 0 && ref.current)) {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
var sel = window.getSelection();
|
|
299
|
+
|
|
300
|
+
if (sel && hasReopenQuery && ref.current.lastChild instanceof Text) {
|
|
301
|
+
var lastChild = ref.current.lastChild;
|
|
302
|
+
var range = document.createRange();
|
|
303
|
+
range.setStart(ref.current.lastChild, lastChild.length);
|
|
304
|
+
range.collapse(true);
|
|
305
|
+
sel.removeAllRanges();
|
|
306
|
+
sel.addRange(range);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
ref.current.focus();
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}, [forceFocus, reopenQuery]);
|
|
313
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, triggerQueryPrefix, /*#__PURE__*/_react.default.createElement(QuerySpan, {
|
|
314
|
+
contentEditable: true,
|
|
315
|
+
innerRef: ref,
|
|
316
|
+
onKeyUp: onKeyUp,
|
|
317
|
+
onClick: onClick,
|
|
318
|
+
role: "textbox",
|
|
319
|
+
suppressContentEditableWarning: true,
|
|
320
|
+
"data-query-prefix": triggerQueryPrefix
|
|
321
|
+
}));
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
exports.InputQuery = InputQuery;
|
|
325
|
+
InputQuery.displayName = 'InputQuery';
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.TypeAheadList = void 0;
|
|
11
|
+
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
|
|
16
|
+
var _colors = require("@atlaskit/theme/colors");
|
|
17
|
+
|
|
18
|
+
var _item = require("@atlaskit/item");
|
|
19
|
+
|
|
20
|
+
var _components = require("@atlaskit/theme/components");
|
|
21
|
+
|
|
22
|
+
var _styledComponents = require("styled-components");
|
|
23
|
+
|
|
24
|
+
var _TypeAheadListItem = require("./TypeAheadListItem");
|
|
25
|
+
|
|
26
|
+
var _reactWindow = require("react-window");
|
|
27
|
+
|
|
28
|
+
var _useResizeObserver = require("./hooks/use-resize-observer");
|
|
29
|
+
|
|
30
|
+
var _useDynamicListHeightCalculation = require("./hooks/use-dynamic-list-height-calculation");
|
|
31
|
+
|
|
32
|
+
var _DynamicHeightListItem = require("./DynamicHeightListItem");
|
|
33
|
+
|
|
34
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
35
|
+
|
|
36
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
37
|
+
|
|
38
|
+
var ITEM_PADDING = 12;
|
|
39
|
+
var LIST_ITEM_ESTIMATED_HEIGHT = _TypeAheadListItem.ICON_HEIGHT + ITEM_PADDING * 2;
|
|
40
|
+
var LIST_MAX_HEIGHT = 380;
|
|
41
|
+
var LIST_WIDTH = 320;
|
|
42
|
+
var itemTheme = (0, _defineProperty2.default)({}, _item.itemThemeNamespace, {
|
|
43
|
+
padding: {
|
|
44
|
+
default: {
|
|
45
|
+
bottom: ITEM_PADDING,
|
|
46
|
+
left: ITEM_PADDING,
|
|
47
|
+
right: ITEM_PADDING,
|
|
48
|
+
top: ITEM_PADDING
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
beforeItemSpacing: {
|
|
52
|
+
default: function _default() {
|
|
53
|
+
return ITEM_PADDING;
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
borderRadius: function borderRadius() {
|
|
57
|
+
return 0;
|
|
58
|
+
},
|
|
59
|
+
hover: {
|
|
60
|
+
// background: colors.transparent, transparent is not a thing
|
|
61
|
+
text: _colors.text,
|
|
62
|
+
secondaryText: _colors.N200
|
|
63
|
+
},
|
|
64
|
+
selected: {
|
|
65
|
+
background: (0, _components.themed)({
|
|
66
|
+
light: _colors.N20,
|
|
67
|
+
dark: _colors.DN70
|
|
68
|
+
}),
|
|
69
|
+
text: (0, _components.themed)({
|
|
70
|
+
light: _colors.N800,
|
|
71
|
+
dark: _colors.DN600
|
|
72
|
+
}),
|
|
73
|
+
secondaryText: (0, _components.themed)({
|
|
74
|
+
light: _colors.N200,
|
|
75
|
+
dark: _colors.DN300
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
var TypeAheadList = /*#__PURE__*/_react.default.memo(function (_ref) {
|
|
81
|
+
var items = _ref.items,
|
|
82
|
+
selectedIndex = _ref.selectedIndex,
|
|
83
|
+
onItemHover = _ref.onItemHover,
|
|
84
|
+
onItemClick = _ref.onItemClick;
|
|
85
|
+
var listRef = (0, _react.useRef)();
|
|
86
|
+
var redrawListAtIndex = (0, _react.useCallback)(function (index) {
|
|
87
|
+
listRef.current.resetAfterIndex(index);
|
|
88
|
+
}, []);
|
|
89
|
+
var lastVisibleIndexes = (0, _react.useRef)({
|
|
90
|
+
overscanStartIndex: 0,
|
|
91
|
+
overscanStopIndex: 0,
|
|
92
|
+
visibleStartIndex: 0,
|
|
93
|
+
visibleStopIndex: 0
|
|
94
|
+
});
|
|
95
|
+
var getFirstVisibleIndex = (0, _react.useCallback)(function () {
|
|
96
|
+
return lastVisibleIndexes.current.overscanStartIndex;
|
|
97
|
+
}, []);
|
|
98
|
+
|
|
99
|
+
var _useDynamicListHeight = (0, _useDynamicListHeightCalculation.useDynamicListHeightCalculation)({
|
|
100
|
+
redrawListAtIndex: redrawListAtIndex,
|
|
101
|
+
getFirstVisibleIndex: getFirstVisibleIndex,
|
|
102
|
+
listLength: items.length,
|
|
103
|
+
listMaxHeight: LIST_MAX_HEIGHT,
|
|
104
|
+
listItemEstimatedHeight: LIST_ITEM_ESTIMATED_HEIGHT
|
|
105
|
+
}),
|
|
106
|
+
getListItemHeight = _useDynamicListHeight.getListItemHeight,
|
|
107
|
+
setListItemHeight = _useDynamicListHeight.setListItemHeight,
|
|
108
|
+
renderedListHeight = _useDynamicListHeight.renderedListHeight;
|
|
109
|
+
|
|
110
|
+
var onItemsRendered = (0, _react.useCallback)(function (props) {
|
|
111
|
+
lastVisibleIndexes.current = props;
|
|
112
|
+
}, []);
|
|
113
|
+
var actions = (0, _react.useMemo)(function () {
|
|
114
|
+
return {
|
|
115
|
+
onItemClick: onItemClick,
|
|
116
|
+
onItemHover: onItemHover
|
|
117
|
+
};
|
|
118
|
+
}, [onItemClick, onItemHover]);
|
|
119
|
+
var onScroll = (0, _react.useCallback)(function (_ref2) {
|
|
120
|
+
var scrollUpdateWasRequested = _ref2.scrollUpdateWasRequested;
|
|
121
|
+
|
|
122
|
+
if (!scrollUpdateWasRequested) {
|
|
123
|
+
return;
|
|
124
|
+
} // In case the user scroll to a non-visible item like press ArrowUp from the first index
|
|
125
|
+
// We will force the scroll calling the scrollToItem in the useEffect hook
|
|
126
|
+
// When the scroll happens and we render the elements,
|
|
127
|
+
// we still need calculate the items height and re-draw the List.
|
|
128
|
+
// It is possible the item selected became invisible again (because the items height changed)
|
|
129
|
+
// So, we need to wait for height to be calculated. Then we need to check
|
|
130
|
+
// if the selected item is visible or not. If it isn't visible we call the scrollToItem again.
|
|
131
|
+
//
|
|
132
|
+
// We can't do this check in the first frame because that frame is being used by the resetScreenThrottled
|
|
133
|
+
// to calculate each height. THen, we can schedule a new frame when this one finishs.
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
requestAnimationFrame(function () {
|
|
137
|
+
requestAnimationFrame(function () {
|
|
138
|
+
var indexes = lastVisibleIndexes.current;
|
|
139
|
+
var isSelectedItemVisible = selectedIndex >= indexes.visibleStartIndex && selectedIndex <= indexes.visibleStopIndex;
|
|
140
|
+
|
|
141
|
+
if (!isSelectedItemVisible) {
|
|
142
|
+
listRef.current.scrollToItem(selectedIndex);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
}, [selectedIndex]);
|
|
147
|
+
(0, _react.useEffect)(function () {
|
|
148
|
+
if (!listRef.current) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
listRef.current.scrollToItem(selectedIndex);
|
|
153
|
+
}, [selectedIndex]);
|
|
154
|
+
(0, _react.useLayoutEffect)(function () {
|
|
155
|
+
requestAnimationFrame(function () {
|
|
156
|
+
listRef.current.resetAfterIndex(lastVisibleIndexes.current.overscanStartIndex);
|
|
157
|
+
});
|
|
158
|
+
}, [items]);
|
|
159
|
+
|
|
160
|
+
if (!Array.isArray(items)) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
var estimatedHeight = items.length * LIST_ITEM_ESTIMATED_HEIGHT;
|
|
165
|
+
var height = Math.min(typeof renderedListHeight === 'number' ? renderedListHeight : estimatedHeight, LIST_MAX_HEIGHT);
|
|
166
|
+
return /*#__PURE__*/_react.default.createElement(_styledComponents.ThemeProvider, {
|
|
167
|
+
theme: itemTheme
|
|
168
|
+
}, /*#__PURE__*/_react.default.createElement(_item.ItemGroup, {
|
|
169
|
+
role: "listbox",
|
|
170
|
+
"aria-live": "polite",
|
|
171
|
+
"aria-label": "TypeAhead results",
|
|
172
|
+
"aria-relevant": "additions removals"
|
|
173
|
+
}, /*#__PURE__*/_react.default.createElement(_useResizeObserver.ResizeObserverProvider, null, /*#__PURE__*/_react.default.createElement(_DynamicHeightListItem.UpdateListItemHeightContext.Provider, {
|
|
174
|
+
value: setListItemHeight
|
|
175
|
+
}, /*#__PURE__*/_react.default.createElement(_DynamicHeightListItem.ListItemActionsContext.Provider, {
|
|
176
|
+
value: actions
|
|
177
|
+
}, /*#__PURE__*/_react.default.createElement(_DynamicHeightListItem.SelectedIndexContext.Provider, {
|
|
178
|
+
value: selectedIndex
|
|
179
|
+
}, /*#__PURE__*/_react.default.createElement(_reactWindow.VariableSizeList, {
|
|
180
|
+
useIsScrolling: true,
|
|
181
|
+
ref: listRef,
|
|
182
|
+
itemData: items,
|
|
183
|
+
itemCount: items.length,
|
|
184
|
+
estimatedItemSize: LIST_ITEM_ESTIMATED_HEIGHT,
|
|
185
|
+
onScroll: onScroll,
|
|
186
|
+
onItemsRendered: onItemsRendered,
|
|
187
|
+
itemSize: getListItemHeight,
|
|
188
|
+
width: LIST_WIDTH,
|
|
189
|
+
height: height,
|
|
190
|
+
overscanCount: 3
|
|
191
|
+
}, _DynamicHeightListItem.DynamicHeightListItem)))))));
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
exports.TypeAheadList = TypeAheadList;
|
|
195
|
+
TypeAheadList.displayName = 'TypeAheadList';
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.TypeAheadListItem = exports.ItemIcon = exports.ICON_WIDTH = exports.ICON_HEIGHT = void 0;
|
|
11
|
+
|
|
12
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
|
|
16
|
+
var _colors = require("@atlaskit/theme/colors");
|
|
17
|
+
|
|
18
|
+
var _constants = require("@atlaskit/theme/constants");
|
|
19
|
+
|
|
20
|
+
var _item = _interopRequireDefault(require("@atlaskit/item"));
|
|
21
|
+
|
|
22
|
+
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
23
|
+
|
|
24
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
25
|
+
|
|
26
|
+
var _fallback = _interopRequireDefault(require("../../quick-insert/assets/fallback"));
|
|
27
|
+
|
|
28
|
+
var _styles = require("../../../ui/styles");
|
|
29
|
+
|
|
30
|
+
var _typeAhead = require("@atlaskit/editor-common/type-ahead");
|
|
31
|
+
|
|
32
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
33
|
+
|
|
34
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
35
|
+
|
|
36
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
37
|
+
|
|
38
|
+
var ICON_HEIGHT = 40;
|
|
39
|
+
exports.ICON_HEIGHT = ICON_HEIGHT;
|
|
40
|
+
var ICON_WIDTH = 40;
|
|
41
|
+
exports.ICON_WIDTH = ICON_WIDTH;
|
|
42
|
+
|
|
43
|
+
var ItemIcon = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n width: ", "px;\n height: ", "px;\n overflow: hidden;\n border: 1px solid rgba(223, 225, 229, 0.5); /* N60 at 50% */\n border-radius: ", "px;\n box-sizing: border-box;\n\n display: flex;\n justify-content: center;\n align-items: center;\n\n div {\n width: ", "px;\n height: ", "px;\n }\n"])), ICON_WIDTH, ICON_HEIGHT, (0, _constants.borderRadius)(), ICON_WIDTH, ICON_HEIGHT);
|
|
44
|
+
|
|
45
|
+
exports.ItemIcon = ItemIcon;
|
|
46
|
+
|
|
47
|
+
var ItemBody = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n line-height: 1.4;\n"])));
|
|
48
|
+
|
|
49
|
+
var ItemText = _styledComponents.default.div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n white-space: initial;\n .item-description {\n font-size: ", ";\n color: ", ";\n margin-top: 4px;\n }\n"])), (0, _editorSharedStyles.relativeFontSizeToBase16)(11.67), _colors.N200);
|
|
50
|
+
|
|
51
|
+
var ItemAfter = _styledComponents.default.div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n flex: 0 0 auto;\n"])));
|
|
52
|
+
|
|
53
|
+
var hidden = {
|
|
54
|
+
overflow: 'hidden'
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
var FallbackIcon = /*#__PURE__*/_react.default.memo(function (_ref) {
|
|
58
|
+
var label = _ref.label;
|
|
59
|
+
return /*#__PURE__*/_react.default.createElement(_fallback.default, null);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
var noop = function noop() {};
|
|
63
|
+
|
|
64
|
+
var TypeAheadListItem = function TypeAheadListItem(_ref2) {
|
|
65
|
+
var item = _ref2.item,
|
|
66
|
+
selectedIndex = _ref2.selectedIndex,
|
|
67
|
+
onItemHover = _ref2.onItemHover,
|
|
68
|
+
onItemClick = _ref2.onItemClick,
|
|
69
|
+
itemIndex = _ref2.itemIndex;
|
|
70
|
+
var isSelected = itemIndex === selectedIndex; // It's possible for onMouseMove to be called multiple times in quick
|
|
71
|
+
// succession because the mousemove event can fire very rapidly. This
|
|
72
|
+
// provides an additional safety net to prevent that.
|
|
73
|
+
|
|
74
|
+
var mouseMoveCalled = (0, _react.useRef)(false);
|
|
75
|
+
var onMouseMove = (0, _react.useCallback)(function () {
|
|
76
|
+
if (isSelected || mouseMoveCalled.current) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
mouseMoveCalled.current = true;
|
|
81
|
+
onItemHover({
|
|
82
|
+
item: item,
|
|
83
|
+
index: itemIndex
|
|
84
|
+
});
|
|
85
|
+
}, [item, itemIndex, onItemHover, isSelected]);
|
|
86
|
+
(0, _react.useLayoutEffect)(function () {
|
|
87
|
+
if (!isSelected) {
|
|
88
|
+
mouseMoveCalled.current = false;
|
|
89
|
+
}
|
|
90
|
+
}, [isSelected]);
|
|
91
|
+
var icon = item.icon,
|
|
92
|
+
title = item.title,
|
|
93
|
+
customRenderItem = item.render;
|
|
94
|
+
var elementIcon = (0, _react.useMemo)(function () {
|
|
95
|
+
return /*#__PURE__*/_react.default.createElement(ItemIcon, null, icon ? icon() : /*#__PURE__*/_react.default.createElement(FallbackIcon, {
|
|
96
|
+
label: title
|
|
97
|
+
}));
|
|
98
|
+
}, [icon, title]);
|
|
99
|
+
var insertSelectedItem = (0, _react.useCallback)(function () {
|
|
100
|
+
onItemClick(_typeAhead.SelectItemMode.SELECTED, itemIndex);
|
|
101
|
+
}, [onItemClick, itemIndex]);
|
|
102
|
+
var customItem = (0, _react.useMemo)(function () {
|
|
103
|
+
if (!customRenderItem) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
var Comp = customRenderItem;
|
|
108
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
109
|
+
"aria-selected": isSelected,
|
|
110
|
+
"aria-label": title,
|
|
111
|
+
role: "option",
|
|
112
|
+
tabIndex: 0,
|
|
113
|
+
style: hidden,
|
|
114
|
+
onMouseMove: onMouseMove
|
|
115
|
+
}, /*#__PURE__*/_react.default.createElement(Comp, {
|
|
116
|
+
onClick: insertSelectedItem,
|
|
117
|
+
isSelected: isSelected,
|
|
118
|
+
onHover: noop
|
|
119
|
+
}));
|
|
120
|
+
}, [customRenderItem, insertSelectedItem, onMouseMove, isSelected, title]);
|
|
121
|
+
|
|
122
|
+
if (customItem) {
|
|
123
|
+
return customItem;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return /*#__PURE__*/_react.default.createElement(_item.default, {
|
|
127
|
+
onClick: insertSelectedItem,
|
|
128
|
+
onMouseMove: onMouseMove,
|
|
129
|
+
elemBefore: elementIcon,
|
|
130
|
+
isSelected: isSelected,
|
|
131
|
+
"aria-selected": isSelected,
|
|
132
|
+
"aria-label": item.title,
|
|
133
|
+
role: "option"
|
|
134
|
+
}, /*#__PURE__*/_react.default.createElement(ItemBody, null, /*#__PURE__*/_react.default.createElement(ItemText, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
135
|
+
className: "item-title"
|
|
136
|
+
}, item.title), item.description && /*#__PURE__*/_react.default.createElement("div", {
|
|
137
|
+
className: "item-description"
|
|
138
|
+
}, item.description)), /*#__PURE__*/_react.default.createElement(ItemAfter, null, item.keyshortcut && /*#__PURE__*/_react.default.createElement(_styles.Shortcut, null, item.keyshortcut))));
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
exports.TypeAheadListItem = TypeAheadListItem;
|