Make WordPress Core

Ticket #6331: 6331.2.diff

File 6331.2.diff, 5.4 KB (added by miyauchi, 11 years ago)

change plugin name and some fix

  • src/wp-includes/class-wp-editor.php

     
    243243                                                'wplink',
    244244                                                'wpdialogs',
    245245                                                'wpview',
     246                                                'wpcode',
    246247                                        ) ) );
    247248
    248249                                        if ( ( $key = array_search( 'spellchecker', $plugins ) ) !== false ) {
     
    397398                                $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 );
    398399                                $mce_buttons_2 = $mce_buttons_3 = $mce_buttons_4 = array();
    399400                        } 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);
    401402                                $mce_buttons_2 = apply_filters('mce_buttons_2', array( 'formatselect', 'underline', 'alignjustify', 'forecolor', 'pastetext', 'removeformat', 'charmap', 'outdent', 'indent', 'undo', 'redo', 'wp_help' ), $editor_id);
    402403                                $mce_buttons_3 = apply_filters('mce_buttons_3', array(), $editor_id);
    403404                                $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
     3tinymce.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/*global tinymce:true */
     65
     66tinymce.PluginManager.add('wpcode', function(editor) {
     67        function showDialog() {
     68                if (editor.selection.isCollapsed()) {
     69                        editor.windowManager.open({
     70                                title: "Source code",
     71                                body: {
     72                                        type: 'textbox',
     73                                        name: 'wpcode',
     74                                        multiline: true,
     75                                        minWidth: editor.getParam("code_dialog_width", 600),
     76                                        minHeight: editor.getParam("code_dialog_height", Math.min(tinymce.DOM.getViewPort().h - 200, 500)),
     77                                        value: "",
     78                                        spellcheck: false,
     79                                        style: 'direction: ltr; text-align: left'
     80                                },
     81                                onSubmit: function(e) {
     82                                        // We get a lovely "Wrong document" error in IE 11 if we
     83                                        // don't move the focus to the editor before creating an undo
     84                                        // transation since it tries to make a bookmark for the current selection
     85                                        editor.focus();
     86
     87                                        editor.undoManager.transact(function() {
     88                                                editor.insertContent('<pre>' + escapeHtml(e.data.wpcode) + '</pre>');
     89                                        });
     90
     91                                        editor.selection.setCursorLocation();
     92                                        editor.nodeChanged();
     93                                }
     94                        });
     95                } else {
     96                        editor.undoManager.transact(function() {
     97                                tinymce.activeEditor.selection.setNode(tinymce.activeEditor.dom.create(
     98                                        'code',
     99                                        {},
     100                                        editor.selection.getContent()
     101                                ));
     102                        });
     103                }
     104        }
     105
     106        function escapeHtml(str) {
     107                var div = document.createElement('div');
     108                div.appendChild(document.createTextNode(str));
     109                return div.innerHTML;
     110        };
     111
     112        editor.addCommand("mceCodeEditor", showDialog);
     113
     114        editor.addButton('wpcode', {
     115                icon: 'code',
     116                tooltip: 'Source code',
     117                onclick: showDialog
     118        });
     119
     120        editor.addMenuItem('wpcode', {
     121                icon: 'code',
     122                text: 'Source code',
     123                context: 'tools',
     124                onclick: showDialog
     125        });
     126});