@atlaskit/editor-core 187.32.7 → 187.33.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 +30 -0
- package/dist/cjs/plugins/help-dialog/index.js +10 -15
- package/dist/cjs/plugins/help-dialog/ui/index.js +74 -104
- package/dist/cjs/plugins/media/ui/MediaPicker/ClipboardWrapper.js +11 -2
- package/dist/cjs/plugins/media/ui/MediaPicker/index.js +3 -1
- package/dist/cjs/plugins/quick-insert/index.js +20 -26
- package/dist/cjs/plugins/quick-insert/search.js +26 -18
- package/dist/cjs/plugins/quick-insert/ui/ModalElementBrowser/index.js +5 -9
- package/dist/cjs/ui/ContextPanel/index.js +23 -4
- package/dist/cjs/ui/ElementBrowser/InsertMenu.js +9 -11
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/help-dialog/index.js +10 -13
- package/dist/es2019/plugins/help-dialog/ui/index.js +65 -70
- package/dist/es2019/plugins/media/ui/MediaPicker/ClipboardWrapper.js +20 -9
- package/dist/es2019/plugins/media/ui/MediaPicker/index.js +3 -1
- package/dist/es2019/plugins/quick-insert/index.js +19 -24
- package/dist/es2019/plugins/quick-insert/search.js +11 -11
- package/dist/es2019/plugins/quick-insert/ui/ModalElementBrowser/index.js +4 -8
- package/dist/es2019/ui/ContextPanel/index.js +23 -6
- package/dist/es2019/ui/ElementBrowser/InsertMenu.js +9 -11
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/help-dialog/index.js +10 -15
- package/dist/esm/plugins/help-dialog/ui/index.js +72 -104
- package/dist/esm/plugins/media/ui/MediaPicker/ClipboardWrapper.js +11 -2
- package/dist/esm/plugins/media/ui/MediaPicker/index.js +3 -1
- package/dist/esm/plugins/quick-insert/index.js +20 -26
- package/dist/esm/plugins/quick-insert/search.js +23 -16
- package/dist/esm/plugins/quick-insert/ui/ModalElementBrowser/index.js +4 -8
- package/dist/esm/ui/ContextPanel/index.js +24 -6
- package/dist/esm/ui/ElementBrowser/InsertMenu.js +9 -11
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/labs/next/presets/default.d.ts +2 -2
- package/dist/types/plugins/help-dialog/index.d.ts +5 -0
- package/dist/types/plugins/help-dialog/ui/HelpDialogLoader.d.ts +1 -1
- package/dist/types/plugins/help-dialog/ui/index.d.ts +7 -7
- package/dist/types/plugins/media/ui/MediaPicker/ClipboardWrapper.d.ts +4 -3
- package/dist/types/plugins/quick-insert/index.d.ts +2 -3
- package/dist/types/plugins/quick-insert/search.d.ts +5 -3
- package/dist/types/ui/ContextPanel/index.d.ts +1 -1
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +2 -2
- package/dist/types-ts4.5/plugins/help-dialog/index.d.ts +5 -0
- package/dist/types-ts4.5/plugins/help-dialog/ui/HelpDialogLoader.d.ts +1 -1
- package/dist/types-ts4.5/plugins/help-dialog/ui/index.d.ts +7 -7
- package/dist/types-ts4.5/plugins/media/ui/MediaPicker/ClipboardWrapper.d.ts +4 -3
- package/dist/types-ts4.5/plugins/quick-insert/index.d.ts +2 -3
- package/dist/types-ts4.5/plugins/quick-insert/search.d.ts +5 -3
- package/dist/types-ts4.5/ui/ContextPanel/index.d.ts +1 -1
- package/package.json +5 -5
|
@@ -24,7 +24,7 @@ var _templateObject, _templateObject2;
|
|
|
24
24
|
// AFP-2532 TODO: Fix automatic suppressions below
|
|
25
25
|
// eslint-disable-next-line @atlassian/tangerine/import/entry-points
|
|
26
26
|
var InsertMenu = function InsertMenu(_ref) {
|
|
27
|
-
var _pluginInjectionApi$
|
|
27
|
+
var _pluginInjectionApi$q6, _pluginInjectionApi$q7, _pluginInjectionApi$q8;
|
|
28
28
|
var editorView = _ref.editorView,
|
|
29
29
|
dropdownItems = _ref.dropdownItems,
|
|
30
30
|
showElementBrowserLink = _ref.showElementBrowserLink,
|
|
@@ -78,25 +78,23 @@ var InsertMenu = function InsertMenu(_ref) {
|
|
|
78
78
|
* @see above transform function for more details.
|
|
79
79
|
*/
|
|
80
80
|
if (query) {
|
|
81
|
-
var _pluginInjectionApi$q2, _pluginInjectionApi$q3
|
|
82
|
-
|
|
81
|
+
var _pluginInjectionApi$q2, _pluginInjectionApi$q3;
|
|
82
|
+
result = (_pluginInjectionApi$q2 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$q3 = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q3 === void 0 ? void 0 : _pluginInjectionApi$q3.actions.getSuggestions({
|
|
83
83
|
query: query,
|
|
84
84
|
category: category
|
|
85
|
-
}));
|
|
86
|
-
result = (_pluginInjectionApi$q3 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$q4 = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q4 === void 0 ? void 0 : (_pluginInjectionApi$q5 = _pluginInjectionApi$q4.sharedState.currentState()) === null || _pluginInjectionApi$q5 === void 0 ? void 0 : _pluginInjectionApi$q5.suggestions) !== null && _pluginInjectionApi$q3 !== void 0 ? _pluginInjectionApi$q3 : [];
|
|
85
|
+
})) !== null && _pluginInjectionApi$q2 !== void 0 ? _pluginInjectionApi$q2 : [];
|
|
87
86
|
} else {
|
|
88
|
-
var _pluginInjectionApi$
|
|
89
|
-
|
|
87
|
+
var _pluginInjectionApi$q4, _pluginInjectionApi$q5;
|
|
88
|
+
var featuredQuickInsertSuggestions = (_pluginInjectionApi$q4 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$q5 = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q5 === void 0 ? void 0 : _pluginInjectionApi$q5.actions.getSuggestions({
|
|
90
89
|
category: category,
|
|
91
90
|
featuredItems: true
|
|
92
|
-
}));
|
|
93
|
-
var featuredQuickInsertSuggestions = (_pluginInjectionApi$q7 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$q8 = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q8 === void 0 ? void 0 : (_pluginInjectionApi$q9 = _pluginInjectionApi$q8.sharedState.currentState()) === null || _pluginInjectionApi$q9 === void 0 ? void 0 : _pluginInjectionApi$q9.suggestions) !== null && _pluginInjectionApi$q7 !== void 0 ? _pluginInjectionApi$q7 : [];
|
|
91
|
+
})) !== null && _pluginInjectionApi$q4 !== void 0 ? _pluginInjectionApi$q4 : [];
|
|
94
92
|
result = quickInsertDropdownItems.concat(featuredQuickInsertSuggestions);
|
|
95
93
|
}
|
|
96
94
|
setItemCount(result.length);
|
|
97
95
|
return result;
|
|
98
|
-
}, [pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 :
|
|
99
|
-
var emptyStateHandler = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
96
|
+
}, [pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$q6 = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q6 === void 0 ? void 0 : _pluginInjectionApi$q6.actions, quickInsertDropdownItems]);
|
|
97
|
+
var emptyStateHandler = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$q7 = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q7 === void 0 ? void 0 : (_pluginInjectionApi$q8 = _pluginInjectionApi$q7.sharedState.currentState()) === null || _pluginInjectionApi$q8 === void 0 ? void 0 : _pluginInjectionApi$q8.emptyStateHandler;
|
|
100
98
|
return (0, _react2.jsx)("div", {
|
|
101
99
|
css: function css(theme) {
|
|
102
100
|
return insertMenuWrapper(theme, itemCount);
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.version = exports.nextMajorVersion = exports.name = void 0;
|
|
7
7
|
var name = "@atlaskit/editor-core";
|
|
8
8
|
exports.name = name;
|
|
9
|
-
var version = "187.
|
|
9
|
+
var version = "187.33.0";
|
|
10
10
|
exports.version = version;
|
|
11
11
|
var nextMajorVersion = function nextMajorVersion() {
|
|
12
12
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
3
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
4
|
import { bindKeymapWithCommand, openHelp, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
5
|
-
import WithPluginState from '../../ui/WithPluginState';
|
|
6
5
|
import { HelpDialogLoader } from './ui/HelpDialogLoader';
|
|
7
6
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
8
7
|
import QuestionCircleIcon from '@atlaskit/icon/glyph/question-circle';
|
|
@@ -87,19 +86,17 @@ const helpDialog = ({
|
|
|
87
86
|
contentComponent({
|
|
88
87
|
editorView
|
|
89
88
|
}) {
|
|
90
|
-
return /*#__PURE__*/React.createElement(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
render: ({
|
|
95
|
-
helpDialog = {}
|
|
96
|
-
}) => /*#__PURE__*/React.createElement(HelpDialogLoader, {
|
|
97
|
-
editorView: editorView,
|
|
98
|
-
isVisible: helpDialog.isVisible,
|
|
99
|
-
quickInsertEnabled: !!(api !== null && api !== void 0 && api.quickInsert),
|
|
100
|
-
imageEnabled: helpDialog.imageEnabled
|
|
101
|
-
})
|
|
89
|
+
return /*#__PURE__*/React.createElement(HelpDialogLoader, {
|
|
90
|
+
pluginInjectionApi: api,
|
|
91
|
+
editorView: editorView,
|
|
92
|
+
quickInsertEnabled: !!(api !== null && api !== void 0 && api.quickInsert)
|
|
102
93
|
});
|
|
94
|
+
},
|
|
95
|
+
getSharedState(editorState) {
|
|
96
|
+
if (!editorState) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
return pluginKey.getState(editorState) || null;
|
|
103
100
|
}
|
|
104
101
|
});
|
|
105
102
|
const keymapPlugin = editorAnalyticsAPI => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
2
|
/** @jsx jsx */
|
|
4
|
-
import
|
|
3
|
+
import { useCallback, useEffect } from 'react';
|
|
5
4
|
import { jsx } from '@emotion/react';
|
|
6
5
|
import { injectIntl, defineMessages, FormattedMessage } from 'react-intl-next';
|
|
7
6
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
@@ -17,6 +16,7 @@ import { messages as undoRedoMessages } from '../../undo-redo/messages';
|
|
|
17
16
|
import { alignmentMessages } from '../../../ui/Alignment/messages';
|
|
18
17
|
import { closeHelpCommand } from '../commands';
|
|
19
18
|
import { annotationMessages } from '../../annotation/toolbar';
|
|
19
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
20
20
|
const messages = defineMessages({
|
|
21
21
|
editorHelp: {
|
|
22
22
|
id: 'fabric.editor.editorHelp',
|
|
@@ -365,73 +365,68 @@ const ModalFooter = () => jsx("div", {
|
|
|
365
365
|
keyMap: getComponentFromKeymap(openHelp)
|
|
366
366
|
}
|
|
367
367
|
})));
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
} = this.props.editorView;
|
|
379
|
-
closeHelpCommand(tr, dispatch);
|
|
380
|
-
});
|
|
381
|
-
_defineProperty(this, "handleEsc", e => {
|
|
382
|
-
if (e.key === 'Escape' && this.props.isVisible) {
|
|
383
|
-
this.closeDialog();
|
|
384
|
-
}
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
componentDidMount() {
|
|
388
|
-
document.addEventListener('keydown', this.handleEsc);
|
|
389
|
-
}
|
|
390
|
-
componentWillUnmount() {
|
|
391
|
-
document.removeEventListener('keydown', this.handleEsc);
|
|
392
|
-
}
|
|
393
|
-
render() {
|
|
368
|
+
const HelpDialog = ({
|
|
369
|
+
pluginInjectionApi,
|
|
370
|
+
editorView,
|
|
371
|
+
quickInsertEnabled,
|
|
372
|
+
intl
|
|
373
|
+
}) => {
|
|
374
|
+
const {
|
|
375
|
+
helpDialogState
|
|
376
|
+
} = useSharedPluginState(pluginInjectionApi, ['helpDialog']);
|
|
377
|
+
const closeDialog = useCallback(() => {
|
|
394
378
|
const {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
} =
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
|
|
379
|
+
state: {
|
|
380
|
+
tr
|
|
381
|
+
},
|
|
382
|
+
dispatch
|
|
383
|
+
} = editorView;
|
|
384
|
+
closeHelpCommand(tr, dispatch);
|
|
385
|
+
}, [editorView]);
|
|
386
|
+
const handleEsc = useCallback(e => {
|
|
387
|
+
if (e.key === 'Escape' && helpDialogState !== null && helpDialogState !== void 0 && helpDialogState.isVisible) {
|
|
388
|
+
closeDialog();
|
|
389
|
+
}
|
|
390
|
+
}, [closeDialog, helpDialogState === null || helpDialogState === void 0 ? void 0 : helpDialogState.isVisible]);
|
|
391
|
+
useEffect(() => {
|
|
392
|
+
document.addEventListener('keydown', handleEsc);
|
|
393
|
+
return () => {
|
|
394
|
+
document.removeEventListener('keydown', handleEsc);
|
|
395
|
+
};
|
|
396
|
+
}, [handleEsc]);
|
|
397
|
+
const formatting = getSupportedFormatting(editorView.state.schema, intl, helpDialogState === null || helpDialogState === void 0 ? void 0 : helpDialogState.imageEnabled, quickInsertEnabled);
|
|
398
|
+
return jsx(ModalTransition, null, helpDialogState !== null && helpDialogState !== void 0 && helpDialogState.isVisible ? jsx(AkModalDialog, {
|
|
399
|
+
width: "large",
|
|
400
|
+
onClose: closeDialog,
|
|
401
|
+
testId: "help-modal-dialog"
|
|
402
|
+
}, jsx(ModalHeader, null), jsx("div", {
|
|
403
|
+
css: contentWrapper
|
|
404
|
+
}, jsx("div", {
|
|
405
|
+
css: line
|
|
406
|
+
}), jsx("div", {
|
|
407
|
+
css: content
|
|
408
|
+
}, jsx("div", {
|
|
409
|
+
css: column
|
|
410
|
+
}, jsx("h2", {
|
|
411
|
+
css: title
|
|
412
|
+
}, jsx(FormattedMessage, messages.keyboardShortcuts)), jsx("ul", null, formatting.filter(form => {
|
|
413
|
+
const keymap = form.keymap && form.keymap();
|
|
414
|
+
return keymap && keymap[browser.mac ? 'mac' : 'windows'];
|
|
415
|
+
}).map(form => jsx("li", {
|
|
416
|
+
css: row,
|
|
417
|
+
key: `textFormatting-${form.name}`
|
|
418
|
+
}, jsx("span", null, form.name), getComponentFromKeymap(form.keymap()))), formatting.filter(form => shortcutNamesWithoutKeymap.indexOf(form.type) !== -1).filter(form => form.autoFormatting).map(form => jsx("li", {
|
|
419
|
+
css: row,
|
|
420
|
+
key: `autoFormatting-${form.name}`
|
|
421
|
+
}, jsx("span", null, form.name), form.autoFormatting())))), jsx("div", {
|
|
422
|
+
css: line
|
|
423
|
+
}), jsx("div", {
|
|
424
|
+
css: column
|
|
425
|
+
}, jsx("h2", {
|
|
426
|
+
css: title
|
|
427
|
+
}, jsx(FormattedMessage, messages.markdown)), jsx("ul", null, formatting.filter(form => shortcutNamesWithoutKeymap.indexOf(form.type) === -1).map(form => form.autoFormatting && jsx("li", {
|
|
428
|
+
key: `autoFormatting-${form.name}`,
|
|
429
|
+
css: row
|
|
430
|
+
}, jsx("span", null, form.name), form.autoFormatting())))))), jsx(ModalFooter, null)) : null);
|
|
431
|
+
};
|
|
437
432
|
export default injectIntl(HelpDialog);
|
|
@@ -3,7 +3,8 @@ import PickerFacadeProvider from './PickerFacadeProvider';
|
|
|
3
3
|
import { Clipboard } from '@atlaskit/media-picker';
|
|
4
4
|
export const ClipboardWrapper = ({
|
|
5
5
|
mediaState,
|
|
6
|
-
featureFlags
|
|
6
|
+
featureFlags,
|
|
7
|
+
container
|
|
7
8
|
}) => /*#__PURE__*/React.createElement(PickerFacadeProvider, {
|
|
8
9
|
mediaState: mediaState,
|
|
9
10
|
analyticsName: "clipboard"
|
|
@@ -11,11 +12,21 @@ export const ClipboardWrapper = ({
|
|
|
11
12
|
mediaClientConfig,
|
|
12
13
|
config,
|
|
13
14
|
pickerFacadeInstance
|
|
14
|
-
}) =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
15
|
+
}) => {
|
|
16
|
+
const clipboardConfig = Object.assign({}, config);
|
|
17
|
+
if ((featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.securedClipboard) === true) {
|
|
18
|
+
clipboardConfig.container = container;
|
|
19
|
+
clipboardConfig.onPaste = event => {
|
|
20
|
+
event.stopPropagation();
|
|
21
|
+
return false;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return /*#__PURE__*/React.createElement(Clipboard, {
|
|
25
|
+
mediaClientConfig: mediaClientConfig,
|
|
26
|
+
config: clipboardConfig,
|
|
27
|
+
onError: pickerFacadeInstance.handleUploadError,
|
|
28
|
+
onPreviewUpdate: pickerFacadeInstance.handleUploadPreviewUpdate,
|
|
29
|
+
onEnd: pickerFacadeInstance.handleReady,
|
|
30
|
+
featureFlags: featureFlags
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -16,9 +16,11 @@ const MediaPicker = ({
|
|
|
16
16
|
focusState
|
|
17
17
|
} = useSharedPluginState(api, ['focus']);
|
|
18
18
|
const featureFlags = mediaState.mediaOptions && mediaState.mediaOptions.featureFlags;
|
|
19
|
+
const container = editorDomElement;
|
|
19
20
|
const clipboard = focusState !== null && focusState !== void 0 && focusState.hasFocus ? /*#__PURE__*/React.createElement(ClipboardWrapper, {
|
|
20
21
|
mediaState: mediaState,
|
|
21
|
-
featureFlags: featureFlags
|
|
22
|
+
featureFlags: featureFlags,
|
|
23
|
+
container: container
|
|
22
24
|
}) : null;
|
|
23
25
|
return /*#__PURE__*/React.createElement(React.Fragment, null, clipboard, /*#__PURE__*/React.createElement(DropzoneWrapper, {
|
|
24
26
|
mediaState: mediaState,
|
|
@@ -2,12 +2,13 @@ import React from 'react';
|
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
3
|
import { TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
|
|
4
4
|
import { pluginKey } from './plugin-key';
|
|
5
|
-
import { search } from './search';
|
|
6
5
|
import ModalElementBrowser from './ui/ModalElementBrowser';
|
|
7
6
|
import { openElementBrowserModal, insertItem } from './commands';
|
|
8
|
-
import { memoProcessQuickInsertItems
|
|
7
|
+
import { memoProcessQuickInsertItems } from '@atlaskit/editor-common/quick-insert';
|
|
8
|
+
import { getQuickInsertSuggestions } from './search';
|
|
9
9
|
const quickInsertPlugin = ({
|
|
10
|
-
config: options
|
|
10
|
+
config: options,
|
|
11
|
+
api
|
|
11
12
|
}) => ({
|
|
12
13
|
name: 'quickInsert',
|
|
13
14
|
pmPlugins(defaultItems) {
|
|
@@ -32,13 +33,9 @@ const quickInsertPlugin = ({
|
|
|
32
33
|
}) {
|
|
33
34
|
const quickInsertState = pluginKey.getState(editorState);
|
|
34
35
|
return Promise.resolve(getQuickInsertSuggestions({
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
},
|
|
39
|
-
lazyDefaultItems: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems,
|
|
40
|
-
providedItems: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems
|
|
41
|
-
}));
|
|
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));
|
|
42
39
|
},
|
|
43
40
|
selectItem: (state, item, insert) => {
|
|
44
41
|
return item.action(insert, state);
|
|
@@ -57,7 +54,6 @@ const quickInsertPlugin = ({
|
|
|
57
54
|
return null;
|
|
58
55
|
},
|
|
59
56
|
getSharedState(editorState) {
|
|
60
|
-
var _quickInsertState$sug;
|
|
61
57
|
if (!editorState) {
|
|
62
58
|
return null;
|
|
63
59
|
}
|
|
@@ -66,16 +62,23 @@ const quickInsertPlugin = ({
|
|
|
66
62
|
return null;
|
|
67
63
|
}
|
|
68
64
|
return {
|
|
69
|
-
suggestions: (_quickInsertState$sug = quickInsertState.suggestions) !== null && _quickInsertState$sug !== void 0 ? _quickInsertState$sug : [],
|
|
70
65
|
lazyDefaultItems: quickInsertState.lazyDefaultItems,
|
|
71
|
-
emptyStateHandler: quickInsertState.emptyStateHandler
|
|
66
|
+
emptyStateHandler: quickInsertState.emptyStateHandler,
|
|
67
|
+
providedItems: quickInsertState.providedItems
|
|
72
68
|
};
|
|
73
69
|
},
|
|
74
70
|
actions: {
|
|
75
|
-
insertItem
|
|
71
|
+
insertItem,
|
|
72
|
+
getSuggestions: searchOptions => {
|
|
73
|
+
var _api$quickInsert$shar;
|
|
74
|
+
const {
|
|
75
|
+
lazyDefaultItems,
|
|
76
|
+
providedItems
|
|
77
|
+
} = (_api$quickInsert$shar = api === null || api === void 0 ? void 0 : api.quickInsert.sharedState.currentState()) !== null && _api$quickInsert$shar !== void 0 ? _api$quickInsert$shar : {};
|
|
78
|
+
return getQuickInsertSuggestions(searchOptions, lazyDefaultItems, providedItems);
|
|
79
|
+
}
|
|
76
80
|
},
|
|
77
81
|
commands: {
|
|
78
|
-
search,
|
|
79
82
|
openElementBrowserModal
|
|
80
83
|
}
|
|
81
84
|
});
|
|
@@ -97,20 +100,12 @@ function quickInsertPluginFactory(defaultItems, providerFactory, getIntl, dispat
|
|
|
97
100
|
// lazy so it doesn't run on editor initialization
|
|
98
101
|
// memo here to avoid using a singleton cache, avoids editor
|
|
99
102
|
// getting confused when two editors exist within the same page.
|
|
100
|
-
lazyDefaultItems: () => memoProcessQuickInsertItems(defaultItems || [], getIntl())
|
|
101
|
-
suggestions: []
|
|
103
|
+
lazyDefaultItems: () => memoProcessQuickInsertItems(defaultItems || [], getIntl())
|
|
102
104
|
};
|
|
103
105
|
},
|
|
104
106
|
apply(tr, pluginState) {
|
|
105
107
|
const meta = tr.getMeta(pluginKey);
|
|
106
108
|
if (meta) {
|
|
107
|
-
if ('searchOptions' in meta) {
|
|
108
|
-
meta.suggestions = getQuickInsertSuggestions({
|
|
109
|
-
searchOptions: meta.searchOptions,
|
|
110
|
-
lazyDefaultItems: pluginState.lazyDefaultItems,
|
|
111
|
-
providedItems: pluginState.providedItems
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
109
|
const keys = Object.keys(meta);
|
|
115
110
|
const changed = keys.some(key => {
|
|
116
111
|
return pluginState[key] !== meta[key];
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
disableDefaultItems,
|
|
6
|
-
featuredItems
|
|
7
|
-
}) => ({
|
|
8
|
-
tr
|
|
9
|
-
}) => tr.setMeta(pluginKey, {
|
|
10
|
-
searchOptions: {
|
|
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 {
|
|
11
5
|
query,
|
|
12
6
|
category,
|
|
13
7
|
disableDefaultItems,
|
|
14
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);
|
|
15
14
|
}
|
|
16
|
-
|
|
15
|
+
return find(query || '', category === 'all' || !category ? items : items.filter(item => item.categories && item.categories.includes(category)));
|
|
16
|
+
};
|
|
@@ -3,20 +3,16 @@ import WithPluginState from '../../../../ui/WithPluginState';
|
|
|
3
3
|
import { pluginKey } from '../../plugin-key';
|
|
4
4
|
import ModalElementBrowser from '../../../../ui/ElementBrowser/ModalElementBrowser';
|
|
5
5
|
import { closeElementBrowserModal, insertItem } from '../../commands';
|
|
6
|
-
import { getQuickInsertSuggestions } from '
|
|
6
|
+
import { getQuickInsertSuggestions } from '../../search';
|
|
7
7
|
const Modal = ({
|
|
8
8
|
quickInsertState,
|
|
9
9
|
editorView,
|
|
10
10
|
helpUrl
|
|
11
11
|
}) => {
|
|
12
12
|
const getItems = useCallback((query, category) => getQuickInsertSuggestions({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
lazyDefaultItems: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems,
|
|
18
|
-
providedItems: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems
|
|
19
|
-
}), [quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems]);
|
|
13
|
+
query,
|
|
14
|
+
category
|
|
15
|
+
}, 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]);
|
|
20
16
|
const focusInEditor = useCallback(() => {
|
|
21
17
|
if (!editorView.hasFocus()) {
|
|
22
18
|
editorView.focus();
|
|
@@ -6,11 +6,12 @@ import { css, jsx } from '@emotion/react';
|
|
|
6
6
|
import Transition from 'react-transition-group/Transition';
|
|
7
7
|
import { N30 } from '@atlaskit/theme/colors';
|
|
8
8
|
import { akEditorSwoopCubicBezier, akEditorDefaultLayoutWidth, akEditorWideLayoutWidth, akEditorBreakoutPadding, akEditorContextPanelWidth, ATLASSIAN_NAVIGATION_HEIGHT } from '@atlaskit/editor-shared-styles';
|
|
9
|
-
import { ContextPanelConsumer } from '@atlaskit/editor-common/ui';
|
|
9
|
+
import { ContextPanelConsumer, WidthContext } from '@atlaskit/editor-common/ui';
|
|
10
10
|
import WithPluginState from '../WithPluginState';
|
|
11
11
|
import WithEditorActions from '../WithEditorActions';
|
|
12
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
12
13
|
import { getChildBreakoutModes } from '../../utils/document';
|
|
13
|
-
import {
|
|
14
|
+
import { findChildrenByType } from '@atlaskit/editor-prosemirror/utils';
|
|
14
15
|
const ANIM_SPEED_MS = 500;
|
|
15
16
|
const EDITOR_WIDTH = akEditorDefaultLayoutWidth + akEditorBreakoutPadding;
|
|
16
17
|
const WIDE_EDITOR_WIDTH = akEditorWideLayoutWidth + akEditorBreakoutPadding;
|
|
@@ -21,7 +22,12 @@ const absolutePanelStyles = css`
|
|
|
21
22
|
right: 0;
|
|
22
23
|
height: calc(100% - ${ATLASSIAN_NAVIGATION_HEIGHT});
|
|
23
24
|
`;
|
|
24
|
-
|
|
25
|
+
const checkTableExistsInDoc = editorView => {
|
|
26
|
+
const tableNodeSchema = editorView.state.schema.nodes.table;
|
|
27
|
+
let findResult = findChildrenByType(editorView.state.doc, tableNodeSchema);
|
|
28
|
+
return findResult.length > 0;
|
|
29
|
+
};
|
|
30
|
+
export const shouldPanelBePositionedOverEditor = (editorWidth, panelWidth, editorView) => {
|
|
25
31
|
const {
|
|
26
32
|
lineLength,
|
|
27
33
|
containerWidth = 0,
|
|
@@ -30,7 +36,17 @@ export const shouldPanelBePositionedOverEditor = (editorWidth, panelWidth) => {
|
|
|
30
36
|
const editorNotFullWidth = !(lineLength && lineLength > akEditorDefaultLayoutWidth);
|
|
31
37
|
const hasSpaceForPanel = !contentBreakoutModes.length && containerWidth >= panelWidth * 2 + EDITOR_WIDTH;
|
|
32
38
|
const hasSpaceForWideBreakoutsAndPanel = !contentBreakoutModes.includes(FULLWIDTH_MODE) && contentBreakoutModes.includes(WIDE_MODE) && containerWidth >= panelWidth * 2 + WIDE_EDITOR_WIDTH;
|
|
33
|
-
|
|
39
|
+
if (!getBooleanFF('platform.editor.custom-table-width') || !editorView) {
|
|
40
|
+
return editorNotFullWidth && (hasSpaceForPanel || hasSpaceForWideBreakoutsAndPanel);
|
|
41
|
+
} else {
|
|
42
|
+
// when custom table width feature flag is on,
|
|
43
|
+
// there are scenarios when a table has attr layout default, but width is in full-width or very wide
|
|
44
|
+
// but in this case we still want the shouldPanelBePositionedOverEditor return false
|
|
45
|
+
// previous logic is returning false when table layout default
|
|
46
|
+
// but when custom table width feature flag is one, we want to return false whenever there is a table in the doc
|
|
47
|
+
const isTableInDoc = checkTableExistsInDoc(editorView);
|
|
48
|
+
return editorNotFullWidth && (hasSpaceForPanel || hasSpaceForWideBreakoutsAndPanel) && !isTableInDoc;
|
|
49
|
+
}
|
|
34
50
|
};
|
|
35
51
|
const panelHidden = css`
|
|
36
52
|
width: 0;
|
|
@@ -122,7 +138,8 @@ export class SwappableContentArea extends React.PureComponent {
|
|
|
122
138
|
}
|
|
123
139
|
render() {
|
|
124
140
|
const {
|
|
125
|
-
editorWidth
|
|
141
|
+
editorWidth,
|
|
142
|
+
editorView
|
|
126
143
|
} = this.props;
|
|
127
144
|
const width = akEditorContextPanelWidth;
|
|
128
145
|
const userVisible = !!this.props.visible;
|
|
@@ -133,7 +150,7 @@ export class SwappableContentArea extends React.PureComponent {
|
|
|
133
150
|
positionedOverEditor
|
|
134
151
|
}) => {
|
|
135
152
|
const contextPanelWidth = visible ? width : 0;
|
|
136
|
-
const newPosition = editorWidth ? shouldPanelBePositionedOverEditor(editorWidth, width) : false;
|
|
153
|
+
const newPosition = editorWidth ? shouldPanelBePositionedOverEditor(editorWidth, width, editorView) : false;
|
|
137
154
|
broadcastWidth(contextPanelWidth);
|
|
138
155
|
(newPosition && visible) !== positionedOverEditor && broadcastPosition(newPosition && visible);
|
|
139
156
|
return jsx("div", {
|
|
@@ -20,7 +20,7 @@ const InsertMenu = ({
|
|
|
20
20
|
toggleVisiblity,
|
|
21
21
|
pluginInjectionApi
|
|
22
22
|
}) => {
|
|
23
|
-
var _pluginInjectionApi$
|
|
23
|
+
var _pluginInjectionApi$q6, _pluginInjectionApi$q7, _pluginInjectionApi$q8;
|
|
24
24
|
const [itemCount, setItemCount] = useState(0);
|
|
25
25
|
const transform = useCallback(item => ({
|
|
26
26
|
title: item.content,
|
|
@@ -59,25 +59,23 @@ const InsertMenu = ({
|
|
|
59
59
|
* @see above transform function for more details.
|
|
60
60
|
*/
|
|
61
61
|
if (query) {
|
|
62
|
-
var _pluginInjectionApi$q2, _pluginInjectionApi$q3
|
|
63
|
-
|
|
62
|
+
var _pluginInjectionApi$q2, _pluginInjectionApi$q3;
|
|
63
|
+
result = (_pluginInjectionApi$q2 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$q3 = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q3 === void 0 ? void 0 : _pluginInjectionApi$q3.actions.getSuggestions({
|
|
64
64
|
query,
|
|
65
65
|
category
|
|
66
|
-
}));
|
|
67
|
-
result = (_pluginInjectionApi$q3 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$q4 = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q4 === void 0 ? void 0 : (_pluginInjectionApi$q5 = _pluginInjectionApi$q4.sharedState.currentState()) === null || _pluginInjectionApi$q5 === void 0 ? void 0 : _pluginInjectionApi$q5.suggestions) !== null && _pluginInjectionApi$q3 !== void 0 ? _pluginInjectionApi$q3 : [];
|
|
66
|
+
})) !== null && _pluginInjectionApi$q2 !== void 0 ? _pluginInjectionApi$q2 : [];
|
|
68
67
|
} else {
|
|
69
|
-
var _pluginInjectionApi$
|
|
70
|
-
|
|
68
|
+
var _pluginInjectionApi$q4, _pluginInjectionApi$q5;
|
|
69
|
+
const featuredQuickInsertSuggestions = (_pluginInjectionApi$q4 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$q5 = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q5 === void 0 ? void 0 : _pluginInjectionApi$q5.actions.getSuggestions({
|
|
71
70
|
category,
|
|
72
71
|
featuredItems: true
|
|
73
|
-
}));
|
|
74
|
-
const featuredQuickInsertSuggestions = (_pluginInjectionApi$q7 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$q8 = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q8 === void 0 ? void 0 : (_pluginInjectionApi$q9 = _pluginInjectionApi$q8.sharedState.currentState()) === null || _pluginInjectionApi$q9 === void 0 ? void 0 : _pluginInjectionApi$q9.suggestions) !== null && _pluginInjectionApi$q7 !== void 0 ? _pluginInjectionApi$q7 : [];
|
|
72
|
+
})) !== null && _pluginInjectionApi$q4 !== void 0 ? _pluginInjectionApi$q4 : [];
|
|
75
73
|
result = quickInsertDropdownItems.concat(featuredQuickInsertSuggestions);
|
|
76
74
|
}
|
|
77
75
|
setItemCount(result.length);
|
|
78
76
|
return result;
|
|
79
|
-
}, [pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 :
|
|
80
|
-
const emptyStateHandler = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
77
|
+
}, [pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$q6 = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q6 === void 0 ? void 0 : _pluginInjectionApi$q6.actions, quickInsertDropdownItems]);
|
|
78
|
+
const emptyStateHandler = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$q7 = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q7 === void 0 ? void 0 : (_pluginInjectionApi$q8 = _pluginInjectionApi$q7.sharedState.currentState()) === null || _pluginInjectionApi$q8 === void 0 ? void 0 : _pluginInjectionApi$q8.emptyStateHandler;
|
|
81
79
|
return jsx("div", {
|
|
82
80
|
css: theme => insertMenuWrapper(theme, itemCount)
|
|
83
81
|
}, jsx(ElementBrowserWrapper, {
|
|
@@ -5,7 +5,6 @@ import React from 'react';
|
|
|
5
5
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
6
6
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
7
7
|
import { bindKeymapWithCommand, openHelp, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
8
|
-
import WithPluginState from '../../ui/WithPluginState';
|
|
9
8
|
import { HelpDialogLoader } from './ui/HelpDialogLoader';
|
|
10
9
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
11
10
|
import QuestionCircleIcon from '@atlaskit/icon/glyph/question-circle';
|
|
@@ -93,21 +92,17 @@ var helpDialog = function helpDialog(_ref) {
|
|
|
93
92
|
},
|
|
94
93
|
contentComponent: function contentComponent(_ref4) {
|
|
95
94
|
var editorView = _ref4.editorView;
|
|
96
|
-
return /*#__PURE__*/React.createElement(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
render: function render(_ref5) {
|
|
101
|
-
var _ref5$helpDialog = _ref5.helpDialog,
|
|
102
|
-
helpDialog = _ref5$helpDialog === void 0 ? {} : _ref5$helpDialog;
|
|
103
|
-
return /*#__PURE__*/React.createElement(HelpDialogLoader, {
|
|
104
|
-
editorView: editorView,
|
|
105
|
-
isVisible: helpDialog.isVisible,
|
|
106
|
-
quickInsertEnabled: !!(api !== null && api !== void 0 && api.quickInsert),
|
|
107
|
-
imageEnabled: helpDialog.imageEnabled
|
|
108
|
-
});
|
|
109
|
-
}
|
|
95
|
+
return /*#__PURE__*/React.createElement(HelpDialogLoader, {
|
|
96
|
+
pluginInjectionApi: api,
|
|
97
|
+
editorView: editorView,
|
|
98
|
+
quickInsertEnabled: !!(api !== null && api !== void 0 && api.quickInsert)
|
|
110
99
|
});
|
|
100
|
+
},
|
|
101
|
+
getSharedState: function getSharedState(editorState) {
|
|
102
|
+
if (!editorState) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
return pluginKey.getState(editorState) || null;
|
|
111
106
|
}
|
|
112
107
|
};
|
|
113
108
|
};
|