UNPKG

@yuntijs/ui

Version:

☁️ Yunti UI - an open-source UI component library for building Cloud Native web apps

51 lines 2.66 kB
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray"; import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; var _excluded = ["showToolbar", "classname", "toolbarProps"]; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } import { LexicalComposer } from '@lexical/react/LexicalComposer'; import { useThemeMode } from 'antd-style'; import React from 'react'; import { Editor } from "./Editor"; import { Methods } from "./Methods"; import { Toolbar } from "./components/ToolBar"; import PlaygroundNodes from "./nodes/PlaygroundNodes"; import { useStyles } from "./style"; import PlaygroundEditorTheme from "./themes/PlaygroundEditorTheme"; import { jsx as _jsx } from "react/jsx-runtime"; import { jsxs as _jsxs } from "react/jsx-runtime"; export var RichTextEditor = /*#__PURE__*/React.forwardRef(function (_ref, ref) { var showToolbar = _ref.showToolbar, classname = _ref.classname, toolbarProps = _ref.toolbarProps, props = _objectWithoutProperties(_ref, _excluded); var _useStyles = useStyles({ autoSize: { minRows: 1 }, code: false }), styles = _useStyles.styles, cx = _useStyles.cx; var _useThemeMode = useThemeMode(), isDarkMode = _useThemeMode.isDarkMode; var initialConfig = { namespace: 'RichTextEditor', nodes: _toConsumableArray(PlaygroundNodes), onError: function onError(error) { throw error; }, theme: PlaygroundEditorTheme }; return /*#__PURE__*/_jsx(LexicalComposer, { initialConfig: initialConfig, children: /*#__PURE__*/_jsxs("div", { className: cx(styles.wrapper, classname), "data-theme": isDarkMode ? 'dark' : 'light', children: [showToolbar ? /*#__PURE__*/_jsx(Toolbar, _objectSpread({}, toolbarProps)) : null, /*#__PURE__*/_jsx(Editor, _objectSpread({}, props)), /*#__PURE__*/_jsx(Methods, { mdxRef: ref })] }) }); });