mirror of
https://github.com/James-Yu/LaTeX-Workshop.git
synced 2024-10-04 23:27:20 +03:00
parent
b18f844089
commit
5ba3f10e1a
@ -259,6 +259,10 @@ export class Viewer implements IViewer {
|
||||
void this.extension.locator.locate(data, uri.fsPath)
|
||||
break
|
||||
}
|
||||
case 'external_link': {
|
||||
void vscode.env.openExternal(vscode.Uri.parse(data.url))
|
||||
break
|
||||
}
|
||||
case 'ping': {
|
||||
// nothing to do
|
||||
break
|
||||
|
@ -49,6 +49,9 @@ export type ClientRequest = {
|
||||
} | {
|
||||
type: 'loaded',
|
||||
pdfFileUri: string
|
||||
} | {
|
||||
type: 'external_link',
|
||||
url: string
|
||||
} | {
|
||||
type: 'ping'
|
||||
} | {
|
||||
|
@ -490,10 +490,12 @@ class LateXWorkshopPdfViewer implements ILatexWorkshopPdfViewer {
|
||||
}
|
||||
|
||||
private registerKeybinding() {
|
||||
// if we're embedded we cannot open external links here. So we intercept clicks and forward them to the extension
|
||||
if (this.embedded) {
|
||||
document.addEventListener('click', (e) => {
|
||||
const target = e.target as HTMLAnchorElement
|
||||
if (target.nodeName === 'A' && !target.href.startsWith(window.location.href) && !target.href.startsWith('blob:')) { // is external link
|
||||
this.send({type:'external_link', url:target.href})
|
||||
e.preventDefault()
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user