detach-synctex-control.js 933 B

123456789101112131415161718192021222324252627282930313233343536
  1. import PropTypes from 'prop-types'
  2. import { useLayoutContext } from '../../../shared/context/layout-context'
  3. import PdfSynctexControls from './pdf-synctex-controls'
  4. export function DefaultSynctexControl() {
  5. const { detachRole } = useLayoutContext(layoutContextPropTypes)
  6. if (!detachRole) {
  7. return <PdfSynctexControls />
  8. }
  9. return null
  10. }
  11. export function DetacherSynctexControl() {
  12. const { detachRole, detachIsLinked } = useLayoutContext(
  13. layoutContextPropTypes
  14. )
  15. if (detachRole === 'detacher' && detachIsLinked) {
  16. return <PdfSynctexControls />
  17. }
  18. return null
  19. }
  20. export function DetachedSynctexControl() {
  21. const { detachRole, detachIsLinked } = useLayoutContext(
  22. layoutContextPropTypes
  23. )
  24. if (detachRole === 'detached' && detachIsLinked) {
  25. return <PdfSynctexControls />
  26. }
  27. return null
  28. }
  29. const layoutContextPropTypes = {
  30. detachRole: PropTypes.string,
  31. detachIsLinked: PropTypes.bool,
  32. }