@atlaskit/editor-core 187.32.6 → 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 +37 -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 +7 -7
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
9
2
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
10
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
3
|
/** @jsx jsx */
|
|
13
|
-
import
|
|
4
|
+
import { useCallback, useEffect } from 'react';
|
|
14
5
|
import { jsx } from '@emotion/react';
|
|
15
6
|
import { injectIntl, defineMessages, FormattedMessage } from 'react-intl-next';
|
|
16
7
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
@@ -26,6 +17,7 @@ import { messages as undoRedoMessages } from '../../undo-redo/messages';
|
|
|
26
17
|
import { alignmentMessages } from '../../../ui/Alignment/messages';
|
|
27
18
|
import { closeHelpCommand } from '../commands';
|
|
28
19
|
import { annotationMessages } from '../../annotation/toolbar';
|
|
20
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
29
21
|
var messages = defineMessages({
|
|
30
22
|
editorHelp: {
|
|
31
23
|
id: 'fabric.editor.editorHelp',
|
|
@@ -476,98 +468,74 @@ var ModalFooter = function ModalFooter() {
|
|
|
476
468
|
}
|
|
477
469
|
})));
|
|
478
470
|
};
|
|
479
|
-
var HelpDialog =
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
}, {
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
}).map(function (form) {
|
|
550
|
-
return jsx("li", {
|
|
551
|
-
css: row,
|
|
552
|
-
key: "autoFormatting-".concat(form.name)
|
|
553
|
-
}, jsx("span", null, form.name), form.autoFormatting());
|
|
554
|
-
}))), jsx("div", {
|
|
555
|
-
css: line
|
|
556
|
-
}), jsx("div", {
|
|
557
|
-
css: column
|
|
558
|
-
}, jsx("h2", {
|
|
559
|
-
css: title
|
|
560
|
-
}, jsx(FormattedMessage, messages.markdown)), jsx("ul", null, this.formatting.filter(function (form) {
|
|
561
|
-
return shortcutNamesWithoutKeymap.indexOf(form.type) === -1;
|
|
562
|
-
}).map(function (form) {
|
|
563
|
-
return form.autoFormatting && jsx("li", {
|
|
564
|
-
key: "autoFormatting-".concat(form.name),
|
|
565
|
-
css: row
|
|
566
|
-
}, jsx("span", null, form.name), form.autoFormatting());
|
|
567
|
-
}))))), jsx(ModalFooter, null)) : null);
|
|
568
|
-
}
|
|
569
|
-
}]);
|
|
570
|
-
return HelpDialog;
|
|
571
|
-
}(React.Component);
|
|
572
|
-
_defineProperty(HelpDialog, "displayName", 'HelpDialog');
|
|
471
|
+
var HelpDialog = function HelpDialog(_ref6) {
|
|
472
|
+
var pluginInjectionApi = _ref6.pluginInjectionApi,
|
|
473
|
+
editorView = _ref6.editorView,
|
|
474
|
+
quickInsertEnabled = _ref6.quickInsertEnabled,
|
|
475
|
+
intl = _ref6.intl;
|
|
476
|
+
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['helpDialog']),
|
|
477
|
+
helpDialogState = _useSharedPluginState.helpDialogState;
|
|
478
|
+
var closeDialog = useCallback(function () {
|
|
479
|
+
var tr = editorView.state.tr,
|
|
480
|
+
dispatch = editorView.dispatch;
|
|
481
|
+
closeHelpCommand(tr, dispatch);
|
|
482
|
+
}, [editorView]);
|
|
483
|
+
var handleEsc = useCallback(function (e) {
|
|
484
|
+
if (e.key === 'Escape' && helpDialogState !== null && helpDialogState !== void 0 && helpDialogState.isVisible) {
|
|
485
|
+
closeDialog();
|
|
486
|
+
}
|
|
487
|
+
}, [closeDialog, helpDialogState === null || helpDialogState === void 0 ? void 0 : helpDialogState.isVisible]);
|
|
488
|
+
useEffect(function () {
|
|
489
|
+
document.addEventListener('keydown', handleEsc);
|
|
490
|
+
return function () {
|
|
491
|
+
document.removeEventListener('keydown', handleEsc);
|
|
492
|
+
};
|
|
493
|
+
}, [handleEsc]);
|
|
494
|
+
var formatting = getSupportedFormatting(editorView.state.schema, intl, helpDialogState === null || helpDialogState === void 0 ? void 0 : helpDialogState.imageEnabled, quickInsertEnabled);
|
|
495
|
+
return jsx(ModalTransition, null, helpDialogState !== null && helpDialogState !== void 0 && helpDialogState.isVisible ? jsx(AkModalDialog, {
|
|
496
|
+
width: "large",
|
|
497
|
+
onClose: closeDialog,
|
|
498
|
+
testId: "help-modal-dialog"
|
|
499
|
+
}, jsx(ModalHeader, null), jsx("div", {
|
|
500
|
+
css: contentWrapper
|
|
501
|
+
}, jsx("div", {
|
|
502
|
+
css: line
|
|
503
|
+
}), jsx("div", {
|
|
504
|
+
css: content
|
|
505
|
+
}, jsx("div", {
|
|
506
|
+
css: column
|
|
507
|
+
}, jsx("h2", {
|
|
508
|
+
css: title
|
|
509
|
+
}, jsx(FormattedMessage, messages.keyboardShortcuts)), jsx("ul", null, formatting.filter(function (form) {
|
|
510
|
+
var keymap = form.keymap && form.keymap();
|
|
511
|
+
return keymap && keymap[browser.mac ? 'mac' : 'windows'];
|
|
512
|
+
}).map(function (form) {
|
|
513
|
+
return jsx("li", {
|
|
514
|
+
css: row,
|
|
515
|
+
key: "textFormatting-".concat(form.name)
|
|
516
|
+
}, jsx("span", null, form.name), getComponentFromKeymap(form.keymap()));
|
|
517
|
+
}), formatting.filter(function (form) {
|
|
518
|
+
return shortcutNamesWithoutKeymap.indexOf(form.type) !== -1;
|
|
519
|
+
}).filter(function (form) {
|
|
520
|
+
return form.autoFormatting;
|
|
521
|
+
}).map(function (form) {
|
|
522
|
+
return jsx("li", {
|
|
523
|
+
css: row,
|
|
524
|
+
key: "autoFormatting-".concat(form.name)
|
|
525
|
+
}, jsx("span", null, form.name), form.autoFormatting());
|
|
526
|
+
}))), jsx("div", {
|
|
527
|
+
css: line
|
|
528
|
+
}), jsx("div", {
|
|
529
|
+
css: column
|
|
530
|
+
}, jsx("h2", {
|
|
531
|
+
css: title
|
|
532
|
+
}, jsx(FormattedMessage, messages.markdown)), jsx("ul", null, formatting.filter(function (form) {
|
|
533
|
+
return shortcutNamesWithoutKeymap.indexOf(form.type) === -1;
|
|
534
|
+
}).map(function (form) {
|
|
535
|
+
return form.autoFormatting && jsx("li", {
|
|
536
|
+
key: "autoFormatting-".concat(form.name),
|
|
537
|
+
css: row
|
|
538
|
+
}, jsx("span", null, form.name), form.autoFormatting());
|
|
539
|
+
}))))), jsx(ModalFooter, null)) : null);
|
|
540
|
+
};
|
|
573
541
|
export default injectIntl(HelpDialog);
|
|
@@ -3,7 +3,8 @@ import PickerFacadeProvider from './PickerFacadeProvider';
|
|
|
3
3
|
import { Clipboard } from '@atlaskit/media-picker';
|
|
4
4
|
export var ClipboardWrapper = function ClipboardWrapper(_ref) {
|
|
5
5
|
var mediaState = _ref.mediaState,
|
|
6
|
-
featureFlags = _ref.featureFlags
|
|
6
|
+
featureFlags = _ref.featureFlags,
|
|
7
|
+
container = _ref.container;
|
|
7
8
|
return /*#__PURE__*/React.createElement(PickerFacadeProvider, {
|
|
8
9
|
mediaState: mediaState,
|
|
9
10
|
analyticsName: "clipboard"
|
|
@@ -11,9 +12,17 @@ export var ClipboardWrapper = function ClipboardWrapper(_ref) {
|
|
|
11
12
|
var mediaClientConfig = _ref2.mediaClientConfig,
|
|
12
13
|
config = _ref2.config,
|
|
13
14
|
pickerFacadeInstance = _ref2.pickerFacadeInstance;
|
|
15
|
+
var clipboardConfig = Object.assign({}, config);
|
|
16
|
+
if ((featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.securedClipboard) === true) {
|
|
17
|
+
clipboardConfig.container = container;
|
|
18
|
+
clipboardConfig.onPaste = function (event) {
|
|
19
|
+
event.stopPropagation();
|
|
20
|
+
return false;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
14
23
|
return /*#__PURE__*/React.createElement(Clipboard, {
|
|
15
24
|
mediaClientConfig: mediaClientConfig,
|
|
16
|
-
config:
|
|
25
|
+
config: clipboardConfig,
|
|
17
26
|
onError: pickerFacadeInstance.handleUploadError,
|
|
18
27
|
onPreviewUpdate: pickerFacadeInstance.handleUploadPreviewUpdate,
|
|
19
28
|
onEnd: pickerFacadeInstance.handleReady,
|
|
@@ -22,9 +22,11 @@ var MediaPicker = function MediaPicker(_ref) {
|
|
|
22
22
|
var _useSharedPluginState = useSharedPluginState(api, ['focus']),
|
|
23
23
|
focusState = _useSharedPluginState.focusState;
|
|
24
24
|
var featureFlags = mediaState.mediaOptions && mediaState.mediaOptions.featureFlags;
|
|
25
|
+
var container = editorDomElement;
|
|
25
26
|
var clipboard = focusState !== null && focusState !== void 0 && focusState.hasFocus ? /*#__PURE__*/React.createElement(ClipboardWrapper, {
|
|
26
27
|
mediaState: mediaState,
|
|
27
|
-
featureFlags: featureFlags
|
|
28
|
+
featureFlags: featureFlags,
|
|
29
|
+
container: container
|
|
28
30
|
}) : null;
|
|
29
31
|
return /*#__PURE__*/React.createElement(React.Fragment, null, clipboard, /*#__PURE__*/React.createElement(DropzoneWrapper, {
|
|
30
32
|
mediaState: mediaState,
|
|
@@ -7,12 +7,13 @@ import React from 'react';
|
|
|
7
7
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
8
8
|
import { TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
|
|
9
9
|
import { pluginKey } from './plugin-key';
|
|
10
|
-
import { search } from './search';
|
|
11
10
|
import ModalElementBrowser from './ui/ModalElementBrowser';
|
|
12
11
|
import { openElementBrowserModal, insertItem } from './commands';
|
|
13
|
-
import { memoProcessQuickInsertItems
|
|
12
|
+
import { memoProcessQuickInsertItems } from '@atlaskit/editor-common/quick-insert';
|
|
13
|
+
import { getQuickInsertSuggestions } from './search';
|
|
14
14
|
var quickInsertPlugin = function quickInsertPlugin(_ref) {
|
|
15
|
-
var options = _ref.config
|
|
15
|
+
var options = _ref.config,
|
|
16
|
+
api = _ref.api;
|
|
16
17
|
return {
|
|
17
18
|
name: 'quickInsert',
|
|
18
19
|
pmPlugins: function pmPlugins(defaultItems) {
|
|
@@ -37,13 +38,9 @@ var quickInsertPlugin = function quickInsertPlugin(_ref) {
|
|
|
37
38
|
editorState = _ref3.editorState;
|
|
38
39
|
var quickInsertState = pluginKey.getState(editorState);
|
|
39
40
|
return Promise.resolve(getQuickInsertSuggestions({
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
},
|
|
44
|
-
lazyDefaultItems: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems,
|
|
45
|
-
providedItems: quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems
|
|
46
|
-
}));
|
|
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));
|
|
47
44
|
},
|
|
48
45
|
selectItem: function selectItem(state, item, insert) {
|
|
49
46
|
return item.action(insert, state);
|
|
@@ -61,7 +58,6 @@ var quickInsertPlugin = function quickInsertPlugin(_ref) {
|
|
|
61
58
|
return null;
|
|
62
59
|
},
|
|
63
60
|
getSharedState: function getSharedState(editorState) {
|
|
64
|
-
var _quickInsertState$sug;
|
|
65
61
|
if (!editorState) {
|
|
66
62
|
return null;
|
|
67
63
|
}
|
|
@@ -70,16 +66,22 @@ var quickInsertPlugin = function quickInsertPlugin(_ref) {
|
|
|
70
66
|
return null;
|
|
71
67
|
}
|
|
72
68
|
return {
|
|
73
|
-
suggestions: (_quickInsertState$sug = quickInsertState.suggestions) !== null && _quickInsertState$sug !== void 0 ? _quickInsertState$sug : [],
|
|
74
69
|
lazyDefaultItems: quickInsertState.lazyDefaultItems,
|
|
75
|
-
emptyStateHandler: quickInsertState.emptyStateHandler
|
|
70
|
+
emptyStateHandler: quickInsertState.emptyStateHandler,
|
|
71
|
+
providedItems: quickInsertState.providedItems
|
|
76
72
|
};
|
|
77
73
|
},
|
|
78
74
|
actions: {
|
|
79
|
-
insertItem: insertItem
|
|
75
|
+
insertItem: insertItem,
|
|
76
|
+
getSuggestions: function getSuggestions(searchOptions) {
|
|
77
|
+
var _api$quickInsert$shar;
|
|
78
|
+
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 : {},
|
|
79
|
+
lazyDefaultItems = _ref5.lazyDefaultItems,
|
|
80
|
+
providedItems = _ref5.providedItems;
|
|
81
|
+
return getQuickInsertSuggestions(searchOptions, lazyDefaultItems, providedItems);
|
|
82
|
+
}
|
|
80
83
|
},
|
|
81
84
|
commands: {
|
|
82
|
-
search: search,
|
|
83
85
|
openElementBrowserModal: openElementBrowserModal
|
|
84
86
|
}
|
|
85
87
|
};
|
|
@@ -106,20 +108,12 @@ function quickInsertPluginFactory(defaultItems, providerFactory, getIntl, dispat
|
|
|
106
108
|
// getting confused when two editors exist within the same page.
|
|
107
109
|
lazyDefaultItems: function lazyDefaultItems() {
|
|
108
110
|
return memoProcessQuickInsertItems(defaultItems || [], getIntl());
|
|
109
|
-
}
|
|
110
|
-
suggestions: []
|
|
111
|
+
}
|
|
111
112
|
};
|
|
112
113
|
},
|
|
113
114
|
apply: function apply(tr, pluginState) {
|
|
114
115
|
var meta = tr.getMeta(pluginKey);
|
|
115
116
|
if (meta) {
|
|
116
|
-
if ('searchOptions' in meta) {
|
|
117
|
-
meta.suggestions = getQuickInsertSuggestions({
|
|
118
|
-
searchOptions: meta.searchOptions,
|
|
119
|
-
lazyDefaultItems: pluginState.lazyDefaultItems,
|
|
120
|
-
providedItems: pluginState.providedItems
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
117
|
var keys = Object.keys(meta);
|
|
124
118
|
var changed = keys.some(function (key) {
|
|
125
119
|
return pluginState[key] !== meta[key];
|
|
@@ -135,7 +129,7 @@ function quickInsertPluginFactory(defaultItems, providerFactory, getIntl, dispat
|
|
|
135
129
|
},
|
|
136
130
|
view: function view(editorView) {
|
|
137
131
|
var providerHandler = /*#__PURE__*/function () {
|
|
138
|
-
var
|
|
132
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_name, providerPromise) {
|
|
139
133
|
var provider, providedItems;
|
|
140
134
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
141
135
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -171,7 +165,7 @@ function quickInsertPluginFactory(defaultItems, providerFactory, getIntl, dispat
|
|
|
171
165
|
}, _callee, null, [[1, 11]]);
|
|
172
166
|
}));
|
|
173
167
|
return function providerHandler(_x, _x2) {
|
|
174
|
-
return
|
|
168
|
+
return _ref6.apply(this, arguments);
|
|
175
169
|
};
|
|
176
170
|
}();
|
|
177
171
|
providerFactory.subscribe('quickInsertProvider', providerHandler);
|
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return function (_ref2) {
|
|
8
|
-
var tr = _ref2.tr;
|
|
9
|
-
return tr.setMeta(pluginKey, {
|
|
10
|
-
searchOptions: {
|
|
11
|
-
query: query,
|
|
12
|
-
category: category,
|
|
13
|
-
disableDefaultItems: disableDefaultItems,
|
|
14
|
-
featuredItems: featuredItems
|
|
15
|
-
}
|
|
16
|
-
});
|
|
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 [];
|
|
17
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
|
+
}));
|
|
18
25
|
};
|
|
@@ -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
|
var Modal = function Modal(_ref) {
|
|
8
8
|
var quickInsertState = _ref.quickInsertState,
|
|
9
9
|
editorView = _ref.editorView,
|
|
10
10
|
helpUrl = _ref.helpUrl;
|
|
11
11
|
var getItems = useCallback(function (query, category) {
|
|
12
12
|
return 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
|
-
});
|
|
13
|
+
query: query,
|
|
14
|
+
category: category
|
|
15
|
+
}, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems);
|
|
20
16
|
}, [quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.lazyDefaultItems, quickInsertState === null || quickInsertState === void 0 ? void 0 : quickInsertState.providedItems]);
|
|
21
17
|
var focusInEditor = useCallback(function () {
|
|
22
18
|
if (!editorView.hasFocus()) {
|
|
@@ -20,18 +20,24 @@ import { css, jsx } from '@emotion/react';
|
|
|
20
20
|
import Transition from 'react-transition-group/Transition';
|
|
21
21
|
import { N30 } from '@atlaskit/theme/colors';
|
|
22
22
|
import { akEditorSwoopCubicBezier, akEditorDefaultLayoutWidth, akEditorWideLayoutWidth, akEditorBreakoutPadding, akEditorContextPanelWidth, ATLASSIAN_NAVIGATION_HEIGHT } from '@atlaskit/editor-shared-styles';
|
|
23
|
-
import { ContextPanelConsumer } from '@atlaskit/editor-common/ui';
|
|
23
|
+
import { ContextPanelConsumer, WidthContext } from '@atlaskit/editor-common/ui';
|
|
24
24
|
import WithPluginState from '../WithPluginState';
|
|
25
25
|
import WithEditorActions from '../WithEditorActions';
|
|
26
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
26
27
|
import { getChildBreakoutModes } from '../../utils/document';
|
|
27
|
-
import {
|
|
28
|
+
import { findChildrenByType } from '@atlaskit/editor-prosemirror/utils';
|
|
28
29
|
var ANIM_SPEED_MS = 500;
|
|
29
30
|
var EDITOR_WIDTH = akEditorDefaultLayoutWidth + akEditorBreakoutPadding;
|
|
30
31
|
var WIDE_EDITOR_WIDTH = akEditorWideLayoutWidth + akEditorBreakoutPadding;
|
|
31
32
|
var FULLWIDTH_MODE = 'full-width';
|
|
32
33
|
var WIDE_MODE = 'wide';
|
|
33
34
|
var absolutePanelStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: absolute;\n right: 0;\n height: calc(100% - ", ");\n"])), ATLASSIAN_NAVIGATION_HEIGHT);
|
|
34
|
-
|
|
35
|
+
var checkTableExistsInDoc = function checkTableExistsInDoc(editorView) {
|
|
36
|
+
var tableNodeSchema = editorView.state.schema.nodes.table;
|
|
37
|
+
var findResult = findChildrenByType(editorView.state.doc, tableNodeSchema);
|
|
38
|
+
return findResult.length > 0;
|
|
39
|
+
};
|
|
40
|
+
export var shouldPanelBePositionedOverEditor = function shouldPanelBePositionedOverEditor(editorWidth, panelWidth, editorView) {
|
|
35
41
|
var lineLength = editorWidth.lineLength,
|
|
36
42
|
_editorWidth$containe = editorWidth.containerWidth,
|
|
37
43
|
containerWidth = _editorWidth$containe === void 0 ? 0 : _editorWidth$containe,
|
|
@@ -39,7 +45,17 @@ export var shouldPanelBePositionedOverEditor = function shouldPanelBePositionedO
|
|
|
39
45
|
var editorNotFullWidth = !(lineLength && lineLength > akEditorDefaultLayoutWidth);
|
|
40
46
|
var hasSpaceForPanel = !contentBreakoutModes.length && containerWidth >= panelWidth * 2 + EDITOR_WIDTH;
|
|
41
47
|
var hasSpaceForWideBreakoutsAndPanel = !contentBreakoutModes.includes(FULLWIDTH_MODE) && contentBreakoutModes.includes(WIDE_MODE) && containerWidth >= panelWidth * 2 + WIDE_EDITOR_WIDTH;
|
|
42
|
-
|
|
48
|
+
if (!getBooleanFF('platform.editor.custom-table-width') || !editorView) {
|
|
49
|
+
return editorNotFullWidth && (hasSpaceForPanel || hasSpaceForWideBreakoutsAndPanel);
|
|
50
|
+
} else {
|
|
51
|
+
// when custom table width feature flag is on,
|
|
52
|
+
// there are scenarios when a table has attr layout default, but width is in full-width or very wide
|
|
53
|
+
// but in this case we still want the shouldPanelBePositionedOverEditor return false
|
|
54
|
+
// previous logic is returning false when table layout default
|
|
55
|
+
// but when custom table width feature flag is one, we want to return false whenever there is a table in the doc
|
|
56
|
+
var isTableInDoc = checkTableExistsInDoc(editorView);
|
|
57
|
+
return editorNotFullWidth && (hasSpaceForPanel || hasSpaceForWideBreakoutsAndPanel) && !isTableInDoc;
|
|
58
|
+
}
|
|
43
59
|
};
|
|
44
60
|
var panelHidden = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n width: 0;\n"])));
|
|
45
61
|
export var panel = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n width: ", "px;\n height: 100%;\n transition: width ", "ms ", ";\n overflow: hidden;\n box-shadow: inset 2px 0 0 0 ", ";\n"])), akEditorContextPanelWidth, ANIM_SPEED_MS, akEditorSwoopCubicBezier, "var(--ds-border, ".concat(N30, ")"));
|
|
@@ -115,7 +131,9 @@ export var SwappableContentArea = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
115
131
|
key: "render",
|
|
116
132
|
value: function render() {
|
|
117
133
|
var _this2 = this;
|
|
118
|
-
var
|
|
134
|
+
var _this$props = this.props,
|
|
135
|
+
editorWidth = _this$props.editorWidth,
|
|
136
|
+
editorView = _this$props.editorView;
|
|
119
137
|
var width = akEditorContextPanelWidth;
|
|
120
138
|
var userVisible = !!this.props.visible;
|
|
121
139
|
var visible = userVisible || !!this.state.currentPluginContent;
|
|
@@ -124,7 +142,7 @@ export var SwappableContentArea = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
124
142
|
broadcastPosition = _ref.broadcastPosition,
|
|
125
143
|
positionedOverEditor = _ref.positionedOverEditor;
|
|
126
144
|
var contextPanelWidth = visible ? width : 0;
|
|
127
|
-
var newPosition = editorWidth ? shouldPanelBePositionedOverEditor(editorWidth, width) : false;
|
|
145
|
+
var newPosition = editorWidth ? shouldPanelBePositionedOverEditor(editorWidth, width, editorView) : false;
|
|
128
146
|
broadcastWidth(contextPanelWidth);
|
|
129
147
|
(newPosition && visible) !== positionedOverEditor && broadcastPosition(newPosition && visible);
|
|
130
148
|
return jsx("div", {
|
|
@@ -18,7 +18,7 @@ import withOuterListeners from '../with-outer-listeners';
|
|
|
18
18
|
import ElementBrowser from './components/ElementBrowserLoader';
|
|
19
19
|
import { ELEMENT_ITEM_HEIGHT } from './constants';
|
|
20
20
|
var InsertMenu = function InsertMenu(_ref) {
|
|
21
|
-
var _pluginInjectionApi$
|
|
21
|
+
var _pluginInjectionApi$q6, _pluginInjectionApi$q7, _pluginInjectionApi$q8;
|
|
22
22
|
var editorView = _ref.editorView,
|
|
23
23
|
dropdownItems = _ref.dropdownItems,
|
|
24
24
|
showElementBrowserLink = _ref.showElementBrowserLink,
|
|
@@ -72,25 +72,23 @@ var InsertMenu = function InsertMenu(_ref) {
|
|
|
72
72
|
* @see above transform function for more details.
|
|
73
73
|
*/
|
|
74
74
|
if (query) {
|
|
75
|
-
var _pluginInjectionApi$q2, _pluginInjectionApi$q3
|
|
76
|
-
|
|
75
|
+
var _pluginInjectionApi$q2, _pluginInjectionApi$q3;
|
|
76
|
+
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({
|
|
77
77
|
query: query,
|
|
78
78
|
category: category
|
|
79
|
-
}));
|
|
80
|
-
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 : [];
|
|
79
|
+
})) !== null && _pluginInjectionApi$q2 !== void 0 ? _pluginInjectionApi$q2 : [];
|
|
81
80
|
} else {
|
|
82
|
-
var _pluginInjectionApi$
|
|
83
|
-
|
|
81
|
+
var _pluginInjectionApi$q4, _pluginInjectionApi$q5;
|
|
82
|
+
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({
|
|
84
83
|
category: category,
|
|
85
84
|
featuredItems: true
|
|
86
|
-
}));
|
|
87
|
-
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 : [];
|
|
85
|
+
})) !== null && _pluginInjectionApi$q4 !== void 0 ? _pluginInjectionApi$q4 : [];
|
|
88
86
|
result = quickInsertDropdownItems.concat(featuredQuickInsertSuggestions);
|
|
89
87
|
}
|
|
90
88
|
setItemCount(result.length);
|
|
91
89
|
return result;
|
|
92
|
-
}, [pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 :
|
|
93
|
-
var emptyStateHandler = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
90
|
+
}, [pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$q6 = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q6 === void 0 ? void 0 : _pluginInjectionApi$q6.actions, quickInsertDropdownItems]);
|
|
91
|
+
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;
|
|
94
92
|
return jsx("div", {
|
|
95
93
|
css: function css(theme) {
|
|
96
94
|
return insertMenuWrapper(theme, itemCount);
|
|
@@ -100,9 +100,9 @@ export declare function createDefaultPreset(options: EditorPresetProps & Default
|
|
|
100
100
|
sharedState: import("@atlaskit/editor-common/types").QuickInsertSharedState | null;
|
|
101
101
|
actions: {
|
|
102
102
|
insertItem: (item: import("@atlaskit/editor-common/provider-factory").QuickInsertItem) => import("../../..").Command;
|
|
103
|
+
getSuggestions: (searchOptions: import("@atlaskit/editor-common/types").QuickInsertSearchOptions) => import("@atlaskit/editor-common/provider-factory").QuickInsertItem[];
|
|
103
104
|
};
|
|
104
105
|
commands: {
|
|
105
|
-
search: import("../../../plugins/quick-insert/search").QuickInsertSearch;
|
|
106
106
|
openElementBrowserModal: import("@atlaskit/editor-common/types").EditorCommand;
|
|
107
107
|
};
|
|
108
108
|
}, QuickInsertPluginOptions | undefined>, import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"width", {
|
|
@@ -225,9 +225,9 @@ export declare function useDefaultPreset(props: EditorPresetProps & DefaultPrese
|
|
|
225
225
|
sharedState: import("@atlaskit/editor-common/types").QuickInsertSharedState | null;
|
|
226
226
|
actions: {
|
|
227
227
|
insertItem: (item: import("@atlaskit/editor-common/provider-factory").QuickInsertItem) => import("../../..").Command;
|
|
228
|
+
getSuggestions: (searchOptions: import("@atlaskit/editor-common/types").QuickInsertSearchOptions) => import("@atlaskit/editor-common/provider-factory").QuickInsertItem[];
|
|
228
229
|
};
|
|
229
230
|
commands: {
|
|
230
|
-
search: import("../../../plugins/quick-insert/search").QuickInsertSearch;
|
|
231
231
|
openElementBrowserModal: import("@atlaskit/editor-common/types").EditorCommand;
|
|
232
232
|
};
|
|
233
233
|
}, QuickInsertPluginOptions | undefined>, import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"width", {
|
|
@@ -3,11 +3,16 @@ import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/t
|
|
|
3
3
|
import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
4
|
import type quickInsertPlugin from '../quick-insert';
|
|
5
5
|
export declare function createPlugin(dispatch: Function, imageEnabled: boolean): SafePlugin<any>;
|
|
6
|
+
interface HelpDialogSharedState {
|
|
7
|
+
isVisible: boolean;
|
|
8
|
+
imageEnabled: boolean;
|
|
9
|
+
}
|
|
6
10
|
declare const helpDialog: NextEditorPlugin<'helpDialog', {
|
|
7
11
|
dependencies: [
|
|
8
12
|
OptionalPlugin<typeof analyticsPlugin>,
|
|
9
13
|
OptionalPlugin<typeof quickInsertPlugin>
|
|
10
14
|
];
|
|
11
15
|
pluginConfiguration: boolean;
|
|
16
|
+
sharedState: HelpDialogSharedState | null;
|
|
12
17
|
}>;
|
|
13
18
|
export default helpDialog;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import Loadable from 'react-loadable';
|
|
3
|
-
import type {
|
|
3
|
+
import type { HelpDialogProps } from './index';
|
|
4
4
|
export declare const HelpDialogLoader: import("react").ComponentType<HelpDialogProps> & Loadable.LoadableComponent;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import React from 'react';
|
|
1
|
+
/// <reference types="react" />
|
|
3
2
|
import { jsx } from '@emotion/react';
|
|
4
3
|
import type { IntlShape, WrappedComponentProps } from 'react-intl-next';
|
|
5
4
|
import type { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
6
5
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
7
6
|
import type { Keymap } from '@atlaskit/editor-common/keymaps';
|
|
7
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
8
|
+
import type helpDialogPlugin from '..';
|
|
8
9
|
export interface Format {
|
|
9
10
|
name: string;
|
|
10
11
|
type: string;
|
|
@@ -15,13 +16,12 @@ export interface Format {
|
|
|
15
16
|
export declare const formatting: (intl: IntlShape) => Format[];
|
|
16
17
|
export declare const getSupportedFormatting: (schema: Schema, intl: IntlShape, imageEnabled?: boolean, quickInsertEnabled?: boolean) => Format[];
|
|
17
18
|
export declare const getComponentFromKeymap: (keymap: Keymap) => jsx.JSX.Element;
|
|
18
|
-
export interface
|
|
19
|
+
export interface HelpDialogProps {
|
|
20
|
+
pluginInjectionApi: ExtractInjectionAPI<typeof helpDialogPlugin> | undefined;
|
|
19
21
|
editorView: EditorView;
|
|
20
|
-
isVisible: boolean;
|
|
21
|
-
imageEnabled?: boolean;
|
|
22
22
|
quickInsertEnabled?: boolean;
|
|
23
23
|
}
|
|
24
|
-
declare const _default:
|
|
25
|
-
WrappedComponent:
|
|
24
|
+
declare const _default: import("react").FC<import("react-intl-next").WithIntlProps<HelpDialogProps & WrappedComponentProps<"intl">>> & {
|
|
25
|
+
WrappedComponent: import("react").ComponentType<HelpDialogProps & WrappedComponentProps<"intl">>;
|
|
26
26
|
};
|
|
27
27
|
export default _default;
|