chore(core): port note_types

This commit is contained in:
Elian Doran 2026-01-06 15:16:42 +02:00
parent de4d07e904
commit f5535657ad
No known key found for this signature in database
4 changed files with 37 additions and 35 deletions

View File

@ -1,34 +1,2 @@
const noteTypes = [
{ type: "text", defaultMime: "text/html" },
{ type: "code", defaultMime: "text/plain" },
{ type: "render", defaultMime: "" },
{ type: "file", defaultMime: "application/octet-stream" },
{ type: "image", defaultMime: "" },
{ type: "search", defaultMime: "" },
{ type: "relationMap", defaultMime: "application/json" },
{ type: "book", defaultMime: "" },
{ type: "noteMap", defaultMime: "" },
{ type: "mermaid", defaultMime: "text/vnd.mermaid" },
{ type: "canvas", defaultMime: "application/json" },
{ type: "webView", defaultMime: "" },
{ type: "launcher", defaultMime: "" },
{ type: "doc", defaultMime: "" },
{ type: "contentWidget", defaultMime: "" },
{ type: "mindMap", defaultMime: "application/json" },
{ type: "aiChat", defaultMime: "application/json" }
];
function getDefaultMimeForNoteType(typeName: string) {
const typeRec = noteTypes.find((nt) => nt.type === typeName);
if (!typeRec) {
throw new Error(`Cannot find note type '${typeName}'`);
}
return typeRec.defaultMime;
}
export default {
getNoteTypeNames: () => noteTypes.map((nt) => nt.type),
getDefaultMimeForNoteType
};
import { note_types } from "@triliumnext/core";
export default note_types;

View File

@ -24,6 +24,7 @@ export * as cls from "./services/context";
export * from "./errors";
export { default as getInstanceId } from "./services/instance_id";
export type { CryptoProvider } from "./services/encryption/crypto";
export { default as note_types } from "./services/note_types";
export { default as becca } from "./becca/becca";
export { default as becca_loader } from "./becca/becca_loader";

View File

@ -0,0 +1,34 @@
const noteTypes = [
{ type: "text", defaultMime: "text/html" },
{ type: "code", defaultMime: "text/plain" },
{ type: "render", defaultMime: "" },
{ type: "file", defaultMime: "application/octet-stream" },
{ type: "image", defaultMime: "" },
{ type: "search", defaultMime: "" },
{ type: "relationMap", defaultMime: "application/json" },
{ type: "book", defaultMime: "" },
{ type: "noteMap", defaultMime: "" },
{ type: "mermaid", defaultMime: "text/vnd.mermaid" },
{ type: "canvas", defaultMime: "application/json" },
{ type: "webView", defaultMime: "" },
{ type: "launcher", defaultMime: "" },
{ type: "doc", defaultMime: "" },
{ type: "contentWidget", defaultMime: "" },
{ type: "mindMap", defaultMime: "application/json" },
{ type: "aiChat", defaultMime: "application/json" }
];
function getDefaultMimeForNoteType(typeName: string) {
const typeRec = noteTypes.find((nt) => nt.type === typeName);
if (!typeRec) {
throw new Error(`Cannot find note type '${typeName}'`);
}
return typeRec.defaultMime;
}
export default {
getNoteTypeNames: () => noteTypes.map((nt) => nt.type),
getDefaultMimeForNoteType
};

View File

@ -19,7 +19,6 @@ import entityChangesService from "./entity_changes.js";
import htmlSanitizer from "./html_sanitizer.js";
import imageService from "./image.js";
import noteTypesService from "./note_types.js";
import type { NoteParams } from "./note-interface.js";
import optionService from "./options.js";
import request from "./request.js";
import revisionService from "./revisions.js";