@atlaskit/editor-plugin-toolbar
Version:
Toolbar plugin for @atlaskit/editor-core
39 lines • 1.83 kB
JavaScript
import React, { useCallback } from 'react';
import { EditorToolbarProvider } from '@atlaskit/editor-common/toolbar/context';
import { EditorToolbarUIProvider } from '@atlaskit/editor-common/toolbar/EditorToolbarUIProvider';
import { useToolbarUI } from '@atlaskit/editor-toolbar/ui-context';
/**
* Editor and toolbar UI context shared by the floating toolbars (selection and element).
*/
export var ToolbarProviders = function ToolbarProviders(_ref) {
var api = _ref.api,
children = _ref.children,
editorToolbarDockingPreference = _ref.editorToolbarDockingPreference,
editorView = _ref.editorView,
editorViewMode = _ref.editorViewMode,
isOffline = _ref.isOffline,
keyboardNavigation = _ref.keyboardNavigation,
popupsBoundariesElement = _ref.popupsBoundariesElement,
popupsMountPoint = _ref.popupsMountPoint,
popupsScrollableElement = _ref.popupsScrollableElement;
var _useToolbarUI = useToolbarUI(),
isDisabled = _useToolbarUI.isDisabled;
var fireAnalyticsEvent = useCallback(function (payload) {
var _api$analytics;
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent(payload);
}, [api]);
return /*#__PURE__*/React.createElement(EditorToolbarProvider, {
editorView: editorView,
editorToolbarDockingPreference: editorToolbarDockingPreference,
editorViewMode: editorViewMode,
isOffline: isOffline
}, /*#__PURE__*/React.createElement(EditorToolbarUIProvider, {
api: api,
isDisabled: isDisabled,
fireAnalyticsEvent: fireAnalyticsEvent,
keyboardNavigation: keyboardNavigation,
popupsMountPoint: popupsMountPoint,
popupsBoundariesElement: popupsBoundariesElement,
popupsScrollableElement: popupsScrollableElement
}, children));
};