No Description

index.js 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. className: i.iconTextClass,
  75. style: IconTextStyle
  76. }, i.text) : null;
  77. var divWrapStyle = _objectSpread({
  78. color: i.color
  79. }, IconWrapStyle);
  80. var wrapperDom = React.createElement("div", {
  81. key: "toolList_".concat(i.key),
  82. style: divWrapStyle,
  83. onClick: i.onClick
  84. }, innerIcon, innerText);
  85. if (i.render) {
  86. return i.render(i, innerIcon, innerText, divWrapStyle);
  87. }
  88. return wrapperDom;
  89. }));
  90. };
  91. var css = ".index_bottomToolBarWrapper__DzhzC {\n display: flex;\n}\n";
  92. var styles = {
  93. "bottomToolBarWrapper": "index_bottomToolBarWrapper__DzhzC"
  94. };
  95. styleInject(css);
  96. var SimpleEditor = function SimpleEditor(props) {
  97. var value = props.value,
  98. onChange = props.onChange,
  99. _props$toolAlign = props.toolAlign,
  100. toolAlign = _props$toolAlign === void 0 ? 'inner' : _props$toolAlign,
  101. _props$toolList = props.toolList,
  102. toolList = _props$toolList === void 0 ? [] : _props$toolList,
  103. _props$injectControls = props.injectControlsToolBar,
  104. injectControlsToolBar = _props$injectControls === void 0 ? {} : _props$injectControls,
  105. _props$toolBarContain = props.toolBarContainerStyle,
  106. toolBarContainerStyle = _props$toolBarContain === void 0 ? {} : _props$toolBarContain,
  107. _props$injectBraftEdi = props.injectBraftEditorProps,
  108. injectBraftEditorProps = _props$injectBraftEdi === void 0 ? {} : _props$injectBraftEdi,
  109. _props$appendToolBtn = props.appendToolBtn,
  110. appendToolBtn = _props$appendToolBtn === void 0 ? null : _props$appendToolBtn,
  111. _props$appendInnderBa = props.appendInnderBar,
  112. appendInnderBar = _props$appendInnderBa === void 0 ? null : _props$appendInnderBa;
  113. if (toolAlign === 'inner') {
  114. return React.createElement(BarftEditorPage, Object.assign({
  115. value: value,
  116. onChange: onChange,
  117. controls: [],
  118. FloatControls: function FloatControls(_ref) {
  119. var editorState = _ref.editorState,
  120. setEditorState = _ref.setEditorState;
  121. return React.createElement(ControlsToolBar, Object.assign({
  122. editorState: editorState,
  123. setEditorState: setEditorState,
  124. toolList: toolList
  125. }, injectControlsToolBar));
  126. }
  127. }, injectBraftEditorProps));
  128. }
  129. if (toolAlign === 'both') {
  130. return React.createElement("div", null, React.createElement(BarftEditorPage, Object.assign({
  131. value: value,
  132. onChange: onChange,
  133. controls: [],
  134. FloatControls: function FloatControls() {
  135. return appendInnderBar;
  136. }
  137. }, injectBraftEditorProps)), React.createElement("div", {
  138. style: toolBarContainerStyle
  139. }, React.createElement("div", {
  140. className: styles.bottomToolBarWrapper
  141. }, React.createElement(ControlsToolBar, Object.assign({
  142. editorState: value,
  143. setEditorState: onChange,
  144. toolList: toolList
  145. }, injectControlsToolBar))), appendToolBtn));
  146. }
  147. return React.createElement("div", null, React.createElement(BarftEditorPage, Object.assign({
  148. value: value,
  149. onChange: onChange,
  150. controls: []
  151. }, injectBraftEditorProps)), React.createElement("div", {
  152. style: toolBarContainerStyle
  153. }, React.createElement("div", {
  154. className: styles.bottomToolBarWrapper
  155. }, React.createElement(ControlsToolBar, Object.assign({
  156. editorState: value,
  157. setEditorState: onChange,
  158. toolList: toolList
  159. }, injectControlsToolBar))), appendToolBtn));
  160. };
  161. export { SimpleEditor };
  162. //# sourceMappingURL=index.js.map