@atlaskit/editor-core 188.7.6 → 188.9.0

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.
Files changed (117) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/cjs/composable-editor/editor-internal.js +2 -2
  3. package/dist/cjs/create-editor/ReactEditorView.js +796 -8
  4. package/dist/cjs/labs/next/presets/universal.js +7 -4
  5. package/dist/cjs/plugins/index.js +0 -21
  6. package/dist/cjs/plugins/type-ahead/index.js +4 -372
  7. package/dist/cjs/plugins/type-ahead/plugin.js +382 -0
  8. package/dist/cjs/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.js +17 -8
  9. package/dist/cjs/version-wrapper.js +1 -1
  10. package/dist/es2019/composable-editor/editor-internal.js +1 -1
  11. package/dist/es2019/create-editor/ReactEditorView.js +753 -2
  12. package/dist/es2019/labs/next/presets/universal.js +4 -1
  13. package/dist/es2019/plugins/index.js +0 -3
  14. package/dist/es2019/plugins/type-ahead/index.js +2 -375
  15. package/dist/es2019/plugins/type-ahead/plugin.js +381 -0
  16. package/dist/es2019/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.js +17 -8
  17. package/dist/es2019/version-wrapper.js +1 -1
  18. package/dist/esm/composable-editor/editor-internal.js +1 -1
  19. package/dist/esm/create-editor/ReactEditorView.js +797 -8
  20. package/dist/esm/labs/next/presets/universal.js +4 -1
  21. package/dist/esm/plugins/index.js +0 -3
  22. package/dist/esm/plugins/type-ahead/index.js +2 -368
  23. package/dist/esm/plugins/type-ahead/plugin.js +374 -0
  24. package/dist/esm/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.js +17 -8
  25. package/dist/esm/version-wrapper.js +1 -1
  26. package/dist/types/create-editor/ReactEditorView.d.ts +119 -5
  27. package/dist/types/labs/next/presets/default.d.ts +30 -12
  28. package/dist/types/plugins/index.d.ts +0 -3
  29. package/dist/types/plugins/insert-block/types.d.ts +1 -1
  30. package/dist/types/plugins/type-ahead/index.d.ts +3 -14
  31. package/dist/types/plugins/type-ahead/plugin.d.ts +10 -0
  32. package/dist/types/plugins/type-ahead/types.d.ts +51 -6
  33. package/dist/types/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.d.ts +1 -1
  34. package/dist/types-ts4.5/create-editor/ReactEditorView.d.ts +119 -5
  35. package/dist/types-ts4.5/labs/next/presets/default.d.ts +30 -12
  36. package/dist/types-ts4.5/plugins/index.d.ts +0 -3
  37. package/dist/types-ts4.5/plugins/insert-block/types.d.ts +1 -1
  38. package/dist/types-ts4.5/plugins/type-ahead/index.d.ts +3 -14
  39. package/dist/types-ts4.5/plugins/type-ahead/plugin.d.ts +10 -0
  40. package/dist/types-ts4.5/plugins/type-ahead/types.d.ts +53 -6
  41. package/dist/types-ts4.5/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.d.ts +1 -1
  42. package/package.json +6 -4
  43. package/dist/cjs/create-editor/ReactEditorViewInternal.js +0 -812
  44. package/dist/cjs/create-editor/ReactEditorViewNext.js +0 -15
  45. package/dist/cjs/plugins/save-on-enter/index.js +0 -70
  46. package/dist/cjs/plugins/scroll-into-view/index.js +0 -55
  47. package/dist/cjs/plugins/status/actions.js +0 -158
  48. package/dist/cjs/plugins/status/analytics.js +0 -31
  49. package/dist/cjs/plugins/status/index.js +0 -143
  50. package/dist/cjs/plugins/status/keymap.js +0 -22
  51. package/dist/cjs/plugins/status/nodeviews/status.js +0 -58
  52. package/dist/cjs/plugins/status/plugin-key.js +0 -9
  53. package/dist/cjs/plugins/status/plugin.js +0 -133
  54. package/dist/cjs/plugins/status/types.js +0 -5
  55. package/dist/cjs/plugins/status/ui/statusPicker.js +0 -314
  56. package/dist/cjs/plugins/status/utils.js +0 -22
  57. package/dist/cjs/plugins/view-update-subscription/subscribe/type-ahead-updates.js +0 -33
  58. package/dist/es2019/create-editor/ReactEditorViewInternal.js +0 -753
  59. package/dist/es2019/create-editor/ReactEditorViewNext.js +0 -7
  60. package/dist/es2019/plugins/save-on-enter/index.js +0 -63
  61. package/dist/es2019/plugins/scroll-into-view/index.js +0 -44
  62. package/dist/es2019/plugins/status/actions.js +0 -144
  63. package/dist/es2019/plugins/status/analytics.js +0 -18
  64. package/dist/es2019/plugins/status/index.js +0 -135
  65. package/dist/es2019/plugins/status/keymap.js +0 -13
  66. package/dist/es2019/plugins/status/nodeviews/status.js +0 -60
  67. package/dist/es2019/plugins/status/plugin-key.js +0 -3
  68. package/dist/es2019/plugins/status/plugin.js +0 -113
  69. package/dist/es2019/plugins/status/types.js +0 -1
  70. package/dist/es2019/plugins/status/ui/statusPicker.js +0 -293
  71. package/dist/es2019/plugins/status/utils.js +0 -12
  72. package/dist/es2019/plugins/view-update-subscription/subscribe/type-ahead-updates.js +0 -28
  73. package/dist/esm/create-editor/ReactEditorViewInternal.js +0 -806
  74. package/dist/esm/create-editor/ReactEditorViewNext.js +0 -7
  75. package/dist/esm/plugins/save-on-enter/index.js +0 -63
  76. package/dist/esm/plugins/scroll-into-view/index.js +0 -50
  77. package/dist/esm/plugins/status/actions.js +0 -151
  78. package/dist/esm/plugins/status/analytics.js +0 -24
  79. package/dist/esm/plugins/status/index.js +0 -136
  80. package/dist/esm/plugins/status/keymap.js +0 -15
  81. package/dist/esm/plugins/status/nodeviews/status.js +0 -51
  82. package/dist/esm/plugins/status/plugin-key.js +0 -3
  83. package/dist/esm/plugins/status/plugin.js +0 -115
  84. package/dist/esm/plugins/status/types.js +0 -1
  85. package/dist/esm/plugins/status/ui/statusPicker.js +0 -308
  86. package/dist/esm/plugins/status/utils.js +0 -16
  87. package/dist/esm/plugins/view-update-subscription/subscribe/type-ahead-updates.js +0 -27
  88. package/dist/types/create-editor/ReactEditorViewInternal.d.ts +0 -119
  89. package/dist/types/create-editor/ReactEditorViewNext.d.ts +0 -8
  90. package/dist/types/plugins/save-on-enter/index.d.ts +0 -10
  91. package/dist/types/plugins/scroll-into-view/index.d.ts +0 -14
  92. package/dist/types/plugins/status/actions.d.ts +0 -16
  93. package/dist/types/plugins/status/analytics.d.ts +0 -4
  94. package/dist/types/plugins/status/index.d.ts +0 -15
  95. package/dist/types/plugins/status/keymap.d.ts +0 -3
  96. package/dist/types/plugins/status/nodeviews/status.d.ts +0 -25
  97. package/dist/types/plugins/status/plugin-key.d.ts +0 -4
  98. package/dist/types/plugins/status/plugin.d.ts +0 -7
  99. package/dist/types/plugins/status/types.d.ts +0 -18
  100. package/dist/types/plugins/status/ui/statusPicker.d.ts +0 -63
  101. package/dist/types/plugins/status/utils.d.ts +0 -5
  102. package/dist/types/plugins/view-update-subscription/subscribe/type-ahead-updates.d.ts +0 -9
  103. package/dist/types-ts4.5/create-editor/ReactEditorViewInternal.d.ts +0 -119
  104. package/dist/types-ts4.5/create-editor/ReactEditorViewNext.d.ts +0 -8
  105. package/dist/types-ts4.5/plugins/save-on-enter/index.d.ts +0 -10
  106. package/dist/types-ts4.5/plugins/scroll-into-view/index.d.ts +0 -14
  107. package/dist/types-ts4.5/plugins/status/actions.d.ts +0 -16
  108. package/dist/types-ts4.5/plugins/status/analytics.d.ts +0 -4
  109. package/dist/types-ts4.5/plugins/status/index.d.ts +0 -17
  110. package/dist/types-ts4.5/plugins/status/keymap.d.ts +0 -3
  111. package/dist/types-ts4.5/plugins/status/nodeviews/status.d.ts +0 -25
  112. package/dist/types-ts4.5/plugins/status/plugin-key.d.ts +0 -4
  113. package/dist/types-ts4.5/plugins/status/plugin.d.ts +0 -7
  114. package/dist/types-ts4.5/plugins/status/types.d.ts +0 -18
  115. package/dist/types-ts4.5/plugins/status/ui/statusPicker.d.ts +0 -63
  116. package/dist/types-ts4.5/plugins/status/utils.d.ts +0 -5
  117. package/dist/types-ts4.5/plugins/view-update-subscription/subscribe/type-ahead-updates.d.ts +0 -9
