From d9fe0232fb10103975635b8e919b695f2e60cfd3 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Mon, 6 Apr 2015 22:50:28 +0000 Subject: [PATCH] TinyMCE: fix our shortcuts on Mac, use Ctrl + Opt + letter. Props iseulde. See #29558. git-svn-id: https://develop.svn.wordpress.org/trunk@32059 602fd350-edb4-49c9-b593-d223f7449a82 --- .../js/tinymce/plugins/wordpress/plugin.js | 76 ++++++++++--------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js b/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js index 3a5b72a2c8..b0632aa923 100644 --- a/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js @@ -4,7 +4,10 @@ tinymce.ui.FloatPanel.zIndex = 100100; tinymce.PluginManager.add( 'wordpress', function( editor ) { - var DOM = tinymce.DOM, wpAdvButton, modKey, style, + var DOM = tinymce.DOM, + each = tinymce.each, + __ = editor.editorManager.i18n.translate, + wpAdvButton, style, last = 0; if ( typeof window.jQuery !== 'undefined' ) { @@ -29,7 +32,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { state = 'hide'; } - tinymce.each( toolbars, function( toolbar, i ) { + each( toolbars, function( toolbar, i ) { if ( i > 0 ) { if ( state === 'hide' ) { toolbar.hide(); @@ -91,7 +94,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { if ( e.content ) { if ( e.content.indexOf( '/g, function( match, moretext ) { return '' ) !== -1 ) { - title = editor.editorManager.i18n.translate( 'Page break' ); + title = __( 'Page break' ); e.content = e.content.replace( //g, ''; @@ -309,7 +312,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { bodyClass.push('wp-editor'); - tinymce.each( bodyClass, function( cls ) { + each( bodyClass, function( cls ) { if ( cls ) { dom.addClass( doc.body, cls ); } @@ -351,7 +354,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { editor.on( 'PastePostProcess', function( event ) { // Remove empty paragraphs - tinymce.each( dom.select( 'p', event.node ), function( node ) { + each( dom.select( 'p', event.node ), function( node ) { if ( dom.isEmpty( node ) ) { dom.remove( node ); } @@ -408,41 +411,40 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { if ( tinymce.Env.iOS ) { editor.settings.height = 300; } - }); - // Add custom shortcuts - modKey = 'alt+shift'; + each( { + c: 'JustifyCenter', + r: 'JustifyRight', + l: 'JustifyLeft', + j: 'JustifyFull', + q: 'mceBlockQuote', + u: 'InsertUnorderedList', + o: 'InsertOrderedList', + s: 'unlink', + m: 'WP_Medialib', + z: 'WP_Adv', + t: 'WP_More', + d: 'Strikethrough', + h: 'WP_Help', + p: 'WP_Page', + x: 'WP_Code' + }, function( command, key ) { + editor.shortcuts.add( 'access+' + key, '', command ); + } ); + + editor.addShortcut( 'ctrl+s', '', function() { + if ( typeof wp !== 'undefined' && wp.autosave ) { + wp.autosave.server.triggerSave(); + } + } ); + } ); - editor.addShortcut( modKey + '+c', '', 'JustifyCenter' ); - editor.addShortcut( modKey + '+r', '', 'JustifyRight' ); - editor.addShortcut( modKey + '+l', '', 'JustifyLeft' ); - editor.addShortcut( modKey + '+j', '', 'JustifyFull' ); - editor.addShortcut( modKey + '+q', '', 'mceBlockQuote' ); - editor.addShortcut( modKey + '+u', '', 'InsertUnorderedList' ); - editor.addShortcut( modKey + '+o', '', 'InsertOrderedList' ); - editor.addShortcut( modKey + '+n', '', 'mceSpellCheck' ); - editor.addShortcut( modKey + '+s', '', 'unlink' ); - editor.addShortcut( modKey + '+m', '', 'WP_Medialib' ); - editor.addShortcut( modKey + '+z', '', 'WP_Adv' ); - editor.addShortcut( modKey + '+t', '', 'WP_More' ); - editor.addShortcut( modKey + '+d', '', 'Strikethrough' ); - editor.addShortcut( modKey + '+h', '', 'WP_Help' ); - editor.addShortcut( modKey + '+p', '', 'WP_Page' ); - editor.addShortcut( modKey + '+x', '', 'WP_Code' ); - editor.addShortcut( 'ctrl+s', '', function() { - if ( typeof wp !== 'undefined' && wp.autosave ) { - wp.autosave.server.triggerSave(); - } - }); - /** * Experimental: create a floating toolbar. - * This functionality will change in the next releases. Not recommennded for use by plugins. - */ + * This functionality will change in the next releases. Not recommended for use by plugins. + */ ( function() { - var DOM = tinymce.DOM, - each = tinymce.each, - Factory = tinymce.ui.Factory, + var Factory = tinymce.ui.Factory, settings = editor.settings, currentToolbar, currentSelection;