Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(markdown): integrate into note types
Elian Doranf03e527cb0fc
diff --git a/apps/client/src/menus/context_menu.ts b/apps/client/src/menus/context_menu.tsindex 415c0a2c6a..130b4cfd52 100644--- a/apps/client/src/menus/context_menu.ts+++ b/apps/client/src/menus/context_menu.ts@@ -39,6 +39,7 @@ export interface MenuCommandItem<T> {title: string;command?: T;type?: string;+ mime?: string;/*** The icon to display in the menu item.*diff --git a/apps/client/src/menus/tree_context_menu.ts b/apps/client/src/menus/tree_context_menu.tsindex 8dca18d905..7fc1a8b008 100644--- a/apps/client/src/menus/tree_context_menu.ts+++ b/apps/client/src/menus/tree_context_menu.ts@@ -288,7 +288,7 @@ export default class TreeContextMenu implements SelectMenuItemEventListener<Treereturn items.filter((row) => row !== null) as MenuItem<TreeCommandNames>[];}- async selectMenuItemHandler({ command, type, templateNoteId }: MenuCommandItem<TreeCommandNames>) {+ async selectMenuItemHandler({ command, type, mime, templateNoteId }: MenuCommandItem<TreeCommandNames>) {const notePath = treeService.getNotePath(this.node);if (utils.isMobile()) {@@ -305,6 +305,7 @@ export default class TreeContextMenu implements SelectMenuItemEventListener<Treetarget: "after",targetBranchId: this.node.data.branchId,type,+ mime,isProtected,templateNoteId});@@ -313,6 +314,7 @@ export default class TreeContextMenu implements SelectMenuItemEventListener<TreenoteCreateService.createNote(parentNotePath, {type,+ mime,isProtected: this.node.data.isProtected,templateNoteId});diff --git a/apps/client/src/services/note_types.ts b/apps/client/src/services/note_types.tsindex c99f04ae81..cefd863ca8 100644--- a/apps/client/src/services/note_types.ts+++ b/apps/client/src/services/note_types.ts@@ -49,6 +49,7 @@ export const NOTE_TYPES: NoteTypeMapping[] = [// Code notes{ type: "code", mime: "text/plain", title: t("note_types.code"), icon: "bx-code" },+ { type: "code", mime: "text/x-markdown", title: t("note_types.markdown"), icon: "bxl-markdown" },// Reserved types (cannot be created by the user){ type: "contentWidget", mime: "", title: t("note_types.widget"), reserved: true },@@ -100,6 +101,7 @@ function getBlankNoteTypes(command?: TreeCommandNames): MenuItem<TreeCommandNametitle: nt.title,command,type: nt.type,+ mime: nt.mime,uiIcon: `bx ${nt.icon}`,badges: []};diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 2efdf6b542..f498dc856f 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -1671,6 +1671,7 @@"note_types": {"text": "Text","code": "Code",+ "markdown": "Markdown","saved-search": "Saved Search","relation-map": "Relation Map","note-map": "Note Map",diff --git a/apps/client/src/widgets/FloatingButtonsDefinitions.tsx b/apps/client/src/widgets/FloatingButtonsDefinitions.tsxindex 5d19389cf1..32d3cfd3fa 100644--- a/apps/client/src/widgets/FloatingButtonsDefinitions.tsx+++ b/apps/client/src/widgets/FloatingButtonsDefinitions.tsx@@ -94,7 +94,7 @@ function SwitchSplitOrientationButton({ note, isReadOnly, isDefaultViewMode }: Ffunction ToggleReadOnlyButton({ note, isDefaultViewMode }: FloatingButtonContext) {const [ isReadOnly, setReadOnly ] = useNoteLabelBoolean(note, "readOnly");const isSavedSqlite = note.isTriliumSqlite() && !note.isHiddenCompletely();- const isEnabled = ([ "mermaid", "mindMap", "canvas" ].includes(note.type) || isSavedSqlite)+ const isEnabled = ([ "mermaid", "mindMap", "canvas" ].includes(note.type) || isSavedSqlite || note.isMarkdown())&& note.isContentAvailable() && isDefaultViewMode;return isEnabled && <FloatingButtondiff --git a/apps/client/src/widgets/NoteDetail.tsx b/apps/client/src/widgets/NoteDetail.tsxindex 826cffa0e9..180ca12ba6 100644--- a/apps/client/src/widgets/NoteDetail.tsx+++ b/apps/client/src/widgets/NoteDetail.tsx@@ -352,12 +352,12 @@ export async function getExtendedWidgetType(note: FNote | null | undefined, noteresultingType = "readOnlyText";} else if (note.isTriliumSqlite()) {resultingType = "sqlConsole";+ } else if (note.isMarkdown()) {+ resultingType = "markdown";} else if ((type === "code" || type === "mermaid") && (await noteContext?.isReadOnly())) {resultingType = "readOnlyCode";} else if (type === "text") {resultingType = "editableText";- } else if (note.isMarkdown()) {- resultingType = "markdown";} else if (type === "code") {resultingType = "editableCode";} else if (type === "launcher") {