mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
048194849b
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
81 lines
2.4 KiB
JavaScript
81 lines
2.4 KiB
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow
|
|
* @format
|
|
*/
|
|
|
|
import {createViewConfig} from '../NativeComponent/ViewConfig';
|
|
import UIManager from '../ReactNative/UIManager';
|
|
import createReactNativeComponentClass from '../Renderer/shims/createReactNativeComponentClass';
|
|
import {type HostComponent} from '../Renderer/shims/ReactNativeTypes';
|
|
import {type ProcessedColorValue} from '../StyleSheet/processColor';
|
|
import {type PressEvent} from '../Types/CoreEventTypes';
|
|
import {type TextProps} from './TextProps';
|
|
|
|
type NativeTextProps = $ReadOnly<{
|
|
...TextProps,
|
|
isHighlighted?: ?boolean,
|
|
selectionColor?: ?ProcessedColorValue,
|
|
onClick?: ?(event: PressEvent) => mixed,
|
|
// This is only needed for platforms that optimize text hit testing, e.g.,
|
|
// react-native-windows. It can be used to only hit test virtual text spans
|
|
// that have pressable events attached to them.
|
|
isPressable?: ?boolean,
|
|
}>;
|
|
|
|
const textViewConfig = {
|
|
validAttributes: {
|
|
isHighlighted: true,
|
|
isPressable: true,
|
|
numberOfLines: true,
|
|
ellipsizeMode: true,
|
|
allowFontScaling: true,
|
|
maxFontSizeMultiplier: true,
|
|
disabled: true,
|
|
selectable: true,
|
|
selectionColor: true,
|
|
adjustsFontSizeToFit: true,
|
|
minimumFontScale: true,
|
|
textBreakStrategy: true,
|
|
onTextLayout: true,
|
|
onInlineViewLayout: true,
|
|
dataDetectorType: true,
|
|
android_hyphenationFrequency: true,
|
|
lineBreakStrategyIOS: true,
|
|
},
|
|
directEventTypes: {
|
|
topTextLayout: {
|
|
registrationName: 'onTextLayout',
|
|
},
|
|
topInlineViewLayout: {
|
|
registrationName: 'onInlineViewLayout',
|
|
},
|
|
},
|
|
uiViewClassName: 'RCTText',
|
|
};
|
|
|
|
const virtualTextViewConfig = {
|
|
validAttributes: {
|
|
isHighlighted: true,
|
|
isPressable: true,
|
|
maxFontSizeMultiplier: true,
|
|
},
|
|
uiViewClassName: 'RCTVirtualText',
|
|
};
|
|
|
|
export const NativeText: HostComponent<NativeTextProps> =
|
|
(createReactNativeComponentClass('RCTText', () =>
|
|
createViewConfig(textViewConfig),
|
|
): any);
|
|
|
|
export const NativeVirtualText: HostComponent<NativeTextProps> =
|
|
!global.RN$Bridgeless && !UIManager.hasViewManagerConfig('RCTVirtualText')
|
|
? NativeText
|
|
: (createReactNativeComponentClass('RCTVirtualText', () =>
|
|
createViewConfig(virtualTextViewConfig),
|
|
): any);
|