[Glitch] Emoji: Account page
Port 6abda76d13 to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
1 parent
c52473eebc
commit
c4ef050eb6
10 files changed
+196
-138
No files matched your search
@@ -1,7 +1,10 @@
|
||||
import { useCallback } from 'react';
|
||||
import type { ComponentProps, FC } from 'react';
|
||||
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
import type { OnElementHandler } from '@/flavours/glitch/utils/html';
|
||||
|
||||
export interface HandledLinkProps {
|
||||
href: string;
|
||||
text: string;
|
||||
@@ -77,3 +80,31 @@ export const HandledLink: FC<HandledLinkProps & ComponentProps<'a'>> = ({
|
||||
return text;
|
||||
}
|
||||
};
|
||||
|
||||
export const useElementHandledLink = ({
|
||||
hashtagAccountId,
|
||||
mentionAccountId,
|
||||
}: {
|
||||
hashtagAccountId?: string;
|
||||
mentionAccountId?: string;
|
||||
} = {}) => {
|
||||
const onElement = useCallback<OnElementHandler>(
|
||||
(element, { key, ...props }) => {
|
||||
if (element instanceof HTMLAnchorElement) {
|
||||
return (
|
||||
<HandledLink
|
||||
{...props}
|
||||
key={key as string} // React requires keys to not be part of spread props.
|
||||
href={element.href}
|
||||
text={element.innerText}
|
||||
hashtagAccountId={hashtagAccountId}
|
||||
mentionAccountId={mentionAccountId}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
[hashtagAccountId, mentionAccountId],
|
||||
);
|
||||
return { onElement };
|
||||
};
|
||||
Reference in new issue
Block a user