mirror of
https://github.com/zadam/trilium.git
synced 2025-12-23 07:44:24 +01:00
fix(note_info): fixed note types do not have icon
This commit is contained in:
parent
a5fcee500e
commit
2eaa4ef206
@ -1,17 +1,17 @@
|
|||||||
import server from "../services/server.js";
|
|
||||||
import noteAttributeCache from "../services/note_attribute_cache.js";
|
|
||||||
import protectedSessionHolder from "../services/protected_session_holder.js";
|
|
||||||
import cssClassManager from "../services/css_class_manager.js";
|
import cssClassManager from "../services/css_class_manager.js";
|
||||||
import type { Froca } from "../services/froca-interface.js";
|
import type { Froca } from "../services/froca-interface.js";
|
||||||
import type FAttachment from "./fattachment.js";
|
import noteAttributeCache from "../services/note_attribute_cache.js";
|
||||||
import type { default as FAttribute, AttributeType } from "./fattribute.js";
|
import protectedSessionHolder from "../services/protected_session_holder.js";
|
||||||
import utils from "../services/utils.js";
|
|
||||||
import search from "../services/search.js";
|
import search from "../services/search.js";
|
||||||
|
import server from "../services/server.js";
|
||||||
|
import utils from "../services/utils.js";
|
||||||
|
import type FAttachment from "./fattachment.js";
|
||||||
|
import type { AttributeType,default as FAttribute } from "./fattribute.js";
|
||||||
|
|
||||||
const LABEL = "label";
|
const LABEL = "label";
|
||||||
const RELATION = "relation";
|
const RELATION = "relation";
|
||||||
|
|
||||||
const NOTE_TYPE_ICONS = {
|
export const NOTE_TYPE_ICONS = {
|
||||||
file: "bx bx-file",
|
file: "bx bx-file",
|
||||||
image: "bx bx-image",
|
image: "bx bx-image",
|
||||||
code: "bx bx-code",
|
code: "bx bx-code",
|
||||||
@ -268,13 +268,13 @@ export default class FNote {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
} else {
|
|
||||||
return this.children;
|
|
||||||
}
|
}
|
||||||
|
return this.children;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getSubtreeNoteIds(includeArchived = false) {
|
async getSubtreeNoteIds(includeArchived = false) {
|
||||||
let noteIds: (string | string[])[] = [];
|
const noteIds: (string | string[])[] = [];
|
||||||
for (const child of await this.getChildNotes()) {
|
for (const child of await this.getChildNotes()) {
|
||||||
if (child.isArchived && !includeArchived) continue;
|
if (child.isArchived && !includeArchived) continue;
|
||||||
|
|
||||||
@ -471,9 +471,9 @@ export default class FNote {
|
|||||||
return a.isHidden ? 1 : -1;
|
return a.isHidden ? 1 : -1;
|
||||||
} else if (a.isSearch !== b.isSearch) {
|
} else if (a.isSearch !== b.isSearch) {
|
||||||
return a.isSearch ? 1 : -1;
|
return a.isSearch ? 1 : -1;
|
||||||
} else {
|
|
||||||
return a.notePath.length - b.notePath.length;
|
|
||||||
}
|
}
|
||||||
|
return a.notePath.length - b.notePath.length;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return notePaths;
|
return notePaths;
|
||||||
@ -597,14 +597,14 @@ export default class FNote {
|
|||||||
} else if (this.type === "text") {
|
} else if (this.type === "text") {
|
||||||
if (this.isFolder()) {
|
if (this.isFolder()) {
|
||||||
return "bx bx-folder";
|
return "bx bx-folder";
|
||||||
} else {
|
|
||||||
return "bx bx-note";
|
|
||||||
}
|
}
|
||||||
|
return "bx bx-note";
|
||||||
|
|
||||||
} else if (this.type === "code" && this.mime.startsWith("text/x-sql")) {
|
} else if (this.type === "code" && this.mime.startsWith("text/x-sql")) {
|
||||||
return "bx bx-data";
|
return "bx bx-data";
|
||||||
} else {
|
|
||||||
return NOTE_TYPE_ICONS[this.type];
|
|
||||||
}
|
}
|
||||||
|
return NOTE_TYPE_ICONS[this.type];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getColorClass() {
|
getColorClass() {
|
||||||
@ -617,7 +617,7 @@ export default class FNote {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getFilteredChildBranches() {
|
getFilteredChildBranches() {
|
||||||
let childBranches = this.getChildBranches();
|
const childBranches = this.getChildBranches();
|
||||||
|
|
||||||
if (!childBranches) {
|
if (!childBranches) {
|
||||||
console.error(`No children for '${this.noteId}'. This shouldn't happen.`);
|
console.error(`No children for '${this.noteId}'. This shouldn't happen.`);
|
||||||
@ -811,9 +811,9 @@ export default class FNote {
|
|||||||
return this.getLabelValue(nameWithPrefix.substring(1));
|
return this.getLabelValue(nameWithPrefix.substring(1));
|
||||||
} else if (nameWithPrefix.startsWith("~")) {
|
} else if (nameWithPrefix.startsWith("~")) {
|
||||||
return this.getRelationValue(nameWithPrefix.substring(1));
|
return this.getRelationValue(nameWithPrefix.substring(1));
|
||||||
} else {
|
|
||||||
return this.getLabelValue(nameWithPrefix);
|
|
||||||
}
|
}
|
||||||
|
return this.getLabelValue(nameWithPrefix);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -878,10 +878,10 @@ export default class FNote {
|
|||||||
promotedAttrs.sort((a, b) => {
|
promotedAttrs.sort((a, b) => {
|
||||||
if (a.noteId === b.noteId) {
|
if (a.noteId === b.noteId) {
|
||||||
return a.position < b.position ? -1 : 1;
|
return a.position < b.position ? -1 : 1;
|
||||||
} else {
|
|
||||||
// inherited promoted attributes should stay grouped: https://github.com/zadam/trilium/issues/3761
|
|
||||||
return a.noteId < b.noteId ? -1 : 1;
|
|
||||||
}
|
}
|
||||||
|
// inherited promoted attributes should stay grouped: https://github.com/zadam/trilium/issues/3761
|
||||||
|
return a.noteId < b.noteId ? -1 : 1;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return promotedAttrs;
|
return promotedAttrs;
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import { useContext, useEffect, useMemo, useRef, useState } from "preact/hooks";
|
|||||||
|
|
||||||
import { CommandNames } from "../../components/app_context";
|
import { CommandNames } from "../../components/app_context";
|
||||||
import NoteContext from "../../components/note_context";
|
import NoteContext from "../../components/note_context";
|
||||||
import FNote from "../../entities/fnote";
|
import FNote, { NOTE_TYPE_ICONS } from "../../entities/fnote";
|
||||||
import attributes from "../../services/attributes";
|
import attributes from "../../services/attributes";
|
||||||
import { t } from "../../services/i18n";
|
import { t } from "../../services/i18n";
|
||||||
import { ViewScope } from "../../services/link";
|
import { ViewScope } from "../../services/link";
|
||||||
@ -220,10 +220,10 @@ export function NoteInfoBadge({ note, setSimilarNotesShown }: NoteInfoContext) {
|
|||||||
const dropdownRef = useRef<BootstrapDropdown>(null);
|
const dropdownRef = useRef<BootstrapDropdown>(null);
|
||||||
const { metadata, ...sizeProps } = useNoteMetadata(note);
|
const { metadata, ...sizeProps } = useNoteMetadata(note);
|
||||||
const [ originalFileName ] = useNoteLabel(note, "originalFileName");
|
const [ originalFileName ] = useNoteLabel(note, "originalFileName");
|
||||||
const currentNoteType = useNoteProperty(note, "type");
|
const noteType = useNoteProperty(note, "type");
|
||||||
const currentNoteTypeData = useMemo(() => NOTE_TYPES.find(t => t.type === currentNoteType), [ currentNoteType ]);
|
const noteTypeMapping = useMemo(() => NOTE_TYPES.find(t => t.type === noteType), [ noteType ]);
|
||||||
|
|
||||||
return (note && currentNoteTypeData &&
|
return (note && noteType && noteTypeMapping &&
|
||||||
<StatusBarDropdown
|
<StatusBarDropdown
|
||||||
icon="bx bx-info-circle"
|
icon="bx bx-info-circle"
|
||||||
title={t("status_bar.note_info_title")}
|
title={t("status_bar.note_info_title")}
|
||||||
@ -235,7 +235,7 @@ export function NoteInfoBadge({ note, setSimilarNotesShown }: NoteInfoContext) {
|
|||||||
{originalFileName && <NoteInfoValue text={t("file_properties.original_file_name")} value={originalFileName} />}
|
{originalFileName && <NoteInfoValue text={t("file_properties.original_file_name")} value={originalFileName} />}
|
||||||
<NoteInfoValue text={t("note_info_widget.created")} value={formatDateTime(metadata?.dateCreated)} />
|
<NoteInfoValue text={t("note_info_widget.created")} value={formatDateTime(metadata?.dateCreated)} />
|
||||||
<NoteInfoValue text={t("note_info_widget.modified")} value={formatDateTime(metadata?.dateModified)} />
|
<NoteInfoValue text={t("note_info_widget.modified")} value={formatDateTime(metadata?.dateModified)} />
|
||||||
<NoteInfoValue text={t("note_info_widget.type")} value={<><Icon icon={`bx ${currentNoteTypeData.icon}`}/>{" "}{currentNoteTypeData?.title}</>} />
|
<NoteInfoValue text={t("note_info_widget.type")} value={<><Icon icon={`bx ${noteTypeMapping.icon ?? NOTE_TYPE_ICONS[noteType]}`}/>{" "}{noteTypeMapping?.title}</>} />
|
||||||
{note.mime && <NoteInfoValue text={t("note_info_widget.mime")} value={note.mime} />}
|
{note.mime && <NoteInfoValue text={t("note_info_widget.mime")} value={note.mime} />}
|
||||||
<NoteInfoValue text={t("note_info_widget.note_id")} value={<code>{note.noteId}</code>} />
|
<NoteInfoValue text={t("note_info_widget.note_id")} value={<code>{note.noteId}</code>} />
|
||||||
<NoteInfoValue text={t("note_info_widget.note_size")} title={t("note_info_widget.note_size_info")} value={<NoteSizeWidget {...sizeProps} />} />
|
<NoteInfoValue text={t("note_info_widget.note_size")} title={t("note_info_widget.note_size_info")} value={<NoteSizeWidget {...sizeProps} />} />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user