import { assertEmpty } from "@blocknote/core"; import { ComponentProps, mergeRefs, useDictionary } from "@blocknote/react"; import { Avatar, Group, Skeleton, Text } from "@mantine/core"; import { useHover } from "@mantine/hooks"; import { forwardRef } from "react"; const AuthorInfo = forwardRef< HTMLDivElement, Pick< ComponentProps["Comments"]["Comment"], "authorInfo" | "timeString" | "edited" > >((props, _ref) => { const { authorInfo, timeString, edited, ...rest } = props; const dict = useDictionary(); assertEmpty(rest, false); if (authorInfo === "loading") { return (
); } return ( {authorInfo.username} {timeString} {edited && `(${dict.comments.edited})`} ); }); export const Comment = forwardRef< HTMLDivElement, ComponentProps["Comments"]["Comment"] >((props, ref) => { const { className, showActions, authorInfo: _authorInfo, timeString: _timeString, edited: _edited, actions, emojiPickerOpen, children, ...rest } = props; const { hovered, ref: hoverRef } = useHover(); const mergedRef = mergeRefs([ref, hoverRef]); assertEmpty(rest, false); const doShowActions = actions && (showActions === true || showActions === undefined || (showActions === "hover" && hovered) || emojiPickerOpen); return ( {doShowActions ? ( {actions} ) : null} {children} ); });