@atlaskit/editor-core 148.0.0 → 149.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +110 -0
- package/dist/cjs/create-editor/create-plugins-list.js +6 -1
- package/dist/cjs/editor.js +1 -4
- package/dist/cjs/index.js +24 -40
- package/dist/cjs/labs/next/presets/default.js +1 -1
- package/dist/cjs/messages.js +5 -0
- package/dist/cjs/nodeviews/SelectionBasedNodeView.js +1 -2
- package/dist/cjs/plugins/analytics/plugin.js +9 -7
- package/dist/cjs/plugins/analytics/types/enums.js +5 -0
- package/dist/cjs/plugins/analytics/types/type-ahead.js +5 -0
- package/dist/cjs/plugins/block-type/messages.js +10 -0
- package/dist/cjs/plugins/card/nodeviews/embedCard.js +1 -3
- package/dist/cjs/plugins/collab-edit/participants.js +15 -0
- package/dist/cjs/plugins/collab-edit/plugin-state.js +14 -0
- package/dist/cjs/plugins/collab-edit/ui/avatars-with-plugin-state.js +6 -4
- package/dist/cjs/plugins/collab-edit/ui/avatars.js +19 -2
- package/dist/cjs/plugins/collab-edit/utils.js +42 -2
- package/dist/cjs/plugins/date/actions.js +4 -2
- package/dist/cjs/plugins/date/index.js +1 -1
- package/dist/cjs/plugins/date/pm-plugins/utils.js +6 -1
- package/dist/cjs/plugins/emoji/index.js +143 -120
- package/dist/cjs/plugins/emoji/pm-plugins/ascii-input-rules.js +0 -14
- package/dist/cjs/plugins/expand/pm-plugins/keymap.js +3 -7
- package/dist/cjs/plugins/extension/actions.js +16 -16
- package/dist/cjs/plugins/extension/pm-plugins/main.js +4 -4
- package/dist/cjs/plugins/extension/ui/Extension/ExtensionComponent.js +5 -4
- package/dist/cjs/plugins/extension/ui/Extension/index.js +2 -2
- package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +3 -2
- package/dist/cjs/plugins/floating-toolbar/ui/ConfirmationModal.js +12 -14
- package/dist/cjs/plugins/floating-toolbar/ui/EditorEmojiAddIcon.js +35 -0
- package/dist/cjs/plugins/floating-toolbar/ui/EditorHideEmojiIcon.js +38 -0
- package/dist/cjs/plugins/floating-toolbar/ui/EmojiPickerButton.js +5 -7
- package/dist/cjs/plugins/help-dialog/ui/index.js +12 -18
- package/dist/cjs/plugins/help-dialog/ui/styles.js +2 -6
- package/dist/cjs/plugins/hyperlink/index.js +4 -10
- package/dist/cjs/plugins/insert-block/index.js +9 -8
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +7 -3
- package/dist/cjs/plugins/list/index.js +5 -0
- package/dist/cjs/plugins/macro/actions.js +14 -14
- package/dist/cjs/plugins/media/index.js +1 -0
- package/dist/cjs/plugins/media/nodeviews/mediaGroup.js +1 -0
- package/dist/cjs/plugins/media/pm-plugins/main.js +26 -14
- package/dist/cjs/plugins/media/styles.js +1 -1
- package/dist/cjs/plugins/media/toolbar/filePreviewItem.js +86 -0
- package/dist/cjs/plugins/media/toolbar/index.js +161 -44
- package/dist/cjs/plugins/media/toolbar/utils.js +77 -0
- package/dist/cjs/plugins/mentions/index.js +57 -602
- package/dist/cjs/plugins/mentions/pm-plugins/key.js +11 -0
- package/dist/cjs/plugins/mentions/pm-plugins/main.js +162 -0
- package/dist/cjs/plugins/mentions/pm-plugins/utils.js +12 -0
- package/dist/cjs/plugins/mentions/type-ahead/index.js +449 -0
- package/dist/cjs/plugins/mentions/ui/InviteItem/index.js +3 -1
- package/dist/cjs/plugins/mentions/ui/InviteItem/styles.js +8 -3
- package/dist/cjs/plugins/mentions/ui/ToolbarMention/index.js +3 -3
- package/dist/cjs/plugins/mentions/utils.js +24 -2
- package/dist/cjs/plugins/panel/index.js +46 -13
- package/dist/cjs/plugins/panel/nodeviews/panel.js +39 -25
- package/dist/cjs/plugins/panel/toolbar.js +94 -6
- package/dist/cjs/plugins/panel/toolbar.test.js +149 -16
- package/dist/cjs/plugins/paste/handlers.js +2 -2
- package/dist/cjs/plugins/paste/pm-plugins/analytics.js +6 -3
- package/dist/cjs/plugins/placeholder/index.js +6 -0
- package/dist/cjs/plugins/quick-insert/api.js +30 -0
- package/dist/cjs/plugins/quick-insert/assets/custom-panel.js +55 -0
- package/dist/cjs/plugins/quick-insert/assets/index.js +14 -1
- package/dist/cjs/plugins/quick-insert/index.js +10 -24
- package/dist/cjs/plugins/quick-insert/ui/ModalElementBrowser/index.js +1 -0
- package/dist/cjs/plugins/rank.js +1 -1
- package/dist/cjs/plugins/rule/index.js +1 -25
- package/dist/cjs/plugins/scroll-into-view/index.js +1 -4
- package/dist/cjs/plugins/selection/gap-cursor/actions.js +5 -6
- package/dist/cjs/plugins/selection/pm-plugins/selection-main.js +1 -3
- package/dist/cjs/plugins/status/actions.js +5 -2
- package/dist/cjs/plugins/status/plugin.js +1 -1
- package/dist/cjs/plugins/table/commands/selection.js +24 -24
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +8 -1
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +14 -15
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/decisionItem.js +3 -1
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/taskItem.js +3 -1
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -2
- package/dist/cjs/plugins/text-formatting/pm-plugins/cursor.js +1 -4
- package/dist/cjs/plugins/type-ahead/api.js +243 -0
- package/dist/cjs/plugins/type-ahead/commands/insert-type-ahead-item.js +238 -0
- package/dist/cjs/plugins/type-ahead/commands/update-list-items.js +30 -0
- package/dist/cjs/plugins/type-ahead/commands/update-query.js +16 -18
- package/dist/cjs/plugins/type-ahead/commands/update-selected-index.js +36 -0
- package/dist/cjs/plugins/type-ahead/constants.js +25 -0
- package/dist/cjs/plugins/type-ahead/index.js +183 -52
- package/dist/cjs/plugins/type-ahead/insert-utils.js +132 -0
- package/dist/cjs/plugins/type-ahead/pm-plugins/actions.js +12 -9
- package/dist/cjs/plugins/type-ahead/pm-plugins/decorations.js +238 -0
- package/dist/cjs/plugins/type-ahead/pm-plugins/input-rules.js +20 -40
- package/dist/cjs/plugins/type-ahead/pm-plugins/insert-item-plugin.js +28 -0
- package/dist/cjs/plugins/type-ahead/pm-plugins/{plugin-key.js → key.js} +0 -0
- package/dist/cjs/plugins/type-ahead/pm-plugins/main.js +79 -424
- package/dist/cjs/plugins/type-ahead/pm-plugins/reducer.js +188 -0
- package/dist/cjs/plugins/type-ahead/pm-plugins/utils.js +26 -0
- package/dist/cjs/plugins/type-ahead/stats-modifier.js +49 -0
- package/dist/cjs/plugins/type-ahead/transforms/close-type-ahead.js +18 -0
- package/dist/cjs/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +51 -0
- package/dist/cjs/plugins/type-ahead/transforms/set-selection-before-query.js +24 -0
- package/dist/cjs/plugins/type-ahead/ui/DynamicHeightListItem.js +77 -0
- package/dist/cjs/plugins/type-ahead/ui/InputQuery.js +325 -0
- package/dist/cjs/plugins/type-ahead/ui/TypeAheadList.js +195 -0
- package/dist/cjs/plugins/type-ahead/ui/TypeAheadListItem.js +141 -0
- package/dist/cjs/plugins/type-ahead/ui/TypeAheadPopup.js +141 -0
- package/dist/cjs/plugins/type-ahead/ui/WrapperTypeAhead.js +151 -0
- package/dist/cjs/plugins/type-ahead/ui/hooks/use-dynamic-list-height-calculation.js +118 -0
- package/dist/cjs/plugins/type-ahead/ui/hooks/use-item-insert.js +132 -0
- package/dist/cjs/plugins/type-ahead/ui/hooks/use-load-items.js +61 -0
- package/dist/cjs/plugins/type-ahead/ui/hooks/use-on-force-select.js +50 -0
- package/dist/cjs/plugins/type-ahead/ui/hooks/use-resize-observer.js +70 -0
- package/dist/cjs/plugins/type-ahead/utils.js +127 -0
- package/dist/cjs/plugins/undo-redo/ui/ToolbarUndoRedo/index.js +33 -2
- package/dist/cjs/plugins/view-update-subscription/index.js +19 -14
- package/dist/cjs/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.js +10 -3
- package/dist/cjs/plugins/view-update-subscription/subscribe/type-ahead-updates.js +46 -0
- package/dist/cjs/test-utils.js +17 -0
- package/dist/cjs/types/empty-state-handler.js +5 -0
- package/dist/cjs/ui/ConfigPanel/Fields/ColorPicker.js +4 -21
- package/dist/cjs/ui/ElementBrowser/ElementBrowser.js +4 -2
- package/dist/cjs/ui/ElementBrowser/InsertMenu.js +1 -0
- package/dist/cjs/ui/ElementBrowser/ModalElementBrowser.js +16 -23
- package/dist/cjs/ui/ElementBrowser/components/ElementList/ElementList.js +11 -4
- package/dist/cjs/ui/ElementBrowser/components/StatelessElementBrowser.js +12 -4
- package/dist/cjs/ui/PanelTextInput/index.js +1 -3
- package/dist/cjs/utils/compare.js +7 -7
- package/dist/cjs/utils/index.js +7 -8
- package/dist/cjs/utils/rich-media-utils.js +2 -2
- package/dist/cjs/utils/selection.js +6 -3
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/create-editor/create-plugins-list.js +6 -1
- package/dist/es2019/editor.js +1 -4
- package/dist/es2019/index.js +4 -6
- package/dist/es2019/labs/next/presets/default.js +2 -2
- package/dist/es2019/messages.js +5 -0
- package/dist/es2019/nodeviews/SelectionBasedNodeView.js +1 -2
- package/dist/es2019/plugins/analytics/plugin.js +5 -1
- package/dist/es2019/plugins/analytics/types/enums.js +5 -0
- package/dist/es2019/plugins/analytics/types/type-ahead.js +1 -0
- package/dist/es2019/plugins/block-type/messages.js +10 -0
- package/dist/es2019/plugins/card/nodeviews/embedCard.js +1 -3
- package/dist/es2019/plugins/collab-edit/participants.js +14 -0
- package/dist/es2019/plugins/collab-edit/plugin-state.js +17 -1
- package/dist/es2019/plugins/collab-edit/ui/avatars-with-plugin-state.js +6 -4
- package/dist/es2019/plugins/collab-edit/ui/avatars.js +17 -2
- package/dist/es2019/plugins/collab-edit/utils.js +34 -0
- package/dist/es2019/plugins/date/actions.js +4 -2
- package/dist/es2019/plugins/date/index.js +1 -1
- package/dist/es2019/plugins/date/pm-plugins/utils.js +6 -1
- package/dist/es2019/plugins/emoji/index.js +169 -146
- package/dist/es2019/plugins/emoji/pm-plugins/ascii-input-rules.js +0 -11
- package/dist/es2019/plugins/expand/pm-plugins/keymap.js +3 -6
- package/dist/es2019/plugins/extension/actions.js +16 -16
- package/dist/es2019/plugins/extension/pm-plugins/main.js +4 -4
- package/dist/es2019/plugins/extension/ui/Extension/ExtensionComponent.js +5 -4
- package/dist/es2019/plugins/extension/ui/Extension/index.js +2 -2
- package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +3 -2
- package/dist/es2019/plugins/floating-toolbar/ui/ConfirmationModal.js +12 -15
- package/dist/es2019/plugins/floating-toolbar/ui/EditorEmojiAddIcon.js +25 -0
- package/dist/es2019/plugins/floating-toolbar/ui/EditorHideEmojiIcon.js +28 -0
- package/dist/es2019/plugins/floating-toolbar/ui/EmojiPickerButton.js +3 -5
- package/dist/es2019/plugins/help-dialog/ui/index.js +20 -26
- package/dist/es2019/plugins/help-dialog/ui/styles.js +2 -2
- package/dist/es2019/plugins/hyperlink/index.js +4 -12
- package/dist/es2019/plugins/insert-block/index.js +4 -4
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +8 -4
- package/dist/es2019/plugins/list/index.js +20 -14
- package/dist/es2019/plugins/macro/actions.js +14 -14
- package/dist/es2019/plugins/media/index.js +1 -0
- package/dist/es2019/plugins/media/nodeviews/mediaGroup.js +1 -0
- package/dist/es2019/plugins/media/pm-plugins/main.js +27 -12
- package/dist/es2019/plugins/media/styles.js +7 -2
- package/dist/es2019/plugins/media/toolbar/filePreviewItem.js +59 -0
- package/dist/es2019/plugins/media/toolbar/index.js +158 -42
- package/dist/es2019/plugins/media/toolbar/utils.js +32 -0
- package/dist/es2019/plugins/mentions/index.js +34 -536
- package/dist/es2019/plugins/mentions/pm-plugins/key.js +2 -0
- package/dist/es2019/plugins/mentions/pm-plugins/main.js +138 -0
- package/dist/es2019/plugins/mentions/pm-plugins/utils.js +4 -0
- package/dist/es2019/plugins/mentions/type-ahead/index.js +394 -0
- package/dist/es2019/plugins/mentions/ui/InviteItem/index.js +2 -1
- package/dist/es2019/plugins/mentions/ui/InviteItem/styles.js +4 -2
- package/dist/es2019/plugins/mentions/ui/ToolbarMention/index.js +2 -2
- package/dist/es2019/plugins/mentions/utils.js +20 -1
- package/dist/es2019/plugins/panel/index.js +95 -62
- package/dist/es2019/plugins/panel/nodeviews/panel.js +7 -1
- package/dist/es2019/plugins/panel/toolbar.js +90 -6
- package/dist/es2019/plugins/panel/toolbar.test.js +131 -14
- package/dist/es2019/plugins/paste/handlers.js +2 -2
- package/dist/es2019/plugins/paste/pm-plugins/analytics.js +6 -3
- package/dist/es2019/plugins/placeholder/index.js +5 -0
- package/dist/es2019/plugins/quick-insert/api.js +18 -0
- package/dist/es2019/plugins/quick-insert/assets/custom-panel.js +45 -0
- package/dist/es2019/plugins/quick-insert/assets/index.js +6 -0
- package/dist/es2019/plugins/quick-insert/index.js +12 -23
- package/dist/es2019/plugins/quick-insert/search.js +1 -3
- package/dist/es2019/plugins/quick-insert/ui/ModalElementBrowser/index.js +1 -0
- package/dist/es2019/plugins/rank.js +1 -1
- package/dist/es2019/plugins/rule/index.js +1 -22
- package/dist/es2019/plugins/scroll-into-view/index.js +1 -3
- package/dist/es2019/plugins/selection/gap-cursor/actions.js +5 -6
- package/dist/es2019/plugins/selection/pm-plugins/selection-main.js +1 -3
- package/dist/es2019/plugins/status/actions.js +5 -2
- package/dist/es2019/plugins/status/plugin.js +1 -1
- package/dist/es2019/plugins/table/commands/selection.js +25 -25
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +8 -1
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +14 -15
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/decisionItem.js +2 -1
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/taskItem.js +2 -1
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -2
- package/dist/es2019/plugins/text-formatting/pm-plugins/cursor.js +1 -4
- package/dist/es2019/plugins/type-ahead/api.js +224 -0
- package/dist/es2019/plugins/type-ahead/commands/insert-type-ahead-item.js +222 -0
- package/dist/es2019/plugins/type-ahead/commands/update-list-items.js +19 -0
- package/dist/es2019/plugins/type-ahead/commands/update-query.js +17 -15
- package/dist/es2019/plugins/type-ahead/commands/update-selected-index.js +25 -0
- package/dist/es2019/plugins/type-ahead/constants.js +15 -0
- package/dist/es2019/plugins/type-ahead/index.js +203 -78
- package/dist/es2019/plugins/type-ahead/insert-utils.js +119 -0
- package/dist/es2019/plugins/type-ahead/pm-plugins/actions.js +11 -8
- package/dist/es2019/plugins/type-ahead/pm-plugins/decorations.js +211 -0
- package/dist/es2019/plugins/type-ahead/pm-plugins/input-rules.js +18 -32
- package/dist/es2019/plugins/type-ahead/pm-plugins/insert-item-plugin.js +19 -0
- package/dist/es2019/plugins/type-ahead/pm-plugins/{plugin-key.js → key.js} +0 -0
- package/dist/es2019/plugins/type-ahead/pm-plugins/main.js +81 -401
- package/dist/es2019/plugins/type-ahead/pm-plugins/reducer.js +165 -0
- package/dist/es2019/plugins/type-ahead/pm-plugins/utils.js +16 -0
- package/dist/es2019/plugins/type-ahead/stats-modifier.js +41 -0
- package/dist/es2019/plugins/type-ahead/transforms/close-type-ahead.js +7 -0
- package/dist/es2019/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +40 -0
- package/dist/es2019/plugins/type-ahead/transforms/set-selection-before-query.js +11 -0
- package/dist/es2019/plugins/type-ahead/ui/DynamicHeightListItem.js +51 -0
- package/dist/es2019/plugins/type-ahead/ui/InputQuery.js +307 -0
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadList.js +163 -0
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadListItem.js +136 -0
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadPopup.js +120 -0
- package/dist/es2019/plugins/type-ahead/ui/WrapperTypeAhead.js +110 -0
- package/dist/es2019/plugins/type-ahead/ui/hooks/use-dynamic-list-height-calculation.js +97 -0
- package/dist/es2019/plugins/type-ahead/ui/hooks/use-item-insert.js +126 -0
- package/dist/es2019/plugins/type-ahead/ui/hooks/use-load-items.js +43 -0
- package/dist/es2019/plugins/type-ahead/ui/hooks/use-on-force-select.js +41 -0
- package/dist/es2019/plugins/type-ahead/ui/hooks/use-resize-observer.js +53 -0
- package/dist/es2019/plugins/type-ahead/utils.js +93 -0
- package/dist/es2019/plugins/undo-redo/ui/ToolbarUndoRedo/index.js +29 -2
- package/dist/es2019/plugins/view-update-subscription/index.js +19 -14
- package/dist/es2019/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.js +9 -3
- package/dist/es2019/plugins/view-update-subscription/subscribe/type-ahead-updates.js +34 -0
- package/dist/es2019/test-utils.js +7 -0
- package/dist/es2019/types/empty-state-handler.js +1 -0
- package/dist/es2019/ui/ConfigPanel/Fields/ColorPicker.js +4 -8
- package/dist/es2019/ui/ConfigPanel/transformers.js +9 -9
- package/dist/es2019/ui/ElementBrowser/ElementBrowser.js +4 -2
- package/dist/es2019/ui/ElementBrowser/InsertMenu.js +1 -0
- package/dist/es2019/ui/ElementBrowser/ModalElementBrowser.js +20 -21
- package/dist/es2019/ui/ElementBrowser/components/ElementList/ElementList.js +9 -2
- package/dist/es2019/ui/ElementBrowser/components/StatelessElementBrowser.js +12 -4
- package/dist/es2019/ui/PanelTextInput/index.js +1 -3
- package/dist/es2019/utils/compare.js +7 -7
- package/dist/es2019/utils/index.js +7 -8
- package/dist/es2019/utils/rich-media-utils.js +2 -2
- package/dist/es2019/utils/selection.js +6 -3
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/create-editor/create-plugins-list.js +6 -1
- package/dist/esm/editor.js +1 -4
- package/dist/esm/index.js +4 -6
- package/dist/esm/labs/next/presets/default.js +2 -2
- package/dist/esm/messages.js +5 -0
- package/dist/esm/nodeviews/SelectionBasedNodeView.js +1 -2
- package/dist/esm/plugins/analytics/plugin.js +8 -6
- package/dist/esm/plugins/analytics/types/enums.js +5 -0
- package/dist/esm/plugins/analytics/types/type-ahead.js +1 -0
- package/dist/esm/plugins/block-type/messages.js +10 -0
- package/dist/esm/plugins/card/nodeviews/embedCard.js +1 -3
- package/dist/esm/plugins/collab-edit/participants.js +15 -0
- package/dist/esm/plugins/collab-edit/plugin-state.js +15 -1
- package/dist/esm/plugins/collab-edit/ui/avatars-with-plugin-state.js +6 -4
- package/dist/esm/plugins/collab-edit/ui/avatars.js +17 -2
- package/dist/esm/plugins/collab-edit/utils.js +32 -0
- package/dist/esm/plugins/date/actions.js +4 -2
- package/dist/esm/plugins/date/index.js +1 -1
- package/dist/esm/plugins/date/pm-plugins/utils.js +6 -1
- package/dist/esm/plugins/emoji/index.js +136 -112
- package/dist/esm/plugins/emoji/pm-plugins/ascii-input-rules.js +0 -13
- package/dist/esm/plugins/expand/pm-plugins/keymap.js +3 -6
- package/dist/esm/plugins/extension/actions.js +16 -16
- package/dist/esm/plugins/extension/pm-plugins/main.js +4 -4
- package/dist/esm/plugins/extension/ui/Extension/ExtensionComponent.js +5 -4
- package/dist/esm/plugins/extension/ui/Extension/index.js +2 -2
- package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +3 -2
- package/dist/esm/plugins/floating-toolbar/ui/ConfirmationModal.js +12 -15
- package/dist/esm/plugins/floating-toolbar/ui/EditorEmojiAddIcon.js +25 -0
- package/dist/esm/plugins/floating-toolbar/ui/EditorHideEmojiIcon.js +28 -0
- package/dist/esm/plugins/floating-toolbar/ui/EmojiPickerButton.js +3 -5
- package/dist/esm/plugins/help-dialog/ui/index.js +13 -19
- package/dist/esm/plugins/help-dialog/ui/styles.js +2 -6
- package/dist/esm/plugins/hyperlink/index.js +4 -10
- package/dist/esm/plugins/insert-block/index.js +5 -5
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +8 -4
- package/dist/esm/plugins/list/index.js +5 -0
- package/dist/esm/plugins/macro/actions.js +14 -14
- package/dist/esm/plugins/media/index.js +1 -0
- package/dist/esm/plugins/media/nodeviews/mediaGroup.js +1 -0
- package/dist/esm/plugins/media/pm-plugins/main.js +27 -14
- package/dist/esm/plugins/media/styles.js +2 -2
- package/dist/esm/plugins/media/toolbar/filePreviewItem.js +62 -0
- package/dist/esm/plugins/media/toolbar/index.js +154 -43
- package/dist/esm/plugins/media/toolbar/utils.js +60 -0
- package/dist/esm/plugins/mentions/index.js +45 -557
- package/dist/esm/plugins/mentions/pm-plugins/key.js +2 -0
- package/dist/esm/plugins/mentions/pm-plugins/main.js +145 -0
- package/dist/esm/plugins/mentions/pm-plugins/utils.js +4 -0
- package/dist/esm/plugins/mentions/type-ahead/index.js +415 -0
- package/dist/esm/plugins/mentions/ui/InviteItem/index.js +2 -1
- package/dist/esm/plugins/mentions/ui/InviteItem/styles.js +4 -2
- package/dist/esm/plugins/mentions/ui/ToolbarMention/index.js +2 -2
- package/dist/esm/plugins/mentions/utils.js +19 -0
- package/dist/esm/plugins/panel/index.js +44 -13
- package/dist/esm/plugins/panel/nodeviews/panel.js +36 -22
- package/dist/esm/plugins/panel/toolbar.js +92 -6
- package/dist/esm/plugins/panel/toolbar.test.js +148 -16
- package/dist/esm/plugins/paste/handlers.js +2 -2
- package/dist/esm/plugins/paste/pm-plugins/analytics.js +6 -3
- package/dist/esm/plugins/placeholder/index.js +5 -0
- package/dist/esm/plugins/quick-insert/api.js +20 -0
- package/dist/esm/plugins/quick-insert/assets/custom-panel.js +45 -0
- package/dist/esm/plugins/quick-insert/assets/index.js +12 -0
- package/dist/esm/plugins/quick-insert/index.js +10 -24
- package/dist/esm/plugins/quick-insert/search.js +1 -3
- package/dist/esm/plugins/quick-insert/ui/ModalElementBrowser/index.js +1 -0
- package/dist/esm/plugins/rank.js +1 -1
- package/dist/esm/plugins/rule/index.js +1 -22
- package/dist/esm/plugins/scroll-into-view/index.js +1 -3
- package/dist/esm/plugins/selection/gap-cursor/actions.js +5 -6
- package/dist/esm/plugins/selection/pm-plugins/selection-main.js +1 -3
- package/dist/esm/plugins/status/actions.js +5 -2
- package/dist/esm/plugins/status/plugin.js +1 -1
- package/dist/esm/plugins/table/commands/selection.js +24 -24
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +8 -1
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +14 -15
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/decisionItem.js +2 -1
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/taskItem.js +2 -1
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -2
- package/dist/esm/plugins/text-formatting/pm-plugins/cursor.js +1 -4
- package/dist/esm/plugins/type-ahead/api.js +228 -0
- package/dist/esm/plugins/type-ahead/commands/insert-type-ahead-item.js +217 -0
- package/dist/esm/plugins/type-ahead/commands/update-list-items.js +19 -0
- package/dist/esm/plugins/type-ahead/commands/update-query.js +13 -13
- package/dist/esm/plugins/type-ahead/commands/update-selected-index.js +25 -0
- package/dist/esm/plugins/type-ahead/constants.js +15 -0
- package/dist/esm/plugins/type-ahead/index.js +173 -53
- package/dist/esm/plugins/type-ahead/insert-utils.js +116 -0
- package/dist/esm/plugins/type-ahead/pm-plugins/actions.js +11 -8
- package/dist/esm/plugins/type-ahead/pm-plugins/decorations.js +204 -0
- package/dist/esm/plugins/type-ahead/pm-plugins/input-rules.js +18 -33
- package/dist/esm/plugins/type-ahead/pm-plugins/insert-item-plugin.js +18 -0
- package/dist/esm/plugins/type-ahead/pm-plugins/{plugin-key.js → key.js} +0 -0
- package/dist/esm/plugins/type-ahead/pm-plugins/main.js +80 -393
- package/dist/esm/plugins/type-ahead/pm-plugins/reducer.js +168 -0
- package/dist/esm/plugins/type-ahead/pm-plugins/utils.js +16 -0
- package/dist/esm/plugins/type-ahead/stats-modifier.js +43 -0
- package/dist/esm/plugins/type-ahead/transforms/close-type-ahead.js +7 -0
- package/dist/esm/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +39 -0
- package/dist/esm/plugins/type-ahead/transforms/set-selection-before-query.js +13 -0
- package/dist/esm/plugins/type-ahead/ui/DynamicHeightListItem.js +51 -0
- package/dist/esm/plugins/type-ahead/ui/InputQuery.js +302 -0
- package/dist/esm/plugins/type-ahead/ui/TypeAheadList.js +168 -0
- package/dist/esm/plugins/type-ahead/ui/TypeAheadListItem.js +105 -0
- package/dist/esm/plugins/type-ahead/ui/TypeAheadPopup.js +114 -0
- package/dist/esm/plugins/type-ahead/ui/WrapperTypeAhead.js +125 -0
- package/dist/esm/plugins/type-ahead/ui/hooks/use-dynamic-list-height-calculation.js +101 -0
- package/dist/esm/plugins/type-ahead/ui/hooks/use-item-insert.js +118 -0
- package/dist/esm/plugins/type-ahead/ui/hooks/use-load-items.js +46 -0
- package/dist/esm/plugins/type-ahead/ui/hooks/use-on-force-select.js +38 -0
- package/dist/esm/plugins/type-ahead/ui/hooks/use-resize-observer.js +48 -0
- package/dist/esm/plugins/type-ahead/utils.js +88 -0
- package/dist/esm/plugins/undo-redo/ui/ToolbarUndoRedo/index.js +33 -2
- package/dist/esm/plugins/view-update-subscription/index.js +19 -14
- package/dist/esm/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.js +10 -3
- package/dist/esm/plugins/view-update-subscription/subscribe/type-ahead-updates.js +33 -0
- package/dist/esm/test-utils.js +7 -0
- package/dist/esm/types/empty-state-handler.js +1 -0
- package/dist/esm/ui/ConfigPanel/Fields/ColorPicker.js +4 -14
- package/dist/esm/ui/ElementBrowser/ElementBrowser.js +4 -2
- package/dist/esm/ui/ElementBrowser/InsertMenu.js +1 -0
- package/dist/esm/ui/ElementBrowser/ModalElementBrowser.js +16 -23
- package/dist/esm/ui/ElementBrowser/components/ElementList/ElementList.js +10 -3
- package/dist/esm/ui/ElementBrowser/components/StatelessElementBrowser.js +12 -4
- package/dist/esm/ui/PanelTextInput/index.js +1 -3
- package/dist/esm/utils/compare.js +7 -7
- package/dist/esm/utils/index.js +7 -8
- package/dist/esm/utils/rich-media-utils.js +2 -2
- package/dist/esm/utils/selection.js +6 -3
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/commands/index.d.ts +1 -1
- package/dist/types/create-editor/ErrorBoundary.d.ts +1 -1
- package/dist/types/index.d.ts +3 -5
- package/dist/types/labs/next/full-page.d.ts +1 -1
- package/dist/types/labs/next/mobile.d.ts +1 -1
- package/dist/types/labs/next/presets/default.d.ts +2 -0
- package/dist/types/messages.d.ts +5 -0
- package/dist/types/plugins/alignment/commands/index.d.ts +2 -2
- package/dist/types/plugins/analytics/types/enums.d.ts +6 -1
- package/dist/types/plugins/analytics/types/events.d.ts +12 -2
- package/dist/types/plugins/analytics/types/general-events.d.ts +2 -23
- package/dist/types/plugins/analytics/types/type-ahead.d.ts +27 -0
- package/dist/types/plugins/block-type/messages.d.ts +10 -0
- package/dist/types/plugins/card/ui/ResizableEmbedCard.d.ts +1 -1
- package/dist/types/plugins/collab-edit/participants.d.ts +1 -0
- package/dist/types/plugins/collab-edit/ui/avatars.d.ts +3 -1
- package/dist/types/plugins/collab-edit/ui/invite-to-edit.d.ts +1 -1
- package/dist/types/plugins/collab-edit/utils.d.ts +4 -2
- package/dist/types/plugins/date/actions.d.ts +1 -1
- package/dist/types/plugins/date/pm-plugins/types.d.ts +1 -0
- package/dist/types/plugins/emoji/index.d.ts +2 -4
- package/dist/types/plugins/emoji/types.d.ts +2 -2
- package/dist/types/plugins/extension/ui/Extension/Extension/index.d.ts +2 -3
- package/dist/types/plugins/extension/ui/Extension/Extension/styles.d.ts +1 -1
- package/dist/types/plugins/extension/ui/Extension/ExtensionComponent.d.ts +2 -3
- package/dist/types/plugins/extension/ui/Extension/index.d.ts +2 -3
- package/dist/types/plugins/feature-flags-context/get-enabled-feature-flag-keys.d.ts +1 -1
- package/dist/types/plugins/find-replace/ui/styles.d.ts +3 -3
- package/dist/types/plugins/floating-toolbar/ui/EditorEmojiAddIcon.d.ts +1 -0
- package/dist/types/plugins/floating-toolbar/ui/EditorHideEmojiIcon.d.ts +1 -0
- package/dist/types/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.d.ts +1 -1
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +0 -1
- package/dist/types/plugins/media/pm-plugins/main.d.ts +1 -0
- package/dist/types/plugins/media/toolbar/filePreviewItem.d.ts +7 -0
- package/dist/types/plugins/media/toolbar/utils.d.ts +4 -0
- package/dist/types/plugins/media/types.d.ts +3 -0
- package/dist/types/plugins/media/ui/ResizableMediaSingle/index.d.ts +1 -1
- package/dist/types/plugins/media/utils/media-single.d.ts +1 -1
- package/dist/types/plugins/mentions/analytics.d.ts +1 -1
- package/dist/types/plugins/mentions/index.d.ts +4 -30
- package/dist/types/plugins/mentions/pm-plugins/key.d.ts +3 -0
- package/dist/types/plugins/mentions/pm-plugins/main.d.ts +8 -0
- package/dist/types/plugins/mentions/pm-plugins/utils.d.ts +3 -0
- package/dist/types/plugins/mentions/type-ahead/index.d.ts +17 -0
- package/dist/types/plugins/mentions/types.d.ts +2 -0
- package/dist/types/plugins/mentions/ui/InviteItem/index.d.ts +1 -0
- package/dist/types/plugins/mentions/ui/InviteItem/styles.d.ts +2 -0
- package/dist/types/plugins/mentions/utils.d.ts +4 -0
- package/dist/types/plugins/panel/nodeviews/panel.d.ts +19 -3
- package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +2 -0
- package/dist/types/plugins/quick-insert/api.d.ts +6 -0
- package/dist/types/plugins/quick-insert/assets/custom-panel.d.ts +1 -0
- package/dist/types/plugins/quick-insert/assets/index.d.ts +1 -0
- package/dist/types/plugins/quick-insert/search.d.ts +1 -1
- package/dist/types/plugins/quick-insert/types.d.ts +3 -0
- package/dist/types/plugins/status/actions.d.ts +3 -1
- package/dist/types/plugins/status/ui/statusPicker.d.ts +1 -1
- package/dist/types/plugins/type-ahead/api.d.ts +53 -0
- package/dist/types/plugins/type-ahead/commands/insert-type-ahead-item.d.ts +12 -0
- package/dist/types/plugins/type-ahead/commands/update-list-items.d.ts +3 -0
- package/dist/types/plugins/type-ahead/commands/update-query.d.ts +2 -2
- package/dist/types/plugins/type-ahead/commands/update-selected-index.d.ts +2 -0
- package/dist/types/plugins/type-ahead/constants.d.ts +10 -0
- package/dist/types/plugins/type-ahead/index.d.ts +5 -4
- package/dist/types/plugins/type-ahead/insert-utils.d.ts +18 -0
- package/dist/types/plugins/type-ahead/pm-plugins/actions.d.ts +9 -8
- package/dist/types/plugins/type-ahead/pm-plugins/decorations.d.ts +24 -0
- package/dist/types/plugins/type-ahead/pm-plugins/input-rules.d.ts +0 -1
- package/dist/types/plugins/type-ahead/pm-plugins/insert-item-plugin.d.ts +2 -0
- package/dist/types/plugins/type-ahead/pm-plugins/{plugin-key.d.ts → key.d.ts} +0 -0
- package/dist/types/plugins/type-ahead/pm-plugins/main.d.ts +12 -39
- package/dist/types/plugins/type-ahead/pm-plugins/reducer.d.ts +10 -0
- package/dist/types/plugins/type-ahead/pm-plugins/utils.d.ts +4 -0
- package/dist/types/plugins/type-ahead/stats-modifier.d.ts +20 -0
- package/dist/types/plugins/type-ahead/transforms/close-type-ahead.d.ts +2 -0
- package/dist/types/plugins/type-ahead/transforms/open-typeahead-at-cursor.d.ts +9 -0
- package/dist/types/plugins/type-ahead/transforms/set-selection-before-query.d.ts +2 -0
- package/dist/types/plugins/type-ahead/types.d.ts +95 -30
- package/dist/types/plugins/type-ahead/ui/DynamicHeightListItem.d.ts +21 -0
- package/dist/types/plugins/type-ahead/ui/InputQuery.d.ts +22 -0
- package/dist/types/plugins/type-ahead/ui/TypeAheadList.d.ts +11 -0
- package/dist/types/plugins/type-ahead/ui/TypeAheadListItem.d.ts +15 -0
- package/dist/types/plugins/type-ahead/ui/TypeAheadPopup.d.ts +22 -0
- package/dist/types/plugins/type-ahead/ui/WrapperTypeAhead.d.ts +20 -0
- package/dist/types/plugins/type-ahead/ui/hooks/use-dynamic-list-height-calculation.d.ts +25 -0
- package/dist/types/plugins/type-ahead/ui/hooks/use-item-insert.d.ts +3 -0
- package/dist/types/plugins/type-ahead/ui/hooks/use-load-items.d.ts +3 -0
- package/dist/types/plugins/type-ahead/ui/hooks/use-on-force-select.d.ts +11 -0
- package/dist/types/plugins/type-ahead/ui/hooks/use-resize-observer.d.ts +9 -0
- package/dist/types/plugins/type-ahead/utils.d.ts +18 -0
- package/dist/types/plugins/view-update-subscription/subscribe/type-ahead-updates.d.ts +9 -0
- package/dist/types/test-utils.d.ts +2 -0
- package/dist/types/types/editor-props.d.ts +2 -0
- package/dist/types/types/empty-state-handler.d.ts +7 -0
- package/dist/types/types/feature-flags.d.ts +8 -0
- package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types/ui/ColorPickerButton/index.d.ts +1 -1
- package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
- package/dist/types/ui/ConfigPanel/FormErrorBoundary.d.ts +1 -1
- package/dist/types/ui/ElementBrowser/ElementBrowser.d.ts +2 -0
- package/dist/types/ui/ElementBrowser/ModalElementBrowser.d.ts +2 -0
- package/dist/types/ui/ElementBrowser/components/CategoryList.d.ts +1 -1
- package/dist/types/ui/ElementBrowser/components/ElementList/ElementList.d.ts +5 -1
- package/dist/types/ui/ElementBrowser/components/StatelessElementBrowser.d.ts +3 -1
- package/dist/types/ui/LinkSearch/index.d.ts +20 -20
- package/dist/types/ui/PortalProvider/index.d.ts +1 -1
- package/dist/types/ui/ToolbarButton/index.d.ts +4 -4
- package/dist/types/ui/ToolbarButton/styles.d.ts +2 -2
- package/dist/types/utils/selection.d.ts +2 -2
- package/package.json +32 -29
- package/dist/cjs/plugins/emoji/commands/insert-emoji-query.js +0 -22
- package/dist/cjs/plugins/mentions/commands/insert-mention-query.js +0 -22
- package/dist/cjs/plugins/type-ahead/commands/dismiss.js +0 -44
- package/dist/cjs/plugins/type-ahead/commands/insert-query.js +0 -38
- package/dist/cjs/plugins/type-ahead/commands/items-list-updated.js +0 -25
- package/dist/cjs/plugins/type-ahead/commands/select-item.js +0 -163
- package/dist/cjs/plugins/type-ahead/commands/set-current-index.js +0 -25
- package/dist/cjs/plugins/type-ahead/pm-plugins/keymap.js +0 -115
- package/dist/cjs/plugins/type-ahead/ui/TypeAhead.js +0 -221
- package/dist/cjs/plugins/type-ahead/ui/TypeAheadItemsList.js +0 -239
- package/dist/cjs/plugins/type-ahead/utils/find-query-mark.js +0 -33
- package/dist/cjs/plugins/type-ahead/utils/is-query-active.js +0 -16
- package/dist/es2019/plugins/emoji/commands/insert-emoji-query.js +0 -13
- package/dist/es2019/plugins/mentions/commands/insert-mention-query.js +0 -13
- package/dist/es2019/plugins/type-ahead/commands/dismiss.js +0 -36
- package/dist/es2019/plugins/type-ahead/commands/insert-query.js +0 -26
- package/dist/es2019/plugins/type-ahead/commands/items-list-updated.js +0 -12
- package/dist/es2019/plugins/type-ahead/commands/select-item.js +0 -119
- package/dist/es2019/plugins/type-ahead/commands/set-current-index.js +0 -13
- package/dist/es2019/plugins/type-ahead/pm-plugins/keymap.js +0 -94
- package/dist/es2019/plugins/type-ahead/ui/TypeAhead.js +0 -175
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadItemsList.js +0 -196
- package/dist/es2019/plugins/type-ahead/utils/find-query-mark.js +0 -29
- package/dist/es2019/plugins/type-ahead/utils/is-query-active.js +0 -9
- package/dist/esm/plugins/emoji/commands/insert-emoji-query.js +0 -13
- package/dist/esm/plugins/mentions/commands/insert-mention-query.js +0 -13
- package/dist/esm/plugins/type-ahead/commands/dismiss.js +0 -33
- package/dist/esm/plugins/type-ahead/commands/insert-query.js +0 -26
- package/dist/esm/plugins/type-ahead/commands/items-list-updated.js +0 -14
- package/dist/esm/plugins/type-ahead/commands/select-item.js +0 -132
- package/dist/esm/plugins/type-ahead/commands/set-current-index.js +0 -15
- package/dist/esm/plugins/type-ahead/pm-plugins/keymap.js +0 -94
- package/dist/esm/plugins/type-ahead/ui/TypeAhead.js +0 -202
- package/dist/esm/plugins/type-ahead/ui/TypeAheadItemsList.js +0 -204
- package/dist/esm/plugins/type-ahead/utils/find-query-mark.js +0 -24
- package/dist/esm/plugins/type-ahead/utils/is-query-active.js +0 -9
- package/dist/types/plugins/emoji/commands/insert-emoji-query.d.ts +0 -2
- package/dist/types/plugins/mentions/commands/insert-mention-query.d.ts +0 -2
- package/dist/types/plugins/type-ahead/commands/dismiss.d.ts +0 -2
- package/dist/types/plugins/type-ahead/commands/insert-query.d.ts +0 -2
- package/dist/types/plugins/type-ahead/commands/items-list-updated.d.ts +0 -3
- package/dist/types/plugins/type-ahead/commands/select-item.d.ts +0 -9
- package/dist/types/plugins/type-ahead/commands/set-current-index.d.ts +0 -2
- package/dist/types/plugins/type-ahead/pm-plugins/keymap.d.ts +0 -3
- package/dist/types/plugins/type-ahead/ui/TypeAhead.d.ts +0 -37
- package/dist/types/plugins/type-ahead/ui/TypeAheadItemsList.d.ts +0 -32
- package/dist/types/plugins/type-ahead/utils/find-query-mark.d.ts +0 -10
- package/dist/types/plugins/type-ahead/utils/is-query-active.d.ts +0 -2
|
@@ -1,89 +1,42 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
|
|
4
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
-
|
|
6
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
7
|
-
|
|
8
1
|
import React from 'react';
|
|
9
2
|
import uuid from 'uuid';
|
|
10
|
-
import {
|
|
11
|
-
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
12
|
-
import debounce from 'lodash/debounce';
|
|
13
|
-
import { ELEMENTS_CHANNEL, isResolvingMentionProvider, SLI_EVENT_TYPE, SMART_EVENT_TYPE, buildSliPayload } from '@atlaskit/mention/resource';
|
|
14
|
-
import { TeamMentionHighlight, TeamMentionHighlightController } from '@atlaskit/mention/spotlight';
|
|
15
|
-
import { MentionItem } from '@atlaskit/mention/item';
|
|
3
|
+
import { ELEMENTS_CHANNEL } from '@atlaskit/mention/resource';
|
|
16
4
|
import { mention } from '@atlaskit/adf-schema';
|
|
17
5
|
import WithPluginState from '../../ui/WithPluginState';
|
|
18
|
-
import {
|
|
19
|
-
import InviteItem, { INVITE_ITEM_DESCRIPTION } from './ui/InviteItem';
|
|
6
|
+
import { isTypeAheadAllowed } from '../type-ahead/utils';
|
|
20
7
|
import ToolbarMention from './ui/ToolbarMention';
|
|
21
|
-
import
|
|
22
|
-
import { buildTypeAheadCancelPayload, buildTypeAheadInsertedPayload, buildTypeAheadInviteExposurePayload, buildTypeAheadInviteItemClickedPayload, buildTypeAheadInviteItemViewedPayload, buildTypeAheadRenderedPayload } from './analytics';
|
|
23
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, addAnalytics, analyticsPluginKey, EVENT_TYPE, INPUT_METHOD } from '../analytics';
|
|
24
|
-
import { isInviteItem, isTeamStats, isTeamType } from './utils';
|
|
8
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, addAnalytics, EVENT_TYPE, INPUT_METHOD } from '../analytics';
|
|
25
9
|
import { IconMention } from '../quick-insert/assets';
|
|
26
10
|
import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
|
|
27
|
-
import {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
render: function render(_ref) {
|
|
33
|
-
var isSelected = _ref.isSelected,
|
|
34
|
-
onClick = _ref.onClick,
|
|
35
|
-
onHover = _ref.onHover;
|
|
36
|
-
return /*#__PURE__*/React.createElement(MentionItem, {
|
|
37
|
-
mention: mention,
|
|
38
|
-
selected: isSelected,
|
|
39
|
-
onMouseEnter: onHover,
|
|
40
|
-
onSelection: onClick
|
|
41
|
-
});
|
|
42
|
-
},
|
|
43
|
-
mention: mention
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
export function memoize(fn) {
|
|
47
|
-
// Cache results here
|
|
48
|
-
var seen = new Map();
|
|
49
|
-
|
|
50
|
-
function memoized(mention) {
|
|
51
|
-
// Check cache for hits
|
|
52
|
-
var hit = seen.get(mention.id);
|
|
53
|
-
|
|
54
|
-
if (hit) {
|
|
55
|
-
return hit;
|
|
56
|
-
} // Generate new result and cache it
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
var result = fn(mention);
|
|
60
|
-
seen.set(mention.id, result);
|
|
61
|
-
return result;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return {
|
|
65
|
-
call: memoized,
|
|
66
|
-
clear: seen.clear.bind(seen)
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
var memoizedToItem = memoize(mentionToTypeaheadItem);
|
|
11
|
+
import { openTypeAheadAtCursor } from '../type-ahead/transforms/open-typeahead-at-cursor';
|
|
12
|
+
import { createTypeAheadConfig } from './type-ahead';
|
|
13
|
+
import { mentionPluginKey } from './pm-plugins/key';
|
|
14
|
+
import { createMentionPlugin } from './pm-plugins/main';
|
|
15
|
+
export { mentionPluginKey };
|
|
70
16
|
|
|
71
17
|
var mentionsPlugin = function mentionsPlugin(options) {
|
|
72
18
|
var sessionId = uuid();
|
|
73
19
|
|
|
74
20
|
var fireEvent = function fireEvent(payload) {
|
|
75
|
-
if (options && options.createAnalyticsEvent) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
21
|
+
if (!(options !== null && options !== void 0 && options.createAnalyticsEvent)) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var createAnalyticsEvent = options.createAnalyticsEvent;
|
|
79
26
|
|
|
80
|
-
|
|
27
|
+
if (payload.attributes && !payload.attributes.sessionId) {
|
|
28
|
+
payload.attributes.sessionId = sessionId;
|
|
81
29
|
}
|
|
30
|
+
|
|
31
|
+
createAnalyticsEvent(payload).fire(ELEMENTS_CHANNEL);
|
|
82
32
|
};
|
|
83
33
|
|
|
84
|
-
var
|
|
85
|
-
|
|
86
|
-
|
|
34
|
+
var typeAhead = createTypeAheadConfig({
|
|
35
|
+
sanitizePrivateContent: options === null || options === void 0 ? void 0 : options.sanitizePrivateContent,
|
|
36
|
+
mentionInsertDisplayName: options === null || options === void 0 ? void 0 : options.insertDisplayName,
|
|
37
|
+
HighlightComponent: options === null || options === void 0 ? void 0 : options.HighlightComponent,
|
|
38
|
+
fireEvent: fireEvent
|
|
39
|
+
});
|
|
87
40
|
return {
|
|
88
41
|
name: 'mention',
|
|
89
42
|
nodes: function nodes() {
|
|
@@ -95,39 +48,36 @@ var mentionsPlugin = function mentionsPlugin(options) {
|
|
|
95
48
|
pmPlugins: function pmPlugins() {
|
|
96
49
|
return [{
|
|
97
50
|
name: 'mention',
|
|
98
|
-
plugin: function plugin(
|
|
99
|
-
var providerFactory =
|
|
100
|
-
dispatch =
|
|
101
|
-
portalProviderAPI =
|
|
102
|
-
eventDispatcher =
|
|
103
|
-
return
|
|
51
|
+
plugin: function plugin(_ref) {
|
|
52
|
+
var providerFactory = _ref.providerFactory,
|
|
53
|
+
dispatch = _ref.dispatch,
|
|
54
|
+
portalProviderAPI = _ref.portalProviderAPI,
|
|
55
|
+
eventDispatcher = _ref.eventDispatcher;
|
|
56
|
+
return createMentionPlugin(dispatch, providerFactory, portalProviderAPI, eventDispatcher, fireEvent, options);
|
|
104
57
|
}
|
|
105
58
|
}];
|
|
106
59
|
},
|
|
107
|
-
secondaryToolbarComponent: function secondaryToolbarComponent(
|
|
108
|
-
var editorView =
|
|
109
|
-
disabled =
|
|
60
|
+
secondaryToolbarComponent: function secondaryToolbarComponent(_ref2) {
|
|
61
|
+
var editorView = _ref2.editorView,
|
|
62
|
+
disabled = _ref2.disabled;
|
|
110
63
|
return /*#__PURE__*/React.createElement(WithPluginState, {
|
|
111
64
|
editorView: editorView,
|
|
112
65
|
plugins: {
|
|
113
|
-
typeAheadState: typeAheadPluginKey,
|
|
114
66
|
mentionState: mentionPluginKey
|
|
115
67
|
},
|
|
116
|
-
render: function render(
|
|
117
|
-
var
|
|
118
|
-
|
|
119
|
-
_ref4$mentionState = _ref4.mentionState,
|
|
120
|
-
mentionState = _ref4$mentionState === void 0 ? {} : _ref4$mentionState;
|
|
68
|
+
render: function render(_ref3) {
|
|
69
|
+
var _ref3$mentionState = _ref3.mentionState,
|
|
70
|
+
mentionState = _ref3$mentionState === void 0 ? {} : _ref3$mentionState;
|
|
121
71
|
return !mentionState.mentionProvider ? null : /*#__PURE__*/React.createElement(ToolbarMention, {
|
|
122
72
|
editorView: editorView,
|
|
123
|
-
isDisabled: disabled ||
|
|
73
|
+
isDisabled: disabled || isTypeAheadAllowed(editorView.state)
|
|
124
74
|
});
|
|
125
75
|
}
|
|
126
76
|
});
|
|
127
77
|
},
|
|
128
78
|
pluginsOptions: {
|
|
129
|
-
quickInsert: function quickInsert(
|
|
130
|
-
var formatMessage =
|
|
79
|
+
quickInsert: function quickInsert(_ref4) {
|
|
80
|
+
var formatMessage = _ref4.formatMessage;
|
|
131
81
|
return [{
|
|
132
82
|
id: 'mention',
|
|
133
83
|
title: formatMessage(messages.mention),
|
|
@@ -139,11 +89,11 @@ var mentionsPlugin = function mentionsPlugin(options) {
|
|
|
139
89
|
return /*#__PURE__*/React.createElement(IconMention, null);
|
|
140
90
|
},
|
|
141
91
|
action: function action(insert, state) {
|
|
142
|
-
var
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
92
|
+
var tr = insert(undefined);
|
|
93
|
+
openTypeAheadAtCursor({
|
|
94
|
+
triggerHandler: typeAhead,
|
|
95
|
+
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
96
|
+
})(tr);
|
|
147
97
|
return addAnalytics(state, tr, {
|
|
148
98
|
action: ACTION.INVOKED,
|
|
149
99
|
actionSubject: ACTION_SUBJECT.TYPEAHEAD,
|
|
@@ -156,471 +106,9 @@ var mentionsPlugin = function mentionsPlugin(options) {
|
|
|
156
106
|
}
|
|
157
107
|
}];
|
|
158
108
|
},
|
|
159
|
-
typeAhead:
|
|
160
|
-
trigger: '@',
|
|
161
|
-
// Custom regex must have a capture group around trigger
|
|
162
|
-
// so it's possible to use it without needing to scan through all triggers again
|
|
163
|
-
customRegex: '\\(?(@)',
|
|
164
|
-
getHighlight: function getHighlight(state) {
|
|
165
|
-
var CustomHighlightComponent = options === null || options === void 0 ? void 0 : options.HighlightComponent;
|
|
166
|
-
|
|
167
|
-
if (CustomHighlightComponent) {
|
|
168
|
-
return /*#__PURE__*/React.createElement(CustomHighlightComponent, null);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
var pluginState = getMentionPluginState(state);
|
|
172
|
-
var provider = pluginState.mentionProvider;
|
|
173
|
-
|
|
174
|
-
if (provider) {
|
|
175
|
-
var teamMentionProvider = provider;
|
|
176
|
-
|
|
177
|
-
if (isTeamMentionProvider(teamMentionProvider) && teamMentionProvider.mentionTypeaheadHighlightEnabled()) {
|
|
178
|
-
return /*#__PURE__*/React.createElement(TeamMentionHighlight, {
|
|
179
|
-
createTeamLink: teamMentionProvider.mentionTypeaheadCreateTeamPath(),
|
|
180
|
-
onClose: function onClose() {
|
|
181
|
-
return TeamMentionHighlightController.registerClosed();
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return null;
|
|
188
|
-
},
|
|
189
|
-
getItems: function getItems(query, state, _intl, _ref6, tr, dispatch) {
|
|
190
|
-
var prevActive = _ref6.prevActive,
|
|
191
|
-
queryChanged = _ref6.queryChanged;
|
|
192
|
-
|
|
193
|
-
if (!prevActive && queryChanged && !tr.getMeta(analyticsPluginKey)) {
|
|
194
|
-
// Clear cache on first invoke to reduce memory leaks
|
|
195
|
-
memoizedToItem.clear();
|
|
196
|
-
dispatch(analyticsEventKey, {
|
|
197
|
-
payload: {
|
|
198
|
-
action: ACTION.INVOKED,
|
|
199
|
-
actionSubject: ACTION_SUBJECT.TYPEAHEAD,
|
|
200
|
-
actionSubjectId: ACTION_SUBJECT_ID.TYPEAHEAD_MENTION,
|
|
201
|
-
attributes: {
|
|
202
|
-
inputMethod: INPUT_METHOD.KEYBOARD
|
|
203
|
-
},
|
|
204
|
-
eventType: EVENT_TYPE.UI
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
var pluginState = getMentionPluginState(state);
|
|
210
|
-
var mentions = !prevActive && queryChanged ? EMPTY : pluginState.mentions || EMPTY;
|
|
211
|
-
|
|
212
|
-
var mentionContext = _objectSpread(_objectSpread({}, pluginState.contextIdentifierProvider), {}, {
|
|
213
|
-
sessionId: sessionId
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
if (queryChanged && pluginState.mentionProvider) {
|
|
217
|
-
// get ready to track invite item exposure once re-fetched is just invoked
|
|
218
|
-
shouldTrackInviteItemExposure = true;
|
|
219
|
-
pluginState.mentionProvider.filter(query || '', mentionContext);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
var mentionItems = mentions.map(function (mention) {
|
|
223
|
-
return memoizedToItem.call(mention);
|
|
224
|
-
}); // to show invite teammate item only if there is 2 or less mentionable user/team available
|
|
225
|
-
|
|
226
|
-
if (pluginState.mentionProvider && !!query && mentions.length <= 2) {
|
|
227
|
-
var _pluginState$mentionP = pluginState.mentionProvider,
|
|
228
|
-
inviteExperimentCohort = _pluginState$mentionP.inviteExperimentCohort,
|
|
229
|
-
shouldEnableInvite = _pluginState$mentionP.shouldEnableInvite,
|
|
230
|
-
userRole = _pluginState$mentionP.userRole;
|
|
231
|
-
|
|
232
|
-
if (shouldTrackInviteItemExposure) {
|
|
233
|
-
// we don't want to overly fire the exposure event for each continuous key press
|
|
234
|
-
debouncedFireEvent(buildTypeAheadInviteExposurePayload(!!shouldEnableInvite, sessionId, pluginState.contextIdentifierProvider, inviteExperimentCohort, userRole));
|
|
235
|
-
shouldTrackInviteItemExposure = false;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
if (shouldEnableInvite) {
|
|
239
|
-
if (inviteExperimentFirstQueryWithNoResults === '' && mentions.length === 0) {
|
|
240
|
-
inviteExperimentFirstQueryWithNoResults = query;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
if (mentions.length === 0 && !shouldKeepInviteItem(query, inviteExperimentFirstQueryWithNoResults)) {
|
|
244
|
-
return mentionItems;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
return [].concat(_toConsumableArray(mentionItems), [// invite item should be shown at the bottom
|
|
248
|
-
{
|
|
249
|
-
title: INVITE_ITEM_DESCRIPTION.id,
|
|
250
|
-
render: function render(_ref7) {
|
|
251
|
-
var isSelected = _ref7.isSelected,
|
|
252
|
-
onClick = _ref7.onClick,
|
|
253
|
-
onHover = _ref7.onHover;
|
|
254
|
-
return /*#__PURE__*/React.createElement(InviteItem, {
|
|
255
|
-
productName: pluginState.mentionProvider ? pluginState.mentionProvider.productName : undefined,
|
|
256
|
-
selected: isSelected,
|
|
257
|
-
onMount: function onMount() {
|
|
258
|
-
fireEvent(buildTypeAheadInviteItemViewedPayload(sessionId, pluginState.contextIdentifierProvider, userRole));
|
|
259
|
-
},
|
|
260
|
-
onMouseEnter: onHover,
|
|
261
|
-
onSelection: onClick,
|
|
262
|
-
userRole: userRole
|
|
263
|
-
});
|
|
264
|
-
},
|
|
265
|
-
mention: INVITE_ITEM_DESCRIPTION
|
|
266
|
-
}]);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
return mentionItems;
|
|
271
|
-
},
|
|
272
|
-
selectItem: function selectItem(state, item, insert, _ref8) {
|
|
273
|
-
var mode = _ref8.mode;
|
|
274
|
-
var sanitizePrivateContent = options && options.sanitizePrivateContent;
|
|
275
|
-
var mentionInsertDisplayName = options && options.insertDisplayName;
|
|
276
|
-
var schema = state.schema;
|
|
277
|
-
var pluginState = getMentionPluginState(state);
|
|
278
|
-
var mentionProvider = pluginState.mentionProvider;
|
|
279
|
-
var _item$mention = item.mention,
|
|
280
|
-
id = _item$mention.id,
|
|
281
|
-
name = _item$mention.name,
|
|
282
|
-
nickname = _item$mention.nickname,
|
|
283
|
-
accessLevel = _item$mention.accessLevel,
|
|
284
|
-
userType = _item$mention.userType;
|
|
285
|
-
var trimmedNickname = nickname && nickname.startsWith('@') ? nickname.slice(1) : nickname;
|
|
286
|
-
var renderName = mentionInsertDisplayName || !trimmedNickname ? name : trimmedNickname;
|
|
287
|
-
var typeAheadPluginState = typeAheadPluginKey.getState(state);
|
|
288
|
-
|
|
289
|
-
var mentionContext = _objectSpread(_objectSpread({}, pluginState.contextIdentifierProvider), {}, {
|
|
290
|
-
sessionId: sessionId
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
if (mentionProvider && !isInviteItem(item.mention)) {
|
|
294
|
-
mentionProvider.recordMentionSelection(item.mention, mentionContext);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
var pickerElapsedTime = typeAheadPluginState.queryStarted ? Date.now() - typeAheadPluginState.queryStarted : 0;
|
|
298
|
-
|
|
299
|
-
if (mentionProvider && mentionProvider.shouldEnableInvite && isInviteItem(item.mention)) {
|
|
300
|
-
// Don't fire event and the callback with selection by space press
|
|
301
|
-
if (mode !== 'space') {
|
|
302
|
-
fireEvent(buildTypeAheadInviteItemClickedPayload(pickerElapsedTime, typeAheadPluginState.upKeyCount, typeAheadPluginState.downKeyCount, sessionId, mode, typeAheadPluginState.query || '', pluginState.contextIdentifierProvider, mentionProvider.userRole));
|
|
303
|
-
|
|
304
|
-
if (mentionProvider.onInviteItemClick) {
|
|
305
|
-
mentionProvider.onInviteItemClick('mention');
|
|
306
|
-
} // reset the query cache upon selection
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
inviteExperimentFirstQueryWithNoResults = '';
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
return state.tr;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
fireEvent(buildTypeAheadInsertedPayload(pickerElapsedTime, typeAheadPluginState.upKeyCount, typeAheadPluginState.downKeyCount, sessionId, mode, item.mention, pluginState.mentions, typeAheadPluginState.query || '', pluginState.contextIdentifierProvider));
|
|
316
|
-
sessionId = uuid();
|
|
317
|
-
|
|
318
|
-
if (mentionProvider && isTeamType(userType)) {
|
|
319
|
-
TeamMentionHighlightController.registerTeamMention();
|
|
320
|
-
return insert(buildNodesForTeamMention(schema, item.mention, mentionProvider, sanitizePrivateContent));
|
|
321
|
-
} // Don't insert into document if document data is sanitized.
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
var text = sanitizePrivateContent ? '' : "@".concat(renderName);
|
|
325
|
-
|
|
326
|
-
if (sanitizePrivateContent && isResolvingMentionProvider(mentionProvider)) {
|
|
327
|
-
// Cache (locally) for later rendering
|
|
328
|
-
mentionProvider.cacheMentionName(id, renderName);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
return insert(schema.nodes.mention.createChecked({
|
|
332
|
-
text: text,
|
|
333
|
-
id: id,
|
|
334
|
-
accessLevel: accessLevel,
|
|
335
|
-
userType: userType === 'DEFAULT' ? null : userType
|
|
336
|
-
}));
|
|
337
|
-
},
|
|
338
|
-
dismiss: function dismiss(state) {
|
|
339
|
-
var pluginState = getMentionPluginState(state);
|
|
340
|
-
var mentionProvider = pluginState.mentionProvider;
|
|
341
|
-
|
|
342
|
-
if (mentionProvider && mentionProvider.shouldEnableInvite) {
|
|
343
|
-
// reset the query cache upon dismiss
|
|
344
|
-
inviteExperimentFirstQueryWithNoResults = '';
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
var typeAheadPluginState = typeAheadPluginKey.getState(state);
|
|
348
|
-
var pickerElapsedTime = typeAheadPluginState.queryStarted ? Date.now() - typeAheadPluginState.queryStarted : 0;
|
|
349
|
-
fireEvent(buildTypeAheadCancelPayload(pickerElapsedTime, typeAheadPluginState.upKeyCount, typeAheadPluginState.downKeyCount, sessionId, typeAheadPluginState.query || ''));
|
|
350
|
-
sessionId = uuid();
|
|
351
|
-
}
|
|
352
|
-
}
|
|
109
|
+
typeAhead: typeAhead
|
|
353
110
|
}
|
|
354
111
|
};
|
|
355
112
|
};
|
|
356
113
|
|
|
357
|
-
export default mentionsPlugin;
|
|
358
|
-
/**
|
|
359
|
-
* Actions
|
|
360
|
-
*/
|
|
361
|
-
|
|
362
|
-
export var ACTIONS = {
|
|
363
|
-
SET_PROVIDER: 'SET_PROVIDER',
|
|
364
|
-
SET_RESULTS: 'SET_RESULTS',
|
|
365
|
-
SET_CONTEXT: 'SET_CONTEXT'
|
|
366
|
-
};
|
|
367
|
-
export var setProvider = function setProvider(provider) {
|
|
368
|
-
return function (state, dispatch) {
|
|
369
|
-
if (dispatch) {
|
|
370
|
-
dispatch(state.tr.setMeta(mentionPluginKey, {
|
|
371
|
-
action: ACTIONS.SET_PROVIDER,
|
|
372
|
-
params: {
|
|
373
|
-
provider: provider
|
|
374
|
-
}
|
|
375
|
-
}));
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
return true;
|
|
379
|
-
};
|
|
380
|
-
};
|
|
381
|
-
export var setResults = function setResults(results) {
|
|
382
|
-
return function (state, dispatch) {
|
|
383
|
-
if (dispatch) {
|
|
384
|
-
dispatch(state.tr.setMeta(mentionPluginKey, {
|
|
385
|
-
action: ACTIONS.SET_RESULTS,
|
|
386
|
-
params: {
|
|
387
|
-
results: results
|
|
388
|
-
}
|
|
389
|
-
}));
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
return true;
|
|
393
|
-
};
|
|
394
|
-
};
|
|
395
|
-
export var setContext = function setContext(context) {
|
|
396
|
-
return function (state, dispatch) {
|
|
397
|
-
if (dispatch) {
|
|
398
|
-
dispatch(state.tr.setMeta(mentionPluginKey, {
|
|
399
|
-
action: ACTIONS.SET_CONTEXT,
|
|
400
|
-
params: {
|
|
401
|
-
context: context
|
|
402
|
-
}
|
|
403
|
-
}));
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
return true;
|
|
407
|
-
};
|
|
408
|
-
};
|
|
409
|
-
/**
|
|
410
|
-
*
|
|
411
|
-
* ProseMirror Plugin
|
|
412
|
-
*
|
|
413
|
-
*/
|
|
414
|
-
|
|
415
|
-
export var mentionPluginKey = new PluginKey('mentionPlugin');
|
|
416
|
-
export function getMentionPluginState(state) {
|
|
417
|
-
return mentionPluginKey.getState(state);
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
function mentionPluginFactory(dispatch, providerFactory, portalProviderAPI, eventDispatcher, fireEvent, options) {
|
|
421
|
-
var mentionProvider;
|
|
422
|
-
|
|
423
|
-
var sendAnalytics = function sendAnalytics(event, actionSubject, action, attributes) {
|
|
424
|
-
if (event === SLI_EVENT_TYPE || event === SMART_EVENT_TYPE) {
|
|
425
|
-
fireEvent(buildSliPayload(actionSubject, action, attributes));
|
|
426
|
-
}
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
return new Plugin({
|
|
430
|
-
key: mentionPluginKey,
|
|
431
|
-
state: {
|
|
432
|
-
init: function init() {
|
|
433
|
-
return {};
|
|
434
|
-
},
|
|
435
|
-
apply: function apply(tr, pluginState) {
|
|
436
|
-
var _ref9 = tr.getMeta(mentionPluginKey) || {
|
|
437
|
-
action: null,
|
|
438
|
-
params: null
|
|
439
|
-
},
|
|
440
|
-
action = _ref9.action,
|
|
441
|
-
params = _ref9.params;
|
|
442
|
-
|
|
443
|
-
var newPluginState = pluginState;
|
|
444
|
-
|
|
445
|
-
switch (action) {
|
|
446
|
-
case ACTIONS.SET_PROVIDER:
|
|
447
|
-
newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
448
|
-
mentionProvider: params.provider
|
|
449
|
-
});
|
|
450
|
-
dispatch(mentionPluginKey, newPluginState);
|
|
451
|
-
return newPluginState;
|
|
452
|
-
|
|
453
|
-
case ACTIONS.SET_RESULTS:
|
|
454
|
-
newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
455
|
-
mentions: params.results
|
|
456
|
-
});
|
|
457
|
-
dispatch(mentionPluginKey, newPluginState);
|
|
458
|
-
return newPluginState;
|
|
459
|
-
|
|
460
|
-
case ACTIONS.SET_CONTEXT:
|
|
461
|
-
newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
462
|
-
contextIdentifierProvider: params.context
|
|
463
|
-
});
|
|
464
|
-
dispatch(mentionPluginKey, newPluginState);
|
|
465
|
-
return newPluginState;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
return newPluginState;
|
|
469
|
-
}
|
|
470
|
-
},
|
|
471
|
-
props: {
|
|
472
|
-
nodeViews: {
|
|
473
|
-
mention: mentionNodeView(portalProviderAPI, eventDispatcher, providerFactory, options)
|
|
474
|
-
}
|
|
475
|
-
},
|
|
476
|
-
view: function view(editorView) {
|
|
477
|
-
var providerHandler = function providerHandler(name, providerPromise) {
|
|
478
|
-
switch (name) {
|
|
479
|
-
case 'mentionProvider':
|
|
480
|
-
if (!providerPromise) {
|
|
481
|
-
return setProvider(undefined)(editorView.state, editorView.dispatch);
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
providerPromise.then(function (provider) {
|
|
485
|
-
if (mentionProvider) {
|
|
486
|
-
mentionProvider.unsubscribe('mentionPlugin');
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
mentionProvider = provider;
|
|
490
|
-
setProvider(provider)(editorView.state, editorView.dispatch);
|
|
491
|
-
provider.subscribe('mentionPlugin', function (mentions, query, stats) {
|
|
492
|
-
setResults(mentions)(editorView.state, editorView.dispatch);
|
|
493
|
-
var duration = 0;
|
|
494
|
-
var userOrTeamIds = null;
|
|
495
|
-
var teams = null;
|
|
496
|
-
|
|
497
|
-
if (!isTeamStats(stats)) {
|
|
498
|
-
// is from primary mention endpoint which could be just user mentions or user/team mentions
|
|
499
|
-
duration = stats && stats.duration;
|
|
500
|
-
teams = null;
|
|
501
|
-
userOrTeamIds = mentions.map(function (mention) {
|
|
502
|
-
return mention.id;
|
|
503
|
-
});
|
|
504
|
-
} else {
|
|
505
|
-
// is from dedicated team-only mention endpoint
|
|
506
|
-
duration = stats && stats.teamMentionDuration;
|
|
507
|
-
userOrTeamIds = null;
|
|
508
|
-
teams = mentions.map(function (mention) {
|
|
509
|
-
return isTeamType(mention.userType) ? {
|
|
510
|
-
teamId: mention.id,
|
|
511
|
-
includesYou: mention.context.includesYou,
|
|
512
|
-
memberCount: mention.context.memberCount
|
|
513
|
-
} : null;
|
|
514
|
-
}).filter(function (m) {
|
|
515
|
-
return !!m;
|
|
516
|
-
});
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
var payload = buildTypeAheadRenderedPayload(duration, userOrTeamIds, query || '', teams);
|
|
520
|
-
fireEvent(payload);
|
|
521
|
-
}, undefined, undefined, undefined, sendAnalytics);
|
|
522
|
-
}).catch(function () {
|
|
523
|
-
return setProvider(undefined)(editorView.state, editorView.dispatch);
|
|
524
|
-
});
|
|
525
|
-
break;
|
|
526
|
-
|
|
527
|
-
case 'contextIdentifierProvider':
|
|
528
|
-
if (!providerPromise) {
|
|
529
|
-
return setContext(undefined)(editorView.state, editorView.dispatch);
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
providerPromise.then(function (provider) {
|
|
533
|
-
setContext(provider)(editorView.state, editorView.dispatch);
|
|
534
|
-
});
|
|
535
|
-
break;
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
return;
|
|
539
|
-
};
|
|
540
|
-
|
|
541
|
-
providerFactory.subscribe('mentionProvider', providerHandler);
|
|
542
|
-
providerFactory.subscribe('contextIdentifierProvider', providerHandler);
|
|
543
|
-
return {
|
|
544
|
-
destroy: function destroy() {
|
|
545
|
-
if (providerFactory) {
|
|
546
|
-
providerFactory.unsubscribe('mentionProvider', providerHandler);
|
|
547
|
-
providerFactory.unsubscribe('contextIdentifierProvider', providerHandler);
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
if (mentionProvider) {
|
|
551
|
-
mentionProvider.unsubscribe('mentionPlugin');
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
};
|
|
555
|
-
}
|
|
556
|
-
});
|
|
557
|
-
}
|
|
558
|
-
/**
|
|
559
|
-
* When a team mention is selected, we render a team link and list of member/user mentions
|
|
560
|
-
* in editor content
|
|
561
|
-
*/
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
function buildNodesForTeamMention(schema, selectedMention, mentionProvider, sanitizePrivateContent) {
|
|
565
|
-
var nodes = schema.nodes,
|
|
566
|
-
marks = schema.marks;
|
|
567
|
-
var name = selectedMention.name,
|
|
568
|
-
teamId = selectedMention.id,
|
|
569
|
-
accessLevel = selectedMention.accessLevel,
|
|
570
|
-
context = selectedMention.context; // build team link
|
|
571
|
-
|
|
572
|
-
var defaultTeamLink = "".concat(window.location.origin, "/people/team/").concat(teamId);
|
|
573
|
-
var teamLink = context && context.teamLink ? context.teamLink : defaultTeamLink;
|
|
574
|
-
var teamLinkNode = schema.text(name, [marks.link.create({
|
|
575
|
-
href: teamLink
|
|
576
|
-
})]);
|
|
577
|
-
var openBracketText = schema.text('(');
|
|
578
|
-
var closeBracketText = schema.text(')');
|
|
579
|
-
var emptySpaceText = schema.text(' ');
|
|
580
|
-
var inlineNodes = [teamLinkNode, emptySpaceText, openBracketText];
|
|
581
|
-
var members = context && context.members ? context.members : [];
|
|
582
|
-
members.forEach(function (member, index) {
|
|
583
|
-
var name = member.name,
|
|
584
|
-
id = member.id;
|
|
585
|
-
var mentionName = "@".concat(name);
|
|
586
|
-
var text = sanitizePrivateContent ? '' : mentionName;
|
|
587
|
-
|
|
588
|
-
if (sanitizePrivateContent && isResolvingMentionProvider(mentionProvider)) {
|
|
589
|
-
mentionProvider.cacheMentionName(id, name);
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
var userMentionNode = nodes.mention.createChecked({
|
|
593
|
-
text: text,
|
|
594
|
-
id: member.id,
|
|
595
|
-
accessLevel: accessLevel,
|
|
596
|
-
userType: 'DEFAULT'
|
|
597
|
-
});
|
|
598
|
-
inlineNodes.push(userMentionNode); // should not add empty space after the last user mention.
|
|
599
|
-
|
|
600
|
-
if (index !== members.length - 1) {
|
|
601
|
-
inlineNodes.push(emptySpaceText);
|
|
602
|
-
}
|
|
603
|
-
});
|
|
604
|
-
inlineNodes.push(closeBracketText);
|
|
605
|
-
return Fragment.fromArray(inlineNodes);
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
var isTeamMentionProvider = function isTeamMentionProvider(p) {
|
|
609
|
-
return !!(p.mentionTypeaheadHighlightEnabled && p.mentionTypeaheadCreateTeamPath);
|
|
610
|
-
};
|
|
611
|
-
|
|
612
|
-
export var shouldKeepInviteItem = function shouldKeepInviteItem(query, firstQueryWithoutResults) {
|
|
613
|
-
if (!firstQueryWithoutResults) {
|
|
614
|
-
return true;
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
var lastIndexWithResults = firstQueryWithoutResults.length - 1;
|
|
618
|
-
var suffix = query.slice(lastIndexWithResults);
|
|
619
|
-
|
|
620
|
-
if (query[lastIndexWithResults - 1] === ' ') {
|
|
621
|
-
suffix = ' ' + suffix;
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
var depletedExtraWords = /\s[^\s]+\s/.test(suffix);
|
|
625
|
-
return !depletedExtraWords;
|
|
626
|
-
};
|
|
114
|
+
export default mentionsPlugin;
|