Skip to content

Commit de36f49

Browse files
committed
fix(mobile): support text wrapping in sheet cells
1 parent 2a5cb5f commit de36f49

File tree

1 file changed

+43
-14
lines changed

1 file changed

+43
-14
lines changed

apps/mobile/v1/src/components/NativeSheetsViewer.tsx

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,14 @@ export function NativeSheetsViewer({
650650
}
651651
}
652652

653+
// Check if text wrapping is enabled
654+
// Univer enum: 1=OVERFLOW, 2=WRAP, 3=CLIP (but some versions use different values)
655+
// Your data shows tb:3 for wrapped text, so check for both 2 and 3
656+
const isWrapped = style?.tb === 2 || style?.tb === 3;
657+
658+
// Calculate available text width (cell width minus padding)
659+
const textWidth = cellWidth - 8; // 4px padding on each side
660+
653661
return (
654662
<View
655663
key={`${row}-${col}`}
@@ -667,23 +675,44 @@ export function NativeSheetsViewer({
667675
justifyContent: getVerticalAlign(style?.vt),
668676
alignItems: getHorizontalAlign(style?.ht),
669677
zIndex: mergeInfo ? 2 : 0, // Merged cells on top
678+
overflow: 'hidden',
679+
paddingHorizontal: 4,
680+
paddingVertical: 2,
670681
},
671682
]}
672683
>
673-
<Text
674-
style={{
675-
fontSize,
676-
color: textColor,
677-
fontWeight: style?.bl === 1 ? 'bold' : 'normal',
678-
fontStyle: style?.it === 1 ? 'italic' : 'normal',
679-
fontFamily: style?.ff || undefined,
680-
textAlign: getTextAlign(style?.ht),
681-
textDecorationLine: style?.ul?.s === 1 ? 'underline' : style?.st?.s === 1 ? 'line-through' : 'none',
682-
}}
683-
numberOfLines={style?.tb === 2 ? undefined : 1}
684-
>
685-
{value}
686-
</Text>
684+
{isWrapped ? (
685+
<Text
686+
style={{
687+
fontSize,
688+
color: textColor,
689+
fontWeight: style?.bl === 1 ? 'bold' : 'normal',
690+
fontStyle: style?.it === 1 ? 'italic' : 'normal',
691+
fontFamily: style?.ff || undefined,
692+
textAlign: getTextAlign(style?.ht),
693+
textDecorationLine: style?.ul?.s === 1 ? 'underline' : style?.st?.s === 1 ? 'line-through' : 'none',
694+
width: textWidth,
695+
}}
696+
>
697+
{value}
698+
</Text>
699+
) : (
700+
<Text
701+
style={{
702+
fontSize,
703+
color: textColor,
704+
fontWeight: style?.bl === 1 ? 'bold' : 'normal',
705+
fontStyle: style?.it === 1 ? 'italic' : 'normal',
706+
fontFamily: style?.ff || undefined,
707+
textAlign: getTextAlign(style?.ht),
708+
textDecorationLine: style?.ul?.s === 1 ? 'underline' : style?.st?.s === 1 ? 'line-through' : 'none',
709+
}}
710+
numberOfLines={1}
711+
ellipsizeMode="tail"
712+
>
713+
{value}
714+
</Text>
715+
)}
687716
</View>
688717
);
689718
};

0 commit comments

Comments
 (0)