Skip to content

Conversation

gjulivan
Copy link
Collaborator

Pull request type


Description

@Copilot Copilot AI review requested due to automatic review settings September 16, 2025 11:43
@gjulivan gjulivan requested a review from a team as a code owner September 16, 2025 11:43
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR allows users to configure a custom URL for the PDF.js worker file in the Document Viewer widget, enabling self-hosted deployments instead of relying on external CDNs.

Key changes:

  • Added a new "PDF.js worker URL" configuration property in the Advanced settings
  • Modified the PDF viewer to use the custom worker URL when provided, with fallback to unpkg CDN
  • Version bumped to 1.1.1 with appropriate changelog entry

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
package.xml Version bump to 1.1.1
DocumentViewer.xml Added new pdfjsWorkerUrl property in Advanced propertyGroup
package.json Version bump to 1.1.1
PDFViewer.tsx Implemented dynamic worker URL configuration with useMemo hook
CHANGELOG.md Added entry for the new self-hosted worker configuration feature

Comment on lines +16 to +23
const { file, setDocumentStatus, pdfjsWorkerUrl } = props;
pdfjs.GlobalWorkerOptions.workerSrc = useMemo(() => {
if (pdfjsWorkerUrl?.status === "available" && pdfjsWorkerUrl?.value) {
return pdfjsWorkerUrl.value;
}
return `//unpkg.com/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.mjs`;
}, [pdfjsWorkerUrl]);

Copy link
Collaborator

@r0b1n r0b1n Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be on the safe side, we probably should delay the rendering until this value if correctly resolved, we don't what to process with loading from cdn while it is being loaded. Also if this URL is unavailable we probably should not render at all. Unexpected loading from CDN can be seen as security issues.
So I guess we should load from cdn only if the value is available and is explicitly empty string. Other than that - wait for it. If value goes to unavailable - show an error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants