Selaa lähdekoodia

Merge pull request #12502 from TyLindberg/editor-mac-undo

Editor: Listen for Command-Z instead of Ctrl-Z on Mac
Mr.doob 7 vuotta sitten
vanhempi
commit
bf2f88a553
1 muutettua tiedostoa jossa 10 lisäystä ja 4 poistoa
  1. 10 4
      editor/index.html

+ 10 - 4
editor/index.html

@@ -163,6 +163,8 @@
 			window.URL = window.URL || window.webkitURL;
 			window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
 
+			const IS_MAC = navigator.platform.toUpperCase().indexOf( 'MAC' ) >= 0;
+
 			Number.prototype.format = function (){
 				return this.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,");
 			};
@@ -311,13 +313,17 @@
 
 					case 90: // Register Ctrl-Z for Undo, Ctrl-Shift-Z for Redo
 
-						if ( event.ctrlKey && event.shiftKey ) {
+						if ( IS_MAC ? event.metaKey : event.ctrlKey ) {
+
+							if ( event.shiftKey ) {
+
+								editor.redo();
 
-							editor.redo();
+							} else {
 
-						} else if ( event.ctrlKey ) {
+								editor.undo();
 
-							editor.undo();
+							}
 
 						}