@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
|
@@ -8,29 +8,132 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
Object.defineProperty(exports, "typeAheadPluginKey", {
|
|
9
9
|
enumerable: true,
|
|
10
10
|
get: function get() {
|
|
11
|
-
return
|
|
11
|
+
return _key.pluginKey;
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
14
|
exports.default = void 0;
|
|
15
15
|
|
|
16
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
17
|
+
|
|
16
18
|
var _react = _interopRequireDefault(require("react"));
|
|
17
19
|
|
|
18
|
-
var
|
|
20
|
+
var _typeAhead = require("@atlaskit/editor-common/type-ahead");
|
|
21
|
+
|
|
22
|
+
var _main = require("./pm-plugins/main");
|
|
23
|
+
|
|
24
|
+
var _insertItemPlugin = require("./pm-plugins/insert-item-plugin");
|
|
19
25
|
|
|
20
26
|
var _WithPluginState = _interopRequireDefault(require("../../ui/WithPluginState"));
|
|
21
27
|
|
|
28
|
+
var _adfSchema = require("@atlaskit/adf-schema");
|
|
29
|
+
|
|
30
|
+
var _key = require("./pm-plugins/key");
|
|
31
|
+
|
|
22
32
|
var _inputRules = require("./pm-plugins/input-rules");
|
|
23
33
|
|
|
24
|
-
var
|
|
34
|
+
var _TypeAheadPopup = require("./ui/TypeAheadPopup");
|
|
25
35
|
|
|
26
|
-
var
|
|
36
|
+
var _utils = require("./utils");
|
|
37
|
+
|
|
38
|
+
var _useItemInsert3 = require("./ui/hooks/use-item-insert");
|
|
39
|
+
|
|
40
|
+
var _updateSelectedIndex = require("./commands/update-selected-index");
|
|
41
|
+
|
|
42
|
+
var _statsModifier = require("./stats-modifier");
|
|
27
43
|
|
|
28
|
-
var
|
|
44
|
+
var _analytics = require("../analytics");
|
|
45
|
+
|
|
46
|
+
var TypeAheadMenu = /*#__PURE__*/_react.default.memo(function (_ref) {
|
|
47
|
+
var _popupMountRef$curren, _popupMountRef$curren2, _popupMountRef$curren3;
|
|
48
|
+
|
|
49
|
+
var editorView = _ref.editorView,
|
|
50
|
+
popupMountRef = _ref.popupMountRef,
|
|
51
|
+
typeAheadState = _ref.typeAheadState,
|
|
52
|
+
fireAnalyticsCallback = _ref.fireAnalyticsCallback;
|
|
53
|
+
var isOpen = typeAheadState.decorationSet.find().length > 0;
|
|
54
|
+
var triggerHandler = typeAheadState.triggerHandler,
|
|
55
|
+
items = typeAheadState.items,
|
|
56
|
+
selectedIndex = typeAheadState.selectedIndex,
|
|
57
|
+
decorationElement = typeAheadState.decorationElement,
|
|
58
|
+
decorationSet = typeAheadState.decorationSet,
|
|
59
|
+
query = typeAheadState.query;
|
|
60
|
+
|
|
61
|
+
var _useItemInsert = (0, _useItemInsert3.useItemInsert)(triggerHandler, editorView, items),
|
|
62
|
+
_useItemInsert2 = (0, _slicedToArray2.default)(_useItemInsert, 3),
|
|
63
|
+
onItemInsert = _useItemInsert2[0],
|
|
64
|
+
onItemMatch = _useItemInsert2[2];
|
|
65
|
+
|
|
66
|
+
var setSelectedItem = _react.default.useCallback(function (_ref2) {
|
|
67
|
+
var nextIndex = _ref2.index;
|
|
68
|
+
queueMicrotask(function () {
|
|
69
|
+
(0, _updateSelectedIndex.updateSelectedIndex)(nextIndex)(editorView.state, editorView.dispatch);
|
|
70
|
+
});
|
|
71
|
+
}, [editorView]);
|
|
72
|
+
|
|
73
|
+
var insertItem = _react.default.useCallback(function () {
|
|
74
|
+
var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _typeAhead.SelectItemMode.SELECTED;
|
|
75
|
+
var index = arguments.length > 1 ? arguments[1] : undefined;
|
|
76
|
+
queueMicrotask(function () {
|
|
77
|
+
onItemInsert({
|
|
78
|
+
mode: mode,
|
|
79
|
+
index: index,
|
|
80
|
+
query: query
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}, [onItemInsert, query]);
|
|
84
|
+
|
|
85
|
+
_react.default.useEffect(function () {
|
|
86
|
+
if (!isOpen || !query) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
var isLastCharSpace = query[query.length - 1] === ' ';
|
|
91
|
+
|
|
92
|
+
if (!isLastCharSpace) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
var result = onItemMatch({
|
|
97
|
+
mode: _typeAhead.SelectItemMode.SPACE,
|
|
98
|
+
query: query.trim()
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
if (!result) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
}, [isOpen, query, onItemMatch]);
|
|
105
|
+
|
|
106
|
+
if (!isOpen || !triggerHandler || !(decorationElement instanceof HTMLElement) || items.length === 0) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return /*#__PURE__*/_react.default.createElement(_TypeAheadPopup.TypeAheadPopup, {
|
|
111
|
+
editorView: editorView,
|
|
112
|
+
popupsMountPoint: (_popupMountRef$curren = popupMountRef.current) === null || _popupMountRef$curren === void 0 ? void 0 : _popupMountRef$curren.popupsMountPoint,
|
|
113
|
+
popupsBoundariesElement: (_popupMountRef$curren2 = popupMountRef.current) === null || _popupMountRef$curren2 === void 0 ? void 0 : _popupMountRef$curren2.popupsBoundariesElement,
|
|
114
|
+
popupsScrollableElement: (_popupMountRef$curren3 = popupMountRef.current) === null || _popupMountRef$curren3 === void 0 ? void 0 : _popupMountRef$curren3.popupsScrollableElement,
|
|
115
|
+
anchorElement: decorationElement,
|
|
116
|
+
triggerHandler: triggerHandler,
|
|
117
|
+
fireAnalyticsCallback: fireAnalyticsCallback,
|
|
118
|
+
items: items,
|
|
119
|
+
selectedIndex: selectedIndex,
|
|
120
|
+
setSelectedItem: setSelectedItem,
|
|
121
|
+
onItemInsert: insertItem,
|
|
122
|
+
decorationSet: decorationSet,
|
|
123
|
+
isEmptyQuery: !query
|
|
124
|
+
});
|
|
125
|
+
});
|
|
29
126
|
|
|
30
127
|
var typeAheadPlugin = function typeAheadPlugin(options) {
|
|
128
|
+
var fireAnalyticsCallback = (0, _analytics.fireAnalyticsEvent)(options === null || options === void 0 ? void 0 : options.createAnalyticsEvent);
|
|
129
|
+
var popupMountRef = {
|
|
130
|
+
current: null
|
|
131
|
+
};
|
|
31
132
|
return {
|
|
32
133
|
name: 'typeAhead',
|
|
33
134
|
marks: function marks() {
|
|
135
|
+
// We need to keep this to make sure
|
|
136
|
+
// All documents with typeahead marks will be loaded normaly
|
|
34
137
|
return [{
|
|
35
138
|
name: 'typeAheadQuery',
|
|
36
139
|
mark: _adfSchema.typeAheadQuery
|
|
@@ -40,71 +143,99 @@ var typeAheadPlugin = function typeAheadPlugin(options) {
|
|
|
40
143
|
var typeAhead = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
41
144
|
return [{
|
|
42
145
|
name: 'typeAhead',
|
|
43
|
-
plugin: function plugin(
|
|
44
|
-
var dispatch =
|
|
45
|
-
reactContext =
|
|
46
|
-
return (0, _main.createPlugin)(
|
|
146
|
+
plugin: function plugin(_ref3) {
|
|
147
|
+
var dispatch = _ref3.dispatch,
|
|
148
|
+
reactContext = _ref3.reactContext;
|
|
149
|
+
return (0, _main.createPlugin)({
|
|
150
|
+
reactContext: reactContext,
|
|
151
|
+
popupMountRef: popupMountRef,
|
|
152
|
+
reactDispatch: dispatch,
|
|
153
|
+
typeAheadHandlers: typeAhead,
|
|
154
|
+
createAnalyticsEvent: options === null || options === void 0 ? void 0 : options.createAnalyticsEvent
|
|
155
|
+
});
|
|
47
156
|
}
|
|
157
|
+
}, {
|
|
158
|
+
name: 'typeAheadInsertItem',
|
|
159
|
+
plugin: _insertItemPlugin.createPlugin
|
|
48
160
|
}, {
|
|
49
161
|
name: 'typeAheadInputRule',
|
|
50
|
-
plugin: function plugin(
|
|
51
|
-
var schema =
|
|
52
|
-
featureFlags =
|
|
162
|
+
plugin: function plugin(_ref4) {
|
|
163
|
+
var schema = _ref4.schema,
|
|
164
|
+
featureFlags = _ref4.featureFlags;
|
|
53
165
|
return (0, _inputRules.inputRulePlugin)(schema, typeAhead, featureFlags);
|
|
54
166
|
}
|
|
55
|
-
}, {
|
|
56
|
-
name: 'typeAheadKeymap',
|
|
57
|
-
plugin: function plugin() {
|
|
58
|
-
return (0, _keymap.keymapPlugin)();
|
|
59
|
-
}
|
|
60
167
|
}];
|
|
61
168
|
},
|
|
62
|
-
contentComponent: function contentComponent(
|
|
63
|
-
var editorView =
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
169
|
+
contentComponent: function contentComponent(_ref5) {
|
|
170
|
+
var editorView = _ref5.editorView,
|
|
171
|
+
containerElement = _ref5.containerElement,
|
|
172
|
+
popupsMountPoint = _ref5.popupsMountPoint,
|
|
173
|
+
popupsBoundariesElement = _ref5.popupsBoundariesElement,
|
|
174
|
+
popupsScrollableElement = _ref5.popupsScrollableElement;
|
|
175
|
+
popupMountRef.current = {
|
|
176
|
+
popupsMountPoint: popupsMountPoint || containerElement || undefined,
|
|
177
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
178
|
+
popupsScrollableElement: popupsScrollableElement
|
|
179
|
+
};
|
|
67
180
|
return /*#__PURE__*/_react.default.createElement(_WithPluginState.default, {
|
|
68
181
|
plugins: {
|
|
69
|
-
|
|
182
|
+
typeAheadState: _key.pluginKey
|
|
70
183
|
},
|
|
71
|
-
render: function render(
|
|
72
|
-
var
|
|
73
|
-
typeAhead = _ref4$typeAhead === void 0 ? (0, _main.createInitialPluginState)() : _ref4$typeAhead;
|
|
184
|
+
render: function render(_ref6) {
|
|
185
|
+
var typeAheadState = _ref6.typeAheadState;
|
|
74
186
|
|
|
75
|
-
if (
|
|
187
|
+
if (!typeAheadState) {
|
|
76
188
|
return null;
|
|
77
189
|
}
|
|
78
190
|
|
|
79
|
-
|
|
80
|
-
var domRef = null;
|
|
81
|
-
|
|
82
|
-
if (queryMarkPos !== null) {
|
|
83
|
-
// temporary fix to avoid page crash until it is fixed properly
|
|
84
|
-
try {
|
|
85
|
-
domRef = editorView.domAtPos(queryMarkPos);
|
|
86
|
-
} catch (ex) {
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
var anchorElement = domRef ? domRef.node.childNodes[domRef.offset] : undefined;
|
|
92
|
-
return /*#__PURE__*/_react.default.createElement(_TypeAhead.TypeAhead, {
|
|
191
|
+
return /*#__PURE__*/_react.default.createElement(TypeAheadMenu, {
|
|
93
192
|
editorView: editorView,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
anchorElement: anchorElement,
|
|
98
|
-
active: typeAhead.active,
|
|
99
|
-
isLoading: !!typeAhead.itemsLoader,
|
|
100
|
-
items: typeAhead.items,
|
|
101
|
-
currentIndex: typeAhead.currentIndex,
|
|
102
|
-
highlight: typeAhead.highlight,
|
|
103
|
-
createAnalyticsEvent: options === null || options === void 0 ? void 0 : options.createAnalyticsEvent,
|
|
104
|
-
query: typeAhead.query
|
|
193
|
+
popupMountRef: popupMountRef,
|
|
194
|
+
typeAheadState: typeAheadState,
|
|
195
|
+
fireAnalyticsCallback: fireAnalyticsCallback
|
|
105
196
|
});
|
|
106
197
|
}
|
|
107
198
|
});
|
|
199
|
+
},
|
|
200
|
+
onEditorViewStateUpdated: function onEditorViewStateUpdated(_ref7) {
|
|
201
|
+
var oldEditorState = _ref7.oldEditorState,
|
|
202
|
+
newEditorState = _ref7.newEditorState;
|
|
203
|
+
var oldPluginState = (0, _utils.getPluginState)(oldEditorState);
|
|
204
|
+
var newPluginState = (0, _utils.getPluginState)(newEditorState);
|
|
205
|
+
|
|
206
|
+
if (!oldPluginState || !newPluginState) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
var oldTriggerHandler = oldPluginState.triggerHandler;
|
|
211
|
+
var newTriggerHandler = newPluginState.triggerHandler;
|
|
212
|
+
var isANewHandler = oldTriggerHandler !== newTriggerHandler;
|
|
213
|
+
|
|
214
|
+
if (oldTriggerHandler !== null && oldTriggerHandler !== void 0 && oldTriggerHandler.dismiss && isANewHandler) {
|
|
215
|
+
oldTriggerHandler.dismiss({
|
|
216
|
+
editorState: newEditorState,
|
|
217
|
+
query: oldPluginState.query,
|
|
218
|
+
stats: (oldPluginState.stats || new _statsModifier.StatsModifier()).serialize()
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (newTriggerHandler !== null && newTriggerHandler !== void 0 && newTriggerHandler.onOpen && isANewHandler) {
|
|
223
|
+
newTriggerHandler.onOpen(newEditorState);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (newTriggerHandler && isANewHandler && options !== null && options !== void 0 && options.createAnalyticsEvent) {
|
|
227
|
+
fireAnalyticsCallback({
|
|
228
|
+
payload: {
|
|
229
|
+
action: _analytics.ACTION.INVOKED,
|
|
230
|
+
actionSubject: _analytics.ACTION_SUBJECT.TYPEAHEAD,
|
|
231
|
+
actionSubjectId: newTriggerHandler.id || 'not_set',
|
|
232
|
+
attributes: {
|
|
233
|
+
inputMethod: newPluginState.inputMethod || _analytics.INPUT_METHOD.KEYBOARD
|
|
234
|
+
},
|
|
235
|
+
eventType: _analytics.EVENT_TYPE.UI
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
}
|
|
108
239
|
}
|
|
109
240
|
};
|
|
110
241
|
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.insertInlineNodeOrFragment = exports.insertBlockNode = void 0;
|
|
7
|
+
|
|
8
|
+
var _prosemirrorState = require("prosemirror-state");
|
|
9
|
+
|
|
10
|
+
var _prosemirrorModel = require("prosemirror-model");
|
|
11
|
+
|
|
12
|
+
var _selection = require("../../utils/selection");
|
|
13
|
+
|
|
14
|
+
var _insert = require("../../utils/insert");
|
|
15
|
+
|
|
16
|
+
function findInsertPoint(doc, pos, nodeToInsert) {
|
|
17
|
+
var $pos = doc.resolve(pos);
|
|
18
|
+
|
|
19
|
+
var createInsertPosition = function createInsertPosition(from, to) {
|
|
20
|
+
return {
|
|
21
|
+
from: from,
|
|
22
|
+
to: to || from
|
|
23
|
+
};
|
|
24
|
+
}; // Search for a valid position for nodeToInsert in progressively higher levels
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
for (var level = $pos.depth; level >= 0; level--) {
|
|
28
|
+
var nodeAtLevel = $pos.node(level); // Try to replace the empty paragraph in the level above
|
|
29
|
+
// Scenario:
|
|
30
|
+
// doc(
|
|
31
|
+
// table(
|
|
32
|
+
// row(
|
|
33
|
+
// cell(
|
|
34
|
+
// p('{<>}'),
|
|
35
|
+
// ),
|
|
36
|
+
// )
|
|
37
|
+
// )
|
|
38
|
+
// )
|
|
39
|
+
|
|
40
|
+
var levelAbove = Math.max(level - 1, 0);
|
|
41
|
+
var parentNode = $pos.node(levelAbove); // Special case: when this is true, the 'to' position should be the end
|
|
42
|
+
// of the empty paragraph
|
|
43
|
+
|
|
44
|
+
var isNodeAtLevelEmptyParagraph = nodeAtLevel.type.name === 'paragraph' && nodeAtLevel.content.size === 0;
|
|
45
|
+
var indexAtLevelAbove = $pos.index(levelAbove);
|
|
46
|
+
var canReplaceNodeAtLevelAbove = parentNode.canReplaceWith(indexAtLevelAbove, indexAtLevelAbove, nodeToInsert.type);
|
|
47
|
+
|
|
48
|
+
if (isNodeAtLevelEmptyParagraph && canReplaceNodeAtLevelAbove) {
|
|
49
|
+
var from = $pos.posAtIndex(indexAtLevelAbove, levelAbove);
|
|
50
|
+
return createInsertPosition(from, from + nodeAtLevel.nodeSize);
|
|
51
|
+
} // Try to insert this node right after the node in the level above
|
|
52
|
+
// Scenario:
|
|
53
|
+
// doc(
|
|
54
|
+
// panel(
|
|
55
|
+
// p('{<>}'),
|
|
56
|
+
// )
|
|
57
|
+
// )
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
var indexAfterAtLevelAbove = $pos.indexAfter(levelAbove);
|
|
61
|
+
var canInsertNodeAtLevelAbove = parentNode.canReplaceWith(indexAfterAtLevelAbove, indexAfterAtLevelAbove, nodeToInsert.type);
|
|
62
|
+
|
|
63
|
+
if (canInsertNodeAtLevelAbove) {
|
|
64
|
+
return createInsertPosition($pos.posAtIndex(indexAfterAtLevelAbove, levelAbove));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return createInsertPosition(0);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
var insertBlockNode = function insertBlockNode(_ref) {
|
|
72
|
+
var node = _ref.node,
|
|
73
|
+
tr = _ref.tr,
|
|
74
|
+
position = _ref.position;
|
|
75
|
+
var start = position.start,
|
|
76
|
+
end = position.end;
|
|
77
|
+
|
|
78
|
+
if (node.isText) {
|
|
79
|
+
return tr.replaceWith(start, end, node);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (node.isBlock) {
|
|
83
|
+
tr.delete(start, end);
|
|
84
|
+
var mappedStart = tr.mapping.map(start);
|
|
85
|
+
var nodeNormalized = (0, _selection.normaliseNestedLayout)(tr, node); // Handle edge cases for hr and mediaSingle
|
|
86
|
+
|
|
87
|
+
var inserted = (0, _insert.safeInsert)(nodeNormalized, mappedStart)(tr);
|
|
88
|
+
|
|
89
|
+
if (inserted) {
|
|
90
|
+
return tr;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
var sliceInserted = _prosemirrorModel.Slice.maxOpen(_prosemirrorModel.Fragment.from(nodeNormalized));
|
|
94
|
+
|
|
95
|
+
var _findInsertPoint = findInsertPoint(tr.doc, mappedStart, nodeNormalized),
|
|
96
|
+
from = _findInsertPoint.from,
|
|
97
|
+
to = _findInsertPoint.to;
|
|
98
|
+
|
|
99
|
+
tr.replaceWith(from, to, node);
|
|
100
|
+
var openPosition = Math.min(from + (node.isAtom ? node.nodeSize : sliceInserted.openStart), tr.doc.content.size);
|
|
101
|
+
var FORWARD_DIRECTION = 1;
|
|
102
|
+
|
|
103
|
+
var nextSelection = _prosemirrorState.TextSelection.findFrom(tr.doc.resolve(openPosition), FORWARD_DIRECTION, true);
|
|
104
|
+
|
|
105
|
+
if (nextSelection) {
|
|
106
|
+
return tr.setSelection(nextSelection);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return tr;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
exports.insertBlockNode = insertBlockNode;
|
|
114
|
+
|
|
115
|
+
var insertInlineNodeOrFragment = function insertInlineNodeOrFragment(_ref2) {
|
|
116
|
+
var maybeFragment = _ref2.maybeFragment,
|
|
117
|
+
tr = _ref2.tr,
|
|
118
|
+
position = _ref2.position,
|
|
119
|
+
selectInlineNode = _ref2.selectInlineNode;
|
|
120
|
+
var start = position.start,
|
|
121
|
+
end = position.end;
|
|
122
|
+
var fragment = maybeFragment instanceof _prosemirrorModel.Node ? _prosemirrorModel.Fragment.from(maybeFragment) : maybeFragment;
|
|
123
|
+
tr.replaceWith(start, end, fragment);
|
|
124
|
+
|
|
125
|
+
if (selectInlineNode) {
|
|
126
|
+
return tr.setSelection(_prosemirrorState.NodeSelection.create(tr.doc, start));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return tr.setSelection(_prosemirrorState.TextSelection.near(tr.doc.resolve(start + fragment.size)));
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
exports.insertInlineNodeOrFragment = insertInlineNodeOrFragment;
|
|
@@ -4,12 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ACTIONS = void 0;
|
|
7
|
-
var ACTIONS
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
var ACTIONS;
|
|
8
|
+
exports.ACTIONS = ACTIONS;
|
|
9
|
+
|
|
10
|
+
(function (ACTIONS) {
|
|
11
|
+
ACTIONS["OPEN_TYPEAHEAD_AT_CURSOR"] = "OPEN_TYPEAHEAD_AT_CURSOR";
|
|
12
|
+
ACTIONS["CLOSE_TYPE_AHEAD"] = "CLOSE_TYPE_AHEAD";
|
|
13
|
+
ACTIONS["CHANGE_QUERY"] = "CHANGE_QUERY";
|
|
14
|
+
ACTIONS["INSERT_ITEM"] = "INSERT_ITEM";
|
|
15
|
+
ACTIONS["INSERT_RAW_QUERY"] = "INSERT_RAW_QUERY";
|
|
16
|
+
ACTIONS["UPDATE_LIST_ITEMS"] = "UPDATE_LIST_ITEMS";
|
|
17
|
+
ACTIONS["UPDATE_SELECTED_INDEX"] = "UPDATE_SELECTED_INDEX";
|
|
18
|
+
})(ACTIONS || (exports.ACTIONS = ACTIONS = {}));
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.findDecorationElement = exports.isSelectionInsideTypeAhead = exports.factoryDecorations = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
13
|
+
|
|
14
|
+
var _uuid = _interopRequireDefault(require("uuid"));
|
|
15
|
+
|
|
16
|
+
var _prosemirrorState = require("prosemirror-state");
|
|
17
|
+
|
|
18
|
+
var _prosemirrorView = require("prosemirror-view");
|
|
19
|
+
|
|
20
|
+
var _colors = require("@atlaskit/theme/colors");
|
|
21
|
+
|
|
22
|
+
var _w3cKeyname = require("w3c-keyname");
|
|
23
|
+
|
|
24
|
+
var _reactIntl = require("react-intl");
|
|
25
|
+
|
|
26
|
+
var _prosemirrorHistory = require("prosemirror-history");
|
|
27
|
+
|
|
28
|
+
var _constants = require("../constants");
|
|
29
|
+
|
|
30
|
+
var _WrapperTypeAhead = require("../ui/WrapperTypeAhead");
|
|
31
|
+
|
|
32
|
+
var _statsModifier = require("../stats-modifier");
|
|
33
|
+
|
|
34
|
+
var _utils = require("../utils");
|
|
35
|
+
|
|
36
|
+
var _closeTypeAhead = require("../transforms/close-type-ahead");
|
|
37
|
+
|
|
38
|
+
var factoryDecorations = function factoryDecorations(_ref) {
|
|
39
|
+
var intl = _ref.intl,
|
|
40
|
+
popupMountRef = _ref.popupMountRef,
|
|
41
|
+
createAnalyticsEvent = _ref.createAnalyticsEvent;
|
|
42
|
+
|
|
43
|
+
var createDecorations = function createDecorations(tr, _ref2) {
|
|
44
|
+
var triggerHandler = _ref2.triggerHandler,
|
|
45
|
+
inputMethod = _ref2.inputMethod,
|
|
46
|
+
reopenQuery = _ref2.reopenQuery;
|
|
47
|
+
var selection = tr.selection;
|
|
48
|
+
|
|
49
|
+
if (!(selection instanceof _prosemirrorState.TextSelection) || !selection.$cursor) {
|
|
50
|
+
return {
|
|
51
|
+
decorationSet: _prosemirrorView.DecorationSet.empty,
|
|
52
|
+
stats: null,
|
|
53
|
+
decorationElement: null
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var decorationId = "decoration_id_".concat(_constants.TYPE_AHEAD_DECORATION_KEY, "_").concat((0, _uuid.default)());
|
|
58
|
+
var $cursor = selection.$cursor;
|
|
59
|
+
var typeaheadComponent = document.createElement('mark');
|
|
60
|
+
var stats = new _statsModifier.StatsModifier();
|
|
61
|
+
var shouldFocusCursorInsideQuery = true;
|
|
62
|
+
|
|
63
|
+
var deco = _prosemirrorView.Decoration.widget($cursor.pos, function (editorView, getDecorationPosition) {
|
|
64
|
+
var _popupMountRef$curren, _popupMountRef$curren2, _popupMountRef$curren3;
|
|
65
|
+
|
|
66
|
+
typeaheadComponent.setAttribute('id', decorationId);
|
|
67
|
+
typeaheadComponent.setAttribute('role', 'search');
|
|
68
|
+
typeaheadComponent.setAttribute('aria-label', "On ".concat(triggerHandler.id));
|
|
69
|
+
typeaheadComponent.dataset.typeAheadQuery = 'true';
|
|
70
|
+
typeaheadComponent.dataset.trigger = triggerHandler.trigger; // This line below seems weird,
|
|
71
|
+
// we need that cuz the clickAreaHelper
|
|
72
|
+
// will try to hijack any click event coming
|
|
73
|
+
// from the inside of the Editor
|
|
74
|
+
// packages/editor/editor-core/src/ui/Addon/click-area-helper.ts
|
|
75
|
+
|
|
76
|
+
typeaheadComponent.dataset.editorPopup = 'true';
|
|
77
|
+
typeaheadComponent.dataset.typeAhead = _constants.TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE;
|
|
78
|
+
typeaheadComponent.style.color = _colors.B400;
|
|
79
|
+
typeaheadComponent.style.backgroundColor = 'transparent';
|
|
80
|
+
|
|
81
|
+
var onUndoRedo = function onUndoRedo(inputType) {
|
|
82
|
+
if (!['historyUndo', 'historyRedo'].includes(inputType)) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
var hasReopenQuery = typeof reopenQuery === 'string' && reopenQuery.trim().length > 0;
|
|
87
|
+
var currentQuery = (0, _utils.getTypeAheadQuery)(editorView.state);
|
|
88
|
+
|
|
89
|
+
if (hasReopenQuery || currentQuery.length === 0) {
|
|
90
|
+
var command = inputType === 'historyUndo' ? _prosemirrorHistory.undo : _prosemirrorHistory.redo;
|
|
91
|
+
var _tr = editorView.state.tr;
|
|
92
|
+
|
|
93
|
+
var fakeDispatch = function fakeDispatch(customTr) {
|
|
94
|
+
_tr = customTr;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
var result = command(editorView.state, fakeDispatch);
|
|
98
|
+
|
|
99
|
+
if (result) {
|
|
100
|
+
(0, _closeTypeAhead.closeTypeAhead)(_tr);
|
|
101
|
+
editorView.dispatch(_tr);
|
|
102
|
+
editorView.focus();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return false;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
_reactDom.default.render( /*#__PURE__*/_react.default.createElement(_reactIntl.IntlProvider, {
|
|
112
|
+
locale: intl.locale || 'en',
|
|
113
|
+
messages: intl.messages,
|
|
114
|
+
formats: intl.formats
|
|
115
|
+
}, /*#__PURE__*/_react.default.createElement(_WrapperTypeAhead.WrapperTypeAhead, {
|
|
116
|
+
triggerHandler: triggerHandler,
|
|
117
|
+
editorView: editorView,
|
|
118
|
+
anchorElement: typeaheadComponent,
|
|
119
|
+
createAnalyticsEvent: createAnalyticsEvent,
|
|
120
|
+
inputMethod: inputMethod,
|
|
121
|
+
getDecorationPosition: getDecorationPosition,
|
|
122
|
+
shouldFocusCursorInsideQuery: shouldFocusCursorInsideQuery,
|
|
123
|
+
popupsMountPoint: (_popupMountRef$curren = popupMountRef.current) === null || _popupMountRef$curren === void 0 ? void 0 : _popupMountRef$curren.popupsMountPoint,
|
|
124
|
+
popupsBoundariesElement: (_popupMountRef$curren2 = popupMountRef.current) === null || _popupMountRef$curren2 === void 0 ? void 0 : _popupMountRef$curren2.popupsBoundariesElement,
|
|
125
|
+
popupsScrollableElement: (_popupMountRef$curren3 = popupMountRef.current) === null || _popupMountRef$curren3 === void 0 ? void 0 : _popupMountRef$curren3.popupsScrollableElement,
|
|
126
|
+
onUndoRedo: onUndoRedo,
|
|
127
|
+
reopenQuery: reopenQuery
|
|
128
|
+
})), typeaheadComponent);
|
|
129
|
+
|
|
130
|
+
shouldFocusCursorInsideQuery = false;
|
|
131
|
+
return typeaheadComponent;
|
|
132
|
+
}, {
|
|
133
|
+
isTypeAheadDecoration: true,
|
|
134
|
+
key: decorationId,
|
|
135
|
+
side: 0,
|
|
136
|
+
stopEvent: function stopEvent(e) {
|
|
137
|
+
var key = (0, _w3cKeyname.keyName)(e);
|
|
138
|
+
var sel = document.getSelection();
|
|
139
|
+
|
|
140
|
+
if ('ArrowLeft' === key && (sel === null || sel === void 0 ? void 0 : sel.anchorOffset) === 0) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return true;
|
|
145
|
+
},
|
|
146
|
+
ignoreSelection: false
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
decorationSet: _prosemirrorView.DecorationSet.create(tr.doc, [deco]),
|
|
151
|
+
decorationElement: typeaheadComponent,
|
|
152
|
+
stats: stats
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
var removeDecorations = function removeDecorations(decorationSet) {
|
|
157
|
+
if (!decorationSet || decorationSet === _prosemirrorView.DecorationSet.empty) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
var typeAheadDecorations = decorationSet.find(undefined, undefined, function (spec) {
|
|
162
|
+
return spec.isTypeAheadDecoration;
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
if (!typeAheadDecorations || typeAheadDecorations.length === 0) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
typeAheadDecorations.forEach(function (_ref3) {
|
|
170
|
+
var spec = _ref3.spec;
|
|
171
|
+
|
|
172
|
+
if (!spec.key) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
var decoElement = document.querySelector("#".concat(spec.key));
|
|
177
|
+
|
|
178
|
+
if (!decoElement) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
_reactDom.default.unmountComponentAtNode(decoElement);
|
|
183
|
+
});
|
|
184
|
+
return true;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
return {
|
|
188
|
+
createDecorations: createDecorations,
|
|
189
|
+
removeDecorations: removeDecorations
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
exports.factoryDecorations = factoryDecorations;
|
|
194
|
+
|
|
195
|
+
var isSelectionInsideTypeAhead = function isSelectionInsideTypeAhead(_ref4) {
|
|
196
|
+
var decorationSet = _ref4.decorationSet,
|
|
197
|
+
selection = _ref4.selection;
|
|
198
|
+
|
|
199
|
+
if (!decorationSet || decorationSet === _prosemirrorView.DecorationSet.empty) {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
var typeAheadDecorations = decorationSet.find(undefined, undefined, function (spec) {
|
|
204
|
+
return spec.isTypeAheadDecoration;
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
if (!typeAheadDecorations || typeAheadDecorations.length === 0) {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return typeAheadDecorations.some(function (dec) {
|
|
212
|
+
return dec.from === selection.from && dec.to === selection.to;
|
|
213
|
+
});
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
exports.isSelectionInsideTypeAhead = isSelectionInsideTypeAhead;
|
|
217
|
+
|
|
218
|
+
var findDecorationElement = function findDecorationElement(_ref5) {
|
|
219
|
+
var selection = _ref5.selection,
|
|
220
|
+
decorationSet = _ref5.decorationSet;
|
|
221
|
+
|
|
222
|
+
if (!decorationSet || decorationSet === _prosemirrorView.DecorationSet.empty || !(selection instanceof _prosemirrorState.TextSelection) || !selection.$cursor) {
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
var pos = selection.$cursor.pos;
|
|
227
|
+
var decoration = decorationSet.find(pos, pos, function (spec) {
|
|
228
|
+
return spec === null || spec === void 0 ? void 0 : spec.isTypeAheadDecoration;
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
if (!decoration || decoration.length !== 1) {
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return document.querySelector("#".concat(decoration[0].spec.key));
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
exports.findDecorationElement = findDecorationElement;
|