ENH - expand Notes rich text editing

This commit is contained in:
smx.pusha
2026-08-13 17:25:37 +02:00
parent 223cb4a600
commit b4b341d202
9 changed files with 929 additions and 134 deletions
+24
View File
@@ -1,6 +1,11 @@
import { describe, expect, it } from 'vitest'
import { parseNotes } from './notes'
import {
noteBodyToEditorHtml,
noteBodyToPlainText,
serializeRichNoteBody,
} from './noteRichText'
describe('notes persistence', () => {
it('returns valid notes and ignores malformed entries', () => {
@@ -24,3 +29,22 @@ describe('notes persistence', () => {
expect(parseNotes('{}')).toEqual([])
})
})
describe('notes rich text', () => {
it('keeps legacy plain text notes editable without interpreting HTML', () => {
expect(noteBodyToEditorHtml('First line\n<b>not markup</b>')).toBe(
'<p>First line<br>&lt;b&gt;not markup&lt;/b&gt;</p>',
)
})
it('stores formatted notes and derives a clean preview', () => {
const body = serializeRichNoteBody(
'<h2>Briefing</h2><p><strong>Meet</strong> outside.</p><ul><li>Radio</li><li>Vest</li></ul>',
)
expect(noteBodyToEditorHtml(body)).toContain('<strong>Meet</strong>')
expect(noteBodyToPlainText(body)).toBe(
'Briefing\nMeet outside.\n• Radio\n• Vest',
)
})
})