diff --git a/public/javascripts/jstoolbar/jstoolbar.js b/public/javascripts/jstoolbar/jstoolbar.js index 376698f9a..7a3631a1a 100644 --- a/public/javascripts/jstoolbar/jstoolbar.js +++ b/public/javascripts/jstoolbar/jstoolbar.js @@ -21,6 +21,7 @@ */ /* Modified by JP LANG for textile formatting */ +let lastJstPreviewed; function jsToolBar(textarea) { if (!document.createElement) { return; } @@ -507,3 +508,20 @@ jsToolBar.prototype.tableMenu = function(fn){ }); return false; }; + +$(document).keydown(function(e) { + if (e.shiftKey && e.metaKey && e.which === 80) { + e.preventDefault(); + + const jst = $(e.target).closest('.jstBlock'); + + if (jst.find('.tab-edit.selected').length > 0) { + jst.find('.tab-preview').click(); + lastJstPreviewed = jst + } else { + (lastJstPreviewed || jst).find('.tab-edit').click(); + (lastJstPreviewed || jst).find('textarea').focus(); + lastJstPreviewed = null; + } + } +});