説明なし

index.js 5.0KB

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