暫無描述

index.js 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. require('react-dom');
  7. var styleInject_es = require('../style-inject.es-dcee06b6.js');
  8. var defineProperty = require('../defineProperty-ba7cd53d.js');
  9. require('../index-1143667e.js');
  10. require('../slicedToArray-172f4624.js');
  11. var BraftEditor = require('../BraftEditor/index.js');
  12. require('react-dom/server');
  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._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__default.createElement(React__default.Fragment, null, toolList.map(function (i) {
  69. var innerIcon = React__default.createElement("i", {
  70. className: i.iconClass,
  71. style: IconStyle
  72. });
  73. var innerText = i.text ? React__default.createElement("span", {
  74. style: IconTextStyle
  75. }, i.text) : null;
  76. var divWrapStyle = _objectSpread({
  77. color: i.color
  78. }, IconWrapStyle);
  79. var wrapperDom = React__default.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__3mYXO {\n display: flex;\n}\n";
  91. var styles = {
  92. "bottomToolBarWrapper": "index_bottomToolBarWrapper__3mYXO"
  93. };
  94. styleInject_es.styleInject(css);
  95. var QASimpleEditor = function QASimpleEditor(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__default.createElement(BraftEditor.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__default.createElement(ControlsToolBar, {
  117. editorState: editorState,
  118. setEditorState: setEditorState,
  119. toolList: toolList
  120. });
  121. }
  122. });
  123. }
  124. return React__default.createElement("div", null, React__default.createElement(BraftEditor.BarftEditorPage, {
  125. value: value,
  126. onChange: onChange,
  127. controls: []
  128. }), React__default.createElement("div", {
  129. style: toolBarContainerStyle
  130. }, React__default.createElement("div", {
  131. className: styles.bottomToolBarWrapper
  132. }, React__default.createElement(ControlsToolBar, Object.assign({
  133. editorState: value,
  134. setEditorState: onChange,
  135. toolList: toolList
  136. }, injectControlsToolBar))), appendToolBtn));
  137. };
  138. exports.BraftEditor = BraftEditor.default;
  139. exports.QASimpleEditor = QASimpleEditor;
  140. //# sourceMappingURL=index.js.map