react-native-highlight-text-view 0.1.29 → 0.1.30
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/ios/HighlightTextView.mm +7 -10
- package/package.json +2 -2
package/ios/HighlightTextView.mm
CHANGED
|
@@ -28,25 +28,20 @@ using namespace facebook::react;
|
|
|
28
28
|
NSRange glyphRange = [self glyphRangeForCharacterRange:charRange actualCharacterRange:NULL];
|
|
29
29
|
|
|
30
30
|
if (glyphRange.length > 0) {
|
|
31
|
-
// Get the actual character to ensure it's not a whitespace or control character
|
|
32
31
|
unichar character = [textStorage.string characterAtIndex:i];
|
|
33
32
|
if (character == '\n' || character == '\r' || character == ' ' || character == '\t') {
|
|
34
33
|
continue;
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
// Get the glyph's position and line metrics
|
|
38
36
|
CGPoint glyphLocation = [self locationForGlyphAtIndex:glyphRange.location];
|
|
39
37
|
NSUInteger lineIndex = [self lineFragmentRectForGlyphAtIndex:glyphRange.location effectiveRange:NULL].origin.y;
|
|
40
38
|
CGRect lineRect = [self lineFragmentRectForGlyphAtIndex:glyphRange.location effectiveRange:NULL];
|
|
41
39
|
|
|
42
|
-
// Calculate precise character width using the font's attributes
|
|
43
|
-
// This avoids the extra spacing that boundingRectForGlyphRange includes with lineHeight
|
|
44
40
|
NSDictionary *attributes = [textStorage attributesAtIndex:i effectiveRange:NULL];
|
|
45
41
|
UIFont *font = attributes[NSFontAttributeName];
|
|
46
42
|
NSString *charString = [textStorage.string substringWithRange:NSMakeRange(i, 1)];
|
|
47
43
|
CGSize charSize = [charString sizeWithAttributes:@{NSFontAttributeName: font}];
|
|
48
44
|
|
|
49
|
-
// Build the character rect with precise width
|
|
50
45
|
CGRect boundingRect = CGRectMake(
|
|
51
46
|
glyphLocation.x,
|
|
52
47
|
lineRect.origin.y,
|
|
@@ -54,10 +49,8 @@ using namespace facebook::react;
|
|
|
54
49
|
lineRect.size.height
|
|
55
50
|
);
|
|
56
51
|
|
|
57
|
-
// Ensure the glyph has reasonable dimensions
|
|
58
52
|
if (boundingRect.size.width > 1.0 && boundingRect.size.height > 1.0) {
|
|
59
53
|
|
|
60
|
-
// Apply background insets first (shrinks from line box)
|
|
61
54
|
boundingRect.origin.y += self.backgroundInsetTop;
|
|
62
55
|
boundingRect.size.height -= (self.backgroundInsetTop + self.backgroundInsetBottom);
|
|
63
56
|
boundingRect.origin.x += self.backgroundInsetLeft;
|
|
@@ -288,9 +281,13 @@ using namespace facebook::react;
|
|
|
288
281
|
_currentVerticalAlignment = verticalPart;
|
|
289
282
|
[self updateVerticalAlignment:verticalPart];
|
|
290
283
|
} else if (!verticalPart && horizontalPart) {
|
|
291
|
-
//
|
|
292
|
-
_currentVerticalAlignment
|
|
293
|
-
|
|
284
|
+
// Preserve existing vertical alignment when only horizontal alignment is specified
|
|
285
|
+
if (_currentVerticalAlignment) {
|
|
286
|
+
[self updateVerticalAlignment:_currentVerticalAlignment];
|
|
287
|
+
} else {
|
|
288
|
+
// Default vertical centering only if no vertical alignment was previously set
|
|
289
|
+
_textView.textContainerInset = UIEdgeInsetsMake(10, 10, 10, 10);
|
|
290
|
+
}
|
|
294
291
|
}
|
|
295
292
|
|
|
296
293
|
[self applyCharacterBackgrounds]; // Reapply to update alignment
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-highlight-text-view",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.30",
|
|
4
4
|
"description": "A native text input for React Native that supports inline text highlighting",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"android",
|
|
19
19
|
"ios",
|
|
20
20
|
"cpp",
|
|
21
|
-
"*.podspec",
|
|
21
|
+
"*.podspec",
|
|
22
22
|
"react-native.config.js",
|
|
23
23
|
"!ios/build",
|
|
24
24
|
"!android/build",
|