mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 19:05:59 +01:00
chore(react/ribbon): add note types
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import { useCallback, useMemo } from "preact/hooks";
|
||||
import Dropdown from "../react/Dropdown";
|
||||
import { NOTE_TYPES } from "../../services/note_types";
|
||||
import { FormListBadge, FormListItem } from "../react/FormList";
|
||||
import { FormDivider, FormListBadge, FormListItem } from "../react/FormList";
|
||||
import { t } from "../../services/i18n";
|
||||
import { useTriliumOption } from "../react/hooks";
|
||||
import mime_types from "../../services/mime_types";
|
||||
|
||||
export default function BasicPropertiesTab() {
|
||||
return (
|
||||
@@ -14,9 +16,11 @@ export default function BasicPropertiesTab() {
|
||||
|
||||
function NoteTypeWidget() {
|
||||
const noteTypes = useMemo(() => NOTE_TYPES.filter((nt) => !nt.reserved && !nt.static), []);
|
||||
const [ codeNotesMimeTypes ] = useTriliumOption("codeNotesMimeTypes");
|
||||
const mimeTypes = useMemo(() => mime_types.getMimeTypes().filter(mimeType => mimeType.enabled), [ codeNotesMimeTypes ]);
|
||||
|
||||
return (
|
||||
<Dropdown>
|
||||
<Dropdown dropdownContainerClassName="note-type-dropdown">
|
||||
{noteTypes.map(noteType => {
|
||||
const badges: FormListBadge[] = [];
|
||||
if (noteType.isNew) {
|
||||
@@ -31,12 +35,27 @@ function NoteTypeWidget() {
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<FormListItem
|
||||
badges={badges}
|
||||
>{noteType.title}</FormListItem>
|
||||
);
|
||||
if (noteType.type !== "code") {
|
||||
return (
|
||||
<FormListItem
|
||||
badges={badges}
|
||||
>{noteType.title}</FormListItem>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<>
|
||||
<FormDivider />
|
||||
<FormListItem disabled>
|
||||
<strong>{noteType.title}</strong>
|
||||
</FormListItem>
|
||||
</>
|
||||
)
|
||||
}
|
||||
})}
|
||||
|
||||
{mimeTypes.map(mimeType => (
|
||||
<FormListItem>{mimeType.title}</FormListItem>
|
||||
))}
|
||||
</Dropdown>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user