import { NoteType } from "@triliumnext/commons"; import { useContext } from "preact/hooks"; import Component from "../../components/component"; import NoteContext from "../../components/note_context"; import FNote from "../../entities/fnote"; import { t } from "../../services/i18n"; import { downloadFileNote, openNoteExternally } from "../../services/open"; import ActionButton from "../react/ActionButton"; import { FormFileUploadActionButton } from "../react/FormFileUpload"; import { useNoteProperty } from "../react/hooks"; import { ParentComponent } from "../react/react_utils"; import { buildUploadNewFileRevisionListener } from "./FilePropertiesTab"; import { buildUploadNewImageRevisionListener } from "./ImagePropertiesTab"; interface NoteActionsCustomProps { note: FNote; ntxId: string; noteContext: NoteContext; } interface NoteActionsCustomInnerProps extends NoteActionsCustomProps { noteType: NoteType; isDefaultViewMode: boolean; parentComponent: Component; } /** * Part of {@link NoteActions} on the new layout, but are rendered with a slight spacing * from the rest of the note items and the buttons differ based on the note type. */ export default function NoteActionsCustom(props: NoteActionsCustomProps) { const noteType = useNoteProperty(props.note, "type"); const parentComponent = useContext(ParentComponent); const innerProps: NoteActionsCustomInnerProps | null | undefined = noteType && parentComponent && { ...props, noteType, isDefaultViewMode: props.noteContext.viewScope?.viewMode === "default", parentComponent }; return (innerProps &&