This commit is contained in:
Mikael Sand
2017-06-13 12:43:32 +03:00
parent 377cb7267f
commit e9747bee01

View File

@@ -80,7 +80,7 @@ function parseDelta(delta) {
}
}
export default function(props, container, ref) {
export default function(props, container) {
const {
x,
y,
@@ -96,47 +96,34 @@ export default function(props, container, ref) {
let { children } = props;
let content = null;
let fontProps = extractFont(props);
if (props.parentFontProps) {
fontProps = Object.assign({}, props.parentFontProps, fontProps);
}
if (typeof children === 'string' || typeof children === 'number') {
const childrenString = children.toString();
if (container) {
children = <TSpan parentFontProps={fontProps}>{childrenString}</TSpan>;
children = <TSpan>{childrenString}</TSpan>;
} else {
content = childrenString;
children = null;
}
} else if (Children.count(children) >= 1 || Array.isArray(children)) {
} else if (Children.count(children) > 1 || Array.isArray(children)) {
children = Children.map(children, child => {
if (typeof child === 'string' || typeof child === 'number') {
return <TSpan parentFontProps={fontProps}>{child.toString()}</TSpan>;
return <TSpan>{child.toString()}</TSpan>;
} else {
//return child;
return React.cloneElement(child, {
parentFontProps: fontProps
});
return child;
}
});
}
let posY = null;
if (fontProps.fontSize) {
posY = (parseFloat(y || 0) - parseFloat(fontProps.fontSize || 0)).toString();
} else if (y) {
posY = y.toString();
}
return {
textAnchor: anchors[textAnchor] || 0,
font: fontProps,
font: extractFont(props),
children,
content,
deltaX,
deltaY,
startOffset: (startOffset || 0).toString(),
positionX: _.isNil(x) ? null : x.toString(),
positionY: posY
positionY: _.isNil(y) ? null : y.toString()
};
}