@atlaskit/editor-core 187.30.10 → 187.31.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 +10 -0
- package/dist/cjs/index.js +2 -21
- 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/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/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
|
@@ -10,10 +10,6 @@ import { themed } from '@atlaskit/theme/components';
|
|
|
10
10
|
import { DN50, N0, N30A, N60A } from '@atlaskit/theme/colors';
|
|
11
11
|
import { IconCode, IconDate, IconDecision, IconDivider, IconExpand, IconPanel, IconQuote, IconStatus } from '@atlaskit/editor-common/quick-insert';
|
|
12
12
|
import withOuterListeners from '../with-outer-listeners';
|
|
13
|
-
import WithPluginState from '../WithPluginState';
|
|
14
|
-
import { pluginKey } from '../../plugins/quick-insert/plugin-key';
|
|
15
|
-
import { getFeaturedQuickInsertItems, searchQuickInsertItems } from '../../plugins/quick-insert/search';
|
|
16
|
-
import { insertItem } from '../../plugins/quick-insert/commands';
|
|
17
13
|
import ElementBrowser from './components/ElementBrowserLoader';
|
|
18
14
|
import { ELEMENT_ITEM_HEIGHT } from './constants';
|
|
19
15
|
const InsertMenu = ({
|
|
@@ -21,8 +17,10 @@ const InsertMenu = ({
|
|
|
21
17
|
dropdownItems,
|
|
22
18
|
showElementBrowserLink,
|
|
23
19
|
onInsert,
|
|
24
|
-
toggleVisiblity
|
|
20
|
+
toggleVisiblity,
|
|
21
|
+
pluginInjectionApi
|
|
25
22
|
}) => {
|
|
23
|
+
var _pluginInjectionApi$d10, _pluginInjectionApi$d11, _pluginInjectionApi$d12, _pluginInjectionApi$d13;
|
|
26
24
|
const [itemCount, setItemCount] = useState(0);
|
|
27
25
|
const transform = useCallback(item => ({
|
|
28
26
|
title: item.content,
|
|
@@ -45,13 +43,14 @@ const InsertMenu = ({
|
|
|
45
43
|
const quickInsertDropdownItems = dropdownItems.map(transform);
|
|
46
44
|
const viewMoreItem = showElementBrowserLink ? quickInsertDropdownItems.pop() : undefined;
|
|
47
45
|
const onInsertItem = useCallback(item => {
|
|
46
|
+
var _pluginInjectionApi$d;
|
|
48
47
|
toggleVisiblity();
|
|
49
48
|
if (!editorView.hasFocus()) {
|
|
50
49
|
editorView.focus();
|
|
51
50
|
}
|
|
52
|
-
insertItem(item)(editorView.state, editorView.dispatch);
|
|
53
|
-
}, [editorView, toggleVisiblity]);
|
|
54
|
-
const getItems = useCallback(
|
|
51
|
+
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);
|
|
52
|
+
}, [editorView, toggleVisiblity, pluginInjectionApi]);
|
|
53
|
+
const getItems = useCallback((query, category) => {
|
|
55
54
|
let result;
|
|
56
55
|
/**
|
|
57
56
|
* @warning The results if there is a query are not the same as the results if there is no query.
|
|
@@ -60,23 +59,35 @@ const InsertMenu = ({
|
|
|
60
59
|
* @see above transform function for more details.
|
|
61
60
|
*/
|
|
62
61
|
if (query) {
|
|
63
|
-
|
|
62
|
+
var _pluginInjectionApi$d2, _pluginInjectionApi$d3, _pluginInjectionApi$d4, _pluginInjectionApi$d5;
|
|
63
|
+
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({
|
|
64
|
+
query,
|
|
65
|
+
category
|
|
66
|
+
}));
|
|
67
|
+
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 : [];
|
|
64
68
|
} else {
|
|
65
|
-
|
|
69
|
+
var _pluginInjectionApi$d6, _pluginInjectionApi$d7, _pluginInjectionApi$d8, _pluginInjectionApi$d9;
|
|
70
|
+
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({
|
|
71
|
+
category,
|
|
72
|
+
featuredItems: true
|
|
73
|
+
}));
|
|
74
|
+
const 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 : [];
|
|
75
|
+
result = quickInsertDropdownItems.concat(featuredQuickInsertSuggestions);
|
|
66
76
|
}
|
|
67
77
|
setItemCount(result.length);
|
|
68
78
|
return result;
|
|
69
|
-
}, [quickInsertDropdownItems]);
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
79
|
+
}, [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]);
|
|
80
|
+
const 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;
|
|
81
|
+
return jsx("div", {
|
|
82
|
+
css: theme => insertMenuWrapper(theme, itemCount)
|
|
83
|
+
}, jsx(ElementBrowserWrapper, {
|
|
73
84
|
handleClickOutside: toggleVisiblity,
|
|
74
85
|
handleEscapeKeydown: toggleVisiblity,
|
|
75
86
|
closeOnTab: true
|
|
76
87
|
}, jsx(ElementBrowser, {
|
|
77
88
|
mode: "inline",
|
|
78
|
-
getItems: getItems
|
|
79
|
-
emptyStateHandler:
|
|
89
|
+
getItems: getItems,
|
|
90
|
+
emptyStateHandler: emptyStateHandler,
|
|
80
91
|
onInsertItem: onInsertItem,
|
|
81
92
|
showSearch: true,
|
|
82
93
|
showCategories: false
|
|
@@ -84,15 +95,7 @@ const InsertMenu = ({
|
|
|
84
95
|
,
|
|
85
96
|
key: quickInsertDropdownItems.length,
|
|
86
97
|
viewMoreItem: viewMoreItem
|
|
87
|
-
}))
|
|
88
|
-
return jsx("div", {
|
|
89
|
-
css: theme => insertMenuWrapper(theme, itemCount)
|
|
90
|
-
}, jsx(WithPluginState, {
|
|
91
|
-
plugins: {
|
|
92
|
-
quickInsertState: pluginKey
|
|
93
|
-
},
|
|
94
|
-
render: render
|
|
95
|
-
}));
|
|
98
|
+
})));
|
|
96
99
|
};
|
|
97
100
|
const getSvgIconForItem = ({
|
|
98
101
|
name
|
|
@@ -115,31 +115,6 @@ export const isInsideBlockQuote = state => {
|
|
|
115
115
|
} = state.schema.nodes;
|
|
116
116
|
return hasParentNodeOfType(blockquote)(state.selection);
|
|
117
117
|
};
|
|
118
|
-
export function dedupe(list = [], iteratee = p => p) {
|
|
119
|
-
/**
|
|
120
|
-
.,
|
|
121
|
-
. _,'f----.._
|
|
122
|
-
|\ ,-'"/ | ,'
|
|
123
|
-
|,_ ,--. /
|
|
124
|
-
/,-. ,'`. (_
|
|
125
|
-
f o| o|__ "`-.
|
|
126
|
-
,-._.,--'_ `. _.,-`
|
|
127
|
-
`"' ___.,'` j,-'
|
|
128
|
-
`-.__.,--'
|
|
129
|
-
Gotta go fast!
|
|
130
|
-
*/
|
|
131
|
-
|
|
132
|
-
const seen = new Set();
|
|
133
|
-
list.forEach(l => seen.add(iteratee(l)));
|
|
134
|
-
return list.filter(l => {
|
|
135
|
-
const it = iteratee(l);
|
|
136
|
-
if (seen.has(it)) {
|
|
137
|
-
seen.delete(it);
|
|
138
|
-
return true;
|
|
139
|
-
}
|
|
140
|
-
return false;
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
118
|
export { isTextSelection, isElementInTableCell, isLastItemMediaGroup, nonNullable } from '@atlaskit/editor-common/utils';
|
|
144
119
|
|
|
145
120
|
/** Helper type for single arg function */
|
package/dist/esm/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';
|
|
@@ -7,7 +7,6 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
7
7
|
import { bindKeymapWithCommand, openHelp, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
8
8
|
import WithPluginState from '../../ui/WithPluginState';
|
|
9
9
|
import { HelpDialogLoader } from './ui/HelpDialogLoader';
|
|
10
|
-
import { pluginKey as quickInsertPluginKey } from '../quick-insert';
|
|
11
10
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
12
11
|
import QuestionCircleIcon from '@atlaskit/icon/glyph/question-circle';
|
|
13
12
|
import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
|
|
@@ -95,17 +94,15 @@ var helpDialog = function helpDialog() {
|
|
|
95
94
|
var editorView = _ref3.editorView;
|
|
96
95
|
return /*#__PURE__*/React.createElement(WithPluginState, {
|
|
97
96
|
plugins: {
|
|
98
|
-
helpDialog: pluginKey
|
|
99
|
-
quickInsert: quickInsertPluginKey
|
|
97
|
+
helpDialog: pluginKey
|
|
100
98
|
},
|
|
101
99
|
render: function render(_ref4) {
|
|
102
100
|
var _ref4$helpDialog = _ref4.helpDialog,
|
|
103
|
-
helpDialog = _ref4$helpDialog === void 0 ? {} : _ref4$helpDialog
|
|
104
|
-
quickInsert = _ref4.quickInsert;
|
|
101
|
+
helpDialog = _ref4$helpDialog === void 0 ? {} : _ref4$helpDialog;
|
|
105
102
|
return /*#__PURE__*/React.createElement(HelpDialogLoader, {
|
|
106
103
|
editorView: editorView,
|
|
107
104
|
isVisible: helpDialog.isVisible,
|
|
108
|
-
quickInsertEnabled: !!quickInsert,
|
|
105
|
+
quickInsertEnabled: !!(api !== null && api !== void 0 && api.dependencies.quickInsert),
|
|
109
106
|
imageEnabled: helpDialog.imageEnabled
|
|
110
107
|
});
|
|
111
108
|
}
|
|
@@ -18,7 +18,8 @@ export var BlockInsertElementBrowser = function 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 var BlockInsertMenu = function 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, {
|
|
@@ -20,7 +20,6 @@ import { Popup } from '@atlaskit/editor-common/ui';
|
|
|
20
20
|
import ToolbarButton from '../../../../ui/ToolbarButton';
|
|
21
21
|
import { separatorStyles, buttonGroupStyle, wrapperStyle } from '@atlaskit/editor-common/styles';
|
|
22
22
|
import { insertDate } from '../../../date/actions';
|
|
23
|
-
import { openElementBrowserModal } from '../../../quick-insert/commands';
|
|
24
23
|
import { showPlaceholderFloatingToolbar } from '../../../placeholder-text/actions';
|
|
25
24
|
import { insertLayoutColumnsWithAnalytics } from '../../../layout/actions';
|
|
26
25
|
import { insertTaskDecisionCommand } from '../../../tasks-and-decisions/commands';
|
|
@@ -284,7 +283,9 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
284
283
|
return true;
|
|
285
284
|
});
|
|
286
285
|
_defineProperty(_assertThisInitialized(_this), "openElementBrowser", function () {
|
|
287
|
-
|
|
286
|
+
var _pluginInjectionApi$d10;
|
|
287
|
+
var pluginInjectionApi = _this.props.pluginInjectionApi;
|
|
288
|
+
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);
|
|
288
289
|
});
|
|
289
290
|
_defineProperty(_assertThisInitialized(_this), "onItemActivated", function (_ref2) {
|
|
290
291
|
var item = _ref2.item,
|
|
@@ -496,7 +497,8 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
496
497
|
onOpenChange: this.onOpenChange,
|
|
497
498
|
togglePlusMenuVisibility: this.togglePlusMenuVisibility,
|
|
498
499
|
replacePlusMenuWithElementBrowser: (_this$props$replacePl = this.props.replacePlusMenuWithElementBrowser) !== null && _this$props$replacePl !== void 0 ? _this$props$replacePl : false,
|
|
499
|
-
showElementBrowserLink: this.props.showElementBrowserLink || false
|
|
500
|
+
showElementBrowserLink: this.props.showElementBrowserLink || false,
|
|
501
|
+
pluginInjectionApi: this.props.pluginInjectionApi
|
|
500
502
|
})), this.props.showSeparator && jsx("span", {
|
|
501
503
|
css: separatorStyles
|
|
502
504
|
}));
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { insertSelectedItem } from '@atlaskit/editor-common/insert';
|
|
2
2
|
import { pluginKey } from './plugin-key';
|
|
3
|
-
export var openElementBrowserModal = function openElementBrowserModal() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}));
|
|
9
|
-
}
|
|
10
|
-
return true;
|
|
11
|
-
};
|
|
3
|
+
export var openElementBrowserModal = function openElementBrowserModal(_ref) {
|
|
4
|
+
var tr = _ref.tr;
|
|
5
|
+
return tr.setMeta(pluginKey, {
|
|
6
|
+
isElementBrowserModalOpen: true
|
|
7
|
+
});
|
|
12
8
|
};
|
|
13
9
|
export var closeElementBrowserModal = function closeElementBrowserModal() {
|
|
14
10
|
return function (state, dispatch) {
|
|
@@ -21,7 +17,7 @@ export var closeElementBrowserModal = function closeElementBrowserModal() {
|
|
|
21
17
|
};
|
|
22
18
|
};
|
|
23
19
|
|
|
24
|
-
// this method was adapted from the
|
|
20
|
+
// this method was adapted from the typeahead plugin so we respect the API for quick insert items
|
|
25
21
|
export var insertItem = function insertItem(item) {
|
|
26
22
|
return function (state, dispatch) {
|
|
27
23
|
var insert = function insert(maybeNode) {
|
|
@@ -5,16 +5,16 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
5
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
8
|
-
import memoizeOne from 'memoize-one';
|
|
9
8
|
import { TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
|
|
10
9
|
import { pluginKey } from './plugin-key';
|
|
11
|
-
import {
|
|
10
|
+
import { search } from './search';
|
|
12
11
|
import ModalElementBrowser from './ui/ModalElementBrowser';
|
|
13
|
-
|
|
12
|
+
import { openElementBrowserModal, insertItem } from './commands';
|
|
13
|
+
import { memoProcessQuickInsertItems, getQuickInsertSuggestions } from '@atlaskit/editor-common/quick-insert';
|
|
14
14
|
var quickInsertPlugin = function quickInsertPlugin(options) {
|
|
15
15
|
return {
|
|
16
16
|
name: 'quickInsert',
|
|
17
|
-
pmPlugins: function pmPlugins(
|
|
17
|
+
pmPlugins: function pmPlugins(defaultItems) {
|
|
18
18
|
return [{
|
|
19
19
|
name: 'quickInsert',
|
|
20
20
|
// It's important that this plugin is above TypeAheadPlugin
|
|
@@ -22,7 +22,7 @@ var quickInsertPlugin = function quickInsertPlugin(options) {
|
|
|
22
22
|
var providerFactory = _ref.providerFactory,
|
|
23
23
|
getIntl = _ref.getIntl,
|
|
24
24
|
dispatch = _ref.dispatch;
|
|
25
|
-
return quickInsertPluginFactory(
|
|
25
|
+
return quickInsertPluginFactory(defaultItems, providerFactory, getIntl, dispatch, options === null || options === void 0 ? void 0 : options.emptyStateHandler);
|
|
26
26
|
}
|
|
27
27
|
}];
|
|
28
28
|
},
|
|
@@ -30,12 +30,19 @@ var quickInsertPlugin = function quickInsertPlugin(options) {
|
|
|
30
30
|
typeAhead: {
|
|
31
31
|
id: TypeAheadAvailableNodes.QUICK_INSERT,
|
|
32
32
|
trigger: '/',
|
|
33
|
-
headless: options ? options.headless
|
|
33
|
+
headless: options === null || options === void 0 ? void 0 : options.headless,
|
|
34
34
|
getItems: function getItems(_ref2) {
|
|
35
35
|
var query = _ref2.query,
|
|
36
36
|
editorState = _ref2.editorState;
|
|
37
37
|
var quickInsertState = pluginKey.getState(editorState);
|
|
38
|
-
return Promise.resolve(
|
|
38
|
+
return Promise.resolve(getQuickInsertSuggestions({
|
|
39
|
+
searchOptions: {
|
|
40
|
+
query: query,
|
|
41
|
+
disableDefaultItems: options === null || options === void 0 ? void 0 : options.disableDefaultItems
|
|
42
|
+
},
|
|
43
|
+
lazyDefaultItems: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems,
|
|
44
|
+
providedItems: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems
|
|
45
|
+
}));
|
|
39
46
|
},
|
|
40
47
|
selectItem: function selectItem(state, item, insert) {
|
|
41
48
|
return item.action(insert, state);
|
|
@@ -44,51 +51,39 @@ var quickInsertPlugin = function quickInsertPlugin(options) {
|
|
|
44
51
|
},
|
|
45
52
|
contentComponent: function contentComponent(_ref3) {
|
|
46
53
|
var editorView = _ref3.editorView;
|
|
47
|
-
if (options && options.enableElementBrowser) {
|
|
54
|
+
if (options !== null && options !== void 0 && options.enableElementBrowser) {
|
|
48
55
|
return /*#__PURE__*/React.createElement(ModalElementBrowser, {
|
|
49
56
|
editorView: editorView,
|
|
50
|
-
helpUrl: options.elementBrowserHelpUrl
|
|
57
|
+
helpUrl: options === null || options === void 0 ? void 0 : options.elementBrowserHelpUrl
|
|
51
58
|
});
|
|
52
59
|
}
|
|
53
60
|
return null;
|
|
61
|
+
},
|
|
62
|
+
getSharedState: function getSharedState(editorState) {
|
|
63
|
+
var _quickInsertState$sug;
|
|
64
|
+
if (!editorState) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
var quickInsertState = pluginKey.getState(editorState);
|
|
68
|
+
if (!quickInsertState) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
suggestions: (_quickInsertState$sug = quickInsertState.suggestions) !== null && _quickInsertState$sug !== void 0 ? _quickInsertState$sug : [],
|
|
73
|
+
lazyDefaultItems: quickInsertState.lazyDefaultItems,
|
|
74
|
+
emptyStateHandler: quickInsertState.emptyStateHandler
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
actions: {
|
|
78
|
+
insertItem: insertItem
|
|
79
|
+
},
|
|
80
|
+
commands: {
|
|
81
|
+
search: search,
|
|
82
|
+
openElementBrowserModal: openElementBrowserModal
|
|
54
83
|
}
|
|
55
84
|
};
|
|
56
85
|
};
|
|
57
86
|
export default quickInsertPlugin;
|
|
58
|
-
var processItems = function processItems(items, intl, extendedActions) {
|
|
59
|
-
var reducedItems = items.reduce(function (acc, item) {
|
|
60
|
-
if (typeof item === 'function') {
|
|
61
|
-
var quickInsertItems = item(intl);
|
|
62
|
-
return acc.concat(quickInsertItems);
|
|
63
|
-
}
|
|
64
|
-
return acc.concat(item);
|
|
65
|
-
}, []);
|
|
66
|
-
return extendQuickInsertAction(reducedItems, extendedActions);
|
|
67
|
-
};
|
|
68
|
-
export var memoProcessItems = memoizeOne(processItems);
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Allows for extending the quickInsertItems actions with the provided extendedActions.
|
|
72
|
-
* The provided extended action will then be called after the original action is executed.
|
|
73
|
-
* This is useful for mobile communications where we need to talk to the mobile bridge.
|
|
74
|
-
*/
|
|
75
|
-
var extendQuickInsertAction = function extendQuickInsertAction(quickInsertItems, extendedActions) {
|
|
76
|
-
if (!extendedActions) {
|
|
77
|
-
return quickInsertItems;
|
|
78
|
-
}
|
|
79
|
-
return quickInsertItems.map(function (quickInsertItem) {
|
|
80
|
-
var quickInsertId = quickInsertItem.id;
|
|
81
|
-
if (quickInsertId && extendedActions[quickInsertId]) {
|
|
82
|
-
var originalAction = quickInsertItem.action;
|
|
83
|
-
quickInsertItem.action = function (insert, state) {
|
|
84
|
-
var result = originalAction(insert, state);
|
|
85
|
-
extendedActions[quickInsertId](quickInsertItem);
|
|
86
|
-
return result;
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
return quickInsertItem;
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
87
|
var setProviderState = function setProviderState(providerState) {
|
|
93
88
|
return function (state, dispatch) {
|
|
94
89
|
if (dispatch) {
|
|
@@ -97,7 +92,7 @@ var setProviderState = function setProviderState(providerState) {
|
|
|
97
92
|
return true;
|
|
98
93
|
};
|
|
99
94
|
};
|
|
100
|
-
function quickInsertPluginFactory(
|
|
95
|
+
function quickInsertPluginFactory(defaultItems, providerFactory, getIntl, dispatch, emptyStateHandler) {
|
|
101
96
|
return new SafePlugin({
|
|
102
97
|
key: pluginKey,
|
|
103
98
|
state: {
|
|
@@ -109,13 +104,21 @@ function quickInsertPluginFactory(quickInsertItems, providerFactory, getIntl, di
|
|
|
109
104
|
// memo here to avoid using a singleton cache, avoids editor
|
|
110
105
|
// getting confused when two editors exist within the same page.
|
|
111
106
|
lazyDefaultItems: function lazyDefaultItems() {
|
|
112
|
-
return
|
|
113
|
-
}
|
|
107
|
+
return memoProcessQuickInsertItems(defaultItems || [], getIntl());
|
|
108
|
+
},
|
|
109
|
+
suggestions: []
|
|
114
110
|
};
|
|
115
111
|
},
|
|
116
112
|
apply: function apply(tr, pluginState) {
|
|
117
113
|
var meta = tr.getMeta(pluginKey);
|
|
118
114
|
if (meta) {
|
|
115
|
+
if ('searchOptions' in meta) {
|
|
116
|
+
meta.suggestions = getQuickInsertSuggestions({
|
|
117
|
+
searchOptions: meta.searchOptions,
|
|
118
|
+
lazyDefaultItems: pluginState.lazyDefaultItems,
|
|
119
|
+
providedItems: pluginState.providedItems
|
|
120
|
+
});
|
|
121
|
+
}
|
|
119
122
|
var keys = Object.keys(meta);
|
|
120
123
|
var changed = keys.some(function (key) {
|
|
121
124
|
return pluginState[key] !== meta[key];
|
|
@@ -1,59 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
name: 'description',
|
|
17
|
-
weight: 0.04
|
|
18
|
-
}, {
|
|
19
|
-
name: 'keyshortcut',
|
|
20
|
-
weight: 0.01
|
|
21
|
-
}]
|
|
22
|
-
};
|
|
23
|
-
export function find(query, items) {
|
|
24
|
-
var fuse = new Fuse(items, options);
|
|
25
|
-
if (query === '') {
|
|
26
|
-
// Copy and sort list by priority
|
|
27
|
-
return items.slice(0).sort(function (a, b) {
|
|
28
|
-
return (a.priority || Number.POSITIVE_INFINITY) - (b.priority || Number.POSITIVE_INFINITY);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
return fuse.search(query).map(function (result) {
|
|
32
|
-
return result.item;
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
export var searchQuickInsertItems = function searchQuickInsertItems(quickInsertState, options) {
|
|
36
|
-
return function (query, category) {
|
|
37
|
-
var defaultItems = !quickInsertState || options && options.disableDefaultItems ? [] : quickInsertState.lazyDefaultItems();
|
|
38
|
-
var providedItems = quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems;
|
|
39
|
-
var items = providedItems ? dedupe([].concat(_toConsumableArray(defaultItems), _toConsumableArray(providedItems)), function (item) {
|
|
40
|
-
return item.title;
|
|
41
|
-
}) : defaultItems;
|
|
42
|
-
return find(query || '', category === 'all' || !category ? items : items.filter(function (item) {
|
|
43
|
-
return item.categories && item.categories.includes(category);
|
|
44
|
-
}));
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
export var getFeaturedQuickInsertItems = function getFeaturedQuickInsertItems(_ref, options) {
|
|
48
|
-
var providedItems = _ref.providedItems,
|
|
49
|
-
lazyDefaultItems = _ref.lazyDefaultItems;
|
|
50
|
-
return function () {
|
|
51
|
-
var defaultItems = options && options.disableDefaultItems ? [] : lazyDefaultItems();
|
|
52
|
-
var items = providedItems ? dedupe([].concat(_toConsumableArray(defaultItems), _toConsumableArray(providedItems)), function (item) {
|
|
53
|
-
return item.title;
|
|
54
|
-
}) : defaultItems;
|
|
55
|
-
return items.filter(function (item) {
|
|
56
|
-
return item.featured;
|
|
1
|
+
import { pluginKey } from './plugin-key';
|
|
2
|
+
export var search = function search(_ref) {
|
|
3
|
+
var query = _ref.query,
|
|
4
|
+
category = _ref.category,
|
|
5
|
+
disableDefaultItems = _ref.disableDefaultItems,
|
|
6
|
+
featuredItems = _ref.featuredItems;
|
|
7
|
+
return function (_ref2) {
|
|
8
|
+
var tr = _ref2.tr;
|
|
9
|
+
return tr.setMeta(pluginKey, {
|
|
10
|
+
searchOptions: {
|
|
11
|
+
query: query,
|
|
12
|
+
category: category,
|
|
13
|
+
disableDefaultItems: disableDefaultItems,
|
|
14
|
+
featuredItems: featuredItems
|
|
15
|
+
}
|
|
57
16
|
});
|
|
58
17
|
};
|
|
59
18
|
};
|
|
@@ -1,16 +1,23 @@
|
|
|
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
|
var Modal = function Modal(_ref) {
|
|
8
8
|
var quickInsertState = _ref.quickInsertState,
|
|
9
9
|
editorView = _ref.editorView,
|
|
10
10
|
helpUrl = _ref.helpUrl;
|
|
11
11
|
var getItems = useCallback(function (query, category) {
|
|
12
|
-
return
|
|
13
|
-
|
|
12
|
+
return getQuickInsertSuggestions({
|
|
13
|
+
searchOptions: {
|
|
14
|
+
query: query,
|
|
15
|
+
category: 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
|
+
});
|
|
20
|
+
}, [quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems]);
|
|
14
21
|
var focusInEditor = useCallback(function () {
|
|
15
22
|
if (!editorView.hasFocus()) {
|
|
16
23
|
editorView.focus();
|
|
@@ -29,8 +36,8 @@ var Modal = function Modal(_ref) {
|
|
|
29
36
|
getItems: getItems,
|
|
30
37
|
onInsertItem: onInsertItem,
|
|
31
38
|
helpUrl: helpUrl,
|
|
32
|
-
isOpen: quickInsertState
|
|
33
|
-
emptyStateHandler: quickInsertState
|
|
39
|
+
isOpen: (quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.isElementBrowserModalOpen) || false,
|
|
40
|
+
emptyStateHandler: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.emptyStateHandler,
|
|
34
41
|
onClose: onClose
|
|
35
42
|
});
|
|
36
43
|
};
|