A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
fix: trim text extracted from html to get correct headline
thecodrrc0e78aa5c92e
diff --git a/packages/core/__tests__/notes.test.js b/packages/core/__tests__/notes.test.jsindex e6e60fa87..c84a1992c 100644--- a/packages/core/__tests__/notes.test.js+++ b/packages/core/__tests__/notes.test.js@@ -75,6 +75,18 @@ test("note should get headline from content", () =>expect(note.headline).toBe("This is a very colorful existence.");}));+test("note should get headline from content containing only lists", () =>+ noteTest({+ ...TEST_NOTE,+ content: {+ type: TEST_NOTE.content.type,+ data: `<ol style="list-style-type: decimal;" data-mce-style="list-style-type: decimal;"><li>Hello I won't be a headline :(</li><li>Me too.</li><li>Gold.</li></ol>`,+ },+ }).then(async ({ db, id }) => {+ let note = db.notes.note(id);+ expect(note.headline).toBe("Hello I won't be a headline :(Me too.Gold.");+ }));+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.jsindex 6516aba21..ca3bf5847 100644--- a/packages/core/content-types/tiny.js+++ b/packages/core/content-types/tiny.js@@ -15,9 +15,9 @@ class Tiny {}toTXT() {- if (window.DOMParser) {+ if ("DOMParser" in window || "DOMParser" in global) {let doc = new DOMParser().parseFromString(this.data, "text/html");- return (doc.body || doc.firstElementChild).textContent || "";+ return doc.body.textContent.trim();} else {return decode(this.data.replace(/<br[^>]*>/gi, "\n").replace(/<[^>]+>/g, "")