@dongsuo/react-native-uitextview 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +225 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/RNUITextViewSpec-generated.cpp +22 -0
- package/android/generated/jni/RNUITextViewSpec.h +24 -0
- package/android/generated/jni/react/renderer/components/RNUITextViewSpec/ComponentDescriptors.cpp +23 -0
- package/android/generated/jni/react/renderer/components/RNUITextViewSpec/ComponentDescriptors.h +25 -0
- package/android/generated/jni/react/renderer/components/RNUITextViewSpec/EventEmitters.cpp +61 -0
- package/android/generated/jni/react/renderer/components/RNUITextViewSpec/EventEmitters.h +49 -0
- package/android/generated/jni/react/renderer/components/RNUITextViewSpec/Props.cpp +47 -0
- package/android/generated/jni/react/renderer/components/RNUITextViewSpec/Props.h +182 -0
- package/android/generated/jni/react/renderer/components/RNUITextViewSpec/RNUITextViewSpecJSI-generated.cpp +17 -0
- package/android/generated/jni/react/renderer/components/RNUITextViewSpec/RNUITextViewSpecJSI.h +19 -0
- package/android/generated/jni/react/renderer/components/RNUITextViewSpec/ShadowNodes.cpp +18 -0
- package/android/generated/jni/react/renderer/components/RNUITextViewSpec/ShadowNodes.h +43 -0
- package/android/generated/jni/react/renderer/components/RNUITextViewSpec/States.cpp +16 -0
- package/android/generated/jni/react/renderer/components/RNUITextViewSpec/States.h +41 -0
- package/ios/RNUITextView.h +23 -0
- package/ios/RNUITextView.mm +474 -0
- package/ios/RNUITextViewChild.h +24 -0
- package/ios/RNUITextViewChild.mm +76 -0
- package/ios/RNUITextViewChildComponentDescriptor.h +13 -0
- package/ios/RNUITextViewChildShadowNode.cpp +6 -0
- package/ios/RNUITextViewChildShadowNode.h +16 -0
- package/ios/RNUITextViewComponentDescriptor.h +13 -0
- package/ios/RNUITextViewEventEmitter.h +26 -0
- package/ios/RNUITextViewManager.mm +36 -0
- package/ios/RNUITextViewShadowNode.cpp +127 -0
- package/ios/RNUITextViewShadowNode.h +48 -0
- package/ios/RNUITextViewSpecJSI-generated.cpp +17 -0
- package/ios/RNUITextViewSpecJSI.h +19 -0
- package/ios/generated/RNUITextViewSpec/ComponentDescriptors.cpp +23 -0
- package/ios/generated/RNUITextViewSpec/ComponentDescriptors.h +25 -0
- package/ios/generated/RNUITextViewSpec/EventEmitters.cpp +61 -0
- package/ios/generated/RNUITextViewSpec/EventEmitters.h +49 -0
- package/ios/generated/RNUITextViewSpec/Props.cpp +47 -0
- package/ios/generated/RNUITextViewSpec/Props.h +182 -0
- package/ios/generated/RNUITextViewSpec/RCTComponentViewHelpers.h +24 -0
- package/ios/generated/RNUITextViewSpec/RNUITextViewSpec-generated.mm +16 -0
- package/ios/generated/RNUITextViewSpec/RNUITextViewSpec.h +38 -0
- package/ios/generated/RNUITextViewSpec/ShadowNodes.cpp +18 -0
- package/ios/generated/RNUITextViewSpec/ShadowNodes.h +43 -0
- package/ios/generated/RNUITextViewSpec/States.cpp +16 -0
- package/ios/generated/RNUITextViewSpec/States.h +41 -0
- package/ios/generated/RNUITextViewSpecJSI-generated.cpp +17 -0
- package/ios/generated/RNUITextViewSpecJSI.h +19 -0
- package/lib/commonjs/RNUITextViewChildNativeComponent.ts +48 -0
- package/lib/commonjs/RNUITextViewNativeComponent.ts +47 -0
- package/lib/commonjs/Text.js +140 -0
- package/lib/commonjs/Text.js.map +1 -0
- package/lib/commonjs/index.js +17 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/util.js +64 -0
- package/lib/commonjs/util.js.map +1 -0
- package/lib/module/RNUITextViewChildNativeComponent.ts +48 -0
- package/lib/module/RNUITextViewNativeComponent.ts +47 -0
- package/lib/module/Text.js +136 -0
- package/lib/module/Text.js.map +1 -0
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/util.js +60 -0
- package/lib/module/util.js.map +1 -0
- package/lib/typescript/commonjs/example/src/App.d.ts +2 -0
- package/lib/typescript/commonjs/example/src/App.d.ts.map +1 -0
- package/lib/typescript/commonjs/example/src/CustomMenuExample.d.ts +3 -0
- package/lib/typescript/commonjs/example/src/CustomMenuExample.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/RNUITextViewChildNativeComponent.d.ts +28 -0
- package/lib/typescript/commonjs/src/RNUITextViewChildNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/RNUITextViewNativeComponent.d.ts +29 -0
- package/lib/typescript/commonjs/src/RNUITextViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Text.d.ts +17 -0
- package/lib/typescript/commonjs/src/Text.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +2 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/util.d.ts +160 -0
- package/lib/typescript/commonjs/src/util.d.ts.map +1 -0
- package/lib/typescript/module/example/src/App.d.ts +2 -0
- package/lib/typescript/module/example/src/App.d.ts.map +1 -0
- package/lib/typescript/module/example/src/CustomMenuExample.d.ts +3 -0
- package/lib/typescript/module/example/src/CustomMenuExample.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/RNUITextViewChildNativeComponent.d.ts +28 -0
- package/lib/typescript/module/src/RNUITextViewChildNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/RNUITextViewNativeComponent.d.ts +29 -0
- package/lib/typescript/module/src/RNUITextViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/Text.d.ts +17 -0
- package/lib/typescript/module/src/Text.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +2 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/util.d.ts +160 -0
- package/lib/typescript/module/src/util.d.ts.map +1 -0
- package/package.json +187 -0
- package/react-native-uitextview.podspec +21 -0
- package/react-native.config.js +28 -0
- package/src/RNUITextViewChildNativeComponent.ts +48 -0
- package/src/RNUITextViewNativeComponent.ts +47 -0
- package/src/Text.tsx +148 -0
- package/src/index.tsx +1 -0
- package/src/util.ts +65 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleObjCpp
|
|
8
|
+
*
|
|
9
|
+
* We create an umbrella header (and corresponding implementation) here since
|
|
10
|
+
* Cxx compilation in BUCK has a limitation: source-code producing genrule()s
|
|
11
|
+
* must have a single output. More files => more genrule()s => slower builds.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
#ifndef __cplusplus
|
|
15
|
+
#error This file must be compiled as Obj-C++. If you are importing it, you must change your file extension to .mm.
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
// Avoid multiple includes of RNUITextViewSpec symbols
|
|
19
|
+
#ifndef RNUITextViewSpec_H
|
|
20
|
+
#define RNUITextViewSpec_H
|
|
21
|
+
|
|
22
|
+
#import <Foundation/Foundation.h>
|
|
23
|
+
#import <RCTRequired/RCTRequired.h>
|
|
24
|
+
#import <RCTTypeSafety/RCTConvertHelpers.h>
|
|
25
|
+
#import <RCTTypeSafety/RCTTypedModuleConstants.h>
|
|
26
|
+
#import <React/RCTBridgeModule.h>
|
|
27
|
+
#import <React/RCTCxxConvert.h>
|
|
28
|
+
#import <React/RCTManagedPointer.h>
|
|
29
|
+
#import <ReactCommon/RCTTurboModule.h>
|
|
30
|
+
#import <optional>
|
|
31
|
+
#import <vector>
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
NS_ASSUME_NONNULL_END
|
|
38
|
+
#endif // RNUITextViewSpec_H
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateShadowNodeCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "ShadowNodes.h"
|
|
12
|
+
|
|
13
|
+
namespace facebook::react {
|
|
14
|
+
|
|
15
|
+
extern const char RNUITextViewChildComponentName[] = "RNUITextViewChild";
|
|
16
|
+
extern const char RNUITextViewComponentName[] = "RNUITextView";
|
|
17
|
+
|
|
18
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateShadowNodeH.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include "EventEmitters.h"
|
|
14
|
+
#include "Props.h"
|
|
15
|
+
#include "States.h"
|
|
16
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
17
|
+
#include <jsi/jsi.h>
|
|
18
|
+
|
|
19
|
+
namespace facebook::react {
|
|
20
|
+
|
|
21
|
+
JSI_EXPORT extern const char RNUITextViewChildComponentName[];
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
* `ShadowNode` for <RNUITextViewChild> component.
|
|
25
|
+
*/
|
|
26
|
+
using RNUITextViewChildShadowNode = ConcreteViewShadowNode<
|
|
27
|
+
RNUITextViewChildComponentName,
|
|
28
|
+
RNUITextViewChildProps,
|
|
29
|
+
RNUITextViewChildEventEmitter,
|
|
30
|
+
RNUITextViewChildState>;
|
|
31
|
+
|
|
32
|
+
JSI_EXPORT extern const char RNUITextViewComponentName[];
|
|
33
|
+
|
|
34
|
+
/*
|
|
35
|
+
* `ShadowNode` for <RNUITextView> component.
|
|
36
|
+
*/
|
|
37
|
+
using RNUITextViewShadowNode = ConcreteViewShadowNode<
|
|
38
|
+
RNUITextViewComponentName,
|
|
39
|
+
RNUITextViewProps,
|
|
40
|
+
RNUITextViewEventEmitter,
|
|
41
|
+
RNUITextViewState>;
|
|
42
|
+
|
|
43
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateStateCpp.js
|
|
9
|
+
*/
|
|
10
|
+
#include "States.h"
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateStateH.js
|
|
8
|
+
*/
|
|
9
|
+
#pragma once
|
|
10
|
+
|
|
11
|
+
#ifdef ANDROID
|
|
12
|
+
#include <folly/dynamic.h>
|
|
13
|
+
#endif
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
class RNUITextViewChildState {
|
|
18
|
+
public:
|
|
19
|
+
RNUITextViewChildState() = default;
|
|
20
|
+
|
|
21
|
+
#ifdef ANDROID
|
|
22
|
+
RNUITextViewChildState(RNUITextViewChildState const &previousState, folly::dynamic data){};
|
|
23
|
+
folly::dynamic getDynamic() const {
|
|
24
|
+
return {};
|
|
25
|
+
};
|
|
26
|
+
#endif
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
class RNUITextViewState {
|
|
30
|
+
public:
|
|
31
|
+
RNUITextViewState() = default;
|
|
32
|
+
|
|
33
|
+
#ifdef ANDROID
|
|
34
|
+
RNUITextViewState(RNUITextViewState const &previousState, folly::dynamic data){};
|
|
35
|
+
folly::dynamic getDynamic() const {
|
|
36
|
+
return {};
|
|
37
|
+
};
|
|
38
|
+
#endif
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleCpp.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#include "RNUITextViewSpecJSI.h"
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleH.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <ReactCommon/TurboModule.h>
|
|
13
|
+
#include <react/bridging/Bridging.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'
|
|
2
|
+
import type {ColorValue, ViewProps} from 'react-native'
|
|
3
|
+
import type {
|
|
4
|
+
BubblingEventHandler,
|
|
5
|
+
Float,
|
|
6
|
+
Int32,
|
|
7
|
+
WithDefault,
|
|
8
|
+
} from 'react-native/Libraries/Types/CodegenTypes'
|
|
9
|
+
|
|
10
|
+
interface TargetedEvent {
|
|
11
|
+
target: Int32
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type TextDecorationLine = 'none' | 'underline' | 'line-through'
|
|
15
|
+
|
|
16
|
+
type TextDecorationStyle = 'solid' | 'double' | 'dotted' | 'dashed'
|
|
17
|
+
|
|
18
|
+
export type NativeFontWeight =
|
|
19
|
+
| 'normal'
|
|
20
|
+
| 'bold'
|
|
21
|
+
| 'ultraLight'
|
|
22
|
+
| 'light'
|
|
23
|
+
| 'medium'
|
|
24
|
+
| 'semibold'
|
|
25
|
+
| 'heavy'
|
|
26
|
+
|
|
27
|
+
type FontStyle = 'normal' | 'italic'
|
|
28
|
+
|
|
29
|
+
interface NativeProps extends ViewProps {
|
|
30
|
+
text: string
|
|
31
|
+
color?: ColorValue
|
|
32
|
+
fontSize?: Float
|
|
33
|
+
fontStyle?: WithDefault<FontStyle, 'normal'>
|
|
34
|
+
fontWeight?: WithDefault<NativeFontWeight, 'normal'>
|
|
35
|
+
fontFamily?: string
|
|
36
|
+
letterSpacing?: Float
|
|
37
|
+
lineHeight?: Float
|
|
38
|
+
textDecorationLine?: WithDefault<TextDecorationLine, 'none'>
|
|
39
|
+
textDecorationStyle?: WithDefault<TextDecorationStyle, 'solid'>
|
|
40
|
+
textDecorationColor?: ColorValue
|
|
41
|
+
shadowRadius?: WithDefault<Float, 0>
|
|
42
|
+
onPress?: BubblingEventHandler<TargetedEvent>
|
|
43
|
+
onLongPress?: BubblingEventHandler<TargetedEvent>
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default codegenNativeComponent<NativeProps>('RNUITextViewChild', {
|
|
47
|
+
excludedPlatforms: ['android'],
|
|
48
|
+
})
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'
|
|
2
|
+
import type {ViewProps} from 'react-native'
|
|
3
|
+
import type {
|
|
4
|
+
BubblingEventHandler,
|
|
5
|
+
Int32,
|
|
6
|
+
WithDefault,
|
|
7
|
+
DirectEventHandler,
|
|
8
|
+
} from 'react-native/Libraries/Types/CodegenTypes'
|
|
9
|
+
|
|
10
|
+
interface TargetedEvent {
|
|
11
|
+
target: Int32
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface TextLayoutEvent extends TargetedEvent {
|
|
15
|
+
lines: string[]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// 自定义菜单项接口
|
|
19
|
+
interface CustomMenuItem {
|
|
20
|
+
title: string
|
|
21
|
+
actionId: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// 自定义菜单操作事件
|
|
25
|
+
interface CustomMenuActionEvent extends TargetedEvent {
|
|
26
|
+
actionId: string
|
|
27
|
+
selectedText: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type EllipsizeMode = 'head' | 'middle' | 'tail' | 'clip'
|
|
31
|
+
|
|
32
|
+
interface NativeProps extends ViewProps {
|
|
33
|
+
// 现有属性
|
|
34
|
+
numberOfLines?: Int32
|
|
35
|
+
allowsFontScaling?: boolean
|
|
36
|
+
ellipsizeMode?: WithDefault<EllipsizeMode, 'tail'>
|
|
37
|
+
selectable?: boolean
|
|
38
|
+
onTextLayout?: BubblingEventHandler<TextLayoutEvent>
|
|
39
|
+
|
|
40
|
+
// 新增自定义菜单属性
|
|
41
|
+
customMenuItems?: ReadonlyArray<CustomMenuItem>
|
|
42
|
+
onCustomMenuAction?: DirectEventHandler<CustomMenuActionEvent>
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default codegenNativeComponent<NativeProps>('RNUITextView', {
|
|
46
|
+
excludedPlatforms: ['android'],
|
|
47
|
+
})
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.UITextView = UITextView;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _RNUITextViewChildNativeComponent = _interopRequireDefault(require("./RNUITextViewChildNativeComponent"));
|
|
10
|
+
var _RNUITextViewNativeComponent = _interopRequireDefault(require("./RNUITextViewNativeComponent"));
|
|
11
|
+
var _util = require("./util.js");
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
// 自定义菜单项接口
|
|
15
|
+
|
|
16
|
+
// 自定义菜单事件接口
|
|
17
|
+
|
|
18
|
+
const TextAncestorContext = /*#__PURE__*/_react.default.createContext([false, _reactNative.StyleSheet.create({})]);
|
|
19
|
+
const textDefaults = {
|
|
20
|
+
allowFontScaling: true,
|
|
21
|
+
selectable: true
|
|
22
|
+
};
|
|
23
|
+
const useTextAncestorContext = () => _react.default.useContext(TextAncestorContext);
|
|
24
|
+
|
|
25
|
+
// 扩展 TextProps 类型添加自定义菜单相关属性
|
|
26
|
+
|
|
27
|
+
function UITextViewChild({
|
|
28
|
+
style,
|
|
29
|
+
children,
|
|
30
|
+
customMenuItems,
|
|
31
|
+
onCustomMenuAction,
|
|
32
|
+
...rest
|
|
33
|
+
}) {
|
|
34
|
+
const [isAncestor, rootStyle] = useTextAncestorContext();
|
|
35
|
+
|
|
36
|
+
// Flatten the styles, and apply the root styles when needed
|
|
37
|
+
const flattenedStyle = _react.default.useMemo(() => (0, _util.flattenStyles)(rootStyle, style), [rootStyle, style]);
|
|
38
|
+
console.log('customMenuItems', customMenuItems);
|
|
39
|
+
if (!isAncestor) {
|
|
40
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(TextAncestorContext.Provider, {
|
|
41
|
+
value: [true, flattenedStyle],
|
|
42
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_RNUITextViewNativeComponent.default, {
|
|
43
|
+
...textDefaults,
|
|
44
|
+
...rest,
|
|
45
|
+
// ellipsizeMode={rest.ellipsizeMode ?? rest.lineBreakMode ?? 'tail'}
|
|
46
|
+
style: [flattenedStyle]
|
|
47
|
+
// 自定义菜单相关属性
|
|
48
|
+
,
|
|
49
|
+
customMenuItems: customMenuItems,
|
|
50
|
+
onCustomMenuAction: event => {
|
|
51
|
+
onCustomMenuAction && onCustomMenuAction({
|
|
52
|
+
actionId: event.nativeEvent.actionId,
|
|
53
|
+
selectedText: event.nativeEvent.selectedText
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
// @ts-expect-error Weirdness
|
|
57
|
+
,
|
|
58
|
+
onPress: undefined,
|
|
59
|
+
onLongPress: undefined,
|
|
60
|
+
children: _react.default.Children.toArray(children).map((c, index) => {
|
|
61
|
+
if (/*#__PURE__*/_react.default.isValidElement(c)) {
|
|
62
|
+
return c;
|
|
63
|
+
} else if (typeof c === 'string' || typeof c === 'number') {
|
|
64
|
+
return (
|
|
65
|
+
/*#__PURE__*/
|
|
66
|
+
// @ts-expect-error @TODO fix this type
|
|
67
|
+
(0, _jsxRuntime.jsx)(_RNUITextViewChildNativeComponent.default, {
|
|
68
|
+
style: flattenedStyle,
|
|
69
|
+
text: c.toString(),
|
|
70
|
+
...rest
|
|
71
|
+
}, index)
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
});
|
|
78
|
+
} else {
|
|
79
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
80
|
+
children: _react.default.Children.toArray(children).map((c, index) => {
|
|
81
|
+
if (/*#__PURE__*/_react.default.isValidElement(c)) {
|
|
82
|
+
return c;
|
|
83
|
+
} else if (typeof c === 'string' || typeof c === 'number') {
|
|
84
|
+
return (
|
|
85
|
+
/*#__PURE__*/
|
|
86
|
+
// @ts-expect-error @TODO fix this type
|
|
87
|
+
(0, _jsxRuntime.jsx)(_RNUITextViewChildNativeComponent.default, {
|
|
88
|
+
style: flattenedStyle,
|
|
89
|
+
text: c.toString(),
|
|
90
|
+
...rest
|
|
91
|
+
}, index)
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
})
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function UITextViewInner(props) {
|
|
100
|
+
const [isAncestor] = useTextAncestorContext();
|
|
101
|
+
|
|
102
|
+
// Even if the uiTextView prop is set, we can still default to using
|
|
103
|
+
// normal selection (i.e. base RN text) if the text doesn't need to be
|
|
104
|
+
// selectable
|
|
105
|
+
if ((!props.selectable || !props.uiTextView) && !isAncestor) {
|
|
106
|
+
// 当使用原生 RNText 时,自定义菜单功能不可用
|
|
107
|
+
// Using _ prefix to indicate these are intentionally unused
|
|
108
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
109
|
+
const {
|
|
110
|
+
customMenuItems: _,
|
|
111
|
+
onCustomMenuAction: __,
|
|
112
|
+
...restProps
|
|
113
|
+
} = props;
|
|
114
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
115
|
+
...restProps
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(UITextViewChild, {
|
|
119
|
+
...props
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
function UITextView(props) {
|
|
123
|
+
if (_reactNative.Platform.OS !== 'ios') {
|
|
124
|
+
// 当不是 iOS 平台时,自定义菜单功能不可用
|
|
125
|
+
// Using _ prefix to indicate these are intentionally unused
|
|
126
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
127
|
+
const {
|
|
128
|
+
customMenuItems: _,
|
|
129
|
+
onCustomMenuAction: __,
|
|
130
|
+
...restProps
|
|
131
|
+
} = props;
|
|
132
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
133
|
+
...restProps
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(UITextViewInner, {
|
|
137
|
+
...props
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=Text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_RNUITextViewChildNativeComponent","_RNUITextViewNativeComponent","_util","_jsxRuntime","e","__esModule","default","TextAncestorContext","React","createContext","StyleSheet","create","textDefaults","allowFontScaling","selectable","useTextAncestorContext","useContext","UITextViewChild","style","children","customMenuItems","onCustomMenuAction","rest","isAncestor","rootStyle","flattenedStyle","useMemo","flattenStyles","console","log","jsx","Provider","value","event","actionId","nativeEvent","selectedText","onPress","undefined","onLongPress","Children","toArray","map","c","index","isValidElement","text","toString","Fragment","UITextViewInner","props","uiTextView","_","__","restProps","Text","UITextView","Platform","OS"],"sourceRoot":"../../src","sources":["Text.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAmBA,IAAAE,iCAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,4BAAA,GAAAJ,sBAAA,CAAAC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use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _Text = require("./Text.js");
|
|
7
|
+
Object.keys(_Text).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _Text[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _Text[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_Text","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,KAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,KAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.flattenStyles = flattenStyles;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
function flattenStyles(rootStyle, style) {
|
|
9
|
+
const flattenedStyle = _reactNative.StyleSheet.flatten([rootStyle, style]);
|
|
10
|
+
return {
|
|
11
|
+
...flattenedStyle,
|
|
12
|
+
fontWeight: fontWeightToNativeProp(flattenedStyle.fontWeight ?? 'normal'),
|
|
13
|
+
backgroundColor: flattenedStyle.backgroundColor ? flattenedStyle.backgroundColor : 'transparent',
|
|
14
|
+
shadowOffset: flattenedStyle.shadowOffset ? flattenedStyle.shadowOffset : {
|
|
15
|
+
width: 0,
|
|
16
|
+
height: 0
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Codegen doesn't like using integer values for enums (c++ L) so we'll conver them to the proper native prop
|
|
22
|
+
// value before returning flattened styles.
|
|
23
|
+
function fontWeightToNativeProp(fontWeight) {
|
|
24
|
+
switch (fontWeight) {
|
|
25
|
+
case 'normal':
|
|
26
|
+
return 'normal';
|
|
27
|
+
case 'bold':
|
|
28
|
+
return 'bold';
|
|
29
|
+
case 100:
|
|
30
|
+
case '100':
|
|
31
|
+
case 'ultralight':
|
|
32
|
+
return 'ultraLight';
|
|
33
|
+
case 200:
|
|
34
|
+
case '200':
|
|
35
|
+
return 'ultraLight';
|
|
36
|
+
case 300:
|
|
37
|
+
case '300':
|
|
38
|
+
case 'light':
|
|
39
|
+
return 'light';
|
|
40
|
+
case 400:
|
|
41
|
+
case '400':
|
|
42
|
+
case 'regular':
|
|
43
|
+
return 'normal';
|
|
44
|
+
case 500:
|
|
45
|
+
return 'medium';
|
|
46
|
+
case 600:
|
|
47
|
+
case '600':
|
|
48
|
+
case 'semibold':
|
|
49
|
+
return 'semibold';
|
|
50
|
+
case 700:
|
|
51
|
+
case '700':
|
|
52
|
+
return 'semibold';
|
|
53
|
+
case 800:
|
|
54
|
+
case '800':
|
|
55
|
+
return 'bold';
|
|
56
|
+
case 900:
|
|
57
|
+
case '900':
|
|
58
|
+
case 'heavy':
|
|
59
|
+
return 'heavy';
|
|
60
|
+
default:
|
|
61
|
+
return 'normal';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","flattenStyles","rootStyle","style","flattenedStyle","StyleSheet","flatten","fontWeight","fontWeightToNativeProp","backgroundColor","shadowOffset","width","height"],"sourceRoot":"../../src","sources":["util.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAGO,SAASC,aAAaA,CAC3BC,SAAoB,EACpBC,KAA2B,EAC3B;EACA,MAAMC,cAAc,GAAGC,uBAAU,CAACC,OAAO,CAAC,CAACJ,SAAS,EAAEC,KAAK,CAAC,CAAc;EAC1E,OAAO;IACL,GAAGC,cAAc;IACjBG,UAAU,EAAEC,sBAAsB,CAACJ,cAAc,CAACG,UAAU,IAAI,QAAQ,CAAC;IACzEE,eAAe,EAAEL,cAAc,CAACK,eAAe,GAC3CL,cAAc,CAACK,eAAe,GAC9B,aAAa;IACjBC,YAAY,EAAEN,cAAc,CAACM,YAAY,GACrCN,cAAc,CAACM,YAAY,GAC3B;MAACC,KAAK,EAAE,CAAC;MAAEC,MAAM,EAAE;IAAC;EAC1B,CAAC;AACH;;AAEA;AACA;AACA,SAASJ,sBAAsBA,CAC7BD,UAAmC,EACjB;EAClB,QAAQA,UAAU;IAChB,KAAK,QAAQ;MACX,OAAO,QAAQ;IACjB,KAAK,MAAM;MACT,OAAO,MAAM;IACf,KAAK,GAAG;IACR,KAAK,KAAK;IACV,KAAK,YAAY;MACf,OAAO,YAAY;IACrB,KAAK,GAAG;IACR,KAAK,KAAK;MACR,OAAO,YAAY;IACrB,KAAK,GAAG;IACR,KAAK,KAAK;IACV,KAAK,OAAO;MACV,OAAO,OAAO;IAChB,KAAK,GAAG;IACR,KAAK,KAAK;IACV,KAAK,SAAS;MACZ,OAAO,QAAQ;IACjB,KAAK,GAAG;MACN,OAAO,QAAQ;IACjB,KAAK,GAAG;IACR,KAAK,KAAK;IACV,KAAK,UAAU;MACb,OAAO,UAAU;IACnB,KAAK,GAAG;IACR,KAAK,KAAK;MACR,OAAO,UAAU;IACnB,KAAK,GAAG;IACR,KAAK,KAAK;MACR,OAAO,MAAM;IACf,KAAK,GAAG;IACR,KAAK,KAAK;IACV,KAAK,OAAO;MACV,OAAO,OAAO;IAChB;MACE,OAAO,QAAQ;EACnB;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'
|
|
2
|
+
import type {ColorValue, ViewProps} from 'react-native'
|
|
3
|
+
import type {
|
|
4
|
+
BubblingEventHandler,
|
|
5
|
+
Float,
|
|
6
|
+
Int32,
|
|
7
|
+
WithDefault,
|
|
8
|
+
} from 'react-native/Libraries/Types/CodegenTypes'
|
|
9
|
+
|
|
10
|
+
interface TargetedEvent {
|
|
11
|
+
target: Int32
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type TextDecorationLine = 'none' | 'underline' | 'line-through'
|
|
15
|
+
|
|
16
|
+
type TextDecorationStyle = 'solid' | 'double' | 'dotted' | 'dashed'
|
|
17
|
+
|
|
18
|
+
export type NativeFontWeight =
|
|
19
|
+
| 'normal'
|
|
20
|
+
| 'bold'
|
|
21
|
+
| 'ultraLight'
|
|
22
|
+
| 'light'
|
|
23
|
+
| 'medium'
|
|
24
|
+
| 'semibold'
|
|
25
|
+
| 'heavy'
|
|
26
|
+
|
|
27
|
+
type FontStyle = 'normal' | 'italic'
|
|
28
|
+
|
|
29
|
+
interface NativeProps extends ViewProps {
|
|
30
|
+
text: string
|
|
31
|
+
color?: ColorValue
|
|
32
|
+
fontSize?: Float
|
|
33
|
+
fontStyle?: WithDefault<FontStyle, 'normal'>
|
|
34
|
+
fontWeight?: WithDefault<NativeFontWeight, 'normal'>
|
|
35
|
+
fontFamily?: string
|
|
36
|
+
letterSpacing?: Float
|
|
37
|
+
lineHeight?: Float
|
|
38
|
+
textDecorationLine?: WithDefault<TextDecorationLine, 'none'>
|
|
39
|
+
textDecorationStyle?: WithDefault<TextDecorationStyle, 'solid'>
|
|
40
|
+
textDecorationColor?: ColorValue
|
|
41
|
+
shadowRadius?: WithDefault<Float, 0>
|
|
42
|
+
onPress?: BubblingEventHandler<TargetedEvent>
|
|
43
|
+
onLongPress?: BubblingEventHandler<TargetedEvent>
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default codegenNativeComponent<NativeProps>('RNUITextViewChild', {
|
|
47
|
+
excludedPlatforms: ['android'],
|
|
48
|
+
})
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'
|
|
2
|
+
import type {ViewProps} from 'react-native'
|
|
3
|
+
import type {
|
|
4
|
+
BubblingEventHandler,
|
|
5
|
+
Int32,
|
|
6
|
+
WithDefault,
|
|
7
|
+
DirectEventHandler,
|
|
8
|
+
} from 'react-native/Libraries/Types/CodegenTypes'
|
|
9
|
+
|
|
10
|
+
interface TargetedEvent {
|
|
11
|
+
target: Int32
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface TextLayoutEvent extends TargetedEvent {
|
|
15
|
+
lines: string[]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// 自定义菜单项接口
|
|
19
|
+
interface CustomMenuItem {
|
|
20
|
+
title: string
|
|
21
|
+
actionId: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// 自定义菜单操作事件
|
|
25
|
+
interface CustomMenuActionEvent extends TargetedEvent {
|
|
26
|
+
actionId: string
|
|
27
|
+
selectedText: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type EllipsizeMode = 'head' | 'middle' | 'tail' | 'clip'
|
|
31
|
+
|
|
32
|
+
interface NativeProps extends ViewProps {
|
|
33
|
+
// 现有属性
|
|
34
|
+
numberOfLines?: Int32
|
|
35
|
+
allowsFontScaling?: boolean
|
|
36
|
+
ellipsizeMode?: WithDefault<EllipsizeMode, 'tail'>
|
|
37
|
+
selectable?: boolean
|
|
38
|
+
onTextLayout?: BubblingEventHandler<TextLayoutEvent>
|
|
39
|
+
|
|
40
|
+
// 新增自定义菜单属性
|
|
41
|
+
customMenuItems?: ReadonlyArray<CustomMenuItem>
|
|
42
|
+
onCustomMenuAction?: DirectEventHandler<CustomMenuActionEvent>
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default codegenNativeComponent<NativeProps>('RNUITextView', {
|
|
46
|
+
excludedPlatforms: ['android'],
|
|
47
|
+
})
|