|
@@ -89,12 +89,13 @@ export default function useSynctex(): {
|
|
|
}, [dirname, getCurrentDocumentId, pathInFolder, rootDocId])
|
|
}, [dirname, getCurrentDocumentId, pathInFolder, rootDocId])
|
|
|
|
|
|
|
|
const goToCodeLine = useCallback(
|
|
const goToCodeLine = useCallback(
|
|
|
- (file?: string, line?: number) => {
|
|
|
|
|
|
|
+ (file?: string, line?: number, selectText?: string) => {
|
|
|
if (file) {
|
|
if (file) {
|
|
|
const doc = findEntityByPath(file)?.entity
|
|
const doc = findEntityByPath(file)?.entity
|
|
|
if (doc) {
|
|
if (doc) {
|
|
|
openDocWithId(doc._id, {
|
|
openDocWithId(doc._id, {
|
|
|
gotoLine: line,
|
|
gotoLine: line,
|
|
|
|
|
+ selectText,
|
|
|
})
|
|
})
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -186,9 +187,11 @@ export default function useSynctex(): {
|
|
|
const _syncToCode = useCallback(
|
|
const _syncToCode = useCallback(
|
|
|
({
|
|
({
|
|
|
position = positionRef.current,
|
|
position = positionRef.current,
|
|
|
|
|
+ selectText,
|
|
|
visualOffset = 0,
|
|
visualOffset = 0,
|
|
|
}: {
|
|
}: {
|
|
|
position?: PdfScrollPosition
|
|
position?: PdfScrollPosition
|
|
|
|
|
+ selectText?: string
|
|
|
visualOffset?: number
|
|
visualOffset?: number
|
|
|
}) => {
|
|
}) => {
|
|
|
if (!position) {
|
|
if (!position) {
|
|
@@ -231,7 +234,7 @@ export default function useSynctex(): {
|
|
|
getJSON(`/project/${projectId}/sync/pdf?${params}`, { signal })
|
|
getJSON(`/project/${projectId}/sync/pdf?${params}`, { signal })
|
|
|
.then(data => {
|
|
.then(data => {
|
|
|
const [{ file, line }] = data.code
|
|
const [{ file, line }] = data.code
|
|
|
- goToCodeLine(file, line)
|
|
|
|
|
|
|
+ goToCodeLine(file, line, selectText)
|
|
|
if (data.downloadedFromCache) {
|
|
if (data.downloadedFromCache) {
|
|
|
sendMB('synctex-downloaded-from-cache', {
|
|
sendMB('synctex-downloaded-from-cache', {
|
|
|
projectId,
|
|
projectId,
|
|
@@ -266,10 +269,7 @@ export default function useSynctex(): {
|
|
|
|
|
|
|
|
useEventListener(
|
|
useEventListener(
|
|
|
'synctex:sync-to-position',
|
|
'synctex:sync-to-position',
|
|
|
- useCallback(
|
|
|
|
|
- (event: CustomEvent) => syncToCode({ position: event.detail }),
|
|
|
|
|
- [syncToCode]
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ useCallback((event: CustomEvent) => syncToCode(event.detail), [syncToCode])
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
const [hasSingleSelectedDoc, setHasSingleSelectedDoc] = useDetachState(
|
|
const [hasSingleSelectedDoc, setHasSingleSelectedDoc] = useDetachState(
|