HtmlDocument.jsx 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import React from 'react'
  2. import { TextAreaApp } from 'tracim_frontend_lib'
  3. import { MODE } from '../helper.js'
  4. import { translate } from 'react-i18next'
  5. const HtmlDocument = props => {
  6. return (
  7. <div className='wsContentHtmlDocument__contentpage__textnote html-document__contentpage__textnote'>
  8. {props.isArchived &&
  9. <div className='html-document__contentpage__textnote__state'>
  10. <div className='html-document__contentpage__textnote__state__msg'>
  11. <i className='fa fa-fw fa-archive' />
  12. {props.t('This content is archived.')}
  13. </div>
  14. <button className='html-document__contentpage__textnote__state__btnrestore btn' onClick={props.onClickRestoreArchived}>
  15. <i className='fa fa-fw fa-archive' />
  16. {props.t('Restore')}
  17. </button>
  18. </div>
  19. }
  20. {props.isDeleted &&
  21. <div className='html-document__contentpage__textnote__state'>
  22. <div className='html-document__contentpage__textnote__state__msg'>
  23. <i className='fa fa-fw fa-trash' />
  24. {props.t('This content is deleted.')}
  25. </div>
  26. <button className='html-document__contentpage__textnote__state__btnrestore btn' onClick={props.onClickRestoreDeleted}>
  27. <i className='fa fa-fw fa-trash' />
  28. {props.t('Restore')}
  29. </button>
  30. </div>
  31. }
  32. {(props.mode === MODE.VIEW || props.mode === MODE.REVISION) &&
  33. <div>
  34. <div className='html-document__contentpage__textnote__version'>
  35. version n°
  36. <div dangerouslySetInnerHTML={{__html: props.mode === MODE.VIEW ? props.lastVersion : props.version}} />
  37. {props.mode === MODE.REVISION &&
  38. <div className='html-document__contentpage__textnote__lastversion'>
  39. ({props.t('latest version :')} {props.lastVersion})
  40. </div>
  41. }
  42. </div>
  43. {/* need try to inject html in stateless component () => <span>{props.text}</span> */}
  44. <div className='html-document__contentpage__textnote__text' dangerouslySetInnerHTML={{__html: props.text}} />
  45. </div>
  46. }
  47. {props.mode === MODE.EDIT &&
  48. <TextAreaApp
  49. id={props.wysiwygNewVersion}
  50. customClass={'html-document__editionmode'}
  51. customColor={props.customColor}
  52. onClickCancelBtn={props.onClickCloseEditMode}
  53. onClickValidateBtn={props.onClickValidateBtn}
  54. text={props.text}
  55. onChangeText={props.onChangeText}
  56. />
  57. }
  58. </div>
  59. )
  60. }
  61. export default translate()(HtmlDocument)