AbstractEditor.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. forceToFocus() {
  16. }
  17. /**
  18. * set caret position of codemirror
  19. * @param {string} number
  20. */
  21. setCaretLine(line) {
  22. }
  23. /**
  24. * scroll
  25. * @param {number} line
  26. */
  27. setScrollTopByLine(line) {
  28. }
  29. /**
  30. * insert text
  31. * @param {string} text
  32. */
  33. insertText(text) {
  34. }
  35. /**
  36. * dispatch onSave event
  37. */
  38. dispatchSave() {
  39. if (this.props.onSave != null) {
  40. this.props.onSave();
  41. }
  42. }
  43. }
  44. AbstractEditor.propTypes = {
  45. value: PropTypes.string,
  46. editorOptions: PropTypes.object,
  47. onChange: PropTypes.func,
  48. onScroll: PropTypes.func,
  49. onScrollCursorIntoView: PropTypes.func,
  50. onSave: PropTypes.func,
  51. onPasteFiles: PropTypes.func,
  52. };