|
@@ -1,6 +1,5 @@
|
|
|
import { memo, useCallback, useEffect, useRef, useState } from 'react'
|
|
import { memo, useCallback, useEffect, useRef, useState } from 'react'
|
|
|
import { debounce, throttle } from 'lodash'
|
|
import { debounce, throttle } from 'lodash'
|
|
|
-import PdfViewerControls from './pdf-viewer-controls'
|
|
|
|
|
import PdfViewerControlsToolbar from './pdf-viewer-controls-toolbar'
|
|
import PdfViewerControlsToolbar from './pdf-viewer-controls-toolbar'
|
|
|
import { useProjectContext } from '../../../shared/context/project-context'
|
|
import { useProjectContext } from '../../../shared/context/project-context'
|
|
|
import usePersistedState from '../../../shared/hooks/use-persisted-state'
|
|
import usePersistedState from '../../../shared/hooks/use-persisted-state'
|
|
@@ -14,7 +13,6 @@ import * as eventTracking from '../../../infrastructure/event-tracking'
|
|
|
import { getPdfCachingMetrics } from '../util/metrics'
|
|
import { getPdfCachingMetrics } from '../util/metrics'
|
|
|
import { debugConsole } from '@/utils/debugging'
|
|
import { debugConsole } from '@/utils/debugging'
|
|
|
import { usePdfPreviewContext } from '@/features/pdf-preview/components/pdf-preview-provider'
|
|
import { usePdfPreviewContext } from '@/features/pdf-preview/components/pdf-preview-provider'
|
|
|
-import { useFeatureFlag } from '@/shared/context/split-test-context'
|
|
|
|
|
import usePresentationMode from '../hooks/use-presentation-mode'
|
|
import usePresentationMode from '../hooks/use-presentation-mode'
|
|
|
import useMouseWheelZoom from '../hooks/use-mouse-wheel-zoom'
|
|
import useMouseWheelZoom from '../hooks/use-mouse-wheel-zoom'
|
|
|
|
|
|
|
@@ -31,8 +29,6 @@ function PdfJsViewer({ url, pdfFile }: PdfJsViewerProps) {
|
|
|
|
|
|
|
|
const { setLoadingError } = usePdfPreviewContext()
|
|
const { setLoadingError } = usePdfPreviewContext()
|
|
|
|
|
|
|
|
- const hasNewPdfToolbar = useFeatureFlag('pdf-controls')
|
|
|
|
|
-
|
|
|
|
|
// state values persisted in localStorage to restore on load
|
|
// state values persisted in localStorage to restore on load
|
|
|
const [scale, setScale] = usePersistedState(
|
|
const [scale, setScale] = usePersistedState(
|
|
|
`pdf-viewer-scale:${projectId}`,
|
|
`pdf-viewer-scale:${projectId}`,
|
|
@@ -389,15 +385,6 @@ function PdfJsViewer({ url, pdfFile }: PdfJsViewerProps) {
|
|
|
const setZoom = useCallback(
|
|
const setZoom = useCallback(
|
|
|
zoom => {
|
|
zoom => {
|
|
|
switch (zoom) {
|
|
switch (zoom) {
|
|
|
- // TODO: We can remove fit-width and fit-height once the
|
|
|
|
|
- // pdf toolbar is fully rolled out
|
|
|
|
|
- case 'fit-width':
|
|
|
|
|
- setScale('page-width')
|
|
|
|
|
- break
|
|
|
|
|
-
|
|
|
|
|
- case 'fit-height':
|
|
|
|
|
- setScale('page-height')
|
|
|
|
|
- break
|
|
|
|
|
case 'zoom-in':
|
|
case 'zoom-in':
|
|
|
if (pdfJsWrapper) {
|
|
if (pdfJsWrapper) {
|
|
|
setScale(
|
|
setScale(
|
|
@@ -505,22 +492,16 @@ function PdfJsViewer({ url, pdfFile }: PdfJsViewerProps) {
|
|
|
>
|
|
>
|
|
|
<div className="pdfViewer" />
|
|
<div className="pdfViewer" />
|
|
|
</div>
|
|
</div>
|
|
|
- <div className="pdfjs-controls" tabIndex={0}>
|
|
|
|
|
- {hasNewPdfToolbar ? (
|
|
|
|
|
- toolbarInfoLoaded && (
|
|
|
|
|
- <PdfViewerControlsToolbar
|
|
|
|
|
- requestPresentationMode={requestPresentationMode}
|
|
|
|
|
- setZoom={setZoom}
|
|
|
|
|
- rawScale={rawScale}
|
|
|
|
|
- setPage={handlePageChange}
|
|
|
|
|
- page={page}
|
|
|
|
|
- totalPages={totalPages}
|
|
|
|
|
- />
|
|
|
|
|
- )
|
|
|
|
|
- ) : (
|
|
|
|
|
- <PdfViewerControls setZoom={setZoom} />
|
|
|
|
|
- )}
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ {toolbarInfoLoaded && (
|
|
|
|
|
+ <PdfViewerControlsToolbar
|
|
|
|
|
+ requestPresentationMode={requestPresentationMode}
|
|
|
|
|
+ setZoom={setZoom}
|
|
|
|
|
+ rawScale={rawScale}
|
|
|
|
|
+ setPage={handlePageChange}
|
|
|
|
|
+ page={page}
|
|
|
|
|
+ totalPages={totalPages}
|
|
|
|
|
+ />
|
|
|
|
|
+ )}
|
|
|
</div>
|
|
</div>
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|