From 94585fafc842f5cf6e5bc1227c36a44f465dd422 Mon Sep 17 00:00:00 2001 From: Justin McCandless Date: Fri, 23 Feb 2024 12:22:26 -0800 Subject: [PATCH 1/4] Remove NO from scribble, is it needed? Fixes the problem. --- .../darwin/ios/framework/Source/FlutterTextInputPlugin.mm | 5 ----- 1 file changed, 5 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index 75195368a7266..e0b5db4c69010 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -1145,11 +1145,6 @@ - (BOOL)resignFirstResponder { } - (BOOL)canPerformAction:(SEL)action withSender:(id)sender { - // When scribble is available, the FlutterTextInputView will display the native toolbar unless - // these text editing actions are disabled. - if ([self isScribbleAvailable] && sender == NULL) { - return NO; - } if (action == @selector(paste:)) { // Forbid pasting images, memojis, or other non-string content. return [UIPasteboard generalPasteboard].string != nil; From 606bc4983b02d532acffdd10ac2f27b5a6e10da6 Mon Sep 17 00:00:00 2001 From: Justin McCandless Date: Fri, 8 Mar 2024 09:15:02 -0800 Subject: [PATCH 2/4] Fix paste permission request on keyboard show --- .../darwin/ios/framework/Source/FlutterTextInputPlugin.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index e0b5db4c69010..8e695243294aa 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -1146,8 +1146,12 @@ - (BOOL)resignFirstResponder { - (BOOL)canPerformAction:(SEL)action withSender:(id)sender { if (action == @selector(paste:)) { + UIPasteboard* pasteboard = [UIPasteboard generalPasteboard]; + if (@available(iOS 10, *)) { + return pasteboard.hasStrings; + } // Forbid pasting images, memojis, or other non-string content. - return [UIPasteboard generalPasteboard].string != nil; + return pasteboard.string != nil; } return [super canPerformAction:action withSender:sender]; From 8b94d72ad2a2ce1020d8007fb1bf16e8417261ff Mon Sep 17 00:00:00 2001 From: Justin McCandless Date: Fri, 8 Mar 2024 10:44:31 -0800 Subject: [PATCH 3/4] Tests --- .../ios/framework/Source/FlutterTextInputPluginTest.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm index 17ef8b2f2c7c4..724def096d19c 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm @@ -1299,15 +1299,15 @@ - (void)testCanCopyPasteWithScribbleEnabled { [mockInputView insertText:@"aaaa"]; [mockInputView selectAll:nil]; - XCTAssertFalse([mockInputView canPerformAction:@selector(copy:) withSender:NULL]); + XCTAssertTrue([mockInputView canPerformAction:@selector(copy:) withSender:NULL]); XCTAssertTrue([mockInputView canPerformAction:@selector(copy:) withSender:@"sender"]); XCTAssertFalse([mockInputView canPerformAction:@selector(paste:) withSender:NULL]); XCTAssertFalse([mockInputView canPerformAction:@selector(paste:) withSender:@"sender"]); [mockInputView copy:NULL]; - XCTAssertFalse([mockInputView canPerformAction:@selector(copy:) withSender:NULL]); + XCTAssertTrue([mockInputView canPerformAction:@selector(copy:) withSender:NULL]); XCTAssertTrue([mockInputView canPerformAction:@selector(copy:) withSender:@"sender"]); - XCTAssertFalse([mockInputView canPerformAction:@selector(paste:) withSender:NULL]); + XCTAssertTrue([mockInputView canPerformAction:@selector(paste:) withSender:NULL]); XCTAssertTrue([mockInputView canPerformAction:@selector(paste:) withSender:@"sender"]); } } From 43f444ed8575697d4d048605934f5073e28e5c2d Mon Sep 17 00:00:00 2001 From: Justin McCandless Date: Fri, 8 Mar 2024 11:09:35 -0800 Subject: [PATCH 4/4] Flutter doesn't support iOS 11 and below anymore --- .../darwin/ios/framework/Source/FlutterTextInputPlugin.mm | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index 8e695243294aa..ea36de564d408 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -1146,12 +1146,8 @@ - (BOOL)resignFirstResponder { - (BOOL)canPerformAction:(SEL)action withSender:(id)sender { if (action == @selector(paste:)) { - UIPasteboard* pasteboard = [UIPasteboard generalPasteboard]; - if (@available(iOS 10, *)) { - return pasteboard.hasStrings; - } // Forbid pasting images, memojis, or other non-string content. - return pasteboard.string != nil; + return [UIPasteboard generalPasteboard].hasStrings; } return [super canPerformAction:action withSender:sender];