Browse Source

set undo/redo/cut/paste disabled when show context menu for readonly textbox

MaysWind 3 years ago
parent
commit
04ea120ec0
2 changed files with 10 additions and 0 deletions
  1. 4 0
      app/scripts/core/root.js
  2. 6 0
      main/components/menu.js

+ 4 - 0
app/scripts/core/root.js

@@ -537,6 +537,10 @@
                 context.selected = !!selection && selection.length > 0;
             }
 
+            if (angular.element(event.target).attr('readonly') === 'readonly') {
+                context.editable = false;
+            }
+
             if (event.target.nodeName.match(/^(input|textarea)$/i) || event.target.isContentEditable) {
                 ariaNgNativeElectronService.showTextboxContextMenu(context);
             }

+ 6 - 0
main/components/menu.js

@@ -138,6 +138,12 @@ let buildTextboxContextMenu = function(context) {
             }
         }
 
+        if (item.role === 'undo' || item.role === 'redo' || item.role === 'cut' || item.role === 'paste') {
+            if (context.editable === false) {
+                item.enabled = false;
+            }
+        }
+
         newMenus.push(item);
     }