Hydrate body ranges for story replies
This commit is contained in:
parent
9f85db3fd8
commit
be6e988a95
39 changed files with 221 additions and 172 deletions
|
@ -321,28 +321,20 @@ export type Props = {
|
|||
|
||||
const SUPPORTED_PROTOCOLS = /^(http|https):/i;
|
||||
|
||||
export class Linkify extends React.Component<Props> {
|
||||
public static defaultProps: Partial<Props> = {
|
||||
renderNonLink: ({ text }) => text,
|
||||
};
|
||||
const defaultRenderNonLink: RenderTextCallbackType = ({ text }) => text;
|
||||
|
||||
export class Linkify extends React.Component<Props> {
|
||||
public override render():
|
||||
| JSX.Element
|
||||
| string
|
||||
| null
|
||||
| Array<JSX.Element | string | null> {
|
||||
const { text, renderNonLink } = this.props;
|
||||
const { text, renderNonLink = defaultRenderNonLink } = this.props;
|
||||
|
||||
if (!shouldLinkifyMessage(text)) {
|
||||
return text;
|
||||
}
|
||||
|
||||
// We have to do this, because renderNonLink is not required in our Props object,
|
||||
// but it is always provided via defaultProps.
|
||||
if (!renderNonLink) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const chunkData: Array<{
|
||||
chunk: string;
|
||||
matchData: ReadonlyArray<LinkifyIt.Match>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue