SymphonyElectron/js/spellChecker/spellChecker.js
Kiran Niranjan e21f7adfaa Electron-47
1. Fixed some issues with windows
2. Changed the arg from external to exclude
2017-08-01 12:19:59 +05:30

47 lines
1.3 KiB
JavaScript

const { remote } = require('electron');
const { MenuItem } = remote;
const { SpellCheckHandler, ContextMenuListener, ContextMenuBuilder } = require('electron-spellchecker');
class SpellCheckHelper {
constructor() {
this.spellCheckHandler = new SpellCheckHandler();
}
/**
* Method to initialize spell checker
*/
initializeSpellChecker() {
this.spellCheckHandler.attachToInput();
const contextMenuBuilder = new ContextMenuBuilder(this.spellCheckHandler, null, false, SpellCheckHelper.processMenu);
this.contextMenuListener = new ContextMenuListener((info) => {
contextMenuBuilder.showPopupMenu(info);
});
}
/**
* Method to add default menu items to the
* menu that was generated by ContextMenuBuilder
*
* This method will be invoked by electron-spellchecker
* before showing the context menu
*
* @param menu
* @returns menu
*/
static processMenu(menu) {
menu.append(new MenuItem({ type: 'separator' }));
menu.append(new MenuItem({
role: 'reload',
accelerator: 'CmdOrCtrl+R',
label: 'Reload'
}));
return menu;
}
}
module.exports = {
SpellCheckHelper: SpellCheckHelper
};