shinkan-jinkendo/frontend/src/utils/htmlUtils.js
Lars d8f439a3e5
Some checks failed
Deploy Development / deploy (push) Successful in 36s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 6s
Test Suite / playwright-tests (push) Failing after 1m58s
feat: enhance exercise management with training types and rich text support
- 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.
2026-04-27 14:48:46 +02:00

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
}