Remove unused components and models for improved maintainability
- Deleted redundant components (`AddActionButton`, `AlertBox`, `AlertStack`, `BackButton`, `CancelButton`, and `CollapsableArea`) and related files. - Removed unused models (`Book`, `BookSerie`, `BookTables`, `Character`, and `Chapter`) to reduce codebase clutter. - Updated project structure and references to reflect these removals.
This commit is contained in:
27
lib/utils/html.ts
Normal file
27
lib/utils/html.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
export function formatHTMLContent(htmlContent: string): string {
|
||||
return htmlContent
|
||||
.replace(/<h1>/g, '<h1 style="color: var(--color-text-primary); text-indent: 5px; font-size: 28px; font-weight: bold; text-align: left; margin-vertical: 10px;">')
|
||||
.replace(/<p>/g, '<p style="color: var(--color-editor-text); text-indent: 30px; font-size: 16px; line-height: 22px; margin-vertical: 5px;">')
|
||||
.replace(/<blockquote>/g, '<blockquote style="border-left-width: 4px; border-left-color: var(--color-gray-light); padding-left: 10px; font-style: italic; color: var(--color-text-dimmed);">');
|
||||
}
|
||||
|
||||
export function textContentToHtml(content: string): string {
|
||||
const paragraphs: string[] = content
|
||||
.split(/\n+/)
|
||||
.map((paragraph: string) => paragraph.trim())
|
||||
.filter((paragraph: string) => paragraph.length > 0);
|
||||
|
||||
return paragraphs
|
||||
.map((paragraph: string) => `<p>${paragraph}</p>`)
|
||||
.join('');
|
||||
}
|
||||
|
||||
export function htmlToText(html: string): string {
|
||||
return html
|
||||
.replace(/<br\s*\/?>/gi, '\n')
|
||||
.replace(/<\/?(p|h[1-6]|div)(\s+[^>]*)?>/gi, '\n')
|
||||
.replace(/<\/?[^>]+(>|$)/g, '')
|
||||
.replace(/(\n\s*){2,}/g, '\n\n')
|
||||
.replace(/^\s+|\s+$|(?<=\s)\s+/g, '')
|
||||
.trim();
|
||||
}
|
||||
Reference in New Issue
Block a user