2
0

Preview.js 994 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. ref={(elm) => {
  17. this.previewElement = elm;
  18. this.props.inputRef(elm);
  19. }}>
  20. <RevisionBody
  21. {...this.props}
  22. renderMathJaxInRealtime={renderMathJaxInRealtime}
  23. />
  24. </div>
  25. )
  26. }
  27. }
  28. Preview.propTypes = {
  29. html: PropTypes.string,
  30. inputRef: PropTypes.func.isRequired, // for getting div element
  31. isMathJaxEnabled: PropTypes.bool,
  32. renderMathJaxOnInit: PropTypes.bool,
  33. previewOptions: PropTypes.instanceOf(PreviewOptions),
  34. };