Merge pull request #33994 from overleaf/mj-command-palette-synctex
[web] Add synctex to command palette GitOrigin-RevId: 10e769dae6088d279d010fcfa3577b489c6ff89c
This commit is contained in:
committed by
Copybot
parent
f8c7e092fa
commit
cc762bb7e6
+2
@@ -18,6 +18,8 @@ const ENABLED_COMMANDS: string[] = [
|
||||
'compile',
|
||||
'stop-compile',
|
||||
'recompile-from-scratch',
|
||||
'synctex-sync-to-pdf',
|
||||
'synctex-sync-to-code',
|
||||
]
|
||||
|
||||
const useCommandRegistrySource = (): CommandPaletteSource => {
|
||||
|
||||
@@ -11,6 +11,7 @@ import useSynctex from '../hooks/use-synctex'
|
||||
import { useFeatureFlag } from '@/shared/context/split-test-context'
|
||||
import OLSpinner from '@/shared/components/ol/ol-spinner'
|
||||
import { sendMB } from '@/infrastructure/event-tracking'
|
||||
import { useCommandProvider } from '@/features/ide-react/hooks/use-command-provider'
|
||||
|
||||
const GoToCodeButton = memo(function GoToCodeButton({
|
||||
syncToCode,
|
||||
@@ -22,6 +23,24 @@ const GoToCodeButton = memo(function GoToCodeButton({
|
||||
isDetachLayout?: boolean
|
||||
}) {
|
||||
const { t } = useTranslation()
|
||||
useCommandProvider(
|
||||
() => [
|
||||
{
|
||||
id: 'synctex-sync-to-code',
|
||||
handler: () => {
|
||||
sendMB('jump-to-location', {
|
||||
method: 'command',
|
||||
direction: 'pdf-location-in-code',
|
||||
})
|
||||
syncToCode({ visualOffset: 72 })
|
||||
},
|
||||
disabled: syncToCodeInFlight,
|
||||
label: t('go_to_pdf_location_in_code'),
|
||||
},
|
||||
],
|
||||
[t, syncToCode, syncToCodeInFlight]
|
||||
)
|
||||
|
||||
const buttonClasses = classNames('synctex-control', {
|
||||
'detach-synctex-control': !!isDetachLayout,
|
||||
})
|
||||
@@ -98,6 +117,24 @@ const GoToPdfButton = memo(function GoToPdfButton({
|
||||
syncToPdf()
|
||||
}, [syncToPdf])
|
||||
|
||||
useCommandProvider(
|
||||
() => [
|
||||
{
|
||||
id: 'synctex-sync-to-pdf',
|
||||
handler: () => {
|
||||
sendMB('jump-to-location', {
|
||||
method: 'command',
|
||||
direction: 'code-location-in-pdf',
|
||||
})
|
||||
syncToPdf()
|
||||
},
|
||||
label: t('go_to_code_location_in_pdf'),
|
||||
disabled: syncToPdfInFlight || !canSyncToPdf,
|
||||
},
|
||||
],
|
||||
[t, syncToPdf, syncToPdfInFlight, canSyncToPdf]
|
||||
)
|
||||
|
||||
let buttonIcon = null
|
||||
if (syncToPdfInFlight) {
|
||||
buttonIcon = <OLSpinner size="sm" />
|
||||
|
||||
Reference in New Issue
Block a user