Custom Selection menu items#4
Custom Selection menu items#4RohitKushvaha01 wants to merge 4 commits intoAcode-Foundation:codemirrorfrom
Conversation
Summary of ChangesHello @RohitKushvaha01, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the application's text editing capabilities on Android by introducing a robust system for customizing the native text selection menu. It provides a new Java class to manage these custom menu items, integrates this functionality directly into the main activity's lifecycle, and exposes a comprehensive set of JavaScript APIs through a Cordova plugin. This allows developers to dynamically add, remove, and control custom actions that appear when text is selected, offering a more tailored user experience. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a feature for custom text selection menu items, which is a great addition. The implementation includes a new EditorContextMenu manager in Java, along with the necessary Cordova plugin wiring and JavaScript integrations. The overall approach is solid. However, I've identified a critical issue in the new MainActivity.java where a WeakReference to the context is not initialized, which would likely lead to runtime crashes. I've also included a few suggestions to improve the code quality and maintainability of the new Java files.
| PluginResult.Status.OK, | ||
| result | ||
| ); | ||
| pr.setKeepCallback(true); |
There was a problem hiding this comment.
The PluginResult for the onActionItemClicked callback is created with setKeepCallback(true). Since the action mode is finished immediately after the item is clicked, this callback is effectively a one-shot callback. The default behavior (setKeepCallback(false)) is more appropriate here and avoids potential confusion or resource leaks on the JavaScript side if it's not expecting multiple invocations. It's better to remove this line.
|
@bajrangCoder This PR has one issue: custom menu items should be disabled when the editor is not in use. Otherwise, they appear globally. I tried adding the enable/disable calls in In short, |
API Reference