mirror of
https://github.com/tenrok/BBob.git
synced 2026-06-11 18:02:26 +03:00
add eslint, travis config, test tasks
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
const React = require('react');
|
||||
const parse = require('bbob-html');
|
||||
|
||||
class BBCode extends React.Component {
|
||||
render() {
|
||||
const Container = this.props.container;
|
||||
|
||||
return (
|
||||
<Container>
|
||||
{this.content()}
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
content() {
|
||||
if (this.props.source) {
|
||||
return <span dangerouslySetInnerHTML={{ __html: this.renderBBCode(this.props.source) }} />;
|
||||
}
|
||||
else {
|
||||
return React.Children.map(this.props.children, child => {
|
||||
if (typeof child === 'string') {
|
||||
return <span dangerouslySetInnerHTML={{ __html: this.renderBBCode(child) }} />;
|
||||
}
|
||||
else {
|
||||
return child;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
renderBBCode(source) {
|
||||
return parse(source)
|
||||
}
|
||||
}
|
||||
|
||||
BBCode.defaultProps = {
|
||||
container: 'div',
|
||||
options: {},
|
||||
};
|
||||
|
||||
module.exports = BBCode;
|
||||
Reference in New Issue
Block a user