@atlaskit/editor-core 187.43.8 → 187.43.12
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 +15 -0
- package/dist/cjs/labs/next/presets/default.js +2 -2
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +1 -1
- package/dist/cjs/plugins/media/pm-plugins/main.js +6 -0
- package/dist/cjs/plugins/media/toolbar/index.js +3 -5
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/taskItem.js +3 -1
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/helpers.js +111 -2
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/main.js +108 -7
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/types.js +12 -0
- 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/media/nodeviews/mediaSingle.js +1 -1
- package/dist/es2019/plugins/media/pm-plugins/main.js +6 -0
- package/dist/es2019/plugins/media/toolbar/index.js +3 -7
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/taskItem.js +4 -1
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/helpers.js +121 -1
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/main.js +113 -5
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/types.js +5 -0
- 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/media/nodeviews/mediaSingle.js +1 -1
- package/dist/esm/plugins/media/pm-plugins/main.js +6 -0
- package/dist/esm/plugins/media/toolbar/index.js +3 -5
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/taskItem.js +3 -1
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/helpers.js +102 -1
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/main.js +106 -5
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/types.js +5 -0
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/help-dialog/index.d.ts +4 -4
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/plugins/insert-block/types.d.ts +2 -2
- package/dist/types/plugins/media/pm-plugins/main.d.ts +1 -0
- package/dist/types/plugins/media/pm-plugins/types.d.ts +1 -0
- package/dist/types/plugins/tasks-and-decisions/pm-plugins/helpers.d.ts +23 -1
- package/dist/types/plugins/tasks-and-decisions/pm-plugins/types.d.ts +8 -0
- package/dist/types/plugins/tasks-and-decisions/ui/Task/index.d.ts +1 -0
- package/dist/types/plugins/tasks-and-decisions/ui/Task/task-item-with-providers.d.ts +1 -0
- package/dist/types-ts4.5/plugins/help-dialog/index.d.ts +4 -4
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/insert-block/types.d.ts +2 -2
- package/dist/types-ts4.5/plugins/media/pm-plugins/main.d.ts +1 -0
- package/dist/types-ts4.5/plugins/media/pm-plugins/types.d.ts +1 -0
- package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/helpers.d.ts +23 -1
- package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/types.d.ts +8 -0
- package/dist/types-ts4.5/plugins/tasks-and-decisions/ui/Task/index.d.ts +1 -0
- package/dist/types-ts4.5/plugins/tasks-and-decisions/ui/Task/task-item-with-providers.d.ts +1 -0
- package/package.json +7 -6
- package/report.api.md +2 -0
- package/tmp/api-report-tmp.d.ts +2 -0
- package/dist/cjs/plugins/quick-insert/commands.js +0 -44
- package/dist/cjs/plugins/quick-insert/index.js +0 -189
- package/dist/cjs/plugins/quick-insert/plugin-key.js +0 -9
- package/dist/cjs/plugins/quick-insert/search.js +0 -33
- package/dist/cjs/plugins/quick-insert/ui/ModalElementBrowser/ModalElementBrowser.js +0 -140
- package/dist/cjs/plugins/quick-insert/ui/ModalElementBrowser/categories.js +0 -100
- package/dist/cjs/plugins/quick-insert/ui/ModalElementBrowser/index.js +0 -61
- package/dist/cjs/plugins/quick-insert/ui/ModalElementBrowser/messages.js +0 -15
- package/dist/es2019/plugins/quick-insert/commands.js +0 -29
- package/dist/es2019/plugins/quick-insert/index.js +0 -151
- package/dist/es2019/plugins/quick-insert/plugin-key.js +0 -2
- package/dist/es2019/plugins/quick-insert/search.js +0 -16
- package/dist/es2019/plugins/quick-insert/ui/ModalElementBrowser/ModalElementBrowser.js +0 -137
- package/dist/es2019/plugins/quick-insert/ui/ModalElementBrowser/categories.js +0 -94
- package/dist/es2019/plugins/quick-insert/ui/ModalElementBrowser/index.js +0 -51
- package/dist/es2019/plugins/quick-insert/ui/ModalElementBrowser/messages.js +0 -8
- package/dist/esm/plugins/quick-insert/commands.js +0 -35
- package/dist/esm/plugins/quick-insert/index.js +0 -181
- package/dist/esm/plugins/quick-insert/plugin-key.js +0 -2
- package/dist/esm/plugins/quick-insert/search.js +0 -25
- package/dist/esm/plugins/quick-insert/ui/ModalElementBrowser/ModalElementBrowser.js +0 -128
- package/dist/esm/plugins/quick-insert/ui/ModalElementBrowser/categories.js +0 -94
- package/dist/esm/plugins/quick-insert/ui/ModalElementBrowser/index.js +0 -50
- package/dist/esm/plugins/quick-insert/ui/ModalElementBrowser/messages.js +0 -8
- package/dist/types/plugins/quick-insert/commands.d.ts +0 -5
- package/dist/types/plugins/quick-insert/index.d.ts +0 -16
- package/dist/types/plugins/quick-insert/plugin-key.d.ts +0 -3
- package/dist/types/plugins/quick-insert/search.d.ts +0 -5
- package/dist/types/plugins/quick-insert/ui/ModalElementBrowser/ModalElementBrowser.d.ts +0 -18
- package/dist/types/plugins/quick-insert/ui/ModalElementBrowser/categories.d.ts +0 -5
- package/dist/types/plugins/quick-insert/ui/ModalElementBrowser/index.d.ts +0 -11
- package/dist/types/plugins/quick-insert/ui/ModalElementBrowser/messages.d.ts +0 -7
- package/dist/types-ts4.5/plugins/quick-insert/commands.d.ts +0 -5
- package/dist/types-ts4.5/plugins/quick-insert/index.d.ts +0 -16
- package/dist/types-ts4.5/plugins/quick-insert/plugin-key.d.ts +0 -3
- package/dist/types-ts4.5/plugins/quick-insert/search.d.ts +0 -5
- package/dist/types-ts4.5/plugins/quick-insert/ui/ModalElementBrowser/ModalElementBrowser.d.ts +0 -18
- package/dist/types-ts4.5/plugins/quick-insert/ui/ModalElementBrowser/categories.d.ts +0 -5
- package/dist/types-ts4.5/plugins/quick-insert/ui/ModalElementBrowser/index.d.ts +0 -11
- package/dist/types-ts4.5/plugins/quick-insert/ui/ModalElementBrowser/messages.d.ts +0 -7
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { insertSelectedItem } from '@atlaskit/editor-common/insert';
|
|
2
|
-
import { pluginKey } from './plugin-key';
|
|
3
|
-
export var openElementBrowserModal = function openElementBrowserModal(_ref) {
|
|
4
|
-
var tr = _ref.tr;
|
|
5
|
-
return tr.setMeta(pluginKey, {
|
|
6
|
-
isElementBrowserModalOpen: true
|
|
7
|
-
});
|
|
8
|
-
};
|
|
9
|
-
export var closeElementBrowserModal = function closeElementBrowserModal() {
|
|
10
|
-
return function (state, dispatch) {
|
|
11
|
-
if (dispatch) {
|
|
12
|
-
dispatch(state.tr.setMeta(pluginKey, {
|
|
13
|
-
isElementBrowserModalOpen: false
|
|
14
|
-
}));
|
|
15
|
-
}
|
|
16
|
-
return true;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// this method was adapted from the typeahead plugin so we respect the API for quick insert items
|
|
21
|
-
export var insertItem = function insertItem(item) {
|
|
22
|
-
return function (state, dispatch) {
|
|
23
|
-
var insert = function insert(maybeNode) {
|
|
24
|
-
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
25
|
-
return insertSelectedItem(maybeNode, opts)(state, state.tr, state.selection.head);
|
|
26
|
-
};
|
|
27
|
-
var tr = item.action(insert, state);
|
|
28
|
-
|
|
29
|
-
/** @note There is no transaction when called without a search currently (different insert) */
|
|
30
|
-
if (tr && dispatch) {
|
|
31
|
-
dispatch(tr);
|
|
32
|
-
}
|
|
33
|
-
return true;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
-
import React from 'react';
|
|
7
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
8
|
-
import { TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
|
|
9
|
-
import { pluginKey } from './plugin-key';
|
|
10
|
-
import ModalElementBrowser from './ui/ModalElementBrowser';
|
|
11
|
-
import { openElementBrowserModal, insertItem } from './commands';
|
|
12
|
-
import { memoProcessQuickInsertItems } from '@atlaskit/editor-common/quick-insert';
|
|
13
|
-
import { getQuickInsertSuggestions } from './search';
|
|
14
|
-
var quickInsertPlugin = function quickInsertPlugin(_ref) {
|
|
15
|
-
var options = _ref.config,
|
|
16
|
-
api = _ref.api;
|
|
17
|
-
return {
|
|
18
|
-
name: 'quickInsert',
|
|
19
|
-
pmPlugins: function pmPlugins(defaultItems) {
|
|
20
|
-
return [{
|
|
21
|
-
name: 'quickInsert',
|
|
22
|
-
// It's important that this plugin is above TypeAheadPlugin
|
|
23
|
-
plugin: function plugin(_ref2) {
|
|
24
|
-
var providerFactory = _ref2.providerFactory,
|
|
25
|
-
getIntl = _ref2.getIntl,
|
|
26
|
-
dispatch = _ref2.dispatch;
|
|
27
|
-
return quickInsertPluginFactory(defaultItems, providerFactory, getIntl, dispatch, options === null || options === void 0 ? void 0 : options.emptyStateHandler);
|
|
28
|
-
}
|
|
29
|
-
}];
|
|
30
|
-
},
|
|
31
|
-
pluginsOptions: {
|
|
32
|
-
typeAhead: {
|
|
33
|
-
id: TypeAheadAvailableNodes.QUICK_INSERT,
|
|
34
|
-
trigger: '/',
|
|
35
|
-
headless: options === null || options === void 0 ? void 0 : options.headless,
|
|
36
|
-
getItems: function getItems(_ref3) {
|
|
37
|
-
var query = _ref3.query,
|
|
38
|
-
editorState = _ref3.editorState;
|
|
39
|
-
var quickInsertState = pluginKey.getState(editorState);
|
|
40
|
-
return Promise.resolve(getQuickInsertSuggestions({
|
|
41
|
-
query: query,
|
|
42
|
-
disableDefaultItems: options === null || options === void 0 ? void 0 : options.disableDefaultItems
|
|
43
|
-
}, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems));
|
|
44
|
-
},
|
|
45
|
-
selectItem: function selectItem(state, item, insert) {
|
|
46
|
-
return item.action(insert, state);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
contentComponent: function contentComponent(_ref4) {
|
|
51
|
-
var editorView = _ref4.editorView;
|
|
52
|
-
if (options !== null && options !== void 0 && options.enableElementBrowser) {
|
|
53
|
-
return /*#__PURE__*/React.createElement(ModalElementBrowser, {
|
|
54
|
-
editorView: editorView,
|
|
55
|
-
helpUrl: options === null || options === void 0 ? void 0 : options.elementBrowserHelpUrl,
|
|
56
|
-
pluginInjectionAPI: api
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
return null;
|
|
60
|
-
},
|
|
61
|
-
getSharedState: function getSharedState(editorState) {
|
|
62
|
-
if (!editorState) {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
var quickInsertState = pluginKey.getState(editorState);
|
|
66
|
-
if (!quickInsertState) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
return {
|
|
70
|
-
lazyDefaultItems: quickInsertState.lazyDefaultItems,
|
|
71
|
-
emptyStateHandler: quickInsertState.emptyStateHandler,
|
|
72
|
-
providedItems: quickInsertState.providedItems,
|
|
73
|
-
isElementBrowserModalOpen: quickInsertState.isElementBrowserModalOpen
|
|
74
|
-
};
|
|
75
|
-
},
|
|
76
|
-
actions: {
|
|
77
|
-
insertItem: insertItem,
|
|
78
|
-
getSuggestions: function getSuggestions(searchOptions) {
|
|
79
|
-
var _api$quickInsert$shar;
|
|
80
|
-
var _ref5 = (_api$quickInsert$shar = api === null || api === void 0 ? void 0 : api.quickInsert.sharedState.currentState()) !== null && _api$quickInsert$shar !== void 0 ? _api$quickInsert$shar : {},
|
|
81
|
-
lazyDefaultItems = _ref5.lazyDefaultItems,
|
|
82
|
-
providedItems = _ref5.providedItems;
|
|
83
|
-
return getQuickInsertSuggestions(searchOptions, lazyDefaultItems, providedItems);
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
commands: {
|
|
87
|
-
openElementBrowserModal: openElementBrowserModal
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
export default quickInsertPlugin;
|
|
92
|
-
var setProviderState = function setProviderState(providerState) {
|
|
93
|
-
return function (state, dispatch) {
|
|
94
|
-
if (dispatch) {
|
|
95
|
-
dispatch(state.tr.setMeta(pluginKey, providerState));
|
|
96
|
-
}
|
|
97
|
-
return true;
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
function quickInsertPluginFactory(defaultItems, providerFactory, getIntl, dispatch, emptyStateHandler) {
|
|
101
|
-
return new SafePlugin({
|
|
102
|
-
key: pluginKey,
|
|
103
|
-
state: {
|
|
104
|
-
init: function init() {
|
|
105
|
-
return {
|
|
106
|
-
isElementBrowserModalOpen: false,
|
|
107
|
-
emptyStateHandler: emptyStateHandler,
|
|
108
|
-
// lazy so it doesn't run on editor initialization
|
|
109
|
-
// memo here to avoid using a singleton cache, avoids editor
|
|
110
|
-
// getting confused when two editors exist within the same page.
|
|
111
|
-
lazyDefaultItems: function lazyDefaultItems() {
|
|
112
|
-
return memoProcessQuickInsertItems(defaultItems || [], getIntl());
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
},
|
|
116
|
-
apply: function apply(tr, pluginState) {
|
|
117
|
-
var meta = tr.getMeta(pluginKey);
|
|
118
|
-
if (meta) {
|
|
119
|
-
var keys = Object.keys(meta);
|
|
120
|
-
var changed = keys.some(function (key) {
|
|
121
|
-
return pluginState[key] !== meta[key];
|
|
122
|
-
});
|
|
123
|
-
if (changed) {
|
|
124
|
-
var newState = _objectSpread(_objectSpread({}, pluginState), meta);
|
|
125
|
-
dispatch(pluginKey, newState);
|
|
126
|
-
return newState;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return pluginState;
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
view: function view(editorView) {
|
|
133
|
-
var providerHandler = /*#__PURE__*/function () {
|
|
134
|
-
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_name, providerPromise) {
|
|
135
|
-
var provider, providedItems;
|
|
136
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
137
|
-
while (1) switch (_context.prev = _context.next) {
|
|
138
|
-
case 0:
|
|
139
|
-
if (!providerPromise) {
|
|
140
|
-
_context.next = 14;
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
_context.prev = 1;
|
|
144
|
-
_context.next = 4;
|
|
145
|
-
return providerPromise;
|
|
146
|
-
case 4:
|
|
147
|
-
provider = _context.sent;
|
|
148
|
-
_context.next = 7;
|
|
149
|
-
return provider.getItems();
|
|
150
|
-
case 7:
|
|
151
|
-
providedItems = _context.sent;
|
|
152
|
-
setProviderState({
|
|
153
|
-
provider: provider,
|
|
154
|
-
providedItems: providedItems
|
|
155
|
-
})(editorView.state, editorView.dispatch);
|
|
156
|
-
_context.next = 14;
|
|
157
|
-
break;
|
|
158
|
-
case 11:
|
|
159
|
-
_context.prev = 11;
|
|
160
|
-
_context.t0 = _context["catch"](1);
|
|
161
|
-
// eslint-disable-next-line no-console
|
|
162
|
-
console.error('Error getting items from quick insert provider', _context.t0);
|
|
163
|
-
case 14:
|
|
164
|
-
case "end":
|
|
165
|
-
return _context.stop();
|
|
166
|
-
}
|
|
167
|
-
}, _callee, null, [[1, 11]]);
|
|
168
|
-
}));
|
|
169
|
-
return function providerHandler(_x, _x2) {
|
|
170
|
-
return _ref6.apply(this, arguments);
|
|
171
|
-
};
|
|
172
|
-
}();
|
|
173
|
-
providerFactory.subscribe('quickInsertProvider', providerHandler);
|
|
174
|
-
return {
|
|
175
|
-
destroy: function destroy() {
|
|
176
|
-
providerFactory.unsubscribe('quickInsertProvider', providerHandler);
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
-
import { dedupe } from '@atlaskit/editor-common/utils';
|
|
3
|
-
import { find } from '@atlaskit/editor-common/quick-insert';
|
|
4
|
-
export var getQuickInsertSuggestions = function getQuickInsertSuggestions(searchOptions) {
|
|
5
|
-
var lazyDefaultItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
|
|
6
|
-
return [];
|
|
7
|
-
};
|
|
8
|
-
var providedItems = arguments.length > 2 ? arguments[2] : undefined;
|
|
9
|
-
var query = searchOptions.query,
|
|
10
|
-
category = searchOptions.category,
|
|
11
|
-
disableDefaultItems = searchOptions.disableDefaultItems,
|
|
12
|
-
featuredItems = searchOptions.featuredItems;
|
|
13
|
-
var defaultItems = disableDefaultItems ? [] : lazyDefaultItems();
|
|
14
|
-
var items = providedItems ? dedupe([].concat(_toConsumableArray(defaultItems), _toConsumableArray(providedItems)), function (item) {
|
|
15
|
-
return item.title;
|
|
16
|
-
}) : defaultItems;
|
|
17
|
-
if (featuredItems) {
|
|
18
|
-
return items.filter(function (item) {
|
|
19
|
-
return item.featured;
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
return find(query || '', category === 'all' || !category ? items : items.filter(function (item) {
|
|
23
|
-
return item.categories && item.categories.includes(category);
|
|
24
|
-
}));
|
|
25
|
-
};
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
3
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
4
|
-
/** @jsx jsx */
|
|
5
|
-
import React, { useState, useCallback } from 'react';
|
|
6
|
-
import { css, jsx } from '@emotion/react';
|
|
7
|
-
import { injectIntl } from 'react-intl-next';
|
|
8
|
-
import { DN50, N0 } from '@atlaskit/theme/colors';
|
|
9
|
-
import { themed } from '@atlaskit/theme/components';
|
|
10
|
-
import { borderRadius } from '@atlaskit/theme/constants';
|
|
11
|
-
import Button from '@atlaskit/button/custom-theme-button';
|
|
12
|
-
import Modal, { ModalTransition, useModal } from '@atlaskit/modal-dialog';
|
|
13
|
-
import QuestionCircleIcon from '@atlaskit/icon/glyph/question-circle';
|
|
14
|
-
import { ElementBrowser } from '@atlaskit/editor-common/element-browser';
|
|
15
|
-
import { getCategories } from './categories';
|
|
16
|
-
import { messages } from './messages';
|
|
17
|
-
export var MODAL_WRAPPER_PADDING = 16;
|
|
18
|
-
var actions = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-flex;\n margin: 0 -4px;\n"])));
|
|
19
|
-
var actionItem = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n flex: 1 0 auto;\n margin: 0 ", ";\n"])), "var(--ds-space-050, 4px)");
|
|
20
|
-
var wrapper = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n flex: 1 1 auto;\n box-sizing: border-box;\n padding: ", " ", " 0 10px;\n overflow: hidden;\n background-color: ", ";\n border-radius: ", "px;\n"])), "var(--ds-space-200, 16px)", "var(--ds-space-200, 16px)", themed({
|
|
21
|
-
light: "var(--ds-surface-overlay, ".concat(N0, ")"),
|
|
22
|
-
dark: "var(--ds-surface-overlay, ".concat(DN50, ")")
|
|
23
|
-
})(), borderRadius());
|
|
24
|
-
var modalFooter = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: flex;\n padding: ", ";\n\n position: relative;\n align-items: center;\n justify-content: space-between;\n"])), "var(--ds-space-200, 16px)");
|
|
25
|
-
var ModalElementBrowser = function ModalElementBrowser(props) {
|
|
26
|
-
var _useState = useState(),
|
|
27
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
28
|
-
selectedItem = _useState2[0],
|
|
29
|
-
setSelectedItem = _useState2[1];
|
|
30
|
-
var helpUrl = props.helpUrl,
|
|
31
|
-
intl = props.intl,
|
|
32
|
-
onClose = props.onClose,
|
|
33
|
-
onInsertItemFn = props.onInsertItem;
|
|
34
|
-
var onSelectItem = useCallback(function (item) {
|
|
35
|
-
setSelectedItem(item);
|
|
36
|
-
}, [setSelectedItem]);
|
|
37
|
-
var onInsertItem = useCallback(function (item) {
|
|
38
|
-
onInsertItemFn(item);
|
|
39
|
-
}, [onInsertItemFn]);
|
|
40
|
-
var RenderFooter = useCallback(function () {
|
|
41
|
-
return jsx(Footer, {
|
|
42
|
-
onInsert: function onInsert() {
|
|
43
|
-
return onInsertItem(selectedItem);
|
|
44
|
-
},
|
|
45
|
-
beforeElement: helpUrl ? HelpLink(helpUrl, intl.formatMessage(messages.help)) : undefined
|
|
46
|
-
});
|
|
47
|
-
}, [onInsertItem, selectedItem, helpUrl, intl]);
|
|
48
|
-
|
|
49
|
-
// Since Modal uses stackIndex it's shouldCloseOnEscapePress prop doesn't work.
|
|
50
|
-
var onKeyDown = useCallback(function (e) {
|
|
51
|
-
if (e.key === 'Escape') {
|
|
52
|
-
onClose();
|
|
53
|
-
}
|
|
54
|
-
}, [onClose]);
|
|
55
|
-
var RenderBody = useCallback(function () {
|
|
56
|
-
return jsx("div", {
|
|
57
|
-
css: wrapper
|
|
58
|
-
}, jsx(ElementBrowser, {
|
|
59
|
-
categories: getCategories(props.intl),
|
|
60
|
-
getItems: props.getItems,
|
|
61
|
-
showSearch: true,
|
|
62
|
-
showCategories: true,
|
|
63
|
-
mode: "full",
|
|
64
|
-
onSelectItem: onSelectItem,
|
|
65
|
-
onInsertItem: onInsertItem,
|
|
66
|
-
emptyStateHandler: props.emptyStateHandler
|
|
67
|
-
}));
|
|
68
|
-
}, [props.intl, props.getItems, onSelectItem, onInsertItem, props.emptyStateHandler]);
|
|
69
|
-
return jsx("div", {
|
|
70
|
-
"data-editor-popup": true,
|
|
71
|
-
onClick: onModalClick,
|
|
72
|
-
onKeyDown: onKeyDown
|
|
73
|
-
}, jsx(ModalTransition, null, props.isOpen && jsx(Modal, {
|
|
74
|
-
testId: "element-browser-modal-dialog",
|
|
75
|
-
stackIndex: 0,
|
|
76
|
-
key: "element-browser-modal",
|
|
77
|
-
onClose: props.onClose,
|
|
78
|
-
height: "664px",
|
|
79
|
-
width: "x-large",
|
|
80
|
-
autoFocus: false
|
|
81
|
-
// defaults to true and doesn't work along with stackIndex=1.
|
|
82
|
-
// packages/design-system/modal-dialog/src/components/Content.tsx Line 287
|
|
83
|
-
,
|
|
84
|
-
shouldCloseOnEscapePress: false
|
|
85
|
-
}, jsx(RenderBody, null), jsx(RenderFooter, null))));
|
|
86
|
-
};
|
|
87
|
-
ModalElementBrowser.displayName = 'ModalElementBrowser';
|
|
88
|
-
|
|
89
|
-
// Prevent ModalElementBrowser click propagation through to the editor.
|
|
90
|
-
var onModalClick = function onModalClick(e) {
|
|
91
|
-
return e.stopPropagation();
|
|
92
|
-
};
|
|
93
|
-
var Footer = function Footer(_ref) {
|
|
94
|
-
var onInsert = _ref.onInsert,
|
|
95
|
-
beforeElement = _ref.beforeElement;
|
|
96
|
-
var _useModal = useModal(),
|
|
97
|
-
onClose = _useModal.onClose;
|
|
98
|
-
return jsx("div", {
|
|
99
|
-
css: modalFooter
|
|
100
|
-
}, beforeElement ? beforeElement : jsx("span", null), jsx("div", {
|
|
101
|
-
css: actions
|
|
102
|
-
}, jsx("div", {
|
|
103
|
-
css: actionItem
|
|
104
|
-
}, jsx(Button, {
|
|
105
|
-
appearance: "primary",
|
|
106
|
-
onClick: onInsert,
|
|
107
|
-
testId: "ModalElementBrowser__insert-button"
|
|
108
|
-
}, "Insert")), jsx("div", {
|
|
109
|
-
css: actionItem
|
|
110
|
-
}, jsx(Button, {
|
|
111
|
-
appearance: "subtle",
|
|
112
|
-
onClick: onClose,
|
|
113
|
-
testId: "ModalElementBrowser__close-button"
|
|
114
|
-
}, "Close"))));
|
|
115
|
-
};
|
|
116
|
-
var HelpLink = function HelpLink(url, helpText) {
|
|
117
|
-
return jsx(Button, {
|
|
118
|
-
iconBefore: jsx(QuestionCircleIcon, {
|
|
119
|
-
label: "",
|
|
120
|
-
size: "medium"
|
|
121
|
-
}),
|
|
122
|
-
appearance: "subtle-link",
|
|
123
|
-
href: url,
|
|
124
|
-
target: "_blank",
|
|
125
|
-
testId: "ModalElementBrowser__help-button"
|
|
126
|
-
}, helpText);
|
|
127
|
-
};
|
|
128
|
-
export default injectIntl(ModalElementBrowser);
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { defineMessages } from 'react-intl-next';
|
|
2
|
-
export function getCategories(intl) {
|
|
3
|
-
return [{
|
|
4
|
-
title: intl.formatMessage(messages.all),
|
|
5
|
-
name: 'all'
|
|
6
|
-
}, {
|
|
7
|
-
title: intl.formatMessage(messages.formatting),
|
|
8
|
-
name: 'formatting'
|
|
9
|
-
}, {
|
|
10
|
-
title: intl.formatMessage(messages['confluence-content']),
|
|
11
|
-
name: 'confluence-content'
|
|
12
|
-
}, {
|
|
13
|
-
title: intl.formatMessage(messages.media),
|
|
14
|
-
name: 'media'
|
|
15
|
-
}, {
|
|
16
|
-
title: intl.formatMessage(messages.visuals),
|
|
17
|
-
name: 'visuals'
|
|
18
|
-
}, {
|
|
19
|
-
title: intl.formatMessage(messages.navigation),
|
|
20
|
-
name: 'navigation'
|
|
21
|
-
}, {
|
|
22
|
-
title: intl.formatMessage(messages['external-content']),
|
|
23
|
-
name: 'external-content'
|
|
24
|
-
}, {
|
|
25
|
-
title: intl.formatMessage(messages.communication),
|
|
26
|
-
name: 'communication'
|
|
27
|
-
}, {
|
|
28
|
-
title: intl.formatMessage(messages.reporting),
|
|
29
|
-
name: 'reporting'
|
|
30
|
-
}, {
|
|
31
|
-
title: intl.formatMessage(messages.admin),
|
|
32
|
-
name: 'admin'
|
|
33
|
-
}, {
|
|
34
|
-
title: intl.formatMessage(messages.development),
|
|
35
|
-
name: 'development'
|
|
36
|
-
}];
|
|
37
|
-
}
|
|
38
|
-
var messages = defineMessages({
|
|
39
|
-
all: {
|
|
40
|
-
id: 'fabric.editor.elementbrowser.categorylist.category-all',
|
|
41
|
-
defaultMessage: 'All',
|
|
42
|
-
description: 'all'
|
|
43
|
-
},
|
|
44
|
-
formatting: {
|
|
45
|
-
id: 'fabric.editor.elementbrowser.categorylist.category-formatting',
|
|
46
|
-
defaultMessage: 'Formatting',
|
|
47
|
-
description: 'formatting'
|
|
48
|
-
},
|
|
49
|
-
'confluence-content': {
|
|
50
|
-
id: 'fabric.editor.elementbrowser.categorylist.category-confluence-content',
|
|
51
|
-
defaultMessage: 'Confluence content',
|
|
52
|
-
description: 'confluence-content'
|
|
53
|
-
},
|
|
54
|
-
media: {
|
|
55
|
-
id: 'fabric.editor.elementbrowser.categorylist.category-media',
|
|
56
|
-
defaultMessage: 'Media',
|
|
57
|
-
description: 'media'
|
|
58
|
-
},
|
|
59
|
-
visuals: {
|
|
60
|
-
id: 'fabric.editor.elementbrowser.categorylist.category-visuals',
|
|
61
|
-
defaultMessage: 'Visuals & images',
|
|
62
|
-
description: 'visuals'
|
|
63
|
-
},
|
|
64
|
-
navigation: {
|
|
65
|
-
id: 'fabric.editor.elementbrowser.categorylist.category-navigation',
|
|
66
|
-
defaultMessage: 'Navigation',
|
|
67
|
-
description: 'navigation'
|
|
68
|
-
},
|
|
69
|
-
'external-content': {
|
|
70
|
-
id: 'fabric.editor.elementbrowser.categorylist.category-external-content',
|
|
71
|
-
defaultMessage: 'External content',
|
|
72
|
-
description: 'external-content'
|
|
73
|
-
},
|
|
74
|
-
communication: {
|
|
75
|
-
id: 'fabric.editor.elementbrowser.categorylist.category-communication',
|
|
76
|
-
defaultMessage: 'Communication',
|
|
77
|
-
description: 'communication'
|
|
78
|
-
},
|
|
79
|
-
reporting: {
|
|
80
|
-
id: 'fabric.editor.elementbrowser.categorylist.category-reporting',
|
|
81
|
-
defaultMessage: 'Reporting',
|
|
82
|
-
description: 'reporting'
|
|
83
|
-
},
|
|
84
|
-
admin: {
|
|
85
|
-
id: 'fabric.editor.elementbrowser.categorylist.category-admin',
|
|
86
|
-
defaultMessage: 'Administration',
|
|
87
|
-
description: 'admin'
|
|
88
|
-
},
|
|
89
|
-
development: {
|
|
90
|
-
id: 'fabric.editor.elementbrowser.categorylist.category-development',
|
|
91
|
-
defaultMessage: 'Development',
|
|
92
|
-
description: 'development'
|
|
93
|
-
}
|
|
94
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import React, { useCallback } from 'react';
|
|
2
|
-
import ModalElementBrowser from './ModalElementBrowser';
|
|
3
|
-
import { closeElementBrowserModal, insertItem } from '../../commands';
|
|
4
|
-
import { getQuickInsertSuggestions } from '../../search';
|
|
5
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
6
|
-
var Modal = function Modal(_ref) {
|
|
7
|
-
var quickInsertState = _ref.quickInsertState,
|
|
8
|
-
editorView = _ref.editorView,
|
|
9
|
-
helpUrl = _ref.helpUrl;
|
|
10
|
-
var getItems = useCallback(function (query, category) {
|
|
11
|
-
return getQuickInsertSuggestions({
|
|
12
|
-
query: query,
|
|
13
|
-
category: category
|
|
14
|
-
}, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems);
|
|
15
|
-
}, [quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems]);
|
|
16
|
-
var focusInEditor = useCallback(function () {
|
|
17
|
-
if (!editorView.hasFocus()) {
|
|
18
|
-
editorView.focus();
|
|
19
|
-
}
|
|
20
|
-
}, [editorView]);
|
|
21
|
-
var onInsertItem = useCallback(function (item) {
|
|
22
|
-
closeElementBrowserModal()(editorView.state, editorView.dispatch);
|
|
23
|
-
focusInEditor();
|
|
24
|
-
insertItem(item)(editorView.state, editorView.dispatch);
|
|
25
|
-
}, [editorView, focusInEditor]);
|
|
26
|
-
var onClose = useCallback(function () {
|
|
27
|
-
closeElementBrowserModal()(editorView.state, editorView.dispatch);
|
|
28
|
-
focusInEditor();
|
|
29
|
-
}, [editorView, focusInEditor]);
|
|
30
|
-
return /*#__PURE__*/React.createElement(ModalElementBrowser, {
|
|
31
|
-
getItems: getItems,
|
|
32
|
-
onInsertItem: onInsertItem,
|
|
33
|
-
helpUrl: helpUrl,
|
|
34
|
-
isOpen: (quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.isElementBrowserModalOpen) || false,
|
|
35
|
-
emptyStateHandler: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.emptyStateHandler,
|
|
36
|
-
onClose: onClose
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
export default (function (_ref2) {
|
|
40
|
-
var editorView = _ref2.editorView,
|
|
41
|
-
helpUrl = _ref2.helpUrl,
|
|
42
|
-
pluginInjectionAPI = _ref2.pluginInjectionAPI;
|
|
43
|
-
var _useSharedPluginState = useSharedPluginState(pluginInjectionAPI, ['quickInsert']),
|
|
44
|
-
quickInsertState = _useSharedPluginState.quickInsertState;
|
|
45
|
-
return /*#__PURE__*/React.createElement(Modal, {
|
|
46
|
-
quickInsertState: quickInsertState !== null && quickInsertState !== void 0 ? quickInsertState : undefined,
|
|
47
|
-
editorView: editorView,
|
|
48
|
-
helpUrl: helpUrl
|
|
49
|
-
});
|
|
50
|
-
});
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { QuickInsertItem } from '@atlaskit/editor-common/provider-factory';
|
|
2
|
-
import type { EditorCommand, Command } from '@atlaskit/editor-common/types';
|
|
3
|
-
export declare const openElementBrowserModal: EditorCommand;
|
|
4
|
-
export declare const closeElementBrowserModal: () => Command;
|
|
5
|
-
export declare const insertItem: (item: QuickInsertItem) => Command;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { QuickInsertItem } from '@atlaskit/editor-common/provider-factory';
|
|
2
|
-
import type { NextEditorPlugin, Command, QuickInsertPluginOptions, QuickInsertSharedState, EditorCommand, QuickInsertSearchOptions } from '@atlaskit/editor-common/types';
|
|
3
|
-
export type { QuickInsertPluginOptions };
|
|
4
|
-
export type QuickInsertPlugin = NextEditorPlugin<'quickInsert', {
|
|
5
|
-
pluginConfiguration: QuickInsertPluginOptions | undefined;
|
|
6
|
-
sharedState: QuickInsertSharedState | null;
|
|
7
|
-
actions: {
|
|
8
|
-
insertItem: (item: QuickInsertItem) => Command;
|
|
9
|
-
getSuggestions: (searchOptions: QuickInsertSearchOptions) => QuickInsertItem[];
|
|
10
|
-
};
|
|
11
|
-
commands: {
|
|
12
|
-
openElementBrowserModal: EditorCommand;
|
|
13
|
-
};
|
|
14
|
-
}>;
|
|
15
|
-
declare const quickInsertPlugin: QuickInsertPlugin;
|
|
16
|
-
export default quickInsertPlugin;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { QuickInsertItem } from '@atlaskit/editor-common/provider-factory';
|
|
2
|
-
import type { QuickInsertSearchOptions } from '@atlaskit/editor-common/types';
|
|
3
|
-
type GetQuickInsertSuggestions = (searchOptions: QuickInsertSearchOptions, lazyDefaultItems?: () => QuickInsertItem[], providedItems?: QuickInsertItem[]) => QuickInsertItem[];
|
|
4
|
-
export declare const getQuickInsertSuggestions: GetQuickInsertSuggestions;
|
|
5
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import type { WrappedComponentProps } from 'react-intl-next';
|
|
4
|
-
import type { QuickInsertItem } from '@atlaskit/editor-common/provider-factory';
|
|
5
|
-
import type { EmptyStateHandler } from '@atlaskit/editor-common/types';
|
|
6
|
-
export declare const MODAL_WRAPPER_PADDING = 16;
|
|
7
|
-
export interface Props {
|
|
8
|
-
getItems: (query?: string, category?: string) => QuickInsertItem[];
|
|
9
|
-
onInsertItem: (item: QuickInsertItem) => void;
|
|
10
|
-
isOpen?: boolean;
|
|
11
|
-
onClose: () => void;
|
|
12
|
-
helpUrl?: string | undefined;
|
|
13
|
-
emptyStateHandler?: EmptyStateHandler;
|
|
14
|
-
}
|
|
15
|
-
declare const _default: React.FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps<"intl">>> & {
|
|
16
|
-
WrappedComponent: React.ComponentType<Props & WrappedComponentProps<"intl">>;
|
|
17
|
-
};
|
|
18
|
-
export default _default;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
-
import type { QuickInsertPlugin } from '../../';
|
|
5
|
-
type Props = {
|
|
6
|
-
editorView: EditorView;
|
|
7
|
-
helpUrl: string | undefined;
|
|
8
|
-
pluginInjectionAPI: ExtractInjectionAPI<QuickInsertPlugin> | undefined;
|
|
9
|
-
};
|
|
10
|
-
declare const _default: ({ editorView, helpUrl, pluginInjectionAPI }: Props) => JSX.Element;
|
|
11
|
-
export default _default;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { QuickInsertItem } from '@atlaskit/editor-common/provider-factory';
|
|
2
|
-
import type { EditorCommand, Command } from '@atlaskit/editor-common/types';
|
|
3
|
-
export declare const openElementBrowserModal: EditorCommand;
|
|
4
|
-
export declare const closeElementBrowserModal: () => Command;
|
|
5
|
-
export declare const insertItem: (item: QuickInsertItem) => Command;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { QuickInsertItem } from '@atlaskit/editor-common/provider-factory';
|
|
2
|
-
import type { NextEditorPlugin, Command, QuickInsertPluginOptions, QuickInsertSharedState, EditorCommand, QuickInsertSearchOptions } from '@atlaskit/editor-common/types';
|
|
3
|
-
export type { QuickInsertPluginOptions };
|
|
4
|
-
export type QuickInsertPlugin = NextEditorPlugin<'quickInsert', {
|
|
5
|
-
pluginConfiguration: QuickInsertPluginOptions | undefined;
|
|
6
|
-
sharedState: QuickInsertSharedState | null;
|
|
7
|
-
actions: {
|
|
8
|
-
insertItem: (item: QuickInsertItem) => Command;
|
|
9
|
-
getSuggestions: (searchOptions: QuickInsertSearchOptions) => QuickInsertItem[];
|
|
10
|
-
};
|
|
11
|
-
commands: {
|
|
12
|
-
openElementBrowserModal: EditorCommand;
|
|
13
|
-
};
|
|
14
|
-
}>;
|
|
15
|
-
declare const quickInsertPlugin: QuickInsertPlugin;
|
|
16
|
-
export default quickInsertPlugin;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { QuickInsertItem } from '@atlaskit/editor-common/provider-factory';
|
|
2
|
-
import type { QuickInsertSearchOptions } from '@atlaskit/editor-common/types';
|
|
3
|
-
type GetQuickInsertSuggestions = (searchOptions: QuickInsertSearchOptions, lazyDefaultItems?: () => QuickInsertItem[], providedItems?: QuickInsertItem[]) => QuickInsertItem[];
|
|
4
|
-
export declare const getQuickInsertSuggestions: GetQuickInsertSuggestions;
|
|
5
|
-
export {};
|