Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide disabled command from context menu #5580

Merged
merged 4 commits into from
Jun 12, 2024

Conversation

mkslanc
Copy link
Contributor

@mkslanc mkslanc commented Jun 4, 2024

Issue #, if available: #5579

Description of changes:

  • Hide command if it was disabled from mobile menu
  • Add option to enable/disable mobile menu at all

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Pull Request Checklist:

Copy link

codecov bot commented Jun 4, 2024

Codecov Report

Attention: Patch coverage is 96.77419% with 1 line in your changes missing coverage. Please review.

Project coverage is 86.78%. Comparing base (a3277ea) to head (a5e52ee).
Report is 1 commits behind head on master.

Files Patch % Lines
src/mouse/touch_handler.js 92.30% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5580   +/-   ##
=======================================
  Coverage   86.78%   86.78%           
=======================================
  Files         594      594           
  Lines       43017    43042   +25     
  Branches     7129     7135    +6     
=======================================
+ Hits        37331    37355   +24     
- Misses       5686     5687    +1     
Flag Coverage Δ
unittests 86.78% <96.77%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Jun 5, 2024

One of the public type files has been updated, plase make sure there are no backwards incompatible changes done in the PR.

Copy link

github-actions bot commented Jun 5, 2024

One of the public type files has been updated, plase make sure there are no backwards incompatible changes done in the PR.

@mkslanc mkslanc marked this pull request as ready for review June 5, 2024 10:23
@@ -26,15 +26,16 @@ exports.addTouchListeners = function(el, editor) {
var updateMenu = function() {
var selected = editor.getCopyText();
var hasUndo = editor.session.getUndoManager().hasUndo();
var commands = editor.commands.byName;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small improvement:

var hasCommand = function(cmd) {
    var commands = editor.commands.byName;
    if(!commands[cmd]) return false;
    if(!editor.getReadOnly()) return false;
    return commands[cmd].readOnly;
};

this also disables commands when they are readonly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you want to remove non-readonly commands on readonly editor? Or for all editors?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@whazor did you mean if (!commands[cmd].readOnly && editor.getReadOnly())) return false for the readonly part?
https://github.com/ajaxorg/ace/blob/master/src/commands/command_manager.js#L48C23-L48C39

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think it would be nice to hide all commands that are unavailable. So in a readonly editor, only Select/Find/...

After looking at the command manager, maybe we could move the logic from 'exec' to a seperate method (has?) in the command manager and include both readOnly and isAvailable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New changes should make it, I think

Copy link

github-actions bot commented Jun 6, 2024

One of the public type files has been updated, plase make sure there are no backwards incompatible changes done in the PR.

Copy link

github-actions bot commented Jun 6, 2024

One of the public type files has been updated, plase make sure there are no backwards incompatible changes done in the PR.

@InspiredGuy InspiredGuy merged commit ecc5f67 into ajaxorg:master Jun 12, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants