feat(notes): rich-text editor with tiptap (task 85)
Replace plain textarea with shared tiptap editor and sanitized html rendering. Adds interactive checklists on read surfaces and mobile overflow fixes.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { describe, it } from "node:test";
|
||||
import { normalizeNoteBody } from "../../src/components/rich-text/normalize-body";
|
||||
import { sanitizeRichTextHtml } from "../../src/components/rich-text/sanitize";
|
||||
import { toggleTaskItemInHtml } from "../../src/components/rich-text/toggle-checklist";
|
||||
|
||||
describe("normalizeNoteBody", () => {
|
||||
it("wraps plain text paragraphs in HTML", () => {
|
||||
const html = normalizeNoteBody("Hello\n\nWorld");
|
||||
assert.match(html, /<p>Hello<\/p>/);
|
||||
assert.match(html, /<p>World<\/p>/);
|
||||
});
|
||||
|
||||
it("preserves existing HTML", () => {
|
||||
const input = "<p><strong>Bold</strong></p>";
|
||||
assert.equal(normalizeNoteBody(input), input);
|
||||
});
|
||||
});
|
||||
|
||||
describe("sanitizeRichTextHtml", () => {
|
||||
it("strips script tags", () => {
|
||||
const safe = sanitizeRichTextHtml('<p>Hi</p><script>alert("x")</script>');
|
||||
assert.doesNotMatch(safe, /<script/i);
|
||||
assert.match(safe, /Hi/);
|
||||
});
|
||||
});
|
||||
|
||||
describe("toggleTaskItemInHtml", () => {
|
||||
it("flips the requested checklist item", () => {
|
||||
const html =
|
||||
'<ul data-type="taskList"><li data-type="taskItem" data-checked="false"><p>One</p></li><li data-type="taskItem" data-checked="false"><p>Two</p></li></ul>';
|
||||
const next = toggleTaskItemInHtml(html, 1, true);
|
||||
assert.match(next, /data-checked="false"/);
|
||||
assert.match(next, /data-checked="true"/);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user