new interactive
This commit is contained in:
@@ -1,23 +1,25 @@
|
||||
import { generateAnonymizedText } from "@/app/utils/generateAnonymizedText";
|
||||
import { EntityMapping } from "@/app/config/entityLabels";
|
||||
|
||||
interface DownloadActionsProps {
|
||||
outputText: string;
|
||||
entityMappings?: EntityMapping[];
|
||||
anonymizedText?: string; // Nouveau paramètre pour le texte déjà anonymisé par Presidio
|
||||
}
|
||||
|
||||
export const useDownloadActions = ({
|
||||
outputText,
|
||||
entityMappings = [],
|
||||
anonymizedText, // Texte déjà anonymisé par Presidio
|
||||
}: DownloadActionsProps) => {
|
||||
const copyToClipboard = () => {
|
||||
const anonymizedText = generateAnonymizedText(outputText, entityMappings);
|
||||
navigator.clipboard.writeText(anonymizedText);
|
||||
// Toujours utiliser le texte anonymisé de Presidio
|
||||
const textToCopy = anonymizedText || outputText;
|
||||
navigator.clipboard.writeText(textToCopy);
|
||||
};
|
||||
|
||||
const downloadText = () => {
|
||||
const anonymizedText = generateAnonymizedText(outputText, entityMappings);
|
||||
const blob = new Blob([anonymizedText], { type: "text/plain" });
|
||||
// Utiliser le texte anonymisé de Presidio si disponible, sinon fallback sur outputText
|
||||
const textToDownload = anonymizedText || outputText;
|
||||
const blob = new Blob([textToDownload], { type: "text/plain" });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
|
||||
Reference in New Issue
Block a user