Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/macos-example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export default function App() {
onLinkPress={handleLinkPress}
markdownStyle={markdownStyle}
contextMenuItems={contextMenuItems}
selectionColor="#DCDDFE"
/>
</ScrollView>
{lastLink != null && (
Expand Down
8 changes: 6 additions & 2 deletions ios/utils/ENRMUIKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,16 @@ static inline void ENRMSetCursorColor(ENRMPlatformTextView *textView, RCTUIColor
#endif
}

/// Cross-platform selection color: iOS uses tintColor (affects both cursor and selection);
/// macOS selection highlight is managed by the system and not directly settable.
/// Cross-platform selection color: iOS uses tintColor (also affects the caret
/// and selection handles); macOS sets the selection background via
/// `selectedTextAttributes`. Pass `nil` to restore the system default.
static inline void ENRMSetSelectionColor(ENRMPlatformTextView *textView, RCTUIColor *color)
{
#if !TARGET_OS_OSX
textView.tintColor = color;
#else
RCTUIColor *resolved = color ?: [NSColor selectedTextBackgroundColor];
textView.selectedTextAttributes = @{NSBackgroundColorAttributeName : resolved};
#endif
}

Expand Down
5 changes: 3 additions & 2 deletions src/EnrichedMarkdownNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,10 @@ export interface NativeProps extends ViewProps {
* Color of the text selection highlight.
*
* On iOS, this also affects the caret and selection handle colors
* (they share a single tint).
* (they share a single tint). On macOS, only the selection background
* is affected.
*
* @platform ios, android, web
* @platform ios, android, macos, web
*/
selectionColor?: ColorValue;
/**
Expand Down
5 changes: 3 additions & 2 deletions src/EnrichedMarkdownTextNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,10 @@ export interface NativeProps extends ViewProps {
* Color of the text selection highlight.
*
* On iOS, this also affects the caret and selection handle colors
* (they share a single tint).
* (they share a single tint). On macOS, only the selection background
* is affected.
*
* @platform ios, android, web
* @platform ios, android, macos, web
*/
selectionColor?: ColorValue;
/**
Expand Down
5 changes: 3 additions & 2 deletions src/types/MarkdownTextProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ export interface EnrichedMarkdownTextProps extends Omit<ViewProps, 'style'> {
* Color of the text selection highlight.
*
* On iOS, this also affects the caret and selection handle colors
* (they share a single tint).
* (they share a single tint). On macOS, only the selection background
* is affected.
*
* @platform ios, android, web
* @platform ios, android, macos, web
*/
selectionColor?: ColorValue;
/**
Expand Down
Loading