No Description

index.js 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. import React from 'react';
  2. import { s as styleInject } from '../style-inject.es-1f59c1d0.js';
  3. import { _ as _defineProperty } from '../defineProperty-18999f8e.js';
  4. import '../index-e3cf212a.js';
  5. import '../slicedToArray-4cd9e6d3.js';
  6. import 'braft-editor';
  7. import { BarftEditorPage } from '../BraftEditor/index.js';
  8. export { default as BraftEditor } from '../BraftEditor/index.js';
  9. import 'braft-editor/dist/index.css';
  10. import 'braft-extensions/dist/emoticon.css';
  11. import 'braft-extensions/dist/emoticon';
  12. import 'braft-extensions/dist/max-length';
  13. function ownKeys(object, enumerableOnly) {
  14. var keys = Object.keys(object);
  15. if (Object.getOwnPropertySymbols) {
  16. var symbols = Object.getOwnPropertySymbols(object);
  17. if (enumerableOnly) symbols = symbols.filter(function (sym) {
  18. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  19. });
  20. keys.push.apply(keys, symbols);
  21. }
  22. return keys;
  23. }
  24. function _objectSpread(target) {
  25. for (var i = 1; i < arguments.length; i++) {
  26. var source = arguments[i] != null ? arguments[i] : {};
  27. if (i % 2) {
  28. ownKeys(Object(source), true).forEach(function (key) {
  29. _defineProperty(target, key, source[key]);
  30. });
  31. } else if (Object.getOwnPropertyDescriptors) {
  32. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  33. } else {
  34. ownKeys(Object(source)).forEach(function (key) {
  35. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  36. });
  37. }
  38. }
  39. return target;
  40. }
  41. var ControlsToolBar = function ControlsToolBar(props) {
  42. var editorState = props.editorState,
  43. setEditorState = props.setEditorState,
  44. _props$toolList = props.toolList,
  45. toolList = _props$toolList === void 0 ? [] : _props$toolList,
  46. _props$injectIconWrap = props.injectIconWrapStyle,
  47. injectIconWrapStyle = _props$injectIconWrap === void 0 ? {} : _props$injectIconWrap,
  48. _props$injectIconStyl = props.injectIconStyle,
  49. injectIconStyle = _props$injectIconStyl === void 0 ? {} : _props$injectIconStyl,
  50. _props$injectIconText = props.injectIconTextStyle,
  51. injectIconTextStyle = _props$injectIconText === void 0 ? {} : _props$injectIconText;
  52. var IconWrapStyle = _objectSpread({
  53. display: 'flex',
  54. alignItems: 'center',
  55. cursor: "pointer",
  56. textAlign: "center",
  57. minWidth: "42px"
  58. }, injectIconWrapStyle);
  59. var IconStyle = _objectSpread({
  60. fontSize: "21px"
  61. }, injectIconStyle);
  62. var IconTextStyle = _objectSpread({
  63. margin: "0 4px"
  64. }, injectIconTextStyle);
  65. if (toolList.length < 1) {
  66. return null;
  67. }
  68. return React.createElement(React.Fragment, null, toolList.map(function (i) {
  69. var innerIcon = React.createElement("i", {
  70. className: i.iconClass,
  71. style: IconStyle
  72. });
  73. var innerText = i.text ? React.createElement("span", {
  74. style: IconTextStyle
  75. }, i.text) : null;
  76. var divWrapStyle = _objectSpread({
  77. color: i.color
  78. }, IconWrapStyle);
  79. var wrapperDom = React.createElement("div", {
  80. key: "toolList_".concat(i.key),
  81. style: divWrapStyle,
  82. onClick: i.onClick
  83. }, innerIcon, innerText);
  84. if (i.render) {
  85. return i.render(i, innerIcon, innerText, divWrapStyle);
  86. }
  87. return wrapperDom;
  88. }));
  89. };
  90. var css = ".index_bottomToolBarWrapper__DzhzC {\n display: flex;\n}\n";
  91. var styles = {
  92. "bottomToolBarWrapper": "index_bottomToolBarWrapper__DzhzC"
  93. };
  94. styleInject(css);
  95. var SimpleEditor = function SimpleEditor(props) {
  96. var value = props.value,
  97. onChange = props.onChange,
  98. _props$toolAlign = props.toolAlign,
  99. toolAlign = _props$toolAlign === void 0 ? 'inner' : _props$toolAlign,
  100. _props$toolList = props.toolList,
  101. toolList = _props$toolList === void 0 ? [] : _props$toolList,
  102. _props$injectControls = props.injectControlsToolBar,
  103. injectControlsToolBar = _props$injectControls === void 0 ? {} : _props$injectControls,
  104. _props$toolBarContain = props.toolBarContainerStyle,
  105. toolBarContainerStyle = _props$toolBarContain === void 0 ? {} : _props$toolBarContain,
  106. _props$appendToolBtn = props.appendToolBtn,
  107. appendToolBtn = _props$appendToolBtn === void 0 ? null : _props$appendToolBtn;
  108. if (toolAlign === 'inner') {
  109. return React.createElement(BarftEditorPage, {
  110. value: value,
  111. onChange: onChange,
  112. controls: [],
  113. FloatControls: function FloatControls(_ref) {
  114. var editorState = _ref.editorState,
  115. setEditorState = _ref.setEditorState;
  116. return React.createElement(ControlsToolBar, {
  117. editorState: editorState,
  118. setEditorState: setEditorState,
  119. toolList: toolList
  120. });
  121. }
  122. });
  123. }
  124. return React.createElement("div", null, React.createElement(BarftEditorPage, {
  125. value: value,
  126. onChange: onChange,
  127. controls: []
  128. }), React.createElement("div", {
  129. style: toolBarContainerStyle
  130. }, React.createElement("div", {
  131. className: styles.bottomToolBarWrapper
  132. }, React.createElement(ControlsToolBar, Object.assign({
  133. editorState: value,
  134. setEditorState: onChange,
  135. toolList: toolList
  136. }, injectControlsToolBar))), appendToolBtn));
  137. };
  138. export { SimpleEditor };
  139. //# sourceMappingURL=index.js.map