import { PLAIN_EDITOR_NAME } from '@/Constants/Constants' import { sanitizeHtmlString, SNNote } from '@standardnotes/snjs' import { observer } from 'mobx-react-lite' import { FunctionComponent } from 'react' import Icon from '@/Components/Icon/Icon' import ListItemConflictIndicator from './ListItemConflictIndicator' import ListItemFlagIcons from './ListItemFlagIcons' import ListItemTags from './ListItemTags' import ListItemMetadata from './ListItemMetadata' import { DisplayableListItemProps } from './Types/DisplayableListItemProps' const NoteListItem: FunctionComponent = ({ application, notesController, selectionController, hideDate, hideIcon, hideTags, hidePreview, item, selected, sortBy, tags, }) => { const editorForNote = application.componentManager.editorForNote(item as SNNote) const editorName = editorForNote?.name ?? PLAIN_EDITOR_NAME const [icon, tint] = application.iconsController.getIconAndTintForNoteType(editorForNote?.package_info.note_type) const hasFiles = application.items.getFilesForNote(item as SNNote).length > 0 const openNoteContextMenu = (posX: number, posY: number) => { notesController.setContextMenuClickLocation({ x: posX, y: posY, }) notesController.reloadContextMenuLayout() notesController.setContextMenuOpen(true) } const openContextMenu = async (posX: number, posY: number) => { const { didSelect } = await selectionController.selectItem(item.uuid, true) if (didSelect) { openNoteContextMenu(posX, posY) } } return (
{ void selectionController.selectItem(item.uuid, true) }} onContextMenu={(event) => { event.preventDefault() void openContextMenu(event.clientX, event.clientY) }} > {!hideIcon ? (
) : (
)}
{item.title}
{!hidePreview && !item.hidePreview && !item.protected && (
{item.preview_html && (
)} {!item.preview_html && item.preview_plain && (
{item.preview_plain}
)} {!item.preview_html && !item.preview_plain && item.text && (
{item.text}
)}
)}
) } export default observer(NoteListItem)