Skip to content

Etherpad plugin to observe shortcuts pressed on the editor, and to tell the editor wrapper/parent that they were pressed

Notifications You must be signed in to change notification settings

storytouch/ep_external_shortcuts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ep_external_shortcuts

Etherpad plugin to observe shortcuts pressed on the editor, and to send a message to Etherpad content window (when used on iframe) whenever a shortcut is pressed

Usage

To setup which combos should be observed:

var message = {
  type: 'register_shortcuts',
  combos: ['command+s', 'ctrl+s'],
}
yourEtherpadIFrame.contentWindow.postMessage(message, '*');

This plugin uses Mousetrap to observe key combos. Take a look on the supported keys and on the examples for more information about how to register your combos.

To handle whenever a registered combo is pressed:

window.removeEventListener('message', function(e) {
  var type = e.data.type;
  var comboPressed = e.data.combo;
  if (type === 'shortcut_triggered') {
    // do something with your comboPressed
  }
});

About

Etherpad plugin to observe shortcuts pressed on the editor, and to tell the editor wrapper/parent that they were pressed

Resources

Stars

Watchers

Forks

Packages

No packages published