fix: word detection + highlighting for all pair types

- Remove needsWordDetection guard — wordMap always populated
- "Als Wort erstellen" banner shown for all types
- Erkannte Wörter indicator shown for all types

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-25 16:14:35 +02:00
parent 0c816d3f2d
commit 6c730889be

View File

@@ -189,8 +189,8 @@ function PairForm({ objectId, onPairSaved }) {
const [saving, setSaving] = useState(false); const [saving, setSaving] = useState(false);
// Auto-detect words in sentence fields // Auto-detect words in sentence fields
const needsWordDetection = type === 'text' || type === 'question'; // Always detect words from all sentence fields (for all types)
const allText = needsWordDetection ? `${question} ${positive} ${negative}` : ''; const allText = `${question} ${positive} ${negative}`;
useEffect(() => { useEffect(() => {
if (!allText.trim()) { setWordMap({}); return; } if (!allText.trim()) { setWordMap({}); return; }
const t = setTimeout(async () => { const t = setTimeout(async () => {
@@ -342,8 +342,8 @@ function PairForm({ objectId, onPairSaved }) {
{type && ( {type && (
<div className="space-y-2.5 pt-1 border-t border-indigo-100"> <div className="space-y-2.5 pt-1 border-t border-indigo-100">
{/* Word creation banner (text/question) */} {/* Word creation banner — shown for any type when text is selected */}
{(type === 'text' || type === 'question') && selection && ( {selection && (
<div className="flex items-center gap-2 bg-white border border-indigo-200 rounded-lg px-2.5 py-1.5"> <div className="flex items-center gap-2 bg-white border border-indigo-200 rounded-lg px-2.5 py-1.5">
<span className="text-xs text-slate-600 flex-1 truncate"> <span className="text-xs text-slate-600 flex-1 truncate">
<strong className="text-indigo-700">{selection}</strong>" <strong className="text-indigo-700">{selection}</strong>"
@@ -462,8 +462,8 @@ function PairForm({ objectId, onPairSaved }) {
</> </>
)} )}
{/* Detected words indicator */} {/* Detected words indicator — shown for all types */}
{(type === 'text' || type === 'question') && Object.keys(wordMap).length > 0 && ( {Object.keys(wordMap).length > 0 && (
<div className="flex flex-wrap gap-1"> <div className="flex flex-wrap gap-1">
<span className="text-xs text-slate-400 w-full">Erkannte Wörter:</span> <span className="text-xs text-slate-400 w-full">Erkannte Wörter:</span>
{Object.entries(wordMap).map(([title, w]) => ( {Object.entries(wordMap).map(([title, w]) => (