AbstractEditor.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. export default class AbstractEditor extends React.Component {
  4. constructor(props) {
  5. super(props);
  6. this.state = {
  7. value: this.props.value,
  8. };
  9. this.forceToFocus = this.forceToFocus.bind(this);
  10. this.setCaretLine = this.setCaretLine.bind(this);
  11. this.setScrollTopByLine = this.setScrollTopByLine.bind(this);
  12. this.insertText = this.insertText.bind(this);
  13. this.dispatchSave = this.dispatchSave.bind(this);
  14. }
  15. componentDidMount() {
  16. // initialize caret line
  17. this.setCaretLine(0);
  18. }
  19. forceToFocus() {
  20. }
  21. /**
  22. * set caret position of codemirror
  23. * @param {string} number
  24. */
  25. setCaretLine(line) {
  26. }
  27. /**
  28. * scroll
  29. * @param {number} line
  30. */
  31. setScrollTopByLine(line) {
  32. }
  33. /**
  34. * insert text
  35. * @param {string} text
  36. */
  37. insertText(text) {
  38. }
  39. /**
  40. * dispatch onSave event
  41. */
  42. dispatchSave() {
  43. }
  44. }
  45. AbstractEditor.propTypes = {
  46. value: PropTypes.string,
  47. editorOptions: PropTypes.object,
  48. onChange: PropTypes.func,
  49. onScroll: PropTypes.func,
  50. onScrollCursorIntoView: PropTypes.func,
  51. onSave: PropTypes.func,
  52. };