From 045c767e0af4ca404dc6df752c344db3a58d7c58 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Mon, 1 Sep 2014 19:02:08 +0000 Subject: [PATCH] TinyMCE: fix the 'tabfocus' plugin to check if default is prevented on pressing tab, bind the events later so other plugins can cancel them. Merged upstream in https://github.com/tinymce/tinymce/commit/86098b348582e1544cc208db25954d31755e6d13 together with another change. Fixes #29430 git-svn-id: https://develop.svn.wordpress.org/trunk@29657 602fd350-edb4-49c9-b593-d223f7449a82 --- .../js/tinymce/plugins/tabfocus/plugin.js | 19 ++++++++++--------- .../js/tinymce/plugins/tabfocus/plugin.min.js | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/wp-includes/js/tinymce/plugins/tabfocus/plugin.js b/src/wp-includes/js/tinymce/plugins/tabfocus/plugin.js index 0d81497f5f..47ddfdee17 100644 --- a/src/wp-includes/js/tinymce/plugins/tabfocus/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/tabfocus/plugin.js @@ -22,7 +22,7 @@ tinymce.PluginManager.add('tabfocus', function(editor) { function tabHandler(e) { var x, el, v, i; - if (e.keyCode !== 9 || e.ctrlKey || e.altKey || e.metaKey) { + if (e.keyCode !== 9 || e.ctrlKey || e.altKey || e.metaKey || e.isDefaultPrevented()) { return; } @@ -112,13 +112,14 @@ tinymce.PluginManager.add('tabfocus', function(editor) { // Remove default tabIndex in inline mode tinymce.DOM.setAttrib(editor.getBody(), 'tabIndex', null); } + + editor.on('keyup', tabCancel); + + // Add later so other plugins can preventDefault() + if (tinymce.Env.gecko) { + editor.on('keypress keydown', tabHandler); + } else { + editor.on('keydown', tabHandler); + } }); - - editor.on('keyup', tabCancel); - - if (tinymce.Env.gecko) { - editor.on('keypress keydown', tabHandler); - } else { - editor.on('keydown', tabHandler); - } }); diff --git a/src/wp-includes/js/tinymce/plugins/tabfocus/plugin.min.js b/src/wp-includes/js/tinymce/plugins/tabfocus/plugin.min.js index 68fe35e35a..2e6dbd1f60 100644 --- a/src/wp-includes/js/tinymce/plugins/tabfocus/plugin.min.js +++ b/src/wp-includes/js/tinymce/plugins/tabfocus/plugin.min.js @@ -1 +1 @@ -tinymce.PluginManager.add("tabfocus",function(e){function n(e){9!==e.keyCode||e.ctrlKey||e.altKey||e.metaKey||e.preventDefault()}function t(n){function t(n){function t(e){return"BODY"===e.nodeName||"hidden"!=e.type&&"none"!=e.style.display&&"hidden"!=e.style.visibility&&t(e.parentNode)}function r(e){return e.tabIndex||"INPUT"==e.nodeName||"TEXTAREA"==e.nodeName}function c(e){return!r(e)&&"-1"!=e.getAttribute("tabindex")&&t(e)}if(u=i.select(":input:enabled,*[tabindex]:not(iframe)"),o(u,function(n,t){return n.id==e.id?(a=t,!1):void 0}),n>0){for(d=a+1;d=0;d--)if(c(u[d]))return u[d];return null}var a,u,c,d;if(!(9!==n.keyCode||n.ctrlKey||n.altKey||n.metaKey)&&(c=r(e.getParam("tab_focus",e.getParam("tabfocus_elements",":prev,:next"))),1==c.length&&(c[1]=c[0],c[0]=":prev"),u=n.shiftKey?":prev"==c[0]?t(-1):i.get(c[0]):":next"==c[1]?t(1):i.get(c[1]))){var y=tinymce.get(u.id||u.name);u.id&&y?y.focus():window.setTimeout(function(){tinymce.Env.webkit||window.focus(),u.focus()},10),n.preventDefault()}}var i=tinymce.DOM,o=tinymce.each,r=tinymce.explode;e.on("init",function(){e.inline&&tinymce.DOM.setAttrib(e.getBody(),"tabIndex",null)}),e.on("keyup",n),tinymce.Env.gecko?e.on("keypress keydown",t):e.on("keydown",t)}); \ No newline at end of file +tinymce.PluginManager.add("tabfocus",function(a){function b(a){9!==a.keyCode||a.ctrlKey||a.altKey||a.metaKey||a.preventDefault()}function c(b){function c(b){function c(a){return"BODY"===a.nodeName||"hidden"!=a.type&&"none"!=a.style.display&&"hidden"!=a.style.visibility&&c(a.parentNode)}function f(a){return a.tabIndex||"INPUT"==a.nodeName||"TEXTAREA"==a.nodeName}function i(a){return!f(a)&&"-1"!=a.getAttribute("tabindex")&&c(a)}if(h=d.select(":input:enabled,*[tabindex]:not(iframe)"),e(h,function(b,c){return b.id==a.id?(g=c,!1):void 0}),b>0){for(j=g+1;j=0;j--)if(i(h[j]))return h[j];return null}var g,h,i,j;if(!(9!==b.keyCode||b.ctrlKey||b.altKey||b.metaKey||b.isDefaultPrevented())&&(i=f(a.getParam("tab_focus",a.getParam("tabfocus_elements",":prev,:next"))),1==i.length&&(i[1]=i[0],i[0]=":prev"),h=b.shiftKey?":prev"==i[0]?c(-1):d.get(i[0]):":next"==i[1]?c(1):d.get(i[1]))){var k=tinymce.get(h.id||h.name);h.id&&k?k.focus():window.setTimeout(function(){tinymce.Env.webkit||window.focus(),h.focus()},10),b.preventDefault()}}var d=tinymce.DOM,e=tinymce.each,f=tinymce.explode;a.on("init",function(){a.inline&&tinymce.DOM.setAttrib(a.getBody(),"tabIndex",null),a.on("keyup",b),tinymce.Env.gecko?a.on("keypress keydown",c):a.on("keydown",c)})}); \ No newline at end of file