@tbvjaos510/react-native-paste-input 0.9.2 → 0.9.5
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/android/build.gradle +5 -27
- package/android/src/main/java/com/mattermost/pasteinputtext/PasteInputActionCallback.kt +10 -9
- package/android/src/main/java/com/mattermost/pasteinputtext/PasteInputEditText.kt +1 -2
- package/android/src/main/java/com/mattermost/pasteinputtext/PasteInputListener.kt +91 -44
- package/android/src/main/java/com/mattermost/pasteinputtext/PasteTextInputManager.kt +33 -0
- package/ios/PasteTextInput.mm +11 -3
- package/ios/PasteTextInputManager.mm +20 -95
- package/lib/commonjs/PasteTextInputNativeComponent.js +33 -0
- package/lib/commonjs/PasteTextInputNativeComponent.js.map +1 -0
- package/lib/module/PasteTextInputNativeComponent.js +31 -0
- package/lib/module/PasteTextInputNativeComponent.js.map +1 -0
- package/lib/typescript/PasteTextInput.d.ts.map +1 -0
- package/lib/typescript/{src/PasteTextInputNativeComponent.d.ts → PasteTextInputNativeComponent.d.ts} +2 -1
- package/lib/typescript/PasteTextInputNativeComponent.d.ts.map +1 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/types.d.ts.map +1 -0
- package/package.json +4 -16
- package/react-native-paste-input.podspec +12 -4
- package/react-native.config.js +5 -1
- package/src/PasteTextInputNativeComponent.ts +34 -6
- package/android/generated/java/com/facebook/react/viewmanagers/PasteTextInputManagerDelegate.java +0 -236
- package/android/generated/java/com/facebook/react/viewmanagers/PasteTextInputManagerInterface.java +0 -84
- package/android/generated/jni/CMakeLists.txt +0 -36
- package/android/generated/jni/PasteTextInputSpecs-generated.cpp +0 -27
- package/android/generated/jni/PasteTextInputSpecs.h +0 -28
- package/android/generated/jni/react/renderer/components/PasteTextInputSpecs/ComponentDescriptors.cpp +0 -22
- package/android/generated/jni/react/renderer/components/PasteTextInputSpecs/ComponentDescriptors.h +0 -166
- package/android/generated/jni/react/renderer/components/PasteTextInputSpecs/EventEmitters.cpp +0 -183
- package/android/generated/jni/react/renderer/components/PasteTextInputSpecs/EventEmitters.h +0 -148
- package/android/generated/jni/react/renderer/components/PasteTextInputSpecs/PasteTextInputSpecsJSI-generated.cpp +0 -17
- package/android/generated/jni/react/renderer/components/PasteTextInputSpecs/PasteTextInputSpecsJSI.h +0 -19
- package/android/generated/jni/react/renderer/components/PasteTextInputSpecs/Props.cpp +0 -640
- package/android/generated/jni/react/renderer/components/PasteTextInputSpecs/Props.h +0 -144
- package/android/generated/jni/react/renderer/components/PasteTextInputSpecs/ShadowNodes.cpp +0 -247
- package/android/generated/jni/react/renderer/components/PasteTextInputSpecs/ShadowNodes.h +0 -95
- package/android/generated/jni/react/renderer/components/PasteTextInputSpecs/States.cpp +0 -14
- package/android/generated/jni/react/renderer/components/PasteTextInputSpecs/States.h +0 -19
- package/lib/commonjs/PasteTextInputNativeComponent.ts +0 -277
- package/lib/module/PasteTextInputNativeComponent.ts +0 -277
- package/lib/typescript/src/PasteTextInput.d.ts.map +0 -1
- package/lib/typescript/src/PasteTextInputNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/index.d.ts.map +0 -1
- package/lib/typescript/src/types.d.ts.map +0 -1
- /package/lib/typescript/{src/PasteTextInput.d.ts → PasteTextInput.d.ts} +0 -0
- /package/lib/typescript/{src/index.d.ts → index.d.ts} +0 -0
- /package/lib/typescript/{src/types.d.ts → types.d.ts} +0 -0
|
@@ -1,144 +0,0 @@
|
|
|
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: GeneratePropsH.js
|
|
9
|
-
*/
|
|
10
|
-
#pragma once
|
|
11
|
-
|
|
12
|
-
#include <react/renderer/core/Props.h>
|
|
13
|
-
#include <react/renderer/graphics/Color.h>
|
|
14
|
-
|
|
15
|
-
#include <react/renderer/attributedstring/TextAttributes.h>
|
|
16
|
-
#include <react/renderer/attributedstring/conversions.h>
|
|
17
|
-
#include <react/renderer/components/textinput/BaseTextInputProps.h>
|
|
18
|
-
#include <react/renderer/components/textinput/basePrimitives.h>
|
|
19
|
-
#include <react/renderer/core/PropsParserContext.h>
|
|
20
|
-
#include <react/renderer/core/propsConversions.h>
|
|
21
|
-
#include <react/renderer/graphics/Color.h>
|
|
22
|
-
#include <react/renderer/imagemanager/primitives.h>
|
|
23
|
-
#include <react/renderer/components/textinput/BaseTextInputProps.h>
|
|
24
|
-
#include <unordered_map>
|
|
25
|
-
|
|
26
|
-
namespace facebook::react {
|
|
27
|
-
|
|
28
|
-
struct AndroidTextInputTextShadowOffsetStruct {
|
|
29
|
-
double width;
|
|
30
|
-
double height;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
inline static bool operator==(
|
|
34
|
-
const AndroidTextInputTextShadowOffsetStruct& lhs,
|
|
35
|
-
const AndroidTextInputTextShadowOffsetStruct& rhs) {
|
|
36
|
-
return lhs.width == rhs.width && lhs.height == rhs.height;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
static inline void fromRawValue(
|
|
40
|
-
const PropsParserContext& context,
|
|
41
|
-
const RawValue& value,
|
|
42
|
-
AndroidTextInputTextShadowOffsetStruct& result) {
|
|
43
|
-
auto map = (std::unordered_map<std::string, RawValue>)value;
|
|
44
|
-
|
|
45
|
-
auto width = map.find("width");
|
|
46
|
-
if (width != map.end()) {
|
|
47
|
-
fromRawValue(context, width->second, result.width);
|
|
48
|
-
}
|
|
49
|
-
auto height = map.find("height");
|
|
50
|
-
if (height != map.end()) {
|
|
51
|
-
fromRawValue(context, height->second, result.height);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
static inline std::string toString(
|
|
56
|
-
const AndroidTextInputTextShadowOffsetStruct& value) {
|
|
57
|
-
return "[Object AndroidTextInputTextShadowOffsetStruct]";
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
inline folly::dynamic toDynamic(
|
|
61
|
-
const AndroidTextInputTextShadowOffsetStruct& value) {
|
|
62
|
-
folly::dynamic dynamicValue = folly::dynamic::object();
|
|
63
|
-
dynamicValue["width"] = value.width;
|
|
64
|
-
dynamicValue["height"] = value.height;
|
|
65
|
-
return dynamicValue;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
class PasteTextInputProps final : public BaseTextInputProps {
|
|
69
|
-
public:
|
|
70
|
-
PasteTextInputProps() = default;
|
|
71
|
-
PasteTextInputProps(
|
|
72
|
-
const PropsParserContext& context,
|
|
73
|
-
const PasteTextInputProps& sourceProps,
|
|
74
|
-
const RawProps& rawProps);
|
|
75
|
-
|
|
76
|
-
void setProp(
|
|
77
|
-
const PropsParserContext& context,
|
|
78
|
-
RawPropsPropNameHash hash,
|
|
79
|
-
const char* propName,
|
|
80
|
-
const RawValue& value);
|
|
81
|
-
|
|
82
|
-
folly::dynamic getDynamic() const;
|
|
83
|
-
|
|
84
|
-
#pragma mark - Props
|
|
85
|
-
|
|
86
|
-
bool disableCopyPaste{false};
|
|
87
|
-
std::string autoComplete{};
|
|
88
|
-
std::string returnKeyLabel{};
|
|
89
|
-
int numberOfLines{0};
|
|
90
|
-
bool disableFullscreenUI{false};
|
|
91
|
-
std::string textBreakStrategy{};
|
|
92
|
-
std::string inlineImageLeft{};
|
|
93
|
-
int inlineImagePadding{0};
|
|
94
|
-
std::string importantForAutofill{};
|
|
95
|
-
bool showSoftInputOnFocus{false};
|
|
96
|
-
bool autoCorrect{false};
|
|
97
|
-
bool allowFontScaling{false};
|
|
98
|
-
Float maxFontSizeMultiplier{0.0};
|
|
99
|
-
std::string keyboardType{};
|
|
100
|
-
std::string returnKeyType{};
|
|
101
|
-
bool secureTextEntry{false};
|
|
102
|
-
std::string value{};
|
|
103
|
-
bool selectTextOnFocus{false};
|
|
104
|
-
bool caretHidden{false};
|
|
105
|
-
bool contextMenuHidden{false};
|
|
106
|
-
SharedColor textShadowColor{};
|
|
107
|
-
Float textShadowRadius{0.0};
|
|
108
|
-
std::string textDecorationLine{};
|
|
109
|
-
std::string fontStyle{};
|
|
110
|
-
AndroidTextInputTextShadowOffsetStruct textShadowOffset{};
|
|
111
|
-
Float lineHeight{0.0};
|
|
112
|
-
std::string textTransform{};
|
|
113
|
-
SharedColor color{0};
|
|
114
|
-
Float letterSpacing{0.0};
|
|
115
|
-
Float fontSize{0.0};
|
|
116
|
-
std::string textAlign{};
|
|
117
|
-
bool includeFontPadding{false};
|
|
118
|
-
std::string fontWeight{};
|
|
119
|
-
std::string fontFamily{};
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Auxiliary information to detect if these props are set or not.
|
|
123
|
-
* See AndroidTextInputComponentDescriptor for usage.
|
|
124
|
-
* TODO T63008435: can these, and this feature, be removed entirely?
|
|
125
|
-
*/
|
|
126
|
-
bool hasPadding{};
|
|
127
|
-
bool hasPaddingHorizontal{};
|
|
128
|
-
bool hasPaddingVertical{};
|
|
129
|
-
bool hasPaddingLeft{};
|
|
130
|
-
bool hasPaddingTop{};
|
|
131
|
-
bool hasPaddingRight{};
|
|
132
|
-
bool hasPaddingBottom{};
|
|
133
|
-
bool hasPaddingStart{};
|
|
134
|
-
bool hasPaddingEnd{};
|
|
135
|
-
|
|
136
|
-
#if RN_DEBUG_STRING_CONVERTIBLE
|
|
137
|
-
SharedDebugStringConvertibleList getDebugProps() const override;
|
|
138
|
-
#endif
|
|
139
|
-
|
|
140
|
-
ComponentName getDiffPropsImplementationTarget() const;
|
|
141
|
-
folly::dynamic getDiffProps(const Props* prevProps) const override;
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
} // namespace facebook::react
|
|
@@ -1,247 +0,0 @@
|
|
|
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
|
-
#include <react/featureflags/ReactNativeFeatureFlags.h>
|
|
14
|
-
#include <react/renderer/attributedstring/AttributedStringBox.h>
|
|
15
|
-
#include <react/renderer/attributedstring/TextAttributes.h>
|
|
16
|
-
#include <react/renderer/components/text/BaseTextShadowNode.h>
|
|
17
|
-
#include <react/renderer/core/LayoutConstraints.h>
|
|
18
|
-
#include <react/renderer/core/LayoutContext.h>
|
|
19
|
-
#include <react/renderer/core/conversions.h>
|
|
20
|
-
#include <react/renderer/textlayoutmanager/TextLayoutContext.h>
|
|
21
|
-
|
|
22
|
-
namespace facebook::react {
|
|
23
|
-
|
|
24
|
-
extern const char PasteTextInputComponentName[] = "PasteTextInput";
|
|
25
|
-
|
|
26
|
-
void PasteTextInputShadowNode::setTextLayoutManager(
|
|
27
|
-
std::shared_ptr<const TextLayoutManager> textLayoutManager) {
|
|
28
|
-
ensureUnsealed();
|
|
29
|
-
textLayoutManager_ = std::move(textLayoutManager);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
Size PasteTextInputShadowNode::measureContent(
|
|
33
|
-
const LayoutContext& layoutContext,
|
|
34
|
-
const LayoutConstraints& layoutConstraints) const {
|
|
35
|
-
auto textConstraints = getTextConstraints(layoutConstraints);
|
|
36
|
-
|
|
37
|
-
TextLayoutContext textLayoutContext{
|
|
38
|
-
.pointScaleFactor = layoutContext.pointScaleFactor,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
if (getStateData().cachedAttributedStringId != 0) {
|
|
42
|
-
auto textSize = textLayoutManager_
|
|
43
|
-
->measureCachedSpannableById(
|
|
44
|
-
getStateData().cachedAttributedStringId,
|
|
45
|
-
getConcreteProps().paragraphAttributes,
|
|
46
|
-
textLayoutContext,
|
|
47
|
-
textConstraints)
|
|
48
|
-
.size;
|
|
49
|
-
return layoutConstraints.clamp(textSize);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// Layout is called right after measure.
|
|
53
|
-
// Measure is marked as `const`, and `layout` is not; so State can be
|
|
54
|
-
// updated during layout, but not during `measure`. If State is out-of-date
|
|
55
|
-
// in layout, it's too late: measure will have already operated on old
|
|
56
|
-
// State. Thus, we use the same value here that we *will* use in layout to
|
|
57
|
-
// update the state.
|
|
58
|
-
AttributedString attributedString =
|
|
59
|
-
getMostRecentAttributedString(layoutContext);
|
|
60
|
-
|
|
61
|
-
if (attributedString.isEmpty()) {
|
|
62
|
-
attributedString = getPlaceholderAttributedString(layoutContext);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (attributedString.isEmpty() && getStateData().mostRecentEventCount != 0) {
|
|
66
|
-
return {.width = 0, .height = 0};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
auto textSize = textLayoutManager_
|
|
70
|
-
->measure(
|
|
71
|
-
AttributedStringBox{attributedString},
|
|
72
|
-
getConcreteProps().paragraphAttributes,
|
|
73
|
-
textLayoutContext,
|
|
74
|
-
textConstraints)
|
|
75
|
-
.size;
|
|
76
|
-
return layoutConstraints.clamp(textSize);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
void PasteTextInputShadowNode::layout(LayoutContext layoutContext) {
|
|
80
|
-
updateStateIfNeeded(layoutContext);
|
|
81
|
-
ConcreteViewShadowNode::layout(layoutContext);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
Float PasteTextInputShadowNode::baseline(
|
|
85
|
-
const LayoutContext& layoutContext,
|
|
86
|
-
Size size) const {
|
|
87
|
-
AttributedString attributedString =
|
|
88
|
-
getMostRecentAttributedString(layoutContext);
|
|
89
|
-
|
|
90
|
-
if (attributedString.isEmpty()) {
|
|
91
|
-
attributedString = getPlaceholderAttributedString(layoutContext);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Yoga expects a baseline relative to the Node's border-box edge instead of
|
|
95
|
-
// the content, so we need to adjust by the padding and border widths, which
|
|
96
|
-
// have already been set by the time of baseline alignment
|
|
97
|
-
auto top = YGNodeLayoutGetBorder(&yogaNode_, YGEdgeTop) +
|
|
98
|
-
YGNodeLayoutGetPadding(&yogaNode_, YGEdgeTop);
|
|
99
|
-
|
|
100
|
-
AttributedStringBox attributedStringBox{attributedString};
|
|
101
|
-
return LineMeasurement::baseline(textLayoutManager_->measureLines(
|
|
102
|
-
attributedStringBox,
|
|
103
|
-
getConcreteProps().paragraphAttributes,
|
|
104
|
-
size)) +
|
|
105
|
-
top;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
LayoutConstraints PasteTextInputShadowNode::getTextConstraints(
|
|
109
|
-
const LayoutConstraints& layoutConstraints) const {
|
|
110
|
-
if (getConcreteProps().multiline) {
|
|
111
|
-
return layoutConstraints;
|
|
112
|
-
} else {
|
|
113
|
-
// A single line TextInput acts as a horizontal scroller of infinitely
|
|
114
|
-
// expandable text, so we want to measure the text as if it is allowed to
|
|
115
|
-
// infinitely expand horizontally, and later clamp to the constraints of the
|
|
116
|
-
// input.
|
|
117
|
-
return LayoutConstraints{
|
|
118
|
-
.minimumSize = layoutConstraints.minimumSize,
|
|
119
|
-
.maximumSize =
|
|
120
|
-
Size{
|
|
121
|
-
.width = std::numeric_limits<Float>::infinity(),
|
|
122
|
-
.height = layoutConstraints.maximumSize.height,
|
|
123
|
-
},
|
|
124
|
-
.layoutDirection = layoutConstraints.layoutDirection,
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
void PasteTextInputShadowNode::updateStateIfNeeded(
|
|
131
|
-
const LayoutContext& layoutContext) {
|
|
132
|
-
ensureUnsealed();
|
|
133
|
-
const auto& stateData = getStateData();
|
|
134
|
-
auto reactTreeAttributedString = getAttributedString(layoutContext);
|
|
135
|
-
|
|
136
|
-
// Tree is often out of sync with the value of the TextInput.
|
|
137
|
-
// This is by design - don't change the value of the TextInput in the State,
|
|
138
|
-
// and therefore in Java, unless the tree itself changes.
|
|
139
|
-
if (stateData.reactTreeAttributedString == reactTreeAttributedString) {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// If props event counter is less than what we already have in state, skip it
|
|
144
|
-
const auto& props = BaseShadowNode::getConcreteProps();
|
|
145
|
-
if (props.mostRecentEventCount < stateData.mostRecentEventCount) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// Even if we're here and updating state, it may be only to update the layout
|
|
150
|
-
// manager If that is the case, make sure we don't update text: pass in the
|
|
151
|
-
// current attributedString unchanged, and pass in zero for the "event count"
|
|
152
|
-
// so no changes are applied There's no way to prevent a state update from
|
|
153
|
-
// flowing to Java, so we just ensure it's a noop in those cases.
|
|
154
|
-
auto newEventCount = stateData.reactTreeAttributedString.isContentEqual(
|
|
155
|
-
reactTreeAttributedString)
|
|
156
|
-
? 0
|
|
157
|
-
: props.mostRecentEventCount;
|
|
158
|
-
auto newAttributedString = getMostRecentAttributedString(layoutContext);
|
|
159
|
-
|
|
160
|
-
setStateData(TextInputState{
|
|
161
|
-
AttributedStringBox(newAttributedString),
|
|
162
|
-
reactTreeAttributedString,
|
|
163
|
-
props.paragraphAttributes,
|
|
164
|
-
newEventCount});
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
AttributedString PasteTextInputShadowNode::getAttributedString(const LayoutContext& layoutContext) const {
|
|
168
|
-
// Use BaseTextShadowNode to get attributed string from children
|
|
169
|
-
auto childTextAttributes = TextAttributes::defaultTextAttributes();
|
|
170
|
-
childTextAttributes.fontSizeMultiplier = layoutContext.fontSizeMultiplier;
|
|
171
|
-
childTextAttributes.apply(getConcreteProps().textAttributes);
|
|
172
|
-
// Don't propagate the background color of the TextInput onto the attributed
|
|
173
|
-
// string. Android tries to render shadow of the background alongside the
|
|
174
|
-
// shadow of the text which results in weird artifacts.
|
|
175
|
-
childTextAttributes.backgroundColor = HostPlatformColor::UndefinedColor;
|
|
176
|
-
|
|
177
|
-
auto attributedString = AttributedString{};
|
|
178
|
-
auto attachments = BaseTextShadowNode::Attachments{};
|
|
179
|
-
BaseTextShadowNode::buildAttributedString(
|
|
180
|
-
childTextAttributes, *this, attributedString, attachments);
|
|
181
|
-
attributedString.setBaseTextAttributes(childTextAttributes);
|
|
182
|
-
|
|
183
|
-
// BaseTextShadowNode only gets children. We must detect and prepend text
|
|
184
|
-
// value attributes manually.
|
|
185
|
-
if (!getConcreteProps().text.empty()) {
|
|
186
|
-
auto textAttributes = TextAttributes::defaultTextAttributes();
|
|
187
|
-
textAttributes.apply(getConcreteProps().textAttributes);
|
|
188
|
-
textAttributes.fontSizeMultiplier = layoutContext.fontSizeMultiplier;
|
|
189
|
-
auto fragment = AttributedString::Fragment{};
|
|
190
|
-
fragment.string = getConcreteProps().text;
|
|
191
|
-
fragment.textAttributes = textAttributes;
|
|
192
|
-
// If the TextInput opacity is 0 < n < 1, the opacity of the TextInput and
|
|
193
|
-
// text value's background will stack. This is a hack/workaround to prevent
|
|
194
|
-
// that effect.
|
|
195
|
-
fragment.textAttributes.backgroundColor = clearColor();
|
|
196
|
-
fragment.parentShadowView = ShadowView(*this);
|
|
197
|
-
attributedString.prependFragment(std::move(fragment));
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return attributedString;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
AttributedString PasteTextInputShadowNode::getMostRecentAttributedString(
|
|
204
|
-
const LayoutContext& layoutContext) const {
|
|
205
|
-
const auto& state = getStateData();
|
|
206
|
-
|
|
207
|
-
auto reactTreeAttributedString = getAttributedString(layoutContext);
|
|
208
|
-
|
|
209
|
-
// Sometimes the treeAttributedString will only differ from the state
|
|
210
|
-
// not by inherent properties (string or prop attributes), but by the frame of
|
|
211
|
-
// the parent which has changed Thus, we can't directly compare the entire
|
|
212
|
-
// AttributedString
|
|
213
|
-
bool treeAttributedStringChanged =
|
|
214
|
-
!state.reactTreeAttributedString.compareTextAttributesWithoutFrame(
|
|
215
|
-
reactTreeAttributedString);
|
|
216
|
-
|
|
217
|
-
return (
|
|
218
|
-
!treeAttributedStringChanged ? state.attributedStringBox.getValue()
|
|
219
|
-
: reactTreeAttributedString);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// For measurement purposes, we want to make sure that there's at least a
|
|
223
|
-
// single character in the string so that the measured height is greater
|
|
224
|
-
// than zero. Otherwise, empty TextInputs with no placeholder don't
|
|
225
|
-
// display at all.
|
|
226
|
-
// TODO T67606511: We will redefine the measurement of empty strings as part
|
|
227
|
-
// of T67606511
|
|
228
|
-
AttributedString PasteTextInputShadowNode::getPlaceholderAttributedString(
|
|
229
|
-
const LayoutContext& layoutContext) const {
|
|
230
|
-
const auto& props = BaseShadowNode::getConcreteProps();
|
|
231
|
-
|
|
232
|
-
AttributedString attributedString;
|
|
233
|
-
auto placeholderString = !props.placeholder.empty()
|
|
234
|
-
? props.placeholder
|
|
235
|
-
: BaseTextShadowNode::getEmptyPlaceholder();
|
|
236
|
-
auto textAttributes = TextAttributes::defaultTextAttributes();
|
|
237
|
-
textAttributes.fontSizeMultiplier = layoutContext.fontSizeMultiplier;
|
|
238
|
-
textAttributes.apply(props.textAttributes);
|
|
239
|
-
attributedString.appendFragment(
|
|
240
|
-
{.string = std::move(placeholderString),
|
|
241
|
-
.textAttributes = textAttributes,
|
|
242
|
-
.parentShadowView = ShadowView(*this)});
|
|
243
|
-
return attributedString;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
} // namespace facebook::react
|
|
@@ -1,95 +0,0 @@
|
|
|
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 <jsi/jsi.h>
|
|
17
|
-
|
|
18
|
-
#include <react/renderer/attributedstring/AttributedString.h>
|
|
19
|
-
#include <react/renderer/components/textinput/TextInputState.h>
|
|
20
|
-
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
21
|
-
#include <react/utils/ContextContainer.h>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
namespace facebook::react {
|
|
25
|
-
|
|
26
|
-
JSI_EXPORT extern const char PasteTextInputComponentName[];
|
|
27
|
-
|
|
28
|
-
/*
|
|
29
|
-
* `ShadowNode` for <PasteTextInput> component.
|
|
30
|
-
*/
|
|
31
|
-
class PasteTextInputShadowNode final : public ConcreteViewShadowNode<
|
|
32
|
-
PasteTextInputComponentName,
|
|
33
|
-
PasteTextInputProps,
|
|
34
|
-
PasteTextInputEventEmitter,
|
|
35
|
-
TextInputState> {
|
|
36
|
-
public:
|
|
37
|
-
using ConcreteViewShadowNode::ConcreteViewShadowNode;
|
|
38
|
-
|
|
39
|
-
static ShadowNodeTraits BaseTraits() {
|
|
40
|
-
auto traits = ConcreteViewShadowNode::BaseTraits();
|
|
41
|
-
traits.set(ShadowNodeTraits::Trait::LeafYogaNode);
|
|
42
|
-
traits.set(ShadowNodeTraits::Trait::MeasurableYogaNode);
|
|
43
|
-
traits.set(ShadowNodeTraits::Trait::BaselineYogaNode);
|
|
44
|
-
return traits;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/*
|
|
48
|
-
* Associates a shared TextLayoutManager with the node.
|
|
49
|
-
* `TextInputShadowNode` uses the manager to measure text content
|
|
50
|
-
* and construct `PasteTextInputState` objects.
|
|
51
|
-
*/
|
|
52
|
-
void setTextLayoutManager(
|
|
53
|
-
std::shared_ptr<const TextLayoutManager> textLayoutManager);
|
|
54
|
-
|
|
55
|
-
protected:
|
|
56
|
-
Size measureContent(
|
|
57
|
-
const LayoutContext& layoutContext,
|
|
58
|
-
const LayoutConstraints& layoutConstraints) const override;
|
|
59
|
-
|
|
60
|
-
void layout(LayoutContext layoutContext) override;
|
|
61
|
-
|
|
62
|
-
Float baseline(const LayoutContext& layoutContext, Size size) const override;
|
|
63
|
-
|
|
64
|
-
std::shared_ptr<const TextLayoutManager> textLayoutManager_;
|
|
65
|
-
|
|
66
|
-
/*
|
|
67
|
-
* Determines the constraints to use while measure the underlying text
|
|
68
|
-
*/
|
|
69
|
-
LayoutConstraints getTextConstraints(
|
|
70
|
-
const LayoutConstraints& layoutConstraints) const;
|
|
71
|
-
|
|
72
|
-
private:
|
|
73
|
-
/*
|
|
74
|
-
* Creates a `State` object (with `AttributedText` and
|
|
75
|
-
* `TextLayoutManager`) if needed.
|
|
76
|
-
*/
|
|
77
|
-
void updateStateIfNeeded(const LayoutContext& layoutContext);
|
|
78
|
-
|
|
79
|
-
/*
|
|
80
|
-
* Returns a `AttributedString` which represents text content of the node.
|
|
81
|
-
*/
|
|
82
|
-
AttributedString getAttributedString(
|
|
83
|
-
const LayoutContext& layoutContext) const;
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Get the most up-to-date attributed string for measurement and State.
|
|
87
|
-
*/
|
|
88
|
-
AttributedString getMostRecentAttributedString(
|
|
89
|
-
const LayoutContext& layoutContext) const;
|
|
90
|
-
|
|
91
|
-
AttributedString getPlaceholderAttributedString(
|
|
92
|
-
const LayoutContext& layoutContext) const;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
} // namespace facebook::react
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
-
namespace facebook::react {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} // namespace facebook::react
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
|
|
16
|
-
namespace facebook::react {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} // namespace facebook::react
|