Add per-library toggles for PDF internal and external links - #4777
Open
aliooo36 wants to merge 2 commits into
Open
Add per-library toggles for PDF internal and external links#4777aliooo36 wants to merge 2 commits into
aliooo36 wants to merge 2 commits into
Conversation
Allow libraries to disable external URL links and in-document internal links in the PDF reader, with EF migration, API/DTO wiring, UI settings, and migration/service tests.
There was a problem hiding this comment.
Pull request overview
Adds per-library controls to restrict PDF link behavior (external URLs and in-document navigation) and enforces those restrictions in the web PDF reader, with persistence via EF migration and coverage via service/migration tests.
Changes:
- Introduces
EnablePdfExternalLinks/EnablePdfInternalLinkslibrary settings persisted in the database and exposed via DTOs/controllers. - Adds Library Settings UI switches for the two toggles and threads the values into the PDF reader runtime behavior.
- Adds integration tests to validate update/copy behavior and a migration test to confirm default values.
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| UI/Web/src/assets/langs/en.json | Adds i18n strings for the new library settings toggles. |
| UI/Web/src/app/sidenav/_modals/library-settings-modal/library-settings-modal.component.ts | Adds form controls and populates them from the library model. |
| UI/Web/src/app/sidenav/_modals/library-settings-modal/library-settings-modal.component.html | Adds two switches to configure PDF link behavior per library. |
| UI/Web/src/app/pdf-reader/_components/pdf-reader/pdf-reader.component.ts | Fetches library toggles and configures PDF.js/annotation visibility accordingly. |
| UI/Web/src/app/pdf-reader/_components/pdf-reader/pdf-reader.component.scss | Adds CSS rules to hide link annotations when disabled. |
| UI/Web/src/app/pdf-reader/_components/pdf-reader/pdf-reader.component.html | Binds CSS classes and hooks annotationLayerRendered for per-page updates. |
| UI/Web/src/app/_models/library/library.ts | Extends the Library TS interface with the two new booleans. |
| Kavita.Services.Tests/LibraryPdfLinkSettingsTests.cs | Tests update + copy-settings propagation for the new toggles. |
| Kavita.Services.Tests/Helpers/LibrarySettingsTestHelper.cs | Test helper to mirror library settings update/copy behavior. |
| Kavita.Server/Controllers/LibraryController.cs | Wires new DTO fields into create/update/copy settings flows. |
| Kavita.Models/Entities/Library.cs | Adds entity properties with default true. |
| Kavita.Models/DTOs/UpdateLibraryDto.cs | Adds update DTO fields for the new toggles. |
| Kavita.Models/DTOs/LibraryDto.cs | Adds fields to Lite/Library DTOs so clients can read the toggles. |
| Kavita.Database/Migrations/DataContextModelSnapshot.cs | Updates snapshot with the new columns + defaults. |
| Kavita.Database/Migrations/20260705223354_PdfLinkSettings.Designer.cs | EF designer output for the new migration. |
| Kavita.Database/Migrations/20260705223354_PdfLinkSettings.cs | Migration adding the two new columns with default true. |
| Kavita.Database/DataContext.cs | Configures default values for the new entity properties. |
| Kavita.Database.Tests/Migrations/PdfLinkSettingsMigrationTests.cs | Verifies migration applies and defaults are true. |
Comment on lines
+51
to
+53
| /// <inheritdoc cref="Library.EnablePdfExternalLinks"/> | ||
| [Required] | ||
| public bool EnablePdfExternalLinks { get; init; } |
Comment on lines
+54
to
+56
| /// <inheritdoc cref="Library.EnablePdfInternalLinks"/> | ||
| [Required] | ||
| public bool EnablePdfInternalLinks { get; init; } |
Comment on lines
+370
to
+374
| const isInternal = section.hasAttribute('data-internal-link'); | ||
| const hide = (isInternal && !this.enablePdfInternalLinks) | ||
| || (!isInternal && !this.enablePdfExternalLinks); | ||
| (section as HTMLElement).hidden = hide; | ||
| }); |
Comment on lines
+111
to
+115
| .pdf-external-links-disabled ::ng-deep .annotationLayer section.linkAnnotation:not([data-internal-link]), | ||
| .pdf-internal-links-disabled ::ng-deep .annotationLayer section.linkAnnotation[data-internal-link] { | ||
| display: none !important; | ||
| pointer-events: none !important; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Allow libraries to disable external URL links and in-document internal links in the PDF reader, with EF migration, API/DTO wiring, UI settings, and migration/service test
Added
Changed
🐈 Manual testing video + Feature showcase hyperlinked!
! Why I Implemented this feature (As mentioned in this discussion post)
I primarily read PDFs in Kavita and the core experience works great. However, navigating documents with a mix of internal references (footnotes, indexes) and external web URLs creates unnecessary friction.
An "Internal-Only" link toggle addresses two specific issues:
1. Preventing Reading Disruptions
2. Local Privacy & Security
Behavior
Add a configuration toggle in the PDF reader settings (e.g., "Restrict to Internal Links Only"). When enabled,

http://andhttps://protocols are ignored, while document anchor tags continue to handle internal navigation normally.