TinyMCE: add internal command and shortcut (Alt+Shift+X) for toggling <code>. Define a button that can be added to any toolbar as `wp_code`. See #6113

git-svn-id: https://develop.svn.wordpress.org/trunk@27545 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2014-03-14 22:42:59 +00:00
parent b6e2bd9f0e
commit 0fdb6dadfb
2 changed files with 15 additions and 0 deletions

View File

@ -661,6 +661,10 @@ i.mce-i-wp_page:before {
content: '\f158'; content: '\f158';
} }
.mce-i-wp_code:before {
content: "\e017";
}
/* Editors */ /* Editors */
.wp-editor-wrap { .wp-editor-wrap {
position: relative; position: relative;

View File

@ -193,6 +193,10 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
} }
}); });
editor.addCommand( 'WP_Code', function() {
editor.formatter.toggle('code');
});
editor.addCommand( 'WP_Page', function() { editor.addCommand( 'WP_Page', function() {
editor.execCommand( 'WP_More', 'nextpage' ); editor.execCommand( 'WP_More', 'nextpage' );
}); });
@ -232,6 +236,12 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
cmd: 'WP_Help' cmd: 'WP_Help'
}); });
editor.addButton( 'wp_code', {
tooltip: 'Code',
cmd: 'WP_Code',
stateSelector: 'code'
});
// Menubar // Menubar
// Insert->Add Media // Insert->Add Media
if ( typeof wp !== 'undefined' && wp.media && wp.media.editor ) { if ( typeof wp !== 'undefined' && wp.media && wp.media.editor ) {
@ -442,6 +452,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
editor.addShortcut( modKey + '+d', '', 'Strikethrough' ); editor.addShortcut( modKey + '+d', '', 'Strikethrough' );
editor.addShortcut( modKey + '+h', '', 'WP_Help' ); editor.addShortcut( modKey + '+h', '', 'WP_Help' );
editor.addShortcut( modKey + '+p', '', 'WP_Page' ); editor.addShortcut( modKey + '+p', '', 'WP_Page' );
editor.addShortcut( modKey + '+x', '', 'WP_Code' );
editor.addShortcut( 'ctrl+s', '', function() { editor.addShortcut( 'ctrl+s', '', function() {
if ( typeof wp !== 'undefined' && wp.autosave ) { if ( typeof wp !== 'undefined' && wp.autosave ) {
wp.autosave.server.triggerSave(); wp.autosave.server.triggerSave();