選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

Captions.web.js 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // @flow
  2. import React from 'react';
  3. import { getParticipantCountWithFake } from '../../base/participants';
  4. import { connect } from '../../base/redux';
  5. import {
  6. _abstractMapStateToProps,
  7. AbstractCaptions,
  8. type AbstractCaptionsProps
  9. } from './AbstractCaptions';
  10. type Props = {
  11. /**
  12. * Whether the subtitles container is lifted above the invite box.
  13. */
  14. _isLifted: boolean
  15. } & AbstractCaptionsProps;
  16. /**
  17. * React {@code Component} which can display speech-to-text results from
  18. * Jigasi as subtitles.
  19. */
  20. class Captions
  21. extends AbstractCaptions<Props> {
  22. /**
  23. * Renders the transcription text.
  24. *
  25. * @param {string} id - The ID of the transcript message from which the
  26. * {@code text} has been created.
  27. * @param {string} text - Subtitles text formatted with the participant's
  28. * name.
  29. * @protected
  30. * @returns {React$Element} - The React element which displays the text.
  31. */
  32. _renderParagraph(id: string, text: string): React$Element<*> {
  33. return (
  34. <p key = { id }>
  35. <span>{ text }</span>
  36. </p>
  37. );
  38. }
  39. /**
  40. * Renders the subtitles container.
  41. *
  42. * @param {Array<React$Element>} paragraphs - An array of elements created
  43. * for each subtitle using the {@link _renderParagraph} method.
  44. * @protected
  45. * @returns {React$Element} - The subtitles container.
  46. */
  47. _renderSubtitlesContainer(
  48. paragraphs: Array<React$Element<*>>): React$Element<*> {
  49. const className = this.props._isLifted ? 'transcription-subtitles lifted' : 'transcription-subtitles';
  50. return (
  51. <div className = { className } >
  52. { paragraphs }
  53. </div>
  54. );
  55. }
  56. }
  57. /**
  58. * Maps (parts of) the redux state to the associated {@code }'s
  59. * props.
  60. *
  61. * @param {Object} state - The redux state.
  62. * @private
  63. * @returns {Object}
  64. */
  65. function mapStateToProps(state) {
  66. return {
  67. ..._abstractMapStateToProps(state),
  68. _isLifted: getParticipantCountWithFake(state) < 2
  69. };
  70. }
  71. export default connect(mapStateToProps)(Captions);