Merge pull request #31591 from overleaf/mg-show-pdf-sync
Always show pdf when jump to pdf menu item clicked GitOrigin-RevId: 4094e681c00d3acfed0f6072f428a6c83bb701c3
This commit is contained in:
@@ -34,7 +34,12 @@ export const useContextMenuItems = () => {
|
||||
const { wantTrackChanges } = useEditorPropertiesContext()
|
||||
const { syncToPdf, syncToPdfInFlight, canSyncToPdf } = useSynctex()
|
||||
const { pdfUrl, pdfViewer } = useDetachCompileContext()
|
||||
const { detachRole } = useLayoutContext()
|
||||
const {
|
||||
detachRole,
|
||||
changeLayout,
|
||||
pdfLayout,
|
||||
view: ideView,
|
||||
} = useLayoutContext()
|
||||
const visualPreviewEnabled = useFeatureFlag('visual-preview')
|
||||
const { t } = useTranslation()
|
||||
const { shortcuts } = useCommandRegistry()
|
||||
@@ -72,12 +77,14 @@ export const useContextMenuItems = () => {
|
||||
|
||||
const hasSelection = !state.selection.main.empty
|
||||
const canEdit = permissions.write || permissions.trackedWrite
|
||||
|
||||
// Determine layout states for PDF sync functionality
|
||||
const isPdfDetached = detachRole === 'detacher'
|
||||
const isEditorOnly =
|
||||
pdfLayout === 'flat' && ideView === 'editor' && !isPdfDetached
|
||||
|
||||
const jumpToLocationInPdfEnabled =
|
||||
pdfUrl &&
|
||||
pdfViewer !== 'native' &&
|
||||
!detachRole &&
|
||||
!visualPreviewEnabled &&
|
||||
canSyncToPdf
|
||||
pdfUrl && pdfViewer !== 'native' && !visualPreviewEnabled && canSyncToPdf
|
||||
|
||||
const wrapForContextMenu = useCallback(
|
||||
(command: () => Promise<boolean> | boolean) => async () => {
|
||||
@@ -119,10 +126,14 @@ export const useContextMenuItems = () => {
|
||||
|
||||
// Sync-to-PDF is special: it needs to wait for async completion before closing
|
||||
const handleSyncToPdf = useCallback(() => {
|
||||
// Switch to split view only when in editor-only mode with non-detached PDF
|
||||
if (isEditorOnly) {
|
||||
changeLayout('sideBySide')
|
||||
}
|
||||
requestedPdfSyncRef.current = true
|
||||
syncToPdf()
|
||||
view.focus()
|
||||
}, [syncToPdf, view])
|
||||
}, [syncToPdf, view, changeLayout, isEditorOnly])
|
||||
|
||||
const getShortcut = useCallback(
|
||||
(id: string) => {
|
||||
|
||||
Reference in New Issue
Block a user