Make WordPress Core

Changeset 32059


Ignore:
Timestamp:
04/06/2015 10:50:28 PM (12 years ago)
Author:
azaozz
Message:

TinyMCE: fix our shortcuts on Mac, use Ctrl + Opt + letter.
Props iseulde. See #29558.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js

    r31878 r32059  
    55
    66tinymce.PluginManager.add( 'wordpress', function( editor ) {
    7         var DOM = tinymce.DOM, wpAdvButton, modKey, style,
     7        var DOM = tinymce.DOM,
     8                each = tinymce.each,
     9                __ = editor.editorManager.i18n.translate,
     10                wpAdvButton, style,
    811                last = 0;
    912
    … …  
    3033                }
    3134
    32                 tinymce.each( toolbars, function( toolbar, i ) {
     35                each( toolbars, function( toolbar, i ) {
    3336                        if ( i > 0 ) {
    3437                                if ( state === 'hide' ) {
    … …  
    9295                if ( e.content ) {
    9396                        if ( e.content.indexOf( '<!--more' ) !== -1 ) {
    94                                 title = editor.editorManager.i18n.translate( 'Read more...' );
     97                                title = __( 'Read more...' );
    9598
    9699                                e.content = e.content.replace( /<!--more(.*?)-->/g, function( match, moretext ) {
    … …  
    101104
    102105                        if ( e.content.indexOf( '<!--nextpage-->' ) !== -1 ) {
    103                                 title = editor.editorManager.i18n.translate( 'Page break' );
     106                                title = __( 'Page break' );
    104107
    105108                                e.content = e.content.replace( /<!--nextpage-->/g,
    … …  
    150153                classname += ' mce-wp-' + tag;
    151154                title = tag === 'more' ? 'Read more...' : 'Next page';
    152                 title = editor.editorManager.i18n.translate( title );
     155                title = __( title );
    153156                html = '<img src="' + tinymce.Env.transparentSrc + '" title="' + title + '" class="' + classname + '" ' +
    154157                        'data-wp-more="' + tag + '" data-mce-resize="false" data-mce-placeholder="1" />';
    … …  
    310313                bodyClass.push('wp-editor');
    311314
    312                 tinymce.each( bodyClass, function( cls ) {
     315                each( bodyClass, function( cls ) {
    313316                        if ( cls ) {
    314317                                dom.addClass( doc.body, cls );
    … …  
    352355                        editor.on( 'PastePostProcess', function( event ) {
    353356                                // Remove empty paragraphs
    354                                 tinymce.each( dom.select( 'p', event.node ), function( node ) {
     357                                each( dom.select( 'p', event.node ), function( node ) {
    355358                                        if ( dom.isEmpty( node ) ) {
    356359                                                dom.remove( node );
    … …  
    409412                        editor.settings.height = 300;
    410413                }
    411         });
    412 
    413         // Add custom shortcuts
    414         modKey = 'alt+shift';
    415 
    416         editor.addShortcut( modKey + '+c', '', 'JustifyCenter' );
    417         editor.addShortcut( modKey + '+r', '', 'JustifyRight' );
    418         editor.addShortcut( modKey + '+l', '', 'JustifyLeft' );
    419         editor.addShortcut( modKey + '+j', '', 'JustifyFull' );
    420         editor.addShortcut( modKey + '+q', '', 'mceBlockQuote' );
    421         editor.addShortcut( modKey + '+u', '', 'InsertUnorderedList' );
    422         editor.addShortcut( modKey + '+o', '', 'InsertOrderedList' );
    423         editor.addShortcut( modKey + '+n', '', 'mceSpellCheck' );
    424         editor.addShortcut( modKey + '+s', '', 'unlink' );
    425         editor.addShortcut( modKey + '+m', '', 'WP_Medialib' );
    426         editor.addShortcut( modKey + '+z', '', 'WP_Adv' );
    427         editor.addShortcut( modKey + '+t', '', 'WP_More' );
    428         editor.addShortcut( modKey + '+d', '', 'Strikethrough' );
    429         editor.addShortcut( modKey + '+h', '', 'WP_Help' );
    430         editor.addShortcut( modKey + '+p', '', 'WP_Page' );
    431         editor.addShortcut( modKey + '+x', '', 'WP_Code' );
    432         editor.addShortcut( 'ctrl+s', '', function() {
    433                 if ( typeof wp !== 'undefined' && wp.autosave ) {
    434                         wp.autosave.server.triggerSave();
    435                 }
    436         });
    437        
     414
     415                each( {
     416                        c: 'JustifyCenter',
     417                        r: 'JustifyRight',
     418                        l: 'JustifyLeft',
     419                        j: 'JustifyFull',
     420                        q: 'mceBlockQuote',
     421                        u: 'InsertUnorderedList',
     422                        o: 'InsertOrderedList',
     423                        s: 'unlink',
     424                        m: 'WP_Medialib',
     425                        z: 'WP_Adv',
     426                        t: 'WP_More',
     427                        d: 'Strikethrough',
     428                        h: 'WP_Help',
     429                        p: 'WP_Page',
     430                        x: 'WP_Code'
     431                }, function( command, key ) {
     432                        editor.shortcuts.add( 'access+' + key, '', command );
     433                } );
     434
     435                editor.addShortcut( 'ctrl+s', '', function() {
     436                        if ( typeof wp !== 'undefined' && wp.autosave ) {
     437                                wp.autosave.server.triggerSave();
     438                        }
     439                } );
     440        } );
     441
    438442        /**
    439443         * Experimental: create a floating toolbar.
    440          * This functionality will change in the next releases. Not recommennded for use by plugins.
    441          */             
     444         * This functionality will change in the next releases. Not recommended for use by plugins.
     445         */
    442446        ( function() {
    443                 var DOM = tinymce.DOM,
    444                         each = tinymce.each,
    445                         Factory = tinymce.ui.Factory,
     447                var Factory = tinymce.ui.Factory,
    446448                        settings = editor.settings,
    447449                        currentToolbar,
Note: See TracChangeset for help on using the changeset viewer.