[FA-misc] Switches to using DTOs, updates frontend with details and reader page, updates novel import to be an upsert

This commit is contained in:
gamer147
2025-12-08 18:30:00 -05:00
parent c9d93a4e55
commit 81e4e88ad4
48 changed files with 3298 additions and 329 deletions

View File

@@ -0,0 +1,74 @@
import DOMPurify from 'isomorphic-dompurify';
/**
* Sanitizes chapter HTML content with extended allowed tags.
* More permissive than the description sanitizer to support
* formatted novel content including headings, lists, and images.
*/
export function sanitizeChapterHtml(html: string): string {
return DOMPurify.sanitize(html, {
ALLOWED_TAGS: [
// Basic formatting
'b',
'i',
'em',
'strong',
'u',
's',
'strike',
'del',
'ins',
// Structure
'p',
'br',
'hr',
'div',
'span',
// Headings
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
// Lists
'ul',
'ol',
'li',
// Quotes
'blockquote',
'q',
'cite',
// Preformatted
'pre',
'code',
// Ruby (for Asian language annotations)
'ruby',
'rt',
'rp',
// Images
'img',
// Tables
'table',
'thead',
'tbody',
'tr',
'th',
'td'
],
ALLOWED_ATTR: [
// Image attributes
'src',
'alt',
'title',
'width',
'height',
// Table attributes
'colspan',
'rowspan',
// Generic styling (limited)
'class'
],
ALLOW_DATA_ATTR: false
});
}