@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,168 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6
|
+
|
|
7
|
+
import { DecorationSet } from 'prosemirror-view';
|
|
8
|
+
import { InsertTypeAheadStep, InsertTypeAheadStages } from '@atlaskit/adf-schema/steps';
|
|
9
|
+
import { ACTIONS } from './actions';
|
|
10
|
+
import { pluginKey } from './key';
|
|
11
|
+
import { INPUT_METHOD } from '../../analytics/types/enums';
|
|
12
|
+
import { isTypeAheadHandler } from '../utils';
|
|
13
|
+
|
|
14
|
+
var shouldForceOpen = function shouldForceOpen(step) {
|
|
15
|
+
if (!(step instanceof InsertTypeAheadStep)) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
var isDeletionRawQueryOperation = step.isInsertionStep() && step.stage === InsertTypeAheadStages.DELETING_RAW_QUERY;
|
|
20
|
+
var isUndoingInsertionItem = step.isUndoingStep() && step.stage === InsertTypeAheadStages.INSERTING_ITEM;
|
|
21
|
+
return isDeletionRawQueryOperation || isUndoingInsertionItem;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
var shouldForceClose = function shouldForceClose(step) {
|
|
25
|
+
if (!(step instanceof InsertTypeAheadStep)) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var isInsertingItem = step.isInsertionStep() && step.stage === InsertTypeAheadStages.INSERTING_ITEM;
|
|
30
|
+
var isUndoingDeletionRawQuery = step.isUndoingStep() && step.stage === InsertTypeAheadStages.DELETING_RAW_QUERY;
|
|
31
|
+
return isInsertingItem || isUndoingDeletionRawQuery;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
var createFindHandler = function createFindHandler(typeAheadHandlers) {
|
|
35
|
+
return function (step) {
|
|
36
|
+
if (!(step instanceof InsertTypeAheadStep)) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
var handler = typeAheadHandlers.find(function (h) {
|
|
41
|
+
return h.trigger === step.trigger;
|
|
42
|
+
});
|
|
43
|
+
return handler || null;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export var createReducer = function createReducer(_ref) {
|
|
48
|
+
var typeAheadHandlers = _ref.typeAheadHandlers,
|
|
49
|
+
removeDecorations = _ref.removeDecorations,
|
|
50
|
+
createDecorations = _ref.createDecorations;
|
|
51
|
+
var findHandler = createFindHandler(typeAheadHandlers);
|
|
52
|
+
|
|
53
|
+
var openMenu = function openMenu(currentPluginState, _ref2) {
|
|
54
|
+
var tr = _ref2.tr,
|
|
55
|
+
triggerHandler = _ref2.triggerHandler,
|
|
56
|
+
inputMethod = _ref2.inputMethod,
|
|
57
|
+
reopenQuery = _ref2.reopenQuery,
|
|
58
|
+
selectedIndex = _ref2.selectedIndex;
|
|
59
|
+
removeDecorations(currentPluginState.decorationSet);
|
|
60
|
+
|
|
61
|
+
var _createDecorations = createDecorations(tr, {
|
|
62
|
+
triggerHandler: triggerHandler,
|
|
63
|
+
inputMethod: inputMethod,
|
|
64
|
+
reopenQuery: reopenQuery
|
|
65
|
+
}),
|
|
66
|
+
decorationSet = _createDecorations.decorationSet,
|
|
67
|
+
decorationElement = _createDecorations.decorationElement,
|
|
68
|
+
stats = _createDecorations.stats;
|
|
69
|
+
|
|
70
|
+
return _objectSpread(_objectSpread({}, currentPluginState), {}, {
|
|
71
|
+
stats: stats,
|
|
72
|
+
decorationSet: decorationSet,
|
|
73
|
+
triggerHandler: triggerHandler,
|
|
74
|
+
decorationElement: decorationElement,
|
|
75
|
+
inputMethod: inputMethod,
|
|
76
|
+
selectedIndex: typeof selectedIndex === 'number' ? selectedIndex : 0,
|
|
77
|
+
items: [],
|
|
78
|
+
query: reopenQuery || ''
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
var closeMenu = function closeMenu(currentPluginState) {
|
|
83
|
+
removeDecorations(currentPluginState.decorationSet);
|
|
84
|
+
return _objectSpread(_objectSpread({}, currentPluginState), {}, {
|
|
85
|
+
inputMethod: null,
|
|
86
|
+
query: '',
|
|
87
|
+
decorationElement: null,
|
|
88
|
+
decorationSet: DecorationSet.empty,
|
|
89
|
+
stats: null,
|
|
90
|
+
triggerHandler: undefined,
|
|
91
|
+
items: []
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
return function (tr, currentPluginState, typeAheadStepOverride) {
|
|
96
|
+
var meta = tr.getMeta(pluginKey) || {}; // This code below controls when we should force
|
|
97
|
+
// the menu to open or close during undo/redo operations
|
|
98
|
+
|
|
99
|
+
var overrideHandler = findHandler(typeAheadStepOverride);
|
|
100
|
+
|
|
101
|
+
if (typeAheadStepOverride && overrideHandler && shouldForceOpen(typeAheadStepOverride)) {
|
|
102
|
+
return openMenu(currentPluginState, {
|
|
103
|
+
tr: tr,
|
|
104
|
+
triggerHandler: overrideHandler,
|
|
105
|
+
inputMethod: INPUT_METHOD.KEYBOARD,
|
|
106
|
+
reopenQuery: typeAheadStepOverride.query,
|
|
107
|
+
selectedIndex: typeAheadStepOverride.selectedIndex
|
|
108
|
+
});
|
|
109
|
+
} else if (shouldForceClose(typeAheadStepOverride)) {
|
|
110
|
+
return closeMenu(currentPluginState);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
var _ref3 = meta || {},
|
|
114
|
+
action = _ref3.action,
|
|
115
|
+
params = _ref3.params;
|
|
116
|
+
|
|
117
|
+
var shouldOpenMenu = action === ACTIONS.OPEN_TYPEAHEAD_AT_CURSOR && isTypeAheadHandler(params === null || params === void 0 ? void 0 : params.triggerHandler);
|
|
118
|
+
var selectionChanged = tr.selectionSet && (tr.isGeneric || Boolean(tr.getMeta('pointer')));
|
|
119
|
+
var shouldCloseMenu = [ACTIONS.CLOSE_TYPE_AHEAD, ACTIONS.INSERT_ITEM].includes(action) || selectionChanged;
|
|
120
|
+
var shouldUpdateQuery = action === ACTIONS.CHANGE_QUERY;
|
|
121
|
+
var shouldUpdateListItems = action === ACTIONS.UPDATE_LIST_ITEMS;
|
|
122
|
+
var shouldUpdateSelectedIndex = action === ACTIONS.UPDATE_SELECTED_INDEX;
|
|
123
|
+
|
|
124
|
+
if (shouldOpenMenu) {
|
|
125
|
+
return openMenu(currentPluginState, {
|
|
126
|
+
tr: tr,
|
|
127
|
+
triggerHandler: params.triggerHandler,
|
|
128
|
+
inputMethod: params.inputMethod
|
|
129
|
+
});
|
|
130
|
+
} else if (shouldCloseMenu) {
|
|
131
|
+
return closeMenu(currentPluginState);
|
|
132
|
+
} else if (shouldUpdateQuery) {
|
|
133
|
+
return _objectSpread(_objectSpread({}, currentPluginState), {}, {
|
|
134
|
+
query: params.query
|
|
135
|
+
});
|
|
136
|
+
} else if (shouldUpdateListItems) {
|
|
137
|
+
var items = params.items;
|
|
138
|
+
var selectedIndex = currentPluginState.selectedIndex;
|
|
139
|
+
return _objectSpread(_objectSpread({}, currentPluginState), {}, {
|
|
140
|
+
items: items,
|
|
141
|
+
selectedIndex: Math.max(selectedIndex >= items.length ? items.length - 1 : selectedIndex, 0)
|
|
142
|
+
});
|
|
143
|
+
} else if (shouldUpdateSelectedIndex) {
|
|
144
|
+
return _objectSpread(_objectSpread({}, currentPluginState), {}, {
|
|
145
|
+
selectedIndex: params.selectedIndex
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (tr.docChanged) {
|
|
150
|
+
var decorationSet = currentPluginState.decorationSet;
|
|
151
|
+
|
|
152
|
+
var onRemove = function onRemove() {
|
|
153
|
+
// Make sure we are unmounting the component
|
|
154
|
+
// from the react tree when this decoration is removed
|
|
155
|
+
removeDecorations(currentPluginState.decorationSet);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
var mappedDecorationSet = decorationSet.map(tr.mapping, tr.doc, {
|
|
159
|
+
onRemove: onRemove
|
|
160
|
+
});
|
|
161
|
+
return _objectSpread(_objectSpread({}, currentPluginState), {}, {
|
|
162
|
+
decorationSet: mappedDecorationSet
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return currentPluginState;
|
|
167
|
+
};
|
|
168
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { pluginKey } from './key';
|
|
2
|
+
export var isInsertionTransaction = function isInsertionTransaction(transactions, action) {
|
|
3
|
+
var _tr$getMeta2;
|
|
4
|
+
|
|
5
|
+
var tr = transactions.find(function (tr) {
|
|
6
|
+
var _tr$getMeta;
|
|
7
|
+
|
|
8
|
+
return ((_tr$getMeta = tr.getMeta(pluginKey)) === null || _tr$getMeta === void 0 ? void 0 : _tr$getMeta.action) === action;
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
if (!tr) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return (_tr$getMeta2 = tr.getMeta(pluginKey)) === null || _tr$getMeta2 === void 0 ? void 0 : _tr$getMeta2.params;
|
|
16
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
export var StatsModifier = function StatsModifier() {
|
|
4
|
+
var _this = this;
|
|
5
|
+
|
|
6
|
+
_classCallCheck(this, StatsModifier);
|
|
7
|
+
|
|
8
|
+
_defineProperty(this, "startedAt", 0);
|
|
9
|
+
|
|
10
|
+
_defineProperty(this, "endedAt", 0);
|
|
11
|
+
|
|
12
|
+
_defineProperty(this, "keyCount", {
|
|
13
|
+
arrowUp: 0,
|
|
14
|
+
arrowDown: 0
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
_defineProperty(this, "increaseArrowUp", function () {
|
|
18
|
+
_this.keyCount.arrowUp += 1;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
_defineProperty(this, "increaseArrowDown", function () {
|
|
22
|
+
_this.keyCount.arrowDown += 1;
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
_defineProperty(this, "serialize", function () {
|
|
26
|
+
var _this$keyCount, _this$keyCount2;
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
startedAt: _this.startedAt,
|
|
30
|
+
endedAt: performance.now(),
|
|
31
|
+
keyCount: {
|
|
32
|
+
arrowUp: ((_this$keyCount = _this.keyCount) === null || _this$keyCount === void 0 ? void 0 : _this$keyCount.arrowUp) || 0,
|
|
33
|
+
arrowDown: ((_this$keyCount2 = _this.keyCount) === null || _this$keyCount2 === void 0 ? void 0 : _this$keyCount2.arrowDown) || 0
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
this.startedAt = performance.now();
|
|
39
|
+
this.keyCount = {
|
|
40
|
+
arrowUp: 0,
|
|
41
|
+
arrowDown: 0
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { TextSelection } from 'prosemirror-state';
|
|
2
|
+
import { pluginKey } from '../pm-plugins/key';
|
|
3
|
+
import { ACTIONS } from '../pm-plugins/actions';
|
|
4
|
+
export var openTypeAheadAtCursor = function openTypeAheadAtCursor(_ref) {
|
|
5
|
+
var triggerHandler = _ref.triggerHandler,
|
|
6
|
+
inputMethod = _ref.inputMethod,
|
|
7
|
+
query = _ref.query;
|
|
8
|
+
return function (tr) {
|
|
9
|
+
tr.setMeta(pluginKey, {
|
|
10
|
+
action: ACTIONS.OPEN_TYPEAHEAD_AT_CURSOR,
|
|
11
|
+
params: {
|
|
12
|
+
triggerHandler: triggerHandler,
|
|
13
|
+
inputMethod: inputMethod,
|
|
14
|
+
query: query
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
var selection = tr.selection;
|
|
18
|
+
|
|
19
|
+
if (!(selection instanceof TextSelection)) {
|
|
20
|
+
return tr;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (!selection.$cursor) {
|
|
24
|
+
tr.deleteSelection();
|
|
25
|
+
return tr;
|
|
26
|
+
} // Search & Destroy placeholder
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
var cursorPos = selection.$cursor.pos;
|
|
30
|
+
var nodeAtCursor = tr.doc.nodeAt(cursorPos);
|
|
31
|
+
var isPlaceholderAtCursorPosition = nodeAtCursor && nodeAtCursor.type.name === 'placeholder';
|
|
32
|
+
|
|
33
|
+
if (nodeAtCursor && isPlaceholderAtCursorPosition) {
|
|
34
|
+
tr.delete(cursorPos, cursorPos + nodeAtCursor.nodeSize);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return tr;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TextSelection } from 'prosemirror-state';
|
|
2
|
+
export var setSelectionBeforeQuery = function setSelectionBeforeQuery(rawText) {
|
|
3
|
+
return function (tr) {
|
|
4
|
+
var currentPosition = tr.selection.$from.pos;
|
|
5
|
+
var positionBeforeRawText = Math.max(currentPosition - rawText.length, 0);
|
|
6
|
+
var resolvedPositionBeforeText = tr.doc.resolve(positionBeforeRawText);
|
|
7
|
+
var nextSelection = TextSelection.findFrom(resolvedPositionBeforeText, -1, true);
|
|
8
|
+
|
|
9
|
+
if (nextSelection) {
|
|
10
|
+
tr.setSelection(nextSelection);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -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
|
+
var noop = function noop() {};
|
|
6
|
+
|
|
7
|
+
export var SelectedIndexContext = /*#__PURE__*/React.createContext(0);
|
|
8
|
+
export var ListItemActionsContext = /*#__PURE__*/React.createContext({
|
|
9
|
+
onItemClick: noop,
|
|
10
|
+
onItemHover: noop
|
|
11
|
+
});
|
|
12
|
+
export var UpdateListItemHeightContext = /*#__PURE__*/React.createContext(noop);
|
|
13
|
+
export var DynamicHeightListItem = function DynamicHeightListItem(_ref) {
|
|
14
|
+
var index = _ref.index,
|
|
15
|
+
data = _ref.data,
|
|
16
|
+
style = _ref.style;
|
|
17
|
+
var item = data[index];
|
|
18
|
+
var selectedIndex = useContext(SelectedIndexContext);
|
|
19
|
+
|
|
20
|
+
var _useContext = useContext(ListItemActionsContext),
|
|
21
|
+
onItemClick = _useContext.onItemClick,
|
|
22
|
+
onItemHover = _useContext.onItemHover;
|
|
23
|
+
|
|
24
|
+
var updateItemHeight = useContext(UpdateListItemHeightContext);
|
|
25
|
+
var innerDivRef = useRef(document.createElement('div'));
|
|
26
|
+
var onResize = useCallback(function (entry) {
|
|
27
|
+
if (typeof updateItemHeight !== 'function') {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
updateItemHeight({
|
|
32
|
+
index: 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-".concat(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,302 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
|
|
3
|
+
var _templateObject;
|
|
4
|
+
|
|
5
|
+
import React, { useRef, useEffect, useCallback } from 'react';
|
|
6
|
+
import styled from 'styled-components';
|
|
7
|
+
import { keyName as keyNameNormalized } from 'w3c-keyname';
|
|
8
|
+
import { browser, ZERO_WIDTH_SPACE } from '@atlaskit/editor-common';
|
|
9
|
+
import { CloseSelectionOptions } from '../constants';
|
|
10
|
+
import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
|
|
11
|
+
var QuerySpan = styled.span(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n outline: none;\n"])));
|
|
12
|
+
|
|
13
|
+
var isNavigationKey = function isNavigationKey(event) {
|
|
14
|
+
return ['Enter', 'Tab', 'ArrowDown', 'ArrowUp'].includes(event.key);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
var isUndoRedoShortcut = function isUndoRedoShortcut(event) {
|
|
18
|
+
var key = keyNameNormalized(event);
|
|
19
|
+
|
|
20
|
+
if (event.ctrlKey && key === 'y') {
|
|
21
|
+
return 'historyRedo';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if ((event.ctrlKey || event.metaKey) && event.shiftKey && key === 'Z') {
|
|
25
|
+
return 'historyRedo';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if ((event.ctrlKey || event.metaKey) && key === 'z') {
|
|
29
|
+
return 'historyUndo';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return false;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
|
|
36
|
+
var triggerQueryPrefix = _ref.triggerQueryPrefix,
|
|
37
|
+
cancel = _ref.cancel,
|
|
38
|
+
onQueryChange = _ref.onQueryChange,
|
|
39
|
+
onItemSelect = _ref.onItemSelect,
|
|
40
|
+
selectNextItem = _ref.selectNextItem,
|
|
41
|
+
selectPreviousItem = _ref.selectPreviousItem,
|
|
42
|
+
forceFocus = _ref.forceFocus,
|
|
43
|
+
reopenQuery = _ref.reopenQuery,
|
|
44
|
+
onQueryFocus = _ref.onQueryFocus,
|
|
45
|
+
onUndoRedo = _ref.onUndoRedo;
|
|
46
|
+
var ref = useRef(document.createElement('span'));
|
|
47
|
+
var cleanedInputContent = useCallback(function () {
|
|
48
|
+
var raw = ref.current.textContent || '';
|
|
49
|
+
return raw.replace(ZERO_WIDTH_SPACE, '');
|
|
50
|
+
}, []);
|
|
51
|
+
var onKeyUp = useCallback(function (event) {
|
|
52
|
+
var text = cleanedInputContent();
|
|
53
|
+
onQueryChange(text);
|
|
54
|
+
}, [onQueryChange, cleanedInputContent]);
|
|
55
|
+
var checkKeyEvent = useCallback(function (event) {
|
|
56
|
+
var key = keyNameNormalized(event);
|
|
57
|
+
var sel = document.getSelection();
|
|
58
|
+
var raw = ref.current.textContent || '';
|
|
59
|
+
var text = cleanedInputContent();
|
|
60
|
+
var stopDefault = false;
|
|
61
|
+
|
|
62
|
+
switch (key) {
|
|
63
|
+
case ' ':
|
|
64
|
+
// space key
|
|
65
|
+
if (text.length === 0) {
|
|
66
|
+
cancel({
|
|
67
|
+
forceFocusOnEditor: true,
|
|
68
|
+
text: ' ',
|
|
69
|
+
addPrefixTrigger: true,
|
|
70
|
+
setSelectionAt: CloseSelectionOptions.AFTER_TEXT_INSERTED
|
|
71
|
+
});
|
|
72
|
+
stopDefault = true;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
break;
|
|
76
|
+
|
|
77
|
+
case 'Escape':
|
|
78
|
+
cancel({
|
|
79
|
+
text: text,
|
|
80
|
+
forceFocusOnEditor: true,
|
|
81
|
+
addPrefixTrigger: true,
|
|
82
|
+
setSelectionAt: CloseSelectionOptions.AFTER_TEXT_INSERTED
|
|
83
|
+
});
|
|
84
|
+
break;
|
|
85
|
+
|
|
86
|
+
case 'Backspace':
|
|
87
|
+
if (raw === ZERO_WIDTH_SPACE || raw.length === 0 || (sel === null || sel === void 0 ? void 0 : sel.anchorOffset) === 0) {
|
|
88
|
+
event.stopPropagation();
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
cancel({
|
|
91
|
+
forceFocusOnEditor: true,
|
|
92
|
+
text: text,
|
|
93
|
+
addPrefixTrigger: false,
|
|
94
|
+
setSelectionAt: CloseSelectionOptions.BEFORE_TEXT_INSERTED
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
break;
|
|
99
|
+
|
|
100
|
+
case 'Enter':
|
|
101
|
+
onItemSelect(event.shiftKey ? SelectItemMode.SHIFT_ENTER : SelectItemMode.ENTER);
|
|
102
|
+
break;
|
|
103
|
+
|
|
104
|
+
case 'Tab':
|
|
105
|
+
onItemSelect(SelectItemMode.TAB);
|
|
106
|
+
break;
|
|
107
|
+
|
|
108
|
+
case 'ArrowDown':
|
|
109
|
+
selectNextItem();
|
|
110
|
+
break;
|
|
111
|
+
|
|
112
|
+
case 'ArrowUp':
|
|
113
|
+
selectPreviousItem();
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
var undoRedoType = isUndoRedoShortcut(event);
|
|
118
|
+
|
|
119
|
+
if (onUndoRedo && undoRedoType && onUndoRedo(undoRedoType)) {
|
|
120
|
+
stopDefault = true;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (isNavigationKey(event) || stopDefault) {
|
|
124
|
+
event.stopPropagation();
|
|
125
|
+
event.preventDefault();
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
}, [onUndoRedo, onItemSelect, selectNextItem, cancel, selectPreviousItem, cleanedInputContent]);
|
|
129
|
+
var onClick = useCallback(function (event) {
|
|
130
|
+
event.stopPropagation();
|
|
131
|
+
event.preventDefault();
|
|
132
|
+
onQueryFocus();
|
|
133
|
+
ref.current.focus();
|
|
134
|
+
return false;
|
|
135
|
+
}, [onQueryFocus]);
|
|
136
|
+
useEffect(function () {
|
|
137
|
+
if (!ref.current) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
var element = ref.current;
|
|
142
|
+
|
|
143
|
+
var onFocusIn = function onFocusIn(event) {
|
|
144
|
+
onQueryFocus();
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
var keyDown = function keyDown(event) {
|
|
148
|
+
var key = keyNameNormalized(event);
|
|
149
|
+
|
|
150
|
+
if (['ArrowLeft', 'ArrowRight'].includes(key) && document.getSelection && document.getSelection()) {
|
|
151
|
+
var q = ref.current.textContent || '';
|
|
152
|
+
var sel = document.getSelection();
|
|
153
|
+
var isMovingRight = sel && 'ArrowRight' === key && sel.anchorOffset === q.length;
|
|
154
|
+
var isMovingLeft = sel && 'ArrowLeft' === key && sel.anchorOffset === 0;
|
|
155
|
+
|
|
156
|
+
if (!isMovingRight && !isMovingLeft) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
cancel({
|
|
161
|
+
forceFocusOnEditor: true,
|
|
162
|
+
addPrefixTrigger: true,
|
|
163
|
+
text: cleanedInputContent(),
|
|
164
|
+
setSelectionAt: isMovingRight ? CloseSelectionOptions.AFTER_TEXT_INSERTED : CloseSelectionOptions.BEFORE_TEXT_INSERTED
|
|
165
|
+
});
|
|
166
|
+
event.preventDefault();
|
|
167
|
+
event.stopPropagation();
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
checkKeyEvent(event);
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
var onFocusOut = function onFocusOut(event) {
|
|
175
|
+
cancel({
|
|
176
|
+
addPrefixTrigger: true,
|
|
177
|
+
text: cleanedInputContent(),
|
|
178
|
+
setSelectionAt: CloseSelectionOptions.BEFORE_TEXT_INSERTED,
|
|
179
|
+
forceFocusOnEditor: false
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
var close = function close() {
|
|
184
|
+
cancel({
|
|
185
|
+
addPrefixTrigger: false,
|
|
186
|
+
text: '',
|
|
187
|
+
forceFocusOnEditor: true,
|
|
188
|
+
setSelectionAt: CloseSelectionOptions.BEFORE_TEXT_INSERTED
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
var beforeinput = function beforeinput(e) {
|
|
193
|
+
var _target$textContent;
|
|
194
|
+
|
|
195
|
+
var target = e.target;
|
|
196
|
+
|
|
197
|
+
if (e.isComposing || !(target instanceof HTMLElement)) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (e.inputType === 'historyUndo' && (((_target$textContent = target.textContent) === null || _target$textContent === void 0 ? void 0 : _target$textContent.length) === 0 || target.textContent === ZERO_WIDTH_SPACE)) {
|
|
202
|
+
e.preventDefault();
|
|
203
|
+
e.stopPropagation();
|
|
204
|
+
close();
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (e.data != null && target.textContent === ZERO_WIDTH_SPACE) {
|
|
209
|
+
element.textContent = ''; // We need to change the content on Safari
|
|
210
|
+
// and set the cursor at the right place
|
|
211
|
+
|
|
212
|
+
if (browser.safari) {
|
|
213
|
+
e.preventDefault();
|
|
214
|
+
var dataElement = document.createTextNode(e.data);
|
|
215
|
+
element.appendChild(dataElement);
|
|
216
|
+
var sel = window.getSelection();
|
|
217
|
+
var range = document.createRange();
|
|
218
|
+
range.setStart(dataElement, dataElement.length);
|
|
219
|
+
range.collapse(true);
|
|
220
|
+
sel === null || sel === void 0 ? void 0 : sel.removeAllRanges();
|
|
221
|
+
sel === null || sel === void 0 ? void 0 : sel.addRange(range);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
var onInput = null;
|
|
227
|
+
|
|
228
|
+
if (browser.safari) {
|
|
229
|
+
// On Safari, for reasons beyond my understanding,
|
|
230
|
+
// The undo behavior is totally different from other browsers
|
|
231
|
+
// That why we need to have an specific branch only for Safari.
|
|
232
|
+
var _onInput = function _onInput(e) {
|
|
233
|
+
var _target$textContent2;
|
|
234
|
+
|
|
235
|
+
var target = e.target;
|
|
236
|
+
|
|
237
|
+
if (e.isComposing || !(target instanceof HTMLElement)) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (e.inputType === 'historyUndo' && ((_target$textContent2 = target.textContent) === null || _target$textContent2 === void 0 ? void 0 : _target$textContent2.length) === 1) {
|
|
242
|
+
e.preventDefault();
|
|
243
|
+
e.stopPropagation();
|
|
244
|
+
close();
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
element.addEventListener('input', _onInput);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
element.addEventListener('focusout', onFocusOut);
|
|
253
|
+
element.addEventListener('focusin', onFocusIn);
|
|
254
|
+
element.addEventListener('keydown', keyDown);
|
|
255
|
+
element.addEventListener('beforeinput', beforeinput);
|
|
256
|
+
return function () {
|
|
257
|
+
element.removeEventListener('focusout', onFocusOut);
|
|
258
|
+
element.removeEventListener('focusin', onFocusIn);
|
|
259
|
+
element.removeEventListener('keydown', keyDown);
|
|
260
|
+
element.removeEventListener('beforeinput', beforeinput);
|
|
261
|
+
|
|
262
|
+
if (browser.safari) {
|
|
263
|
+
element.removeEventListener('input', onInput);
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
}, [triggerQueryPrefix, cleanedInputContent, onQueryFocus, cancel, checkKeyEvent]);
|
|
267
|
+
useEffect(function () {
|
|
268
|
+
var hasReopenQuery = typeof reopenQuery === 'string' && reopenQuery.trim().length > 0;
|
|
269
|
+
|
|
270
|
+
if (ref.current && forceFocus) {
|
|
271
|
+
ref.current.textContent = hasReopenQuery ? reopenQuery : ZERO_WIDTH_SPACE;
|
|
272
|
+
requestAnimationFrame(function () {
|
|
273
|
+
if (!(ref !== null && ref !== void 0 && ref.current)) {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
var sel = window.getSelection();
|
|
278
|
+
|
|
279
|
+
if (sel && hasReopenQuery && ref.current.lastChild instanceof Text) {
|
|
280
|
+
var lastChild = ref.current.lastChild;
|
|
281
|
+
var range = document.createRange();
|
|
282
|
+
range.setStart(ref.current.lastChild, lastChild.length);
|
|
283
|
+
range.collapse(true);
|
|
284
|
+
sel.removeAllRanges();
|
|
285
|
+
sel.addRange(range);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
ref.current.focus();
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}, [forceFocus, reopenQuery]);
|
|
292
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, triggerQueryPrefix, /*#__PURE__*/React.createElement(QuerySpan, {
|
|
293
|
+
contentEditable: true,
|
|
294
|
+
innerRef: ref,
|
|
295
|
+
onKeyUp: onKeyUp,
|
|
296
|
+
onClick: onClick,
|
|
297
|
+
role: "textbox",
|
|
298
|
+
suppressContentEditableWarning: true,
|
|
299
|
+
"data-query-prefix": triggerQueryPrefix
|
|
300
|
+
}));
|
|
301
|
+
});
|
|
302
|
+
InputQuery.displayName = 'InputQuery';
|