feat(exercises): update inline media functionality and version bump to 0.8.63
Deploy Development / deploy (push) Successful in 34s
Test Suite / pytest-backend (push) Successful in 24s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 7s
Test Suite / playwright-tests (push) Successful in 30s
Deploy Development / deploy (push) Successful in 34s
Test Suite / pytest-backend (push) Successful in 24s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 7s
Test Suite / playwright-tests (push) Successful in 30s
- Incremented application version to 0.8.63 and updated changelog with new features. - Enhanced inline media handling in the Rich Text Editor, including support for captions. - Introduced new CSS styles for improved media display and layout in the editor. - Replaced `ExerciseMediaEmbed` with `ExerciseAttachmentMediaStrip` for better media management in exercise content.
This commit is contained in:
1 parent
311a106d93
commit
337f29401b
13 files changed
+887
-429
No files matched your search
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react'
|
||||
import { Link, useNavigate, useParams } from 'react-router-dom'
|
||||
import api from '../utils/api'
|
||||
import ExerciseRichTextBlock from '../components/ExerciseRichTextBlock'
|
||||
import ExerciseMediaEmbed from '../components/ExerciseMediaEmbed'
|
||||
import ExerciseAttachmentMediaStrip from '../components/ExerciseAttachmentMediaStrip'
|
||||
import { formatSkillLevelSlug } from '../constants/skillLevels'
|
||||
|
||||
function TagRow({ exercise }) {
|
||||
@@ -104,10 +104,6 @@ function ExerciseDetailPage() {
|
||||
if (!exercise) return null
|
||||
|
||||
const meta = metaParts(exercise)
|
||||
const visibleMedia = (exercise.media || []).filter((m) => {
|
||||
const lc = String(m.asset_lifecycle_state || 'active').toLowerCase()
|
||||
return lc !== 'trash_hidden'
|
||||
})
|
||||
|
||||
return (
|
||||
<div className="exercise-detail-shell" style={{ padding: '12px 12px 24px' }}>
|
||||
@@ -168,23 +164,7 @@ function ExerciseDetailPage() {
|
||||
</section>
|
||||
)}
|
||||
|
||||
{visibleMedia.length > 0 && (
|
||||
<section className="card exercise-detail-section">
|
||||
<h2>Medien</h2>
|
||||
{visibleMedia.map((m) => (
|
||||
<div key={m.id} style={{ marginBottom: '1.25rem' }}>
|
||||
<strong style={{ fontSize: '15px' }}>{m.title || m.original_filename || m.media_type}</strong>
|
||||
{String(m.asset_lifecycle_state || 'active').toLowerCase() === 'trash_soft' && (
|
||||
<p style={{ fontSize: '12px', color: 'var(--danger)', margin: '6px 0 0' }}>
|
||||
Hinweis: Dieses Medium ist im Papierkorb und steht künftig nicht mehr zur Verfügung.
|
||||
</p>
|
||||
)}
|
||||
{m.description && <p style={{ color: 'var(--text2)', fontSize: '0.9rem' }}>{m.description}</p>}
|
||||
<ExerciseMediaEmbed media={m} exerciseId={exercise.id} layoutSize="full" />
|
||||
</div>
|
||||
))}
|
||||
</section>
|
||||
)}
|
||||
<ExerciseAttachmentMediaStrip exercise={exercise} exerciseId={exercise.id} />
|
||||
|
||||
{exercise.trainer_notes && (
|
||||
<section className="card exercise-detail-section">
|
||||
|
||||
@@ -4,87 +4,14 @@ import api, { buildExerciseApiPayload } from '../utils/api'
|
||||
import { resolveExerciseMediaFileUrl, resolveMediaAssetFileUrl } from '../utils/exerciseMediaUrl'
|
||||
import RichTextEditor from '../components/RichTextEditor'
|
||||
import ExerciseProgressionGraphPanel from '../components/ExerciseProgressionGraphPanel'
|
||||
import ExerciseMediaThumbTile from '../components/ExerciseMediaThumbTile'
|
||||
import {
|
||||
SHINKAN_EXERCISE_MEDIA_DRAG_MIME,
|
||||
buildExerciseMediaDragPayload,
|
||||
} from '../utils/exerciseInlineMediaRefs'
|
||||
import { SKILL_LEVEL_OPTIONS, normalizeSkillLevelSlug } from '../constants/skillLevels'
|
||||
import { useAuth } from '../context/AuthContext'
|
||||
|
||||
/** MIME/Dateiname → Übungs-media_type; null → Dropdown-Fallback. */
|
||||
function inferExerciseMediaType(file) {
|
||||
if (!file) return null
|
||||
const mime = (file.type || '').toLowerCase()
|
||||
if (mime.startsWith('image/')) return 'image'
|
||||
if (mime.startsWith('video/')) return 'video'
|
||||
if (mime === 'application/pdf' || mime.includes('pdf')) return 'document'
|
||||
const name = (file.name || '').toLowerCase()
|
||||
if (/\.(mp4|webm|mov|mkv|avi|m4v|mpeg|mpg)$/.test(name)) return 'video'
|
||||
if (/\.(jpg|jpeg|png|gif|webp|bmp|svg)$/.test(name)) return 'image'
|
||||
if (/\.pdf$/.test(name)) return 'document'
|
||||
return null
|
||||
}
|
||||
|
||||
/** Kachelvorschau: Video nutzt ersten Frame (metadata), Bild = img. */
|
||||
function ExerciseMediaThumbTile({ exerciseId, media, onOpenPreview }) {
|
||||
const src = !media.embed_url ? resolveExerciseMediaFileUrl(exerciseId, media) : null
|
||||
const commonStyle = {
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
objectFit: 'cover',
|
||||
}
|
||||
return (
|
||||
<div
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
title="Vorschau"
|
||||
onClick={() => onOpenPreview(media)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
e.preventDefault()
|
||||
onOpenPreview(media)
|
||||
}
|
||||
}}
|
||||
style={{
|
||||
width: 72,
|
||||
height: 72,
|
||||
flexShrink: 0,
|
||||
borderRadius: '8px',
|
||||
overflow: 'hidden',
|
||||
background: 'var(--surface2, rgba(127,127,127,0.12))',
|
||||
border: '1px solid var(--border)',
|
||||
cursor: 'pointer',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
}}
|
||||
>
|
||||
{media.embed_url ? (
|
||||
<span style={{ fontSize: '11px', padding: '4px', color: 'var(--text2)', textAlign: 'center' }}>
|
||||
{media.embed_platform || 'Embed'}
|
||||
</span>
|
||||
) : (media.mime_type?.startsWith('image/') || media.media_type === 'image') && src ? (
|
||||
<img alt="" src={src} style={commonStyle} />
|
||||
) : (media.mime_type?.startsWith('video/') || media.media_type === 'video') && src ? (
|
||||
<video
|
||||
src={src}
|
||||
muted
|
||||
playsInline
|
||||
preload="metadata"
|
||||
style={{ ...commonStyle, pointerEvents: 'none' }}
|
||||
onLoadedMetadata={(e) => {
|
||||
try {
|
||||
const el = e.currentTarget
|
||||
const d = el.duration
|
||||
el.currentTime = Number.isFinite(d) && d > 0 ? Math.min(0.05, d * 0.01) : 0.05
|
||||
} catch (_) {
|
||||
/* ignore */
|
||||
}
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<span style={{ fontSize: '11px', color: 'var(--text2)' }}>Datei</span>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const INTENSITY_OPTIONS = [
|
||||
{ value: '', label: '—' },
|
||||
{ value: 'niedrig', label: 'niedrig' },
|
||||
@@ -175,6 +102,7 @@ function ExerciseVariantFields({
|
||||
prerequisiteOthers,
|
||||
rteMinHeight = '110px',
|
||||
inlineExerciseId,
|
||||
linkedExerciseMedia = [],
|
||||
onExerciseMediaListChanged,
|
||||
}) {
|
||||
return (
|
||||
@@ -206,6 +134,7 @@ function ExerciseVariantFields({
|
||||
placeholder="Was unterscheidet diese Variante? (Listen über Symbolleiste)"
|
||||
minHeight={rteMinHeight}
|
||||
inlineExerciseId={inlineExerciseId}
|
||||
linkedExerciseMedia={linkedExerciseMedia}
|
||||
onExerciseMediaListChanged={onExerciseMediaListChanged}
|
||||
/>
|
||||
</div>
|
||||
@@ -452,12 +381,6 @@ function ExerciseFormPage() {
|
||||
const [variantEditSelection, setVariantEditSelection] = useState(null)
|
||||
const variantsDetailsRef = useRef(null)
|
||||
|
||||
const [mediaFiles, setMediaFiles] = useState([])
|
||||
const [mediaType, setMediaType] = useState('image')
|
||||
const [mediaTitle, setMediaTitle] = useState('')
|
||||
const [mediaContext, setMediaContext] = useState('ablauf')
|
||||
const [embedUrl, setEmbedUrl] = useState('')
|
||||
const [embedTitle, setEmbedTitle] = useState('')
|
||||
const [mediaFields, setMediaFields] = useState({})
|
||||
const [mediaSavingId, setMediaSavingId] = useState(null)
|
||||
const [archiveOpen, setArchiveOpen] = useState(false)
|
||||
@@ -763,88 +686,6 @@ function ExerciseFormPage() {
|
||||
[mediaList],
|
||||
)
|
||||
|
||||
const handleUploadFile = async () => {
|
||||
if (!exerciseId || mediaFiles.length === 0) {
|
||||
alert('Datei(en) wählen')
|
||||
return
|
||||
}
|
||||
const files = [...mediaFiles]
|
||||
for (const file of files) {
|
||||
const inferred = inferExerciseMediaType(file) || mediaType
|
||||
const fd = new FormData()
|
||||
fd.append('file', file)
|
||||
fd.append('media_type', inferred)
|
||||
fd.append('title', mediaTitle)
|
||||
fd.append('description', '')
|
||||
fd.append('context', mediaContext)
|
||||
fd.append('is_primary', 'false')
|
||||
try {
|
||||
await api.uploadExerciseMedia(exerciseId, fd)
|
||||
} catch (err) {
|
||||
if (err.code === 'MEDIA_ASSET_IN_TRASH' && err.payload?.media_asset_id != null) {
|
||||
const aid = err.payload.media_asset_id
|
||||
const nameHint = file?.name || err.payload.original_filename || 'diese Datei'
|
||||
if (
|
||||
confirm(
|
||||
`Die hochgeladene Datei ist inhaltsgleich mit einem Archiv-Medium im Papierkorb (${nameHint}). ` +
|
||||
'Soll dieses Medium wieder aktiviert und an die Übung gehängt werden? (Es wird kein zweites Exemplar auf der Platte angelegt.)',
|
||||
)
|
||||
) {
|
||||
try {
|
||||
await api.postMediaAssetLifecycle(aid, 'reactivate')
|
||||
await api.attachExerciseMediaFromAsset(exerciseId, {
|
||||
media_asset_id: aid,
|
||||
title: mediaTitle || undefined,
|
||||
description: '',
|
||||
context: mediaContext,
|
||||
is_primary: false,
|
||||
})
|
||||
} catch (e2) {
|
||||
alert(e2.message || String(e2))
|
||||
return
|
||||
}
|
||||
} else {
|
||||
return
|
||||
}
|
||||
} else if (err.code === 'MEDIA_ASSET_UNAVAILABLE') {
|
||||
alert(
|
||||
(err.message || 'Archiv-Konflikt') +
|
||||
' Bitte wenden Sie sich an einen Administrator oder wählen Sie eine andere Datei.',
|
||||
)
|
||||
return
|
||||
} else {
|
||||
alert(`Upload (${file.name}): ${err.message || String(err)}`)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
setMediaFiles([])
|
||||
setMediaTitle('')
|
||||
await refreshMedia()
|
||||
}
|
||||
|
||||
const handleAddEmbed = async () => {
|
||||
if (!exerciseId || !embedUrl.trim()) {
|
||||
alert('Embed-URL eingeben')
|
||||
return
|
||||
}
|
||||
const fd = new FormData()
|
||||
fd.append('embed_url', embedUrl.trim())
|
||||
fd.append('media_type', 'video')
|
||||
fd.append('title', embedTitle)
|
||||
fd.append('description', '')
|
||||
fd.append('context', mediaContext)
|
||||
fd.append('is_primary', 'false')
|
||||
try {
|
||||
await api.uploadExerciseMedia(exerciseId, fd)
|
||||
setEmbedUrl('')
|
||||
setEmbedTitle('')
|
||||
await refreshMedia()
|
||||
} catch (err) {
|
||||
alert('Embed: ' + err.message)
|
||||
}
|
||||
}
|
||||
|
||||
const handleDeleteMedia = async (mid) => {
|
||||
if (
|
||||
!confirm(
|
||||
@@ -1050,6 +891,7 @@ function ExerciseFormPage() {
|
||||
placeholder="Kurzbeschreibung (optional)"
|
||||
minHeight="80px"
|
||||
inlineExerciseId={isEdit ? exerciseId : null}
|
||||
linkedExerciseMedia={isEdit ? mediaList : []}
|
||||
onExerciseMediaListChanged={refreshMedia}
|
||||
/>
|
||||
</div>
|
||||
@@ -1062,6 +904,7 @@ function ExerciseFormPage() {
|
||||
placeholder="Trainingsziel"
|
||||
minHeight="120px"
|
||||
inlineExerciseId={isEdit ? exerciseId : null}
|
||||
linkedExerciseMedia={isEdit ? mediaList : []}
|
||||
onExerciseMediaListChanged={refreshMedia}
|
||||
/>
|
||||
</div>
|
||||
@@ -1074,6 +917,7 @@ function ExerciseFormPage() {
|
||||
placeholder="Ablauf Schritt für Schritt"
|
||||
minHeight="180px"
|
||||
inlineExerciseId={isEdit ? exerciseId : null}
|
||||
linkedExerciseMedia={isEdit ? mediaList : []}
|
||||
onExerciseMediaListChanged={refreshMedia}
|
||||
/>
|
||||
</div>
|
||||
@@ -1086,6 +930,7 @@ function ExerciseFormPage() {
|
||||
placeholder="Matten, Raum, …"
|
||||
minHeight="100px"
|
||||
inlineExerciseId={isEdit ? exerciseId : null}
|
||||
linkedExerciseMedia={isEdit ? mediaList : []}
|
||||
onExerciseMediaListChanged={refreshMedia}
|
||||
/>
|
||||
</div>
|
||||
@@ -1098,6 +943,7 @@ function ExerciseFormPage() {
|
||||
placeholder="Sicherheit, Varianten-Hinweise, …"
|
||||
minHeight="100px"
|
||||
inlineExerciseId={isEdit ? exerciseId : null}
|
||||
linkedExerciseMedia={isEdit ? mediaList : []}
|
||||
onExerciseMediaListChanged={refreshMedia}
|
||||
/>
|
||||
</div>
|
||||
@@ -1394,6 +1240,7 @@ function ExerciseFormPage() {
|
||||
prerequisiteOthers={variants}
|
||||
rteMinHeight="110px"
|
||||
inlineExerciseId={isEdit ? exerciseId : null}
|
||||
linkedExerciseMedia={isEdit ? mediaList : []}
|
||||
onExerciseMediaListChanged={refreshMedia}
|
||||
/>
|
||||
<button type="submit" className="btn btn-primary" style={{ marginTop: '10px' }} disabled={variantBusy}>
|
||||
@@ -1462,6 +1309,7 @@ function ExerciseFormPage() {
|
||||
prerequisiteOthers={variants.filter((o) => o.id !== selectedVariantForEdit.id)}
|
||||
rteMinHeight="110px"
|
||||
inlineExerciseId={isEdit ? exerciseId : null}
|
||||
linkedExerciseMedia={isEdit ? mediaList : []}
|
||||
onExerciseMediaListChanged={refreshMedia}
|
||||
/>
|
||||
</div>
|
||||
@@ -1491,8 +1339,13 @@ function ExerciseFormPage() {
|
||||
{isEdit && (
|
||||
<div className="card" style={{ marginTop: '16px' }}>
|
||||
<h2 style={{ marginTop: 0, fontSize: '1.1rem' }}>Medien</h2>
|
||||
<p style={{ color: 'var(--text2)', fontSize: '13px' }}>
|
||||
Datei oder Embed (YouTube, Vimeo, Instagram, TikTok). Max. 10 pro Übung.
|
||||
<p style={{ color: 'var(--text2)', fontSize: '13px', marginBottom: '6px' }}>
|
||||
Neue Uploads oder Embeds über die Textfeld-Symbolleiste („Medien im Text“ / „Embed im Text“). Hier
|
||||
verwaltest du Verknüpfungen — Kachel in ein Textfeld ziehen, um sie an der Cursorposition einzufügen
|
||||
(mittlere Darstellung).
|
||||
</p>
|
||||
<p style={{ color: 'var(--text3)', fontSize: '12px', marginTop: 0 }}>
|
||||
Max. 10 Medien pro Übung.
|
||||
</p>
|
||||
<div
|
||||
style={{
|
||||
@@ -1510,191 +1363,139 @@ function ExerciseFormPage() {
|
||||
Medienbibliothek
|
||||
</Link>
|
||||
</div>
|
||||
<div style={{ display: 'grid', gap: '12px', marginTop: '12px' }}>
|
||||
<div>
|
||||
<label className="form-label">Dateien</label>
|
||||
<input
|
||||
type="file"
|
||||
multiple
|
||||
accept="image/*,video/*,application/pdf"
|
||||
onChange={(e) => {
|
||||
setMediaFiles(Array.from(e.target.files || []))
|
||||
e.target.value = ''
|
||||
}}
|
||||
/>
|
||||
{mediaFiles.length > 0 && (
|
||||
<div style={{ fontSize: '0.875rem', color: 'var(--text2)', marginTop: '6px' }}>
|
||||
{mediaFiles.length} Datei(en): {mediaFiles.map((f) => f.name).join(', ')}
|
||||
</div>
|
||||
)}
|
||||
<div className="form-row" style={{ marginTop: '8px' }}>
|
||||
<select className="form-input" value={mediaType} onChange={(e) => setMediaType(e.target.value)}>
|
||||
<option value="image">Typ-Fallback: Bild</option>
|
||||
<option value="video">Typ-Fallback: Video</option>
|
||||
<option value="document">Typ-Fallback: PDF</option>
|
||||
</select>
|
||||
<input
|
||||
type="text"
|
||||
className="form-input"
|
||||
placeholder="Titel (optional)"
|
||||
value={mediaTitle}
|
||||
onChange={(e) => setMediaTitle(e.target.value)}
|
||||
style={{ marginTop: '8px' }}
|
||||
/>
|
||||
<select
|
||||
className="form-input"
|
||||
value={mediaContext}
|
||||
onChange={(e) => setMediaContext(e.target.value)}
|
||||
style={{ marginTop: '8px' }}
|
||||
>
|
||||
<option value="ablauf">Ablauf</option>
|
||||
<option value="detail">Detail</option>
|
||||
<option value="trainer_hint">Trainer-Hinweis</option>
|
||||
</select>
|
||||
</div>
|
||||
<button type="button" className="btn btn-secondary" style={{ marginTop: '8px' }} onClick={handleUploadFile}>
|
||||
Hochladen
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<label className="form-label">Embed-URL</label>
|
||||
<input
|
||||
type="url"
|
||||
className="form-input"
|
||||
placeholder="https://…"
|
||||
value={embedUrl}
|
||||
onChange={(e) => setEmbedUrl(e.target.value)}
|
||||
/>
|
||||
<input
|
||||
type="text"
|
||||
className="form-input"
|
||||
placeholder="Titel (optional)"
|
||||
value={embedTitle}
|
||||
onChange={(e) => setEmbedTitle(e.target.value)}
|
||||
style={{ marginTop: '8px' }}
|
||||
/>
|
||||
<button type="button" className="btn btn-secondary" style={{ marginTop: '8px' }} onClick={handleAddEmbed}>
|
||||
Embed hinzufügen
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{mediaList.length > 0 && (
|
||||
<ul style={{ marginTop: '12px', paddingLeft: '0', listStyle: 'none' }}>
|
||||
{mediaList.map((m, idx) => (
|
||||
<li
|
||||
key={m.id}
|
||||
className="card"
|
||||
style={{
|
||||
marginBottom: '10px',
|
||||
padding: '10px 12px',
|
||||
border: '1px solid var(--border)',
|
||||
display: 'flex',
|
||||
gap: '12px',
|
||||
alignItems: 'flex-start',
|
||||
}}
|
||||
>
|
||||
<ExerciseMediaThumbTile exerciseId={exerciseId} media={m} onOpenPreview={setMediaPreview} />
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '8px', alignItems: 'center' }}>
|
||||
<span style={{ fontSize: '12px', color: 'var(--text3)' }}>
|
||||
#{idx + 1} · {m.media_type}
|
||||
{m.embed_platform ? ` · ${m.embed_platform}` : ''}
|
||||
</span>
|
||||
{mediaList.length > 1 && (
|
||||
<>
|
||||
<ul className="exercise-edit-media-strip">
|
||||
{mediaList.map((m, idx) => {
|
||||
const cap =
|
||||
(m.title || '').trim() ||
|
||||
(m.original_filename || '').trim() ||
|
||||
(m.embed_url ? String(m.embed_url).replace(/^https?:\/\//i, '').slice(0, 80) : '')
|
||||
const sub = [m.media_type, m.embed_platform].filter(Boolean).join(' · ') || 'Medium'
|
||||
const payloadCaption = (
|
||||
[m.title, m.original_filename].find((x) => typeof x === 'string' && x.trim()) || ''
|
||||
).trim()
|
||||
return (
|
||||
<li key={m.id} className="exercise-edit-media-strip__item">
|
||||
<div className="exercise-edit-media-strip__lead">
|
||||
{!m.embed_url ? (
|
||||
<ExerciseMediaThumbTile exerciseId={exerciseId} media={m} onOpenPreview={setMediaPreview} size={76} />
|
||||
) : (
|
||||
<div
|
||||
className="exercise-edit-media-strip__embed-badge exercise-edit-media-strip__embed-badge--solo"
|
||||
aria-hidden
|
||||
>
|
||||
{m.embed_platform || 'Embed'}
|
||||
</div>
|
||||
)}
|
||||
<div
|
||||
className="exercise-edit-media-strip__handle"
|
||||
title="Mit Drag und Drop in ein Textfeld ziehen"
|
||||
draggable
|
||||
onDragStart={(e) => {
|
||||
try {
|
||||
e.dataTransfer.setData(
|
||||
SHINKAN_EXERCISE_MEDIA_DRAG_MIME,
|
||||
buildExerciseMediaDragPayload(m.id, payloadCaption),
|
||||
)
|
||||
e.dataTransfer.effectAllowed = 'copy'
|
||||
} catch (_) {
|
||||
/* ignore */
|
||||
}
|
||||
}}
|
||||
>
|
||||
⣿<span className="exercise-edit-media-strip__handle-text"> Ziehen</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="exercise-edit-media-strip__body">
|
||||
<div className="exercise-edit-media-strip__headline">
|
||||
<span style={{ fontSize: '12px', color: 'var(--text3)' }}>
|
||||
#{m.id} · {sub}
|
||||
</span>
|
||||
</div>
|
||||
<div style={{ fontSize: '13px', color: 'var(--text2)', lineHeight: 1.35 }}>{cap || '—'}</div>
|
||||
<div className="exercise-edit-media-strip__toolbar">
|
||||
<input
|
||||
type="text"
|
||||
className="form-input exercise-edit-media-strip__title"
|
||||
placeholder="Titel"
|
||||
value={(mediaFields[m.id] || {}).title ?? ''}
|
||||
onChange={(e) =>
|
||||
setMediaFields((prev) => ({
|
||||
...prev,
|
||||
[m.id]: {
|
||||
...(prev[m.id] || {}),
|
||||
title: e.target.value,
|
||||
context: (prev[m.id] || {}).context || 'ablauf',
|
||||
},
|
||||
}))
|
||||
}
|
||||
/>
|
||||
<select
|
||||
className="form-input exercise-edit-media-strip__ctx"
|
||||
value={(mediaFields[m.id] || {}).context || 'ablauf'}
|
||||
onChange={(e) =>
|
||||
setMediaFields((prev) => ({
|
||||
...prev,
|
||||
[m.id]: {
|
||||
...(prev[m.id] || {}),
|
||||
title: (prev[m.id] || {}).title ?? '',
|
||||
context: e.target.value,
|
||||
},
|
||||
}))
|
||||
}
|
||||
>
|
||||
<option value="ablauf">Ablauf</option>
|
||||
<option value="detail">Detail</option>
|
||||
<option value="trainer_hint">Trainer-Hinweis</option>
|
||||
</select>
|
||||
</div>
|
||||
<div className="exercise-edit-media-strip__actions">
|
||||
{mediaList.length > 1 && (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
style={{ fontSize: '11px', padding: '4px 8px' }}
|
||||
disabled={idx === 0}
|
||||
onClick={() => moveMediaRow(idx, -1)}
|
||||
title="Nach oben"
|
||||
>
|
||||
↑
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
style={{ fontSize: '11px', padding: '4px 8px' }}
|
||||
disabled={idx >= mediaList.length - 1}
|
||||
onClick={() => moveMediaRow(idx, 1)}
|
||||
title="Nach unten"
|
||||
>
|
||||
↓
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
style={{ fontSize: '11px', padding: '2px 8px' }}
|
||||
disabled={idx === 0}
|
||||
onClick={() => moveMediaRow(idx, -1)}
|
||||
title="Nach oben"
|
||||
className="btn btn-primary"
|
||||
style={{ fontSize: '12px', padding: '4px 10px' }}
|
||||
disabled={mediaSavingId === m.id}
|
||||
onClick={() => saveMediaMeta(m.id)}
|
||||
>
|
||||
↑
|
||||
{mediaSavingId === m.id ? '…' : 'Speichern'}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
style={{ fontSize: '11px', padding: '2px 8px' }}
|
||||
disabled={idx >= mediaList.length - 1}
|
||||
onClick={() => moveMediaRow(idx, 1)}
|
||||
title="Nach unten"
|
||||
style={{ fontSize: '12px', padding: '4px 10px' }}
|
||||
onClick={() => handleDeleteMedia(m.id)}
|
||||
>
|
||||
↓
|
||||
Entfernen
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
fontSize: '12px',
|
||||
color: 'var(--text2)',
|
||||
marginTop: '6px',
|
||||
wordBreak: 'break-word',
|
||||
lineHeight: 1.35,
|
||||
}}
|
||||
>
|
||||
{(m.original_filename || '').trim() ||
|
||||
(m.title || '').trim() ||
|
||||
(m.embed_url ? m.embed_url : '') ||
|
||||
'—'}
|
||||
</div>
|
||||
<div className="form-row" style={{ marginTop: '8px', display: 'grid', gap: '8px' }}>
|
||||
<input
|
||||
type="text"
|
||||
className="form-input"
|
||||
placeholder="Titel"
|
||||
value={(mediaFields[m.id] || {}).title ?? ''}
|
||||
onChange={(e) =>
|
||||
setMediaFields((prev) => ({
|
||||
...prev,
|
||||
[m.id]: { ...(prev[m.id] || {}), title: e.target.value, context: (prev[m.id] || {}).context || 'ablauf' },
|
||||
}))
|
||||
}
|
||||
/>
|
||||
<select
|
||||
className="form-input"
|
||||
value={(mediaFields[m.id] || {}).context || 'ablauf'}
|
||||
onChange={(e) =>
|
||||
setMediaFields((prev) => ({
|
||||
...prev,
|
||||
[m.id]: {
|
||||
...(prev[m.id] || {}),
|
||||
title: (prev[m.id] || {}).title ?? '',
|
||||
context: e.target.value,
|
||||
},
|
||||
}))
|
||||
}
|
||||
>
|
||||
<option value="ablauf">Ablauf</option>
|
||||
<option value="detail">Detail</option>
|
||||
<option value="trainer_hint">Trainer-Hinweis</option>
|
||||
</select>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary"
|
||||
style={{ fontSize: '12px' }}
|
||||
disabled={mediaSavingId === m.id}
|
||||
onClick={() => saveMediaMeta(m.id)}
|
||||
>
|
||||
{mediaSavingId === m.id ? 'Speichern…' : 'Titel & Sektion speichern'}
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
style={{
|
||||
marginTop: '8px',
|
||||
fontSize: '12px',
|
||||
padding: '6px 12px',
|
||||
}}
|
||||
onClick={() => handleDeleteMedia(m.id)}
|
||||
>
|
||||
Aus Übung entfernen
|
||||
</button>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
)}
|
||||
{archiveOpen && (
|
||||
|
||||
Reference in new issue
Block a user