No Description

SimpleEditor.tsx 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import React from "react";
  2. import classnames from "classnames";
  3. import {
  4. BarftEditorPage,
  5. BaseEditorProps,
  6. } from "@components/Editor/BraftEditor";
  7. import {
  8. ControlsToolBar,
  9. ToolListItem,
  10. } from "@components/Editor/CommonTool/ControlsToolBar";
  11. import { ContentUtils } from "braft-utils";
  12. import styles from "./index.less";
  13. interface SimpleEditorProps extends BaseEditorProps {
  14. toolAlign?: "inner" | "bottom" | "both";
  15. toolList?: Array<ToolListItem>;
  16. injectControlsToolBar?: any;
  17. injectBraftEditorProps?: any;
  18. toolBarContainerStyle?: any;
  19. appendToolBtn?: any;
  20. appendInnderBar?: any;
  21. }
  22. const SimpleEditor = (props: SimpleEditorProps) => {
  23. const {
  24. value,
  25. onChange,
  26. toolAlign = "inner",
  27. toolList = [],
  28. injectControlsToolBar = {},
  29. toolBarContainerStyle = {},
  30. injectBraftEditorProps = {},
  31. appendToolBtn = null,
  32. appendInnderBar = null,
  33. } = props;
  34. if (toolAlign === "inner") {
  35. return (
  36. <div className={styles.innerWrapper}>
  37. <BarftEditorPage
  38. value={value}
  39. onChange={onChange}
  40. controls={[]}
  41. {...injectBraftEditorProps}
  42. />
  43. <div className={classnames(styles.floatControls)}>
  44. <ControlsToolBar
  45. editorState={value}
  46. setEditorState={onChange}
  47. toolList={toolList}
  48. {...injectControlsToolBar}
  49. />
  50. </div>
  51. </div>
  52. );
  53. }
  54. if (toolAlign === "both") {
  55. return (
  56. <div>
  57. <div className={styles.innerWrapper}>
  58. <BarftEditorPage
  59. value={value}
  60. onChange={onChange}
  61. controls={[]}
  62. {...injectBraftEditorProps}
  63. />
  64. <div className={classnames(styles.floatControls)}>
  65. {appendInnderBar}
  66. </div>
  67. </div>
  68. <div style={toolBarContainerStyle}>
  69. <div className={styles.bottomToolBarWrapper}>
  70. <ControlsToolBar
  71. editorState={value}
  72. setEditorState={onChange}
  73. toolList={toolList}
  74. {...injectControlsToolBar}
  75. />
  76. </div>
  77. {appendToolBtn}
  78. </div>
  79. </div>
  80. );
  81. }
  82. return (
  83. <div>
  84. <BarftEditorPage
  85. value={value}
  86. onChange={onChange}
  87. controls={[]}
  88. {...injectBraftEditorProps}
  89. />
  90. <div style={toolBarContainerStyle}>
  91. <div className={styles.bottomToolBarWrapper}>
  92. <ControlsToolBar
  93. editorState={value}
  94. setEditorState={onChange}
  95. toolList={toolList}
  96. {...injectControlsToolBar}
  97. />
  98. </div>
  99. {appendToolBtn}
  100. </div>
  101. </div>
  102. );
  103. };
  104. export default SimpleEditor;