- Added support for training types in exercise creation and updates, allowing for better categorization of exercises. - Implemented a rich text editor for exercise descriptions, improving content formatting capabilities. - Updated the ExerciseDetailPage to display training types and enhanced the layout for better user experience. - Refactored ExerciseFormPage to accommodate new multi-association fields for training styles, types, and target groups. - Improved API payload handling to include training types and ensure proper data structure for exercise management. - Enhanced the ExercisesListPage with improved loading and filtering functionalities for better performance.
24 lines
848 B
JavaScript
24 lines
848 B
JavaScript
/** Einfache HTML-Hilfen für Rich-Text (Trainer-Content, kein öffentliches CMS). */
|
|
|
|
export function stripHtmlToText(html) {
|
|
if (!html || typeof html !== 'string') return ''
|
|
const d = document.createElement('div')
|
|
d.innerHTML = html
|
|
return (d.textContent || '').replace(/\s+/g, ' ').trim()
|
|
}
|
|
|
|
/** Entfernt script/iframes und Event-Handler-Attribute grob. */
|
|
export function sanitizeTrainerHtml(html) {
|
|
if (!html || typeof html !== 'string') return ''
|
|
const d = document.createElement('div')
|
|
d.innerHTML = html
|
|
d.querySelectorAll('script, iframe, object, embed').forEach((n) => n.remove())
|
|
d.querySelectorAll('*').forEach((el) => {
|
|
for (const attr of [...el.attributes]) {
|
|
const n = attr.name.toLowerCase()
|
|
if (n.startsWith('on') || n === 'srcdoc') el.removeAttribute(attr.name)
|
|
}
|
|
})
|
|
return d.innerHTML
|
|
}
|