'use client'; import React from 'react'; import type { TMentionElement } from '@udecode/plate-mention'; import { cn, withRef } from '@udecode/cn'; import { getHandler, IS_APPLE } from '@udecode/plate'; import { PlateElement, useFocused, useReadOnly, useSelected, } from '@udecode/plate/react'; import { useMounted } from '@plone/plate/hooks/use-mounted'; export const MentionElement = withRef< typeof PlateElement, { prefix?: string; onClick?: (mentionNode: any) => void; } >(({ children, className, prefix, onClick, ...props }, ref) => { const element = props.element as TMentionElement; const selected = useSelected(); const focused = useFocused(); const mounted = useMounted(); const readOnly = useReadOnly(); return ( {mounted && IS_APPLE ? ( // Mac OS IME https://github.com/ianstormtaylor/slate/issues/3490 {children} {prefix} {element.value} ) : ( // Others like Android https://github.com/ianstormtaylor/slate/pull/5360 {prefix} {element.value} {children} )} ); });