mirror of
https://github.com/zadam/trilium.git
synced 2026-02-27 00:53:35 +01:00
chore(core): port note_types
This commit is contained in:
parent
de4d07e904
commit
f5535657ad
@ -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;
|
||||
|
||||
@ -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";
|
||||
|
||||
34
packages/trilium-core/src/services/note_types.ts
Normal file
34
packages/trilium-core/src/services/note_types.ts
Normal 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
|
||||
};
|
||||
@ -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";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user