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