@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
|
@@ -102,6 +102,12 @@ export const IconPanel = Loadable({
|
|
|
102
102
|
'./panel').then(module => module.default),
|
|
103
103
|
loading: () => null
|
|
104
104
|
});
|
|
105
|
+
export const IconCustomPanel = Loadable({
|
|
106
|
+
loader: () => import(
|
|
107
|
+
/* webpackChunkName: "@atlaskit-internal_editor-icon-custon-panel" */
|
|
108
|
+
'./custom-panel').then(module => module.default),
|
|
109
|
+
loading: () => null
|
|
110
|
+
});
|
|
105
111
|
export const IconQuote = Loadable({
|
|
106
112
|
loader: () => import(
|
|
107
113
|
/* webpackChunkName: "@atlaskit-internal_editor-icon-quote" */
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Plugin } from 'prosemirror-state';
|
|
3
3
|
import memoizeOne from 'memoize-one';
|
|
4
|
-
import {
|
|
5
|
-
import { analyticsEventKey } from '../analytics/consts';
|
|
4
|
+
import { TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
|
|
6
5
|
import { pluginKey } from './plugin-key';
|
|
7
6
|
import { searchQuickInsertItems } from './search';
|
|
8
7
|
import ModalElementBrowser from './ui/ModalElementBrowser';
|
|
@@ -19,35 +18,24 @@ const quickInsertPlugin = options => ({
|
|
|
19
18
|
providerFactory,
|
|
20
19
|
reactContext,
|
|
21
20
|
dispatch
|
|
22
|
-
}) => quickInsertPluginFactory(quickInsert, providerFactory, reactContext().intl, dispatch)
|
|
21
|
+
}) => quickInsertPluginFactory(quickInsert, providerFactory, reactContext().intl, dispatch, options === null || options === void 0 ? void 0 : options.emptyStateHandler)
|
|
23
22
|
}];
|
|
24
23
|
},
|
|
25
24
|
|
|
26
25
|
pluginsOptions: {
|
|
27
26
|
typeAhead: {
|
|
27
|
+
id: TypeAheadAvailableNodes.QUICK_INSERT,
|
|
28
28
|
trigger: '/',
|
|
29
29
|
headless: options ? options.headless : undefined,
|
|
30
|
-
getItems: (query, state, intl, {
|
|
31
|
-
prevActive,
|
|
32
|
-
queryChanged
|
|
33
|
-
}, _tr, dispatch) => {
|
|
34
|
-
if (!prevActive && queryChanged) {
|
|
35
|
-
dispatch(analyticsEventKey, {
|
|
36
|
-
payload: {
|
|
37
|
-
action: ACTION.INVOKED,
|
|
38
|
-
actionSubject: ACTION_SUBJECT.TYPEAHEAD,
|
|
39
|
-
actionSubjectId: ACTION_SUBJECT_ID.TYPEAHEAD_QUICK_INSERT,
|
|
40
|
-
attributes: {
|
|
41
|
-
inputMethod: INPUT_METHOD.KEYBOARD
|
|
42
|
-
},
|
|
43
|
-
eventType: EVENT_TYPE.UI
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
30
|
|
|
48
|
-
|
|
49
|
-
|
|
31
|
+
getItems({
|
|
32
|
+
query,
|
|
33
|
+
editorState
|
|
34
|
+
}) {
|
|
35
|
+
const quickInsertState = pluginKey.getState(editorState);
|
|
36
|
+
return Promise.resolve(searchQuickInsertItems(quickInsertState, options)(query));
|
|
50
37
|
},
|
|
38
|
+
|
|
51
39
|
selectItem: (state, item, insert) => {
|
|
52
40
|
return item.action(insert, state);
|
|
53
41
|
}
|
|
@@ -120,13 +108,14 @@ const setProviderState = providerState => (state, dispatch) => {
|
|
|
120
108
|
return true;
|
|
121
109
|
};
|
|
122
110
|
|
|
123
|
-
function quickInsertPluginFactory(quickInsertItems, providerFactory, intl, dispatch) {
|
|
111
|
+
function quickInsertPluginFactory(quickInsertItems, providerFactory, intl, dispatch, emptyStateHandler) {
|
|
124
112
|
return new Plugin({
|
|
125
113
|
key: pluginKey,
|
|
126
114
|
state: {
|
|
127
115
|
init() {
|
|
128
116
|
return {
|
|
129
117
|
isElementBrowserModalOpen: false,
|
|
118
|
+
emptyStateHandler,
|
|
130
119
|
// lazy so it doesn't run on editor initialization
|
|
131
120
|
// memo here to avoid using a singleton cache, avoids editor
|
|
132
121
|
// getting confused when two editors exist within the same page.
|
|
@@ -30,6 +30,7 @@ const Modal = ({
|
|
|
30
30
|
onInsertItem: onInsertItem,
|
|
31
31
|
helpUrl: helpUrl,
|
|
32
32
|
isOpen: quickInsertState && quickInsertState.isElementBrowserModalOpen || false,
|
|
33
|
+
emptyStateHandler: quickInsertState && quickInsertState.emptyStateHandler,
|
|
33
34
|
onClose: onClose
|
|
34
35
|
});
|
|
35
36
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
plugins: ['featureFlagsContextPlugin', 'compositionPlugin', 'inlineCursorTargetPlugin', 'focusHandlerPlugin', 'frozenEditor', 'submitEditor', 'saveOnEnter', 'customAutoformatting', 'newlinePreserveMarksPlugin', 'imageUpload', 'imageUploadInputRule', 'clipboard', 'paste', 'pasteKeymap', 'mention', 'mentionInputRule', 'mentionKeymap', 'emoji', 'placeholderText', 'emojiInputRule', 'emojiKeymap', 'emojiAsciiInputRule', 'blockType', 'quickInsert', 'tasksAndDecisions', 'blockTypeInputRule', 'tasksAndDecisionsInputRule', 'list', 'typeAhead', 'typeAheadKeymap', 'typeAheadInputRule', 'date', // Needs to be before indentation to handle tab into input field
|
|
2
|
+
plugins: ['featureFlagsContextPlugin', 'compositionPlugin', 'inlineCursorTargetPlugin', 'typeAhead', 'typeAheadInsertItem', 'focusHandlerPlugin', 'frozenEditor', 'submitEditor', 'saveOnEnter', 'customAutoformatting', 'newlinePreserveMarksPlugin', 'imageUpload', 'imageUploadInputRule', 'clipboard', 'paste', 'pasteKeymap', 'mention', 'mentionInputRule', 'mentionKeymap', 'emoji', 'placeholderText', 'emojiInputRule', 'emojiKeymap', 'emojiAsciiInputRule', 'blockType', 'quickInsert', 'tasksAndDecisions', 'blockTypeInputRule', 'tasksAndDecisionsInputRule', 'list', 'typeAhead', 'typeAheadKeymap', 'typeAheadInputRule', 'date', // Needs to be before indentation to handle tab into input field
|
|
3
3
|
'dateKeymap', // This should be always after `typeAheadKeymap` & `emojiKeymap`
|
|
4
4
|
'indentationKeymap', 'textColor', 'alignmentPlugin', 'listInputRule', 'listKeymap', 'codeBlock', 'codeBlockIDEKeyBindings', 'codeBlockKeyMap', 'textFormatting', 'textFormattingCursor', 'textFormattingInputRule', 'textFormattingSmartRule', 'textFormattingClear', 'textFormattingKeymap', // task/decisions keymap needs to be above table keymap so can indent actions in a table
|
|
5
5
|
'tasksAndDecisionsKeyMap', // expand and table keymaps need to be above selection keymap to add their custom selection behaviour:
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Fragment } from 'prosemirror-model';
|
|
3
2
|
import { rule } from '@atlaskit/adf-schema';
|
|
4
|
-
import { safeInsert } from '../../utils/insert';
|
|
5
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, addAnalytics, EVENT_TYPE, INPUT_METHOD } from '../analytics';
|
|
6
|
-
import { getFeatureFlags } from '../feature-flags-context';
|
|
7
4
|
import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
|
|
8
5
|
import { IconDivider } from '../quick-insert/assets';
|
|
9
6
|
import inputRulePlugin from './pm-plugins/input-rule';
|
|
@@ -45,25 +42,7 @@ const rulePlugin = () => ({
|
|
|
45
42
|
icon: () => /*#__PURE__*/React.createElement(IconDivider, null),
|
|
46
43
|
|
|
47
44
|
action(insert, state) {
|
|
48
|
-
let tr =
|
|
49
|
-
const {
|
|
50
|
-
newInsertionBehaviour
|
|
51
|
-
} = getFeatureFlags(state);
|
|
52
|
-
|
|
53
|
-
if (newInsertionBehaviour) {
|
|
54
|
-
/**
|
|
55
|
-
* This is a workaround to get rid of the typeahead text when using quick insert
|
|
56
|
-
* Once we insert *nothing*, we get a new transaction, so we can use the new selection
|
|
57
|
-
* without considering the extra text after the `/` command.
|
|
58
|
-
**/
|
|
59
|
-
tr = insert(Fragment.empty);
|
|
60
|
-
tr = safeInsert(state.schema.nodes.rule.createChecked(), tr.selection.from)(tr);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (!tr) {
|
|
64
|
-
tr = insert(state.schema.nodes.rule.createChecked());
|
|
65
|
-
}
|
|
66
|
-
|
|
45
|
+
let tr = insert(state.schema.nodes.rule.createChecked());
|
|
67
46
|
return addAnalytics(state, tr, {
|
|
68
47
|
action: ACTION.INSERTED,
|
|
69
48
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
2
|
-
import { typeAheadInputRulesPluginKey } from '../type-ahead/pm-plugins/input-rules';
|
|
3
2
|
import { TEXT_INPUT_RULE_TRANSACTION_KEY } from '@atlaskit/prosemirror-input-rules';
|
|
4
3
|
/**
|
|
5
4
|
* Plugin to scroll the user's selection into view whenever the user updates
|
|
@@ -25,8 +24,7 @@ const createPlugin = () => new Plugin({
|
|
|
25
24
|
if ((tr.docChanged || tr.storedMarksSet) && !tr.scrolledIntoView && tr.getMeta('scrollIntoView') !== false && // ignore anything we would not want to undo
|
|
26
25
|
// this covers things like autofixing layouts, hovering table rows/cols
|
|
27
26
|
tr.getMeta('addToHistory') !== false && // ignore collab changes from another user
|
|
28
|
-
!tr.getMeta('isRemote') && // ignore
|
|
29
|
-
!tr.getMeta(typeAheadInputRulesPluginKey) && // ignore any transaction coming from the input text rule plugin
|
|
27
|
+
!tr.getMeta('isRemote') && // ignore any transaction coming from the input text rule plugin
|
|
30
28
|
!tr.getMeta(TEXT_INPUT_RULE_TRANSACTION_KEY)) {
|
|
31
29
|
return newState.tr.scrollIntoView();
|
|
32
30
|
}
|
|
@@ -107,8 +107,7 @@ export const arrow = (dir, endOfTextblock) => (state, dispatch, view) => {
|
|
|
107
107
|
|
|
108
108
|
|
|
109
109
|
if (selection instanceof GapCursorSelection && // next node allow gap cursor position
|
|
110
|
-
isValidTargetNode(isBackward(dir) ? $pos.nodeBefore : $pos.nodeAfter) && (
|
|
111
|
-
isBackward(dir) && selection.side === Side.LEFT || isForward(dir) && selection.side === Side.RIGHT)) {
|
|
110
|
+
isValidTargetNode(isBackward(dir) ? $pos.nodeBefore : $pos.nodeAfter) && (isBackward(dir) && selection.side === Side.LEFT || isForward(dir) && selection.side === Side.RIGHT)) {
|
|
112
111
|
// reverse cursor position
|
|
113
112
|
if (dispatch) {
|
|
114
113
|
dispatch(tr.setSelection(new GapCursorSelection($pos, selection.side === Side.RIGHT ? Side.LEFT : Side.RIGHT)).scrollIntoView());
|
|
@@ -270,12 +269,12 @@ export const setSelectionTopLevelBlocks = (tr, event, editorRef, posAtCoords, ed
|
|
|
270
269
|
} // try to set text selection if the editor isnt focused
|
|
271
270
|
// if the editor is focused, we are most likely dragging a selection outside.
|
|
272
271
|
else if (editorFocused === false) {
|
|
273
|
-
|
|
272
|
+
const selectionTemp = Selection.findFrom($pos, cursorCoords.side === Side.LEFT ? 1 : -1, true);
|
|
274
273
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}
|
|
274
|
+
if (selectionTemp) {
|
|
275
|
+
tr.setSelection(selectionTemp);
|
|
278
276
|
}
|
|
277
|
+
}
|
|
279
278
|
};
|
|
280
279
|
export const setCursorForTopLevelBlocks = (event, editorRef, posAtCoords, editorFocused) => (state, dispatch) => {
|
|
281
280
|
const {
|
|
@@ -25,9 +25,7 @@ export const createPlugin = (dispatch, dispatchAnalyticsEvent, options = {}) =>
|
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
const analyticsPayload = getNodeSelectionAnalyticsPayload(state.selection) || getAllSelectionAnalyticsPayload(state.selection) || // We
|
|
29
|
-
// handled in mouseup handler below
|
|
30
|
-
!editorView.mouseDown && (getRangeSelectionAnalyticsPayload(state.selection, state.doc) || getCellSelectionAnalyticsPayload(state)); // We have to use dispatchAnalyticsEvent over any of the analytics plugin helpers
|
|
28
|
+
const analyticsPayload = getNodeSelectionAnalyticsPayload(state.selection) || getAllSelectionAnalyticsPayload(state.selection) || !editorView.mouseDown && (getRangeSelectionAnalyticsPayload(state.selection, state.doc) || getCellSelectionAnalyticsPayload(state)); // We have to use dispatchAnalyticsEvent over any of the analytics plugin helpers
|
|
31
29
|
// as there were several issues caused by the fact that adding analytics through
|
|
32
30
|
// the plugin adds a new step to the transaction
|
|
33
31
|
// This causes prosemirror to run through some different code paths, eg. attempting
|
|
@@ -8,11 +8,14 @@ export const DEFAULT_STATUS = {
|
|
|
8
8
|
text: '',
|
|
9
9
|
color: 'neutral'
|
|
10
10
|
};
|
|
11
|
-
export const createStatus = (showStatusPickerAtOffset =
|
|
11
|
+
export const createStatus = (showStatusPickerAtOffset = 0) => (insert, state) => {
|
|
12
12
|
const statusNode = state.schema.nodes.status.createChecked({ ...DEFAULT_STATUS,
|
|
13
13
|
localId: uuid.generate()
|
|
14
14
|
});
|
|
15
|
-
const
|
|
15
|
+
const space = state.schema.text(' ');
|
|
16
|
+
const tr = insert(Fragment.from([statusNode, space]), {
|
|
17
|
+
selectInlineNode: true
|
|
18
|
+
});
|
|
16
19
|
const showStatusPickerAt = tr.selection.from + showStatusPickerAtOffset;
|
|
17
20
|
return tr.setSelection(NodeSelection.create(tr.doc, showStatusPickerAt)).setMeta(pluginKey, {
|
|
18
21
|
showStatusPickerAt,
|
|
@@ -40,7 +40,7 @@ const createPlugin = (dispatch, portalProviderAPI, eventDispatcher, options) =>
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
if (
|
|
43
|
+
if (tr.selectionSet) {
|
|
44
44
|
// Change in selection, while status picker was open, update state, if required.
|
|
45
45
|
const selectionFrom = tr.selection.from;
|
|
46
46
|
const nodeAtSelection = tr.doc.nodeAt(selectionFrom);
|
|
@@ -171,24 +171,24 @@ const arrowLeftFromText = selection => (state, dispatch) => {
|
|
|
171
171
|
|
|
172
172
|
if (isSelectionAtStartOfTable($from, selection) && $from.parent.type.name === 'paragraph' && $from.depth === table.depth + 3 // + 3 for: row, cell & paragraph nodes
|
|
173
173
|
) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
174
|
+
const {
|
|
175
|
+
selectionRelativeToNode
|
|
176
|
+
} = getSelectionPluginState(state);
|
|
177
|
+
|
|
178
|
+
if (selectionRelativeToNode === RelativeSelectionPos.Before) {
|
|
179
|
+
// we have a text selection at start of first table cell, directly inside a top level paragraph,
|
|
180
|
+
// and want to set gap cursor selection before table
|
|
181
|
+
return setGapCursorBeforeTable()(state, dispatch);
|
|
182
|
+
} else {
|
|
183
|
+
// we have a text selection at start of first table cell, directly inside a top level paragraph,
|
|
184
|
+
// and want to set a full table cell selection
|
|
185
|
+
return selectFullTable({
|
|
186
|
+
node: table.node,
|
|
187
|
+
startPos: table.start,
|
|
188
|
+
dir: TableSelectionDirection.BottomToTop
|
|
189
|
+
})(state, dispatch);
|
|
191
190
|
}
|
|
191
|
+
}
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
return false;
|
|
@@ -204,14 +204,14 @@ const arrowRightFromText = selection => (state, dispatch) => {
|
|
|
204
204
|
|
|
205
205
|
if (isSelectionAtEndOfTable($to, selection) && $to.parent.type.name === 'paragraph' && $to.depth === table.depth + 3 // + 3 for: row, cell & paragraph nodes
|
|
206
206
|
) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
207
|
+
// we have a text selection at end of last table cell, directly inside a top level paragraph,
|
|
208
|
+
// and want to set a full table cell selection
|
|
209
|
+
return selectFullTable({
|
|
210
|
+
node: table.node,
|
|
211
|
+
startPos: table.start,
|
|
212
|
+
dir: TableSelectionDirection.TopToBottom
|
|
213
|
+
})(state, dispatch);
|
|
214
|
+
}
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
return false;
|
|
@@ -87,6 +87,7 @@ export class TableRowNodeView {
|
|
|
87
87
|
|
|
88
88
|
_defineProperty(this, "onTablePluginState", state => {
|
|
89
89
|
const tableRef = state.tableRef;
|
|
90
|
+
let focusChanged = false;
|
|
90
91
|
const tree = this.tree;
|
|
91
92
|
|
|
92
93
|
if (!tree) {
|
|
@@ -103,6 +104,11 @@ export class TableRowNodeView {
|
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
const isCurrentTableSelected = tableRef === tree.table;
|
|
107
|
+
|
|
108
|
+
if (isCurrentTableSelected !== this.focused) {
|
|
109
|
+
focusChanged = true;
|
|
110
|
+
}
|
|
111
|
+
|
|
106
112
|
this.focused = isCurrentTableSelected;
|
|
107
113
|
const {
|
|
108
114
|
wrapper
|
|
@@ -129,7 +135,8 @@ export class TableRowNodeView {
|
|
|
129
135
|
|
|
130
136
|
|
|
131
137
|
setTimeout(() => {
|
|
132
|
-
if
|
|
138
|
+
// if focus changed while header is sticky - still repaint the positions will shift
|
|
139
|
+
if (!this.stickyHeadersOptimization || focusChanged && this.isSticky) {
|
|
133
140
|
this.paint(tree);
|
|
134
141
|
}
|
|
135
142
|
|
|
@@ -146,8 +146,7 @@ export const bulkColumnsResize = (resizeState, columnsIndexes, sourceColumnIndex
|
|
|
146
146
|
});
|
|
147
147
|
let newState = { ...resizeState,
|
|
148
148
|
cols: cols.map(col => {
|
|
149
|
-
if (columnsIndexes.indexOf(col.index) > -1 ||
|
|
150
|
-
columnsIndexes.indexOf(sourceColumnIndex) > -1 && col.index < colIndex) {
|
|
149
|
+
if (columnsIndexes.indexOf(col.index) > -1 || columnsIndexes.indexOf(sourceColumnIndex) > -1 && col.index < colIndex) {
|
|
151
150
|
return col;
|
|
152
151
|
}
|
|
153
152
|
|
|
@@ -184,19 +183,19 @@ export const bulkColumnsResize = (resizeState, columnsIndexes, sourceColumnIndex
|
|
|
184
183
|
} // table is in overflow: keep the dragged column at its widths and evenly distribute columns
|
|
185
184
|
// to recover from overflow state
|
|
186
185
|
else {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
186
|
+
const columnWidth = Math.floor((minTableWidth - sourceCol.width) / (newState.cols.length - 1));
|
|
187
|
+
newState = { ...resizeState,
|
|
188
|
+
cols: newState.cols.map(col => {
|
|
189
|
+
if (col.index === sourceCol.index) {
|
|
190
|
+
return col;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return { ...col,
|
|
194
|
+
width: columnWidth
|
|
195
|
+
};
|
|
196
|
+
})
|
|
197
|
+
};
|
|
198
|
+
}
|
|
200
199
|
} // fix total table widths by adding missing pixels to columns widths here and there
|
|
201
200
|
|
|
202
201
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ReactNodeView } from '../../../nodeviews';
|
|
3
3
|
import DecisionItem from '../ui/Decision';
|
|
4
|
+
import { isTypeAheadOpen } from '../../type-ahead/utils';
|
|
4
5
|
|
|
5
6
|
class Decision extends ReactNodeView {
|
|
6
7
|
isContentEmpty(node) {
|
|
@@ -26,7 +27,7 @@ class Decision extends ReactNodeView {
|
|
|
26
27
|
render(_props, forwardRef) {
|
|
27
28
|
return /*#__PURE__*/React.createElement(DecisionItem, {
|
|
28
29
|
contentRef: forwardRef,
|
|
29
|
-
showPlaceholder: this.isContentEmpty(this.node)
|
|
30
|
+
showPlaceholder: this.isContentEmpty(this.node) && !isTypeAheadOpen(this.view.state)
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
33
|
|
|
@@ -5,6 +5,7 @@ import { ReactNodeView } from '../../../nodeviews';
|
|
|
5
5
|
import WithPluginState from '../../../ui/WithPluginState';
|
|
6
6
|
import { stateKey as taskPluginKey } from '../pm-plugins/plugin-key';
|
|
7
7
|
import TaskItem from '../ui/Task';
|
|
8
|
+
import { isTypeAheadOpen } from '../../type-ahead/utils';
|
|
8
9
|
|
|
9
10
|
class Task extends ReactNodeView {
|
|
10
11
|
constructor(...args) {
|
|
@@ -92,7 +93,7 @@ class Task extends ReactNodeView {
|
|
|
92
93
|
contentRef: forwardRef,
|
|
93
94
|
isDone: state === 'DONE',
|
|
94
95
|
onChange: this.handleOnChange,
|
|
95
|
-
showPlaceholder: this.isContentEmpty(this.node),
|
|
96
|
+
showPlaceholder: this.isContentEmpty(this.node) && !isTypeAheadOpen(this.view.state),
|
|
96
97
|
providers: props.providerFactory
|
|
97
98
|
});
|
|
98
99
|
}
|
|
@@ -173,8 +173,7 @@ const deleteHandler = filter([isInsideTaskOrDecisionItem, isEmptySelectionAtEnd]
|
|
|
173
173
|
} // if nested, just unindent
|
|
174
174
|
|
|
175
175
|
|
|
176
|
-
if ($next.node($next.depth - 2).type === taskList ||
|
|
177
|
-
$next.node($next.depth - 1).type === taskList && $next.parent.type === taskList) {
|
|
176
|
+
if ($next.node($next.depth - 2).type === taskList || $next.node($next.depth - 1).type === taskList && $next.parent.type === taskList) {
|
|
178
177
|
const tr = liftBlock(state.tr, $next, $next);
|
|
179
178
|
|
|
180
179
|
if (dispatch && tr) {
|
|
@@ -28,10 +28,7 @@ export default new Plugin({
|
|
|
28
28
|
const clickWasAtTextNode = !!(clickNode && clickNode.isText);
|
|
29
29
|
const clickWasAtEndOfAParagraphNode = $click.parent.type === paragraph && $click.textOffset === 0 && $click.nodeAfter === null;
|
|
30
30
|
|
|
31
|
-
if (clickWasAtEdgeOfATextNode && clickWasNearACodeMark && clickedDOMElementPosition && (
|
|
32
|
-
// it was at a directly adjacent non-text node, so we skip this manual
|
|
33
|
-
// text selection logic to preserve that non-text node's selection
|
|
34
|
-
clickWasAtTextNode || clickWasAtEndOfAParagraphNode)) {
|
|
31
|
+
if (clickWasAtEdgeOfATextNode && clickWasNearACodeMark && clickedDOMElementPosition && (clickWasAtTextNode || clickWasAtEndOfAParagraphNode)) {
|
|
35
32
|
const clickWasInsideNodeDOM = event.target.parentNode === view.domAtPos(clickedDOMElementPosition).node && code.isInSet(view.state.doc.resolve(clickedDOMElementPosition).nodeAfter.marks);
|
|
36
33
|
const nodeNextToClick = $click.nodeBefore && code.isInSet($click.nodeBefore.marks) ? $click.nodeAfter : $click.nodeBefore; // Need to set the selection here to allow clicking between [code('text'),{<>},emoji()]
|
|
37
34
|
|
|
@@ -0,0 +1,224 @@
|
|
|
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
|
+
const open = ({
|
|
10
|
+
editorView
|
|
11
|
+
}) => itemType => inputMethod => {
|
|
12
|
+
const {
|
|
13
|
+
state
|
|
14
|
+
} = editorView;
|
|
15
|
+
const handler = findHandler(itemType, state);
|
|
16
|
+
|
|
17
|
+
if (!handler) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const {
|
|
22
|
+
tr
|
|
23
|
+
} = state;
|
|
24
|
+
openTypeAheadAtCursor({
|
|
25
|
+
triggerHandler: handler,
|
|
26
|
+
inputMethod
|
|
27
|
+
})(tr);
|
|
28
|
+
editorView.dispatch(tr);
|
|
29
|
+
return true;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const defaultCloseOptions = {
|
|
33
|
+
insertCurrentQueryAsRawText: false
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const close = ({
|
|
37
|
+
editorView
|
|
38
|
+
}) => (options = defaultCloseOptions) => {
|
|
39
|
+
const {
|
|
40
|
+
state
|
|
41
|
+
} = editorView;
|
|
42
|
+
const currentQuery = getTypeAheadQuery(editorView.state);
|
|
43
|
+
let tr = state.tr;
|
|
44
|
+
|
|
45
|
+
if (options.attachCommand) {
|
|
46
|
+
const fakeDispatch = customTr => {
|
|
47
|
+
tr = customTr;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
options.attachCommand(state, fakeDispatch);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
closeTypeAhead(tr);
|
|
54
|
+
|
|
55
|
+
if (options.insertCurrentQueryAsRawText && currentQuery && currentQuery.length > 0) {
|
|
56
|
+
const handler = getTypeAheadHandler(state);
|
|
57
|
+
const text = handler.trigger.concat(currentQuery);
|
|
58
|
+
tr.replaceSelectionWith(state.schema.text(text));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
editorView.dispatch(tr);
|
|
62
|
+
|
|
63
|
+
if (!editorView.hasFocus()) {
|
|
64
|
+
editorView.focus();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return true;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const search = ({
|
|
71
|
+
editorView
|
|
72
|
+
}) => itemType => (query = '') => {
|
|
73
|
+
const {
|
|
74
|
+
state
|
|
75
|
+
} = editorView;
|
|
76
|
+
const handler = findHandler(itemType, state);
|
|
77
|
+
|
|
78
|
+
if (!handler) {
|
|
79
|
+
throw new Error(`Handler not found, did you load the ${itemType} plugin properly`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
open({
|
|
83
|
+
editorView
|
|
84
|
+
})(itemType)(INPUT_METHOD.KEYBOARD);
|
|
85
|
+
updateQuery(query)(editorView.state, editorView.dispatch);
|
|
86
|
+
const lastQuery = {
|
|
87
|
+
current: query
|
|
88
|
+
};
|
|
89
|
+
const last = handler.getItems({
|
|
90
|
+
query,
|
|
91
|
+
editorState: state
|
|
92
|
+
}).then(items => {
|
|
93
|
+
if (!handler.forceSelect) {
|
|
94
|
+
return items;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const forceSelectedItem = handler.forceSelect({
|
|
98
|
+
items,
|
|
99
|
+
query,
|
|
100
|
+
editorState: state
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
if (!forceSelectedItem) {
|
|
104
|
+
return items;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
insertTypeAheadItem(editorView)({
|
|
108
|
+
handler,
|
|
109
|
+
item: forceSelectedItem,
|
|
110
|
+
query,
|
|
111
|
+
mode: SelectItemMode.SELECTED,
|
|
112
|
+
sourceListItem: items
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
const results = {
|
|
116
|
+
last
|
|
117
|
+
};
|
|
118
|
+
return {
|
|
119
|
+
type: appendValue => {
|
|
120
|
+
if (!appendValue) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
lastQuery.current += appendValue;
|
|
125
|
+
updateQuery(lastQuery.current)(editorView.state, editorView.dispatch);
|
|
126
|
+
const promise = handler.getItems({
|
|
127
|
+
query: lastQuery.current,
|
|
128
|
+
editorState: state
|
|
129
|
+
});
|
|
130
|
+
results.last = promise;
|
|
131
|
+
return promise;
|
|
132
|
+
},
|
|
133
|
+
result: () => results.last,
|
|
134
|
+
close: close({
|
|
135
|
+
editorView
|
|
136
|
+
}),
|
|
137
|
+
insert: ({
|
|
138
|
+
index,
|
|
139
|
+
mode
|
|
140
|
+
}) => {
|
|
141
|
+
return results.last.then(result => {
|
|
142
|
+
const item = result ? result[index] : null;
|
|
143
|
+
|
|
144
|
+
if (result && item) {
|
|
145
|
+
insertTypeAheadItem(editorView)({
|
|
146
|
+
handler,
|
|
147
|
+
item,
|
|
148
|
+
query,
|
|
149
|
+
mode: mode || SelectItemMode.SELECTED,
|
|
150
|
+
sourceListItem: result
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const insertItem = ({
|
|
159
|
+
editorView
|
|
160
|
+
}) => itemType => ({
|
|
161
|
+
contentItem,
|
|
162
|
+
query,
|
|
163
|
+
sourceListItem
|
|
164
|
+
}) => {
|
|
165
|
+
const {
|
|
166
|
+
state
|
|
167
|
+
} = editorView;
|
|
168
|
+
const handler = findHandler(itemType, state);
|
|
169
|
+
|
|
170
|
+
if (!handler) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
insertTypeAheadItem(editorView)({
|
|
175
|
+
handler,
|
|
176
|
+
item: contentItem,
|
|
177
|
+
mode: SelectItemMode.SELECTED,
|
|
178
|
+
query,
|
|
179
|
+
sourceListItem
|
|
180
|
+
});
|
|
181
|
+
return true;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const isOpen = ({
|
|
185
|
+
editorView
|
|
186
|
+
}) => () => {
|
|
187
|
+
if (!isTypeAheadOpen(editorView.state)) {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const handler = getTypeAheadHandler(editorView.state);
|
|
192
|
+
|
|
193
|
+
if (!handler) {
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return handler;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const currentQuery = ({
|
|
201
|
+
editorView
|
|
202
|
+
}) => () => {
|
|
203
|
+
return getTypeAheadQuery(editorView.state);
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
export const createTypeAheadTools = editorView => {
|
|
207
|
+
const props = {
|
|
208
|
+
editorView
|
|
209
|
+
};
|
|
210
|
+
return {
|
|
211
|
+
isOpen: isOpen(props),
|
|
212
|
+
currentQuery: currentQuery(props),
|
|
213
|
+
close: close(props),
|
|
214
|
+
openMention: open(props)(TypeAheadAvailableNodes.MENTION),
|
|
215
|
+
searchMention: search(props)(TypeAheadAvailableNodes.MENTION),
|
|
216
|
+
openQuickInsert: open(props)(TypeAheadAvailableNodes.QUICK_INSERT),
|
|
217
|
+
searchQuickInsert: search(props)(TypeAheadAvailableNodes.QUICK_INSERT),
|
|
218
|
+
openEmoji: open(props)(TypeAheadAvailableNodes.EMOJI),
|
|
219
|
+
searchEmoji: search(props)(TypeAheadAvailableNodes.EMOJI),
|
|
220
|
+
insertItemMention: insertItem(props)(TypeAheadAvailableNodes.MENTION),
|
|
221
|
+
insertItemEmoji: insertItem(props)(TypeAheadAvailableNodes.EMOJI),
|
|
222
|
+
insertItemQuickInsert: insertItem(props)(TypeAheadAvailableNodes.QUICK_INSERT)
|
|
223
|
+
};
|
|
224
|
+
};
|