@@ -2,7 +2,8 @@ import _typeof from "@babel/runtime/helpers/typeof";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
- import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, extensionPlugin, fragmentMarkPlugin, insertBlockPlugin, jiraIssuePlugin, layoutPlugin, toolbarListsIndentationPlugin, macroPlugin, maxContentSizePlugin, mentionsPlugin, panelPlugin, placeholderTextPlugin, saveOnEnterPlugin, tasksAndDecisionsPlugin, textColorPlugin, statusPlugin, alignmentPlugin, indentationPlugin, customAutoformatPlugin, feedbackDialogPlugin, historyPlugin, expandPlugin, isExpandInsertionEnabled, scrollIntoViewPlugin, mobileDimensionsPlugin, findReplacePlugin, mobileSelectionPlugin, annotationPlugin, avatarGroupPlugin, viewUpdateSubscriptionPlugin, beforePrimaryToolbarPlugin, codeBidiWarningPlugin } from '../../../plugins';
5
+ import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, extensionPlugin, fragmentMarkPlugin, insertBlockPlugin, jiraIssuePlugin, layoutPlugin, toolbarListsIndentationPlugin, macroPlugin, maxContentSizePlugin, mentionsPlugin, panelPlugin, placeholderTextPlugin, tasksAndDecisionsPlugin, textColorPlugin, alignmentPlugin, indentationPlugin, customAutoformatPlugin, feedbackDialogPlugin, historyPlugin, expandPlugin, isExpandInsertionEnabled, mobileDimensionsPlugin, findReplacePlugin, mobileSelectionPlugin, annotationPlugin, avatarGroupPlugin, viewUpdateSubscriptionPlugin, beforePrimaryToolbarPlugin, codeBidiWarningPlugin } from '../../../plugins';
6
+ import { statusPlugin } from '@atlaskit/editor-plugin-status';
6
7
  import { datePlugin } from '../../../plugins/date';
7
8
  import { captionPlugin } from '@atlaskit/editor-plugin-caption';
8
9
  import { borderPlugin } from '@atlaskit/editor-plugin-border';
@@ -19,6 +20,8 @@ import { cardPlugin } from '@atlaskit/editor-plugin-card';
19
20
  import { tablesPlugin } from '@atlaskit/editor-plugin-table';
20
21
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
21
22
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
23
+ import { saveOnEnterPlugin } from '@atlaskit/editor-plugin-save-on-enter';
24
+ import { scrollIntoViewPlugin } from '@atlaskit/editor-plugin-scroll-into-view';
22
25
  import { isFullPage as fullPageCheck } from '../../../utils/is-full-page';
23
26
  import { getMediaFeatureFlag } from '@atlaskit/media-common';
24
27
  import { createDefaultPreset } from './default';
@@ -15,12 +15,10 @@ export { default as mentionsPlugin } from './mentions';
15
15
  export { default as panelPlugin } from './panel';
16
16
  export { default as pastePlugin } from './paste';
17
17
  export { default as placeholderTextPlugin } from './placeholder-text';
18
- export { default as saveOnEnterPlugin } from './save-on-enter';
19
18
  export { default as submitEditorPlugin } from './submit-editor';
20
19
  export { default as tasksAndDecisionsPlugin } from './tasks-and-decisions';
21
20
  export { default as textColorPlugin } from './text-color';
22
21
  export { default as typeAheadPlugin } from './type-ahead';
23
- export { default as statusPlugin } from './status';
24
22
  export { default as breakoutPlugin } from './breakout';
