first step of TSpan

This commit is contained in:
Horcrux
2016-08-30 09:37:38 +08:00
parent e78e5db092
commit bd26c04a1d
10 changed files with 400 additions and 137 deletions

View File

@@ -0,0 +1,26 @@
import React, {
Children
} from 'react';
import TSpan from '../../elements/TSpan';
const newLine = /\n/g;
export default function(children) {
let spans = [];
Children.forEach(children, function (child = '') {
let span;
if (typeof child === 'string') {
span = <TSpan>{child.replace(newLine, ' ')}</TSpan>;
} else if (child.type === TSpan) {
span = child;
} else {
// give warning about the illegal child type
return;
}
spans.push(span);
});
return spans;
}