@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,228 @@
|
|
|
1
|
+
import { TypeAheadAvailableNodes, SelectItemMode } from '@atlaskit/editor-common/type-ahead';
|
|
2
|
+
import { findHandler, isTypeAheadOpen, getTypeAheadHandler, getTypeAheadQuery } from './utils';
|
|
3
|
+
import { INPUT_METHOD } from '../analytics/types/enums';
|
|
4
|
+
import { openTypeAheadAtCursor } from './transforms/open-typeahead-at-cursor';
|
|
5
|
+
import { closeTypeAhead } from './transforms/close-type-ahead';
|
|
6
|
+
import { updateQuery } from './commands/update-query';
|
|
7
|
+
import { insertTypeAheadItem } from './commands/insert-type-ahead-item';
|
|
8
|
+
|
|
9
|
+
var open = function open(_ref) {
|
|
10
|
+
var editorView = _ref.editorView;
|
|
11
|
+
return function (itemType) {
|
|
12
|
+
return function (inputMethod) {
|
|
13
|
+
var state = editorView.state;
|
|
14
|
+
var handler = findHandler(itemType, state);
|
|
15
|
+
|
|
16
|
+
if (!handler) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
var tr = state.tr;
|
|
21
|
+
openTypeAheadAtCursor({
|
|
22
|
+
triggerHandler: handler,
|
|
23
|
+
inputMethod: inputMethod
|
|
24
|
+
})(tr);
|
|
25
|
+
editorView.dispatch(tr);
|
|
26
|
+
return true;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
var defaultCloseOptions = {
|
|
32
|
+
insertCurrentQueryAsRawText: false
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
var close = function close(_ref2) {
|
|
36
|
+
var editorView = _ref2.editorView;
|
|
37
|
+
return function () {
|
|
38
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultCloseOptions;
|
|
39
|
+
var state = editorView.state;
|
|
40
|
+
var currentQuery = getTypeAheadQuery(editorView.state);
|
|
41
|
+
var tr = state.tr;
|
|
42
|
+
|
|
43
|
+
if (options.attachCommand) {
|
|
44
|
+
var fakeDispatch = function fakeDispatch(customTr) {
|
|
45
|
+
tr = customTr;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
options.attachCommand(state, fakeDispatch);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
closeTypeAhead(tr);
|
|
52
|
+
|
|
53
|
+
if (options.insertCurrentQueryAsRawText && currentQuery && currentQuery.length > 0) {
|
|
54
|
+
var handler = getTypeAheadHandler(state);
|
|
55
|
+
var text = handler.trigger.concat(currentQuery);
|
|
56
|
+
tr.replaceSelectionWith(state.schema.text(text));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
editorView.dispatch(tr);
|
|
60
|
+
|
|
61
|
+
if (!editorView.hasFocus()) {
|
|
62
|
+
editorView.focus();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return true;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
var search = function search(_ref3) {
|
|
70
|
+
var editorView = _ref3.editorView;
|
|
71
|
+
return function (itemType) {
|
|
72
|
+
return function () {
|
|
73
|
+
var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
74
|
+
var state = editorView.state;
|
|
75
|
+
var handler = findHandler(itemType, state);
|
|
76
|
+
|
|
77
|
+
if (!handler) {
|
|
78
|
+
throw new Error("Handler not found, did you load the ".concat(itemType, " plugin properly"));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
open({
|
|
82
|
+
editorView: editorView
|
|
83
|
+
})(itemType)(INPUT_METHOD.KEYBOARD);
|
|
84
|
+
updateQuery(query)(editorView.state, editorView.dispatch);
|
|
85
|
+
var lastQuery = {
|
|
86
|
+
current: query
|
|
87
|
+
};
|
|
88
|
+
var last = handler.getItems({
|
|
89
|
+
query: query,
|
|
90
|
+
editorState: state
|
|
91
|
+
}).then(function (items) {
|
|
92
|
+
if (!handler.forceSelect) {
|
|
93
|
+
return items;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
var forceSelectedItem = handler.forceSelect({
|
|
97
|
+
items: items,
|
|
98
|
+
query: query,
|
|
99
|
+
editorState: state
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
if (!forceSelectedItem) {
|
|
103
|
+
return items;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
insertTypeAheadItem(editorView)({
|
|
107
|
+
handler: handler,
|
|
108
|
+
item: forceSelectedItem,
|
|
109
|
+
query: query,
|
|
110
|
+
mode: SelectItemMode.SELECTED,
|
|
111
|
+
sourceListItem: items
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
var results = {
|
|
115
|
+
last: last
|
|
116
|
+
};
|
|
117
|
+
return {
|
|
118
|
+
type: function type(appendValue) {
|
|
119
|
+
if (!appendValue) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
lastQuery.current += appendValue;
|
|
124
|
+
updateQuery(lastQuery.current)(editorView.state, editorView.dispatch);
|
|
125
|
+
var promise = handler.getItems({
|
|
126
|
+
query: lastQuery.current,
|
|
127
|
+
editorState: state
|
|
128
|
+
});
|
|
129
|
+
results.last = promise;
|
|
130
|
+
return promise;
|
|
131
|
+
},
|
|
132
|
+
result: function result() {
|
|
133
|
+
return results.last;
|
|
134
|
+
},
|
|
135
|
+
close: close({
|
|
136
|
+
editorView: editorView
|
|
137
|
+
}),
|
|
138
|
+
insert: function insert(_ref4) {
|
|
139
|
+
var index = _ref4.index,
|
|
140
|
+
mode = _ref4.mode;
|
|
141
|
+
return results.last.then(function (result) {
|
|
142
|
+
var item = result ? result[index] : null;
|
|
143
|
+
|
|
144
|
+
if (result && item) {
|
|
145
|
+
insertTypeAheadItem(editorView)({
|
|
146
|
+
handler: handler,
|
|
147
|
+
item: item,
|
|
148
|
+
query: query,
|
|
149
|
+
mode: mode || SelectItemMode.SELECTED,
|
|
150
|
+
sourceListItem: result
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
var insertItem = function insertItem(_ref5) {
|
|
161
|
+
var editorView = _ref5.editorView;
|
|
162
|
+
return function (itemType) {
|
|
163
|
+
return function (_ref6) {
|
|
164
|
+
var contentItem = _ref6.contentItem,
|
|
165
|
+
query = _ref6.query,
|
|
166
|
+
sourceListItem = _ref6.sourceListItem;
|
|
167
|
+
var state = editorView.state;
|
|
168
|
+
var handler = findHandler(itemType, state);
|
|
169
|
+
|
|
170
|
+
if (!handler) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
insertTypeAheadItem(editorView)({
|
|
175
|
+
handler: handler,
|
|
176
|
+
item: contentItem,
|
|
177
|
+
mode: SelectItemMode.SELECTED,
|
|
178
|
+
query: query,
|
|
179
|
+
sourceListItem: sourceListItem
|
|
180
|
+
});
|
|
181
|
+
return true;
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
var isOpen = function isOpen(_ref7) {
|
|
187
|
+
var editorView = _ref7.editorView;
|
|
188
|
+
return function () {
|
|
189
|
+
if (!isTypeAheadOpen(editorView.state)) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
var handler = getTypeAheadHandler(editorView.state);
|
|
194
|
+
|
|
195
|
+
if (!handler) {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return handler;
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
var currentQuery = function currentQuery(_ref8) {
|
|
204
|
+
var editorView = _ref8.editorView;
|
|
205
|
+
return function () {
|
|
206
|
+
return getTypeAheadQuery(editorView.state);
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
export var createTypeAheadTools = function createTypeAheadTools(editorView) {
|
|
211
|
+
var props = {
|
|
212
|
+
editorView: editorView
|
|
213
|
+
};
|
|
214
|
+
return {
|
|
215
|
+
isOpen: isOpen(props),
|
|
216
|
+
currentQuery: currentQuery(props),
|
|
217
|
+
close: close(props),
|
|
218
|
+
openMention: open(props)(TypeAheadAvailableNodes.MENTION),
|
|
219
|
+
searchMention: search(props)(TypeAheadAvailableNodes.MENTION),
|
|
220
|
+
openQuickInsert: open(props)(TypeAheadAvailableNodes.QUICK_INSERT),
|
|
221
|
+
searchQuickInsert: search(props)(TypeAheadAvailableNodes.QUICK_INSERT),
|
|
222
|
+
openEmoji: open(props)(TypeAheadAvailableNodes.EMOJI),
|
|
223
|
+
searchEmoji: search(props)(TypeAheadAvailableNodes.EMOJI),
|
|
224
|
+
insertItemMention: insertItem(props)(TypeAheadAvailableNodes.MENTION),
|
|
225
|
+
insertItemEmoji: insertItem(props)(TypeAheadAvailableNodes.EMOJI),
|
|
226
|
+
insertItemQuickInsert: insertItem(props)(TypeAheadAvailableNodes.QUICK_INSERT)
|
|
227
|
+
};
|
|
228
|
+
};
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import { Node as PMNode, Fragment } from 'prosemirror-model';
|
|
3
|
+
import { InsertTypeAheadStep, InsertTypeAheadStages } from '@atlaskit/adf-schema/steps';
|
|
4
|
+
import { closeHistory } from 'prosemirror-history';
|
|
5
|
+
import { pluginKey } from '../pm-plugins/key';
|
|
6
|
+
import { insertBlockNode, insertInlineNodeOrFragment } from '../insert-utils';
|
|
7
|
+
import { StatsModifier } from '../stats-modifier';
|
|
8
|
+
import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
|
|
9
|
+
import { ACTIONS } from '../pm-plugins/actions';
|
|
10
|
+
import { closeTypeAhead } from '../transforms/close-type-ahead';
|
|
11
|
+
import { getPluginState } from '../utils';
|
|
12
|
+
|
|
13
|
+
var validateNode = function validateNode(_ref) {
|
|
14
|
+
var schema = _ref.schema,
|
|
15
|
+
maybeNode = _ref.maybeNode;
|
|
16
|
+
|
|
17
|
+
if (!maybeNode) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (maybeNode instanceof PMNode || maybeNode instanceof Fragment) {
|
|
22
|
+
return maybeNode;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (typeof maybeNode === 'string') {
|
|
26
|
+
return schema.text(maybeNode);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
return PMNode.fromJSON(schema, maybeNode);
|
|
31
|
+
} catch (e) {
|
|
32
|
+
// eslint-disable-next-line no-console
|
|
33
|
+
console.error(e);
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
var createInsertCallback = function createInsertCallback(_ref2) {
|
|
39
|
+
var state = _ref2.editorState,
|
|
40
|
+
handler = _ref2.handler,
|
|
41
|
+
query = _ref2.query,
|
|
42
|
+
mode = _ref2.mode,
|
|
43
|
+
wasInsertedBySpace = _ref2.wasInsertedBySpace,
|
|
44
|
+
selectedIndex = _ref2.selectedIndex,
|
|
45
|
+
textStartPosition = _ref2.textStartPosition,
|
|
46
|
+
textInserted = _ref2.textInserted;
|
|
47
|
+
return function (maybeNode) {
|
|
48
|
+
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
49
|
+
var tr = state.tr;
|
|
50
|
+
var position = {
|
|
51
|
+
start: textStartPosition,
|
|
52
|
+
end: textStartPosition + (wasInsertedBySpace ? textInserted.length : 0)
|
|
53
|
+
};
|
|
54
|
+
var node = validateNode({
|
|
55
|
+
schema: state.schema,
|
|
56
|
+
maybeNode: maybeNode
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
if (!node) {
|
|
60
|
+
closeTypeAhead(tr); // In this kind of situation we need to
|
|
61
|
+
// delete the raw text query
|
|
62
|
+
|
|
63
|
+
tr.delete(position.start, position.end);
|
|
64
|
+
return tr;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
node instanceof PMNode && node.isBlock ? insertBlockNode({
|
|
68
|
+
node: node,
|
|
69
|
+
tr: tr,
|
|
70
|
+
position: position
|
|
71
|
+
}) : insertInlineNodeOrFragment({
|
|
72
|
+
maybeFragment: node,
|
|
73
|
+
tr: tr,
|
|
74
|
+
position: position,
|
|
75
|
+
selectInlineNode: Boolean(opts.selectInlineNode)
|
|
76
|
+
});
|
|
77
|
+
closeHistory(tr);
|
|
78
|
+
|
|
79
|
+
if (wasInsertedBySpace) {
|
|
80
|
+
return tr;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
var config = {
|
|
84
|
+
stage: InsertTypeAheadStages.INSERTING_ITEM,
|
|
85
|
+
query: query,
|
|
86
|
+
selectedIndex: selectedIndex,
|
|
87
|
+
trigger: handler.trigger
|
|
88
|
+
};
|
|
89
|
+
tr.step(new InsertTypeAheadStep(config));
|
|
90
|
+
return tr;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
var createDeleteRawTextCallback = function createDeleteRawTextCallback(_ref3) {
|
|
95
|
+
var trigger = _ref3.trigger,
|
|
96
|
+
selectedIndex = _ref3.selectedIndex,
|
|
97
|
+
position = _ref3.position,
|
|
98
|
+
query = _ref3.query,
|
|
99
|
+
wasInsertedBySpace = _ref3.wasInsertedBySpace,
|
|
100
|
+
insertItem = _ref3.insertItem;
|
|
101
|
+
return function (newState) {
|
|
102
|
+
var tr = newState.tr;
|
|
103
|
+
closeHistory(tr);
|
|
104
|
+
|
|
105
|
+
if (!wasInsertedBySpace) {
|
|
106
|
+
tr.delete(position.start, position.end);
|
|
107
|
+
var config = {
|
|
108
|
+
stage: InsertTypeAheadStages.DELETING_RAW_QUERY,
|
|
109
|
+
selectedIndex: selectedIndex,
|
|
110
|
+
query: query,
|
|
111
|
+
trigger: trigger
|
|
112
|
+
};
|
|
113
|
+
tr.step(new InsertTypeAheadStep(config));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
tr.setMeta(pluginKey, {
|
|
117
|
+
action: ACTIONS.INSERT_ITEM,
|
|
118
|
+
params: insertItem
|
|
119
|
+
});
|
|
120
|
+
return tr;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export var insertTypeAheadItem = function insertTypeAheadItem(view) {
|
|
125
|
+
return function (_ref4) {
|
|
126
|
+
var item = _ref4.item,
|
|
127
|
+
handler = _ref4.handler,
|
|
128
|
+
mode = _ref4.mode,
|
|
129
|
+
query = _ref4.query,
|
|
130
|
+
sourceListItem = _ref4.sourceListItem;
|
|
131
|
+
var pluginState = getPluginState(view.state);
|
|
132
|
+
|
|
133
|
+
if (!pluginState) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
var stats = (pluginState.stats || new StatsModifier()).serialize();
|
|
138
|
+
var meta = {
|
|
139
|
+
mode: mode,
|
|
140
|
+
query: query,
|
|
141
|
+
stats: stats,
|
|
142
|
+
sourceListItem: sourceListItem
|
|
143
|
+
};
|
|
144
|
+
var tr = view.state.tr;
|
|
145
|
+
var trigger = handler.trigger;
|
|
146
|
+
var text = "".concat(trigger).concat(query);
|
|
147
|
+
|
|
148
|
+
if (mode === SelectItemMode.SPACE) {
|
|
149
|
+
text = text.trim().concat(' ');
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
var selectedIndex = Math.max(sourceListItem.indexOf(item), 0);
|
|
153
|
+
var wasInsertedBySpace = mode === SelectItemMode.SPACE;
|
|
154
|
+
var textStartPosition = tr.selection.from;
|
|
155
|
+
|
|
156
|
+
var insertItem = function insertItem(newEditorSate) {
|
|
157
|
+
var insertCallback = createInsertCallback({
|
|
158
|
+
editorState: newEditorSate,
|
|
159
|
+
query: query,
|
|
160
|
+
mode: mode,
|
|
161
|
+
handler: handler,
|
|
162
|
+
wasInsertedBySpace: wasInsertedBySpace,
|
|
163
|
+
selectedIndex: selectedIndex,
|
|
164
|
+
textInserted: text,
|
|
165
|
+
textStartPosition: textStartPosition
|
|
166
|
+
});
|
|
167
|
+
var wasInsertCallbackCalled = false; // Some wierd plugins doesn't call the insert item callback
|
|
168
|
+
// For example, the link quick insert item
|
|
169
|
+
// For those cases we need to make sure we are closing the typeahead
|
|
170
|
+
|
|
171
|
+
var proxyHandler = {
|
|
172
|
+
apply: function apply(target, _thisContext, argumentsList) {
|
|
173
|
+
wasInsertCallbackCalled = true;
|
|
174
|
+
return target.apply(void 0, _toConsumableArray(argumentsList));
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
var insertCallbackProxy = new Proxy(insertCallback, proxyHandler);
|
|
178
|
+
var nextTr = handler.selectItem(newEditorSate, item, insertCallbackProxy, meta);
|
|
179
|
+
|
|
180
|
+
if (!wasInsertCallbackCalled && nextTr) {
|
|
181
|
+
closeHistory(nextTr); // In some cases we need to re-open the typeahead
|
|
182
|
+
// e.g.: addign mentions from the quick insert
|
|
183
|
+
//
|
|
184
|
+
// Today, the QuickInsert API doesn't have a tool
|
|
185
|
+
// to help on this. So the code below will close the typeahead
|
|
186
|
+
// only if there is no previous metadata about typeahead in the
|
|
187
|
+
// next transaction
|
|
188
|
+
|
|
189
|
+
if (!nextTr.getMeta(pluginKey)) {
|
|
190
|
+
closeTypeAhead(nextTr);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return nextTr;
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
var position = {
|
|
198
|
+
start: tr.selection.from,
|
|
199
|
+
end: tr.selection.from + text.length
|
|
200
|
+
};
|
|
201
|
+
tr.setMeta(pluginKey, {
|
|
202
|
+
action: ACTIONS.INSERT_RAW_QUERY,
|
|
203
|
+
params: createDeleteRawTextCallback({
|
|
204
|
+
wasInsertedBySpace: wasInsertedBySpace,
|
|
205
|
+
selectedIndex: selectedIndex,
|
|
206
|
+
insertItem: insertItem,
|
|
207
|
+
position: position,
|
|
208
|
+
query: query,
|
|
209
|
+
trigger: trigger
|
|
210
|
+
})
|
|
211
|
+
});
|
|
212
|
+
tr.insertText(text);
|
|
213
|
+
closeHistory(tr);
|
|
214
|
+
view.dispatch(tr);
|
|
215
|
+
view.focus();
|
|
216
|
+
};
|
|
217
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { pluginKey as typeAheadPluginKey } from '../pm-plugins/key';
|
|
2
|
+
import { ACTIONS } from '../pm-plugins/actions';
|
|
3
|
+
export var updateListItem = function updateListItem(items) {
|
|
4
|
+
return function (state, dispatch) {
|
|
5
|
+
var tr = state.tr;
|
|
6
|
+
tr.setMeta(typeAheadPluginKey, {
|
|
7
|
+
action: ACTIONS.UPDATE_LIST_ITEMS,
|
|
8
|
+
params: {
|
|
9
|
+
items: items
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
if (dispatch) {
|
|
14
|
+
dispatch(tr);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return true;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
+
import { pluginKey as typeAheadPluginKey } from '../pm-plugins/key';
|
|
1
2
|
import { ACTIONS } from '../pm-plugins/actions';
|
|
2
|
-
|
|
3
|
-
import { findTypeAheadQuery } from '../utils/find-query-mark';
|
|
4
|
-
import { isQueryActive } from '../utils/is-query-active';
|
|
5
|
-
export var updateQueryCommand = function updateQueryCommand(query) {
|
|
3
|
+
export var updateQuery = function updateQuery(query) {
|
|
6
4
|
return function (state, dispatch) {
|
|
7
|
-
var
|
|
8
|
-
var activeQuery = isQueryActive(state.schema.marks.typeAheadQuery, state.doc, state.selection.from, state.selection.to);
|
|
5
|
+
var pluginState = typeAheadPluginKey.getState(state);
|
|
9
6
|
|
|
10
|
-
if (
|
|
7
|
+
if (pluginState.query === query) {
|
|
11
8
|
return false;
|
|
12
9
|
}
|
|
13
10
|
|
|
11
|
+
var tr = state.tr;
|
|
12
|
+
tr.setMeta(typeAheadPluginKey, {
|
|
13
|
+
action: ACTIONS.CHANGE_QUERY,
|
|
14
|
+
params: {
|
|
15
|
+
query: query
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
14
19
|
if (dispatch) {
|
|
15
|
-
dispatch(
|
|
16
|
-
action: ACTIONS.SET_QUERY,
|
|
17
|
-
params: {
|
|
18
|
-
query: query
|
|
19
|
-
}
|
|
20
|
-
}));
|
|
20
|
+
dispatch(tr);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
return true;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { pluginKey as typeAheadPluginKey } from '../pm-plugins/key';
|
|
2
|
+
import { ACTIONS } from '../pm-plugins/actions';
|
|
3
|
+
export var updateSelectedIndex = function updateSelectedIndex(selectedIndex) {
|
|
4
|
+
return function (state, dispatch) {
|
|
5
|
+
var pluginState = typeAheadPluginKey.getState(state);
|
|
6
|
+
|
|
7
|
+
if (pluginState.selectedIndex === selectedIndex) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
var tr = state.tr;
|
|
12
|
+
tr.setMeta(typeAheadPluginKey, {
|
|
13
|
+
action: ACTIONS.UPDATE_SELECTED_INDEX,
|
|
14
|
+
params: {
|
|
15
|
+
selectedIndex: selectedIndex
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
if (dispatch) {
|
|
20
|
+
dispatch(tr);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return true;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export var TYPE_AHEAD_DECORATION_KEY = 'typeahead_decoration_key';
|
|
2
|
+
export var TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE = 'typeaheadDecoration';
|
|
3
|
+
export var NavigationDirection;
|
|
4
|
+
|
|
5
|
+
(function (NavigationDirection) {
|
|
6
|
+
NavigationDirection[NavigationDirection["LEFT"] = -1] = "LEFT";
|
|
7
|
+
NavigationDirection[NavigationDirection["RIGHT"] = 1] = "RIGHT";
|
|
8
|
+
})(NavigationDirection || (NavigationDirection = {}));
|
|
9
|
+
|
|
10
|
+
export var CloseSelectionOptions;
|
|
11
|
+
|
|
12
|
+
(function (CloseSelectionOptions) {
|
|
13
|
+
CloseSelectionOptions["BEFORE_TEXT_INSERTED"] = "BEFORE_TEXT_INSERTED";
|
|
14
|
+
CloseSelectionOptions["AFTER_TEXT_INSERTED"] = "AFTER_TEXT_INSERTED";
|
|
15
|
+
})(CloseSelectionOptions || (CloseSelectionOptions = {}));
|