diff --git a/Hakawai/Core/HKWTextView.m b/Hakawai/Core/HKWTextView.m index 1e38753..7413ef7 100644 --- a/Hakawai/Core/HKWTextView.m +++ b/Hakawai/Core/HKWTextView.m @@ -201,7 +201,8 @@ - (void)cut:(id)sender { } - (void)paste:(id)sender { - if (enableMentionsPluginV2 && [self.copyString length] > 0) { + BOOL implementsWillPasteTextInRange = [self.controlFlowPlugin respondsToSelector:@selector(textView:willPasteTextInRange:isProgrammatic:)]; + if (enableMentionsPluginV2 && [self.copyString length] > 0 && implementsWillPasteTextInRange) { __strong __auto_type copyString = self.copyString; // In order to maintain mentions styling, insert the saved copyString into the attributed text NSUInteger cursorLocationAfterPaste = self.selectedRange.location+self.copyString.length; @@ -215,7 +216,9 @@ - (void)paste:(id)sender { // Inform delegate that text view has changed since we are overriding the normal paste behavior that would do so automatically [self.delegate textViewDidChange:self]; } else { - [self.controlFlowPlugin textView:self willPasteTextInRange:self.selectedRange isProgrammatic:NO]; + if (implementsWillPasteTextInRange) { + [self.controlFlowPlugin textView:self willPasteTextInRange:self.selectedRange isProgrammatic:NO]; + } [super paste:sender]; } self.wasPaste = YES;