Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

feat: enhance PDF viewer UI to match LDR design

LearningCircuit65ce660ca493
diff --git a/src/local_deep_research/web/templates/pages/library.html b/src/local_deep_research/web/templates/pages/library.html
index d3f9217a27..8b9d4afe57 100644
--- a/src/local_deep_research/web/templates/pages/library.html
+++ b/src/local_deep_research/web/templates/pages/library.html
@@ -191,14 +191,24 @@
</div>
<!-- PDF Viewer Modal -->
-<div id="pdf-modal" class="modal">
- <div class="modal-content">
- <div class="modal-header">
- <h2 id="pdf-title">PDF Viewer</h2>
- <button class="close" onclick="closePDFModal()">&times;</button>
+<div id="pdf-modal" class="pdf-modal">
+ <div class="pdf-modal-content">
+ <div class="pdf-modal-header">
+ <h2 id="pdf-title" class="pdf-title">PDF Viewer</h2>
+ <div class="pdf-header-actions">
+ <button class="pdf-action-btn" onclick="downloadCurrentPDF()" title="Download PDF">
+ <i class="fas fa-download"></i>
+ </button>
+ <button class="pdf-action-btn" onclick="openPDFInNewTab()" title="Open in new tab">
+ <i class="fas fa-external-link-alt"></i>
+ </button>
+ <button class="pdf-close-btn" onclick="closePDFModal()" title="Close">
+ <i class="fas fa-times"></i>
+ </button>
+ </div>
</div>
- <div class="modal-body">
- <iframe id="pdf-viewer" style="width: 100%; height: 80vh;"></iframe>
+ <div class="pdf-modal-body">
+ <iframe id="pdf-viewer" class="pdf-viewer-frame"></iframe>
</div>
</div>
</div>
@@ -525,17 +535,165 @@
align-items: center;
margin-bottom: 20px;
}
+
+/* Enhanced PDF Viewer Modal */
+.pdf-modal {
+ display: none;
+ position: fixed;
+ z-index: 10000;
+ left: 0;
+ top: 0;
+ width: 100%;
+ height: 100%;
+ background-color: rgba(0, 0, 0, 0.85);
+ backdrop-filter: blur(4px);
+ animation: fadeIn 0.2s ease-in-out;
+}
+
+@keyframes fadeIn {
+ from { opacity: 0; }
+ to { opacity: 1; }
+}
+
+.pdf-modal-content {
+ background: var(--bg-primary, #1a1a1a);
+ margin: 20px auto;
+ width: 95%;
+ height: calc(100vh - 40px);
+ max-width: 1600px;
+ border-radius: 12px;
+ display: flex;
+ flex-direction: column;
+ box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
+ animation: slideUp 0.3s ease-out;
+}
+
+@keyframes slideUp {
+ from {
+ transform: translateY(20px);
+ opacity: 0;
+ }
+ to {
+ transform: translateY(0);
+ opacity: 1;
+ }
+}
+
+.pdf-modal-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 16px 24px;
+ background: var(--bg-secondary, #2a2a2a);
+ border-radius: 12px 12px 0 0;
+ border-bottom: 1px solid rgba(255, 255, 255, 0.1);
+}
+
+.pdf-title {
+ font-size: 18px;
+ font-weight: 600;
+ color: var(--text-primary, #e4e4e4);
+ margin: 0;
+ max-width: 70%;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.pdf-header-actions {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+}
+
+.pdf-action-btn,
+.pdf-close-btn {
+ background: transparent;
+ border: none;
+ color: var(--text-secondary, #a0a0a0);
+ cursor: pointer;
+ padding: 8px;
+ border-radius: 6px;
+ transition: all 0.2s ease;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 36px;
+ height: 36px;
+}
+
+.pdf-action-btn:hover {
+ background: rgba(255, 255, 255, 0.1);
+ color: var(--text-primary, #e4e4e4);
+}
+
+.pdf-close-btn:hover {
+ background: rgba(239, 68, 68, 0.2);
+ color: #ef4444;
+}
+
+.pdf-modal-body {
+ flex: 1;
+ padding: 0;
+ overflow: hidden;
+ background: #525252;
+ border-radius: 0 0 12px 12px;
+}
+
+.pdf-viewer-frame {
+ width: 100%;
+ height: 100%;
+ border: none;
+ border-radius: 0 0 12px 12px;
+}
+
+/* Dark mode adjustments */
+@media (prefers-color-scheme: dark) {
+ .pdf-modal-content {
+ background: #1a1a1a;
+ }
+
+ .pdf-modal-header {
+ background: #2a2a2a;
+ }
+}
+
+/* Mobile responsiveness */
+@media (max-width: 768px) {
+ .pdf-modal-content {
+ width: 100%;
+ height: 100vh;
+ margin: 0;
+ border-radius: 0;
+ }
+
+ .pdf-modal-header {
+ border-radius: 0;
+ }
+
+ .pdf-modal-body,
+ .pdf-viewer-frame {
+ border-radius: 0;
+ }
+}
</style>
<script>
+// Store current PDF data globally
+let currentPDFData = null;
+
// Open PDF in modal
function openPDF(docId) {
fetch(`/library/api/document/${docId}/pdf-url`)
.then(res => res.json())
.then(data => {
+ currentPDFData = data;
document.getElementById('pdf-viewer').src = data.url;
document.getElementById('pdf-title').textContent = data.title;
document.getElementById('pdf-modal').style.display = 'block';
+
+ // Add escape key listener
+ document.addEventListener('keydown', handleEscapeKey);
});
}
@@ -543,8 +701,43 @@ function openPDF(docId) {
function closePDFModal() {
document.getElementById('pdf-modal').style.display = 'none';
document.getElementById('pdf-viewer').src = '';
+ currentPDFData = null;
+
+ // Remove escape key listener
+ document.removeEventListener('keydown', handleEscapeKey);
+}
+
+// Handle escape key
+function handleEscapeKey(e) {
+ if (e.key === 'Escape') {
+ closePDFModal();
+ }
+}
+
+// Download current PDF
+function downloadCurrentPDF() {
+ if (currentPDFData && currentPDFData.url) {
+ const link = document.createElement('a');
+ link.href = currentPDFData.url;
+ link.download = currentPDFData.title + '.pdf';
+ link.click();
+ }
+}
+
+// Open PDF in new tab
+function openPDFInNewTab() {
+ if (currentPDFData && currentPDFData.url) {
+ window.open(currentPDFData.url, '_blank');
+ }
}
+// Close modal when clicking outside
+document.getElementById('pdf-modal').addEventListener('click', function(e) {
+ if (e.target === this) {
+ closePDFModal();
+ }
+});
+
// Copy path to clipboard
function copyPath(path) {
navigator.clipboard.writeText(path);