@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.
- package/CHANGELOG.md +23 -0
- package/dist/cjs/composable-editor/editor-internal.js +2 -2
- package/dist/cjs/create-editor/ReactEditorView.js +796 -8
- package/dist/cjs/labs/next/presets/universal.js +7 -4
- package/dist/cjs/plugins/index.js +0 -21
- package/dist/cjs/plugins/type-ahead/index.js +4 -372
- package/dist/cjs/plugins/type-ahead/plugin.js +382 -0
- package/dist/cjs/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.js +17 -8
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/composable-editor/editor-internal.js +1 -1
- package/dist/es2019/create-editor/ReactEditorView.js +753 -2
- package/dist/es2019/labs/next/presets/universal.js +4 -1
- package/dist/es2019/plugins/index.js +0 -3
- package/dist/es2019/plugins/type-ahead/index.js +2 -375
- package/dist/es2019/plugins/type-ahead/plugin.js +381 -0
- package/dist/es2019/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.js +17 -8
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/composable-editor/editor-internal.js +1 -1
- package/dist/esm/create-editor/ReactEditorView.js +797 -8
- package/dist/esm/labs/next/presets/universal.js +4 -1
- package/dist/esm/plugins/index.js +0 -3
- package/dist/esm/plugins/type-ahead/index.js +2 -368
- package/dist/esm/plugins/type-ahead/plugin.js +374 -0
- package/dist/esm/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.js +17 -8
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/create-editor/ReactEditorView.d.ts +119 -5
- package/dist/types/labs/next/presets/default.d.ts +30 -12
- package/dist/types/plugins/index.d.ts +0 -3
- package/dist/types/plugins/insert-block/types.d.ts +1 -1
- package/dist/types/plugins/type-ahead/index.d.ts +3 -14
- package/dist/types/plugins/type-ahead/plugin.d.ts +10 -0
- package/dist/types/plugins/type-ahead/types.d.ts +51 -6
- package/dist/types/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.d.ts +1 -1
- package/dist/types-ts4.5/create-editor/ReactEditorView.d.ts +119 -5
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +30 -12
- package/dist/types-ts4.5/plugins/index.d.ts +0 -3
- package/dist/types-ts4.5/plugins/insert-block/types.d.ts +1 -1
- package/dist/types-ts4.5/plugins/type-ahead/index.d.ts +3 -14
- package/dist/types-ts4.5/plugins/type-ahead/plugin.d.ts +10 -0
- package/dist/types-ts4.5/plugins/type-ahead/types.d.ts +53 -6
- package/dist/types-ts4.5/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.d.ts +1 -1
- package/package.json +6 -4
- package/dist/cjs/create-editor/ReactEditorViewInternal.js +0 -812
- package/dist/cjs/create-editor/ReactEditorViewNext.js +0 -15
- package/dist/cjs/plugins/save-on-enter/index.js +0 -70
- package/dist/cjs/plugins/scroll-into-view/index.js +0 -55
- package/dist/cjs/plugins/status/actions.js +0 -158
- package/dist/cjs/plugins/status/analytics.js +0 -31
- package/dist/cjs/plugins/status/index.js +0 -143
- package/dist/cjs/plugins/status/keymap.js +0 -22
- package/dist/cjs/plugins/status/nodeviews/status.js +0 -58
- package/dist/cjs/plugins/status/plugin-key.js +0 -9
- package/dist/cjs/plugins/status/plugin.js +0 -133
- package/dist/cjs/plugins/status/types.js +0 -5
- package/dist/cjs/plugins/status/ui/statusPicker.js +0 -314
- package/dist/cjs/plugins/status/utils.js +0 -22
- package/dist/cjs/plugins/view-update-subscription/subscribe/type-ahead-updates.js +0 -33
- package/dist/es2019/create-editor/ReactEditorViewInternal.js +0 -753
- package/dist/es2019/create-editor/ReactEditorViewNext.js +0 -7
- package/dist/es2019/plugins/save-on-enter/index.js +0 -63
- package/dist/es2019/plugins/scroll-into-view/index.js +0 -44
- package/dist/es2019/plugins/status/actions.js +0 -144
- package/dist/es2019/plugins/status/analytics.js +0 -18
- package/dist/es2019/plugins/status/index.js +0 -135
- package/dist/es2019/plugins/status/keymap.js +0 -13
- package/dist/es2019/plugins/status/nodeviews/status.js +0 -60
- package/dist/es2019/plugins/status/plugin-key.js +0 -3
- package/dist/es2019/plugins/status/plugin.js +0 -113
- package/dist/es2019/plugins/status/types.js +0 -1
- package/dist/es2019/plugins/status/ui/statusPicker.js +0 -293
- package/dist/es2019/plugins/status/utils.js +0 -12
- package/dist/es2019/plugins/view-update-subscription/subscribe/type-ahead-updates.js +0 -28
- package/dist/esm/create-editor/ReactEditorViewInternal.js +0 -806
- package/dist/esm/create-editor/ReactEditorViewNext.js +0 -7
- package/dist/esm/plugins/save-on-enter/index.js +0 -63
- package/dist/esm/plugins/scroll-into-view/index.js +0 -50
- package/dist/esm/plugins/status/actions.js +0 -151
- package/dist/esm/plugins/status/analytics.js +0 -24
- package/dist/esm/plugins/status/index.js +0 -136
- package/dist/esm/plugins/status/keymap.js +0 -15
- package/dist/esm/plugins/status/nodeviews/status.js +0 -51
- package/dist/esm/plugins/status/plugin-key.js +0 -3
- package/dist/esm/plugins/status/plugin.js +0 -115
- package/dist/esm/plugins/status/types.js +0 -1
- package/dist/esm/plugins/status/ui/statusPicker.js +0 -308
- package/dist/esm/plugins/status/utils.js +0 -16
- package/dist/esm/plugins/view-update-subscription/subscribe/type-ahead-updates.js +0 -27
- package/dist/types/create-editor/ReactEditorViewInternal.d.ts +0 -119
- package/dist/types/create-editor/ReactEditorViewNext.d.ts +0 -8
- package/dist/types/plugins/save-on-enter/index.d.ts +0 -10
- package/dist/types/plugins/scroll-into-view/index.d.ts +0 -14
- package/dist/types/plugins/status/actions.d.ts +0 -16
- package/dist/types/plugins/status/analytics.d.ts +0 -4
- package/dist/types/plugins/status/index.d.ts +0 -15
- package/dist/types/plugins/status/keymap.d.ts +0 -3
- package/dist/types/plugins/status/nodeviews/status.d.ts +0 -25
- package/dist/types/plugins/status/plugin-key.d.ts +0 -4
- package/dist/types/plugins/status/plugin.d.ts +0 -7
- package/dist/types/plugins/status/types.d.ts +0 -18
- package/dist/types/plugins/status/ui/statusPicker.d.ts +0 -63
- package/dist/types/plugins/status/utils.d.ts +0 -5
- package/dist/types/plugins/view-update-subscription/subscribe/type-ahead-updates.d.ts +0 -9
- package/dist/types-ts4.5/create-editor/ReactEditorViewInternal.d.ts +0 -119
- package/dist/types-ts4.5/create-editor/ReactEditorViewNext.d.ts +0 -8
- package/dist/types-ts4.5/plugins/save-on-enter/index.d.ts +0 -10
- package/dist/types-ts4.5/plugins/scroll-into-view/index.d.ts +0 -14
- package/dist/types-ts4.5/plugins/status/actions.d.ts +0 -16
- package/dist/types-ts4.5/plugins/status/analytics.d.ts +0 -4
- package/dist/types-ts4.5/plugins/status/index.d.ts +0 -17
- package/dist/types-ts4.5/plugins/status/keymap.d.ts +0 -3
- package/dist/types-ts4.5/plugins/status/nodeviews/status.d.ts +0 -25
- package/dist/types-ts4.5/plugins/status/plugin-key.d.ts +0 -4
- package/dist/types-ts4.5/plugins/status/plugin.d.ts +0 -7
- package/dist/types-ts4.5/plugins/status/types.d.ts +0 -18
- package/dist/types-ts4.5/plugins/status/ui/statusPicker.d.ts +0 -63
- package/dist/types-ts4.5/plugins/status/utils.d.ts +0 -5
- package/dist/types-ts4.5/plugins/view-update-subscription/subscribe/type-ahead-updates.d.ts +0 -9
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.typeAheadPlugin = void 0;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _adfSchema = require("@atlaskit/adf-schema");
|
|
11
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
12
|
+
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
13
|
+
var _typeAhead = require("@atlaskit/editor-common/type-ahead");
|
|
14
|
+
var _withPluginState = require("@atlaskit/editor-common/with-plugin-state");
|
|
15
|
+
var _insertTypeAheadItem = require("./commands/insert-type-ahead-item");
|
|
16
|
+
var _updateSelectedIndex = require("./commands/update-selected-index");
|
|
17
|
+
var _inputRules = require("./pm-plugins/input-rules");
|
|
18
|
+
var _insertItemPlugin = require("./pm-plugins/insert-item-plugin");
|
|
19
|
+
var _key = require("./pm-plugins/key");
|
|
20
|
+
var _main = require("./pm-plugins/main");
|
|
21
|
+
var _statsModifier = require("./stats-modifier");
|
|
22
|
+
var _closeTypeAhead = require("./transforms/close-type-ahead");
|
|
23
|
+
var _openTypeaheadAtCursor = require("./transforms/open-typeahead-at-cursor");
|
|
24
|
+
var _useItemInsert3 = require("./ui/hooks/use-item-insert");
|
|
25
|
+
var _TypeAheadPopup = require("./ui/TypeAheadPopup");
|
|
26
|
+
var _utils = require("./utils");
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* Revamped typeahead using decorations instead of the `typeAheadQuery` mark
|
|
30
|
+
*
|
|
31
|
+
* https://product-fabric.atlassian.net/wiki/spaces/E/pages/2992177582/Technical+TypeAhead+Data+Flow
|
|
32
|
+
*
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
var TypeAheadMenu = /*#__PURE__*/_react.default.memo(function (_ref) {
|
|
37
|
+
var _popupMountRef$curren, _popupMountRef$curren2, _popupMountRef$curren3;
|
|
38
|
+
var editorView = _ref.editorView,
|
|
39
|
+
popupMountRef = _ref.popupMountRef,
|
|
40
|
+
typeAheadState = _ref.typeAheadState,
|
|
41
|
+
fireAnalyticsCallback = _ref.fireAnalyticsCallback;
|
|
42
|
+
var isOpen = typeAheadState.decorationSet.find().length > 0;
|
|
43
|
+
var triggerHandler = typeAheadState.triggerHandler,
|
|
44
|
+
items = typeAheadState.items,
|
|
45
|
+
selectedIndex = typeAheadState.selectedIndex,
|
|
46
|
+
decorationElement = typeAheadState.decorationElement,
|
|
47
|
+
decorationSet = typeAheadState.decorationSet,
|
|
48
|
+
query = typeAheadState.query;
|
|
49
|
+
var _useItemInsert = (0, _useItemInsert3.useItemInsert)(triggerHandler, editorView, items),
|
|
50
|
+
_useItemInsert2 = (0, _slicedToArray2.default)(_useItemInsert, 3),
|
|
51
|
+
onItemInsert = _useItemInsert2[0],
|
|
52
|
+
onTextInsert = _useItemInsert2[1],
|
|
53
|
+
onItemMatch = _useItemInsert2[2];
|
|
54
|
+
var setSelectedItem = _react.default.useCallback(function (_ref2) {
|
|
55
|
+
var nextIndex = _ref2.index;
|
|
56
|
+
queueMicrotask(function () {
|
|
57
|
+
(0, _updateSelectedIndex.updateSelectedIndex)(nextIndex)(editorView.state, editorView.dispatch);
|
|
58
|
+
});
|
|
59
|
+
}, [editorView]);
|
|
60
|
+
var insertItem = _react.default.useCallback(function () {
|
|
61
|
+
var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _typeAhead.SelectItemMode.SELECTED;
|
|
62
|
+
var index = arguments.length > 1 ? arguments[1] : undefined;
|
|
63
|
+
queueMicrotask(function () {
|
|
64
|
+
onItemInsert({
|
|
65
|
+
mode: mode,
|
|
66
|
+
index: index,
|
|
67
|
+
query: query
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}, [onItemInsert, query]);
|
|
71
|
+
var cancel = _react.default.useCallback(function (_ref3) {
|
|
72
|
+
var setSelectionAt = _ref3.setSelectionAt,
|
|
73
|
+
addPrefixTrigger = _ref3.addPrefixTrigger,
|
|
74
|
+
forceFocusOnEditor = _ref3.forceFocusOnEditor;
|
|
75
|
+
var fullQuery = addPrefixTrigger ? "".concat(triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.trigger).concat(query) : query;
|
|
76
|
+
onTextInsert({
|
|
77
|
+
forceFocusOnEditor: forceFocusOnEditor,
|
|
78
|
+
setSelectionAt: setSelectionAt,
|
|
79
|
+
text: fullQuery
|
|
80
|
+
});
|
|
81
|
+
}, [triggerHandler, onTextInsert, query]);
|
|
82
|
+
_react.default.useEffect(function () {
|
|
83
|
+
if (!isOpen || !query) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
var isLastCharSpace = query[query.length - 1] === ' ';
|
|
87
|
+
if (!isLastCharSpace) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
var result = onItemMatch({
|
|
91
|
+
mode: _typeAhead.SelectItemMode.SPACE,
|
|
92
|
+
query: query.trim()
|
|
93
|
+
});
|
|
94
|
+
if (!result) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
}, [isOpen, query, onItemMatch]);
|
|
98
|
+
if (!isOpen || !triggerHandler || !(decorationElement instanceof HTMLElement) || items.length === 0) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
return /*#__PURE__*/_react.default.createElement(_TypeAheadPopup.TypeAheadPopup, {
|
|
102
|
+
editorView: editorView,
|
|
103
|
+
popupsMountPoint: (_popupMountRef$curren = popupMountRef.current) === null || _popupMountRef$curren === void 0 ? void 0 : _popupMountRef$curren.popupsMountPoint,
|
|
104
|
+
popupsBoundariesElement: (_popupMountRef$curren2 = popupMountRef.current) === null || _popupMountRef$curren2 === void 0 ? void 0 : _popupMountRef$curren2.popupsBoundariesElement,
|
|
105
|
+
popupsScrollableElement: (_popupMountRef$curren3 = popupMountRef.current) === null || _popupMountRef$curren3 === void 0 ? void 0 : _popupMountRef$curren3.popupsScrollableElement,
|
|
106
|
+
anchorElement: decorationElement,
|
|
107
|
+
triggerHandler: triggerHandler,
|
|
108
|
+
fireAnalyticsCallback: fireAnalyticsCallback,
|
|
109
|
+
items: items,
|
|
110
|
+
selectedIndex: selectedIndex,
|
|
111
|
+
setSelectedItem: setSelectedItem,
|
|
112
|
+
onItemInsert: insertItem,
|
|
113
|
+
decorationSet: decorationSet,
|
|
114
|
+
isEmptyQuery: !query,
|
|
115
|
+
cancel: cancel
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
var createOpenAtTransaction = function createOpenAtTransaction(editorAnalyticsAPI) {
|
|
119
|
+
return function (props) {
|
|
120
|
+
return function (tr) {
|
|
121
|
+
var triggerHandler = props.triggerHandler,
|
|
122
|
+
inputMethod = props.inputMethod;
|
|
123
|
+
(0, _openTypeaheadAtCursor.openTypeAheadAtCursor)({
|
|
124
|
+
triggerHandler: triggerHandler,
|
|
125
|
+
inputMethod: inputMethod
|
|
126
|
+
})({
|
|
127
|
+
tr: tr
|
|
128
|
+
});
|
|
129
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
130
|
+
action: _analytics.ACTION.INVOKED,
|
|
131
|
+
actionSubject: _analytics.ACTION_SUBJECT.TYPEAHEAD,
|
|
132
|
+
actionSubjectId: triggerHandler.id,
|
|
133
|
+
attributes: {
|
|
134
|
+
inputMethod: inputMethod
|
|
135
|
+
},
|
|
136
|
+
eventType: _analytics.EVENT_TYPE.UI
|
|
137
|
+
})(tr);
|
|
138
|
+
return true;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
var createOpenTypeAhead = function createOpenTypeAhead(editorViewRef, editorAnalyticsAPI) {
|
|
143
|
+
return function (props) {
|
|
144
|
+
if (!editorViewRef.current) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
var view = editorViewRef.current;
|
|
148
|
+
var tr = view.state.tr;
|
|
149
|
+
createOpenAtTransaction(editorAnalyticsAPI)(props)(tr);
|
|
150
|
+
view.dispatch(tr);
|
|
151
|
+
return true;
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
var createInsertTypeAheadItem = function createInsertTypeAheadItem(editorViewRef) {
|
|
155
|
+
return function (props) {
|
|
156
|
+
if (!editorViewRef.current) {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
var view = editorViewRef.current;
|
|
160
|
+
var triggerHandler = props.triggerHandler,
|
|
161
|
+
contentItem = props.contentItem,
|
|
162
|
+
query = props.query,
|
|
163
|
+
sourceListItem = props.sourceListItem,
|
|
164
|
+
mode = props.mode;
|
|
165
|
+
(0, _insertTypeAheadItem.insertTypeAheadItem)(view)({
|
|
166
|
+
handler: triggerHandler,
|
|
167
|
+
item: contentItem,
|
|
168
|
+
mode: mode || _typeAhead.SelectItemMode.SELECTED,
|
|
169
|
+
query: query,
|
|
170
|
+
sourceListItem: sourceListItem
|
|
171
|
+
});
|
|
172
|
+
return true;
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
var createFindHandlerByTrigger = function createFindHandlerByTrigger(editorViewRef) {
|
|
176
|
+
return function (trigger) {
|
|
177
|
+
if (!editorViewRef.current) {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
var view = editorViewRef.current;
|
|
181
|
+
return (0, _utils.findHandler)(trigger, view.state);
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
var createCloseTypeAhead = function createCloseTypeAhead(editorViewRef) {
|
|
185
|
+
return function (options) {
|
|
186
|
+
if (!editorViewRef.current) {
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
var view = editorViewRef.current;
|
|
190
|
+
var currentQuery = (0, _utils.getTypeAheadQuery)(view.state) || '';
|
|
191
|
+
var state = view.state;
|
|
192
|
+
var tr = state.tr;
|
|
193
|
+
if (options.attachCommand) {
|
|
194
|
+
var fakeDispatch = function fakeDispatch(customTr) {
|
|
195
|
+
tr = customTr;
|
|
196
|
+
};
|
|
197
|
+
options.attachCommand(state, fakeDispatch);
|
|
198
|
+
}
|
|
199
|
+
(0, _closeTypeAhead.closeTypeAhead)(tr);
|
|
200
|
+
if (options.insertCurrentQueryAsRawText && currentQuery && currentQuery.length > 0) {
|
|
201
|
+
var handler = (0, _utils.getTypeAheadHandler)(state);
|
|
202
|
+
if (!handler) {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
var text = handler.trigger.concat(currentQuery);
|
|
206
|
+
tr.replaceSelectionWith(state.schema.text(text));
|
|
207
|
+
}
|
|
208
|
+
view.dispatch(tr);
|
|
209
|
+
if (!view.hasFocus()) {
|
|
210
|
+
view.focus();
|
|
211
|
+
}
|
|
212
|
+
return true;
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
*
|
|
218
|
+
* Revamped typeahead using decorations instead of the `typeAheadQuery` mark
|
|
219
|
+
*
|
|
220
|
+
* https://product-fabric.atlassian.net/wiki/spaces/E/pages/2992177582/Technical+TypeAhead+Data+Flow
|
|
221
|
+
*
|
|
222
|
+
*
|
|
223
|
+
*/
|
|
224
|
+
var typeAheadPlugin = exports.typeAheadPlugin = function typeAheadPlugin(_ref4) {
|
|
225
|
+
var _api$analytics, _api$analytics2;
|
|
226
|
+
var options = _ref4.config,
|
|
227
|
+
api = _ref4.api;
|
|
228
|
+
var fireAnalyticsCallback = (0, _analytics.fireAnalyticsEvent)(options === null || options === void 0 ? void 0 : options.createAnalyticsEvent);
|
|
229
|
+
var popupMountRef = {
|
|
230
|
+
current: null
|
|
231
|
+
};
|
|
232
|
+
var editorViewRef = {
|
|
233
|
+
current: null
|
|
234
|
+
};
|
|
235
|
+
return {
|
|
236
|
+
name: 'typeAhead',
|
|
237
|
+
marks: function marks() {
|
|
238
|
+
// We need to keep this to make sure
|
|
239
|
+
// All documents with typeahead marks will be loaded normally
|
|
240
|
+
return [{
|
|
241
|
+
name: 'typeAheadQuery',
|
|
242
|
+
mark: _adfSchema.typeAheadQuery
|
|
243
|
+
}];
|
|
244
|
+
},
|
|
245
|
+
pmPlugins: function pmPlugins() {
|
|
246
|
+
var typeAhead = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
247
|
+
return [{
|
|
248
|
+
name: 'typeAhead',
|
|
249
|
+
plugin: function plugin(_ref5) {
|
|
250
|
+
var dispatch = _ref5.dispatch,
|
|
251
|
+
getIntl = _ref5.getIntl;
|
|
252
|
+
return (0, _main.createPlugin)({
|
|
253
|
+
getIntl: getIntl,
|
|
254
|
+
popupMountRef: popupMountRef,
|
|
255
|
+
reactDispatch: dispatch,
|
|
256
|
+
typeAheadHandlers: typeAhead,
|
|
257
|
+
createAnalyticsEvent: options === null || options === void 0 ? void 0 : options.createAnalyticsEvent
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}, {
|
|
261
|
+
name: 'typeAheadEditorViewRef',
|
|
262
|
+
plugin: function plugin() {
|
|
263
|
+
return new _safePlugin.SafePlugin({
|
|
264
|
+
view: function view(_view) {
|
|
265
|
+
editorViewRef.current = _view;
|
|
266
|
+
return {
|
|
267
|
+
destroy: function destroy() {
|
|
268
|
+
editorViewRef.current = null;
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
}, {
|
|
275
|
+
name: 'typeAheadInsertItem',
|
|
276
|
+
plugin: _insertItemPlugin.createPlugin
|
|
277
|
+
}, {
|
|
278
|
+
name: 'typeAheadInputRule',
|
|
279
|
+
plugin: function plugin(_ref6) {
|
|
280
|
+
var schema = _ref6.schema,
|
|
281
|
+
featureFlags = _ref6.featureFlags;
|
|
282
|
+
return (0, _inputRules.inputRulePlugin)(schema, typeAhead, featureFlags);
|
|
283
|
+
}
|
|
284
|
+
}];
|
|
285
|
+
},
|
|
286
|
+
getSharedState: function getSharedState(editorState) {
|
|
287
|
+
if (!editorState) {
|
|
288
|
+
return {
|
|
289
|
+
query: '',
|
|
290
|
+
isOpen: false,
|
|
291
|
+
isAllowed: false,
|
|
292
|
+
currentHandler: undefined
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
var isOpen = (0, _utils.isTypeAheadOpen)(editorState);
|
|
296
|
+
return {
|
|
297
|
+
query: (0, _utils.getTypeAheadQuery)(editorState) || '',
|
|
298
|
+
currentHandler: (0, _utils.getTypeAheadHandler)(editorState),
|
|
299
|
+
isOpen: isOpen,
|
|
300
|
+
isAllowed: !isOpen
|
|
301
|
+
};
|
|
302
|
+
},
|
|
303
|
+
actions: {
|
|
304
|
+
isOpen: _utils.isTypeAheadOpen,
|
|
305
|
+
isAllowed: _utils.isTypeAheadAllowed,
|
|
306
|
+
open: createOpenTypeAhead(editorViewRef, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions),
|
|
307
|
+
openAtTransaction: createOpenAtTransaction(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions),
|
|
308
|
+
findHandlerByTrigger: createFindHandlerByTrigger(editorViewRef),
|
|
309
|
+
insert: createInsertTypeAheadItem(editorViewRef),
|
|
310
|
+
close: createCloseTypeAhead(editorViewRef)
|
|
311
|
+
},
|
|
312
|
+
contentComponent: function contentComponent(_ref7) {
|
|
313
|
+
var editorView = _ref7.editorView,
|
|
314
|
+
containerElement = _ref7.containerElement,
|
|
315
|
+
popupsMountPoint = _ref7.popupsMountPoint,
|
|
316
|
+
popupsBoundariesElement = _ref7.popupsBoundariesElement,
|
|
317
|
+
popupsScrollableElement = _ref7.popupsScrollableElement,
|
|
318
|
+
wrapperElement = _ref7.wrapperElement;
|
|
319
|
+
popupMountRef.current = {
|
|
320
|
+
popupsMountPoint: popupsMountPoint || wrapperElement || undefined,
|
|
321
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
322
|
+
popupsScrollableElement: popupsScrollableElement || containerElement || undefined
|
|
323
|
+
};
|
|
324
|
+
return /*#__PURE__*/_react.default.createElement(_withPluginState.WithPluginState, {
|
|
325
|
+
plugins: {
|
|
326
|
+
typeAheadState: _key.pluginKey
|
|
327
|
+
},
|
|
328
|
+
render: function render(_ref8) {
|
|
329
|
+
var typeAheadState = _ref8.typeAheadState;
|
|
330
|
+
if (!typeAheadState) {
|
|
331
|
+
return null;
|
|
332
|
+
}
|
|
333
|
+
return /*#__PURE__*/_react.default.createElement(TypeAheadMenu, {
|
|
334
|
+
editorView: editorView,
|
|
335
|
+
popupMountRef: popupMountRef,
|
|
336
|
+
typeAheadState: typeAheadState,
|
|
337
|
+
fireAnalyticsCallback: fireAnalyticsCallback
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
},
|
|
342
|
+
onEditorViewStateUpdated: function onEditorViewStateUpdated(_ref9) {
|
|
343
|
+
var originalTransaction = _ref9.originalTransaction,
|
|
344
|
+
oldEditorState = _ref9.oldEditorState,
|
|
345
|
+
newEditorState = _ref9.newEditorState;
|
|
346
|
+
var oldPluginState = (0, _utils.getPluginState)(oldEditorState);
|
|
347
|
+
var newPluginState = (0, _utils.getPluginState)(newEditorState);
|
|
348
|
+
if (!oldPluginState || !newPluginState) {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
var oldTriggerHandler = oldPluginState.triggerHandler;
|
|
352
|
+
var newTriggerHandler = newPluginState.triggerHandler;
|
|
353
|
+
var isANewHandler = oldTriggerHandler !== newTriggerHandler;
|
|
354
|
+
if (oldTriggerHandler !== null && oldTriggerHandler !== void 0 && oldTriggerHandler.dismiss && isANewHandler) {
|
|
355
|
+
var typeAheadMessage = originalTransaction.getMeta(_key.pluginKey);
|
|
356
|
+
var wasItemInserted = typeAheadMessage && typeAheadMessage.action === 'INSERT_RAW_QUERY';
|
|
357
|
+
oldTriggerHandler.dismiss({
|
|
358
|
+
editorState: newEditorState,
|
|
359
|
+
query: oldPluginState.query,
|
|
360
|
+
stats: (oldPluginState.stats || new _statsModifier.StatsModifier()).serialize(),
|
|
361
|
+
wasItemInserted: wasItemInserted
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
if (newTriggerHandler !== null && newTriggerHandler !== void 0 && newTriggerHandler.onOpen && isANewHandler) {
|
|
365
|
+
newTriggerHandler.onOpen(newEditorState);
|
|
366
|
+
}
|
|
367
|
+
if (newTriggerHandler && isANewHandler && options !== null && options !== void 0 && options.createAnalyticsEvent) {
|
|
368
|
+
fireAnalyticsCallback({
|
|
369
|
+
payload: {
|
|
370
|
+
action: _analytics.ACTION.INVOKED,
|
|
371
|
+
actionSubject: _analytics.ACTION_SUBJECT.TYPEAHEAD,
|
|
372
|
+
actionSubjectId: newTriggerHandler.id || 'not_set',
|
|
373
|
+
attributes: {
|
|
374
|
+
inputMethod: newPluginState.inputMethod || _analytics.INPUT_METHOD.KEYBOARD
|
|
375
|
+
},
|
|
376
|
+
eventType: _analytics.EVENT_TYPE.UI
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
};
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.subscribeToToolbarAndPickerUpdates = void 0;
|
|
7
7
|
var _floatingToolbar = require("@atlaskit/editor-common/floating-toolbar");
|
|
8
|
-
var _utils = require("../../type-ahead/utils");
|
|
9
8
|
var _ = require("..");
|
|
10
9
|
var areToolbarsSame = function areToolbarsSame(left, right) {
|
|
11
10
|
if (!left && !right) {
|
|
@@ -30,14 +29,13 @@ var subscribeToToolbarAndPickerUpdates = exports.subscribeToToolbarAndPickerUpda
|
|
|
30
29
|
var lastUpdatedState = null;
|
|
31
30
|
var subscription = function subscription(_ref) {
|
|
32
31
|
var newEditorState = _ref.newEditorState;
|
|
33
|
-
// TypeAhead has priority in the mobile-bridge
|
|
34
|
-
// In case it is open we don't need to send
|
|
35
|
-
// any toolbar updates don't need to be send
|
|
36
|
-
if ((0, _utils.isTypeAheadOpen)(newEditorState)) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
32
|
// Creating fake plugin keys for these plugins for the mean time until all these plugins are extracted.
|
|
33
|
+
var typeAheadPluginKey = {
|
|
34
|
+
key: 'typeAheadPlugin$',
|
|
35
|
+
getState: function getState(state) {
|
|
36
|
+
return state['typeAheadPlugin$'];
|
|
37
|
+
}
|
|
38
|
+
};
|
|
41
39
|
var datePluginKey = {
|
|
42
40
|
key: 'datePlugin$',
|
|
43
41
|
getState: function getState(state) {
|
|
@@ -56,6 +54,17 @@ var subscribeToToolbarAndPickerUpdates = exports.subscribeToToolbarAndPickerUpda
|
|
|
56
54
|
return state['floatingToolbarPluginKey$'];
|
|
57
55
|
}
|
|
58
56
|
};
|
|
57
|
+
var isTypeAheadOpen = function isTypeAheadOpen(editorState) {
|
|
58
|
+
var _typeAheadState$decor;
|
|
59
|
+
var typeAheadState = typeAheadPluginKey.getState(newEditorState);
|
|
60
|
+
return !!((_typeAheadState$decor = typeAheadState.decorationSet) !== null && _typeAheadState$decor !== void 0 && _typeAheadState$decor.find().length);
|
|
61
|
+
};
|
|
62
|
+
// TypeAhead has priority in the mobile-bridge
|
|
63
|
+
// In case it is open we don't need to send
|
|
64
|
+
// any toolbar updates don't need to be send
|
|
65
|
+
if (isTypeAheadOpen(newEditorState)) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
59
68
|
var dateState = datePluginKey.getState(newEditorState);
|
|
60
69
|
var statusState = statusPluginKey.getState(newEditorState);
|
|
61
70
|
var _ref2 = floatingToolbarPluginKey.getState(newEditorState),
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.version = exports.nextMajorVersion = exports.name = void 0;
|
|
7
7
|
var name = exports.name = "@atlaskit/editor-core";
|
|
8
|
-
var version = exports.version = "188.
|
|
8
|
+
var version = exports.version = "188.9.0";
|
|
9
9
|
var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
|
|
10
10
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
|
11
11
|
};
|
|
@@ -7,7 +7,7 @@ import { BaseTheme, WidthProvider } from '@atlaskit/editor-common/ui';
|
|
|
7
7
|
import { getUiComponent } from '../create-editor';
|
|
8
8
|
import ErrorBoundary from '../create-editor/ErrorBoundary';
|
|
9
9
|
import { createFeatureFlagsFromProps } from '../create-editor/feature-flags-from-props';
|
|
10
|
-
import ReactEditorView from '../create-editor/
|
|
10
|
+
import ReactEditorView from '../create-editor/ReactEditorView';
|
|
11
11
|
import { ContextAdapter } from '../nodeviews/context-adapter';
|
|
12
12
|
import EditorContext from '../ui/EditorContext';
|
|
13
13
|
import { useSetPresetContext } from '../presets/context';
|