@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,138 @@
|
|
|
1
|
+
import { Plugin } from 'prosemirror-state';
|
|
2
|
+
import { SLI_EVENT_TYPE, SMART_EVENT_TYPE, buildSliPayload } from '@atlaskit/mention/resource';
|
|
3
|
+
import mentionNodeView from '../nodeviews/mention';
|
|
4
|
+
import { mentionPluginKey } from './key';
|
|
5
|
+
const ACTIONS = {
|
|
6
|
+
SET_PROVIDER: 'SET_PROVIDER',
|
|
7
|
+
SET_CONTEXT: 'SET_CONTEXT'
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const setProvider = provider => (state, dispatch) => {
|
|
11
|
+
if (dispatch) {
|
|
12
|
+
dispatch(state.tr.setMeta(mentionPluginKey, {
|
|
13
|
+
action: ACTIONS.SET_PROVIDER,
|
|
14
|
+
params: {
|
|
15
|
+
provider
|
|
16
|
+
}
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return true;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const setContext = context => (state, dispatch) => {
|
|
24
|
+
if (dispatch) {
|
|
25
|
+
dispatch(state.tr.setMeta(mentionPluginKey, {
|
|
26
|
+
action: ACTIONS.SET_CONTEXT,
|
|
27
|
+
params: {
|
|
28
|
+
context
|
|
29
|
+
}
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return true;
|
|
34
|
+
};
|
|
35
|
+
export function createMentionPlugin(dispatch, providerFactory, portalProviderAPI, eventDispatcher, fireEvent, options) {
|
|
36
|
+
let mentionProvider;
|
|
37
|
+
|
|
38
|
+
const sendAnalytics = (event, actionSubject, action, attributes) => {
|
|
39
|
+
if (event === SLI_EVENT_TYPE || event === SMART_EVENT_TYPE) {
|
|
40
|
+
fireEvent(buildSliPayload(actionSubject, action, attributes));
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return new Plugin({
|
|
45
|
+
key: mentionPluginKey,
|
|
46
|
+
state: {
|
|
47
|
+
init() {
|
|
48
|
+
return {};
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
apply(tr, pluginState) {
|
|
52
|
+
const {
|
|
53
|
+
action,
|
|
54
|
+
params
|
|
55
|
+
} = tr.getMeta(mentionPluginKey) || {
|
|
56
|
+
action: null,
|
|
57
|
+
params: null
|
|
58
|
+
};
|
|
59
|
+
let newPluginState = pluginState;
|
|
60
|
+
|
|
61
|
+
switch (action) {
|
|
62
|
+
case ACTIONS.SET_PROVIDER:
|
|
63
|
+
newPluginState = { ...pluginState,
|
|
64
|
+
mentionProvider: params.provider
|
|
65
|
+
};
|
|
66
|
+
dispatch(mentionPluginKey, newPluginState);
|
|
67
|
+
return newPluginState;
|
|
68
|
+
|
|
69
|
+
case ACTIONS.SET_CONTEXT:
|
|
70
|
+
newPluginState = { ...pluginState,
|
|
71
|
+
contextIdentifierProvider: params.context
|
|
72
|
+
};
|
|
73
|
+
dispatch(mentionPluginKey, newPluginState);
|
|
74
|
+
return newPluginState;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return newPluginState;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
},
|
|
81
|
+
props: {
|
|
82
|
+
nodeViews: {
|
|
83
|
+
mention: mentionNodeView(portalProviderAPI, eventDispatcher, providerFactory, options)
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
view(editorView) {
|
|
88
|
+
const providerHandler = (name, providerPromise) => {
|
|
89
|
+
switch (name) {
|
|
90
|
+
case 'mentionProvider':
|
|
91
|
+
if (!providerPromise) {
|
|
92
|
+
return setProvider(undefined)(editorView.state, editorView.dispatch);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
providerPromise.then(provider => {
|
|
96
|
+
if (mentionProvider) {
|
|
97
|
+
mentionProvider.unsubscribe('mentionPlugin');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
mentionProvider = provider;
|
|
101
|
+
setProvider(provider)(editorView.state, editorView.dispatch);
|
|
102
|
+
provider.subscribe('mentionPlugin', undefined, undefined, undefined, undefined, sendAnalytics);
|
|
103
|
+
}).catch(() => setProvider(undefined)(editorView.state, editorView.dispatch));
|
|
104
|
+
break;
|
|
105
|
+
|
|
106
|
+
case 'contextIdentifierProvider':
|
|
107
|
+
if (!providerPromise) {
|
|
108
|
+
return setContext(undefined)(editorView.state, editorView.dispatch);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
providerPromise.then(provider => {
|
|
112
|
+
setContext(provider)(editorView.state, editorView.dispatch);
|
|
113
|
+
});
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
providerFactory.subscribe('mentionProvider', providerHandler);
|
|
121
|
+
providerFactory.subscribe('contextIdentifierProvider', providerHandler);
|
|
122
|
+
return {
|
|
123
|
+
destroy() {
|
|
124
|
+
if (providerFactory) {
|
|
125
|
+
providerFactory.unsubscribe('mentionProvider', providerHandler);
|
|
126
|
+
providerFactory.unsubscribe('contextIdentifierProvider', providerHandler);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (mentionProvider) {
|
|
130
|
+
mentionProvider.unsubscribe('mentionPlugin');
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
});
|
|
138
|
+
}
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import uuid from 'uuid';
|
|
3
|
+
import { Fragment } from 'prosemirror-model';
|
|
4
|
+
import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
|
|
5
|
+
import { MENTION_ITEM_HEIGHT, MentionItem } from '@atlaskit/mention/item';
|
|
6
|
+
import { TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
|
|
7
|
+
import { TeamMentionHighlight, TeamMentionHighlightController } from '@atlaskit/mention/spotlight';
|
|
8
|
+
import { buildTypeAheadCancelPayload, buildTypeAheadInsertedPayload, buildTypeAheadInviteExposurePayload, buildTypeAheadInviteItemClickedPayload, buildTypeAheadInviteItemViewedPayload, buildTypeAheadRenderedPayload } from '../analytics';
|
|
9
|
+
import InviteItem, { INVITE_ITEM_DESCRIPTION } from '../ui/InviteItem';
|
|
10
|
+
import { isInviteItem, isTeamType, isTeamStats, shouldKeepInviteItem } from '../utils';
|
|
11
|
+
import { getMentionPluginState } from '../pm-plugins/utils';
|
|
12
|
+
|
|
13
|
+
const createInviteItem = ({
|
|
14
|
+
mentionProvider,
|
|
15
|
+
onInviteItemMount
|
|
16
|
+
}) => ({
|
|
17
|
+
title: INVITE_ITEM_DESCRIPTION.id,
|
|
18
|
+
render: ({
|
|
19
|
+
isSelected,
|
|
20
|
+
onClick,
|
|
21
|
+
onHover
|
|
22
|
+
}) => /*#__PURE__*/React.createElement(InviteItem, {
|
|
23
|
+
productName: mentionProvider ? mentionProvider.productName : undefined,
|
|
24
|
+
selected: isSelected,
|
|
25
|
+
onMount: onInviteItemMount,
|
|
26
|
+
onMouseEnter: onHover,
|
|
27
|
+
onSelection: onClick,
|
|
28
|
+
userRole: mentionProvider.userRole
|
|
29
|
+
}),
|
|
30
|
+
mention: INVITE_ITEM_DESCRIPTION
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const withInviteItem = ({
|
|
34
|
+
mentionProvider,
|
|
35
|
+
firstQueryWithoutResults,
|
|
36
|
+
currentQuery,
|
|
37
|
+
onInviteItemMount
|
|
38
|
+
}) => mentionItems => {
|
|
39
|
+
const inviteItem = createInviteItem({
|
|
40
|
+
mentionProvider,
|
|
41
|
+
onInviteItemMount
|
|
42
|
+
});
|
|
43
|
+
const keepInviteItem = shouldKeepInviteItem(currentQuery, firstQueryWithoutResults);
|
|
44
|
+
|
|
45
|
+
if (mentionItems.length === 0) {
|
|
46
|
+
return keepInviteItem ? [inviteItem] : [];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return [...mentionItems, // invite item should be shown at the bottom
|
|
50
|
+
inviteItem];
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const mentionToTypeaheadItem = mention => {
|
|
54
|
+
return {
|
|
55
|
+
title: mention.id,
|
|
56
|
+
render: ({
|
|
57
|
+
isSelected,
|
|
58
|
+
onClick,
|
|
59
|
+
onHover
|
|
60
|
+
}) => /*#__PURE__*/React.createElement(MentionItem, {
|
|
61
|
+
mention: mention,
|
|
62
|
+
selected: isSelected,
|
|
63
|
+
onMouseEnter: onHover,
|
|
64
|
+
onSelection: onClick
|
|
65
|
+
}),
|
|
66
|
+
getCustomComponentHeight: () => {
|
|
67
|
+
return MENTION_ITEM_HEIGHT;
|
|
68
|
+
},
|
|
69
|
+
mention
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
export function memoize(fn) {
|
|
73
|
+
// Cache results here
|
|
74
|
+
const seen = new Map();
|
|
75
|
+
|
|
76
|
+
function memoized(mention) {
|
|
77
|
+
// Check cache for hits
|
|
78
|
+
const hit = seen.get(mention.id);
|
|
79
|
+
|
|
80
|
+
if (hit) {
|
|
81
|
+
return hit;
|
|
82
|
+
} // Generate new result and cache it
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
const result = fn(mention);
|
|
86
|
+
seen.set(mention.id, result);
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
call: memoized,
|
|
92
|
+
clear: seen.clear.bind(seen)
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
const memoizedToItem = memoize(mentionToTypeaheadItem);
|
|
96
|
+
|
|
97
|
+
const buildAndSendElementsTypeAheadAnalytics = fireEvent => ({
|
|
98
|
+
query,
|
|
99
|
+
mentions,
|
|
100
|
+
stats
|
|
101
|
+
}) => {
|
|
102
|
+
let duration = 0;
|
|
103
|
+
let userOrTeamIds = null;
|
|
104
|
+
let teams = null;
|
|
105
|
+
|
|
106
|
+
if (!isTeamStats(stats)) {
|
|
107
|
+
// is from primary mention endpoint which could be just user mentions or user/team mentions
|
|
108
|
+
duration = stats && stats.duration;
|
|
109
|
+
teams = null;
|
|
110
|
+
userOrTeamIds = mentions.map(mention => mention.id);
|
|
111
|
+
} else {
|
|
112
|
+
// is from dedicated team-only mention endpoint
|
|
113
|
+
duration = stats && stats.teamMentionDuration;
|
|
114
|
+
userOrTeamIds = null;
|
|
115
|
+
teams = mentions.map(mention => isTeamType(mention.userType) ? {
|
|
116
|
+
teamId: mention.id,
|
|
117
|
+
includesYou: mention.context.includesYou,
|
|
118
|
+
memberCount: mention.context.memberCount
|
|
119
|
+
} : null).filter(m => !!m);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const payload = buildTypeAheadRenderedPayload(duration, userOrTeamIds, query, teams);
|
|
123
|
+
fireEvent(payload);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const isTeamMentionProvider = p => !!(p.mentionTypeaheadHighlightEnabled && p.mentionTypeaheadCreateTeamPath);
|
|
127
|
+
/**
|
|
128
|
+
* When a team mention is selected, we render a team link and list of member/user mentions
|
|
129
|
+
* in editor content
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
const buildNodesForTeamMention = (schema, selectedMention, mentionProvider, sanitizePrivateContent) => {
|
|
134
|
+
const {
|
|
135
|
+
nodes,
|
|
136
|
+
marks
|
|
137
|
+
} = schema;
|
|
138
|
+
const {
|
|
139
|
+
name,
|
|
140
|
+
id: teamId,
|
|
141
|
+
accessLevel,
|
|
142
|
+
context
|
|
143
|
+
} = selectedMention; // build team link
|
|
144
|
+
|
|
145
|
+
const defaultTeamLink = `${window.location.origin}/people/team/${teamId}`;
|
|
146
|
+
const teamLink = context && context.teamLink ? context.teamLink : defaultTeamLink;
|
|
147
|
+
const teamLinkNode = schema.text(name, [marks.link.create({
|
|
148
|
+
href: teamLink
|
|
149
|
+
})]);
|
|
150
|
+
const openBracketText = schema.text('(');
|
|
151
|
+
const closeBracketText = schema.text(')');
|
|
152
|
+
const emptySpaceText = schema.text(' ');
|
|
153
|
+
const inlineNodes = [teamLinkNode, emptySpaceText, openBracketText];
|
|
154
|
+
const members = context && context.members ? context.members : [];
|
|
155
|
+
members.forEach((member, index) => {
|
|
156
|
+
const {
|
|
157
|
+
name,
|
|
158
|
+
id
|
|
159
|
+
} = member;
|
|
160
|
+
const mentionName = `@${name}`;
|
|
161
|
+
const text = sanitizePrivateContent ? '' : mentionName;
|
|
162
|
+
|
|
163
|
+
if (sanitizePrivateContent && isResolvingMentionProvider(mentionProvider)) {
|
|
164
|
+
mentionProvider.cacheMentionName(id, name);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const userMentionNode = nodes.mention.createChecked({
|
|
168
|
+
text,
|
|
169
|
+
id: member.id,
|
|
170
|
+
accessLevel,
|
|
171
|
+
userType: 'DEFAULT'
|
|
172
|
+
});
|
|
173
|
+
inlineNodes.push(userMentionNode); // should not add empty space after the last user mention.
|
|
174
|
+
|
|
175
|
+
if (index !== members.length - 1) {
|
|
176
|
+
inlineNodes.push(emptySpaceText);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
inlineNodes.push(closeBracketText);
|
|
180
|
+
return Fragment.fromArray(inlineNodes);
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export const createTypeAheadConfig = ({
|
|
184
|
+
sanitizePrivateContent,
|
|
185
|
+
mentionInsertDisplayName,
|
|
186
|
+
fireEvent,
|
|
187
|
+
HighlightComponent
|
|
188
|
+
}) => {
|
|
189
|
+
let sessionId = uuid();
|
|
190
|
+
let firstQueryWithoutResults = null;
|
|
191
|
+
const subscriptionKeys = new Set();
|
|
192
|
+
const typeAhead = {
|
|
193
|
+
id: TypeAheadAvailableNodes.MENTION,
|
|
194
|
+
trigger: '@',
|
|
195
|
+
// Custom regex must have a capture group around trigger
|
|
196
|
+
// so it's possible to use it without needing to scan through all triggers again
|
|
197
|
+
customRegex: '\\(?(@)',
|
|
198
|
+
getHighlight: state => {
|
|
199
|
+
const CustomHighlightComponent = HighlightComponent;
|
|
200
|
+
|
|
201
|
+
if (CustomHighlightComponent) {
|
|
202
|
+
return /*#__PURE__*/React.createElement(CustomHighlightComponent, null);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const pluginState = getMentionPluginState(state);
|
|
206
|
+
const provider = pluginState.mentionProvider;
|
|
207
|
+
|
|
208
|
+
if (provider) {
|
|
209
|
+
const teamMentionProvider = provider;
|
|
210
|
+
|
|
211
|
+
if (isTeamMentionProvider(teamMentionProvider) && teamMentionProvider.mentionTypeaheadHighlightEnabled()) {
|
|
212
|
+
return /*#__PURE__*/React.createElement(TeamMentionHighlight, {
|
|
213
|
+
createTeamLink: teamMentionProvider.mentionTypeaheadCreateTeamPath(),
|
|
214
|
+
onClose: () => TeamMentionHighlightController.registerClosed()
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return null;
|
|
220
|
+
},
|
|
221
|
+
|
|
222
|
+
getItems({
|
|
223
|
+
query,
|
|
224
|
+
editorState
|
|
225
|
+
}) {
|
|
226
|
+
const pluginState = getMentionPluginState(editorState);
|
|
227
|
+
|
|
228
|
+
if (!(pluginState !== null && pluginState !== void 0 && pluginState.mentionProvider)) {
|
|
229
|
+
return Promise.resolve([]);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const {
|
|
233
|
+
mentionProvider,
|
|
234
|
+
contextIdentifierProvider
|
|
235
|
+
} = pluginState;
|
|
236
|
+
return new Promise(resolve => {
|
|
237
|
+
const key = `loadingMentionsForTypeAhead_${uuid()}`;
|
|
238
|
+
|
|
239
|
+
const mentionsSubscribeCallback = (mentions, resultQuery = '', stats) => {
|
|
240
|
+
if (query !== resultQuery) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
mentionProvider.unsubscribe(key);
|
|
245
|
+
subscriptionKeys.delete(key);
|
|
246
|
+
const mentionItems = mentions.map(mention => memoizedToItem.call(mention));
|
|
247
|
+
buildAndSendElementsTypeAheadAnalytics(fireEvent)({
|
|
248
|
+
query,
|
|
249
|
+
mentions,
|
|
250
|
+
stats
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
if (mentions.length === 0 && firstQueryWithoutResults === null) {
|
|
254
|
+
firstQueryWithoutResults = query;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (!mentionProvider.shouldEnableInvite || mentionItems.length > 2) {
|
|
258
|
+
resolve(mentionItems);
|
|
259
|
+
} else {
|
|
260
|
+
const items = withInviteItem({
|
|
261
|
+
mentionProvider,
|
|
262
|
+
firstQueryWithoutResults: firstQueryWithoutResults || '',
|
|
263
|
+
currentQuery: query,
|
|
264
|
+
onInviteItemMount: () => {
|
|
265
|
+
fireEvent(buildTypeAheadInviteItemViewedPayload(sessionId, contextIdentifierProvider, mentionProvider.userRole));
|
|
266
|
+
}
|
|
267
|
+
})(mentionItems);
|
|
268
|
+
resolve(items);
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
subscriptionKeys.add(key);
|
|
273
|
+
mentionProvider.subscribe(key, mentionsSubscribeCallback);
|
|
274
|
+
mentionProvider.filter(query || '', { ...contextIdentifierProvider,
|
|
275
|
+
sessionId
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
},
|
|
279
|
+
|
|
280
|
+
onOpen: editorState => {
|
|
281
|
+
firstQueryWithoutResults = null;
|
|
282
|
+
const pluginState = getMentionPluginState(editorState);
|
|
283
|
+
|
|
284
|
+
if (!pluginState || !pluginState.mentionProvider) {
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const {
|
|
289
|
+
contextIdentifierProvider,
|
|
290
|
+
mentionProvider: {
|
|
291
|
+
shouldEnableInvite,
|
|
292
|
+
inviteExperimentCohort,
|
|
293
|
+
userRole
|
|
294
|
+
}
|
|
295
|
+
} = pluginState;
|
|
296
|
+
fireEvent(buildTypeAheadInviteExposurePayload(!!shouldEnableInvite, sessionId, contextIdentifierProvider, inviteExperimentCohort, userRole));
|
|
297
|
+
},
|
|
298
|
+
|
|
299
|
+
selectItem(state, item, insert, {
|
|
300
|
+
mode,
|
|
301
|
+
stats,
|
|
302
|
+
query,
|
|
303
|
+
sourceListItem
|
|
304
|
+
}) {
|
|
305
|
+
const {
|
|
306
|
+
schema
|
|
307
|
+
} = state;
|
|
308
|
+
const pluginState = getMentionPluginState(state);
|
|
309
|
+
const {
|
|
310
|
+
mentionProvider
|
|
311
|
+
} = pluginState;
|
|
312
|
+
const {
|
|
313
|
+
id,
|
|
314
|
+
name,
|
|
315
|
+
nickname,
|
|
316
|
+
accessLevel,
|
|
317
|
+
userType
|
|
318
|
+
} = item.mention;
|
|
319
|
+
const trimmedNickname = nickname && nickname.startsWith('@') ? nickname.slice(1) : nickname;
|
|
320
|
+
const renderName = mentionInsertDisplayName || !trimmedNickname ? name : trimmedNickname;
|
|
321
|
+
const mentionContext = { ...pluginState.contextIdentifierProvider,
|
|
322
|
+
sessionId
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
if (mentionProvider && !isInviteItem(item.mention)) {
|
|
326
|
+
mentionProvider.recordMentionSelection(item.mention, mentionContext);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
const pickerElapsedTime = stats.startedAt ? Date.now() - stats.startedAt : 0;
|
|
330
|
+
|
|
331
|
+
if (mentionProvider && mentionProvider.shouldEnableInvite && isInviteItem(item.mention)) {
|
|
332
|
+
// Don't fire event and the callback with selection by space press
|
|
333
|
+
if (mode !== 'space') {
|
|
334
|
+
fireEvent(buildTypeAheadInviteItemClickedPayload(pickerElapsedTime, stats.keyCount.arrowUp, stats.keyCount.arrowDown, sessionId, mode, query, pluginState.contextIdentifierProvider, mentionProvider.userRole));
|
|
335
|
+
|
|
336
|
+
if (mentionProvider.onInviteItemClick) {
|
|
337
|
+
mentionProvider.onInviteItemClick('mention');
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
return state.tr;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
fireEvent(buildTypeAheadInsertedPayload(pickerElapsedTime, stats.keyCount.arrowUp, stats.keyCount.arrowDown, sessionId, mode, item.mention, sourceListItem.map(x => x.mention), query, pluginState.contextIdentifierProvider));
|
|
345
|
+
sessionId = uuid();
|
|
346
|
+
|
|
347
|
+
if (mentionProvider && isTeamType(userType)) {
|
|
348
|
+
TeamMentionHighlightController.registerTeamMention();
|
|
349
|
+
return insert(buildNodesForTeamMention(schema, item.mention, mentionProvider, sanitizePrivateContent));
|
|
350
|
+
} // Don't insert into document if document data is sanitized.
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
const text = sanitizePrivateContent ? '' : `@${renderName}`;
|
|
354
|
+
|
|
355
|
+
if (sanitizePrivateContent && isResolvingMentionProvider(mentionProvider)) {
|
|
356
|
+
// Cache (locally) for later rendering
|
|
357
|
+
mentionProvider.cacheMentionName(id, renderName);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
const mentionNode = schema.nodes.mention.createChecked({
|
|
361
|
+
text,
|
|
362
|
+
id,
|
|
363
|
+
accessLevel,
|
|
364
|
+
userType: userType === 'DEFAULT' ? null : userType
|
|
365
|
+
});
|
|
366
|
+
const space = schema.text(' ');
|
|
367
|
+
return insert(Fragment.from([mentionNode, space]));
|
|
368
|
+
},
|
|
369
|
+
|
|
370
|
+
dismiss({
|
|
371
|
+
editorState,
|
|
372
|
+
query,
|
|
373
|
+
stats
|
|
374
|
+
}) {
|
|
375
|
+
firstQueryWithoutResults = null;
|
|
376
|
+
const pickerElapsedTime = stats.startedAt ? Date.now() - stats.startedAt : 0;
|
|
377
|
+
fireEvent(buildTypeAheadCancelPayload(pickerElapsedTime, stats.keyCount.arrowUp, stats.keyCount.arrowDown, sessionId, query || ''));
|
|
378
|
+
const pluginState = getMentionPluginState(editorState);
|
|
379
|
+
|
|
380
|
+
if (pluginState !== null && pluginState !== void 0 && pluginState.mentionProvider) {
|
|
381
|
+
const mentionProvider = pluginState.mentionProvider;
|
|
382
|
+
|
|
383
|
+
for (let key of subscriptionKeys) {
|
|
384
|
+
mentionProvider.unsubscribe(key);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
subscriptionKeys.clear();
|
|
389
|
+
sessionId = uuid();
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
};
|
|
393
|
+
return typeAhead;
|
|
394
|
+
};
|
|
@@ -3,8 +3,9 @@ import AddIcon from '@atlaskit/icon/glyph/add';
|
|
|
3
3
|
import { N300 } from '@atlaskit/theme/colors';
|
|
4
4
|
import React, { useCallback, useEffect } from 'react';
|
|
5
5
|
import { FormattedMessage } from 'react-intl';
|
|
6
|
-
import { AvatarStyle, CapitalizedStyle, MentionItemStyle, NameSectionStyle, RowStyle } from './styles';
|
|
6
|
+
import { AvatarStyle, CapitalizedStyle, MentionItemStyle, NameSectionStyle, RowStyle, ROW_SIDE_PADDING, AVATAR_HEIGHT } from './styles';
|
|
7
7
|
import { messages } from '../../messages';
|
|
8
|
+
export const INVITE_ITEM_MIN_HEIGHT = AVATAR_HEIGHT + ROW_SIDE_PADDING * 2;
|
|
8
9
|
export const INVITE_ITEM_DESCRIPTION = {
|
|
9
10
|
id: 'invite-teammate'
|
|
10
11
|
};
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import styled from 'styled-components'; // prettier-ignore
|
|
2
2
|
|
|
3
3
|
import { N30, N300 } from '@atlaskit/theme/colors';
|
|
4
|
+
export const ROW_SIDE_PADDING = 14;
|
|
4
5
|
export const RowStyle = styled.div`
|
|
5
6
|
align-items: center;
|
|
6
7
|
display: flex;
|
|
7
8
|
flex-direction: row;
|
|
8
9
|
flex-wrap: wrap;
|
|
9
10
|
overflow: hidden;
|
|
10
|
-
padding: 6px
|
|
11
|
+
padding: 6px ${ROW_SIDE_PADDING}px;
|
|
11
12
|
text-overflow: ellipsis;
|
|
12
13
|
vertical-align: middle;
|
|
13
14
|
`;
|
|
15
|
+
export const AVATAR_HEIGHT = 36;
|
|
14
16
|
export const AvatarStyle = styled.span`
|
|
15
17
|
position: relative;
|
|
16
18
|
flex: initial;
|
|
17
19
|
opacity: inherit;
|
|
18
20
|
width: 36px;
|
|
19
|
-
height:
|
|
21
|
+
height: ${AVATAR_HEIGHT}px;
|
|
20
22
|
|
|
21
23
|
> span {
|
|
22
24
|
width: 24px;
|
|
@@ -3,8 +3,8 @@ import React from 'react';
|
|
|
3
3
|
import { PureComponent } from 'react';
|
|
4
4
|
import MentionIcon from '@atlaskit/icon/glyph/editor/mention';
|
|
5
5
|
import ToolbarButton, { TOOLBAR_BUTTON } from '../../../../ui/ToolbarButton';
|
|
6
|
-
import { insertMentionQuery } from '../../commands/insert-mention-query';
|
|
7
6
|
import { INPUT_METHOD } from '../../../analytics';
|
|
7
|
+
import { createTypeAheadTools } from '../../../type-ahead/api';
|
|
8
8
|
export default class ToolbarMention extends PureComponent {
|
|
9
9
|
constructor(...args) {
|
|
10
10
|
super(...args);
|
|
@@ -14,7 +14,7 @@ export default class ToolbarMention extends PureComponent {
|
|
|
14
14
|
return false;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
createTypeAheadTools(this.props.editorView).openMention(INPUT_METHOD.INSERT_MENU);
|
|
18
18
|
return true;
|
|
19
19
|
});
|
|
20
20
|
}
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
import { INVITE_ITEM_DESCRIPTION } from './ui/InviteItem';
|
|
2
2
|
export const isTeamType = userType => userType === 'TEAM';
|
|
3
3
|
export const isTeamStats = stat => stat && !isNaN(stat.teamMentionDuration);
|
|
4
|
-
export const isInviteItem = mention => mention && mention.id === INVITE_ITEM_DESCRIPTION.id;
|
|
4
|
+
export const isInviteItem = mention => mention && mention.id === INVITE_ITEM_DESCRIPTION.id;
|
|
5
|
+
/**
|
|
6
|
+
* Actions
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const shouldKeepInviteItem = (query, firstQueryWithoutResults) => {
|
|
10
|
+
if (!firstQueryWithoutResults) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let lastIndexWithResults = firstQueryWithoutResults.length - 1;
|
|
15
|
+
let suffix = query.slice(lastIndexWithResults);
|
|
16
|
+
|
|
17
|
+
if (query[lastIndexWithResults - 1] === ' ') {
|
|
18
|
+
suffix = ' ' + suffix;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const depletedExtraWords = /\s[^\s]+\s/.test(suffix);
|
|
22
|
+
return !depletedExtraWords;
|
|
23
|
+
};
|