import "./NoteTitleActions.css"; import { useEffect, useState } from "preact/hooks"; import NoteContext from "../../components/note_context"; import FNote from "../../entities/fnote"; import { t } from "../../services/i18n"; import { checkFullHeight, getExtendedWidgetType } from "../NoteDetail"; import { PromotedAttributesContent, usePromotedAttributeData } from "../PromotedAttributes"; import Collapsible, { ExternallyControlledCollapsible } from "../react/Collapsible"; import { useNoteContext, useNoteLabel, useNoteProperty, useTriliumEvent, useTriliumOptionBool } from "../react/hooks"; import { NewNoteLink } from "../react/NoteLink"; import { useEditedNotes } from "../ribbon/EditedNotesTab"; import SearchDefinitionTab from "../ribbon/SearchDefinitionTab"; import NoteTypeSwitcher from "./NoteTypeSwitcher"; export default function NoteTitleActions() { const { note, ntxId, componentId, noteContext, viewScope } = useNoteContext(); const noteType = useNoteProperty(note, "type"); return (
{noteType === "search" && } {(!viewScope?.viewMode || viewScope.viewMode === "default") && }
); } function SearchProperties({ note, ntxId }: { note: FNote | null | undefined, ntxId: string | null | undefined }) { return (note && ); } function PromotedAttributes({ note, componentId, noteContext }: { note: FNote | null | undefined, componentId: string, noteContext: NoteContext | undefined }) { const [ cells, setCells ] = usePromotedAttributeData(note, componentId, noteContext); const [ expanded, setExpanded ] = useState(false); useEffect(() => { getExtendedWidgetType(note, noteContext).then(extendedNoteType => { const fullHeight = checkFullHeight(noteContext, extendedNoteType); setExpanded(!fullHeight); }); }, [ note, noteContext ]); // Keyboard shortcut. useTriliumEvent("toggleRibbonTabPromotedAttributes", () => setExpanded(!expanded)); if (!cells?.length) return false; return (note && ( )); } //#region Edited Notes function EditedNotes() { const { note } = useNoteContext(); const [ dateNote ] = useNoteLabel(note, "dateNote"); const [ editedNotesOpenInRibbon ] = useTriliumOptionBool("editedNotesOpenInRibbon"); return (note && dateNote && ); } function EditedNotesContent({ note }: { note: FNote }) { const editedNotes = useEditedNotes(note); return (editedNotes !== undefined && (editedNotes.length > 0 ? editedNotes?.map(editedNote => ( )) : (
{t("edited_notes.no_edited_notes_found")}
))); } //#endregion