Make WordPress Core

Changeset 23154


Ignore:
Timestamp:
12/10/2012 10:12:47 AM (14 years ago)
Author:
nacin
Message:

Restore the duck punch of TinyMCE's schema from [23120], along with updated rules for all HTML5 elements, as painstakingly audited against the HTML5 spec.

Remove conflicting and unnecessary code in the WP TinyMCE plugin.

Fixes all known regressions when working with the embed, object, video, audio, source, and param elements in TinyMCE.

props markjaquith, koopersmith.
fixes #22790, #22842.

Merges [23153] to the 3.5 branch.

Location:
branches/3.5/wp-includes/js/tinymce
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3.5/wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js

    r23146 r23154  
    134134                                        }
    135135                                }
    136                         });
    137 
    138                         // Extend <object> and <embed> (#WP22790)
    139                         ed.onPreInit.add(function(ed) {
    140                                 ed.schema.addValidElements('object[*],param[id|name|value|valuetype|type],embed[*]');
    141                                 ed.schema.addValidChildren('+object[embed]');
    142136                        });
    143137
  • branches/3.5/wp-includes/js/tinymce/wp-tinymce-schema.js

    r23152 r23154  
    11/**
    2  * Schema.js
     2 * TinyMCE Schema.js
     3 *
     4 * Duck-punched by WordPress core to support a sane schema superset.
    35 *
    46 * Copyright, Moxiecode Systems AB
    … …  
    5759                if (!html5) {
    5860                        html5 = mapCache.html5 = unpack({
    59                                         A : 'id|accesskey|class|dir|draggable|item|hidden|itemprop|role|spellcheck|style|subject|title|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup',
    60                                         B : '#|a|abbr|area|audio|b|bdo|br|button|canvas|cite|code|command|datalist|del|dfn|em|embed|i|iframe|img|input|ins|kbd|keygen|label|link|map|mark|meta|' +
    61                                                 'meter|noscript|object|output|progress|q|ruby|samp|script|select|small|span|strong|sub|sup|svg|textarea|time|var|video|wbr',
    62                                         C : '#|a|abbr|area|address|article|aside|audio|b|bdo|blockquote|br|button|canvas|cite|code|command|datalist|del|details|dfn|dialog|div|dl|em|embed|fieldset|' +
    63                                                 'figure|footer|form|h1|h2|h3|h4|h5|h6|header|hgroup|hr|i|iframe|img|input|ins|kbd|keygen|label|link|map|mark|menu|meta|meter|nav|noscript|ol|object|output|' +
    64                                                 'p|pre|progress|q|ruby|samp|script|section|select|small|span|strong|style|sub|sup|svg|table|textarea|time|ul|var|video'
     61                                        A : 'accesskey|class|contextmenu|dir|draggable|dropzone|hidden|id|inert|itemid|itemprop|itemref|itemscope|itemtype|lang|spellcheck|style|tabindex|title|translate|item|role|subject|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup',
     62                                        B : '#|a|abbr|area|audio|b|bdi|bdo|br|button|canvas|cite|code|command|data|datalist|del|dfn|em|embed|i|iframe|img|input|ins|kbd|keygen|label|link|map|mark|math|meta|meter|noscript|object|output|progress|q|ruby|s|samp|script|select|small|span|strong|sub|sup|svg|textarea|time|u|var|video|wbr',
     63                                        C : '#|a|abbr|area|address|article|aside|audio|b|bdi|bdo|blockquote|br|button|canvas|cite|code|command|data|datalist|del|details|dfn|dialog|div|dl|em|embed|fieldset|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hgroup|hr|i|iframe|img|input|ins|kbd|keygen|label|link|map|mark|math|menu|meta|meter|nav|noscript|ol|object|output|p|pre|progress|q|ruby|s|samp|script|section|select|small|span|strong|style|sub|sup|svg|table|textarea|time|u|ul|var|video|wbr'
    6564                                }, 'html[A|manifest][body|head]' +
    6665                                        'head[A][base|command|link|meta|noscript|script|style|title]' +
    6766                                        'title[A][#]' +
    6867                                        'base[A|href|target][]' +
    69                                         'link[A|href|rel|media|type|sizes][]' +
     68                                        'link[A|href|rel|media|type|sizes|crossorigin|hreflang][]' +
    7069                                        'meta[A|http-equiv|name|content|charset][]' +
    7170                                        'style[A|type|media|scoped][#]' +
    72                                         'script[A|charset|type|src|defer|async][#]' +
     71                                        'script[A|charset|type|src|defer|async|crossorigin][#]' +
    7372                                        'noscript[A][C]' +
    74                                         'body[A][C]' +
     73                                        'body[A|onafterprint|onbeforeprint|onbeforeunload|onblur|onerror|onfocus|onfullscreenchange|onfullscreenerror|onhashchange|onload|onmessage|onoffline|ononline|onpagehide|onpageshow|onpopstate|onresize|onscroll|onstorage|onunload][C]' +
    7574                                        'section[A][C]' +
    7675                                        'nav[A][C]' +
    … …  
    9089                                        'br[A][]' +
    9190                                        'pre[A][B]' +
    92                                         'dialog[A][dd|dt]' +
     91                                        'dialog[A|open][C|dd|dt]' +
    9392                                        'blockquote[A|cite][C]' +
    9493                                        'ol[A|start|reversed][li]' +
    … …  
    9695                                        'li[A|value][C]' +
    9796                                        'dl[A][dd|dt]' +
    98                                         'dt[A][B]' +
     97                                        'dt[A][C|B]' +
    9998                                        'dd[A][C]' +
    100                                         'a[A|href|target|ping|rel|media|type][B]' +
     99                                        'a[A|href|target|download|ping|rel|media|type][C|B]' +
    101100                                        'em[A][B]' +
    102101                                        'strong[A][B]' +
    103102                                        'small[A][B]' +
     103                                        's[A][B]' +
    104104                                        'cite[A][B]' +
    105105                                        'q[A|cite][B]' +
    … …  
    114114                                        'i[A][B]' +
    115115                                        'b[A][B]' +
     116                                        'u[A][B]' +
    116117                                        'mark[A][B]' +
    117118                                        'progress[A|value|max][B]' +
    … …  
    121122                                        'rt[A][B]' +
    122123                                        'rp[A][B]' +
     124                                        'bdi[A][B]' +
    123125                                        'bdo[A][B]' +
    124126                                        'span[A][B]' +
    125                                         'ins[A|cite|datetime][B]' +
    126                                         'del[A|cite|datetime][B]' +
     127                                        'ins[A|cite|datetime][C|B]' +
     128                                        'del[A|cite|datetime][C|B]' +
    127129                                        'figure[A][C|legend|figcaption]' +
    128130                                        'figcaption[A][C]' +
    129                                         'img[A|alt|src|height|width|usemap|ismap][]' +
    130                                         'iframe[A|name|src|height|width|sandbox|seamless][]' +
     131                                        'img[A|alt|src|srcset|crossorigin|usemap|ismap|width|height][]' +
     132                                        'iframe[A|name|src|srcdoc|height|width|sandbox|seamless|allowfullscreen][C|B]' +
    131133                                        'embed[A|src|height|width|type][]' +
    132                                         'object[A|data|type|height|width|usemap|name|form|classid][param]' +
     134                                        'object[A|data|type|typemustmatch|name|usemap|form|width|height][C|B|param]' +
    133135                                        'param[A|name|value][]' +
    134                                         'details[A|open][C|legend]' +
    135                                         'command[A|type|label|icon|disabled|checked|radiogroup][]' +
     136                                        'summary[A][B]' +
     137                                        'details[A|open][C|legend|summary]' +
     138                                        'command[A|type|label|icon|disabled|checked|radiogroup|command][]' +
    136139                                        'menu[A|type|label][C|li]' +
    137140                                        'legend[A][C|B]' +
    138141                                        'div[A][C]' +
    139142                                        'source[A|src|type|media][]' +
    140                                         'audio[A|src|autobuffer|autoplay|loop|controls][source]' +
    141                                         'video[A|src|autobuffer|autoplay|loop|controls|width|height|poster][source]' +
     143                                        'track[A|kind|src|srclang|label|default][]' +
     144                                        'audio[A|src|autobuffer|autoplay|loop|controls|crossorigin|preload|mediagroup|muted][C|source|track]' +
     145                                        'video[A|src|autobuffer|autoplay|loop|controls|width|height|poster|crossorigin|preload|mediagroup|muted][C|source|track]' +
    142146                                        'hr[A][]' +
    143147                                        'form[A|accept-charset|action|autocomplete|enctype|method|name|novalidate|target][C]' +
    144148                                        'fieldset[A|disabled|form|name][C|legend]' +
    145149                                        'label[A|form|for][B]' +
    146                                         'input[A|type|accept|alt|autocomplete|autofocus|checked|disabled|form|formaction|formenctype|formmethod|formnovalidate|formtarget|height|list|max|maxlength|min|' +
    147                                                 'multiple|pattern|placeholder|readonly|required|size|src|step|width|files|value|name][]' +
    148                                         'button[A|autofocus|disabled|form|formaction|formenctype|formmethod|formnovalidate|formtarget|name|value|type][B]' +
    149                                         'select[A|autofocus|disabled|form|multiple|name|size][option|optgroup]' +
     150                                        'input[A|type|accept|alt|autocomplete|autofocus|checked|dirname|disabled|form|formaction|formenctype|formmethod|formnovalidate|formtarget|height|inputmode|list|max|maxlength|min|multiple|name|pattern|placeholder|readonly|required|size|src|step|value|width|files][]' +
     151                                        'button[A|autofocus|disabled|form|formaction|formenctype|formmethod|formnovalidate|formtarget|name|type|value][B]' +
     152                                        'select[A|autofocus|disabled|form|multiple|name|required|size][option|optgroup]' +
     153                                        'data[A|value][B]' +
    150154                                        'datalist[A][B|option]' +
    151155                                        'optgroup[A|disabled|label][option]' +
    152                                         'option[A|disabled|selected|label|value][]' +
    153                                         'textarea[A|autofocus|disabled|form|maxlength|name|placeholder|readonly|required|rows|cols|wrap][]' +
     156                                        'option[A|disabled|selected|label|value][#]' +
     157                                        'textarea[A|autocomplete|autofocus|cols|dirname|disabled|form|inputmode|maxlength|name|placeholder|readonly|required|rows|wrap][#]' +
    154158                                        'keygen[A|autofocus|challenge|disabled|form|keytype|name][]' +
    155159                                        'output[A|for|form|name][B]' +
    156                                         'canvas[A|width|height][]' +
    157                                         'map[A|name][B|C]' +
    158                                         'area[A|shape|coords|href|alt|target|media|rel|ping|type][]' +
    159                                         'mathml[A][]' +
     160                                        'canvas[A|width|height][a|button|input]' +
     161                                        'map[A|name][C|B]' +
     162                                        'area[A|alt|coords|shape|href|target|download|ping|rel|media|hreflang|type][]' +
     163                                        'math[A][]' +
    160164                                        'svg[A][]' +
    161                                         'table[A|border][caption|colgroup|thead|tfoot|tbody|tr]' +
     165                                        'table[A][caption|colgroup|thead|tfoot|tbody|tr]' +
    162166                                        'caption[A][C]' +
    163167                                        'colgroup[A|span][col]' +
    … …  
    167171                                        'tbody[A][tr]' +
    168172                                        'tr[A][th|td]' +
    169                                         'th[A|headers|rowspan|colspan|scope][B]' +
     173                                        'th[A|headers|rowspan|colspan|scope][C]' +
    170174                                        'td[A|headers|rowspan|colspan][C]' +
    171175                                        'wbr[A][]'
    … …  
    308312
    309313        /**
     314         * WordPress Core
     315         *
     316         * Returns a schema that is the result of a deep merge between the HTML5
     317         * and HTML4 schemas.
     318         */
     319        function getSaneSchema() {
     320                var cachedMapCache = mapCache,
     321                        html5, html4;
     322
     323                if ( mapCache.sane )
     324                        return mapCache.sane;
     325
     326                // Bust the mapCache so we're not dealing with the other schema objects.
     327                mapCache = {};
     328                html5 = getHTML5();
     329                html4 = getHTML4();
     330                mapCache = cachedMapCache;
     331
     332                each( html4, function( html4settings, tag ) {
     333                        var html5settings = html5[ tag ],
     334                                difference = [];
     335
     336                        // Merge tags missing in HTML5 mode.
     337                        if ( ! html5settings ) {
     338                                html5[ tag ] = html4settings;
     339                                return;
     340                        }
     341
     342                        // Merge attributes missing from this HTML5 tag.
     343                        each( html4settings.attributes, function( attribute, key ) {
     344                                if ( ! html5settings.attributes[ key ] )
     345                                        html5settings.attributes[ key ] = attribute;
     346                        });
     347
     348                        // Merge any missing attributes into the attributes order.
     349                        each( html4settings.attributesOrder, function( key ) {
     350                                if ( -1 === tinymce.inArray( html5settings.attributesOrder, key ) )
     351                                        difference.push( key );
     352                        });
     353
     354                        html5settings.attributesOrder = html5settings.attributesOrder.concat( difference );
     355
     356                        // Merge children missing from this HTML5 tag.
     357                        each( html4settings.children, function( child, key ) {
     358                                if ( ! html5settings.children[ key ] )
     359                                        html5settings.children[ key ] = child;
     360                        });
     361                });
     362
     363                return mapCache.sane = html5;
     364        }
     365
     366        /**
    310367         * Schema validator class.
    311368         *
    … …  
    356413
    357414                settings = settings || {};
    358                 schemaItems = settings.schema == "html5" ? getHTML5() : getHTML4();
     415
     416                /**
     417                 * WordPress core uses a sane schema in place of the default "HTML5" schema.
     418                 */
     419                schemaItems = settings.schema == "html5" ? getSaneSchema() : getHTML4();
    359420
    360421                // Allow all elements and attributes if verify_html is set to false
Note: See TracChangeset for help on using the changeset viewer.