Ticket #6331: 6331.3.diff
File 6331.3.diff, 3.6 KB (added by , 11 years ago) |
---|
-
src/wp-includes/class-wp-editor.php
243 243 'wplink', 244 244 'wpdialogs', 245 245 'wpview', 246 'wpcode', 246 247 ) ) ); 247 248 248 249 if ( ( $key = array_search( 'spellchecker', $plugins ) ) !== false ) { … … 397 398 $mce_buttons = apply_filters( 'teeny_mce_buttons', array('bold', 'italic', 'underline', 'blockquote', 'strikethrough', 'bullist', 'numlist', 'alignleft', 'aligncenter', 'alignright', 'undo', 'redo', 'link', 'unlink', 'fullscreen'), $editor_id ); 398 399 $mce_buttons_2 = $mce_buttons_3 = $mce_buttons_4 = array(); 399 400 } else { 400 $mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', ' bullist', 'numlist', 'blockquote', 'hr', 'alignleft', 'aligncenter', 'alignright', 'link', 'unlink', 'wp_more', 'spellchecker', 'fullscreen', 'wp_adv' ), $editor_id);401 $mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', 'wpcode', 'bullist', 'numlist', 'blockquote', 'hr', 'alignleft', 'aligncenter', 'alignright', 'link', 'unlink', 'wp_more', 'spellchecker', 'fullscreen', 'wp_adv' ), $editor_id); 401 402 $mce_buttons_2 = apply_filters('mce_buttons_2', array( 'formatselect', 'underline', 'alignjustify', 'forecolor', 'pastetext', 'removeformat', 'charmap', 'outdent', 'indent', 'undo', 'redo', 'wp_help' ), $editor_id); 402 403 $mce_buttons_3 = apply_filters('mce_buttons_3', array(), $editor_id); 403 404 $mce_buttons_4 = apply_filters('mce_buttons_4', array(), $editor_id); -
src/wp-includes/js/tinymce/plugins/wpcode/plugin.js
1 /*global tinymce:true */ 2 3 tinymce.PluginManager.add('wpcode', function(editor) { 4 function showDialog() { 5 if (editor.selection.isCollapsed()) { 6 editor.windowManager.open({ 7 title: "Source code", 8 body: { 9 type: 'textbox', 10 name: 'wpcode', 11 multiline: true, 12 minWidth: editor.getParam("code_dialog_width", 600), 13 minHeight: editor.getParam("code_dialog_height", Math.min(tinymce.DOM.getViewPort().h - 200, 500)), 14 value: "", 15 spellcheck: false, 16 style: 'direction: ltr; text-align: left' 17 }, 18 onSubmit: function(e) { 19 // We get a lovely "Wrong document" error in IE 11 if we 20 // don't move the focus to the editor before creating an undo 21 // transation since it tries to make a bookmark for the current selection 22 editor.focus(); 23 24 editor.undoManager.transact(function() { 25 editor.insertContent('<pre>' + escapeHtml(e.data.wpcode) + '</pre>'); 26 }); 27 28 editor.selection.setCursorLocation(); 29 editor.nodeChanged(); 30 } 31 }); 32 } else { 33 editor.undoManager.transact(function() { 34 tinymce.activeEditor.selection.setNode(tinymce.activeEditor.dom.create( 35 'code', 36 {}, 37 editor.selection.getContent() 38 )); 39 }); 40 } 41 } 42 43 function escapeHtml(str) { 44 var div = document.createElement('div'); 45 div.appendChild(document.createTextNode(str)); 46 return div.innerHTML; 47 }; 48 49 editor.addCommand("mceCodeEditor", showDialog); 50 51 editor.addButton('wpcode', { 52 icon: 'code', 53 tooltip: 'Source code', 54 onclick: showDialog 55 }); 56 57 editor.addMenuItem('wpcode', { 58 icon: 'code', 59 text: 'Source code', 60 context: 'tools', 61 onclick: showDialog 62 }); 63 }); 64