mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 10:22:29 +08:00
feat(import/single): support UTF-16 LE with BOM for text notes
This commit is contained in:
parent
cadd78524c
commit
77ee7f96c1
BIN
src/services/import/samples/UTF-16LE Text Note.txt
Normal file
BIN
src/services/import/samples/UTF-16LE Text Note.txt
Normal file
Binary file not shown.
@ -66,4 +66,10 @@ describe("processNoteContent", () => {
|
||||
expect(importedNote.mime).toBe("application/json");
|
||||
expect(importedNote.getContent().toString()).toStrictEqual(stripBom(buffer.toString("utf-16le")));
|
||||
});
|
||||
|
||||
it("supports plain text note with UTF-16", async () => {
|
||||
const { importedNote } = await testImport("UTF-16LE Text Note.txt", "text/plain");
|
||||
expect(importedNote.mime).toBe("text/html");
|
||||
expect(importedNote.getContent().toString()).toBe("<p>Plain text goes here.<br></p>");
|
||||
});
|
||||
})
|
||||
|
@ -91,7 +91,7 @@ function importCodeNote(taskContext: TaskContext, file: File, parentNote: BNote)
|
||||
|
||||
function importPlainText(taskContext: TaskContext, file: File, parentNote: BNote) {
|
||||
const title = getNoteTitle(file.originalname, !!taskContext.data?.replaceUnderscoresWithSpaces);
|
||||
const plainTextContent = file.buffer.toString("utf-8");
|
||||
const plainTextContent = processStringOrBuffer(file.buffer);
|
||||
const htmlContent = convertTextToHtml(plainTextContent);
|
||||
|
||||
const { note } = noteService.createNewNote({
|
||||
|
Loading…
x
Reference in New Issue
Block a user