Нет описания

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