Agents often write drafts as quotes meant to be pasted elsewhere. A plain quote now has a copy control on web, desktop, Android and iOS. It copies the quote's body without the `>` markers and with its nested Markdown. A nested quote, a code block or a Mermaid diagram inside it keeps its own control. Admonitions get no control. Web reads the rendered quote at press time, so a streaming quote copies what it shows, and writes the same two clipboard flavors as selection copy. A rendered Mermaid diagram copies as the fence it shows, and an admonition inside a copied quote copies as its `> [!TYPE]` source. Code blocks and quotes share one copy button with a Copied state and an error toast when the clipboard refuses the write. On compact layouts the control is always visible in a band above the quote body. On wide layouts it shows on hover or focus and the quote keeps a right gutter. Native code blocks and quotes share one header copy control with the Lucide Copy glyph. A quote reserves the code block's header band above its body, so the control never covers text at any font size. Native copy emits the quote body as written, and a copied fence grows longer than any fence inside its code. Supersedes #9429 and #9319. Refs discussion #9303. Co-authored-by: Pedro Vieira <pedro.vieira@dremio.com> Co-authored-by: Phieu Dinh <phieu@fiu.one>
59 lines
2.2 KiB
Objective-C
59 lines
2.2 KiB
Objective-C
#pragma once
|
|
#import "ENRMDynamicBlockProps.h"
|
|
#import "ENRMUIKit.h"
|
|
#import "StyleConfig.h"
|
|
|
|
@class MarkdownASTNode;
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
#if !TARGET_OS_OSX
|
|
typedef UIButton ENRMHeaderCopyButton;
|
|
#else
|
|
typedef NSButton ENRMHeaderCopyButton;
|
|
#endif
|
|
|
|
typedef void (^ENRMCodeBlockCopyBlock)(NSString *code, NSString *language);
|
|
typedef void (^ENRMCodeBlockPressBlock)(NSString *code, NSString *language);
|
|
|
|
@interface ENRMCodeBlockContainerView : RCTUIView
|
|
|
|
- (instancetype)initWithConfig:(StyleConfig *)config;
|
|
|
|
// The header band and its copy control. Quotes show the same control, so the band
|
|
// height, hit box, glyph and placement live here for both.
|
|
+ (CGFloat)headerCopyBandHeightForConfig:(StyleConfig *)config;
|
|
+ (ENRMHeaderCopyButton *)headerCopyButtonForConfig:(StyleConfig *)config target:(id)target action:(SEL)action;
|
|
+ (void)layoutHeaderCopyButton:(ENRMHeaderCopyButton *)button width:(CGFloat)width config:(StyleConfig *)config;
|
|
|
|
- (void)applyCodeBlockNode:(MarkdownASTNode *)node;
|
|
|
|
- (CGFloat)measureHeight:(CGFloat)maxWidth;
|
|
|
|
// View-free height for the shadow-node measurement pass: the same height an
|
|
// instance's measureHeight: reports for the node, without building a view.
|
|
+ (CGFloat)measureHeightForCodeBlockNode:(MarkdownASTNode *)node config:(StyleConfig *)config;
|
|
|
|
@property (nonatomic, strong) StyleConfig *config;
|
|
|
|
// True until the closing fence arrives: highlighting is deferred and copying is
|
|
// disabled, while the header stays visible.
|
|
@property (nonatomic, assign) BOOL pending;
|
|
|
|
// Shared, runtime-mutable block props (context-menu gate, tap gate, copy labels)
|
|
// read live at use-time. Set to the root's shared instance at creation so a code
|
|
// block added after a toggle is born current. See ENRMDynamicBlockProps.
|
|
@property (nonatomic, strong) ENRMDynamicBlockProps *dynamicProps;
|
|
|
|
// Fired when the code is copied (header button, context-menu Copy, or the
|
|
// VoiceOver copy action); set by the host to bridge up to the JS onCopyPress
|
|
// event. Not fired for "Copy as Markdown".
|
|
@property (nonatomic, copy, nullable) ENRMCodeBlockCopyBlock onCopyPress;
|
|
|
|
// Bridges a whole-block tap (not the copy button) up to the JS onCodeBlockPress event.
|
|
@property (nonatomic, copy, nullable) ENRMCodeBlockPressBlock onCodeBlockPress;
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|