Skip to content

Build your personal knowledge base with Trilium Notes

chore(core): port note_types

Elian Doranf5535657ad5d
diff --git a/apps/server/src/services/note_types.ts b/apps/server/src/services/note_types.ts
index 2aa86d0b64..ce31085123 100644
--- a/apps/server/src/services/note_types.ts
+++ b/apps/server/src/services/note_types.ts
@@ -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;
diff --git a/packages/trilium-core/src/index.ts b/packages/trilium-core/src/index.ts
index 3220233faa..c478cac62a 100644
--- a/packages/trilium-core/src/index.ts
+++ b/packages/trilium-core/src/index.ts
@@ -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";
diff --git a/packages/trilium-core/src/services/note_types.ts b/packages/trilium-core/src/services/note_types.ts
new file mode 100644
index 0000000000..2aa86d0b64
--- /dev/null
+++ b/packages/trilium-core/src/services/note_types.ts
@@ -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
+};
diff --git a/packages/trilium-core/src/services/notes.ts b/packages/trilium-core/src/services/notes.ts
index 39cb59be91..7fe87b681c 100644
--- a/packages/trilium-core/src/services/notes.ts
+++ b/packages/trilium-core/src/services/notes.ts
@@ -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";