From 282b5e56d81aa80e7678a0585c7ef6ee69dc2c2a Mon Sep 17 00:00:00 2001
From: Abdulraahman Dabbagh <1924466@stud.hs-mannheim.de>
Date: Wed, 4 Jun 2025 15:46:52 +0200
Subject: [PATCH] =?UTF-8?q?WIP:=20Lokale=20=C3=84nderungen=20vor=20Merge?=
=?UTF-8?q?=20gespeichert?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/components/HighlightOverlay.tsx | 30 --------------
.../src/components/KennzahlenTable.tsx | 3 +-
.../frontend/src/components/highlightData.ts | 21 ----------
project/frontend/src/components/pdfViewer.tsx | 39 ++++++++++++-------
4 files changed, 26 insertions(+), 67 deletions(-)
delete mode 100644 project/frontend/src/components/HighlightOverlay.tsx
delete mode 100644 project/frontend/src/components/highlightData.ts
diff --git a/project/frontend/src/components/HighlightOverlay.tsx b/project/frontend/src/components/HighlightOverlay.tsx
deleted file mode 100644
index 2f30aa5..0000000
--- a/project/frontend/src/components/HighlightOverlay.tsx
+++ /dev/null
@@ -1,30 +0,0 @@
-import { Box } from '@mui/material';
-
-type Props = {
- x: number;
- y: number;
- width: number;
- height: number;
- type: 'all' | 'selected';
-};
-
-// Eine farbige Box, die über dem PDF angezeigt wird
-export default function HighlightOverlay({ x, y, width, height, type }: Props) {
- return (
-
- );
-}
diff --git a/project/frontend/src/components/KennzahlenTable.tsx b/project/frontend/src/components/KennzahlenTable.tsx
index 4d20e22..54ea51f 100644
--- a/project/frontend/src/components/KennzahlenTable.tsx
+++ b/project/frontend/src/components/KennzahlenTable.tsx
@@ -8,7 +8,6 @@ import {
import SearchIcon from '@mui/icons-material/Search';
import EditIcon from '@mui/icons-material/Edit';
import { useState } from 'react';
- import { Dispatch, SetStateAction } from 'react';
// Beispiel-Daten
@@ -20,7 +19,7 @@ import {
];
// React-Komponente
-
+ import { Dispatch, SetStateAction } from 'react';
type Props = {
setSelectedLabel: Dispatch>;
};
diff --git a/project/frontend/src/components/highlightData.ts b/project/frontend/src/components/highlightData.ts
deleted file mode 100644
index 536a633..0000000
--- a/project/frontend/src/components/highlightData.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-// Beispielhafte Highlight-Daten mit Labels
-export const highlightData = [
- {
- label: 'Risikoprofil',
- page: 1,
- x: 100,
- y: 200,
- width: 120,
- height: 20,
- type: 'all', // gelb
- },
- {
- label: 'Risikoprofil',
- page: 1,
- x: 100,
- y: 300,
- width: 140,
- height: 25,
- type: 'selected', // orange (nur wenn ausgewählt)
- }
-];
diff --git a/project/frontend/src/components/pdfViewer.tsx b/project/frontend/src/components/pdfViewer.tsx
index bc7ced8..9900651 100644
--- a/project/frontend/src/components/pdfViewer.tsx
+++ b/project/frontend/src/components/pdfViewer.tsx
@@ -1,13 +1,11 @@
import { Document, Page, pdfjs } from "react-pdf";
-import { useState, useRef, useEffect } from 'react';
+import { useState, useRef, useEffect, useCallback } from 'react';
import 'react-pdf/dist/esm/Page/AnnotationLayer.css';
import 'react-pdf/dist/esm/Page/TextLayer.css';
import { Box, IconButton } from '@mui/material';
import ArrowCircleLeftIcon from '@mui/icons-material/ArrowCircleLeft';
import ArrowCircleRightIcon from '@mui/icons-material/ArrowCircleRight';
import testPDF from '/example.pdf';
-import HighlightOverlay from './HighlightOverlay';
-import { highlightData } from './highlightData';
@@ -32,6 +30,29 @@ type Props = {
setNumPages(numPages);
};
+ const [highlightLabels, setHighlightLabels] = useState([]);
+
+ // Funktion zum Einfärben von Text
+ function highlightPattern(text: string, patterns: string[]) {
+ for (const word of patterns) {
+ const regex = new RegExp(`(${word})`, 'gi');
+ text = text.replace(regex, '$1');
+ }
+ return text;
+ }
+
+ // TextRenderer für PDF
+ const textRenderer = useCallback(
+ (textItem: { str: string }) => highlightPattern(textItem.str, highlightLabels),
+ [highlightLabels]
+ );
+
+ // Beispielanzatz zum Einfärben von Text
+ useEffect(() => {
+ setHighlightLabels(['LTV']);
+ }, []);
+
+
useEffect(() => {
const updateWidth = () => {
if (containerRef.current) {
@@ -76,19 +97,9 @@ type Props = {
- {/* Highlights einfügen */}
- {highlightData
- .filter((h) => h.page === pageNumber)
- .map((h, idx) => (
-
-
- ))}
)}