Preview.js 954 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import RevisionBody from '../Page/RevisionBody';
  4. import { PreviewOptions } from './OptionsSelector';
  5. /**
  6. * Wrapper component for Page/RevisionBody
  7. */
  8. export default class Preview extends React.Component {
  9. constructor(props) {
  10. super(props);
  11. }
  12. render() {
  13. const renderMathJaxInRealtime = this.props.previewOptions.renderMathJaxInRealtime;
  14. return (
  15. <div className="page-editor-preview-body">
  16. <RevisionBody
  17. ref={(elm) => {
  18. this.props.inputRef(elm);
  19. }}
  20. {...this.props}
  21. renderMathJaxInRealtime={renderMathJaxInRealtime}
  22. />
  23. </div>
  24. )
  25. }
  26. }
  27. Preview.propTypes = {
  28. html: PropTypes.string,
  29. inputRef: PropTypes.func.isRequired, // for getting div element
  30. isMathJaxEnabled: PropTypes.bool,
  31. renderMathJaxOnInit: PropTypes.bool,
  32. previewOptions: PropTypes.instanceOf(PreviewOptions),
  33. };