@thiagobueno/rn-selectable-text 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,6 +20,12 @@ using namespace facebook::react;
20
20
 
21
21
  - (BOOL)canPerformAction:(SEL)action withSender:(id)sender
22
22
  {
23
+ // FIX: We explicitly tell iOS that we can perform standard actions.
24
+ // This prevents the "[UIKitCore] The edit menu did not have performable commands" warning and crash.
25
+ if (action == @selector(copy:) || action == @selector(selectAll:)) {
26
+ return YES;
27
+ }
28
+
23
29
  if (self.parentSelectableTextView) {
24
30
  return [self.parentSelectableTextView canPerformAction:action withSender:sender];
25
31
  }
@@ -46,10 +52,10 @@ using namespace facebook::react;
46
52
  }
47
53
  }
48
54
 
49
- // Intercepta o "Copiar" de teclados físicos e anula a ação
55
+ // Intercepts physical keyboard "Copy" and nullifies the action to keep it custom
50
56
  - (void)copy:(id)sender
51
57
  {
52
- // Bloqueado silenciosamente
58
+ // Silently blocked
53
59
  }
54
60
 
55
61
  @end
@@ -222,9 +228,13 @@ using namespace facebook::react;
222
228
  #pragma mark - UITextViewDelegate
223
229
 
224
230
  // ====================================================================
225
- // A NOVA API DO IOS 16+
231
+ // THE NEW IOS 16+ API
226
232
  // ====================================================================
227
233
  - (UIMenu *)textView:(UITextView *)textView editMenuForTextInRange:(NSRange)range suggestedActions:(NSArray<UIMenuElement *> *)suggestedActions API_AVAILABLE(ios(16.0)) {
234
+
235
+ // FORCING THE FOCUS: ensures the system doesn't dismiss our menu unexpectedly
236
+ [textView becomeFirstResponder];
237
+
228
238
  NSMutableArray<UIMenuElement *> *customActions = [[NSMutableArray alloc] init];
229
239
 
230
240
  for (NSString *option in _menuOptions) {
@@ -234,7 +244,7 @@ using namespace facebook::react;
234
244
  [customActions addObject:action];
235
245
  }
236
246
 
237
- // Retorna apenas nosso menu. A ação "Copiar" nativa exigida pelo sistema é engolida e não aparece.
247
+ // Returns only our custom menu. The native "Copy" action required by the system is swallowed and doesn't appear.
238
248
  return [UIMenu menuWithTitle:@"" children:customActions];
239
249
  }
240
250
 
@@ -291,7 +301,7 @@ using namespace facebook::react;
291
301
  }
292
302
 
293
303
  // ====================================================================
294
- // O TRUQUE PARA FORÇAR O MENU A ABRIR
304
+ // THE TRICK TO FORCE THE MENU TO OPEN AND PREVENT UIKIT WARNINGS
295
305
  // ====================================================================
296
306
  - (BOOL)canPerformAction:(SEL)action withSender:(id)sender
297
307
  {
@@ -300,11 +310,10 @@ using namespace facebook::react;
300
310
  return YES;
301
311
  }
302
312
 
303
- if (@available(iOS 16.0, *)) {
304
- // Dizemos para o iOS que podemos copiar. Isso convence o sistema a não abortar o menu.
305
- if (action == @selector(copy:)) {
306
- return YES;
307
- }
313
+ // We tell iOS that we can perform standard actions.
314
+ // This convinces the system not to abort the menu rendering.
315
+ if (action == @selector(copy:) || action == @selector(selectAll:)) {
316
+ return YES;
308
317
  }
309
318
 
310
319
  return NO;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thiagobueno/rn-selectable-text",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "type": "module",
5
5
  "description": "A library for custom text selection menus",
6
6
  "main": "./lib/module/index.js",