new interactive

This commit is contained in:
Biqoz
2025-09-15 19:05:59 +02:00
parent 130929b756
commit 050474e95b
16 changed files with 746 additions and 330 deletions

View File

@@ -39,16 +39,16 @@ export const ResultPreviewComponent = ({
const filteredMappings = entityMappings.filter(
(mapping) => mapping.text !== originalValue
);
const newMappings: EntityMapping[] = [];
if (applyToAllOccurrences) {
// Appliquer à toutes les occurrences
let searchIndex = 0;
while (true) {
const foundIndex = sourceText.indexOf(originalValue, searchIndex);
if (foundIndex === -1) break;
if (isValidEntityBoundary(foundIndex, sourceText, originalValue)) {
newMappings.push({
text: originalValue,
@@ -68,7 +68,7 @@ export const ResultPreviewComponent = ({
const targetMapping = entityMappings.find(
(mapping) => mapping.start === wordStart && mapping.end === wordEnd
);
if (targetMapping) {
// Mettre à jour le mapping existant spécifique
const updatedMappings = entityMappings.map((m) => {
@@ -82,7 +82,7 @@ export const ResultPreviewComponent = ({
}
return m;
});
onMappingsUpdate?.(updatedMappings);
return;
} else {
@@ -101,7 +101,7 @@ export const ResultPreviewComponent = ({
const existingMapping = entityMappings.find(
(mapping) => mapping.text === originalValue
);
if (existingMapping) {
const updatedMappings = entityMappings.map((m) => {
if (
@@ -117,7 +117,7 @@ export const ResultPreviewComponent = ({
}
return m;
});
onMappingsUpdate?.(updatedMappings);
return;
} else {
@@ -138,7 +138,7 @@ export const ResultPreviewComponent = ({
}
}
}
// Notifier le parent avec les nouveaux mappings
const allMappings = [...filteredMappings, ...newMappings];
const uniqueMappings = allMappings.filter(
@@ -148,7 +148,7 @@ export const ResultPreviewComponent = ({
(m) => m.start === mapping.start && m.end === mapping.end
)
);
onMappingsUpdate?.(uniqueMappings.sort((a, b) => a.start - b.start));
};
@@ -225,7 +225,7 @@ export const ResultPreviewComponent = ({
<div className="flex-1 p-4 overflow-hidden">
<InteractiveTextEditor
text={sourceText}
entityMappings={entityMappings} // Utiliser entityMappings du parent au lieu de mappings
entityMappings={entityMappings}
onUpdateMapping={handleUpdateMapping}
onRemoveMapping={handleRemoveMapping}
/>