@atlaskit/editor-plugin-selection-toolbar
Version:
@atlaskit/editor-plugin-selection-toolbar for @atlaskit/editor-core
59 lines • 4.15 kB
JavaScript
/* overflow-toolbar-config.tsx generated by @compiled/babel-plugin v0.39.1 */
import * as React from 'react';
import { ax, ix } from "@compiled/react/runtime";
import { selectionToolbarMessages } from '@atlaskit/editor-common/messages';
import DockToolbarTopIcon from '@atlaskit/icon-lab/core/dock-toolbar-top';
import CheckMarkIcon from '@atlaskit/icon/core/check-mark';
import MinusIcon from '@atlaskit/icon/core/minus';
import { HeadingItem } from '@atlaskit/menu';
import { fg } from '@atlaskit/platform-feature-flags';
export var getOverflowPrimaryToolbarConfig = function getOverflowPrimaryToolbarConfig(_ref) {
var api = _ref.api,
intl = _ref.intl;
return [{
items: [{
content: /*#__PURE__*/React.createElement(HeadingItem, null, intl.formatMessage(selectionToolbarMessages.toolbarAppears)),
value: {
name: ''
},
isDisabled: true
}, {
content: intl.formatMessage(selectionToolbarMessages.toolbarPositionInline),
value: {
name: 'contextual'
},
onClick: function onClick() {
var _api$selectionToolbar, _api$selectionToolbar2, _api$selectionToolbar3;
if (fg('platform_editor_use_preferences_plugin')) {
var _api$core$actions$exe, _api$userPreferences, _api$userPreferences$;
return (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 || (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.actions) === null || _api$userPreferences === void 0 || (_api$userPreferences$ = _api$userPreferences.updateUserPreference) === null || _api$userPreferences$ === void 0 ? void 0 : _api$userPreferences$.call(_api$userPreferences, 'toolbarDockingPosition', 'none'))) !== null && _api$core$actions$exe !== void 0 ? _api$core$actions$exe : false;
}
return (_api$selectionToolbar = api === null || api === void 0 || (_api$selectionToolbar2 = api.selectionToolbar.actions) === null || _api$selectionToolbar2 === void 0 || (_api$selectionToolbar3 = _api$selectionToolbar2.setToolbarDocking) === null || _api$selectionToolbar3 === void 0 ? void 0 : _api$selectionToolbar3.call(_api$selectionToolbar2, 'none')) !== null && _api$selectionToolbar !== void 0 ? _api$selectionToolbar : false;
},
elemBefore: MinusIcon({
label: ''
})
}, {
content: intl.formatMessage(selectionToolbarMessages.toolbarPositionFixedAtTop),
value: {
name: 'fixed'
},
onClick: function onClick() {
var _api$selectionToolbar4, _api$selectionToolbar5, _api$selectionToolbar6;
if (fg('platform_editor_use_preferences_plugin')) {
var _api$core$actions$exe2, _api$userPreferences2, _api$userPreferences3;
return (_api$core$actions$exe2 = api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 || (_api$userPreferences2 = api.userPreferences) === null || _api$userPreferences2 === void 0 || (_api$userPreferences2 = _api$userPreferences2.actions) === null || _api$userPreferences2 === void 0 || (_api$userPreferences3 = _api$userPreferences2.updateUserPreference) === null || _api$userPreferences3 === void 0 ? void 0 : _api$userPreferences3.call(_api$userPreferences2, 'toolbarDockingPosition', 'top'))) !== null && _api$core$actions$exe2 !== void 0 ? _api$core$actions$exe2 : false;
}
return (_api$selectionToolbar4 = api === null || api === void 0 || (_api$selectionToolbar5 = api.selectionToolbar.actions) === null || _api$selectionToolbar5 === void 0 || (_api$selectionToolbar6 = _api$selectionToolbar5.setToolbarDocking) === null || _api$selectionToolbar6 === void 0 ? void 0 : _api$selectionToolbar6.call(_api$selectionToolbar5, 'top')) !== null && _api$selectionToolbar4 !== void 0 ? _api$selectionToolbar4 : false;
},
isActive: true,
elemBefore: DockToolbarTopIcon({
label: ''
}),
elemAfter: /*#__PURE__*/React.createElement(CheckMarkIcon, {
label: "",
size: "small"
})
}]
}];
};