Project

General

Profile

Feature #30459 » switch_edit_preview_tabs_using_keyboard_shortcuts-v2.patch

Mizuki ISHIKAWA, 2020-12-28 03:56

View differences:

public/javascripts/jstoolbar/jstoolbar.js
21 21
*/
22 22

  
23 23
/* Modified by JP LANG for textile formatting */
24
let lastJstPreviewed;
24 25

  
25 26
function jsToolBar(textarea) {
26 27
  if (!document.createElement) { return; }
......
507 508
  });
508 509
  return false;
509 510
};
511

  
512
$(document).keydown(function(e) {
513
  if (e.shiftKey && e.metaKey && e.which === 80) {
514
    e.preventDefault();
515

  
516
    const jst = $(e.target).closest('.jstBlock');
517

  
518
    if (jst.find('.tab-edit.selected').length > 0) {
519
      jst.find('.tab-preview').click();
520
      lastJstPreviewed = jst
521
    } else {
522
      (lastJstPreviewed || jst).find('.tab-edit').click();
523
      (lastJstPreviewed || jst).find('textarea').focus();
524
      lastJstPreviewed = null;
525
    }
526
  }
527
});
(3-3/5)