'use client'; import React from 'react'; import { cn } from '@udecode/cn'; import { type TCommentText, getCommentCount } from '@udecode/plate-comments'; import { type PlateLeafProps, PlateLeaf, useEditorPlugin, usePluginOption, } from '@udecode/plate/react'; import { commentsPlugin } from '@plone/plate/components/editor/plugins/comments-plugin'; export function CommentLeaf({ className, ...props }: PlateLeafProps) { const { children, leaf, nodeProps } = props; const { api, setOption } = useEditorPlugin(commentsPlugin); const hoverId = usePluginOption(commentsPlugin, 'hoverId'); const activeId = usePluginOption(commentsPlugin, 'activeId'); const isOverlapping = getCommentCount(leaf) > 1; const currentId = api.comment.nodeId(leaf); const isActive = activeId === currentId; const isHover = hoverId === currentId; return ( setOption('activeId', currentId ?? null)} onMouseEnter={() => setOption('hoverId', currentId ?? null)} onMouseLeave={() => setOption('hoverId', null)} nodeProps={{ ...nodeProps, }} > {children} ); }