@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,41 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
export class StatsModifier {
|
|
3
|
+
constructor() {
|
|
4
|
+
_defineProperty(this, "startedAt", 0);
|
|
5
|
+
|
|
6
|
+
_defineProperty(this, "endedAt", 0);
|
|
7
|
+
|
|
8
|
+
_defineProperty(this, "keyCount", {
|
|
9
|
+
arrowUp: 0,
|
|
10
|
+
arrowDown: 0
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
_defineProperty(this, "increaseArrowUp", () => {
|
|
14
|
+
this.keyCount.arrowUp += 1;
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
_defineProperty(this, "increaseArrowDown", () => {
|
|
18
|
+
this.keyCount.arrowDown += 1;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
_defineProperty(this, "serialize", () => {
|
|
22
|
+
var _this$keyCount, _this$keyCount2;
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
startedAt: this.startedAt,
|
|
26
|
+
endedAt: performance.now(),
|
|
27
|
+
keyCount: {
|
|
28
|
+
arrowUp: ((_this$keyCount = this.keyCount) === null || _this$keyCount === void 0 ? void 0 : _this$keyCount.arrowUp) || 0,
|
|
29
|
+
arrowDown: ((_this$keyCount2 = this.keyCount) === null || _this$keyCount2 === void 0 ? void 0 : _this$keyCount2.arrowDown) || 0
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
this.startedAt = performance.now();
|
|
35
|
+
this.keyCount = {
|
|
36
|
+
arrowUp: 0,
|
|
37
|
+
arrowDown: 0
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { TextSelection } from 'prosemirror-state';
|
|
2
|
+
import { pluginKey } from '../pm-plugins/key';
|
|
3
|
+
import { ACTIONS } from '../pm-plugins/actions';
|
|
4
|
+
export const openTypeAheadAtCursor = ({
|
|
5
|
+
triggerHandler,
|
|
6
|
+
inputMethod,
|
|
7
|
+
query
|
|
8
|
+
}) => tr => {
|
|
9
|
+
tr.setMeta(pluginKey, {
|
|
10
|
+
action: ACTIONS.OPEN_TYPEAHEAD_AT_CURSOR,
|
|
11
|
+
params: {
|
|
12
|
+
triggerHandler,
|
|
13
|
+
inputMethod,
|
|
14
|
+
query
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
const {
|
|
18
|
+
selection
|
|
19
|
+
} = tr;
|
|
20
|
+
|
|
21
|
+
if (!(selection instanceof TextSelection)) {
|
|
22
|
+
return tr;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!selection.$cursor) {
|
|
26
|
+
tr.deleteSelection();
|
|
27
|
+
return tr;
|
|
28
|
+
} // Search & Destroy placeholder
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
const cursorPos = selection.$cursor.pos;
|
|
32
|
+
const nodeAtCursor = tr.doc.nodeAt(cursorPos);
|
|
33
|
+
const isPlaceholderAtCursorPosition = nodeAtCursor && nodeAtCursor.type.name === 'placeholder';
|
|
34
|
+
|
|
35
|
+
if (nodeAtCursor && isPlaceholderAtCursorPosition) {
|
|
36
|
+
tr.delete(cursorPos, cursorPos + nodeAtCursor.nodeSize);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return tr;
|
|
40
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TextSelection } from 'prosemirror-state';
|
|
2
|
+
export const setSelectionBeforeQuery = rawText => tr => {
|
|
3
|
+
const currentPosition = tr.selection.$from.pos;
|
|
4
|
+
const positionBeforeRawText = Math.max(currentPosition - rawText.length, 0);
|
|
5
|
+
const resolvedPositionBeforeText = tr.doc.resolve(positionBeforeRawText);
|
|
6
|
+
const nextSelection = TextSelection.findFrom(resolvedPositionBeforeText, -1, true);
|
|
7
|
+
|
|
8
|
+
if (nextSelection) {
|
|
9
|
+
tr.setSelection(nextSelection);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React, { useContext, useRef, useCallback } from 'react';
|
|
2
|
+
import { TypeAheadListItem } from './TypeAheadListItem';
|
|
3
|
+
import { useResizeObserver } from './hooks/use-resize-observer';
|
|
4
|
+
|
|
5
|
+
const noop = () => {};
|
|
6
|
+
|
|
7
|
+
export const SelectedIndexContext = /*#__PURE__*/React.createContext(0);
|
|
8
|
+
export const ListItemActionsContext = /*#__PURE__*/React.createContext({
|
|
9
|
+
onItemClick: noop,
|
|
10
|
+
onItemHover: noop
|
|
11
|
+
});
|
|
12
|
+
export const UpdateListItemHeightContext = /*#__PURE__*/React.createContext(noop);
|
|
13
|
+
export const DynamicHeightListItem = ({
|
|
14
|
+
index,
|
|
15
|
+
data,
|
|
16
|
+
style
|
|
17
|
+
}) => {
|
|
18
|
+
const item = data[index];
|
|
19
|
+
const selectedIndex = useContext(SelectedIndexContext);
|
|
20
|
+
const {
|
|
21
|
+
onItemClick,
|
|
22
|
+
onItemHover
|
|
23
|
+
} = useContext(ListItemActionsContext);
|
|
24
|
+
const updateItemHeight = useContext(UpdateListItemHeightContext);
|
|
25
|
+
const innerDivRef = useRef(document.createElement('div'));
|
|
26
|
+
const onResize = useCallback(entry => {
|
|
27
|
+
if (typeof updateItemHeight !== 'function') {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
updateItemHeight({
|
|
32
|
+
index,
|
|
33
|
+
height: entry.contentRect.height
|
|
34
|
+
});
|
|
35
|
+
}, [updateItemHeight, index]);
|
|
36
|
+
useResizeObserver(innerDivRef, onResize);
|
|
37
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
38
|
+
style: style,
|
|
39
|
+
"data-index": index
|
|
40
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
41
|
+
ref: innerDivRef,
|
|
42
|
+
"data-testid": `list-item-height-observed-${index}`
|
|
43
|
+
}, /*#__PURE__*/React.createElement(TypeAheadListItem, {
|
|
44
|
+
key: item.title,
|
|
45
|
+
item: item,
|
|
46
|
+
itemIndex: index,
|
|
47
|
+
selectedIndex: selectedIndex,
|
|
48
|
+
onItemClick: onItemClick,
|
|
49
|
+
onItemHover: onItemHover
|
|
50
|
+
})));
|
|
51
|
+
};
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import React, { useRef, useEffect, useCallback } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { keyName as keyNameNormalized } from 'w3c-keyname';
|
|
4
|
+
import { browser, ZERO_WIDTH_SPACE } from '@atlaskit/editor-common';
|
|
5
|
+
import { CloseSelectionOptions } from '../constants';
|
|
6
|
+
import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
|
|
7
|
+
const QuerySpan = styled.span`
|
|
8
|
+
outline: none;
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
const isNavigationKey = event => {
|
|
12
|
+
return ['Enter', 'Tab', 'ArrowDown', 'ArrowUp'].includes(event.key);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const isUndoRedoShortcut = event => {
|
|
16
|
+
const key = keyNameNormalized(event);
|
|
17
|
+
|
|
18
|
+
if (event.ctrlKey && key === 'y') {
|
|
19
|
+
return 'historyRedo';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if ((event.ctrlKey || event.metaKey) && event.shiftKey && key === 'Z') {
|
|
23
|
+
return 'historyRedo';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if ((event.ctrlKey || event.metaKey) && key === 'z') {
|
|
27
|
+
return 'historyUndo';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return false;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const InputQuery = /*#__PURE__*/React.memo(({
|
|
34
|
+
triggerQueryPrefix,
|
|
35
|
+
cancel,
|
|
36
|
+
onQueryChange,
|
|
37
|
+
onItemSelect,
|
|
38
|
+
selectNextItem,
|
|
39
|
+
selectPreviousItem,
|
|
40
|
+
forceFocus,
|
|
41
|
+
reopenQuery,
|
|
42
|
+
onQueryFocus,
|
|
43
|
+
onUndoRedo
|
|
44
|
+
}) => {
|
|
45
|
+
const ref = useRef(document.createElement('span'));
|
|
46
|
+
const cleanedInputContent = useCallback(() => {
|
|
47
|
+
const raw = ref.current.textContent || '';
|
|
48
|
+
return raw.replace(ZERO_WIDTH_SPACE, '');
|
|
49
|
+
}, []);
|
|
50
|
+
const onKeyUp = useCallback(event => {
|
|
51
|
+
const text = cleanedInputContent();
|
|
52
|
+
onQueryChange(text);
|
|
53
|
+
}, [onQueryChange, cleanedInputContent]);
|
|
54
|
+
const checkKeyEvent = useCallback(event => {
|
|
55
|
+
const key = keyNameNormalized(event);
|
|
56
|
+
const sel = document.getSelection();
|
|
57
|
+
const raw = ref.current.textContent || '';
|
|
58
|
+
const text = cleanedInputContent();
|
|
59
|
+
let stopDefault = false;
|
|
60
|
+
|
|
61
|
+
switch (key) {
|
|
62
|
+
case ' ':
|
|
63
|
+
// space key
|
|
64
|
+
if (text.length === 0) {
|
|
65
|
+
cancel({
|
|
66
|
+
forceFocusOnEditor: true,
|
|
67
|
+
text: ' ',
|
|
68
|
+
addPrefixTrigger: true,
|
|
69
|
+
setSelectionAt: CloseSelectionOptions.AFTER_TEXT_INSERTED
|
|
70
|
+
});
|
|
71
|
+
stopDefault = true;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
break;
|
|
75
|
+
|
|
76
|
+
case 'Escape':
|
|
77
|
+
cancel({
|
|
78
|
+
text,
|
|
79
|
+
forceFocusOnEditor: true,
|
|
80
|
+
addPrefixTrigger: true,
|
|
81
|
+
setSelectionAt: CloseSelectionOptions.AFTER_TEXT_INSERTED
|
|
82
|
+
});
|
|
83
|
+
break;
|
|
84
|
+
|
|
85
|
+
case 'Backspace':
|
|
86
|
+
if (raw === ZERO_WIDTH_SPACE || raw.length === 0 || (sel === null || sel === void 0 ? void 0 : sel.anchorOffset) === 0) {
|
|
87
|
+
event.stopPropagation();
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
cancel({
|
|
90
|
+
forceFocusOnEditor: true,
|
|
91
|
+
text,
|
|
92
|
+
addPrefixTrigger: false,
|
|
93
|
+
setSelectionAt: CloseSelectionOptions.BEFORE_TEXT_INSERTED
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
break;
|
|
98
|
+
|
|
99
|
+
case 'Enter':
|
|
100
|
+
onItemSelect(event.shiftKey ? SelectItemMode.SHIFT_ENTER : SelectItemMode.ENTER);
|
|
101
|
+
break;
|
|
102
|
+
|
|
103
|
+
case 'Tab':
|
|
104
|
+
onItemSelect(SelectItemMode.TAB);
|
|
105
|
+
break;
|
|
106
|
+
|
|
107
|
+
case 'ArrowDown':
|
|
108
|
+
selectNextItem();
|
|
109
|
+
break;
|
|
110
|
+
|
|
111
|
+
case 'ArrowUp':
|
|
112
|
+
selectPreviousItem();
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const undoRedoType = isUndoRedoShortcut(event);
|
|
117
|
+
|
|
118
|
+
if (onUndoRedo && undoRedoType && onUndoRedo(undoRedoType)) {
|
|
119
|
+
stopDefault = true;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (isNavigationKey(event) || stopDefault) {
|
|
123
|
+
event.stopPropagation();
|
|
124
|
+
event.preventDefault();
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
}, [onUndoRedo, onItemSelect, selectNextItem, cancel, selectPreviousItem, cleanedInputContent]);
|
|
128
|
+
const onClick = useCallback(event => {
|
|
129
|
+
event.stopPropagation();
|
|
130
|
+
event.preventDefault();
|
|
131
|
+
onQueryFocus();
|
|
132
|
+
ref.current.focus();
|
|
133
|
+
return false;
|
|
134
|
+
}, [onQueryFocus]);
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
if (!ref.current) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const {
|
|
141
|
+
current: element
|
|
142
|
+
} = ref;
|
|
143
|
+
|
|
144
|
+
const onFocusIn = event => {
|
|
145
|
+
onQueryFocus();
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const keyDown = event => {
|
|
149
|
+
const key = keyNameNormalized(event);
|
|
150
|
+
|
|
151
|
+
if (['ArrowLeft', 'ArrowRight'].includes(key) && document.getSelection && document.getSelection()) {
|
|
152
|
+
const q = ref.current.textContent || '';
|
|
153
|
+
const sel = document.getSelection();
|
|
154
|
+
const isMovingRight = sel && 'ArrowRight' === key && sel.anchorOffset === q.length;
|
|
155
|
+
const isMovingLeft = sel && 'ArrowLeft' === key && sel.anchorOffset === 0;
|
|
156
|
+
|
|
157
|
+
if (!isMovingRight && !isMovingLeft) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
cancel({
|
|
162
|
+
forceFocusOnEditor: true,
|
|
163
|
+
addPrefixTrigger: true,
|
|
164
|
+
text: cleanedInputContent(),
|
|
165
|
+
setSelectionAt: isMovingRight ? CloseSelectionOptions.AFTER_TEXT_INSERTED : CloseSelectionOptions.BEFORE_TEXT_INSERTED
|
|
166
|
+
});
|
|
167
|
+
event.preventDefault();
|
|
168
|
+
event.stopPropagation();
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
checkKeyEvent(event);
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const onFocusOut = event => {
|
|
176
|
+
cancel({
|
|
177
|
+
addPrefixTrigger: true,
|
|
178
|
+
text: cleanedInputContent(),
|
|
179
|
+
setSelectionAt: CloseSelectionOptions.BEFORE_TEXT_INSERTED,
|
|
180
|
+
forceFocusOnEditor: false
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const close = () => {
|
|
185
|
+
cancel({
|
|
186
|
+
addPrefixTrigger: false,
|
|
187
|
+
text: '',
|
|
188
|
+
forceFocusOnEditor: true,
|
|
189
|
+
setSelectionAt: CloseSelectionOptions.BEFORE_TEXT_INSERTED
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
const beforeinput = e => {
|
|
194
|
+
var _target$textContent;
|
|
195
|
+
|
|
196
|
+
const {
|
|
197
|
+
target
|
|
198
|
+
} = e;
|
|
199
|
+
|
|
200
|
+
if (e.isComposing || !(target instanceof HTMLElement)) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (e.inputType === 'historyUndo' && (((_target$textContent = target.textContent) === null || _target$textContent === void 0 ? void 0 : _target$textContent.length) === 0 || target.textContent === ZERO_WIDTH_SPACE)) {
|
|
205
|
+
e.preventDefault();
|
|
206
|
+
e.stopPropagation();
|
|
207
|
+
close();
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (e.data != null && target.textContent === ZERO_WIDTH_SPACE) {
|
|
212
|
+
element.textContent = ''; // We need to change the content on Safari
|
|
213
|
+
// and set the cursor at the right place
|
|
214
|
+
|
|
215
|
+
if (browser.safari) {
|
|
216
|
+
e.preventDefault();
|
|
217
|
+
const dataElement = document.createTextNode(e.data);
|
|
218
|
+
element.appendChild(dataElement);
|
|
219
|
+
const sel = window.getSelection();
|
|
220
|
+
const range = document.createRange();
|
|
221
|
+
range.setStart(dataElement, dataElement.length);
|
|
222
|
+
range.collapse(true);
|
|
223
|
+
sel === null || sel === void 0 ? void 0 : sel.removeAllRanges();
|
|
224
|
+
sel === null || sel === void 0 ? void 0 : sel.addRange(range);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
let onInput = null;
|
|
230
|
+
|
|
231
|
+
if (browser.safari) {
|
|
232
|
+
// On Safari, for reasons beyond my understanding,
|
|
233
|
+
// The undo behavior is totally different from other browsers
|
|
234
|
+
// That why we need to have an specific branch only for Safari.
|
|
235
|
+
const onInput = e => {
|
|
236
|
+
var _target$textContent2;
|
|
237
|
+
|
|
238
|
+
const {
|
|
239
|
+
target
|
|
240
|
+
} = e;
|
|
241
|
+
|
|
242
|
+
if (e.isComposing || !(target instanceof HTMLElement)) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (e.inputType === 'historyUndo' && ((_target$textContent2 = target.textContent) === null || _target$textContent2 === void 0 ? void 0 : _target$textContent2.length) === 1) {
|
|
247
|
+
e.preventDefault();
|
|
248
|
+
e.stopPropagation();
|
|
249
|
+
close();
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
element.addEventListener('input', onInput);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
element.addEventListener('focusout', onFocusOut);
|
|
258
|
+
element.addEventListener('focusin', onFocusIn);
|
|
259
|
+
element.addEventListener('keydown', keyDown);
|
|
260
|
+
element.addEventListener('beforeinput', beforeinput);
|
|
261
|
+
return () => {
|
|
262
|
+
element.removeEventListener('focusout', onFocusOut);
|
|
263
|
+
element.removeEventListener('focusin', onFocusIn);
|
|
264
|
+
element.removeEventListener('keydown', keyDown);
|
|
265
|
+
element.removeEventListener('beforeinput', beforeinput);
|
|
266
|
+
|
|
267
|
+
if (browser.safari) {
|
|
268
|
+
element.removeEventListener('input', onInput);
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
}, [triggerQueryPrefix, cleanedInputContent, onQueryFocus, cancel, checkKeyEvent]);
|
|
272
|
+
useEffect(() => {
|
|
273
|
+
const hasReopenQuery = typeof reopenQuery === 'string' && reopenQuery.trim().length > 0;
|
|
274
|
+
|
|
275
|
+
if (ref.current && forceFocus) {
|
|
276
|
+
ref.current.textContent = hasReopenQuery ? reopenQuery : ZERO_WIDTH_SPACE;
|
|
277
|
+
requestAnimationFrame(() => {
|
|
278
|
+
if (!(ref !== null && ref !== void 0 && ref.current)) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const sel = window.getSelection();
|
|
283
|
+
|
|
284
|
+
if (sel && hasReopenQuery && ref.current.lastChild instanceof Text) {
|
|
285
|
+
const lastChild = ref.current.lastChild;
|
|
286
|
+
const range = document.createRange();
|
|
287
|
+
range.setStart(ref.current.lastChild, lastChild.length);
|
|
288
|
+
range.collapse(true);
|
|
289
|
+
sel.removeAllRanges();
|
|
290
|
+
sel.addRange(range);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
ref.current.focus();
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
}, [forceFocus, reopenQuery]);
|
|
297
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, triggerQueryPrefix, /*#__PURE__*/React.createElement(QuerySpan, {
|
|
298
|
+
contentEditable: true,
|
|
299
|
+
innerRef: ref,
|
|
300
|
+
onKeyUp: onKeyUp,
|
|
301
|
+
onClick: onClick,
|
|
302
|
+
role: "textbox",
|
|
303
|
+
suppressContentEditableWarning: true,
|
|
304
|
+
"data-query-prefix": triggerQueryPrefix
|
|
305
|
+
}));
|
|
306
|
+
});
|
|
307
|
+
InputQuery.displayName = 'InputQuery';
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import React, { useMemo, useEffect, useRef, useCallback, useLayoutEffect } from 'react';
|
|
2
|
+
import { text as colorsText, N200, N20, DN70, N800, DN600, DN300 } from '@atlaskit/theme/colors';
|
|
3
|
+
import { ItemGroup, itemThemeNamespace } from '@atlaskit/item';
|
|
4
|
+
import { themed } from '@atlaskit/theme/components';
|
|
5
|
+
import { ThemeProvider } from 'styled-components';
|
|
6
|
+
import { ICON_HEIGHT } from './TypeAheadListItem';
|
|
7
|
+
import { VariableSizeList as List } from 'react-window';
|
|
8
|
+
import { ResizeObserverProvider } from './hooks/use-resize-observer';
|
|
9
|
+
import { useDynamicListHeightCalculation } from './hooks/use-dynamic-list-height-calculation';
|
|
10
|
+
import { DynamicHeightListItem, SelectedIndexContext, ListItemActionsContext, UpdateListItemHeightContext } from './DynamicHeightListItem';
|
|
11
|
+
const ITEM_PADDING = 12;
|
|
12
|
+
const LIST_ITEM_ESTIMATED_HEIGHT = ICON_HEIGHT + ITEM_PADDING * 2;
|
|
13
|
+
const LIST_MAX_HEIGHT = 380;
|
|
14
|
+
const LIST_WIDTH = 320;
|
|
15
|
+
const itemTheme = {
|
|
16
|
+
[itemThemeNamespace]: {
|
|
17
|
+
padding: {
|
|
18
|
+
default: {
|
|
19
|
+
bottom: ITEM_PADDING,
|
|
20
|
+
left: ITEM_PADDING,
|
|
21
|
+
right: ITEM_PADDING,
|
|
22
|
+
top: ITEM_PADDING
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
beforeItemSpacing: {
|
|
26
|
+
default: () => ITEM_PADDING
|
|
27
|
+
},
|
|
28
|
+
borderRadius: () => 0,
|
|
29
|
+
hover: {
|
|
30
|
+
// background: colors.transparent, transparent is not a thing
|
|
31
|
+
text: colorsText,
|
|
32
|
+
secondaryText: N200
|
|
33
|
+
},
|
|
34
|
+
selected: {
|
|
35
|
+
background: themed({
|
|
36
|
+
light: N20,
|
|
37
|
+
dark: DN70
|
|
38
|
+
}),
|
|
39
|
+
text: themed({
|
|
40
|
+
light: N800,
|
|
41
|
+
dark: DN600
|
|
42
|
+
}),
|
|
43
|
+
secondaryText: themed({
|
|
44
|
+
light: N200,
|
|
45
|
+
dark: DN300
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
export const TypeAheadList = /*#__PURE__*/React.memo(({
|
|
51
|
+
items,
|
|
52
|
+
selectedIndex,
|
|
53
|
+
onItemHover,
|
|
54
|
+
onItemClick
|
|
55
|
+
}) => {
|
|
56
|
+
const listRef = useRef();
|
|
57
|
+
const redrawListAtIndex = useCallback(index => {
|
|
58
|
+
listRef.current.resetAfterIndex(index);
|
|
59
|
+
}, []);
|
|
60
|
+
const lastVisibleIndexes = useRef({
|
|
61
|
+
overscanStartIndex: 0,
|
|
62
|
+
overscanStopIndex: 0,
|
|
63
|
+
visibleStartIndex: 0,
|
|
64
|
+
visibleStopIndex: 0
|
|
65
|
+
});
|
|
66
|
+
const getFirstVisibleIndex = useCallback(() => {
|
|
67
|
+
return lastVisibleIndexes.current.overscanStartIndex;
|
|
68
|
+
}, []);
|
|
69
|
+
const {
|
|
70
|
+
getListItemHeight,
|
|
71
|
+
setListItemHeight,
|
|
72
|
+
renderedListHeight
|
|
73
|
+
} = useDynamicListHeightCalculation({
|
|
74
|
+
redrawListAtIndex,
|
|
75
|
+
getFirstVisibleIndex,
|
|
76
|
+
listLength: items.length,
|
|
77
|
+
listMaxHeight: LIST_MAX_HEIGHT,
|
|
78
|
+
listItemEstimatedHeight: LIST_ITEM_ESTIMATED_HEIGHT
|
|
79
|
+
});
|
|
80
|
+
const onItemsRendered = useCallback(props => {
|
|
81
|
+
lastVisibleIndexes.current = props;
|
|
82
|
+
}, []);
|
|
83
|
+
const actions = useMemo(() => ({
|
|
84
|
+
onItemClick,
|
|
85
|
+
onItemHover
|
|
86
|
+
}), [onItemClick, onItemHover]);
|
|
87
|
+
const onScroll = useCallback(({
|
|
88
|
+
scrollUpdateWasRequested
|
|
89
|
+
}) => {
|
|
90
|
+
if (!scrollUpdateWasRequested) {
|
|
91
|
+
return;
|
|
92
|
+
} // In case the user scroll to a non-visible item like press ArrowUp from the first index
|
|
93
|
+
// We will force the scroll calling the scrollToItem in the useEffect hook
|
|
94
|
+
// When the scroll happens and we render the elements,
|
|
95
|
+
// we still need calculate the items height and re-draw the List.
|
|
96
|
+
// It is possible the item selected became invisible again (because the items height changed)
|
|
97
|
+
// So, we need to wait for height to be calculated. Then we need to check
|
|
98
|
+
// if the selected item is visible or not. If it isn't visible we call the scrollToItem again.
|
|
99
|
+
//
|
|
100
|
+
// We can't do this check in the first frame because that frame is being used by the resetScreenThrottled
|
|
101
|
+
// to calculate each height. THen, we can schedule a new frame when this one finishs.
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
requestAnimationFrame(() => {
|
|
105
|
+
requestAnimationFrame(() => {
|
|
106
|
+
const {
|
|
107
|
+
current: indexes
|
|
108
|
+
} = lastVisibleIndexes;
|
|
109
|
+
const isSelectedItemVisible = selectedIndex >= indexes.visibleStartIndex && selectedIndex <= indexes.visibleStopIndex;
|
|
110
|
+
|
|
111
|
+
if (!isSelectedItemVisible) {
|
|
112
|
+
listRef.current.scrollToItem(selectedIndex);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
}, [selectedIndex]);
|
|
117
|
+
useEffect(() => {
|
|
118
|
+
if (!listRef.current) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
listRef.current.scrollToItem(selectedIndex);
|
|
123
|
+
}, [selectedIndex]);
|
|
124
|
+
useLayoutEffect(() => {
|
|
125
|
+
requestAnimationFrame(() => {
|
|
126
|
+
listRef.current.resetAfterIndex(lastVisibleIndexes.current.overscanStartIndex);
|
|
127
|
+
});
|
|
128
|
+
}, [items]);
|
|
129
|
+
|
|
130
|
+
if (!Array.isArray(items)) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const estimatedHeight = items.length * LIST_ITEM_ESTIMATED_HEIGHT;
|
|
135
|
+
const height = Math.min(typeof renderedListHeight === 'number' ? renderedListHeight : estimatedHeight, LIST_MAX_HEIGHT);
|
|
136
|
+
return /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
137
|
+
theme: itemTheme
|
|
138
|
+
}, /*#__PURE__*/React.createElement(ItemGroup, {
|
|
139
|
+
role: "listbox",
|
|
140
|
+
"aria-live": "polite",
|
|
141
|
+
"aria-label": "TypeAhead results",
|
|
142
|
+
"aria-relevant": "additions removals"
|
|
143
|
+
}, /*#__PURE__*/React.createElement(ResizeObserverProvider, null, /*#__PURE__*/React.createElement(UpdateListItemHeightContext.Provider, {
|
|
144
|
+
value: setListItemHeight
|
|
145
|
+
}, /*#__PURE__*/React.createElement(ListItemActionsContext.Provider, {
|
|
146
|
+
value: actions
|
|
147
|
+
}, /*#__PURE__*/React.createElement(SelectedIndexContext.Provider, {
|
|
148
|
+
value: selectedIndex
|
|
149
|
+
}, /*#__PURE__*/React.createElement(List, {
|
|
150
|
+
useIsScrolling: true,
|
|
151
|
+
ref: listRef,
|
|
152
|
+
itemData: items,
|
|
153
|
+
itemCount: items.length,
|
|
154
|
+
estimatedItemSize: LIST_ITEM_ESTIMATED_HEIGHT,
|
|
155
|
+
onScroll: onScroll,
|
|
156
|
+
onItemsRendered: onItemsRendered,
|
|
157
|
+
itemSize: getListItemHeight,
|
|
158
|
+
width: LIST_WIDTH,
|
|
159
|
+
height: height,
|
|
160
|
+
overscanCount: 3
|
|
161
|
+
}, DynamicHeightListItem)))))));
|
|
162
|
+
});
|
|
163
|
+
TypeAheadList.displayName = 'TypeAheadList';
|