mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-05 14:02:48 +00:00
ASEditableTextNode: added shouldCopy callback
This commit is contained in:
parent
16ce3e690a
commit
75d4f47c24
@ -211,6 +211,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*/
|
||||
- (void)editableTextNodeDidFinishEditing:(ASEditableTextNode *)editableTextNode;
|
||||
|
||||
- (BOOL)editableTextNodeShouldCopy:(ASEditableTextNode *)editableTextNode;
|
||||
- (BOOL)editableTextNodeShouldPaste:(ASEditableTextNode *)editableTextNode;
|
||||
- (ASEditableTextNodeTargetForAction * _Nullable)editableTextNodeTargetForAction:(SEL)action;
|
||||
- (BOOL)editableTextNodeShouldReturn:(ASEditableTextNode *)editableTextNode;
|
||||
|
||||
@ -86,6 +86,7 @@
|
||||
BOOL _initializedPrimaryInputLanguage;
|
||||
}
|
||||
|
||||
@property (nonatomic, copy) bool (^shouldCopy)();
|
||||
@property (nonatomic, copy) bool (^shouldPaste)();
|
||||
@property (nonatomic, copy) ASEditableTextNodeTargetForAction *(^targetForActionImpl)(SEL);
|
||||
@property (nonatomic, copy) bool (^shouldReturn)();
|
||||
@ -163,6 +164,12 @@
|
||||
return [super targetForAction:action withSender:sender];
|
||||
}
|
||||
|
||||
- (void)copy:(id)sender {
|
||||
if (_shouldCopy == nil || _shouldCopy()) {
|
||||
[super copy:sender];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)paste:(id)sender
|
||||
{
|
||||
if (_shouldPaste == nil || _shouldPaste()) {
|
||||
@ -336,6 +343,15 @@
|
||||
ASPanningOverriddenUITextView *textView = [[ASPanningOverriddenUITextView alloc] initWithFrame:CGRectZero textContainer:_textKitComponents.textContainer];
|
||||
textView.initialPrimaryLanguage = _initialPrimaryLanguage;
|
||||
__weak ASEditableTextNode *weakSelf = self;
|
||||
textView.shouldCopy = ^bool{
|
||||
__strong ASEditableTextNode *strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
if ([strongSelf->_delegate respondsToSelector:@selector(editableTextNodeShouldCopy:)]) {
|
||||
return [strongSelf->_delegate editableTextNodeShouldCopy:self];
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
textView.shouldPaste = ^bool{
|
||||
__strong ASEditableTextNode *strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user