@atlaskit/editor-core 188.9.0 → 188.9.5
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 +13 -0
- package/dist/cjs/labs/next/presets/default.js +2 -2
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/plugins/insert-block/index.js +4 -6
- package/dist/cjs/plugins/tasks-and-decisions/index.js +4 -3
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/decisionItem.js +26 -6
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/taskItem.js +45 -13
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/main.js +15 -7
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/labs/next/presets/default.js +1 -1
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/plugins/insert-block/index.js +4 -6
- package/dist/es2019/plugins/tasks-and-decisions/index.js +4 -3
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/decisionItem.js +26 -6
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/taskItem.js +43 -10
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/main.js +13 -6
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/labs/next/presets/default.js +1 -1
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/plugins/insert-block/index.js +4 -6
- package/dist/esm/plugins/tasks-and-decisions/index.js +4 -3
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/decisionItem.js +26 -6
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/taskItem.js +45 -12
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/main.js +14 -7
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/labs/next/presets/default.d.ts +43 -43
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/plugins/insert-block/types.d.ts +2 -0
- package/dist/types/plugins/tasks-and-decisions/index.d.ts +2 -5
- package/dist/types/plugins/tasks-and-decisions/nodeviews/decisionItem.d.ts +9 -4
- package/dist/types/plugins/tasks-and-decisions/nodeviews/taskItem.d.ts +9 -4
- package/dist/types/plugins/tasks-and-decisions/pm-plugins/main.d.ts +4 -2
- package/dist/types/plugins/tasks-and-decisions/types.d.ts +6 -1
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +43 -43
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/insert-block/types.d.ts +2 -0
- package/dist/types-ts4.5/plugins/tasks-and-decisions/index.d.ts +2 -5
- package/dist/types-ts4.5/plugins/tasks-and-decisions/nodeviews/decisionItem.d.ts +9 -4
- package/dist/types-ts4.5/plugins/tasks-and-decisions/nodeviews/taskItem.d.ts +9 -4
- package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/main.d.ts +4 -2
- package/dist/types-ts4.5/plugins/tasks-and-decisions/types.d.ts +8 -1
- package/package.json +10 -8
- package/dist/cjs/plugins/type-ahead/api.js +0 -215
- package/dist/cjs/plugins/type-ahead/commands/insert-type-ahead-item.js +0 -205
- package/dist/cjs/plugins/type-ahead/commands/update-list-items.js +0 -23
- package/dist/cjs/plugins/type-ahead/commands/update-query.js +0 -27
- package/dist/cjs/plugins/type-ahead/commands/update-selected-index.js +0 -27
- package/dist/cjs/plugins/type-ahead/constants.js +0 -15
- package/dist/cjs/plugins/type-ahead/index.js +0 -14
- package/dist/cjs/plugins/type-ahead/insert-utils.js +0 -107
- package/dist/cjs/plugins/type-ahead/messages.js +0 -79
- package/dist/cjs/plugins/type-ahead/plugin.js +0 -382
- package/dist/cjs/plugins/type-ahead/pm-plugins/actions.js +0 -16
- package/dist/cjs/plugins/type-ahead/pm-plugins/decorations.js +0 -148
- package/dist/cjs/plugins/type-ahead/pm-plugins/input-rules.js +0 -36
- package/dist/cjs/plugins/type-ahead/pm-plugins/insert-item-plugin.js +0 -22
- package/dist/cjs/plugins/type-ahead/pm-plugins/key.js +0 -8
- package/dist/cjs/plugins/type-ahead/pm-plugins/main.js +0 -110
- package/dist/cjs/plugins/type-ahead/pm-plugins/reducer.js +0 -158
- package/dist/cjs/plugins/type-ahead/pm-plugins/utils.js +0 -18
- package/dist/cjs/plugins/type-ahead/stats-modifier.js +0 -42
- package/dist/cjs/plugins/type-ahead/transforms/close-type-ahead.js +0 -13
- package/dist/cjs/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +0 -75
- package/dist/cjs/plugins/type-ahead/transforms/set-selection-before-query.js +0 -18
- package/dist/cjs/plugins/type-ahead/types.js +0 -5
- package/dist/cjs/plugins/type-ahead/ui/AssistiveText.js +0 -120
- package/dist/cjs/plugins/type-ahead/ui/InputQuery.js +0 -400
- package/dist/cjs/plugins/type-ahead/ui/TypeAheadList.js +0 -285
- package/dist/cjs/plugins/type-ahead/ui/TypeAheadListItem.js +0 -179
- package/dist/cjs/plugins/type-ahead/ui/TypeAheadPopup.js +0 -230
- package/dist/cjs/plugins/type-ahead/ui/WrapperTypeAhead.js +0 -127
- package/dist/cjs/plugins/type-ahead/ui/hooks/use-item-insert.js +0 -109
- package/dist/cjs/plugins/type-ahead/ui/hooks/use-load-items.js +0 -50
- package/dist/cjs/plugins/type-ahead/ui/hooks/use-on-force-select.js +0 -41
- package/dist/cjs/plugins/type-ahead/utils.js +0 -130
- package/dist/es2019/plugins/type-ahead/api.js +0 -205
- package/dist/es2019/plugins/type-ahead/commands/insert-type-ahead-item.js +0 -204
- package/dist/es2019/plugins/type-ahead/commands/update-list-items.js +0 -17
- package/dist/es2019/plugins/type-ahead/commands/update-query.js +0 -21
- package/dist/es2019/plugins/type-ahead/commands/update-selected-index.js +0 -21
- package/dist/es2019/plugins/type-ahead/constants.js +0 -9
- package/dist/es2019/plugins/type-ahead/index.js +0 -3
- package/dist/es2019/plugins/type-ahead/insert-utils.js +0 -106
- package/dist/es2019/plugins/type-ahead/messages.js +0 -73
- package/dist/es2019/plugins/type-ahead/plugin.js +0 -381
- package/dist/es2019/plugins/type-ahead/pm-plugins/actions.js +0 -10
- package/dist/es2019/plugins/type-ahead/pm-plugins/decorations.js +0 -148
- package/dist/es2019/plugins/type-ahead/pm-plugins/input-rules.js +0 -29
- package/dist/es2019/plugins/type-ahead/pm-plugins/insert-item-plugin.js +0 -16
- package/dist/es2019/plugins/type-ahead/pm-plugins/key.js +0 -2
- package/dist/es2019/plugins/type-ahead/pm-plugins/main.js +0 -106
- package/dist/es2019/plugins/type-ahead/pm-plugins/reducer.js +0 -160
- package/dist/es2019/plugins/type-ahead/pm-plugins/utils.js +0 -12
- package/dist/es2019/plugins/type-ahead/stats-modifier.js +0 -33
- package/dist/es2019/plugins/type-ahead/transforms/close-type-ahead.js +0 -7
- package/dist/es2019/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +0 -71
- package/dist/es2019/plugins/type-ahead/transforms/set-selection-before-query.js +0 -10
- package/dist/es2019/plugins/type-ahead/types.js +0 -1
- package/dist/es2019/plugins/type-ahead/ui/AssistiveText.js +0 -88
- package/dist/es2019/plugins/type-ahead/ui/InputQuery.js +0 -393
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadList.js +0 -273
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadListItem.js +0 -214
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadPopup.js +0 -233
- package/dist/es2019/plugins/type-ahead/ui/WrapperTypeAhead.js +0 -109
- package/dist/es2019/plugins/type-ahead/ui/hooks/use-item-insert.js +0 -112
- package/dist/es2019/plugins/type-ahead/ui/hooks/use-load-items.js +0 -41
- package/dist/es2019/plugins/type-ahead/ui/hooks/use-on-force-select.js +0 -38
- package/dist/es2019/plugins/type-ahead/utils.js +0 -126
- package/dist/esm/plugins/type-ahead/api.js +0 -209
- package/dist/esm/plugins/type-ahead/commands/insert-type-ahead-item.js +0 -198
- package/dist/esm/plugins/type-ahead/commands/update-list-items.js +0 -17
- package/dist/esm/plugins/type-ahead/commands/update-query.js +0 -21
- package/dist/esm/plugins/type-ahead/commands/update-selected-index.js +0 -21
- package/dist/esm/plugins/type-ahead/constants.js +0 -9
- package/dist/esm/plugins/type-ahead/index.js +0 -3
- package/dist/esm/plugins/type-ahead/insert-utils.js +0 -101
- package/dist/esm/plugins/type-ahead/messages.js +0 -73
- package/dist/esm/plugins/type-ahead/plugin.js +0 -374
- package/dist/esm/plugins/type-ahead/pm-plugins/actions.js +0 -10
- package/dist/esm/plugins/type-ahead/pm-plugins/decorations.js +0 -141
- package/dist/esm/plugins/type-ahead/pm-plugins/input-rules.js +0 -29
- package/dist/esm/plugins/type-ahead/pm-plugins/insert-item-plugin.js +0 -16
- package/dist/esm/plugins/type-ahead/pm-plugins/key.js +0 -2
- package/dist/esm/plugins/type-ahead/pm-plugins/main.js +0 -104
- package/dist/esm/plugins/type-ahead/pm-plugins/reducer.js +0 -151
- package/dist/esm/plugins/type-ahead/pm-plugins/utils.js +0 -12
- package/dist/esm/plugins/type-ahead/stats-modifier.js +0 -35
- package/dist/esm/plugins/type-ahead/transforms/close-type-ahead.js +0 -7
- package/dist/esm/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +0 -69
- package/dist/esm/plugins/type-ahead/transforms/set-selection-before-query.js +0 -12
- package/dist/esm/plugins/type-ahead/types.js +0 -1
- package/dist/esm/plugins/type-ahead/ui/AssistiveText.js +0 -115
- package/dist/esm/plugins/type-ahead/ui/InputQuery.js +0 -390
- package/dist/esm/plugins/type-ahead/ui/TypeAheadList.js +0 -276
- package/dist/esm/plugins/type-ahead/ui/TypeAheadListItem.js +0 -169
- package/dist/esm/plugins/type-ahead/ui/TypeAheadPopup.js +0 -220
- package/dist/esm/plugins/type-ahead/ui/WrapperTypeAhead.js +0 -117
- package/dist/esm/plugins/type-ahead/ui/hooks/use-item-insert.js +0 -103
- package/dist/esm/plugins/type-ahead/ui/hooks/use-load-items.js +0 -43
- package/dist/esm/plugins/type-ahead/ui/hooks/use-on-force-select.js +0 -35
- package/dist/esm/plugins/type-ahead/utils.js +0 -124
- package/dist/types/plugins/type-ahead/api.d.ts +0 -61
- package/dist/types/plugins/type-ahead/commands/insert-type-ahead-item.d.ts +0 -12
- package/dist/types/plugins/type-ahead/commands/update-list-items.d.ts +0 -3
- package/dist/types/plugins/type-ahead/commands/update-query.d.ts +0 -2
- package/dist/types/plugins/type-ahead/commands/update-selected-index.d.ts +0 -2
- package/dist/types/plugins/type-ahead/constants.d.ts +0 -8
- package/dist/types/plugins/type-ahead/index.d.ts +0 -4
- package/dist/types/plugins/type-ahead/insert-utils.d.ts +0 -18
- package/dist/types/plugins/type-ahead/messages.d.ts +0 -72
- package/dist/types/plugins/type-ahead/plugin.d.ts +0 -10
- package/dist/types/plugins/type-ahead/pm-plugins/actions.d.ts +0 -9
- package/dist/types/plugins/type-ahead/pm-plugins/decorations.d.ts +0 -14
- package/dist/types/plugins/type-ahead/pm-plugins/input-rules.d.ts +0 -6
- package/dist/types/plugins/type-ahead/pm-plugins/insert-item-plugin.d.ts +0 -2
- package/dist/types/plugins/type-ahead/pm-plugins/key.d.ts +0 -3
- package/dist/types/plugins/type-ahead/pm-plugins/main.d.ts +0 -14
- package/dist/types/plugins/type-ahead/pm-plugins/reducer.d.ts +0 -10
- package/dist/types/plugins/type-ahead/pm-plugins/utils.d.ts +0 -4
- package/dist/types/plugins/type-ahead/stats-modifier.d.ts +0 -20
- package/dist/types/plugins/type-ahead/transforms/close-type-ahead.d.ts +0 -2
- package/dist/types/plugins/type-ahead/transforms/open-typeahead-at-cursor.d.ts +0 -11
- package/dist/types/plugins/type-ahead/transforms/set-selection-before-query.d.ts +0 -2
- package/dist/types/plugins/type-ahead/types.d.ts +0 -109
- package/dist/types/plugins/type-ahead/ui/AssistiveText.d.ts +0 -33
- package/dist/types/plugins/type-ahead/ui/InputQuery.d.ts +0 -26
- package/dist/types/plugins/type-ahead/ui/TypeAheadList.d.ts +0 -25
- package/dist/types/plugins/type-ahead/ui/TypeAheadListItem.d.ts +0 -18
- package/dist/types/plugins/type-ahead/ui/TypeAheadPopup.d.ts +0 -29
- package/dist/types/plugins/type-ahead/ui/WrapperTypeAhead.d.ts +0 -20
- package/dist/types/plugins/type-ahead/ui/hooks/use-item-insert.d.ts +0 -3
- package/dist/types/plugins/type-ahead/ui/hooks/use-load-items.d.ts +0 -3
- package/dist/types/plugins/type-ahead/ui/hooks/use-on-force-select.d.ts +0 -11
- package/dist/types/plugins/type-ahead/utils.d.ts +0 -27
- package/dist/types-ts4.5/plugins/type-ahead/api.d.ts +0 -61
- package/dist/types-ts4.5/plugins/type-ahead/commands/insert-type-ahead-item.d.ts +0 -12
- package/dist/types-ts4.5/plugins/type-ahead/commands/update-list-items.d.ts +0 -3
- package/dist/types-ts4.5/plugins/type-ahead/commands/update-query.d.ts +0 -2
- package/dist/types-ts4.5/plugins/type-ahead/commands/update-selected-index.d.ts +0 -2
- package/dist/types-ts4.5/plugins/type-ahead/constants.d.ts +0 -8
- package/dist/types-ts4.5/plugins/type-ahead/index.d.ts +0 -4
- package/dist/types-ts4.5/plugins/type-ahead/insert-utils.d.ts +0 -18
- package/dist/types-ts4.5/plugins/type-ahead/messages.d.ts +0 -72
- package/dist/types-ts4.5/plugins/type-ahead/plugin.d.ts +0 -10
- package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/actions.d.ts +0 -9
- package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/decorations.d.ts +0 -14
- package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/input-rules.d.ts +0 -6
- package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/insert-item-plugin.d.ts +0 -2
- package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/key.d.ts +0 -3
- package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/main.d.ts +0 -14
- package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/reducer.d.ts +0 -10
- package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/utils.d.ts +0 -4
- package/dist/types-ts4.5/plugins/type-ahead/stats-modifier.d.ts +0 -20
- package/dist/types-ts4.5/plugins/type-ahead/transforms/close-type-ahead.d.ts +0 -2
- package/dist/types-ts4.5/plugins/type-ahead/transforms/open-typeahead-at-cursor.d.ts +0 -11
- package/dist/types-ts4.5/plugins/type-ahead/transforms/set-selection-before-query.d.ts +0 -2
- package/dist/types-ts4.5/plugins/type-ahead/types.d.ts +0 -111
- package/dist/types-ts4.5/plugins/type-ahead/ui/AssistiveText.d.ts +0 -33
- package/dist/types-ts4.5/plugins/type-ahead/ui/InputQuery.d.ts +0 -26
- package/dist/types-ts4.5/plugins/type-ahead/ui/TypeAheadList.d.ts +0 -25
- package/dist/types-ts4.5/plugins/type-ahead/ui/TypeAheadListItem.d.ts +0 -18
- package/dist/types-ts4.5/plugins/type-ahead/ui/TypeAheadPopup.d.ts +0 -29
- package/dist/types-ts4.5/plugins/type-ahead/ui/WrapperTypeAhead.d.ts +0 -20
- package/dist/types-ts4.5/plugins/type-ahead/ui/hooks/use-item-insert.d.ts +0 -7
- package/dist/types-ts4.5/plugins/type-ahead/ui/hooks/use-load-items.d.ts +0 -3
- package/dist/types-ts4.5/plugins/type-ahead/ui/hooks/use-on-force-select.d.ts +0 -11
- package/dist/types-ts4.5/plugins/type-ahead/utils.d.ts +0 -27
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import { TypeAheadAvailableNodes, SelectItemMode } from '@atlaskit/editor-common/type-ahead';
|
|
2
|
-
import { findHandler, isTypeAheadOpen, getTypeAheadHandler, getTypeAheadQuery } from './utils';
|
|
3
|
-
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import { openTypeAheadAtCursor } from './transforms/open-typeahead-at-cursor';
|
|
5
|
-
import { closeTypeAhead } from './transforms/close-type-ahead';
|
|
6
|
-
import { updateQuery } from './commands/update-query';
|
|
7
|
-
import { insertTypeAheadItem } from './commands/insert-type-ahead-item';
|
|
8
|
-
var open = function open(_ref) {
|
|
9
|
-
var editorView = _ref.editorView;
|
|
10
|
-
return function (itemType) {
|
|
11
|
-
return function (inputMethod) {
|
|
12
|
-
var state = editorView.state;
|
|
13
|
-
var handler = findHandler(itemType, state);
|
|
14
|
-
if (!handler) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
var tr = state.tr;
|
|
18
|
-
openTypeAheadAtCursor({
|
|
19
|
-
triggerHandler: handler,
|
|
20
|
-
inputMethod: inputMethod
|
|
21
|
-
})({
|
|
22
|
-
tr: tr
|
|
23
|
-
});
|
|
24
|
-
editorView.dispatch(tr);
|
|
25
|
-
return true;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
var defaultCloseOptions = {
|
|
30
|
-
insertCurrentQueryAsRawText: false
|
|
31
|
-
};
|
|
32
|
-
var close = function close(_ref2) {
|
|
33
|
-
var editorView = _ref2.editorView;
|
|
34
|
-
return function () {
|
|
35
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultCloseOptions;
|
|
36
|
-
var state = editorView.state;
|
|
37
|
-
var currentQuery = getTypeAheadQuery(editorView.state);
|
|
38
|
-
var tr = state.tr;
|
|
39
|
-
if (options.attachCommand) {
|
|
40
|
-
var fakeDispatch = function fakeDispatch(customTr) {
|
|
41
|
-
tr = customTr;
|
|
42
|
-
};
|
|
43
|
-
options.attachCommand(state, fakeDispatch);
|
|
44
|
-
}
|
|
45
|
-
closeTypeAhead(tr);
|
|
46
|
-
if (options.insertCurrentQueryAsRawText && currentQuery && currentQuery.length > 0) {
|
|
47
|
-
var handler = getTypeAheadHandler(state);
|
|
48
|
-
var text = handler.trigger.concat(currentQuery);
|
|
49
|
-
tr.replaceSelectionWith(state.schema.text(text));
|
|
50
|
-
}
|
|
51
|
-
editorView.dispatch(tr);
|
|
52
|
-
if (!editorView.hasFocus()) {
|
|
53
|
-
editorView.focus();
|
|
54
|
-
}
|
|
55
|
-
return true;
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
var search = function search(_ref3) {
|
|
59
|
-
var editorView = _ref3.editorView;
|
|
60
|
-
return function (itemType) {
|
|
61
|
-
return function () {
|
|
62
|
-
var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
63
|
-
var state = editorView.state;
|
|
64
|
-
var handler = findHandler(itemType, state);
|
|
65
|
-
if (!handler) {
|
|
66
|
-
throw new Error("Handler not found, did you load the ".concat(itemType, " plugin properly"));
|
|
67
|
-
}
|
|
68
|
-
open({
|
|
69
|
-
editorView: editorView
|
|
70
|
-
})(itemType)(INPUT_METHOD.KEYBOARD);
|
|
71
|
-
updateQuery(query)(editorView.state, editorView.dispatch);
|
|
72
|
-
var lastQuery = {
|
|
73
|
-
current: query
|
|
74
|
-
};
|
|
75
|
-
var last = handler.getItems({
|
|
76
|
-
query: query,
|
|
77
|
-
editorState: state
|
|
78
|
-
}).then(function (items) {
|
|
79
|
-
if (!handler.forceSelect) {
|
|
80
|
-
return items;
|
|
81
|
-
}
|
|
82
|
-
var forceSelectedItem = handler.forceSelect({
|
|
83
|
-
items: items,
|
|
84
|
-
query: query,
|
|
85
|
-
editorState: state
|
|
86
|
-
});
|
|
87
|
-
if (!forceSelectedItem) {
|
|
88
|
-
return items;
|
|
89
|
-
}
|
|
90
|
-
insertTypeAheadItem(editorView)({
|
|
91
|
-
handler: handler,
|
|
92
|
-
item: forceSelectedItem,
|
|
93
|
-
query: query,
|
|
94
|
-
mode: SelectItemMode.SELECTED,
|
|
95
|
-
sourceListItem: items
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
var results = {
|
|
99
|
-
last: last
|
|
100
|
-
};
|
|
101
|
-
return {
|
|
102
|
-
type: function type(appendValue) {
|
|
103
|
-
if (!appendValue) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
lastQuery.current += appendValue;
|
|
107
|
-
updateQuery(lastQuery.current)(editorView.state, editorView.dispatch);
|
|
108
|
-
var promise = handler.getItems({
|
|
109
|
-
query: lastQuery.current,
|
|
110
|
-
editorState: state
|
|
111
|
-
});
|
|
112
|
-
results.last = promise;
|
|
113
|
-
return promise;
|
|
114
|
-
},
|
|
115
|
-
result: function result() {
|
|
116
|
-
return results.last;
|
|
117
|
-
},
|
|
118
|
-
close: close({
|
|
119
|
-
editorView: editorView
|
|
120
|
-
}),
|
|
121
|
-
insert: function insert(_ref4) {
|
|
122
|
-
var index = _ref4.index,
|
|
123
|
-
mode = _ref4.mode;
|
|
124
|
-
return results.last.then(function (result) {
|
|
125
|
-
var item = result ? result[index] : null;
|
|
126
|
-
if (result && item) {
|
|
127
|
-
insertTypeAheadItem(editorView)({
|
|
128
|
-
handler: handler,
|
|
129
|
-
item: item,
|
|
130
|
-
query: query,
|
|
131
|
-
mode: mode || SelectItemMode.SELECTED,
|
|
132
|
-
sourceListItem: result
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
};
|
|
139
|
-
};
|
|
140
|
-
};
|
|
141
|
-
var insertItem = function insertItem(_ref5) {
|
|
142
|
-
var editorView = _ref5.editorView;
|
|
143
|
-
return function (itemType) {
|
|
144
|
-
return function (_ref6) {
|
|
145
|
-
var contentItem = _ref6.contentItem,
|
|
146
|
-
query = _ref6.query,
|
|
147
|
-
sourceListItem = _ref6.sourceListItem;
|
|
148
|
-
var state = editorView.state;
|
|
149
|
-
var handler = findHandler(itemType, state);
|
|
150
|
-
if (!handler) {
|
|
151
|
-
return false;
|
|
152
|
-
}
|
|
153
|
-
insertTypeAheadItem(editorView)({
|
|
154
|
-
handler: handler,
|
|
155
|
-
item: contentItem,
|
|
156
|
-
mode: SelectItemMode.SELECTED,
|
|
157
|
-
query: query,
|
|
158
|
-
sourceListItem: sourceListItem
|
|
159
|
-
});
|
|
160
|
-
return true;
|
|
161
|
-
};
|
|
162
|
-
};
|
|
163
|
-
};
|
|
164
|
-
var isOpen = function isOpen(_ref7) {
|
|
165
|
-
var editorView = _ref7.editorView;
|
|
166
|
-
return function () {
|
|
167
|
-
if (!isTypeAheadOpen(editorView.state)) {
|
|
168
|
-
return false;
|
|
169
|
-
}
|
|
170
|
-
var handler = getTypeAheadHandler(editorView.state);
|
|
171
|
-
if (!handler) {
|
|
172
|
-
return false;
|
|
173
|
-
}
|
|
174
|
-
return handler;
|
|
175
|
-
};
|
|
176
|
-
};
|
|
177
|
-
var currentQuery = function currentQuery(_ref8) {
|
|
178
|
-
var editorView = _ref8.editorView;
|
|
179
|
-
return function () {
|
|
180
|
-
return getTypeAheadQuery(editorView.state);
|
|
181
|
-
};
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Please do not use it. Ping #help-editor and talk to the Lego team before use it.
|
|
186
|
-
*
|
|
187
|
-
* @private
|
|
188
|
-
* @deprecated
|
|
189
|
-
*
|
|
190
|
-
*/
|
|
191
|
-
export var createTypeAheadTools = function createTypeAheadTools(editorView) {
|
|
192
|
-
var props = {
|
|
193
|
-
editorView: editorView
|
|
194
|
-
};
|
|
195
|
-
return {
|
|
196
|
-
isOpen: isOpen(props),
|
|
197
|
-
currentQuery: currentQuery(props),
|
|
198
|
-
close: close(props),
|
|
199
|
-
openMention: open(props)(TypeAheadAvailableNodes.MENTION),
|
|
200
|
-
searchMention: search(props)(TypeAheadAvailableNodes.MENTION),
|
|
201
|
-
openQuickInsert: open(props)(TypeAheadAvailableNodes.QUICK_INSERT),
|
|
202
|
-
searchQuickInsert: search(props)(TypeAheadAvailableNodes.QUICK_INSERT),
|
|
203
|
-
openEmoji: open(props)(TypeAheadAvailableNodes.EMOJI),
|
|
204
|
-
searchEmoji: search(props)(TypeAheadAvailableNodes.EMOJI),
|
|
205
|
-
insertItemMention: insertItem(props)(TypeAheadAvailableNodes.MENTION),
|
|
206
|
-
insertItemEmoji: insertItem(props)(TypeAheadAvailableNodes.EMOJI),
|
|
207
|
-
insertItemQuickInsert: insertItem(props)(TypeAheadAvailableNodes.QUICK_INSERT)
|
|
208
|
-
};
|
|
209
|
-
};
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
-
import { closeHistory } from '@atlaskit/editor-prosemirror/history';
|
|
3
|
-
import { Fragment, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
-
import { InsertTypeAheadStages, InsertTypeAheadStep } from '@atlaskit/adf-schema/steps';
|
|
5
|
-
import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
|
|
6
|
-
import { insertBlockNode, insertInlineNodeOrFragment } from '../insert-utils';
|
|
7
|
-
import { ACTIONS } from '../pm-plugins/actions';
|
|
8
|
-
import { pluginKey } from '../pm-plugins/key';
|
|
9
|
-
import { StatsModifier } from '../stats-modifier';
|
|
10
|
-
import { closeTypeAhead } from '../transforms/close-type-ahead';
|
|
11
|
-
import { getPluginState } from '../utils';
|
|
12
|
-
var validateNode = function validateNode(_ref) {
|
|
13
|
-
var schema = _ref.schema,
|
|
14
|
-
maybeNode = _ref.maybeNode;
|
|
15
|
-
if (!maybeNode) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
if (maybeNode instanceof PMNode || maybeNode instanceof Fragment) {
|
|
19
|
-
return maybeNode;
|
|
20
|
-
}
|
|
21
|
-
if (typeof maybeNode === 'string') {
|
|
22
|
-
return schema.text(maybeNode);
|
|
23
|
-
}
|
|
24
|
-
try {
|
|
25
|
-
return PMNode.fromJSON(schema, maybeNode);
|
|
26
|
-
} catch (e) {
|
|
27
|
-
// eslint-disable-next-line no-console
|
|
28
|
-
console.error(e);
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
var createInsertCallback = function createInsertCallback(_ref2) {
|
|
33
|
-
var state = _ref2.editorState,
|
|
34
|
-
handler = _ref2.handler,
|
|
35
|
-
query = _ref2.query,
|
|
36
|
-
wasInsertedBySpace = _ref2.wasInsertedBySpace,
|
|
37
|
-
selectedIndex = _ref2.selectedIndex,
|
|
38
|
-
textStartPosition = _ref2.textStartPosition,
|
|
39
|
-
textInserted = _ref2.textInserted;
|
|
40
|
-
return function (maybeNode) {
|
|
41
|
-
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
42
|
-
var tr = state.tr;
|
|
43
|
-
var position = {
|
|
44
|
-
start: textStartPosition,
|
|
45
|
-
end: textStartPosition + (wasInsertedBySpace ? textInserted.length : 0)
|
|
46
|
-
};
|
|
47
|
-
var node = validateNode({
|
|
48
|
-
schema: state.schema,
|
|
49
|
-
maybeNode: maybeNode
|
|
50
|
-
});
|
|
51
|
-
if (!node) {
|
|
52
|
-
closeTypeAhead(tr);
|
|
53
|
-
// In this kind of situation we need to
|
|
54
|
-
// delete the raw text query
|
|
55
|
-
tr.delete(position.start, position.end);
|
|
56
|
-
return tr;
|
|
57
|
-
}
|
|
58
|
-
node instanceof PMNode && node.isBlock ? insertBlockNode({
|
|
59
|
-
node: node,
|
|
60
|
-
tr: tr,
|
|
61
|
-
position: position
|
|
62
|
-
}) : insertInlineNodeOrFragment({
|
|
63
|
-
maybeFragment: node,
|
|
64
|
-
tr: tr,
|
|
65
|
-
position: position,
|
|
66
|
-
selectInlineNode: Boolean(opts.selectInlineNode)
|
|
67
|
-
});
|
|
68
|
-
closeHistory(tr);
|
|
69
|
-
if (wasInsertedBySpace) {
|
|
70
|
-
return tr;
|
|
71
|
-
}
|
|
72
|
-
var config = {
|
|
73
|
-
stage: InsertTypeAheadStages.INSERTING_ITEM,
|
|
74
|
-
query: query,
|
|
75
|
-
selectedIndex: selectedIndex,
|
|
76
|
-
trigger: handler.trigger
|
|
77
|
-
};
|
|
78
|
-
tr.step(new InsertTypeAheadStep(config));
|
|
79
|
-
return tr;
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
var createDeleteRawTextCallback = function createDeleteRawTextCallback(_ref3) {
|
|
83
|
-
var trigger = _ref3.trigger,
|
|
84
|
-
selectedIndex = _ref3.selectedIndex,
|
|
85
|
-
position = _ref3.position,
|
|
86
|
-
query = _ref3.query,
|
|
87
|
-
wasInsertedBySpace = _ref3.wasInsertedBySpace,
|
|
88
|
-
insertItem = _ref3.insertItem;
|
|
89
|
-
return function (newState) {
|
|
90
|
-
var tr = newState.tr;
|
|
91
|
-
closeHistory(tr);
|
|
92
|
-
if (!wasInsertedBySpace) {
|
|
93
|
-
tr.delete(position.start, position.end);
|
|
94
|
-
var config = {
|
|
95
|
-
stage: InsertTypeAheadStages.DELETING_RAW_QUERY,
|
|
96
|
-
selectedIndex: selectedIndex,
|
|
97
|
-
query: query,
|
|
98
|
-
trigger: trigger
|
|
99
|
-
};
|
|
100
|
-
tr.step(new InsertTypeAheadStep(config));
|
|
101
|
-
}
|
|
102
|
-
tr.setMeta(pluginKey, {
|
|
103
|
-
action: ACTIONS.INSERT_ITEM,
|
|
104
|
-
params: insertItem
|
|
105
|
-
});
|
|
106
|
-
return tr;
|
|
107
|
-
};
|
|
108
|
-
};
|
|
109
|
-
export var insertTypeAheadItem = function insertTypeAheadItem(view) {
|
|
110
|
-
return function (_ref4) {
|
|
111
|
-
var item = _ref4.item,
|
|
112
|
-
handler = _ref4.handler,
|
|
113
|
-
mode = _ref4.mode,
|
|
114
|
-
query = _ref4.query,
|
|
115
|
-
sourceListItem = _ref4.sourceListItem;
|
|
116
|
-
var pluginState = getPluginState(view.state);
|
|
117
|
-
if (!pluginState) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
var stats = (pluginState.stats || new StatsModifier()).serialize();
|
|
121
|
-
var meta = {
|
|
122
|
-
mode: mode,
|
|
123
|
-
query: query,
|
|
124
|
-
stats: stats,
|
|
125
|
-
sourceListItem: sourceListItem
|
|
126
|
-
};
|
|
127
|
-
var tr = view.state.tr;
|
|
128
|
-
var trigger = handler.trigger;
|
|
129
|
-
var text = "".concat(trigger).concat(query);
|
|
130
|
-
if (mode === SelectItemMode.SPACE) {
|
|
131
|
-
text = text.trim().concat(' ');
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// We want to always persist selectedIndex as -1 upon selecting an item from typeahead
|
|
135
|
-
// in order to retain exist focus behaviour when undoing
|
|
136
|
-
var selectedIndex = -1;
|
|
137
|
-
var wasInsertedBySpace = mode === SelectItemMode.SPACE;
|
|
138
|
-
var textStartPosition = tr.selection.from;
|
|
139
|
-
var insertItem = function insertItem(newEditorSate) {
|
|
140
|
-
var insertCallback = createInsertCallback({
|
|
141
|
-
editorState: newEditorSate,
|
|
142
|
-
query: query,
|
|
143
|
-
mode: mode,
|
|
144
|
-
handler: handler,
|
|
145
|
-
wasInsertedBySpace: wasInsertedBySpace,
|
|
146
|
-
selectedIndex: selectedIndex,
|
|
147
|
-
textInserted: text,
|
|
148
|
-
textStartPosition: textStartPosition
|
|
149
|
-
});
|
|
150
|
-
var wasInsertCallbackCalled = false;
|
|
151
|
-
// Some wierd plugins doesn't call the insert item callback
|
|
152
|
-
// For example, the link quick insert item
|
|
153
|
-
// For those cases we need to make sure we are closing the typeahead
|
|
154
|
-
var proxyHandler = {
|
|
155
|
-
apply: function apply(target, _thisContext, argumentsList) {
|
|
156
|
-
wasInsertCallbackCalled = true;
|
|
157
|
-
return target.apply(void 0, _toConsumableArray(argumentsList));
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
var insertCallbackProxy = new Proxy(insertCallback, proxyHandler);
|
|
161
|
-
var nextTr = handler.selectItem(newEditorSate, item, insertCallbackProxy, meta);
|
|
162
|
-
if (!wasInsertCallbackCalled && nextTr) {
|
|
163
|
-
closeHistory(nextTr);
|
|
164
|
-
|
|
165
|
-
// In some cases we need to re-open the typeahead
|
|
166
|
-
// e.g.: addign mentions from the quick insert
|
|
167
|
-
//
|
|
168
|
-
// Today, the QuickInsert API doesn't have a tool
|
|
169
|
-
// to help on this. So the code below will close the typeahead
|
|
170
|
-
// only if there is no previous metadata about typeahead in the
|
|
171
|
-
// next transaction
|
|
172
|
-
if (!nextTr.getMeta(pluginKey)) {
|
|
173
|
-
closeTypeAhead(nextTr);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
return nextTr;
|
|
177
|
-
};
|
|
178
|
-
var position = {
|
|
179
|
-
start: tr.selection.from,
|
|
180
|
-
end: tr.selection.from + text.length
|
|
181
|
-
};
|
|
182
|
-
tr.setMeta(pluginKey, {
|
|
183
|
-
action: ACTIONS.INSERT_RAW_QUERY,
|
|
184
|
-
params: createDeleteRawTextCallback({
|
|
185
|
-
wasInsertedBySpace: wasInsertedBySpace,
|
|
186
|
-
selectedIndex: selectedIndex,
|
|
187
|
-
insertItem: insertItem,
|
|
188
|
-
position: position,
|
|
189
|
-
query: query,
|
|
190
|
-
trigger: trigger
|
|
191
|
-
})
|
|
192
|
-
});
|
|
193
|
-
tr.insertText(text);
|
|
194
|
-
closeHistory(tr);
|
|
195
|
-
view.dispatch(tr);
|
|
196
|
-
view.focus();
|
|
197
|
-
};
|
|
198
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { pluginKey as typeAheadPluginKey } from '../pm-plugins/key';
|
|
2
|
-
import { ACTIONS } from '../pm-plugins/actions';
|
|
3
|
-
export var updateListItem = function updateListItem(items) {
|
|
4
|
-
return function (state, dispatch) {
|
|
5
|
-
var tr = state.tr;
|
|
6
|
-
tr.setMeta(typeAheadPluginKey, {
|
|
7
|
-
action: ACTIONS.UPDATE_LIST_ITEMS,
|
|
8
|
-
params: {
|
|
9
|
-
items: items
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
if (dispatch) {
|
|
13
|
-
dispatch(tr);
|
|
14
|
-
}
|
|
15
|
-
return true;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { pluginKey as typeAheadPluginKey } from '../pm-plugins/key';
|
|
2
|
-
import { ACTIONS } from '../pm-plugins/actions';
|
|
3
|
-
export var updateQuery = function updateQuery(query) {
|
|
4
|
-
return function (state, dispatch) {
|
|
5
|
-
var pluginState = typeAheadPluginKey.getState(state);
|
|
6
|
-
if ((pluginState === null || pluginState === void 0 ? void 0 : pluginState.query) === query) {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
var tr = state.tr;
|
|
10
|
-
tr.setMeta(typeAheadPluginKey, {
|
|
11
|
-
action: ACTIONS.CHANGE_QUERY,
|
|
12
|
-
params: {
|
|
13
|
-
query: query
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
if (dispatch) {
|
|
17
|
-
dispatch(tr);
|
|
18
|
-
}
|
|
19
|
-
return true;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { pluginKey as typeAheadPluginKey } from '../pm-plugins/key';
|
|
2
|
-
import { ACTIONS } from '../pm-plugins/actions';
|
|
3
|
-
export var updateSelectedIndex = function updateSelectedIndex(selectedIndex) {
|
|
4
|
-
return function (state, dispatch) {
|
|
5
|
-
var pluginState = typeAheadPluginKey.getState(state);
|
|
6
|
-
if ((pluginState === null || pluginState === void 0 ? void 0 : pluginState.selectedIndex) === selectedIndex) {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
var tr = state.tr;
|
|
10
|
-
tr.setMeta(typeAheadPluginKey, {
|
|
11
|
-
action: ACTIONS.UPDATE_SELECTED_INDEX,
|
|
12
|
-
params: {
|
|
13
|
-
selectedIndex: selectedIndex
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
if (dispatch) {
|
|
17
|
-
dispatch(tr);
|
|
18
|
-
}
|
|
19
|
-
return true;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export var TYPE_AHEAD_DECORATION_KEY = 'typeahead_decoration_key';
|
|
2
|
-
export var TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE = 'typeaheadDecoration';
|
|
3
|
-
export var TYPE_AHEAD_POPUP_CONTENT_CLASS = 'fabric-editor-typeahead';
|
|
4
|
-
export var TYPE_AHEAD_DECORATION_ELEMENT_ID = 'typeahaed_decoration_element_id';
|
|
5
|
-
export var CloseSelectionOptions = /*#__PURE__*/function (CloseSelectionOptions) {
|
|
6
|
-
CloseSelectionOptions["BEFORE_TEXT_INSERTED"] = "BEFORE_TEXT_INSERTED";
|
|
7
|
-
CloseSelectionOptions["AFTER_TEXT_INSERTED"] = "AFTER_TEXT_INSERTED";
|
|
8
|
-
return CloseSelectionOptions;
|
|
9
|
-
}({});
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { TextSelection, NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
import { Node as PMNode, Slice, Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
import { safeInsert, normaliseNestedLayout } from '@atlaskit/editor-common/insert';
|
|
4
|
-
function findInsertPoint(doc, pos, nodeToInsert) {
|
|
5
|
-
var $pos = doc.resolve(pos);
|
|
6
|
-
var createInsertPosition = function createInsertPosition(from, to) {
|
|
7
|
-
return {
|
|
8
|
-
from: from,
|
|
9
|
-
to: to || from
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// Search for a valid position for nodeToInsert in progressively higher levels
|
|
14
|
-
for (var level = $pos.depth; level >= 0; level--) {
|
|
15
|
-
var nodeAtLevel = $pos.node(level);
|
|
16
|
-
|
|
17
|
-
// Try to replace the empty paragraph in the level above
|
|
18
|
-
// Scenario:
|
|
19
|
-
// doc(
|
|
20
|
-
// table(
|
|
21
|
-
// row(
|
|
22
|
-
// cell(
|
|
23
|
-
// p('{<>}'),
|
|
24
|
-
// ),
|
|
25
|
-
// )
|
|
26
|
-
// )
|
|
27
|
-
// )
|
|
28
|
-
var levelAbove = Math.max(level - 1, 0);
|
|
29
|
-
var parentNode = $pos.node(levelAbove);
|
|
30
|
-
// Special case: when this is true, the 'to' position should be the end
|
|
31
|
-
// of the empty paragraph
|
|
32
|
-
var isNodeAtLevelEmptyParagraph = nodeAtLevel.type.name === 'paragraph' && nodeAtLevel.content.size === 0;
|
|
33
|
-
var indexAtLevelAbove = $pos.index(levelAbove);
|
|
34
|
-
var canReplaceNodeAtLevelAbove = parentNode.canReplaceWith(indexAtLevelAbove, indexAtLevelAbove, nodeToInsert.type);
|
|
35
|
-
if (isNodeAtLevelEmptyParagraph && canReplaceNodeAtLevelAbove) {
|
|
36
|
-
var from = $pos.posAtIndex(indexAtLevelAbove, levelAbove);
|
|
37
|
-
return createInsertPosition(from, from + nodeAtLevel.nodeSize);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Try to insert this node right after the node in the level above
|
|
41
|
-
// Scenario:
|
|
42
|
-
// doc(
|
|
43
|
-
// panel(
|
|
44
|
-
// p('{<>}'),
|
|
45
|
-
// )
|
|
46
|
-
// )
|
|
47
|
-
var indexAfterAtLevelAbove = $pos.indexAfter(levelAbove);
|
|
48
|
-
var canInsertNodeAtLevelAbove = parentNode.canReplaceWith(indexAfterAtLevelAbove, indexAfterAtLevelAbove, nodeToInsert.type);
|
|
49
|
-
if (canInsertNodeAtLevelAbove) {
|
|
50
|
-
return createInsertPosition($pos.posAtIndex(indexAfterAtLevelAbove, levelAbove));
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return createInsertPosition(0);
|
|
54
|
-
}
|
|
55
|
-
export var insertBlockNode = function insertBlockNode(_ref) {
|
|
56
|
-
var node = _ref.node,
|
|
57
|
-
tr = _ref.tr,
|
|
58
|
-
position = _ref.position;
|
|
59
|
-
var start = position.start,
|
|
60
|
-
end = position.end;
|
|
61
|
-
if (node.isText) {
|
|
62
|
-
return tr.replaceWith(start, end, node);
|
|
63
|
-
}
|
|
64
|
-
if (node.isBlock) {
|
|
65
|
-
tr.delete(start, end);
|
|
66
|
-
var mappedStart = tr.mapping.map(start);
|
|
67
|
-
var nodeNormalized = normaliseNestedLayout(tr, node);
|
|
68
|
-
|
|
69
|
-
// Handle edge cases for hr and mediaSingle
|
|
70
|
-
var inserted = safeInsert(nodeNormalized, mappedStart)(tr);
|
|
71
|
-
if (inserted) {
|
|
72
|
-
return tr;
|
|
73
|
-
}
|
|
74
|
-
var sliceInserted = Slice.maxOpen(Fragment.from(nodeNormalized));
|
|
75
|
-
var _findInsertPoint = findInsertPoint(tr.doc, mappedStart, nodeNormalized),
|
|
76
|
-
from = _findInsertPoint.from,
|
|
77
|
-
to = _findInsertPoint.to;
|
|
78
|
-
tr.replaceWith(from, to, node);
|
|
79
|
-
var openPosition = Math.min(from + (node.isAtom ? node.nodeSize : sliceInserted.openStart), tr.doc.content.size);
|
|
80
|
-
var FORWARD_DIRECTION = 1;
|
|
81
|
-
var nextSelection = TextSelection.findFrom(tr.doc.resolve(openPosition), FORWARD_DIRECTION, true);
|
|
82
|
-
if (nextSelection) {
|
|
83
|
-
return tr.setSelection(nextSelection);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return tr;
|
|
87
|
-
};
|
|
88
|
-
export var insertInlineNodeOrFragment = function insertInlineNodeOrFragment(_ref2) {
|
|
89
|
-
var maybeFragment = _ref2.maybeFragment,
|
|
90
|
-
tr = _ref2.tr,
|
|
91
|
-
position = _ref2.position,
|
|
92
|
-
selectInlineNode = _ref2.selectInlineNode;
|
|
93
|
-
var start = position.start,
|
|
94
|
-
end = position.end;
|
|
95
|
-
var fragment = maybeFragment instanceof PMNode ? Fragment.from(maybeFragment) : maybeFragment;
|
|
96
|
-
tr.replaceWith(start, end, fragment);
|
|
97
|
-
if (selectInlineNode) {
|
|
98
|
-
return tr.setSelection(NodeSelection.create(tr.doc, start));
|
|
99
|
-
}
|
|
100
|
-
return tr.setSelection(TextSelection.near(tr.doc.resolve(start + fragment.size)));
|
|
101
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { defineMessages } from 'react-intl-next';
|
|
2
|
-
export var typeAheadListMessages = defineMessages({
|
|
3
|
-
typeAheadPopupLabel: {
|
|
4
|
-
id: 'fabric.editor.typeAhead.popupLabel',
|
|
5
|
-
defaultMessage: 'Typeahead results',
|
|
6
|
-
description: 'the result of a typeahead, similar to autocomplete results+'
|
|
7
|
-
},
|
|
8
|
-
quickInsertPopupLabel: {
|
|
9
|
-
id: 'fabric.editor.typeAhead.quickInsertPopupLabel',
|
|
10
|
-
defaultMessage: 'Shortcuts for inserts and formatting',
|
|
11
|
-
description: 'the result of a quick insert typeahead, similar to autocomplete results+'
|
|
12
|
-
},
|
|
13
|
-
quickInsertInputLabel: {
|
|
14
|
-
id: 'fabric.editor.typeAhead.quickInsertInputLabel',
|
|
15
|
-
defaultMessage: 'Begin typing to search or filter shortcut options',
|
|
16
|
-
description: 'assisitve text for typeahed input field'
|
|
17
|
-
},
|
|
18
|
-
emojiPopupLabel: {
|
|
19
|
-
id: 'fabric.editor.typeahead.emojiPopupLabel',
|
|
20
|
-
defaultMessage: 'Emoji shortcuts',
|
|
21
|
-
description: 'the result of a emoji typeahead, similar to autocomplete results+'
|
|
22
|
-
},
|
|
23
|
-
emojiInputLabel: {
|
|
24
|
-
id: 'fabric.editor.typeahead.emojiInputLabel',
|
|
25
|
-
defaultMessage: 'Begin typing to search or filter emoji options',
|
|
26
|
-
description: 'assisitve text for typeahed input field'
|
|
27
|
-
},
|
|
28
|
-
mentionPopupLabel: {
|
|
29
|
-
id: 'fabric.editor.typeahead.mentionPopupLabel',
|
|
30
|
-
defaultMessage: 'Users you can tag',
|
|
31
|
-
description: 'the aria label of a mention typeahead popup'
|
|
32
|
-
},
|
|
33
|
-
mentionInputLabel: {
|
|
34
|
-
id: 'fabric.editor.typeahead.mentionInputLabel',
|
|
35
|
-
defaultMessage: 'Begin typing to search for users to tag',
|
|
36
|
-
description: 'assisitve text for typeahed input field'
|
|
37
|
-
},
|
|
38
|
-
metionListItemLabel: {
|
|
39
|
-
id: 'fabric.editor.typeahead.metionListItemLabel',
|
|
40
|
-
defaultMessage: 'User {name} @{shortName}',
|
|
41
|
-
description: 'assistive text for user mention items username and nickname'
|
|
42
|
-
},
|
|
43
|
-
emojiListItemLabel: {
|
|
44
|
-
id: 'fabric.editor.typeahead.emojiListItemLabel',
|
|
45
|
-
defaultMessage: 'Emoji {name} Text Shortcut {shortcut}',
|
|
46
|
-
description: 'assistive text for emoji name and shortcut'
|
|
47
|
-
},
|
|
48
|
-
inputQueryAssistiveLabel: {
|
|
49
|
-
id: 'fabric.editor.inputQueryAssistiveTxt',
|
|
50
|
-
defaultMessage: 'When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.',
|
|
51
|
-
description: 'Assistive text to the user when using typeahead shortcut'
|
|
52
|
-
},
|
|
53
|
-
searchResultsLabel: {
|
|
54
|
-
id: 'fabric.editor.searchResults',
|
|
55
|
-
defaultMessage: '{itemsLength, plural, one {# search result} other {# search results}} available',
|
|
56
|
-
description: 'Assistive text to the user when using typeahead shortcut and it preceeds with a number - Ex: 10 search results available'
|
|
57
|
-
},
|
|
58
|
-
noSearchResultsLabel: {
|
|
59
|
-
id: 'fabric.editor.noSearchResults',
|
|
60
|
-
defaultMessage: 'No search results',
|
|
61
|
-
description: 'Assistive text to the user when using typeahead shortcut'
|
|
62
|
-
},
|
|
63
|
-
descriptionLabel: {
|
|
64
|
-
id: 'fabric.editor.description',
|
|
65
|
-
defaultMessage: 'Description',
|
|
66
|
-
description: 'Description'
|
|
67
|
-
},
|
|
68
|
-
shortcutLabel: {
|
|
69
|
-
id: 'fabric.editor.shortcut',
|
|
70
|
-
defaultMessage: 'Text shortcut',
|
|
71
|
-
description: 'Text shortcut'
|
|
72
|
-
}
|
|
73
|
-
});
|