Make WordPress Core

Ticket #21812: 21812.patch

File 21812.patch, 9.3 KB (added by azaozz, 12 years ago)
  • wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js

     
    77
    88        tinymce.create('tinymce.plugins.WordPress', {
    99                mceTout : 0,
     10                previews : {i: 0},
     11                reg_previews : [],
    1012
    1113                init : function(ed, url) {
    12                         var t = this, tbId = ed.getParam('wordpress_adv_toolbar', 'toolbar2'), last = 0, moreHTML, nextpageHTML, closeOnClick, mod_key;
     14                        var t = this, tbId = ed.getParam('wordpress_adv_toolbar', 'toolbar2'), last = 0, moreHTML, nextpageHTML, closeOnClick, mod_key,
     15                        wpPreview, each = tinymce.each;
     16
    1317                        moreHTML = '<img src="' + url + '/img/trans.gif" class="mceWPmore mceItemNoResize" title="'+ed.getLang('wordpress.wp_more_alt')+'" />';
    1418                        nextpageHTML = '<img src="' + url + '/img/trans.gif" class="mceWPnextpage mceItemNoResize" title="'+ed.getLang('wordpress.wp_page_alt')+'" />';
    1519
    16                         if ( getUserSetting('hidetb', '0') == '1' )
     20                        t.ed = ed;
     21
     22                        if ( typeof(getUserSetting) == 'function' && getUserSetting('hidetb', '0') == '1' )
    1723                                ed.settings.wordpress_adv_hidden = 0;
    1824
    1925                        // Hides the specified toolbar and resizes the iframe
     
    251257                        // Add custom shortcuts
    252258                        mod_key = 'alt+shift';
    253259
    254                 //      if ( tinymce.isGecko ) // disable for mow, too many shortcuts conflicts
    255                 //              mod_key = 'ctrl+alt';
    256 
    257260                        ed.addShortcut(mod_key + '+c', 'justifycenter_desc', 'JustifyCenter');
    258261                        ed.addShortcut(mod_key + '+r', 'justifyright_desc', 'JustifyRight');
    259262                        ed.addShortcut(mod_key + '+l', 'justifyleft_desc', 'JustifyLeft');
     
    313316                        // close popups when clicking on the background
    314317                        tinymce.dom.Event.remove(document.body, 'click', closeOnClick);
    315318                        tinymce.dom.Event.add(document.body, 'click', closeOnClick);
     319
     320
     321                        /* testing */
     322                        ed.onPreInit.add( function(ed){
     323                                ed.schema.addValidElements('div[*]'); // so we can set contenteditable=false
     324
     325                                if ( typeof(jQuery) != 'undefined' )
     326                                        jQuery(document).trigger( 'wp_add_mce_previews', ed );
     327                        });
     328                        /*
     329                        // runs on paste and on inserting nodes/html, doube/triple runs??
     330                        ed.onInit.add(function(ed) {
     331                                ed.selection.onSetContent.add(function(ed, o) {
     332                                        if ( o.context && t.reg_previews.length ) {
     333                                                each( ed.dom.select(o.context), function(el) {
     334                                                        each( t.reg_previews, function(args){
     335                                                                el.textContent = wpPreview(el.textContent, args);
     336                                                        });
     337                                                });
     338                                        }
     339                                });
     340                        });
     341                        */
     342                        // runs every time content is loaded in the editor
     343                        ed.onBeforeSetContent.add(function(ed, o) {
     344                                if ( t.reg_previews.length && o.content ) {
     345                                        each( t.reg_previews, function(args){
     346                                                o.content = wpPreview(o.content, args);
     347                                        });
     348                                }
     349                        });
     350
     351                        ed.onPostProcess.add(function(ed, o) {
     352                                if ( ( o.get || o.save ) && o.content.indexOf('data-wp-preview') > -1 ) {
     353                                        o.content = o.content.replace(/<div[^>]+data-wp-preview="([^"]+)"[\s\S]+?<\/div><div data-wp-preview-end[^<]+<\/div><\/div>/g, function(a, b){
     354                                                // can identify the registered preview and fire a callback here
     355                                                return '<p>'+decodeURIComponent(b)+'</p>';
     356                                        });
     357                                }
     358                        });
     359
     360                        // register all previews
     361                        ed.wpPreviewRegister = function(args) {
     362
     363console.log( 'wpPreviewRegister' );
     364
     365                                t.reg_previews.push(args);
     366                        };
     367
     368                        ed.onSetContent.add(function(ed){
     369                                // go through the added previews and fire callbacks
     370
     371console.log( t.previews );
     372
     373                                each(t.previews, function(args, div_id){
     374                                        var node = args ? ed.dom.select('#'+div_id) : null;
     375
     376console.log( 'onSetContent' );
     377console.log( args );
     378
     379
     380                                        if ( !args || !node )
     381                                                return;
     382
     383                                        if ( args.node_callback ) {
     384                                                args.node_callback.call( t, { node: node[0], div_id: div_id } );
     385                                        }
     386                                        if ( args.onmousedown ) {
     387                                                ed.dom.events.add( node, 'mousedown', args.onmousedown );
     388                                        }
     389                                        if ( args.onmouseup ) {
     390                                                ed.dom.events.add( node, 'mouseup', args.onmouseup );
     391                                        }
     392                                        if ( args.onclick ) {
     393                                                ed.dom.events.add( node, 'click', args.onclick );
     394                                        }
     395                                });
     396                        });
     397
     398                        /*
     399                        args = {
     400                                preview_regexp: /\[gallery[^\]]*\]/,
     401                                str_callback: function(obj){ console.log('str_callback'); console.log(obj); return obj.original+' 123 ' },
     402                                node_callback: function(obj){ console.log('node_callback'); console.log(obj) },
     403                                onmousedown: function(e){ console.log('onmousedown'); console.log(e) },
     404                                onmouseup: function(e){ console.log('onmouseup'); console.log(e) },
     405                                onclick: function(e){ console.log('onclick'); console.log(e) }
     406                        }
     407                        */
     408                        wpPreview = function(content, args) {
     409                                var self = t, previews = self.previews, div_id, regex;
     410
     411                                if ( args.preview_regexp ) {
     412                                        regex = new RegExp( '(?:<p>\\s*)?(' + args.preview_regexp.source + ')(?:\s*<\/p>)?', 'g' );
     413
     414                                        return content.replace(regex, function(a, orig_str){
     415                                                var html, div_id;
     416
     417                                                previews.i++;
     418                                                div_id = 'wp_mce_preview_' + previews.i;
     419                                                // ed, self or this?
     420                                                orig_str = args.str_callback.call( self, { original: orig_str, div_id: div_id } );
     421                                                previews[div_id] = args;
     422
     423                                                html = '<div id="'+ div_id +'" data-wp-preview="'+ encodeURIComponent(orig_str) +'" class="wp-preview-wrap" contenteditable="false">' +
     424                                                        '<div class="wp-preview-blocker"><br></div>' +
     425                                                        '<div class="wp-preview">'+ orig_str +'</div>' + // add inner wrapper so the preview node(s) can be appended there without disturbing the blocker and end divs?
     426                                                        '<div data-wp-preview-end="1">\uFEFF</div></div>';
     427
     428                                                return html;
     429                                        });
     430                                }
     431                        };
    316432                },
    317433
    318434                getInfo : function() {
     
    418534
    419535                        // Replace images with morebreak
    420536                        ed.onPostProcess.add(function(ed, o) {
    421                                 if (o.get)
     537                                if ( o.get ) {
    422538                                        o.content = o.content.replace(/<img[^>]+>/g, function(im) {
    423                                                 if (im.indexOf('class="mceWPmore') !== -1) {
    424                                                         var m, moretext = (m = im.match(/alt="(.*?)"/)) ? m[1] : '';
     539                                                if ( im.indexOf('class="mceWPmore') !== -1 ) {
     540                                                        var m, moretext = ( m = im.match(/alt="(.*?)"/) ) ? m[1] : '';
    425541                                                        im = '<!--more'+moretext+'-->';
    426542                                                }
    427                                                 if (im.indexOf('class="mceWPnextpage') !== -1)
     543                                                if ( im.indexOf('class="mceWPnextpage') !== -1 )
    428544                                                        im = '<!--nextpage-->';
    429545
    430546                                                return im;
    431547                                        });
     548                                }
    432549                        });
    433550
    434551                        // Set active buttons if user selected pagebreak or more break
  • wp-includes/js/tinymce/plugins/wpgallery/editor_plugin_src.js

     
    2626                                if ( e.target.nodeName == 'IMG' && ed.dom.hasClass(e.target, 'wpGallery') )
    2727                                        ed.plugins.wordpress._showButtons(e.target, 'wp_gallerybtns');
    2828                        });
    29 
     29/*
    3030                        ed.onBeforeSetContent.add(function(ed, o) {
    3131                                o.content = t._do_gallery(o.content);
    3232                        });
     
    3535                                if (o.get)
    3636                                        o.content = t._get_gallery(o.content);
    3737                        });
     38*/
    3839                },
    3940
    4041                _do_gallery : function(co) {
  • wp-includes/js/tinymce/themes/advanced/skins/wp_theme/content.css

     
    141141        height: 250px;
    142142}
    143143
     144/* Previews */
     145
     146div.wp-preview-blocker {
     147        height: 100%;
     148        width: 100%;
     149        position: absolute;
     150        background: #fff;
     151        opacity: 0.01;
     152        filter: alpha(opacity=1);
     153        top: 0;
     154        left: 0;
     155        bottom: 0;
     156        right: 0;
     157        z-index: 5;
     158}
     159
     160div.wp-preview-blocker.focused {
     161        background-color: #000;
     162        filter: alpha(opacity=25);
     163        opacity: 0.25;
     164}
     165
     166div.wp-preview-wrap {
     167        margin: 10px auto;
     168        position: relative;
     169        -ms-user-select: none;
     170        -moz-user-select: none; /* doesn't work */
     171        -webkit-user-select: none;
     172        user-select: none;
     173}
     174
     175div.wp-preview-wrap div[data-wp-preview-end] {
     176        height: 1em;
     177        margin-top: -1em;
     178}
     179
     180div.wp-preview-wrap .gallery-icon {
     181        margin: 0;
     182}
     183
     184div.wp-preview-wrap .gallery-icon img {
     185        display: block;
     186        margin: 0 auto;
     187        padding: 0;
     188        max-width: 90%;
     189        height: auto;
     190        border: 0;
     191}
     192
     193div.wp-preview-wrap dd.gallery-caption {
     194        margin: 0 6%;
     195        font-size: 12px;
     196}
     197
     198div.wp-preview-wrap div.gallery {
     199        clear: both;
     200}
     201
     202div.wp-preview-wrap div.gallery dl.gallery-item {
     203        float: left;
     204        margin: 10px 0;
     205        padding: 0;
     206}
     207
     208div.wp-preview-wrap div.gallery-columns-1 dl.gallery-item {
     209        width: 99%;
     210}
     211
     212div.wp-preview-wrap div.gallery-columns-2 dl.gallery-item {
     213        width: 49.5%;
     214}
     215
     216div.wp-preview-wrap div.gallery-columns-3 dl.gallery-item {
     217        width: 33%;
     218}
     219
     220div.wp-preview-wrap div.gallery-columns-4 dl.gallery-item {
     221        width: 24.75%;
     222}
     223
     224div.wp-preview-wrap div.gallery-columns-5 dl.gallery-item {
     225        width: 19.8%;
     226}
     227
     228div.wp-preview-wrap div.gallery-columns-6 dl.gallery-item {
     229        width: 16.5%;
     230}
     231
     232div.wp-preview-wrap div.gallery-columns-7 dl.gallery-item {
     233        width: 14.2%;
     234}
     235
     236div.wp-preview-wrap div.gallery-columns-8 dl.gallery-item {
     237        width: 12.45%;
     238}
     239
     240div.wp-preview-wrap div.gallery-columns-9 dl.gallery-item {
     241        width: 11.1%;
     242}
     243
     244div.wp-preview-wrap div.gallery-columns-10 dl.gallery-item {
     245        width: 9.99%;
     246}
     247
     248
     249