2
0
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:
Nikolay Kostyurin
2018-06-11 22:31:02 +02:00
parent 305643daa2
commit 792e949b6e
36 changed files with 6529 additions and 434 deletions
+41
View File
@@ -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;