Skip to content

Commit

Permalink
fix[pdfHighlight]: build and pdf highlight issues resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
ArslanSaleem committed Oct 17, 2024
1 parent f82f0f2 commit 03057f1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion backend/app/processing/process_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def process_task(process_id: int):
process.started_at = datetime.utcnow()
db.commit()

process_steps = process_repository.get_process_steps_with_asset_content(db, process.id, [ProcessStepStatus.PENDING.name, ProcessStepStatus.IN_PROGRESS.name])
process_steps = process_repository.get_process_steps_with_asset_content(db, process.id, [ProcessStepStatus.PENDING.name, ProcessStepStatus.FAILED.name, ProcessStepStatus.IN_PROGRESS.name])
if not process_steps:
raise Exception("No process found!")

Expand Down
11 changes: 10 additions & 1 deletion frontend/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
async rewrites() {
return [
Expand All @@ -12,6 +11,16 @@ const nextConfig = {
},
];
},

webpack(config) {
config.module.rules.push({
test: /\.mjs$/,
exclude: /pdf\.worker\.min\.mjs$/, // Exclude pdf.worker.min.mjs from processing
type: "javascript/auto",
});

return config;
},
};

export default nextConfig;
10 changes: 6 additions & 4 deletions frontend/src/ee/components/HighlightPdfViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,17 @@ const HighlightPdfViewer: React.FC<PdfViewerProps> = ({
highlightLayer.className = styles.highlightLayer;
pageContainer.appendChild(highlightLayer);

const pixelRatio = window.devicePixelRatio || 1;

sources.forEach((source) => {
const highlightDiv = document.createElement("div");

// Set the position and size of the highlight
highlightDiv.style.position = "absolute";
highlightDiv.style.left = `${source.x / 2}px`;
highlightDiv.style.top = `${source.y / 2}px`;
highlightDiv.style.width = `${source.width / 2}px`;
highlightDiv.style.height = `${source.height / 2}px`;
highlightDiv.style.left = `${source.x / pixelRatio}px`;
highlightDiv.style.top = `${source.y / pixelRatio}px`;
highlightDiv.style.width = `${source.width / pixelRatio}px`;
highlightDiv.style.height = `${source.height / pixelRatio}px`;
highlightDiv.style.backgroundColor = "rgba(255, 255, 0, 0.3)"; // Yellow highlight
highlightDiv.style.pointerEvents = "none"; // Allow interactions with underlying text
highlightDiv.classList.add(styles.highlightDiv);
Expand Down

0 comments on commit 03057f1

Please sign in to comment.