Changeset 45066
- Timestamp:
- 03/29/2019 12:48:31 AM (5 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/js/_enqueues/vendor/tinymce/plugins/wordpress/plugin.js
r44913 r45066 13 13 $ = window.jQuery, 14 14 wp = window.wp, 15 hasWpautop = ( wp && wp.editor && wp.editor.autop && editor.getParam( 'wpautop', true ) ); 15 hasWpautop = ( wp && wp.editor && wp.editor.autop && editor.getParam( 'wpautop', true ) ), 16 wpTooltips = false; 16 17 17 18 if ( $ ) { … … 581 582 } 582 583 }); 583 }584 585 if ( editor.settings.wp_shortcut_labels && editor.theme.panel ) {586 var labels = {};587 var access = 'Shift+Alt+';588 var meta = 'Ctrl+';589 590 // For Mac: ctrl = \u2303, cmd = \u2318, alt = \u2325591 592 if ( tinymce.Env.mac ) {593 access = '\u2303\u2325';594 meta = '\u2318';595 }596 597 each( editor.settings.wp_shortcut_labels, function( value, name ) {598 labels[ name ] = value.replace( 'access', access ).replace( 'meta', meta );599 } );600 601 each( editor.theme.panel.find('button'), function( button ) {602 if ( button && button.settings.tooltip && labels.hasOwnProperty( button.settings.tooltip ) ) {603 // Need to translate now. We are changing the string so it won't match and cannot be translated later.604 button.settings.tooltip = editor.translate( button.settings.tooltip ) + ' (' + labels[ button.settings.tooltip ] + ')';605 }606 } );607 608 // listbox for the "blocks" drop-down609 each( editor.theme.panel.find('listbox'), function( listbox ) {610 if ( listbox && listbox.settings.text === 'Paragraph' ) {611 each( listbox.settings.values, function( item ) {612 if ( item.text && labels.hasOwnProperty( item.text ) ) {613 item.shortcut = '(' + labels[ item.text ] + ')';614 }615 } );616 }617 } );618 584 } 619 585 }); … … 718 684 } 719 685 }); 686 687 editor.on( 'beforerenderui', function() { 688 if ( editor.theme.panel ) { 689 each( [ 'button', 'colorbutton', 'splitbutton' ], function( buttonType ) { 690 replaceButtonsTooltips( editor.theme.panel.find( buttonType ) ); 691 } ); 692 693 addShortcutsToListbox(); 694 } 695 } ); 696 697 function prepareTooltips() { 698 var access = 'Shift+Alt+'; 699 var meta = 'Ctrl+'; 700 701 wpTooltips = {}; 702 703 // For MacOS: ctrl = \u2303, cmd = \u2318, alt = \u2325 704 if ( tinymce.Env.mac ) { 705 access = '\u2303\u2325'; 706 meta = '\u2318'; 707 } 708 709 // Some tooltips are translated, others are not... 710 if ( editor.settings.wp_shortcut_labels ) { 711 each( editor.settings.wp_shortcut_labels, function( value, tooltip ) { 712 var translated = editor.translate( tooltip ); 713 714 value = value.replace( 'access', access ).replace( 'meta', meta ); 715 wpTooltips[ tooltip ] = value; 716 717 // Add the translated so we can match all of them. 718 if ( tooltip !== translated ) { 719 wpTooltips[ translated ] = value; 720 } 721 } ); 722 } 723 } 724 725 function getTooltip( tooltip ) { 726 var translated = editor.translate( tooltip ); 727 var label; 728 729 if ( ! wpTooltips ) { 730 prepareTooltips(); 731 } 732 733 if ( wpTooltips.hasOwnProperty( translated ) ) { 734 label = wpTooltips[ translated ]; 735 } else if ( wpTooltips.hasOwnProperty( tooltip ) ) { 736 label = wpTooltips[ tooltip ]; 737 } 738 739 return label ? translated + ' (' + label + ')' : translated; 740 } 741 742 function replaceButtonsTooltips( buttons ) { 743 744 if ( ! buttons ) { 745 return; 746 } 747 748 each( buttons, function( button ) { 749 var tooltip; 750 751 if ( button && button.settings.tooltip ) { 752 tooltip = getTooltip( button.settings.tooltip ); 753 button.settings.tooltip = tooltip; 754 755 // Override the aria label wiht the translated tooltip + shortcut. 756 if ( button._aria && button._aria.label ) { 757 button._aria.label = tooltip; 758 } 759 } 760 } ); 761 } 762 763 function addShortcutsToListbox() { 764 // listbox for the "blocks" drop-down 765 each( editor.theme.panel.find( 'listbox' ), function( listbox ) { 766 if ( listbox && listbox.settings.text === 'Paragraph' ) { 767 each( listbox.settings.values, function( item ) { 768 if ( item.text && wpTooltips.hasOwnProperty( item.text ) ) { 769 item.shortcut = '(' + wpTooltips[ item.text ] + ')'; 770 } 771 } ); 772 } 773 } ); 774 } 720 775 721 776 /** … … 753 808 each( buttons, function( item ) { 754 809 var itemName; 810 var tooltip; 755 811 756 812 function bindSelectorChanged() { … … 841 897 if ( settings.toolbar_items_size ) { 842 898 item.size = settings.toolbar_items_size; 899 } 900 901 tooltip = item.tooltip || item.title; 902 903 if ( tooltip ) { 904 item.tooltip = getTooltip( tooltip ); 843 905 } 844 906 -
trunk/src/wp-includes/class-wp-editor.php
r44399 r45066 1152 1152 'Link' => __( 'Link' ), 1153 1153 'Insert link' => __( 'Insert link' ), 1154 'Insert/edit link' => __( 'Insert/edit link' ),1155 1154 'Target' => __( 'Target' ), 1156 1155 'New window' => __( 'New window' ),
Note: See TracChangeset
for help on using the changeset viewer.