You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
906 B
30 lines
906 B
import { useCallback } from 'react'; |
|
|
|
import type { OnElementHandler } from '@/mastodon/utils/html'; |
|
import { polymorphicForwardRef } from '@/types/polymorphic'; |
|
|
|
import type { EmojiHTMLProps } from '../emoji/html'; |
|
import { EmojiHTML } from '../emoji/html'; |
|
import { useElementHandledLink } from '../status/handled_link'; |
|
|
|
export const HTMLBlock = polymorphicForwardRef< |
|
'div', |
|
EmojiHTMLProps & Parameters<typeof useElementHandledLink>[0] |
|
>( |
|
({ |
|
onElement: onParentElement, |
|
hrefToMention, |
|
hashtagAccountId, |
|
...props |
|
}) => { |
|
const { onElement: onLinkElement } = useElementHandledLink({ |
|
hrefToMention, |
|
hashtagAccountId, |
|
}); |
|
const onElement: OnElementHandler = useCallback( |
|
(...args) => onParentElement?.(...args) ?? onLinkElement(...args), |
|
[onLinkElement, onParentElement], |
|
); |
|
return <EmojiHTML {...props} onElement={onElement} />; |
|
}, |
|
);
|
|
|