Skip to content
Snippets Groups Projects
Commit 6c1f862f authored by Florian Bruhin's avatar Florian Bruhin
Browse files

Prevent link click navigation

Fixes #18
parent 664e23e8
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@ from __future__ import annotations
import pathlib
import logging
import functools
from PyQt6.QtWebEngineCore import QWebEngineNavigationRequest
import nbconvert
import nbformat
......@@ -19,6 +20,7 @@ class NotebookView(QWebEngineView):
super().__init__(parent)
self.nodeid_to_tag = {}
self._html_cache = {}
self.page().navigationRequested.connect(self._on_navigation_requested)
def _render(self, path: pathlib.Path) -> str:
key = (git.current_commit(), path)
......@@ -33,6 +35,11 @@ class NotebookView(QWebEngineView):
self._html_cache[key] = html
return html
def _on_navigation_requested(self, request: QWebEngineNavigationRequest) -> None:
link_clicked = QWebEngineNavigationRequest.NavigationType.LinkClickedNavigation
if request.navigationType() == link_clicked:
request.reject()
@pyqtSlot(pathlib.Path)
def on_folder_changed(self, path: pathlib.Path) -> None:
notebooks = list(path.glob('*.ipynb'))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment