From 16db4c75c7ba892178e26a5e84b28773e35daa8d Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Sat, 14 Nov 2026 00:10:35 +0000 Subject: [PATCH] fix(ios): long-pressed blockquotes lift on an opaque preview The blockquote's context menu lifted the bare view, which has no background of its own, so its text was drawn straight over the dimmed thread. Give the highlight and dismiss previews the first opaque background behind the quote. Co-Authored-By: Claude Opus 5.5 --- .../segments/ENRMBlockquoteContainerView.mm | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/packages/react-native-enriched-markdown/ios/segments/ENRMBlockquoteContainerView.mm b/packages/react-native-enriched-markdown/ios/segments/ENRMBlockquoteContainerView.mm index a39f2349..b8cfa113 100644 --- a/packages/react-native-enriched-markdown/ios/segments/ENRMBlockquoteContainerView.mm +++ b/packages/react-native-enriched-markdown/ios/segments/ENRMBlockquoteContainerView.mm @@ -623,6 +623,36 @@ static UIEdgeInsets ENRMBlockquoteContentInsets(StyleConfig *config) return [UIMenu menuWithTitle:@"" children:@[ copyPlainText, copyMarkdown ]]; }]; } + +// The quote has no background of its own, so a lift of the bare view draws its +// text straight over the dimmed thread. Back it with what it sits on. +- (UITargetedPreview *)blockPreview +{ + if (self.window == nil) + return nil; + UIPreviewParameters *parameters = [[UIPreviewParameters alloc] init]; + parameters.backgroundColor = [UIColor systemBackgroundColor]; + for (UIView *view = self; view; view = view.superview) { + UIColor *color = view.backgroundColor; + if (color && CGColorGetAlpha(color.CGColor) > 0) { + parameters.backgroundColor = color; + break; + } + } + return [[UITargetedPreview alloc] initWithView:self parameters:parameters]; +} + +- (UITargetedPreview *)contextMenuInteraction:(UIContextMenuInteraction *)interaction + previewForHighlightingMenuWithConfiguration:(UIContextMenuConfiguration *)configuration +{ + return [self blockPreview]; +} + +- (UITargetedPreview *)contextMenuInteraction:(UIContextMenuInteraction *)interaction + previewForDismissingMenuWithConfiguration:(UIContextMenuConfiguration *)configuration +{ + return [self blockPreview]; +} #endif // !TARGET_OS_OSX #if TARGET_OS_OSX -- 2.43.0