Няма описание

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import React, { useState } from 'react';
  2. import { s as styleInject } from '../style-inject.es-1f59c1d0.js';
  3. import { _ as _defineProperty } from '../defineProperty-18999f8e.js';
  4. import { c as classnames } from '../index-e3cf212a.js';
  5. import { _ as _slicedToArray } from '../slicedToArray-4cd9e6d3.js';
  6. import BraftEditor from 'braft-editor';
  7. import 'braft-editor/dist/index.css';
  8. import 'braft-extensions/dist/emoticon.css';
  9. import Emoticon, { defaultEmoticons } from 'braft-extensions/dist/emoticon';
  10. import MaxLength from 'braft-extensions/dist/max-length';
  11. var css = ".index_baseWrapper__1_-58 {\n position: relative;\n}\n.index_baseWrapper__1_-58 .bf-container {\n display: flex;\n flex-direction: column;\n}\n.index_baseWrapper__1_-58 .bf-container .index_controlBar__3SzSH {\n box-shadow: none;\n}\n.index_baseWrapper__1_-58 .bf-container .index_editorContent__2UOaX {\n border: 1px solid #ccc;\n border-radius: 4px;\n height: auto;\n transition: border-color 0.3s;\n}\n.index_baseWrapper__1_-58 .bf-container .index_editorContent__2UOaX.index_focus__puDJA {\n border-color: #1790ff;\n}\n.index_baseWrapper__1_-58 .index_floatControls__2hVPf {\n position: absolute;\n right: 15px;\n bottom: 15px;\n display: flex;\n z-index: 2;\n}\n";
  12. var styles = {
  13. "baseWrapper": "index_baseWrapper__1_-58",
  14. "controlBar": "index_controlBar__3SzSH",
  15. "editorContent": "index_editorContent__2UOaX",
  16. "focus": "index_focus__puDJA",
  17. "floatControls": "index_floatControls__2hVPf"
  18. };
  19. styleInject(css);
  20. var lengthOptions = {
  21. defaultValue: 100
  22. };
  23. BraftEditor.use(MaxLength(lengthOptions));
  24. var emoticons = defaultEmoticons.map(function (item) {
  25. return require("braft-extensions/dist/assets/".concat(item));
  26. });
  27. var emotionOptions = {
  28. emoticons: emoticons,
  29. closeOnBlur: true,
  30. closeOnSelect: false
  31. };
  32. BraftEditor.use(Emoticon(emotionOptions));
  33. var BarftEditorPage = function BarftEditorPage(_ref) {
  34. var _classnames2;
  35. var value = _ref.value,
  36. onChange = _ref.onChange,
  37. controls = _ref.controls,
  38. _ref$contentStyle = _ref.contentStyle,
  39. contentStyle = _ref$contentStyle === void 0 ? {} : _ref$contentStyle,
  40. FloatControls = _ref.FloatControls,
  41. draftProps = _ref.draftProps,
  42. placeholder = _ref.placeholder,
  43. blockRenderMap = _ref.blockRenderMap,
  44. blockRendererFn = _ref.blockRendererFn,
  45. converts = _ref.converts;
  46. var optionsControls = controls ? controls : ["bold", "italic", "underline", "separator", "link", "emoji", "separator", "media"];
  47. var options = {
  48. controls: optionsControls,
  49. showControlsBar: optionsControls && optionsControls.length > 0 && !FloatControls,
  50. showFloatControls: FloatControls
  51. };
  52. var _useState = useState(false),
  53. _useState2 = _slicedToArray(_useState, 2),
  54. focusState = _useState2[0],
  55. setFocusState = _useState2[1];
  56. return React.createElement("div", {
  57. className: styles.baseWrapper
  58. }, React.createElement(BraftEditor, Object.assign({
  59. value: value,
  60. onChange: onChange,
  61. controls: options.controls,
  62. controlBarClassName: classnames(styles.controlBar, _defineProperty({}, styles.focus, focusState)),
  63. controlBarStyle: options.showControlsBar ? {} : {
  64. display: "none"
  65. },
  66. contentClassName: classnames(styles.editorContent, (_classnames2 = {}, _defineProperty(_classnames2, styles.focus, focusState), _defineProperty(_classnames2, styles.hasFloatControls, options.showFloatControls), _classnames2)),
  67. contentStyle: contentStyle,
  68. onFocus: function onFocus() {
  69. return setFocusState(true);
  70. },
  71. onBlur: function onBlur() {
  72. return setFocusState(false);
  73. },
  74. hooks: {
  75. "toggle-link": function toggleLink(_ref2) {
  76. var href = _ref2.href,
  77. target = _ref2.target;
  78. href = href.indexOf("http") === 0 ? href : "http://".concat(href);
  79. return {
  80. href: href,
  81. target: target
  82. };
  83. }
  84. }
  85. }, {
  86. blockRenderMap: blockRenderMap,
  87. blockRendererFn: blockRendererFn,
  88. converts: converts,
  89. placeholder: placeholder,
  90. draftProps: draftProps
  91. })), options.showFloatControls ? React.createElement("div", {
  92. className: classnames(styles.floatControls)
  93. }, React.createElement(FloatControls, {
  94. editorState: value,
  95. setEditorState: onChange
  96. })) : null);
  97. };
  98. export default BarftEditorPage;
  99. export { BarftEditorPage };
  100. //# sourceMappingURL=index.js.map