Aucune description

SimpleEditor.tsx 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import React from 'react';
  2. import { BarftEditorPage, BaseEditorProps } from "@components/Editor/BraftEditor";
  3. import { ControlsToolBar, ToolListItem } from "@components/Editor/CommonTool/ControlsToolBar";
  4. import { ContentUtils } from "braft-utils";
  5. import styles from './index.less';
  6. interface SimpleEditorProps extends BaseEditorProps {
  7. toolAlign?: 'inner' | 'bottom';
  8. toolList?: Array<ToolListItem>;
  9. injectControlsToolBar?: any;
  10. injectBraftEditorProps?: any;
  11. toolBarContainerStyle?: any;
  12. appendToolBtn?: any;
  13. }
  14. const SimpleEditor = (props: SimpleEditorProps) => {
  15. const {
  16. value,
  17. onChange,
  18. toolAlign = 'inner',
  19. toolList = [],
  20. injectControlsToolBar = {},
  21. toolBarContainerStyle = {},
  22. injectBraftEditorProps = {},
  23. appendToolBtn = null,
  24. } = props;
  25. if (toolAlign === 'inner') {
  26. return (
  27. <BarftEditorPage
  28. value={value}
  29. onChange={onChange}
  30. controls={[]}
  31. FloatControls={({ editorState, setEditorState }: any) => (
  32. <ControlsToolBar
  33. editorState={editorState}
  34. setEditorState={setEditorState}
  35. toolList={toolList}
  36. {...injectControlsToolBar}
  37. />)
  38. }
  39. />
  40. )
  41. }
  42. return (
  43. <div>
  44. <BarftEditorPage
  45. value={value}
  46. onChange={onChange}
  47. controls={[]}
  48. {...injectBraftEditorProps}
  49. />
  50. <div style={toolBarContainerStyle}>
  51. <div className={styles.bottomToolBarWrapper}>
  52. <ControlsToolBar
  53. editorState={value}
  54. setEditorState={onChange}
  55. toolList={toolList}
  56. {...injectControlsToolBar}
  57. />
  58. </div>
  59. {appendToolBtn}
  60. </div>
  61. </div>
  62. );
  63. }
  64. export default SimpleEditor;