25
23
  export { default as alignmentPlugin } from './alignment';
26
24
  export { default as dataConsumerMarkPlugin } from './data-consumer';
@@ -32,7 +30,6 @@ export { default as customAutoformatPlugin } from './custom-autoformat';
32
30
  export { default as feedbackDialogPlugin } from './feedback-dialog';
33
31
  export { default as historyPlugin } from './history';
34
32
  export { default as expandPlugin, isExpandInsertionEnabled } from './expand';
35
- export { default as scrollIntoViewPlugin } from './scroll-into-view';
36
33
  export { default as mobileDimensionsPlugin } from './mobile-dimensions';
37
34
  export { default as findReplacePlugin } from './find-replace';
38
35
  export { default as mobileSelectionPlugin } from './mobile-selection';
@@ -1,369 +1,3 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- /**
3
- *
4
- * Revamped typeahead using decorations instead of the `typeAheadQuery` mark
5
- *
6
- * https://product-fabric.atlassian.net/wiki/spaces/E/pages/2992177582/Technical+TypeAhead+Data+Flow
7
- *
8
- *
9
- */
10
- import React from 'react';
11
- import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
12
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
13
- import { createPlugin } from './pm-plugins/main';
14
- import { createPlugin as createInsertItemPlugin } from './pm-plugins/insert-item-plugin';
15
- import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
16
- import { typeAheadQuery } from '@atlaskit/adf-schema';
17
- import { pluginKey as typeAheadPluginKey } from './pm-plugins/key';
18
- import { inputRulePlugin } from './pm-plugins/input-rules';
19
- import { TypeAheadPopup } from './ui/TypeAheadPopup';
20
- import { findHandler, getPluginState, isTypeAheadOpen, isTypeAheadAllowed, getTypeAheadQuery, getTypeAheadHandler } from './utils';
21
- import { useItemInsert } from './ui/hooks/use-item-insert';
22
- import { updateSelectedIndex } from './commands/update-selected-index';
23
- import { StatsModifier } from './stats-modifier';
24
- import { ACTION, ACTION_SUBJECT, INPUT_METHOD, EVENT_TYPE, fireAnalyticsEvent } from '@atlaskit/editor-common/analytics';
25
- import { openTypeAheadAtCursor } from './transforms/open-typeahead-at-cursor';
26
- import { closeTypeAhead } from './transforms/close-type-ahead';
27
- import { insertTypeAheadItem } from './commands/insert-type-ahead-item';
28
- var TypeAheadMenu = /*#__PURE__*/React.memo(function (_ref) {
29
- var _popupMountRef$curren, _popupMountRef$curren2, _popupMountRef$curren3;
30
- var editorView = _ref.editorView,
31
- popupMountRef = _ref.popupMountRef,
32
- typeAheadState = _ref.typeAheadState,
33
- fireAnalyticsCallback = _ref.fireAnalyticsCallback;
34
- var isOpen = typeAheadState.decorationSet.find().length > 0;
35
- var triggerHandler = typeAheadState.triggerHandler,
36
- items = typeAheadState.items,
37
- selectedIndex = typeAheadState.selectedIndex,
38
- decorationElement = typeAheadState.decorationElement,
39
- decorationSet = typeAheadState.decorationSet,
40
- query = typeAheadState.query;
41
- var _useItemInsert = useItemInsert(triggerHandler, editorView, items),
42
- _useItemInsert2 = _slicedToArray(_useItemInsert, 3),
43
- onItemInsert = _useItemInsert2[0],
44
- onTextInsert = _useItemInsert2[1],
45
- onItemMatch = _useItemInsert2[2];
46
- var setSelectedItem = React.useCallback(function (_ref2) {
47
- var nextIndex = _ref2.index;
48
- queueMicrotask(function () {
49
- updateSelectedIndex(nextIndex)(editorView.state, editorView.dispatch);
50
- });
51
- }, [editorView]);
52
- var insertItem = React.useCallback(function () {
53
- var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SelectItemMode.SELECTED;
54
- var index = arguments.length > 1 ? arguments[1] : undefined;
55
- queueMicrotask(function () {
56
- onItemInsert({
57
- mode: mode,
58
- index: index,
59
- query: query
60
- });
61
- });
62
- }, [onItemInsert, query]);
63
- var cancel = React.useCallback(function (_ref3) {
64
- var setSelectionAt = _ref3.setSelectionAt,
65
- addPrefixTrigger = _ref3.addPrefixTrigger,
66
- forceFocusOnEditor = _ref3.forceFocusOnEditor;
67
- var fullQuery = addPrefixTrigger ? "".concat(triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.trigger).concat(query) : query;
68
- onTextInsert({
69
- forceFocusOnEditor: forceFocusOnEditor,
70
- setSelectionAt: setSelectionAt,
71
- text: fullQuery
72
- });
73
- }, [triggerHandler, onTextInsert, query]);
74
- React.useEffect(function () {
75
- if (!isOpen || !query) {
76
- return;
77
- }
78
- var isLastCharSpace = query[query.length - 1] === ' ';
79
- if (!isLastCharSpace) {
80
- return;
81
- }
82
- var result = onItemMatch({
83
- mode: SelectItemMode.SPACE,
84
- query: query.trim()
85
- });
86
- if (!result) {
87
- return;
88
- }
89
- }, [isOpen, query, onItemMatch]);
90
- if (!isOpen || !triggerHandler || !(decorationElement instanceof HTMLElement) || items.length === 0) {
91
- return null;
92
- }
93
- return /*#__PURE__*/React.createElement(TypeAheadPopup, {
94
- editorView: editorView,
95
- popupsMountPoint: (_popupMountRef$curren = popupMountRef.current) === null || _popupMountRef$curren === void 0 ? void 0 : _popupMountRef$curren.popupsMountPoint,
96
- popupsBoundariesElement: (_popupMountRef$curren2 = popupMountRef.current) === null || _popupMountRef$curren2 === void 0 ? void 0 : _popupMountRef$curren2.popupsBoundariesElement,
97
- popupsScrollableElement: (_popupMountRef$curren3 = popupMountRef.current) === null || _popupMountRef$curren3 === void 0 ? void 0 : _popupMountRef$curren3.popupsScrollableElement,
98
- anchorElement: decorationElement,
99
- triggerHandler: triggerHandler,
100
- fireAnalyticsCallback: fireAnalyticsCallback,
101
- items: items,
102
- selectedIndex: selectedIndex,
103
- setSelectedItem: setSelectedItem,
104
- onItemInsert: insertItem,
105
- decorationSet: decorationSet,
106
- isEmptyQuery: !query,
107
- cancel: cancel
108
- });
109
- });
110
- var createOpenAtTransaction = function createOpenAtTransaction(editorAnalyticsAPI) {
111
- return function (props) {
112
- return function (tr) {
113
- var triggerHandler = props.triggerHandler,
114
- inputMethod = props.inputMethod;
115
- openTypeAheadAtCursor({
116
- triggerHandler: triggerHandler,
117
- inputMethod: inputMethod
118
- })({
119
- tr: tr
120
- });
121
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
122
- action: ACTION.INVOKED,
123
- actionSubject: ACTION_SUBJECT.TYPEAHEAD,
124
- actionSubjectId: triggerHandler.id,
125
- attributes: {
126
- inputMethod: inputMethod
127
- },
128
- eventType: EVENT_TYPE.UI
129
- })(tr);
130
- return true;
131
- };
132
- };
133
- };
134
- var createOpenTypeAhead = function createOpenTypeAhead(editorViewRef, editorAnalyticsAPI) {
135
- return function (props) {
136
- if (!editorViewRef.current) {
137
- return false;
138
- }
139
- var view = editorViewRef.current;
140
- var tr = view.state.tr;
141
- createOpenAtTransaction(editorAnalyticsAPI)(props)(tr);
142
- view.dispatch(tr);
143
- return true;
144
- };
145
- };
146
- var createInsertTypeAheadItem = function createInsertTypeAheadItem(editorViewRef) {
147
- return function (props) {
148
- if (!editorViewRef.current) {
149
- return false;
150
- }
151
- var view = editorViewRef.current;
152
- var triggerHandler = props.triggerHandler,
153
- contentItem = props.contentItem,
154
- query = props.query,
155
- sourceListItem = props.sourceListItem,
156
- mode = props.mode;
157
- insertTypeAheadItem(view)({
158
- handler: triggerHandler,
159
- item: contentItem,
160
- mode: mode || SelectItemMode.SELECTED,
161
- query: query,
162
- sourceListItem: sourceListItem
163
- });
164
- return true;
165
- };
166
- };
167
- var createFindHandlerByTrigger = function createFindHandlerByTrigger(editorViewRef) {
168
- return function (trigger) {
169
- if (!editorViewRef.current) {
170
- return null;
171
- }
172
- var view = editorViewRef.current;
173
- return findHandler(trigger, view.state);
174
- };
175
- };
176
- var createCloseTypeAhead = function createCloseTypeAhead(editorViewRef) {
177
- return function (options) {
178
- if (!editorViewRef.current) {
179
- return false;
180
- }
181
- var view = editorViewRef.current;
182
- var currentQuery = getTypeAheadQuery(view.state) || '';
183
- var state = view.state;
184
- var tr = state.tr;
185
- if (options.attachCommand) {
186
- var fakeDispatch = function fakeDispatch(customTr) {
187
- tr = customTr;
188
- };
189
- options.attachCommand(state, fakeDispatch);
190
- }
191
- closeTypeAhead(tr);
192
- if (options.insertCurrentQueryAsRawText && currentQuery && currentQuery.length > 0) {
193
- var handler = getTypeAheadHandler(state);
194
- if (!handler) {
195
- return false;
196
- }
197
- var text = handler.trigger.concat(currentQuery);
198
- tr.replaceSelectionWith(state.schema.text(text));
199
- }
200
- view.dispatch(tr);
201
- if (!view.hasFocus()) {
202
- view.focus();
203
- }
204
- return true;
205
- };
206
- };
207
-
208
- /**
209
- *
210
- * Revamped typeahead using decorations instead of the `typeAheadQuery` mark
211
- *
212
- * https://product-fabric.atlassian.net/wiki/spaces/E/pages/2992177582/Technical+TypeAhead+Data+Flow
213
- *
214
- *
215
- */
216
- var typeAheadPlugin = function typeAheadPlugin(_ref4) {
217
- var _api$analytics, _api$analytics2;
218
- var options = _ref4.config,
219
- api = _ref4.api;
220
- var fireAnalyticsCallback = fireAnalyticsEvent(options === null || options === void 0 ? void 0 : options.createAnalyticsEvent);
221
- var popupMountRef = {
222
- current: null
223
- };
224
- var editorViewRef = {
225
- current: null
226
- };
227
- return {
228
- name: 'typeAhead',
229
- marks: function marks() {
230
- // We need to keep this to make sure
231
- // All documents with typeahead marks will be loaded normally
232
- return [{
233
- name: 'typeAheadQuery',
234
- mark: typeAheadQuery
235
- }];
236
- },
237
- pmPlugins: function pmPlugins() {
238
- var typeAhead = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
239
- return [{
240
- name: 'typeAhead',
241
- plugin: function plugin(_ref5) {
242
- var dispatch = _ref5.dispatch,
243
- getIntl = _ref5.getIntl;
244
- return createPlugin({
245
- getIntl: getIntl,
246
- popupMountRef: popupMountRef,
247
- reactDispatch: dispatch,
248
- typeAheadHandlers: typeAhead,
249
- createAnalyticsEvent: options === null || options === void 0 ? void 0 : options.createAnalyticsEvent
250
- });
251
- }
252
- }, {
253
- name: 'typeAheadEditorViewRef',
254
- plugin: function plugin() {
255
- return new SafePlugin({
256
- view: function view(_view) {
257
- editorViewRef.current = _view;
258
- return {
259
- destroy: function destroy() {
260
- editorViewRef.current = null;
261
- }
262
- };
263
- }
264
- });
265
- }
266
- }, {
267
- name: 'typeAheadInsertItem',
268
- plugin: createInsertItemPlugin
269
- }, {
270
- name: 'typeAheadInputRule',
271
- plugin: function plugin(_ref6) {
272
- var schema = _ref6.schema,
273
- featureFlags = _ref6.featureFlags;
274
- return inputRulePlugin(schema, typeAhead, featureFlags);
275
- }
276
- }];
277
- },
278
- getSharedState: function getSharedState(editorState) {
279
- if (!editorState) {
280
- return {
281
- query: ''
282
- };
283
- }
284
- return {
285
- query: getTypeAheadQuery(editorState) || ''
286
- };
287
- },
288
- actions: {
289
- isOpen: isTypeAheadOpen,
290
- isAllowed: isTypeAheadAllowed,
291
- open: createOpenTypeAhead(editorViewRef, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions),
292
- openAtTransaction: createOpenAtTransaction(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions),
293
- findHandlerByTrigger: createFindHandlerByTrigger(editorViewRef),
294
- insert: createInsertTypeAheadItem(editorViewRef),
295
- close: createCloseTypeAhead(editorViewRef)
296
- },
297
- contentComponent: function contentComponent(_ref7) {
298
- var editorView = _ref7.editorView,
299
- containerElement = _ref7.containerElement,
300
- popupsMountPoint = _ref7.popupsMountPoint,
301
- popupsBoundariesElement = _ref7.popupsBoundariesElement,
302
- popupsScrollableElement = _ref7.popupsScrollableElement,
303
- wrapperElement = _ref7.wrapperElement;
304
- popupMountRef.current = {
305
- popupsMountPoint: popupsMountPoint || wrapperElement || undefined,
306
- popupsBoundariesElement: popupsBoundariesElement,
307
- popupsScrollableElement: popupsScrollableElement || containerElement || undefined
308
- };
309
- return /*#__PURE__*/React.createElement(WithPluginState, {
310
- plugins: {
311
- typeAheadState: typeAheadPluginKey
312
- },
313
- render: function render(_ref8) {
314
- var typeAheadState = _ref8.typeAheadState;
315
- if (!typeAheadState) {
316
- return null;
317
- }
318
- return /*#__PURE__*/React.createElement(TypeAheadMenu, {
319
- editorView: editorView,
320
- popupMountRef: popupMountRef,
321
- typeAheadState: typeAheadState,
322
- fireAnalyticsCallback: fireAnalyticsCallback
323
- });
324
- }
325
- });
326
- },
327
- onEditorViewStateUpdated: function onEditorViewStateUpdated(_ref9) {
328
- var originalTransaction = _ref9.originalTransaction,
329
- oldEditorState = _ref9.oldEditorState,
330
- newEditorState = _ref9.newEditorState;
331
- var oldPluginState = getPluginState(oldEditorState);
332
- var newPluginState = getPluginState(newEditorState);
333
- if (!oldPluginState || !newPluginState) {
334
- return;
335
- }
336
- var oldTriggerHandler = oldPluginState.triggerHandler;
337
- var newTriggerHandler = newPluginState.triggerHandler;
338
- var isANewHandler = oldTriggerHandler !== newTriggerHandler;
339
- if (oldTriggerHandler !== null && oldTriggerHandler !== void 0 && oldTriggerHandler.dismiss && isANewHandler) {
340
- var typeAheadMessage = originalTransaction.getMeta(typeAheadPluginKey);
341
- var wasItemInserted = typeAheadMessage && typeAheadMessage.action === 'INSERT_RAW_QUERY';
342
- oldTriggerHandler.dismiss({
343
- editorState: newEditorState,
344
- query: oldPluginState.query,
345
- stats: (oldPluginState.stats || new StatsModifier()).serialize(),
346
- wasItemInserted: wasItemInserted
347
- });
348
- }
349
- if (newTriggerHandler !== null && newTriggerHandler !== void 0 && newTriggerHandler.onOpen && isANewHandler) {
350
- newTriggerHandler.onOpen(newEditorState);
351
- }
352
- if (newTriggerHandler && isANewHandler && options !== null && options !== void 0 && options.createAnalyticsEvent) {
353
- fireAnalyticsCallback({
354
- payload: {
355
- action: ACTION.INVOKED,
356
- actionSubject: ACTION_SUBJECT.TYPEAHEAD,
357
- actionSubjectId: newTriggerHandler.id || 'not_set',
358
- attributes: {
359
- inputMethod: newPluginState.inputMethod || INPUT_METHOD.KEYBOARD
360
- },
361
- eventType: EVENT_TYPE.UI
362
- }
363
- });
364
- }
365
- }
366
- };
367
- };
1
+ import { typeAheadPlugin } from './plugin';
368
2
  export default typeAheadPlugin;
369
- export { typeAheadPluginKey };
3
+ export { typeAheadPlugin };