@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
|
@@ -1,226 +1,113 @@
|
|
|
1
|
-
import { Plugin
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { itemsListUpdated } from '../commands/items-list-updated';
|
|
6
|
-
import { selectByIndex } from '../commands/select-item';
|
|
7
|
-
import { updateQueryCommand } from '../commands/update-query';
|
|
8
|
-
import { findTypeAheadQuery } from '../utils/find-query-mark';
|
|
9
|
-
import { isQueryActive } from '../utils/is-query-active';
|
|
1
|
+
import { Plugin } from 'prosemirror-state';
|
|
2
|
+
import { DecorationSet } from 'prosemirror-view';
|
|
3
|
+
import { InsertTypeAheadStep } from '@atlaskit/adf-schema/steps';
|
|
4
|
+
import { TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE } from '../constants';
|
|
10
5
|
import { ACTIONS } from './actions';
|
|
11
|
-
import { pluginKey } from './
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
6
|
+
import { pluginKey } from './key';
|
|
7
|
+
import { closest } from '../../../utils/dom';
|
|
8
|
+
import { createReducer } from './reducer';
|
|
9
|
+
import { factoryDecorations } from './decorations';
|
|
10
|
+
import { isInsertionTransaction } from './utils';
|
|
11
|
+
|
|
12
|
+
const hasTypeAheadStep = tr => {
|
|
13
|
+
const step = tr.steps.find(step => step instanceof InsertTypeAheadStep);
|
|
14
|
+
|
|
15
|
+
if (!step) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return step;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export function createPlugin({
|
|
23
|
+
reactDispatch,
|
|
24
|
+
reactContext,
|
|
25
|
+
popupMountRef,
|
|
26
|
+
createAnalyticsEvent,
|
|
27
|
+
typeAheadHandlers
|
|
28
|
+
}) {
|
|
29
|
+
const intl = reactContext().intl;
|
|
30
|
+
const {
|
|
31
|
+
createDecorations,
|
|
32
|
+
removeDecorations
|
|
33
|
+
} = factoryDecorations({
|
|
34
|
+
intl,
|
|
35
|
+
popupMountRef,
|
|
36
|
+
createAnalyticsEvent: createAnalyticsEvent
|
|
37
|
+
});
|
|
38
|
+
const reducer = createReducer({
|
|
39
|
+
createDecorations,
|
|
40
|
+
removeDecorations,
|
|
41
|
+
typeAheadHandlers,
|
|
42
|
+
popupMountRef
|
|
43
|
+
});
|
|
32
44
|
return new Plugin({
|
|
33
45
|
key: pluginKey,
|
|
34
46
|
state: {
|
|
35
47
|
init() {
|
|
36
|
-
return
|
|
48
|
+
return {
|
|
49
|
+
typeAheadHandlers,
|
|
50
|
+
query: '',
|
|
51
|
+
decorationSet: DecorationSet.empty,
|
|
52
|
+
decorationElement: null,
|
|
53
|
+
items: [],
|
|
54
|
+
selectedIndex: 0,
|
|
55
|
+
stats: null,
|
|
56
|
+
inputMethod: null
|
|
57
|
+
};
|
|
37
58
|
},
|
|
38
59
|
|
|
39
|
-
apply(tr,
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
action,
|
|
43
|
-
params
|
|
44
|
-
} = meta;
|
|
45
|
-
|
|
46
|
-
switch (action) {
|
|
47
|
-
case ACTIONS.SET_CURRENT_INDEX:
|
|
48
|
-
return setCurrentItemIndex({
|
|
49
|
-
dispatch,
|
|
50
|
-
pluginState,
|
|
51
|
-
tr,
|
|
52
|
-
params
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
case ACTIONS.SELECT_PREV:
|
|
56
|
-
return selectPrevActionHandler({
|
|
57
|
-
dispatch,
|
|
58
|
-
pluginState,
|
|
59
|
-
tr
|
|
60
|
-
});
|
|
60
|
+
apply(tr, currentPluginState, oldEditorState, state) {
|
|
61
|
+
const customStep = hasTypeAheadStep(tr);
|
|
62
|
+
const nextPluginState = reducer(tr, currentPluginState, customStep);
|
|
61
63
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
pluginState,
|
|
66
|
-
tr
|
|
67
|
-
});
|
|
64
|
+
if (currentPluginState !== nextPluginState) {
|
|
65
|
+
reactDispatch(pluginKey, nextPluginState);
|
|
66
|
+
}
|
|
68
67
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
dispatch,
|
|
72
|
-
pluginState,
|
|
73
|
-
tr
|
|
74
|
-
});
|
|
68
|
+
return nextPluginState;
|
|
69
|
+
}
|
|
75
70
|
|
|
76
|
-
|
|
77
|
-
const {
|
|
78
|
-
from,
|
|
79
|
-
to
|
|
80
|
-
} = tr.selection;
|
|
81
|
-
const {
|
|
82
|
-
typeAheadQuery
|
|
83
|
-
} = state.schema.marks; // If inserted content has typeAheadQuery mark should fallback to default action handler
|
|
71
|
+
},
|
|
84
72
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
reactContext,
|
|
88
|
-
typeAhead,
|
|
89
|
-
state,
|
|
90
|
-
pluginState,
|
|
91
|
-
tr
|
|
92
|
-
}) : selectCurrentActionHandler({
|
|
93
|
-
dispatch,
|
|
94
|
-
pluginState,
|
|
95
|
-
tr
|
|
96
|
-
});
|
|
73
|
+
appendTransaction(transactions, _oldState, newState) {
|
|
74
|
+
const insertItemCallback = isInsertionTransaction(transactions, ACTIONS.INSERT_RAW_QUERY);
|
|
97
75
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
dispatch,
|
|
101
|
-
pluginState,
|
|
102
|
-
tr,
|
|
103
|
-
params
|
|
104
|
-
});
|
|
76
|
+
if (insertItemCallback) {
|
|
77
|
+
const tr = insertItemCallback(newState);
|
|
105
78
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
dispatch,
|
|
109
|
-
reactContext,
|
|
110
|
-
typeAhead,
|
|
111
|
-
state,
|
|
112
|
-
pluginState,
|
|
113
|
-
tr
|
|
114
|
-
});
|
|
79
|
+
if (tr) {
|
|
80
|
+
return tr;
|
|
115
81
|
}
|
|
116
82
|
}
|
|
117
|
-
|
|
118
83
|
},
|
|
119
84
|
|
|
120
85
|
view() {
|
|
121
86
|
return {
|
|
122
|
-
update(editorView) {
|
|
123
|
-
const pluginState = pluginKey.getState(editorView.state);
|
|
124
|
-
|
|
125
|
-
if (!pluginState) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const {
|
|
130
|
-
state,
|
|
131
|
-
dispatch
|
|
132
|
-
} = editorView;
|
|
133
|
-
const {
|
|
134
|
-
doc,
|
|
135
|
-
selection
|
|
136
|
-
} = state;
|
|
137
|
-
const {
|
|
138
|
-
from,
|
|
139
|
-
to
|
|
140
|
-
} = selection;
|
|
141
|
-
const {
|
|
142
|
-
typeAheadQuery
|
|
143
|
-
} = state.schema.marks; // Disable type ahead query when removing trigger.
|
|
144
|
-
|
|
145
|
-
if (pluginState.active && !pluginState.query && !pluginState.trigger) {
|
|
146
|
-
dismissCommand()(state, dispatch);
|
|
147
|
-
return;
|
|
148
|
-
} // Disable type ahead query when the first character is a space.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
if (pluginState.active && (pluginState.query || '').indexOf(' ') === 0) {
|
|
152
|
-
dismissCommand()(state, dispatch);
|
|
153
|
-
return;
|
|
154
|
-
} // Optimization to not call dismissCommand if plugin is in an inactive state.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
if (!pluginState.active && pluginState.prevActiveState && !doc.rangeHasMark(from - 1, to, typeAheadQuery)) {
|
|
158
|
-
dismissCommand()(state, dispatch);
|
|
159
|
-
return;
|
|
160
|
-
} // Fetch type ahead items if handler returned a promise.
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if (pluginState.active && pluginState.itemsLoader) {
|
|
164
|
-
pluginState.itemsLoader.promise.then(items => itemsListUpdated(items)(editorView.state, dispatch));
|
|
165
|
-
}
|
|
166
|
-
}
|
|
87
|
+
update(editorView) {}
|
|
167
88
|
|
|
168
89
|
};
|
|
169
90
|
},
|
|
170
91
|
|
|
171
|
-
appendTransaction(_trs, _oldState, newState) {
|
|
172
|
-
const pluginState = pluginKey.getState(newState);
|
|
173
|
-
|
|
174
|
-
if (pluginState.active && pluginState.query && pluginState.typeAheadHandler && pluginState.typeAheadHandler.forceSelect) {
|
|
175
|
-
const items = pluginState.items;
|
|
176
|
-
const matchedItem = pluginState.typeAheadHandler.forceSelect(pluginState.query, items);
|
|
177
|
-
|
|
178
|
-
if (matchedItem) {
|
|
179
|
-
let newTr;
|
|
180
|
-
selectByIndex(items.indexOf(matchedItem))(newState, tr => newTr = tr);
|
|
181
|
-
return newTr;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
return null;
|
|
186
|
-
},
|
|
187
|
-
|
|
188
92
|
props: {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const {
|
|
192
|
-
state,
|
|
193
|
-
dispatch
|
|
194
|
-
} = view;
|
|
195
|
-
const {
|
|
196
|
-
selection,
|
|
197
|
-
schema
|
|
198
|
-
} = state;
|
|
199
|
-
|
|
200
|
-
if (selection instanceof TextSelection && selection.$cursor && schema.marks.typeAheadQuery.isInSet(selection.$cursor.marks())) {
|
|
201
|
-
updateQueryCommand(event.data)(state, dispatch);
|
|
202
|
-
return false;
|
|
203
|
-
}
|
|
93
|
+
decorations: state => {
|
|
94
|
+
var _pluginKey$getState;
|
|
204
95
|
|
|
96
|
+
return (_pluginKey$getState = pluginKey.getState(state)) === null || _pluginKey$getState === void 0 ? void 0 : _pluginKey$getState.decorationSet;
|
|
97
|
+
},
|
|
98
|
+
handleDOMEvents: {
|
|
99
|
+
compositionend: (view, event) => {
|
|
205
100
|
return false;
|
|
206
101
|
},
|
|
207
|
-
|
|
208
|
-
// FM-2123: On latest Android version Q there's a bug while compositionend,
|
|
209
|
-
// the typeAheadQuery is inserted next to the position of the trigger character (so that creates double characters).
|
|
210
|
-
// In this use case, need to replace the last written character with our typeAheadQuery.
|
|
211
|
-
compositionend: (view, event) => {
|
|
212
|
-
const {
|
|
213
|
-
state,
|
|
214
|
-
dispatch
|
|
215
|
-
} = view;
|
|
102
|
+
click: (view, event) => {
|
|
216
103
|
const {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
104
|
+
target
|
|
105
|
+
} = event; // ProseMirror view listen to any click event inside of it
|
|
106
|
+
// When this event is coming from the typeahead
|
|
107
|
+
// we should tell to ProseMirror to sit down and relax
|
|
108
|
+
// cuz we know what we are doing (I hope)
|
|
221
109
|
|
|
222
|
-
if (
|
|
223
|
-
insertTypeAheadQuery(event.data, true)(state, dispatch);
|
|
110
|
+
if (target instanceof HTMLElement && closest(target, `[data-type-ahead=${TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE}]`)) {
|
|
224
111
|
return true;
|
|
225
112
|
}
|
|
226
113
|
|
|
@@ -229,211 +116,4 @@ export function createPlugin(dispatch, reactContext, typeAhead) {
|
|
|
229
116
|
}
|
|
230
117
|
}
|
|
231
118
|
});
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
*
|
|
235
|
-
* Action Handlers
|
|
236
|
-
*
|
|
237
|
-
*/
|
|
238
|
-
|
|
239
|
-
export function createItemsLoader(promiseOfItems) {
|
|
240
|
-
let canceled = false;
|
|
241
|
-
return {
|
|
242
|
-
promise: new Promise((resolve, reject) => {
|
|
243
|
-
promiseOfItems.then(result => !canceled && resolve(result)).catch(error => !canceled && reject(error));
|
|
244
|
-
}),
|
|
245
|
-
|
|
246
|
-
cancel() {
|
|
247
|
-
canceled = true;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
export function defaultActionHandler({
|
|
253
|
-
dispatch,
|
|
254
|
-
reactContext,
|
|
255
|
-
typeAhead,
|
|
256
|
-
pluginState,
|
|
257
|
-
state,
|
|
258
|
-
tr
|
|
259
|
-
}) {
|
|
260
|
-
const {
|
|
261
|
-
typeAheadQuery
|
|
262
|
-
} = state.schema.marks;
|
|
263
|
-
const {
|
|
264
|
-
doc,
|
|
265
|
-
selection
|
|
266
|
-
} = state;
|
|
267
|
-
const {
|
|
268
|
-
from,
|
|
269
|
-
to
|
|
270
|
-
} = selection;
|
|
271
|
-
const isActive = isQueryActive(typeAheadQuery, doc, from - 1, to);
|
|
272
|
-
const isAllowed = isMarkTypeAllowedInCurrentSelection(typeAheadQuery, state);
|
|
273
|
-
|
|
274
|
-
if (!isAllowed && !isActive) {
|
|
275
|
-
if (pluginState && pluginState.active === isActive && pluginState.isAllowed === isAllowed) {
|
|
276
|
-
return pluginState;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
const newPluginState = createInitialPluginState(pluginState.active, isAllowed);
|
|
280
|
-
dispatch(pluginKey, newPluginState);
|
|
281
|
-
return newPluginState;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
const {
|
|
285
|
-
nodeBefore
|
|
286
|
-
} = selection.$from;
|
|
287
|
-
|
|
288
|
-
if (!isActive || !nodeBefore || !pluginState) {
|
|
289
|
-
const newPluginState = createInitialPluginState(pluginState ? pluginState.active : false);
|
|
290
|
-
|
|
291
|
-
if (!pluginState || pluginState.active || !pluginState.isAllowed) {
|
|
292
|
-
dispatch(pluginKey, newPluginState);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
return newPluginState;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
const typeAheadMark = typeAheadQuery.isInSet(nodeBefore.marks || []);
|
|
299
|
-
|
|
300
|
-
if (!typeAheadMark || !typeAheadMark.attrs.trigger) {
|
|
301
|
-
return pluginState;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
const textContent = nodeBefore.textContent || '';
|
|
305
|
-
const trigger = typeAheadMark.attrs.trigger.replace(/([^\x00-\xFF]|[\s\n])+/g, ''); // If trigger has been removed, reset plugin state
|
|
306
|
-
|
|
307
|
-
if (!textContent.includes(trigger)) {
|
|
308
|
-
const newPluginState = { ...createInitialPluginState(true),
|
|
309
|
-
active: true
|
|
310
|
-
};
|
|
311
|
-
dispatch(pluginKey, newPluginState);
|
|
312
|
-
return newPluginState;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
const query = textContent.replace(/^([^\x00-\xFF]|[\s\n])+/g, '').replace(trigger, '');
|
|
316
|
-
const typeAheadHandler = typeAhead.find(t => t.trigger === trigger);
|
|
317
|
-
let typeAheadItems = [];
|
|
318
|
-
let itemsLoader = null;
|
|
319
|
-
let highlight = null;
|
|
320
|
-
|
|
321
|
-
try {
|
|
322
|
-
const {
|
|
323
|
-
intl
|
|
324
|
-
} = reactContext();
|
|
325
|
-
typeAheadItems = typeAheadHandler.getItems(query, state, intl, {
|
|
326
|
-
prevActive: pluginState.prevActiveState,
|
|
327
|
-
queryChanged: query !== pluginState.query || trigger !== pluginState.trigger
|
|
328
|
-
}, tr, dispatch);
|
|
329
|
-
|
|
330
|
-
if (typeAheadHandler.getHighlight) {
|
|
331
|
-
highlight = typeAheadHandler.getHighlight(state);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
if (pluginState.itemsLoader) {
|
|
335
|
-
pluginState.itemsLoader.cancel();
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
if (!Array.isArray(typeAheadItems)) {
|
|
339
|
-
itemsLoader = createItemsLoader(typeAheadItems);
|
|
340
|
-
typeAheadItems = pluginState.items;
|
|
341
|
-
}
|
|
342
|
-
} catch (e) {}
|
|
343
|
-
|
|
344
|
-
const queryMark = findTypeAheadQuery(state);
|
|
345
|
-
const newPluginState = {
|
|
346
|
-
isAllowed,
|
|
347
|
-
query,
|
|
348
|
-
trigger,
|
|
349
|
-
typeAheadHandler,
|
|
350
|
-
active: true,
|
|
351
|
-
prevActiveState: pluginState.active,
|
|
352
|
-
items: typeAheadItems,
|
|
353
|
-
itemsLoader: itemsLoader,
|
|
354
|
-
currentIndex: pluginState.currentIndex,
|
|
355
|
-
queryMarkPos: queryMark !== null ? queryMark.start : null,
|
|
356
|
-
queryStarted: Date.now(),
|
|
357
|
-
upKeyCount: 0,
|
|
358
|
-
downKeyCount: 0,
|
|
359
|
-
highlight
|
|
360
|
-
};
|
|
361
|
-
dispatch(pluginKey, newPluginState);
|
|
362
|
-
return newPluginState;
|
|
363
|
-
}
|
|
364
|
-
export function setCurrentItemIndex({
|
|
365
|
-
dispatch,
|
|
366
|
-
pluginState,
|
|
367
|
-
params
|
|
368
|
-
}) {
|
|
369
|
-
if (!params) {
|
|
370
|
-
return pluginState;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
const newPluginState = { ...pluginState,
|
|
374
|
-
currentIndex: params.currentIndex || params.currentIndex === 0 ? params.currentIndex : pluginState.currentIndex
|
|
375
|
-
};
|
|
376
|
-
dispatch(pluginKey, newPluginState);
|
|
377
|
-
return newPluginState;
|
|
378
|
-
}
|
|
379
|
-
export function updateQueryHandler({
|
|
380
|
-
dispatch,
|
|
381
|
-
pluginState,
|
|
382
|
-
params
|
|
383
|
-
}) {
|
|
384
|
-
if (!params) {
|
|
385
|
-
return pluginState;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
const newPluginState = { ...pluginState,
|
|
389
|
-
query: typeof params.query === 'string' ? params.query : null
|
|
390
|
-
};
|
|
391
|
-
dispatch(pluginKey, newPluginState);
|
|
392
|
-
return newPluginState;
|
|
393
|
-
}
|
|
394
|
-
export function selectPrevActionHandler({
|
|
395
|
-
dispatch,
|
|
396
|
-
pluginState
|
|
397
|
-
}) {
|
|
398
|
-
const newIndex = pluginState.currentIndex - 1;
|
|
399
|
-
const newPluginState = { ...pluginState,
|
|
400
|
-
currentIndex: newIndex < 0 ? pluginState.items.length - 1 : newIndex,
|
|
401
|
-
upKeyCount: ++pluginState.upKeyCount
|
|
402
|
-
};
|
|
403
|
-
dispatch(pluginKey, newPluginState);
|
|
404
|
-
return newPluginState;
|
|
405
|
-
}
|
|
406
|
-
export function selectNextActionHandler({
|
|
407
|
-
dispatch,
|
|
408
|
-
pluginState
|
|
409
|
-
}) {
|
|
410
|
-
const newIndex = pluginState.currentIndex + 1;
|
|
411
|
-
const newPluginState = { ...pluginState,
|
|
412
|
-
currentIndex: newIndex > pluginState.items.length - 1 ? 0 : newIndex,
|
|
413
|
-
downKeyCount: ++pluginState.downKeyCount
|
|
414
|
-
};
|
|
415
|
-
dispatch(pluginKey, newPluginState);
|
|
416
|
-
return newPluginState;
|
|
417
|
-
}
|
|
418
|
-
export function itemsListUpdatedActionHandler({
|
|
419
|
-
dispatch,
|
|
420
|
-
pluginState,
|
|
421
|
-
tr
|
|
422
|
-
}) {
|
|
423
|
-
const items = tr.getMeta(pluginKey).items;
|
|
424
|
-
const newPluginState = { ...pluginState,
|
|
425
|
-
items,
|
|
426
|
-
itemsLoader: null,
|
|
427
|
-
// Set to 0 to always reset the query to the top of the typeahead
|
|
428
|
-
currentIndex: 0
|
|
429
|
-
};
|
|
430
|
-
dispatch(pluginKey, newPluginState);
|
|
431
|
-
return newPluginState;
|
|
432
|
-
}
|
|
433
|
-
export function selectCurrentActionHandler({
|
|
434
|
-
dispatch
|
|
435
|
-
}) {
|
|
436
|
-
const newPluginState = createInitialPluginState(false);
|
|
437
|
-
dispatch(pluginKey, newPluginState);
|
|
438
|
-
return newPluginState;
|
|
439
119
|
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { DecorationSet } from 'prosemirror-view';
|
|
2
|
+
import { InsertTypeAheadStep, InsertTypeAheadStages } from '@atlaskit/adf-schema/steps';
|
|
3
|
+
import { ACTIONS } from './actions';
|
|
4
|
+
import { pluginKey } from './key';
|
|
5
|
+
import { INPUT_METHOD } from '../../analytics/types/enums';
|
|
6
|
+
import { isTypeAheadHandler } from '../utils';
|
|
7
|
+
|
|
8
|
+
const shouldForceOpen = step => {
|
|
9
|
+
if (!(step instanceof InsertTypeAheadStep)) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const isDeletionRawQueryOperation = step.isInsertionStep() && step.stage === InsertTypeAheadStages.DELETING_RAW_QUERY;
|
|
14
|
+
const isUndoingInsertionItem = step.isUndoingStep() && step.stage === InsertTypeAheadStages.INSERTING_ITEM;
|
|
15
|
+
return isDeletionRawQueryOperation || isUndoingInsertionItem;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const shouldForceClose = step => {
|
|
19
|
+
if (!(step instanceof InsertTypeAheadStep)) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const isInsertingItem = step.isInsertionStep() && step.stage === InsertTypeAheadStages.INSERTING_ITEM;
|
|
24
|
+
const isUndoingDeletionRawQuery = step.isUndoingStep() && step.stage === InsertTypeAheadStages.DELETING_RAW_QUERY;
|
|
25
|
+
return isInsertingItem || isUndoingDeletionRawQuery;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const createFindHandler = typeAheadHandlers => step => {
|
|
29
|
+
if (!(step instanceof InsertTypeAheadStep)) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const handler = typeAheadHandlers.find(h => h.trigger === step.trigger);
|
|
34
|
+
return handler || null;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const createReducer = ({
|
|
38
|
+
typeAheadHandlers,
|
|
39
|
+
removeDecorations,
|
|
40
|
+
createDecorations
|
|
41
|
+
}) => {
|
|
42
|
+
const findHandler = createFindHandler(typeAheadHandlers);
|
|
43
|
+
|
|
44
|
+
const openMenu = (currentPluginState, {
|
|
45
|
+
tr,
|
|
46
|
+
triggerHandler,
|
|
47
|
+
inputMethod,
|
|
48
|
+
reopenQuery,
|
|
49
|
+
selectedIndex
|
|
50
|
+
}) => {
|
|
51
|
+
removeDecorations(currentPluginState.decorationSet);
|
|
52
|
+
const {
|
|
53
|
+
decorationSet,
|
|
54
|
+
decorationElement,
|
|
55
|
+
stats
|
|
56
|
+
} = createDecorations(tr, {
|
|
57
|
+
triggerHandler,
|
|
58
|
+
inputMethod,
|
|
59
|
+
reopenQuery
|
|
60
|
+
});
|
|
61
|
+
return { ...currentPluginState,
|
|
62
|
+
stats,
|
|
63
|
+
decorationSet,
|
|
64
|
+
triggerHandler,
|
|
65
|
+
decorationElement,
|
|
66
|
+
inputMethod,
|
|
67
|
+
selectedIndex: typeof selectedIndex === 'number' ? selectedIndex : 0,
|
|
68
|
+
items: [],
|
|
69
|
+
query: reopenQuery || ''
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const closeMenu = currentPluginState => {
|
|
74
|
+
removeDecorations(currentPluginState.decorationSet);
|
|
75
|
+
return { ...currentPluginState,
|
|
76
|
+
inputMethod: null,
|
|
77
|
+
query: '',
|
|
78
|
+
decorationElement: null,
|
|
79
|
+
decorationSet: DecorationSet.empty,
|
|
80
|
+
stats: null,
|
|
81
|
+
triggerHandler: undefined,
|
|
82
|
+
items: []
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
return (tr, currentPluginState, typeAheadStepOverride) => {
|
|
87
|
+
const meta = tr.getMeta(pluginKey) || {}; // This code below controls when we should force
|
|
88
|
+
// the menu to open or close during undo/redo operations
|
|
89
|
+
|
|
90
|
+
const overrideHandler = findHandler(typeAheadStepOverride);
|
|
91
|
+
|
|
92
|
+
if (typeAheadStepOverride && overrideHandler && shouldForceOpen(typeAheadStepOverride)) {
|
|
93
|
+
return openMenu(currentPluginState, {
|
|
94
|
+
tr,
|
|
95
|
+
triggerHandler: overrideHandler,
|
|
96
|
+
inputMethod: INPUT_METHOD.KEYBOARD,
|
|
97
|
+
reopenQuery: typeAheadStepOverride.query,
|
|
98
|
+
selectedIndex: typeAheadStepOverride.selectedIndex
|
|
99
|
+
});
|
|
100
|
+
} else if (shouldForceClose(typeAheadStepOverride)) {
|
|
101
|
+
return closeMenu(currentPluginState);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const {
|
|
105
|
+
action,
|
|
106
|
+
params
|
|
107
|
+
} = meta || {};
|
|
108
|
+
const shouldOpenMenu = action === ACTIONS.OPEN_TYPEAHEAD_AT_CURSOR && isTypeAheadHandler(params === null || params === void 0 ? void 0 : params.triggerHandler);
|
|
109
|
+
const selectionChanged = tr.selectionSet && (tr.isGeneric || Boolean(tr.getMeta('pointer')));
|
|
110
|
+
const shouldCloseMenu = [ACTIONS.CLOSE_TYPE_AHEAD, ACTIONS.INSERT_ITEM].includes(action) || selectionChanged;
|
|
111
|
+
const shouldUpdateQuery = action === ACTIONS.CHANGE_QUERY;
|
|
112
|
+
const shouldUpdateListItems = action === ACTIONS.UPDATE_LIST_ITEMS;
|
|
113
|
+
const shouldUpdateSelectedIndex = action === ACTIONS.UPDATE_SELECTED_INDEX;
|
|
114
|
+
|
|
115
|
+
if (shouldOpenMenu) {
|
|
116
|
+
return openMenu(currentPluginState, {
|
|
117
|
+
tr,
|
|
118
|
+
triggerHandler: params.triggerHandler,
|
|
119
|
+
inputMethod: params.inputMethod
|
|
120
|
+
});
|
|
121
|
+
} else if (shouldCloseMenu) {
|
|
122
|
+
return closeMenu(currentPluginState);
|
|
123
|
+
} else if (shouldUpdateQuery) {
|
|
124
|
+
return { ...currentPluginState,
|
|
125
|
+
query: params.query
|
|
126
|
+
};
|
|
127
|
+
} else if (shouldUpdateListItems) {
|
|
128
|
+
const {
|
|
129
|
+
items
|
|
130
|
+
} = params;
|
|
131
|
+
const {
|
|
132
|
+
selectedIndex
|
|
133
|
+
} = currentPluginState;
|
|
134
|
+
return { ...currentPluginState,
|
|
135
|
+
items,
|
|
136
|
+
selectedIndex: Math.max(selectedIndex >= items.length ? items.length - 1 : selectedIndex, 0)
|
|
137
|
+
};
|
|
138
|
+
} else if (shouldUpdateSelectedIndex) {
|
|
139
|
+
return { ...currentPluginState,
|
|
140
|
+
selectedIndex: params.selectedIndex
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (tr.docChanged) {
|
|
145
|
+
const {
|
|
146
|
+
decorationSet
|
|
147
|
+
} = currentPluginState;
|
|
148
|
+
|
|
149
|
+
const onRemove = () => {
|
|
150
|
+
// Make sure we are unmounting the component
|
|
151
|
+
// from the react tree when this decoration is removed
|
|
152
|
+
removeDecorations(currentPluginState.decorationSet);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const mappedDecorationSet = decorationSet.map(tr.mapping, tr.doc, {
|
|
156
|
+
onRemove
|
|
157
|
+
});
|
|
158
|
+
return { ...currentPluginState,
|
|
159
|
+
decorationSet: mappedDecorationSet
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return currentPluginState;
|
|
164
|
+
};
|
|
165
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { pluginKey } from './key';
|
|
2
|
+
export const isInsertionTransaction = (transactions, action) => {
|
|
3
|
+
var _tr$getMeta2;
|
|
4
|
+
|
|
5
|
+
const tr = transactions.find(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
|
+
};
|