feat(markdown): basic note type integration

This commit is contained in:
Elian Doran
2026-04-17 06:20:59 +03:00
parent ec7f6a9325
commit e9d8aa82f4
4 changed files with 25 additions and 1 deletions

View File

@@ -1069,6 +1069,10 @@ export default class FNote {
return this.mime === "text/x-sqlite;schema=trilium";
}
isMarkdown() {
return this.type === "code" && (this.mime === "text/x-markdown" || this.mime === "text/x-gfm");
}
isTriliumScript() {
return this.mime.startsWith("application/javascript");
}

View File

@@ -356,6 +356,8 @@ export async function getExtendedWidgetType(note: FNote | null | undefined, note
resultingType = "readOnlyCode";
} else if (type === "text") {
resultingType = "editableText";
} else if (note.isMarkdown()) {
resultingType = "markdown";
} else if (type === "code") {
resultingType = "editableCode";
} else if (type === "launcher") {

View File

@@ -12,7 +12,7 @@ import { TypeWidgetProps } from "./type_widgets/type_widget";
* A `NoteType` altered by the note detail widget, taking into consideration whether the note is editable or not and adding special note types such as an empty one,
* for protected session or attachment information.
*/
export type ExtendedNoteType = Exclude<NoteType, "launcher" | "text" | "code" | "llmChat"> | "empty" | "readOnlyCode" | "readOnlyText" | "readOnlyOCRText" | "editableText" | "editableCode" | "attachmentDetail" | "attachmentList" | "protectedSession" | "sqlConsole" | "llmChat";
export type ExtendedNoteType = Exclude<NoteType, "launcher" | "text" | "code" | "llmChat"> | "empty" | "readOnlyCode" | "readOnlyText" | "readOnlyOCRText" | "editableText" | "editableCode" | "attachmentDetail" | "attachmentList" | "protectedSession" | "sqlConsole" | "markdown" | "llmChat";
export type TypeWidget = ((props: TypeWidgetProps) => VNode | JSX.Element | undefined);
type NoteTypeView = () => (Promise<{ default: TypeWidget } | TypeWidget> | TypeWidget);
@@ -147,6 +147,12 @@ export const TYPE_MAPPINGS: Record<ExtendedNoteType, NoteTypeMapping> = {
className: "sql-console-widget-container",
isFullHeight: true
},
markdown: {
view: () => import("./type_widgets/code/Markdown"),
className: "note-detail-markdown",
printable: true,
isFullHeight: true
},
spreadsheet: {
view: () => import("./type_widgets/spreadsheet/Spreadsheet"),
className: "note-detail-spreadsheet",

View File

@@ -0,0 +1,12 @@
import SplitEditor from "../helpers/SplitEditor";
import { TypeWidgetProps } from "../type_widget";
export default function Markdown(props: TypeWidgetProps) {
return (
<SplitEditor
noteType="code"
{...props}
previewContent={<div>Hello World</div>}
/>
);
}