mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
feat(iOS): added lineBreakStrategy attribute to Text/TextInput (#31272)
Summary: iOS did not support the implementation of Korean word-wrap(line-break) before iOS14. If the attribute applied, the word-wrap of Korean will works. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [iOS] [Added] - Line break strategy for Text and TextInput components Pull Request resolved: https://github.com/facebook/react-native/pull/31272 Test Plan: 1. Test build and run on above iOS 14. 2. Test it does not affect existing text components when set default(none) strategy. 3. Test whether word-wrap works with Korean when set hangul-word strategy. <img src="https://user-images.githubusercontent.com/26326015/112963967-d7f70c00-9182-11eb-9a34-8c758b80c219.png" width="300" height="" style="max-width:100%;"> Reviewed By: javache Differential Revision: D39824809 Pulled By: lunaleaps fbshipit-source-id: 42cb0385221a38c84e80d3494d1bfc1934ecf32b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
a0ee6fae5e
commit
048194849b
@@ -65,6 +65,7 @@ typedef NSURL RCTFileURL;
|
||||
+ (NSTextAlignment)NSTextAlignment:(id)json;
|
||||
+ (NSUnderlineStyle)NSUnderlineStyle:(id)json;
|
||||
+ (NSWritingDirection)NSWritingDirection:(id)json;
|
||||
+ (NSLineBreakStrategy)NSLineBreakStrategy:(id)json;
|
||||
+ (UITextAutocapitalizationType)UITextAutocapitalizationType:(id)json;
|
||||
+ (UITextFieldViewMode)UITextFieldViewMode:(id)json;
|
||||
+ (UIKeyboardType)UIKeyboardType:(id)json;
|
||||
|
||||
@@ -375,6 +375,25 @@ RCT_ENUM_CONVERTER(
|
||||
NSWritingDirectionNatural,
|
||||
integerValue)
|
||||
|
||||
+ (NSLineBreakStrategy)NSLineBreakStrategy:(id)json RCT_DYNAMIC
|
||||
{
|
||||
if (@available(iOS 14.0, *)) {
|
||||
static NSDictionary *mapping;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
mapping = @{
|
||||
@"none" : @(NSLineBreakStrategyNone),
|
||||
@"standard" : @(NSLineBreakStrategyStandard),
|
||||
@"hangul-word" : @(NSLineBreakStrategyHangulWordPriority),
|
||||
@"push-out" : @(NSLineBreakStrategyPushOut)
|
||||
};
|
||||
});
|
||||
return RCTConvertEnumValue("NSLineBreakStrategy", mapping, @(NSLineBreakStrategyNone), json).integerValue;
|
||||
} else {
|
||||
return NSLineBreakStrategyNone;
|
||||
}
|
||||
}
|
||||
|
||||
RCT_ENUM_CONVERTER(
|
||||
UITextAutocapitalizationType,
|
||||
(@{
|
||||
|
||||
Reference in New Issue
Block a user