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. fixes #22842. git-svn-id: http://core.svn.wordpress.org/trunk@23153 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6a4e57204e
commit
a01fc23c10
|
@ -135,12 +135,6 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Extend <object> and <embed> (#WP22790)
|
|
||||||
ed.onPreInit.add(function(ed) {
|
|
||||||
ed.schema.addValidElements('object[*],param[id|name|value|valuetype|type],embed[*]');
|
|
||||||
ed.schema.addValidChildren('+object[embed]');
|
|
||||||
});
|
|
||||||
|
|
||||||
ed.onInit.add(function(ed) {
|
ed.onInit.add(function(ed) {
|
||||||
var bodyClass = ed.getParam('body_class', ''), body = ed.getBody();
|
var bodyClass = ed.getParam('body_class', ''), body = ed.getBody();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Schema.js
|
* TinyMCE Schema.js
|
||||||
|
*
|
||||||
|
* Duck-punched by WordPress core to support a sane schema superset.
|
||||||
*
|
*
|
||||||
* Copyright, Moxiecode Systems AB
|
* Copyright, Moxiecode Systems AB
|
||||||
* Released under LGPL License.
|
* Released under LGPL License.
|
||||||
|
@ -56,22 +58,19 @@
|
||||||
|
|
||||||
if (!html5) {
|
if (!html5) {
|
||||||
html5 = mapCache.html5 = unpack({
|
html5 = mapCache.html5 = unpack({
|
||||||
A : 'id|accesskey|class|dir|draggable|item|hidden|itemprop|role|spellcheck|style|subject|title|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup',
|
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',
|
||||||
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|' +
|
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',
|
||||||
'meter|noscript|object|output|progress|q|ruby|samp|script|select|small|span|strong|sub|sup|svg|textarea|time|var|video|wbr',
|
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'
|
||||||
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|' +
|
|
||||||
'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|' +
|
|
||||||
'p|pre|progress|q|ruby|samp|script|section|select|small|span|strong|style|sub|sup|svg|table|textarea|time|ul|var|video'
|
|
||||||
}, 'html[A|manifest][body|head]' +
|
}, 'html[A|manifest][body|head]' +
|
||||||
'head[A][base|command|link|meta|noscript|script|style|title]' +
|
'head[A][base|command|link|meta|noscript|script|style|title]' +
|
||||||
'title[A][#]' +
|
'title[A][#]' +
|
||||||
'base[A|href|target][]' +
|
'base[A|href|target][]' +
|
||||||
'link[A|href|rel|media|type|sizes][]' +
|
'link[A|href|rel|media|type|sizes|crossorigin|hreflang][]' +
|
||||||
'meta[A|http-equiv|name|content|charset][]' +
|
'meta[A|http-equiv|name|content|charset][]' +
|
||||||
'style[A|type|media|scoped][#]' +
|
'style[A|type|media|scoped][#]' +
|
||||||
'script[A|charset|type|src|defer|async][#]' +
|
'script[A|charset|type|src|defer|async|crossorigin][#]' +
|
||||||
'noscript[A][C]' +
|
'noscript[A][C]' +
|
||||||
'body[A][C]' +
|
'body[A|onafterprint|onbeforeprint|onbeforeunload|onblur|onerror|onfocus|onfullscreenchange|onfullscreenerror|onhashchange|onload|onmessage|onoffline|ononline|onpagehide|onpageshow|onpopstate|onresize|onscroll|onstorage|onunload][C]' +
|
||||||
'section[A][C]' +
|
'section[A][C]' +
|
||||||
'nav[A][C]' +
|
'nav[A][C]' +
|
||||||
'article[A][C]' +
|
'article[A][C]' +
|
||||||
|
@ -89,18 +88,19 @@
|
||||||
'p[A][B]' +
|
'p[A][B]' +
|
||||||
'br[A][]' +
|
'br[A][]' +
|
||||||
'pre[A][B]' +
|
'pre[A][B]' +
|
||||||
'dialog[A][dd|dt]' +
|
'dialog[A|open][C|dd|dt]' +
|
||||||
'blockquote[A|cite][C]' +
|
'blockquote[A|cite][C]' +
|
||||||
'ol[A|start|reversed][li]' +
|
'ol[A|start|reversed][li]' +
|
||||||
'ul[A][li]' +
|
'ul[A][li]' +
|
||||||
'li[A|value][C]' +
|
'li[A|value][C]' +
|
||||||
'dl[A][dd|dt]' +
|
'dl[A][dd|dt]' +
|
||||||
'dt[A][B]' +
|
'dt[A][C|B]' +
|
||||||
'dd[A][C]' +
|
'dd[A][C]' +
|
||||||
'a[A|href|target|ping|rel|media|type][B]' +
|
'a[A|href|target|download|ping|rel|media|type][C|B]' +
|
||||||
'em[A][B]' +
|
'em[A][B]' +
|
||||||
'strong[A][B]' +
|
'strong[A][B]' +
|
||||||
'small[A][B]' +
|
'small[A][B]' +
|
||||||
|
's[A][B]' +
|
||||||
'cite[A][B]' +
|
'cite[A][B]' +
|
||||||
'q[A|cite][B]' +
|
'q[A|cite][B]' +
|
||||||
'dfn[A][B]' +
|
'dfn[A][B]' +
|
||||||
|
@ -113,6 +113,7 @@
|
||||||
'sup[A][B]' +
|
'sup[A][B]' +
|
||||||
'i[A][B]' +
|
'i[A][B]' +
|
||||||
'b[A][B]' +
|
'b[A][B]' +
|
||||||
|
'u[A][B]' +
|
||||||
'mark[A][B]' +
|
'mark[A][B]' +
|
||||||
'progress[A|value|max][B]' +
|
'progress[A|value|max][B]' +
|
||||||
'meter[A|value|min|max|low|high|optimum][B]' +
|
'meter[A|value|min|max|low|high|optimum][B]' +
|
||||||
|
@ -120,45 +121,48 @@
|
||||||
'ruby[A][B|rt|rp]' +
|
'ruby[A][B|rt|rp]' +
|
||||||
'rt[A][B]' +
|
'rt[A][B]' +
|
||||||
'rp[A][B]' +
|
'rp[A][B]' +
|
||||||
|
'bdi[A][B]' +
|
||||||
'bdo[A][B]' +
|
'bdo[A][B]' +
|
||||||
'span[A][B]' +
|
'span[A][B]' +
|
||||||
'ins[A|cite|datetime][B]' +
|
'ins[A|cite|datetime][C|B]' +
|
||||||
'del[A|cite|datetime][B]' +
|
'del[A|cite|datetime][C|B]' +
|
||||||
'figure[A][C|legend|figcaption]' +
|
'figure[A][C|legend|figcaption]' +
|
||||||
'figcaption[A][C]' +
|
'figcaption[A][C]' +
|
||||||
'img[A|alt|src|height|width|usemap|ismap][]' +
|
'img[A|alt|src|srcset|crossorigin|usemap|ismap|width|height][]' +
|
||||||
'iframe[A|name|src|height|width|sandbox|seamless][]' +
|
'iframe[A|name|src|srcdoc|height|width|sandbox|seamless|allowfullscreen][C|B]' +
|
||||||
'embed[A|src|height|width|type][]' +
|
'embed[A|src|height|width|type][]' +
|
||||||
'object[A|data|type|height|width|usemap|name|form|classid][param]' +
|
'object[A|data|type|typemustmatch|name|usemap|form|width|height][C|B|param]' +
|
||||||
'param[A|name|value][]' +
|
'param[A|name|value][]' +
|
||||||
'details[A|open][C|legend]' +
|
'summary[A][B]' +
|
||||||
'command[A|type|label|icon|disabled|checked|radiogroup][]' +
|
'details[A|open][C|legend|summary]' +
|
||||||
|
'command[A|type|label|icon|disabled|checked|radiogroup|command][]' +
|
||||||
'menu[A|type|label][C|li]' +
|
'menu[A|type|label][C|li]' +
|
||||||
'legend[A][C|B]' +
|
'legend[A][C|B]' +
|
||||||
'div[A][C]' +
|
'div[A][C]' +
|
||||||
'source[A|src|type|media][]' +
|
'source[A|src|type|media][]' +
|
||||||
'audio[A|src|autobuffer|autoplay|loop|controls][source]' +
|
'track[A|kind|src|srclang|label|default][]' +
|
||||||
'video[A|src|autobuffer|autoplay|loop|controls|width|height|poster][source]' +
|
'audio[A|src|autobuffer|autoplay|loop|controls|crossorigin|preload|mediagroup|muted][C|source|track]' +
|
||||||
|
'video[A|src|autobuffer|autoplay|loop|controls|width|height|poster|crossorigin|preload|mediagroup|muted][C|source|track]' +
|
||||||
'hr[A][]' +
|
'hr[A][]' +
|
||||||
'form[A|accept-charset|action|autocomplete|enctype|method|name|novalidate|target][C]' +
|
'form[A|accept-charset|action|autocomplete|enctype|method|name|novalidate|target][C]' +
|
||||||
'fieldset[A|disabled|form|name][C|legend]' +
|
'fieldset[A|disabled|form|name][C|legend]' +
|
||||||
'label[A|form|for][B]' +
|
'label[A|form|for][B]' +
|
||||||
'input[A|type|accept|alt|autocomplete|autofocus|checked|disabled|form|formaction|formenctype|formmethod|formnovalidate|formtarget|height|list|max|maxlength|min|' +
|
'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][]' +
|
||||||
'multiple|pattern|placeholder|readonly|required|size|src|step|width|files|value|name][]' +
|
'button[A|autofocus|disabled|form|formaction|formenctype|formmethod|formnovalidate|formtarget|name|type|value][B]' +
|
||||||
'button[A|autofocus|disabled|form|formaction|formenctype|formmethod|formnovalidate|formtarget|name|value|type][B]' +
|
'select[A|autofocus|disabled|form|multiple|name|required|size][option|optgroup]' +
|
||||||
'select[A|autofocus|disabled|form|multiple|name|size][option|optgroup]' +
|
'data[A|value][B]' +
|
||||||
'datalist[A][B|option]' +
|
'datalist[A][B|option]' +
|
||||||
'optgroup[A|disabled|label][option]' +
|
'optgroup[A|disabled|label][option]' +
|
||||||
'option[A|disabled|selected|label|value][]' +
|
'option[A|disabled|selected|label|value][#]' +
|
||||||
'textarea[A|autofocus|disabled|form|maxlength|name|placeholder|readonly|required|rows|cols|wrap][]' +
|
'textarea[A|autocomplete|autofocus|cols|dirname|disabled|form|inputmode|maxlength|name|placeholder|readonly|required|rows|wrap][#]' +
|
||||||
'keygen[A|autofocus|challenge|disabled|form|keytype|name][]' +
|
'keygen[A|autofocus|challenge|disabled|form|keytype|name][]' +
|
||||||
'output[A|for|form|name][B]' +
|
'output[A|for|form|name][B]' +
|
||||||
'canvas[A|width|height][]' +
|
'canvas[A|width|height][a|button|input]' +
|
||||||
'map[A|name][B|C]' +
|
'map[A|name][C|B]' +
|
||||||
'area[A|shape|coords|href|alt|target|media|rel|ping|type][]' +
|
'area[A|alt|coords|shape|href|target|download|ping|rel|media|hreflang|type][]' +
|
||||||
'mathml[A][]' +
|
'math[A][]' +
|
||||||
'svg[A][]' +
|
'svg[A][]' +
|
||||||
'table[A|border][caption|colgroup|thead|tfoot|tbody|tr]' +
|
'table[A][caption|colgroup|thead|tfoot|tbody|tr]' +
|
||||||
'caption[A][C]' +
|
'caption[A][C]' +
|
||||||
'colgroup[A|span][col]' +
|
'colgroup[A|span][col]' +
|
||||||
'col[A|span][]' +
|
'col[A|span][]' +
|
||||||
|
@ -166,7 +170,7 @@
|
||||||
'tfoot[A][tr]' +
|
'tfoot[A][tr]' +
|
||||||
'tbody[A][tr]' +
|
'tbody[A][tr]' +
|
||||||
'tr[A][th|td]' +
|
'tr[A][th|td]' +
|
||||||
'th[A|headers|rowspan|colspan|scope][B]' +
|
'th[A|headers|rowspan|colspan|scope][C]' +
|
||||||
'td[A|headers|rowspan|colspan][C]' +
|
'td[A|headers|rowspan|colspan][C]' +
|
||||||
'wbr[A][]'
|
'wbr[A][]'
|
||||||
);
|
);
|
||||||
|
@ -306,6 +310,59 @@
|
||||||
return html4;
|
return html4;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WordPress Core
|
||||||
|
*
|
||||||
|
* Returns a schema that is the result of a deep merge between the HTML5
|
||||||
|
* and HTML4 schemas.
|
||||||
|
*/
|
||||||
|
function getSaneSchema() {
|
||||||
|
var cachedMapCache = mapCache,
|
||||||
|
html5, html4;
|
||||||
|
|
||||||
|
if ( mapCache.sane )
|
||||||
|
return mapCache.sane;
|
||||||
|
|
||||||
|
// Bust the mapCache so we're not dealing with the other schema objects.
|
||||||
|
mapCache = {};
|
||||||
|
html5 = getHTML5();
|
||||||
|
html4 = getHTML4();
|
||||||
|
mapCache = cachedMapCache;
|
||||||
|
|
||||||
|
each( html4, function( html4settings, tag ) {
|
||||||
|
var html5settings = html5[ tag ],
|
||||||
|
difference = [];
|
||||||
|
|
||||||
|
// Merge tags missing in HTML5 mode.
|
||||||
|
if ( ! html5settings ) {
|
||||||
|
html5[ tag ] = html4settings;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Merge attributes missing from this HTML5 tag.
|
||||||
|
each( html4settings.attributes, function( attribute, key ) {
|
||||||
|
if ( ! html5settings.attributes[ key ] )
|
||||||
|
html5settings.attributes[ key ] = attribute;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Merge any missing attributes into the attributes order.
|
||||||
|
each( html4settings.attributesOrder, function( key ) {
|
||||||
|
if ( -1 === tinymce.inArray( html5settings.attributesOrder, key ) )
|
||||||
|
difference.push( key );
|
||||||
|
});
|
||||||
|
|
||||||
|
html5settings.attributesOrder = html5settings.attributesOrder.concat( difference );
|
||||||
|
|
||||||
|
// Merge children missing from this HTML5 tag.
|
||||||
|
each( html4settings.children, function( child, key ) {
|
||||||
|
if ( ! html5settings.children[ key ] )
|
||||||
|
html5settings.children[ key ] = child;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return mapCache.sane = html5;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Schema validator class.
|
* Schema validator class.
|
||||||
*
|
*
|
||||||
|
@ -355,7 +412,11 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
settings = settings || {};
|
settings = settings || {};
|
||||||
schemaItems = settings.schema == "html5" ? getHTML5() : getHTML4();
|
|
||||||
|
/**
|
||||||
|
* WordPress core uses a sane schema in place of the default "HTML5" schema.
|
||||||
|
*/
|
||||||
|
schemaItems = settings.schema == "html5" ? getSaneSchema() : getHTML4();
|
||||||
|
|
||||||
// Allow all elements and attributes if verify_html is set to false
|
// Allow all elements and attributes if verify_html is set to false
|
||||||
if (settings.verify_html === false)
|
if (settings.verify_html === false)
|
||||||
|
|
Loading…
Reference in New Issue