@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,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getCategories = getCategories;
|
|
7
|
-
var _reactIntlNext = require("react-intl-next");
|
|
8
|
-
function getCategories(intl) {
|
|
9
|
-
return [{
|
|
10
|
-
title: intl.formatMessage(messages.all),
|
|
11
|
-
name: 'all'
|
|
12
|
-
}, {
|
|
13
|
-
title: intl.formatMessage(messages.formatting),
|
|
14
|
-
name: 'formatting'
|
|
15
|
-
}, {
|
|
16
|
-
title: intl.formatMessage(messages['confluence-content']),
|
|
17
|
-
name: 'confluence-content'
|
|
18
|
-
}, {
|
|
19
|
-
title: intl.formatMessage(messages.media),
|
|
20
|
-
name: 'media'
|
|
21
|
-
}, {
|
|
22
|
-
title: intl.formatMessage(messages.visuals),
|
|
23
|
-
name: 'visuals'
|
|
24
|
-
}, {
|
|
25
|
-
title: intl.formatMessage(messages.navigation),
|
|
26
|
-
name: 'navigation'
|
|
27
|
-
}, {
|
|
28
|
-
title: intl.formatMessage(messages['external-content']),
|
|
29
|
-
name: 'external-content'
|
|
30
|
-
}, {
|
|
31
|
-
title: intl.formatMessage(messages.communication),
|
|
32
|
-
name: 'communication'
|
|
33
|
-
}, {
|
|
34
|
-
title: intl.formatMessage(messages.reporting),
|
|
35
|
-
name: 'reporting'
|
|
36
|
-
}, {
|
|
37
|
-
title: intl.formatMessage(messages.admin),
|
|
38
|
-
name: 'admin'
|
|
39
|
-
}, {
|
|
40
|
-
title: intl.formatMessage(messages.development),
|
|
41
|
-
name: 'development'
|
|
42
|
-
}];
|
|
43
|
-
}
|
|
44
|
-
var messages = (0, _reactIntlNext.defineMessages)({
|
|
45
|
-
all: {
|
|
46
|
-
id: 'fabric.editor.elementbrowser.categorylist.category-all',
|
|
47
|
-
defaultMessage: 'All',
|
|
48
|
-
description: 'all'
|
|
49
|
-
},
|
|
50
|
-
formatting: {
|
|
51
|
-
id: 'fabric.editor.elementbrowser.categorylist.category-formatting',
|
|
52
|
-
defaultMessage: 'Formatting',
|
|
53
|
-
description: 'formatting'
|
|
54
|
-
},
|
|
55
|
-
'confluence-content': {
|
|
56
|
-
id: 'fabric.editor.elementbrowser.categorylist.category-confluence-content',
|
|
57
|
-
defaultMessage: 'Confluence content',
|
|
58
|
-
description: 'confluence-content'
|
|
59
|
-
},
|
|
60
|
-
media: {
|
|
61
|
-
id: 'fabric.editor.elementbrowser.categorylist.category-media',
|
|
62
|
-
defaultMessage: 'Media',
|
|
63
|
-
description: 'media'
|
|
64
|
-
},
|
|
65
|
-
visuals: {
|
|
66
|
-
id: 'fabric.editor.elementbrowser.categorylist.category-visuals',
|
|
67
|
-
defaultMessage: 'Visuals & images',
|
|
68
|
-
description: 'visuals'
|
|
69
|
-
},
|
|
70
|
-
navigation: {
|
|
71
|
-
id: 'fabric.editor.elementbrowser.categorylist.category-navigation',
|
|
72
|
-
defaultMessage: 'Navigation',
|
|
73
|
-
description: 'navigation'
|
|
74
|
-
},
|
|
75
|
-
'external-content': {
|
|
76
|
-
id: 'fabric.editor.elementbrowser.categorylist.category-external-content',
|
|
77
|
-
defaultMessage: 'External content',
|
|
78
|
-
description: 'external-content'
|
|
79
|
-
},
|
|
80
|
-
communication: {
|
|
81
|
-
id: 'fabric.editor.elementbrowser.categorylist.category-communication',
|
|
82
|
-
defaultMessage: 'Communication',
|
|
83
|
-
description: 'communication'
|
|
84
|
-
},
|
|
85
|
-
reporting: {
|
|
86
|
-
id: 'fabric.editor.elementbrowser.categorylist.category-reporting',
|
|
87
|
-
defaultMessage: 'Reporting',
|
|
88
|
-
description: 'reporting'
|
|
89
|
-
},
|
|
90
|
-
admin: {
|
|
91
|
-
id: 'fabric.editor.elementbrowser.categorylist.category-admin',
|
|
92
|
-
defaultMessage: 'Administration',
|
|
93
|
-
description: 'admin'
|
|
94
|
-
},
|
|
95
|
-
development: {
|
|
96
|
-
id: 'fabric.editor.elementbrowser.categorylist.category-development',
|
|
97
|
-
defaultMessage: 'Development',
|
|
98
|
-
description: 'development'
|
|
99
|
-
}
|
|
100
|
-
});
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _ModalElementBrowser = _interopRequireDefault(require("./ModalElementBrowser"));
|
|
11
|
-
var _commands = require("../../commands");
|
|
12
|
-
var _search = require("../../search");
|
|
13
|
-
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
14
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
|
-
var Modal = function Modal(_ref) {
|
|
17
|
-
var quickInsertState = _ref.quickInsertState,
|
|
18
|
-
editorView = _ref.editorView,
|
|
19
|
-
helpUrl = _ref.helpUrl;
|
|
20
|
-
var getItems = (0, _react.useCallback)(function (query, category) {
|
|
21
|
-
return (0, _search.getQuickInsertSuggestions)({
|
|
22
|
-
query: query,
|
|
23
|
-
category: category
|
|
24
|
-
}, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems);
|
|
25
|
-
}, [quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems]);
|
|
26
|
-
var focusInEditor = (0, _react.useCallback)(function () {
|
|
27
|
-
if (!editorView.hasFocus()) {
|
|
28
|
-
editorView.focus();
|
|
29
|
-
}
|
|
30
|
-
}, [editorView]);
|
|
31
|
-
var onInsertItem = (0, _react.useCallback)(function (item) {
|
|
32
|
-
(0, _commands.closeElementBrowserModal)()(editorView.state, editorView.dispatch);
|
|
33
|
-
focusInEditor();
|
|
34
|
-
(0, _commands.insertItem)(item)(editorView.state, editorView.dispatch);
|
|
35
|
-
}, [editorView, focusInEditor]);
|
|
36
|
-
var onClose = (0, _react.useCallback)(function () {
|
|
37
|
-
(0, _commands.closeElementBrowserModal)()(editorView.state, editorView.dispatch);
|
|
38
|
-
focusInEditor();
|
|
39
|
-
}, [editorView, focusInEditor]);
|
|
40
|
-
return /*#__PURE__*/_react.default.createElement(_ModalElementBrowser.default, {
|
|
41
|
-
getItems: getItems,
|
|
42
|
-
onInsertItem: onInsertItem,
|
|
43
|
-
helpUrl: helpUrl,
|
|
44
|
-
isOpen: (quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.isElementBrowserModalOpen) || false,
|
|
45
|
-
emptyStateHandler: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.emptyStateHandler,
|
|
46
|
-
onClose: onClose
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
var _default = function _default(_ref2) {
|
|
50
|
-
var editorView = _ref2.editorView,
|
|
51
|
-
helpUrl = _ref2.helpUrl,
|
|
52
|
-
pluginInjectionAPI = _ref2.pluginInjectionAPI;
|
|
53
|
-
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionAPI, ['quickInsert']),
|
|
54
|
-
quickInsertState = _useSharedPluginState.quickInsertState;
|
|
55
|
-
return /*#__PURE__*/_react.default.createElement(Modal, {
|
|
56
|
-
quickInsertState: quickInsertState !== null && quickInsertState !== void 0 ? quickInsertState : undefined,
|
|
57
|
-
editorView: editorView,
|
|
58
|
-
helpUrl: helpUrl
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
exports.default = _default;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.messages = void 0;
|
|
7
|
-
var _reactIntlNext = require("react-intl-next");
|
|
8
|
-
var messages = (0, _reactIntlNext.defineMessages)({
|
|
9
|
-
help: {
|
|
10
|
-
id: 'fabric.editor.elementBrowser.help',
|
|
11
|
-
defaultMessage: 'Help',
|
|
12
|
-
description: 'Element browser help button label'
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
exports.messages = messages;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { insertSelectedItem } from '@atlaskit/editor-common/insert';
|
|
2
|
-
import { pluginKey } from './plugin-key';
|
|
3
|
-
export const openElementBrowserModal = ({
|
|
4
|
-
tr
|
|
5
|
-
}) => tr.setMeta(pluginKey, {
|
|
6
|
-
isElementBrowserModalOpen: true
|
|
7
|
-
});
|
|
8
|
-
export const closeElementBrowserModal = () => (state, dispatch) => {
|
|
9
|
-
if (dispatch) {
|
|
10
|
-
dispatch(state.tr.setMeta(pluginKey, {
|
|
11
|
-
isElementBrowserModalOpen: false
|
|
12
|
-
}));
|
|
13
|
-
}
|
|
14
|
-
return true;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// this method was adapted from the typeahead plugin so we respect the API for quick insert items
|
|
18
|
-
export const insertItem = item => (state, dispatch) => {
|
|
19
|
-
const insert = (maybeNode, opts = {}) => {
|
|
20
|
-
return insertSelectedItem(maybeNode, opts)(state, state.tr, state.selection.head);
|
|
21
|
-
};
|
|
22
|
-
const tr = item.action(insert, state);
|
|
23
|
-
|
|
24
|
-
/** @note There is no transaction when called without a search currently (different insert) */
|
|
25
|
-
if (tr && dispatch) {
|
|
26
|
-
dispatch(tr);
|
|
27
|
-
}
|
|
28
|
-
return true;
|
|
29
|
-
};
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
import { TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
|
|
4
|
-
import { pluginKey } from './plugin-key';
|
|
5
|
-
import ModalElementBrowser from './ui/ModalElementBrowser';
|
|
6
|
-
import { openElementBrowserModal, insertItem } from './commands';
|
|
7
|
-
import { memoProcessQuickInsertItems } from '@atlaskit/editor-common/quick-insert';
|
|
8
|
-
import { getQuickInsertSuggestions } from './search';
|
|
9
|
-
const quickInsertPlugin = ({
|
|
10
|
-
config: options,
|
|
11
|
-
api
|
|
12
|
-
}) => ({
|
|
13
|
-
name: 'quickInsert',
|
|
14
|
-
pmPlugins(defaultItems) {
|
|
15
|
-
return [{
|
|
16
|
-
name: 'quickInsert',
|
|
17
|
-
// It's important that this plugin is above TypeAheadPlugin
|
|
18
|
-
plugin: ({
|
|
19
|
-
providerFactory,
|
|
20
|
-
getIntl,
|
|
21
|
-
dispatch
|
|
22
|
-
}) => quickInsertPluginFactory(defaultItems, providerFactory, getIntl, dispatch, options === null || options === void 0 ? void 0 : options.emptyStateHandler)
|
|
23
|
-
}];
|
|
24
|
-
},
|
|
25
|
-
pluginsOptions: {
|
|
26
|
-
typeAhead: {
|
|
27
|
-
id: TypeAheadAvailableNodes.QUICK_INSERT,
|
|
28
|
-
trigger: '/',
|
|
29
|
-
headless: options === null || options === void 0 ? void 0 : options.headless,
|
|
30
|
-
getItems({
|
|
31
|
-
query,
|
|
32
|
-
editorState
|
|
33
|
-
}) {
|
|
34
|
-
const quickInsertState = pluginKey.getState(editorState);
|
|
35
|
-
return Promise.resolve(getQuickInsertSuggestions({
|
|
36
|
-
query,
|
|
37
|
-
disableDefaultItems: options === null || options === void 0 ? void 0 : options.disableDefaultItems
|
|
38
|
-
}, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems));
|
|
39
|
-
},
|
|
40
|
-
selectItem: (state, item, insert) => {
|
|
41
|
-
return item.action(insert, state);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
contentComponent({
|
|
46
|
-
editorView
|
|
47
|
-
}) {
|
|
48
|
-
if (options !== null && options !== void 0 && options.enableElementBrowser) {
|
|
49
|
-
return /*#__PURE__*/React.createElement(ModalElementBrowser, {
|
|
50
|
-
editorView: editorView,
|
|
51
|
-
helpUrl: options === null || options === void 0 ? void 0 : options.elementBrowserHelpUrl,
|
|
52
|
-
pluginInjectionAPI: api
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
return null;
|
|
56
|
-
},
|
|
57
|
-
getSharedState(editorState) {
|
|
58
|
-
if (!editorState) {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
const quickInsertState = pluginKey.getState(editorState);
|
|
62
|
-
if (!quickInsertState) {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
return {
|
|
66
|
-
lazyDefaultItems: quickInsertState.lazyDefaultItems,
|
|
67
|
-
emptyStateHandler: quickInsertState.emptyStateHandler,
|
|
68
|
-
providedItems: quickInsertState.providedItems,
|
|
69
|
-
isElementBrowserModalOpen: quickInsertState.isElementBrowserModalOpen
|
|
70
|
-
};
|
|
71
|
-
},
|
|
72
|
-
actions: {
|
|
73
|
-
insertItem,
|
|
74
|
-
getSuggestions: searchOptions => {
|
|
75
|
-
var _api$quickInsert$shar;
|
|
76
|
-
const {
|
|
77
|
-
lazyDefaultItems,
|
|
78
|
-
providedItems
|
|
79
|
-
} = (_api$quickInsert$shar = api === null || api === void 0 ? void 0 : api.quickInsert.sharedState.currentState()) !== null && _api$quickInsert$shar !== void 0 ? _api$quickInsert$shar : {};
|
|
80
|
-
return getQuickInsertSuggestions(searchOptions, lazyDefaultItems, providedItems);
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
commands: {
|
|
84
|
-
openElementBrowserModal
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
export default quickInsertPlugin;
|
|
88
|
-
const setProviderState = providerState => (state, dispatch) => {
|
|
89
|
-
if (dispatch) {
|
|
90
|
-
dispatch(state.tr.setMeta(pluginKey, providerState));
|
|
91
|
-
}
|
|
92
|
-
return true;
|
|
93
|
-
};
|
|
94
|
-
function quickInsertPluginFactory(defaultItems, providerFactory, getIntl, dispatch, emptyStateHandler) {
|
|
95
|
-
return new SafePlugin({
|
|
96
|
-
key: pluginKey,
|
|
97
|
-
state: {
|
|
98
|
-
init() {
|
|
99
|
-
return {
|
|
100
|
-
isElementBrowserModalOpen: false,
|
|
101
|
-
emptyStateHandler,
|
|
102
|
-
// lazy so it doesn't run on editor initialization
|
|
103
|
-
// memo here to avoid using a singleton cache, avoids editor
|
|
104
|
-
// getting confused when two editors exist within the same page.
|
|
105
|
-
lazyDefaultItems: () => memoProcessQuickInsertItems(defaultItems || [], getIntl())
|
|
106
|
-
};
|
|
107
|
-
},
|
|
108
|
-
apply(tr, pluginState) {
|
|
109
|
-
const meta = tr.getMeta(pluginKey);
|
|
110
|
-
if (meta) {
|
|
111
|
-
const keys = Object.keys(meta);
|
|
112
|
-
const changed = keys.some(key => {
|
|
113
|
-
return pluginState[key] !== meta[key];
|
|
114
|
-
});
|
|
115
|
-
if (changed) {
|
|
116
|
-
const newState = {
|
|
117
|
-
...pluginState,
|
|
118
|
-
...meta
|
|
119
|
-
};
|
|
120
|
-
dispatch(pluginKey, newState);
|
|
121
|
-
return newState;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return pluginState;
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
view(editorView) {
|
|
128
|
-
const providerHandler = async (_name, providerPromise) => {
|
|
129
|
-
if (providerPromise) {
|
|
130
|
-
try {
|
|
131
|
-
const provider = await providerPromise;
|
|
132
|
-
const providedItems = await provider.getItems();
|
|
133
|
-
setProviderState({
|
|
134
|
-
provider,
|
|
135
|
-
providedItems
|
|
136
|
-
})(editorView.state, editorView.dispatch);
|
|
137
|
-
} catch (e) {
|
|
138
|
-
// eslint-disable-next-line no-console
|
|
139
|
-
console.error('Error getting items from quick insert provider', e);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
providerFactory.subscribe('quickInsertProvider', providerHandler);
|
|
144
|
-
return {
|
|
145
|
-
destroy() {
|
|
146
|
-
providerFactory.unsubscribe('quickInsertProvider', providerHandler);
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { dedupe } from '@atlaskit/editor-common/utils';
|
|
2
|
-
import { find } from '@atlaskit/editor-common/quick-insert';
|
|
3
|
-
export const getQuickInsertSuggestions = (searchOptions, lazyDefaultItems = () => [], providedItems) => {
|
|
4
|
-
const {
|
|
5
|
-
query,
|
|
6
|
-
category,
|
|
7
|
-
disableDefaultItems,
|
|
8
|
-
featuredItems
|
|
9
|
-
} = searchOptions;
|
|
10
|
-
const defaultItems = disableDefaultItems ? [] : lazyDefaultItems();
|
|
11
|
-
const items = providedItems ? dedupe([...defaultItems, ...providedItems], item => item.title) : defaultItems;
|
|
12
|
-
if (featuredItems) {
|
|
13
|
-
return items.filter(item => item.featured);
|
|
14
|
-
}
|
|
15
|
-
return find(query || '', category === 'all' || !category ? items : items.filter(item => item.categories && item.categories.includes(category)));
|
|
16
|
-
};
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import React, { useState, useCallback } from 'react';
|
|
3
|
-
import { css, jsx } from '@emotion/react';
|
|
4
|
-
import { injectIntl } from 'react-intl-next';
|
|
5
|
-
import { DN50, N0 } from '@atlaskit/theme/colors';
|
|
6
|
-
import { themed } from '@atlaskit/theme/components';
|
|
7
|
-
import { borderRadius } from '@atlaskit/theme/constants';
|
|
8
|
-
import Button from '@atlaskit/button/custom-theme-button';
|
|
9
|
-
import Modal, { ModalTransition, useModal } from '@atlaskit/modal-dialog';
|
|
10
|
-
import QuestionCircleIcon from '@atlaskit/icon/glyph/question-circle';
|
|
11
|
-
import { ElementBrowser } from '@atlaskit/editor-common/element-browser';
|
|
12
|
-
import { getCategories } from './categories';
|
|
13
|
-
import { messages } from './messages';
|
|
14
|
-
export const MODAL_WRAPPER_PADDING = 16;
|
|
15
|
-
const actions = css`
|
|
16
|
-
display: inline-flex;
|
|
17
|
-
margin: 0 -4px;
|
|
18
|
-
`;
|
|
19
|
-
const actionItem = css`
|
|
20
|
-
flex: 1 0 auto;
|
|
21
|
-
margin: 0 ${"var(--ds-space-050, 4px)"};
|
|
22
|
-
`;
|
|
23
|
-
const wrapper = css`
|
|
24
|
-
display: flex;
|
|
25
|
-
flex: 1 1 auto;
|
|
26
|
-
box-sizing: border-box;
|
|
27
|
-
padding: ${"var(--ds-space-200, 16px)"} ${"var(--ds-space-200, 16px)"} 0 10px;
|
|
28
|
-
overflow: hidden;
|
|
29
|
-
background-color: ${themed({
|
|
30
|
-
light: `var(--ds-surface-overlay, ${N0})`,
|
|
31
|
-
dark: `var(--ds-surface-overlay, ${DN50})`
|
|
32
|
-
})()};
|
|
33
|
-
border-radius: ${borderRadius()}px;
|
|
34
|
-
`;
|
|
35
|
-
const modalFooter = css`
|
|
36
|
-
display: flex;
|
|
37
|
-
padding: ${"var(--ds-space-200, 16px)"};
|
|
38
|
-
|
|
39
|
-
position: relative;
|
|
40
|
-
align-items: center;
|
|
41
|
-
justify-content: space-between;
|
|
42
|
-
`;
|
|
43
|
-
const ModalElementBrowser = props => {
|
|
44
|
-
const [selectedItem, setSelectedItem] = useState();
|
|
45
|
-
const {
|
|
46
|
-
helpUrl,
|
|
47
|
-
intl,
|
|
48
|
-
onClose,
|
|
49
|
-
onInsertItem: onInsertItemFn
|
|
50
|
-
} = props;
|
|
51
|
-
const onSelectItem = useCallback(item => {
|
|
52
|
-
setSelectedItem(item);
|
|
53
|
-
}, [setSelectedItem]);
|
|
54
|
-
const onInsertItem = useCallback(item => {
|
|
55
|
-
onInsertItemFn(item);
|
|
56
|
-
}, [onInsertItemFn]);
|
|
57
|
-
const RenderFooter = useCallback(() => jsx(Footer, {
|
|
58
|
-
onInsert: () => onInsertItem(selectedItem),
|
|
59
|
-
beforeElement: helpUrl ? HelpLink(helpUrl, intl.formatMessage(messages.help)) : undefined
|
|
60
|
-
}), [onInsertItem, selectedItem, helpUrl, intl]);
|
|
61
|
-
|
|
62
|
-
// Since Modal uses stackIndex it's shouldCloseOnEscapePress prop doesn't work.
|
|
63
|
-
const onKeyDown = useCallback(e => {
|
|
64
|
-
if (e.key === 'Escape') {
|
|
65
|
-
onClose();
|
|
66
|
-
}
|
|
67
|
-
}, [onClose]);
|
|
68
|
-
const RenderBody = useCallback(() => jsx("div", {
|
|
69
|
-
css: wrapper
|
|
70
|
-
}, jsx(ElementBrowser, {
|
|
71
|
-
categories: getCategories(props.intl),
|
|
72
|
-
getItems: props.getItems,
|
|
73
|
-
showSearch: true,
|
|
74
|
-
showCategories: true,
|
|
75
|
-
mode: "full",
|
|
76
|
-
onSelectItem: onSelectItem,
|
|
77
|
-
onInsertItem: onInsertItem,
|
|
78
|
-
emptyStateHandler: props.emptyStateHandler
|
|
79
|
-
})), [props.intl, props.getItems, onSelectItem, onInsertItem, props.emptyStateHandler]);
|
|
80
|
-
return jsx("div", {
|
|
81
|
-
"data-editor-popup": true,
|
|
82
|
-
onClick: onModalClick,
|
|
83
|
-
onKeyDown: onKeyDown
|
|
84
|
-
}, jsx(ModalTransition, null, props.isOpen && jsx(Modal, {
|
|
85
|
-
testId: "element-browser-modal-dialog",
|
|
86
|
-
stackIndex: 0,
|
|
87
|
-
key: "element-browser-modal",
|
|
88
|
-
onClose: props.onClose,
|
|
89
|
-
height: "664px",
|
|
90
|
-
width: "x-large",
|
|
91
|
-
autoFocus: false
|
|
92
|
-
// defaults to true and doesn't work along with stackIndex=1.
|
|
93
|
-
// packages/design-system/modal-dialog/src/components/Content.tsx Line 287
|
|
94
|
-
,
|
|
95
|
-
shouldCloseOnEscapePress: false
|
|
96
|
-
}, jsx(RenderBody, null), jsx(RenderFooter, null))));
|
|
97
|
-
};
|
|
98
|
-
ModalElementBrowser.displayName = 'ModalElementBrowser';
|
|
99
|
-
|
|
100
|
-
// Prevent ModalElementBrowser click propagation through to the editor.
|
|
101
|
-
const onModalClick = e => e.stopPropagation();
|
|
102
|
-
const Footer = ({
|
|
103
|
-
onInsert,
|
|
104
|
-
beforeElement
|
|
105
|
-
}) => {
|
|
106
|
-
const {
|
|
107
|
-
onClose
|
|
108
|
-
} = useModal();
|
|
109
|
-
return jsx("div", {
|
|
110
|
-
css: modalFooter
|
|
111
|
-
}, beforeElement ? beforeElement : jsx("span", null), jsx("div", {
|
|
112
|
-
css: actions
|
|
113
|
-
}, jsx("div", {
|
|
114
|
-
css: actionItem
|
|
115
|
-
}, jsx(Button, {
|
|
116
|
-
appearance: "primary",
|
|
117
|
-
onClick: onInsert,
|
|
118
|
-
testId: "ModalElementBrowser__insert-button"
|
|
119
|
-
}, "Insert")), jsx("div", {
|
|
120
|
-
css: actionItem
|
|
121
|
-
}, jsx(Button, {
|
|
122
|
-
appearance: "subtle",
|
|
123
|
-
onClick: onClose,
|
|
124
|
-
testId: "ModalElementBrowser__close-button"
|
|
125
|
-
}, "Close"))));
|
|
126
|
-
};
|
|
127
|
-
const HelpLink = (url, helpText) => jsx(Button, {
|
|
128
|
-
iconBefore: jsx(QuestionCircleIcon, {
|
|
129
|
-
label: "",
|
|
130
|
-
size: "medium"
|
|
131
|
-
}),
|
|
132
|
-
appearance: "subtle-link",
|
|
133
|
-
href: url,
|
|
134
|
-
target: "_blank",
|
|
135
|
-
testId: "ModalElementBrowser__help-button"
|
|
136
|
-
}, helpText);
|
|
137
|
-
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
|
-
const 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,51 +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
|
-
const Modal = ({
|
|
7
|
-
quickInsertState,
|
|
8
|
-
editorView,
|
|
9
|
-
helpUrl
|
|
10
|
-
}) => {
|
|
11
|
-
const getItems = useCallback((query, category) => getQuickInsertSuggestions({
|
|
12
|
-
query,
|
|
13
|
-
category
|
|
14
|
-
}, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems), [quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems]);
|
|
15
|
-
const focusInEditor = useCallback(() => {
|
|
16
|
-
if (!editorView.hasFocus()) {
|
|
17
|
-
editorView.focus();
|
|
18
|
-
}
|
|
19
|
-
}, [editorView]);
|
|
20
|
-
const onInsertItem = useCallback(item => {
|
|
21
|
-
closeElementBrowserModal()(editorView.state, editorView.dispatch);
|
|
22
|
-
focusInEditor();
|
|
23
|
-
insertItem(item)(editorView.state, editorView.dispatch);
|
|
24
|
-
}, [editorView, focusInEditor]);
|
|
25
|
-
const onClose = useCallback(() => {
|
|
26
|
-
closeElementBrowserModal()(editorView.state, editorView.dispatch);
|
|
27
|
-
focusInEditor();
|
|
28
|
-
}, [editorView, focusInEditor]);
|
|
29
|
-
return /*#__PURE__*/React.createElement(ModalElementBrowser, {
|
|
30
|
-
getItems: getItems,
|
|
31
|
-
onInsertItem: onInsertItem,
|
|
32
|
-
helpUrl: helpUrl,
|
|
33
|
-
isOpen: (quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.isElementBrowserModalOpen) || false,
|
|
34
|
-
emptyStateHandler: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.emptyStateHandler,
|
|
35
|
-
onClose: onClose
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
export default (({
|
|
39
|
-
editorView,
|
|
40
|
-
helpUrl,
|
|
41
|
-
pluginInjectionAPI
|
|
42
|
-
}) => {
|
|
43
|
-
const {
|
|
44
|
-
quickInsertState
|
|
45
|
-
} = useSharedPluginState(pluginInjectionAPI, ['quickInsert']);
|
|
46
|
-
return /*#__PURE__*/React.createElement(Modal, {
|
|
47
|
-
quickInsertState: quickInsertState !== null && quickInsertState !== void 0 ? quickInsertState : undefined,
|
|
48
|
-
editorView: editorView,
|
|
49
|
-
helpUrl: helpUrl
|
|
50
|
-
});
|
|
51
|
-
});
|