mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2026-03-07 20:20:21 +00:00
52 lines
1.2 KiB
JavaScript
52 lines
1.2 KiB
JavaScript
// @flow
|
|
|
|
import React, { Component } from 'react';
|
|
import ReactLinkify from 'react-linkify';
|
|
|
|
type Props = {
|
|
|
|
/**
|
|
* The children of the component.
|
|
*/
|
|
children: React$Node
|
|
};
|
|
|
|
/**
|
|
* Implements a react wrapper for the react-linkify component.
|
|
*/
|
|
export default class Linkify extends Component<Props> {
|
|
/**
|
|
* Implements {@Component#render}.
|
|
*
|
|
* @inheritdoc
|
|
*/
|
|
render() {
|
|
return (
|
|
<ReactLinkify
|
|
componentDecorator = { this._componentDecorator }>
|
|
{ this.props.children }
|
|
</ReactLinkify>
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Implements a component decorator for react-linkify.
|
|
*
|
|
* @param {string} decoratedHref - The href src.
|
|
* @param {string} decoratedText - The link text.
|
|
* @param {string} key - The component key.
|
|
* @returns {React$Node}
|
|
*/
|
|
_componentDecorator(decoratedHref: string, decoratedText: string, key: number) {
|
|
return (
|
|
<a
|
|
href = { decoratedHref }
|
|
key = { key }
|
|
rel = 'noopener noreferrer'
|
|
target = '_blank'>
|
|
{decoratedText}
|
|
</a>
|
|
);
|
|
}
|
|
}
|