mirror of
https://github.com/zadam/trilium.git
synced 2026-05-06 23:56:55 +02:00
feat(markdown): basic note type integration
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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") {
|
||||
|
||||
@@ -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",
|
||||
|
||||
12
apps/client/src/widgets/type_widgets/code/Markdown.tsx
Normal file
12
apps/client/src/widgets/type_widgets/code/Markdown.tsx
Normal 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>}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user