mirror of https://github.com/TriliumNext/Notes
Merge remote-tracking branch 'origin/develop' into feature/task_list
commit
0e5b8af3a4
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,21 @@
|
|||||||
|
Page 1
|
||||||
|
|
||||||
|
Heading 1
|
||||||
|
---------
|
||||||
|
|
||||||
|
Heading 2
|
||||||
|
---------
|
||||||
|
|
||||||
|
### Heading 3
|
||||||
|
|
||||||
|
```
|
||||||
|
class Foo {
|
||||||
|
hoistedNoteChangedEvent({ ntxId }) {
|
||||||
|
if (this.isNoteContext(ntxId)) {
|
||||||
|
this.refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Page 2
|
||||||
Binary file not shown.
@ -0,0 +1,49 @@
|
|||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
import fs from "fs";
|
||||||
|
import path from "path";
|
||||||
|
import { fileURLToPath } from "url";
|
||||||
|
import { dirname } from "path";
|
||||||
|
import becca from "../../becca/becca.js";
|
||||||
|
import BNote from "../../becca/entities/bnote.js";
|
||||||
|
import TaskContext from "../task_context.js";
|
||||||
|
import cls from "../cls.js";
|
||||||
|
import sql_init from "../sql_init.js";
|
||||||
|
import { initializeTranslations } from "../i18n.js";
|
||||||
|
import single from "./single.js";
|
||||||
|
const scriptDir = dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
|
describe("processNoteContent", () => {
|
||||||
|
it("treats single MDX as Markdown", async () => {
|
||||||
|
const mdxSample = fs.readFileSync(path.join(scriptDir, "samples", "Text Note.mdx"));
|
||||||
|
const taskContext = TaskContext.getInstance("import-mdx", "import", {
|
||||||
|
textImportedAsText: true
|
||||||
|
});
|
||||||
|
|
||||||
|
await new Promise<void>((resolve, reject) => {
|
||||||
|
cls.init(async () => {
|
||||||
|
initializeTranslations();
|
||||||
|
sql_init.initializeDb();
|
||||||
|
await sql_init.dbReady;
|
||||||
|
|
||||||
|
const rootNote = becca.getNote("root");
|
||||||
|
if (!rootNote) {
|
||||||
|
reject("Missing root note.");
|
||||||
|
}
|
||||||
|
|
||||||
|
const importedNote = single.importSingleFile(taskContext, {
|
||||||
|
originalname: "Text Note.mdx",
|
||||||
|
mimetype: "text/mdx",
|
||||||
|
buffer: mdxSample
|
||||||
|
}, rootNote as BNote);
|
||||||
|
try {
|
||||||
|
expect(importedNote.mime).toBe("text/html");
|
||||||
|
expect(importedNote.type).toBe("text");
|
||||||
|
expect(importedNote.title).toBe("Text Note");
|
||||||
|
} catch (e) {
|
||||||
|
reject(e);
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
import fs from "fs";
|
||||||
|
import path from "path";
|
||||||
|
import { fileURLToPath } from "url";
|
||||||
|
import { dirname } from "path";
|
||||||
|
import zip from "./zip.js";
|
||||||
|
import becca from "../../becca/becca.js";
|
||||||
|
import BNote from "../../becca/entities/bnote.js";
|
||||||
|
import TaskContext from "../task_context.js";
|
||||||
|
import cls from "../cls.js";
|
||||||
|
import sql_init from "../sql_init.js";
|
||||||
|
import { initializeTranslations } from "../i18n.js";
|
||||||
|
const scriptDir = dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
|
describe("processNoteContent", () => {
|
||||||
|
it("treats single MDX as Markdown in ZIP as text note", async () => {
|
||||||
|
const mdxSample = fs.readFileSync(path.join(scriptDir, "samples", "mdx.zip"));
|
||||||
|
const taskContext = TaskContext.getInstance("import-mdx", "import", {
|
||||||
|
textImportedAsText: true
|
||||||
|
});
|
||||||
|
|
||||||
|
await new Promise<void>((resolve, reject) => {
|
||||||
|
cls.init(async () => {
|
||||||
|
initializeTranslations();
|
||||||
|
sql_init.initializeDb();
|
||||||
|
await sql_init.dbReady;
|
||||||
|
|
||||||
|
const rootNote = becca.getNote("root");
|
||||||
|
if (!rootNote) {
|
||||||
|
expect(rootNote).toBeTruthy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const importedNote = await zip.importZip(taskContext, mdxSample, rootNote as BNote);
|
||||||
|
try {
|
||||||
|
expect(importedNote.mime).toBe("text/mdx");
|
||||||
|
expect(importedNote.type).toBe("text");
|
||||||
|
expect(importedNote.title).toBe("Text Note");
|
||||||
|
} catch (e) {
|
||||||
|
reject(e);
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
Loading…
Reference in New Issue