UNPKG

@uiw/react-md-editor

Version:

A markdown editor with preview, implemented with React.js and TypeScript.

27 lines 1.08 kB
import _extends from "@babel/runtime/helpers/extends"; import React, { useContext, useMemo } from 'react'; import "./Child.css"; import Toolbar from "./index.js"; import { EditorContext } from "../../Context.js"; import { jsx as _jsx } from "react/jsx-runtime"; export default function Child(props) { var _ref = props || {}, prefixCls = _ref.prefixCls, groupName = _ref.groupName, commands = _ref.commands, children = _ref.children; var _useContext = useContext(EditorContext), _useContext$barPopup = _useContext.barPopup, barPopup = _useContext$barPopup === void 0 ? {} : _useContext$barPopup; return useMemo(() => /*#__PURE__*/_jsx("div", { className: prefixCls + "-toolbar-child " + (groupName && barPopup[groupName] ? 'active' : ''), onClick: e => e.stopPropagation(), children: Array.isArray(commands) ? /*#__PURE__*/_jsx(Toolbar, _extends({ commands: commands }, props, { isChild: true })) : children }), // eslint-disable-next-line react-hooks/exhaustive-deps [commands, barPopup, groupName, prefixCls]); }