@atlaskit/editor-core 187.30.10 → 187.31.1
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 +16 -0
- package/dist/cjs/index.js +2 -21
- package/dist/cjs/plugins/block-type/commands/block-type.js +1 -1
- package/dist/cjs/plugins/help-dialog/index.js +3 -6
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +2 -1
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.js +2 -1
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +11 -9
- package/dist/cjs/plugins/quick-insert/commands.js +6 -10
- package/dist/cjs/plugins/quick-insert/index.js +49 -52
- package/dist/cjs/plugins/quick-insert/search.js +17 -61
- package/dist/cjs/plugins/quick-insert/ui/ModalElementBrowser/index.js +12 -5
- package/dist/cjs/ui/ElementBrowser/InsertMenu.js +54 -54
- package/dist/cjs/utils/index.js +0 -32
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/index.js +7 -4
- package/dist/es2019/plugins/block-type/commands/block-type.js +1 -1
- package/dist/es2019/plugins/help-dialog/index.js +3 -6
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +2 -1
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.js +2 -1
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +7 -3
- package/dist/es2019/plugins/quick-insert/commands.js +6 -9
- package/dist/es2019/plugins/quick-insert/index.js +48 -45
- package/dist/es2019/plugins/quick-insert/search.js +15 -42
- package/dist/es2019/plugins/quick-insert/ui/ModalElementBrowser/index.js +11 -4
- package/dist/es2019/ui/ElementBrowser/InsertMenu.js +28 -25
- package/dist/es2019/utils/index.js +0 -25
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/index.js +7 -4
- package/dist/esm/plugins/block-type/commands/block-type.js +1 -1
- package/dist/esm/plugins/help-dialog/index.js +3 -6
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +2 -1
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.js +2 -1
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +5 -3
- package/dist/esm/plugins/quick-insert/commands.js +6 -10
- package/dist/esm/plugins/quick-insert/index.js +49 -46
- package/dist/esm/plugins/quick-insert/search.js +15 -56
- package/dist/esm/plugins/quick-insert/ui/ModalElementBrowser/index.js +12 -5
- package/dist/esm/ui/ElementBrowser/InsertMenu.js +54 -54
- package/dist/esm/utils/index.js +0 -31
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/index.d.ts +6 -3
- package/dist/types/labs/next/presets/default.d.ts +32 -0
- package/dist/types/plugins/help-dialog/index.d.ts +5 -1
- package/dist/types/plugins/insert-block/types.d.ts +3 -1
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.d.ts +3 -0
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.d.ts +3 -0
- package/dist/types/plugins/quick-insert/commands.d.ts +2 -2
- package/dist/types/plugins/quick-insert/index.d.ts +12 -9
- package/dist/types/plugins/quick-insert/search.d.ts +3 -5
- package/dist/types/ui/ElementBrowser/InsertMenu.d.ts +1 -1
- package/dist/types/ui/ElementBrowser/components/StatelessElementBrowser.d.ts +1 -1
- package/dist/types/ui/ElementBrowser/types.d.ts +3 -0
- package/dist/types/utils/index.d.ts +0 -1
- package/dist/types-ts4.5/index.d.ts +6 -3
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +32 -0
- package/dist/types-ts4.5/plugins/help-dialog/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/insert-block/types.d.ts +3 -1
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.d.ts +3 -0
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.d.ts +3 -0
- package/dist/types-ts4.5/plugins/quick-insert/commands.d.ts +2 -2
- package/dist/types-ts4.5/plugins/quick-insert/index.d.ts +12 -9
- package/dist/types-ts4.5/plugins/quick-insert/search.d.ts +3 -5
- package/dist/types-ts4.5/ui/ElementBrowser/InsertMenu.d.ts +1 -1
- package/dist/types-ts4.5/ui/ElementBrowser/components/StatelessElementBrowser.d.ts +1 -1
- package/dist/types-ts4.5/ui/ElementBrowser/types.d.ts +3 -0
- package/dist/types-ts4.5/utils/index.d.ts +0 -1
- package/package.json +2 -3
- package/report.api.md +2 -30
- package/tmp/api-report-tmp.d.ts +2 -21
- package/dist/cjs/plugins/quick-insert/api.js +0 -23
- package/dist/cjs/plugins/quick-insert/types.js +0 -5
- package/dist/es2019/plugins/quick-insert/api.js +0 -14
- package/dist/es2019/plugins/quick-insert/types.js +0 -1
- package/dist/esm/plugins/quick-insert/api.js +0 -16
- package/dist/esm/plugins/quick-insert/types.js +0 -1
- package/dist/types/plugins/quick-insert/api.d.ts +0 -6
- package/dist/types/plugins/quick-insert/types.d.ts +0 -4
- package/dist/types-ts4.5/plugins/quick-insert/api.d.ts +0 -6
- package/dist/types-ts4.5/plugins/quick-insert/types.d.ts +0 -4
|
@@ -16,10 +16,6 @@ var _components = require("@atlaskit/theme/components");
|
|
|
16
16
|
var _colors = require("@atlaskit/theme/colors");
|
|
17
17
|
var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
18
18
|
var _withOuterListeners = _interopRequireDefault(require("../with-outer-listeners"));
|
|
19
|
-
var _WithPluginState = _interopRequireDefault(require("../WithPluginState"));
|
|
20
|
-
var _pluginKey = require("../../plugins/quick-insert/plugin-key");
|
|
21
|
-
var _search = require("../../plugins/quick-insert/search");
|
|
22
|
-
var _commands = require("../../plugins/quick-insert/commands");
|
|
23
19
|
var _ElementBrowserLoader = _interopRequireDefault(require("./components/ElementBrowserLoader"));
|
|
24
20
|
var _constants = require("./constants");
|
|
25
21
|
var _excluded = ["children"];
|
|
@@ -28,11 +24,13 @@ var _templateObject, _templateObject2;
|
|
|
28
24
|
// AFP-2532 TODO: Fix automatic suppressions below
|
|
29
25
|
// eslint-disable-next-line @atlassian/tangerine/import/entry-points
|
|
30
26
|
var InsertMenu = function InsertMenu(_ref) {
|
|
27
|
+
var _pluginInjectionApi$d10, _pluginInjectionApi$d11, _pluginInjectionApi$d12, _pluginInjectionApi$d13;
|
|
31
28
|
var editorView = _ref.editorView,
|
|
32
29
|
dropdownItems = _ref.dropdownItems,
|
|
33
30
|
showElementBrowserLink = _ref.showElementBrowserLink,
|
|
34
31
|
onInsert = _ref.onInsert,
|
|
35
|
-
toggleVisiblity = _ref.toggleVisiblity
|
|
32
|
+
toggleVisiblity = _ref.toggleVisiblity,
|
|
33
|
+
pluginInjectionApi = _ref.pluginInjectionApi;
|
|
36
34
|
var _useState = (0, _react.useState)(0),
|
|
37
35
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
38
36
|
itemCount = _useState2[0],
|
|
@@ -64,62 +62,64 @@ var InsertMenu = function InsertMenu(_ref) {
|
|
|
64
62
|
var quickInsertDropdownItems = dropdownItems.map(transform);
|
|
65
63
|
var viewMoreItem = showElementBrowserLink ? quickInsertDropdownItems.pop() : undefined;
|
|
66
64
|
var onInsertItem = (0, _react.useCallback)(function (item) {
|
|
65
|
+
var _pluginInjectionApi$d;
|
|
67
66
|
toggleVisiblity();
|
|
68
67
|
if (!editorView.hasFocus()) {
|
|
69
68
|
editorView.focus();
|
|
70
69
|
}
|
|
71
|
-
(0
|
|
72
|
-
}, [editorView, toggleVisiblity]);
|
|
73
|
-
var getItems = (0, _react.useCallback)(function (
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
onInsertItem: onInsertItem,
|
|
102
|
-
showSearch: true,
|
|
103
|
-
showCategories: false
|
|
104
|
-
// On page resize we want the InlineElementBrowser to show updated tools/overflow items
|
|
105
|
-
,
|
|
106
|
-
key: quickInsertDropdownItems.length,
|
|
107
|
-
viewMoreItem: viewMoreItem
|
|
108
|
-
}));
|
|
109
|
-
}, [getItems, onInsertItem, quickInsertDropdownItems.length, toggleVisiblity, viewMoreItem]);
|
|
70
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies.quickInsert) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.actions.insertItem(item)(editorView.state, editorView.dispatch);
|
|
71
|
+
}, [editorView, toggleVisiblity, pluginInjectionApi]);
|
|
72
|
+
var getItems = (0, _react.useCallback)(function (query, category) {
|
|
73
|
+
var result;
|
|
74
|
+
/**
|
|
75
|
+
* @warning The results if there is a query are not the same as the results if there is no query.
|
|
76
|
+
* For example: If you have a typed panel and then select the panel item then it will call a different action
|
|
77
|
+
* than is specified on the editor plugins quick insert
|
|
78
|
+
* @see above transform function for more details.
|
|
79
|
+
*/
|
|
80
|
+
if (query) {
|
|
81
|
+
var _pluginInjectionApi$d2, _pluginInjectionApi$d3, _pluginInjectionApi$d4, _pluginInjectionApi$d5;
|
|
82
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d2 = pluginInjectionApi.dependencies.quickInsert) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.commands.search({
|
|
83
|
+
query: query,
|
|
84
|
+
category: category
|
|
85
|
+
}));
|
|
86
|
+
result = (_pluginInjectionApi$d3 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d4 = pluginInjectionApi.dependencies.quickInsert) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : (_pluginInjectionApi$d5 = _pluginInjectionApi$d4.sharedState.currentState()) === null || _pluginInjectionApi$d5 === void 0 ? void 0 : _pluginInjectionApi$d5.suggestions) !== null && _pluginInjectionApi$d3 !== void 0 ? _pluginInjectionApi$d3 : [];
|
|
87
|
+
} else {
|
|
88
|
+
var _pluginInjectionApi$d6, _pluginInjectionApi$d7, _pluginInjectionApi$d8, _pluginInjectionApi$d9;
|
|
89
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d6 = pluginInjectionApi.dependencies.quickInsert) === null || _pluginInjectionApi$d6 === void 0 ? void 0 : _pluginInjectionApi$d6.commands.search({
|
|
90
|
+
category: category,
|
|
91
|
+
featuredItems: true
|
|
92
|
+
}));
|
|
93
|
+
var featuredQuickInsertSuggestions = (_pluginInjectionApi$d7 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d8 = pluginInjectionApi.dependencies.quickInsert) === null || _pluginInjectionApi$d8 === void 0 ? void 0 : (_pluginInjectionApi$d9 = _pluginInjectionApi$d8.sharedState.currentState()) === null || _pluginInjectionApi$d9 === void 0 ? void 0 : _pluginInjectionApi$d9.suggestions) !== null && _pluginInjectionApi$d7 !== void 0 ? _pluginInjectionApi$d7 : [];
|
|
94
|
+
result = quickInsertDropdownItems.concat(featuredQuickInsertSuggestions);
|
|
95
|
+
}
|
|
96
|
+
setItemCount(result.length);
|
|
97
|
+
return result;
|
|
98
|
+
}, [pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.core.actions, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d10 = pluginInjectionApi.dependencies.quickInsert) === null || _pluginInjectionApi$d10 === void 0 ? void 0 : _pluginInjectionApi$d10.commands, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d11 = pluginInjectionApi.dependencies.quickInsert) === null || _pluginInjectionApi$d11 === void 0 ? void 0 : _pluginInjectionApi$d11.sharedState, quickInsertDropdownItems]);
|
|
99
|
+
var emptyStateHandler = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d12 = pluginInjectionApi.dependencies.quickInsert) === null || _pluginInjectionApi$d12 === void 0 ? void 0 : (_pluginInjectionApi$d13 = _pluginInjectionApi$d12.sharedState.currentState()) === null || _pluginInjectionApi$d13 === void 0 ? void 0 : _pluginInjectionApi$d13.emptyStateHandler;
|
|
110
100
|
return (0, _react2.jsx)("div", {
|
|
111
101
|
css: function css(theme) {
|
|
112
102
|
return insertMenuWrapper(theme, itemCount);
|
|
113
103
|
}
|
|
114
|
-
}, (0, _react2.jsx)(
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
104
|
+
}, (0, _react2.jsx)(ElementBrowserWrapper, {
|
|
105
|
+
handleClickOutside: toggleVisiblity,
|
|
106
|
+
handleEscapeKeydown: toggleVisiblity,
|
|
107
|
+
closeOnTab: true
|
|
108
|
+
}, (0, _react2.jsx)(_ElementBrowserLoader.default, {
|
|
109
|
+
mode: "inline",
|
|
110
|
+
getItems: getItems,
|
|
111
|
+
emptyStateHandler: emptyStateHandler,
|
|
112
|
+
onInsertItem: onInsertItem,
|
|
113
|
+
showSearch: true,
|
|
114
|
+
showCategories: false
|
|
115
|
+
// On page resize we want the InlineElementBrowser to show updated tools/overflow items
|
|
116
|
+
,
|
|
117
|
+
key: quickInsertDropdownItems.length,
|
|
118
|
+
viewMoreItem: viewMoreItem
|
|
119
|
+
})));
|
|
120
120
|
};
|
|
121
|
-
var getSvgIconForItem = function getSvgIconForItem(
|
|
122
|
-
var name =
|
|
121
|
+
var getSvgIconForItem = function getSvgIconForItem(_ref2) {
|
|
122
|
+
var name = _ref2.name;
|
|
123
123
|
var Icon = {
|
|
124
124
|
codeblock: _quickInsert.IconCode,
|
|
125
125
|
panel: _quickInsert.IconPanel,
|
|
@@ -134,8 +134,8 @@ var getSvgIconForItem = function getSvgIconForItem(_ref3) {
|
|
|
134
134
|
label: ""
|
|
135
135
|
}) : undefined;
|
|
136
136
|
};
|
|
137
|
-
var getInsertMenuHeight = function getInsertMenuHeight(
|
|
138
|
-
var itemCount =
|
|
137
|
+
var getInsertMenuHeight = function getInsertMenuHeight(_ref3) {
|
|
138
|
+
var itemCount = _ref3.itemCount;
|
|
139
139
|
// Figure based on visuals to exclude the searchbar, padding/margin, and the ViewMore item.
|
|
140
140
|
var EXTRA_SPACE_EXCLUDING_ELEMENTLIST = 112;
|
|
141
141
|
if (itemCount > 0 && itemCount < 6) {
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -17,7 +17,6 @@ Object.defineProperty(exports, "checkNodeDown", {
|
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
exports.compose = compose;
|
|
20
|
-
exports.dedupe = dedupe;
|
|
21
20
|
Object.defineProperty(exports, "findFarthestParentNode", {
|
|
22
21
|
enumerable: true,
|
|
23
22
|
get: function get() {
|
|
@@ -262,37 +261,6 @@ var isInsideBlockQuote = function isInsideBlockQuote(state) {
|
|
|
262
261
|
return (0, _utils.hasParentNodeOfType)(blockquote)(state.selection);
|
|
263
262
|
};
|
|
264
263
|
exports.isInsideBlockQuote = isInsideBlockQuote;
|
|
265
|
-
function dedupe() {
|
|
266
|
-
var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
267
|
-
var iteratee = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (p) {
|
|
268
|
-
return p;
|
|
269
|
-
};
|
|
270
|
-
/**
|
|
271
|
-
.,
|
|
272
|
-
. _,'f----.._
|
|
273
|
-
|\ ,-'"/ | ,'
|
|
274
|
-
|,_ ,--. /
|
|
275
|
-
/,-. ,'`. (_
|
|
276
|
-
f o| o|__ "`-.
|
|
277
|
-
,-._.,--'_ `. _.,-`
|
|
278
|
-
`"' ___.,'` j,-'
|
|
279
|
-
`-.__.,--'
|
|
280
|
-
Gotta go fast!
|
|
281
|
-
*/
|
|
282
|
-
|
|
283
|
-
var seen = new Set();
|
|
284
|
-
list.forEach(function (l) {
|
|
285
|
-
return seen.add(iteratee(l));
|
|
286
|
-
});
|
|
287
|
-
return list.filter(function (l) {
|
|
288
|
-
var it = iteratee(l);
|
|
289
|
-
if (seen.has(it)) {
|
|
290
|
-
seen.delete(it);
|
|
291
|
-
return true;
|
|
292
|
-
}
|
|
293
|
-
return false;
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
264
|
/** Helper type for single arg function */
|
|
297
265
|
|
|
298
266
|
/**
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.version = exports.nextMajorVersion = exports.name = void 0;
|
|
7
7
|
var name = "@atlaskit/editor-core";
|
|
8
8
|
exports.name = name;
|
|
9
|
-
var version = "187.
|
|
9
|
+
var version = "187.31.1";
|
|
10
10
|
exports.version = version;
|
|
11
11
|
var nextMajorVersion = function nextMajorVersion() {
|
|
12
12
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
package/dist/es2019/index.js
CHANGED
|
@@ -33,13 +33,17 @@ export { dateToDateType } from './plugins/date/utils/formatParse';
|
|
|
33
33
|
export { pluginKey as datePluginKey } from './plugins/date/pm-plugins/plugin-key';
|
|
34
34
|
export { commitStatusPicker, setStatusPickerAt, updateStatus, updateStatusWithAnalytics, removeStatus } from './plugins/status/actions';
|
|
35
35
|
export { typeAheadPluginKey } from './plugins/type-ahead';
|
|
36
|
-
export { pluginKey as quickInsertPluginKey, memoProcessItems as processQuickInsertItems } from './plugins/quick-insert';
|
|
37
36
|
export { historyPluginKey } from './plugins/history';
|
|
38
37
|
export { INPUT_METHOD, ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
39
38
|
export { setKeyboardHeight, setMobilePaddingTop, setIsExpanded } from './plugins/mobile-dimensions/commands';
|
|
40
39
|
|
|
41
40
|
// Used in editor-test-helpers and mobile bridge
|
|
42
|
-
export { setTextSelection,
|
|
41
|
+
export { setTextSelection, getNodesCount, measurements } from './utils';
|
|
42
|
+
export {
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated Use dedupe from @atlaskit/editor-common/utils instead
|
|
45
|
+
*/
|
|
46
|
+
dedupe } from '@atlaskit/editor-common/utils';
|
|
43
47
|
export { ReactEditorView, BaseReactEditorView } from './create-editor';
|
|
44
48
|
export { getDefaultPresetOptionsFromEditorProps } from './create-editor';
|
|
45
49
|
export { default as EditorActions } from './actions';
|
|
@@ -53,5 +57,4 @@ export { default as WithPluginState } from './ui/WithPluginState';
|
|
|
53
57
|
export { lightModeStatusColorPalette, darkModeStatusColorPalette } from './ui/ColorPalette/Palettes/statusColorPalette';
|
|
54
58
|
export { DEFAULT_BORDER_COLOR } from './ui/ColorPalette/Palettes/common';
|
|
55
59
|
export { default as messages, statusMessages, dateMessages } from './messages';
|
|
56
|
-
export { createTypeAheadTools } from './plugins/type-ahead/api';
|
|
57
|
-
export { createQuickInsertTools } from './plugins/quick-insert/api';
|
|
60
|
+
export { createTypeAheadTools } from './plugins/type-ahead/api';
|
|
@@ -239,7 +239,7 @@ export function createWrapSelectionTransaction({
|
|
|
239
239
|
tr.wrap(range, wrapping).scrollIntoView();
|
|
240
240
|
} else {
|
|
241
241
|
/** We always want to append a block type */
|
|
242
|
-
safeInsert(type.createAndFill())(tr).scrollIntoView();
|
|
242
|
+
safeInsert(type.createAndFill(nodeAttributes))(tr).scrollIntoView();
|
|
243
243
|
}
|
|
244
244
|
return tr;
|
|
245
245
|
}
|
|
@@ -4,7 +4,6 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
4
4
|
import { bindKeymapWithCommand, openHelp, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
5
5
|
import WithPluginState from '../../ui/WithPluginState';
|
|
6
6
|
import { HelpDialogLoader } from './ui/HelpDialogLoader';
|
|
7
|
-
import { pluginKey as quickInsertPluginKey } from '../quick-insert';
|
|
8
7
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
9
8
|
import QuestionCircleIcon from '@atlaskit/icon/glyph/question-circle';
|
|
10
9
|
import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
|
|
@@ -87,16 +86,14 @@ const helpDialog = (imageUploadProviderExists = false, api) => ({
|
|
|
87
86
|
}) {
|
|
88
87
|
return /*#__PURE__*/React.createElement(WithPluginState, {
|
|
89
88
|
plugins: {
|
|
90
|
-
helpDialog: pluginKey
|
|
91
|
-
quickInsert: quickInsertPluginKey
|
|
89
|
+
helpDialog: pluginKey
|
|
92
90
|
},
|
|
93
91
|
render: ({
|
|
94
|
-
helpDialog = {}
|
|
95
|
-
quickInsert
|
|
92
|
+
helpDialog = {}
|
|
96
93
|
}) => /*#__PURE__*/React.createElement(HelpDialogLoader, {
|
|
97
94
|
editorView: editorView,
|
|
98
95
|
isVisible: helpDialog.isVisible,
|
|
99
|
-
quickInsertEnabled: !!quickInsert,
|
|
96
|
+
quickInsertEnabled: !!(api !== null && api !== void 0 && api.dependencies.quickInsert),
|
|
100
97
|
imageEnabled: helpDialog.imageEnabled
|
|
101
98
|
})
|
|
102
99
|
});
|
package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js
CHANGED
|
@@ -18,7 +18,8 @@ export const BlockInsertElementBrowser = props => {
|
|
|
18
18
|
dropdownItems: props.items,
|
|
19
19
|
onInsert: props.onInsert,
|
|
20
20
|
toggleVisiblity: props.togglePlusMenuVisibility,
|
|
21
|
-
showElementBrowserLink: props.showElementBrowserLink
|
|
21
|
+
showElementBrowserLink: props.showElementBrowserLink,
|
|
22
|
+
pluginInjectionApi: props.pluginInjectionApi
|
|
22
23
|
})), /*#__PURE__*/React.createElement(DropDownButton, {
|
|
23
24
|
"aria-expanded": props.open,
|
|
24
25
|
"aria-haspopup": true,
|
|
@@ -37,7 +37,8 @@ export const BlockInsertMenu = props => {
|
|
|
37
37
|
popupsScrollableElement: props.popupsScrollableElement,
|
|
38
38
|
spacing: props.spacing,
|
|
39
39
|
togglePlusMenuVisibility: props.togglePlusMenuVisibility,
|
|
40
|
-
showElementBrowserLink: props.showElementBrowserLink
|
|
40
|
+
showElementBrowserLink: props.showElementBrowserLink,
|
|
41
|
+
pluginInjectionApi: props.pluginInjectionApi
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
44
|
return /*#__PURE__*/React.createElement(BlockInsertMenuLegacy, {
|
|
@@ -9,7 +9,6 @@ import { Popup } from '@atlaskit/editor-common/ui';
|
|
|
9
9
|
import ToolbarButton from '../../../../ui/ToolbarButton';
|
|
10
10
|
import { separatorStyles, buttonGroupStyle, wrapperStyle } from '@atlaskit/editor-common/styles';
|
|
11
11
|
import { insertDate } from '../../../date/actions';
|
|
12
|
-
import { openElementBrowserModal } from '../../../quick-insert/commands';
|
|
13
12
|
import { showPlaceholderFloatingToolbar } from '../../../placeholder-text/actions';
|
|
14
13
|
import { insertLayoutColumnsWithAnalytics } from '../../../layout/actions';
|
|
15
14
|
import { insertTaskDecisionCommand } from '../../../tasks-and-decisions/commands';
|
|
@@ -292,7 +291,11 @@ export class ToolbarInsertBlock extends React.PureComponent {
|
|
|
292
291
|
return true;
|
|
293
292
|
});
|
|
294
293
|
_defineProperty(this, "openElementBrowser", () => {
|
|
295
|
-
|
|
294
|
+
var _pluginInjectionApi$d10;
|
|
295
|
+
const {
|
|
296
|
+
pluginInjectionApi
|
|
297
|
+
} = this.props;
|
|
298
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d10 = pluginInjectionApi.dependencies.quickInsert) === null || _pluginInjectionApi$d10 === void 0 ? void 0 : _pluginInjectionApi$d10.commands.openElementBrowserModal);
|
|
296
299
|
});
|
|
297
300
|
_defineProperty(this, "onItemActivated", ({
|
|
298
301
|
item,
|
|
@@ -538,7 +541,8 @@ export class ToolbarInsertBlock extends React.PureComponent {
|
|
|
538
541
|
onOpenChange: this.onOpenChange,
|
|
539
542
|
togglePlusMenuVisibility: this.togglePlusMenuVisibility,
|
|
540
543
|
replacePlusMenuWithElementBrowser: (_this$props$replacePl = this.props.replacePlusMenuWithElementBrowser) !== null && _this$props$replacePl !== void 0 ? _this$props$replacePl : false,
|
|
541
|
-
showElementBrowserLink: this.props.showElementBrowserLink || false
|
|
544
|
+
showElementBrowserLink: this.props.showElementBrowserLink || false,
|
|
545
|
+
pluginInjectionApi: this.props.pluginInjectionApi
|
|
542
546
|
})), this.props.showSeparator && jsx("span", {
|
|
543
547
|
css: separatorStyles
|
|
544
548
|
}));
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { insertSelectedItem } from '@atlaskit/editor-common/insert';
|
|
2
2
|
import { pluginKey } from './plugin-key';
|
|
3
|
-
export const openElementBrowserModal = (
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
return true;
|
|
10
|
-
};
|
|
3
|
+
export const openElementBrowserModal = ({
|
|
4
|
+
tr
|
|
5
|
+
}) => tr.setMeta(pluginKey, {
|
|
6
|
+
isElementBrowserModalOpen: true
|
|
7
|
+
});
|
|
11
8
|
export const closeElementBrowserModal = () => (state, dispatch) => {
|
|
12
9
|
if (dispatch) {
|
|
13
10
|
dispatch(state.tr.setMeta(pluginKey, {
|
|
@@ -17,7 +14,7 @@ export const closeElementBrowserModal = () => (state, dispatch) => {
|
|
|
17
14
|
return true;
|
|
18
15
|
};
|
|
19
16
|
|
|
20
|
-
// this method was adapted from the
|
|
17
|
+
// this method was adapted from the typeahead plugin so we respect the API for quick insert items
|
|
21
18
|
export const insertItem = item => (state, dispatch) => {
|
|
22
19
|
const insert = (maybeNode, opts = {}) => {
|
|
23
20
|
return insertSelectedItem(maybeNode, opts)(state, state.tr, state.selection.head);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
import memoizeOne from 'memoize-one';
|
|
4
3
|
import { TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
|
|
5
4
|
import { pluginKey } from './plugin-key';
|
|
6
|
-
import {
|
|
5
|
+
import { search } from './search';
|
|
7
6
|
import ModalElementBrowser from './ui/ModalElementBrowser';
|
|
8
|
-
|
|
7
|
+
import { openElementBrowserModal, insertItem } from './commands';
|
|
8
|
+
import { memoProcessQuickInsertItems, getQuickInsertSuggestions } from '@atlaskit/editor-common/quick-insert';
|
|
9
9
|
const quickInsertPlugin = options => ({
|
|
10
10
|
name: 'quickInsert',
|
|
11
|
-
pmPlugins(
|
|
11
|
+
pmPlugins(defaultItems) {
|
|
12
12
|
return [{
|
|
13
13
|
name: 'quickInsert',
|
|
14
14
|
// It's important that this plugin is above TypeAheadPlugin
|
|
@@ -16,20 +16,27 @@ const quickInsertPlugin = options => ({
|
|
|
16
16
|
providerFactory,
|
|
17
17
|
getIntl,
|
|
18
18
|
dispatch
|
|
19
|
-
}) => quickInsertPluginFactory(
|
|
19
|
+
}) => quickInsertPluginFactory(defaultItems, providerFactory, getIntl, dispatch, options === null || options === void 0 ? void 0 : options.emptyStateHandler)
|
|
20
20
|
}];
|
|
21
21
|
},
|
|
22
22
|
pluginsOptions: {
|
|
23
23
|
typeAhead: {
|
|
24
24
|
id: TypeAheadAvailableNodes.QUICK_INSERT,
|
|
25
25
|
trigger: '/',
|
|
26
|
-
headless: options ? options.headless
|
|
26
|
+
headless: options === null || options === void 0 ? void 0 : options.headless,
|
|
27
27
|
getItems({
|
|
28
28
|
query,
|
|
29
29
|
editorState
|
|
30
30
|
}) {
|
|
31
31
|
const quickInsertState = pluginKey.getState(editorState);
|
|
32
|
-
return Promise.resolve(
|
|
32
|
+
return Promise.resolve(getQuickInsertSuggestions({
|
|
33
|
+
searchOptions: {
|
|
34
|
+
query,
|
|
35
|
+
disableDefaultItems: options === null || options === void 0 ? void 0 : options.disableDefaultItems
|
|
36
|
+
},
|
|
37
|
+
lazyDefaultItems: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems,
|
|
38
|
+
providedItems: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems
|
|
39
|
+
}));
|
|
33
40
|
},
|
|
34
41
|
selectItem: (state, item, insert) => {
|
|
35
42
|
return item.action(insert, state);
|
|
@@ -39,57 +46,45 @@ const quickInsertPlugin = options => ({
|
|
|
39
46
|
contentComponent({
|
|
40
47
|
editorView
|
|
41
48
|
}) {
|
|
42
|
-
if (options && options.enableElementBrowser) {
|
|
49
|
+
if (options !== null && options !== void 0 && options.enableElementBrowser) {
|
|
43
50
|
return /*#__PURE__*/React.createElement(ModalElementBrowser, {
|
|
44
51
|
editorView: editorView,
|
|
45
|
-
helpUrl: options.elementBrowserHelpUrl
|
|
52
|
+
helpUrl: options === null || options === void 0 ? void 0 : options.elementBrowserHelpUrl
|
|
46
53
|
});
|
|
47
54
|
}
|
|
48
55
|
return null;
|
|
56
|
+
},
|
|
57
|
+
getSharedState(editorState) {
|
|
58
|
+
var _quickInsertState$sug;
|
|
59
|
+
if (!editorState) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
const quickInsertState = pluginKey.getState(editorState);
|
|
63
|
+
if (!quickInsertState) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
suggestions: (_quickInsertState$sug = quickInsertState.suggestions) !== null && _quickInsertState$sug !== void 0 ? _quickInsertState$sug : [],
|
|
68
|
+
lazyDefaultItems: quickInsertState.lazyDefaultItems,
|
|
69
|
+
emptyStateHandler: quickInsertState.emptyStateHandler
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
actions: {
|
|
73
|
+
insertItem
|
|
74
|
+
},
|
|
75
|
+
commands: {
|
|
76
|
+
search,
|
|
77
|
+
openElementBrowserModal
|
|
49
78
|
}
|
|
50
79
|
});
|
|
51
80
|
export default quickInsertPlugin;
|
|
52
|
-
const processItems = (items, intl, extendedActions) => {
|
|
53
|
-
const reducedItems = items.reduce((acc, item) => {
|
|
54
|
-
if (typeof item === 'function') {
|
|
55
|
-
const quickInsertItems = item(intl);
|
|
56
|
-
return acc.concat(quickInsertItems);
|
|
57
|
-
}
|
|
58
|
-
return acc.concat(item);
|
|
59
|
-
}, []);
|
|
60
|
-
return extendQuickInsertAction(reducedItems, extendedActions);
|
|
61
|
-
};
|
|
62
|
-
export const memoProcessItems = memoizeOne(processItems);
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Allows for extending the quickInsertItems actions with the provided extendedActions.
|
|
66
|
-
* The provided extended action will then be called after the original action is executed.
|
|
67
|
-
* This is useful for mobile communications where we need to talk to the mobile bridge.
|
|
68
|
-
*/
|
|
69
|
-
const extendQuickInsertAction = (quickInsertItems, extendedActions) => {
|
|
70
|
-
if (!extendedActions) {
|
|
71
|
-
return quickInsertItems;
|
|
72
|
-
}
|
|
73
|
-
return quickInsertItems.map(quickInsertItem => {
|
|
74
|
-
const quickInsertId = quickInsertItem.id;
|
|
75
|
-
if (quickInsertId && extendedActions[quickInsertId]) {
|
|
76
|
-
const originalAction = quickInsertItem.action;
|
|
77
|
-
quickInsertItem.action = (insert, state) => {
|
|
78
|
-
const result = originalAction(insert, state);
|
|
79
|
-
extendedActions[quickInsertId](quickInsertItem);
|
|
80
|
-
return result;
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
return quickInsertItem;
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
81
|
const setProviderState = providerState => (state, dispatch) => {
|
|
87
82
|
if (dispatch) {
|
|
88
83
|
dispatch(state.tr.setMeta(pluginKey, providerState));
|
|
89
84
|
}
|
|
90
85
|
return true;
|
|
91
86
|
};
|
|
92
|
-
function quickInsertPluginFactory(
|
|
87
|
+
function quickInsertPluginFactory(defaultItems, providerFactory, getIntl, dispatch, emptyStateHandler) {
|
|
93
88
|
return new SafePlugin({
|
|
94
89
|
key: pluginKey,
|
|
95
90
|
state: {
|
|
@@ -100,12 +95,20 @@ function quickInsertPluginFactory(quickInsertItems, providerFactory, getIntl, di
|
|
|
100
95
|
// lazy so it doesn't run on editor initialization
|
|
101
96
|
// memo here to avoid using a singleton cache, avoids editor
|
|
102
97
|
// getting confused when two editors exist within the same page.
|
|
103
|
-
lazyDefaultItems: () =>
|
|
98
|
+
lazyDefaultItems: () => memoProcessQuickInsertItems(defaultItems || [], getIntl()),
|
|
99
|
+
suggestions: []
|
|
104
100
|
};
|
|
105
101
|
},
|
|
106
102
|
apply(tr, pluginState) {
|
|
107
103
|
const meta = tr.getMeta(pluginKey);
|
|
108
104
|
if (meta) {
|
|
105
|
+
if ('searchOptions' in meta) {
|
|
106
|
+
meta.suggestions = getQuickInsertSuggestions({
|
|
107
|
+
searchOptions: meta.searchOptions,
|
|
108
|
+
lazyDefaultItems: pluginState.lazyDefaultItems,
|
|
109
|
+
providedItems: pluginState.providedItems
|
|
110
|
+
});
|
|
111
|
+
}
|
|
109
112
|
const keys = Object.keys(meta);
|
|
110
113
|
const changed = keys.some(key => {
|
|
111
114
|
return pluginState[key] !== meta[key];
|
|
@@ -1,43 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
name: 'description',
|
|
16
|
-
weight: 0.04
|
|
17
|
-
}, {
|
|
18
|
-
name: 'keyshortcut',
|
|
19
|
-
weight: 0.01
|
|
20
|
-
}]
|
|
21
|
-
};
|
|
22
|
-
export function find(query, items) {
|
|
23
|
-
const fuse = new Fuse(items, options);
|
|
24
|
-
if (query === '') {
|
|
25
|
-
// Copy and sort list by priority
|
|
26
|
-
return items.slice(0).sort((a, b) => (a.priority || Number.POSITIVE_INFINITY) - (b.priority || Number.POSITIVE_INFINITY));
|
|
1
|
+
import { pluginKey } from './plugin-key';
|
|
2
|
+
export const search = ({
|
|
3
|
+
query,
|
|
4
|
+
category,
|
|
5
|
+
disableDefaultItems,
|
|
6
|
+
featuredItems
|
|
7
|
+
}) => ({
|
|
8
|
+
tr
|
|
9
|
+
}) => tr.setMeta(pluginKey, {
|
|
10
|
+
searchOptions: {
|
|
11
|
+
query,
|
|
12
|
+
category,
|
|
13
|
+
disableDefaultItems,
|
|
14
|
+
featuredItems
|
|
27
15
|
}
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
export const searchQuickInsertItems = (quickInsertState, options) => (query, category) => {
|
|
31
|
-
const defaultItems = !quickInsertState || options && options.disableDefaultItems ? [] : quickInsertState.lazyDefaultItems();
|
|
32
|
-
const providedItems = quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems;
|
|
33
|
-
const items = providedItems ? dedupe([...defaultItems, ...providedItems], item => item.title) : defaultItems;
|
|
34
|
-
return find(query || '', category === 'all' || !category ? items : items.filter(item => item.categories && item.categories.includes(category)));
|
|
35
|
-
};
|
|
36
|
-
export const getFeaturedQuickInsertItems = ({
|
|
37
|
-
providedItems,
|
|
38
|
-
lazyDefaultItems
|
|
39
|
-
}, options) => () => {
|
|
40
|
-
const defaultItems = options && options.disableDefaultItems ? [] : lazyDefaultItems();
|
|
41
|
-
const items = providedItems ? dedupe([...defaultItems, ...providedItems], item => item.title) : defaultItems;
|
|
42
|
-
return items.filter(item => item.featured);
|
|
43
|
-
};
|
|
16
|
+
});
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import WithPluginState from '../../../../ui/WithPluginState';
|
|
3
3
|
import { pluginKey } from '../../plugin-key';
|
|
4
|
-
import { searchQuickInsertItems } from '../../search';
|
|
5
4
|
import ModalElementBrowser from '../../../../ui/ElementBrowser/ModalElementBrowser';
|
|
6
5
|
import { closeElementBrowserModal, insertItem } from '../../commands';
|
|
6
|
+
import { getQuickInsertSuggestions } from '@atlaskit/editor-common/quick-insert';
|
|
7
7
|
const Modal = ({
|
|
8
8
|
quickInsertState,
|
|
9
9
|
editorView,
|
|
10
10
|
helpUrl
|
|
11
11
|
}) => {
|
|
12
|
-
const getItems = useCallback((query, category) =>
|
|
12
|
+
const getItems = useCallback((query, category) => getQuickInsertSuggestions({
|
|
13
|
+
searchOptions: {
|
|
14
|
+
query,
|
|
15
|
+
category
|
|
16
|
+
},
|
|
17
|
+
lazyDefaultItems: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems,
|
|
18
|
+
providedItems: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems
|
|
19
|
+
}), [quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems]);
|
|
13
20
|
const focusInEditor = useCallback(() => {
|
|
14
21
|
if (!editorView.hasFocus()) {
|
|
15
22
|
editorView.focus();
|
|
@@ -28,8 +35,8 @@ const Modal = ({
|
|
|
28
35
|
getItems: getItems,
|
|
29
36
|
onInsertItem: onInsertItem,
|
|
30
37
|
helpUrl: helpUrl,
|
|
31
|
-
isOpen: quickInsertState
|
|
32
|
-
emptyStateHandler: quickInsertState
|
|
38
|
+
isOpen: (quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.isElementBrowserModalOpen) || false,
|
|
39
|
+
emptyStateHandler: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.emptyStateHandler,
|
|
33
40
|
onClose: onClose
|
|
34
41
|
});
|
|
35
42
|
};
|