encrypt block is set, the viewer can decrypt text in-browser before rendering.
Detection
The loader callshasEncryptedContent(doc) on every load. If encrypted content is detected, one of two flows runs:
- Password in config — if
passwordwas passed in config, it’s used to decrypt in-memory. - Password modal — otherwise a
PasswordModalcomponent is rendered, prompting the user.
JavaScript
Svelte
Programmatic helpers
Imported from the library:Errors
When a wrong password is supplied, the viewer callsonError with a LoaderError carrying code: 'DECRYPT_FAILED'. The modal flow retries until the user cancels or succeeds.