diff --git a/packages/core/__tests__/notes.test.js b/packages/core/__tests__/notes.test.js index b3b1c1183..68edb7f8e 100644 --- a/packages/core/__tests__/notes.test.js +++ b/packages/core/__tests__/notes.test.js @@ -63,6 +63,18 @@ test("note without a title should get title from content", () => expect(note.title).toBe("HelloThis is colorful"); })); +test("note should get headline from content", () => + noteTest({ + ...TEST_NOTE, + content: { + type: TEST_NOTE.content.type, + data: "

This is a very colorful existence.

", + }, + }).then(async ({ db, id }) => { + let note = db.notes.note(id); + expect(note.headline).toBe("This is a very colorful existence."); + })); + test("note title should allow trailing space", () => noteTest({ title: "Hello ", content: TEST_NOTE.content }).then( async ({ db, id }) => { diff --git a/packages/core/content-types/tiny.js b/packages/core/content-types/tiny.js index cb77dfbb4..6e2ca52c8 100644 --- a/packages/core/content-types/tiny.js +++ b/packages/core/content-types/tiny.js @@ -61,13 +61,15 @@ export default Tiny; function getHeadlineFromText(text) { for (var i = 0; i < text.length; ++i) { const char = text[i]; + const nextChar = text[i + 1]; if ( char === "\n" || char === "\t" || char === "\r" || - char === "." || + (char === "." && nextChar === " ") || i >= 120 ) { + if (char === ".") ++i; return text.substring(0, i); } }