Nav apraksta

SimpleEditor.tsx 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. toolBarContainerStyle?: any;
  11. appendToolBtn?: any;
  12. }
  13. const SimpleEditor = (props: SimpleEditorProps) => {
  14. const {
  15. value,
  16. onChange,
  17. toolAlign = 'inner',
  18. toolList = [],
  19. injectControlsToolBar = {},
  20. toolBarContainerStyle = {},
  21. appendToolBtn = null,
  22. } = props;
  23. if (toolAlign === 'inner') {
  24. return (
  25. <BarftEditorPage
  26. value={value}
  27. onChange={onChange}
  28. controls={[]}
  29. FloatControls={({ editorState, setEditorState }: any) => (
  30. <ControlsToolBar
  31. editorState={editorState}
  32. setEditorState={setEditorState}
  33. toolList={toolList}
  34. />)
  35. }
  36. />
  37. )
  38. }
  39. return (
  40. <div>
  41. <BarftEditorPage
  42. value={value}
  43. onChange={onChange}
  44. controls={[]}
  45. />
  46. <div style={toolBarContainerStyle}>
  47. <div className={styles.bottomToolBarWrapper}>
  48. <ControlsToolBar
  49. editorState={value}
  50. setEditorState={onChange}
  51. toolList={toolList}
  52. {...injectControlsToolBar}
  53. />
  54. </div>
  55. {appendToolBtn}
  56. </div>
  57. </div>
  58. );
  59. }
  60. export default SimpleEditor;