UNPKG

@atlaskit/editor-core

Version:

A package contains Atlassian editor core functionality

40 lines (38 loc) 1.3 kB
/* ToolbarPortal.tsx generated by @compiled/babel-plugin v0.39.1 */ import "./ToolbarPortal.compiled.css"; import { ax, ix } from "@compiled/react/runtime"; import React from 'react'; const ToolbarPortalContext = /*#__PURE__*/React.createContext(undefined); export const ToolbarPortalContextProvider = ({ children, portal, isActive }) => { const value = React.useMemo(() => ({ Portal: portal, isActive }), [portal, isActive]); return /*#__PURE__*/React.createElement(ToolbarPortalContext.Provider, { value: value }, children); }; // NOTE: This doesn't throw on undefined context on purpose, as it is likely that // the outer toolbar _won't_ have a context provider as it is unlikely to portal // anywhere export const useToolbarPortal = () => { return React.useContext(ToolbarPortalContext); }; const toolbarPortalStyles = { portal: "_1r04ze3t _kqswstnw _fiawglyw" }; export const ToolbarPortalMountPoint = () => { const portal = useToolbarPortal(); // Don't render a mountpoint when we're already inside a portal if (portal) { return null; } // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop return /*#__PURE__*/React.createElement("div", { className: ax([toolbarPortalStyles.portal, "ak-editor-toolbar-portal"]) }); };