mirror of
				https://github.com/zulip/zulip-desktop.git
				synced 2025-11-03 21:43:18 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			28 lines
		
	
	
		
			844 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			844 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
const {SpellCheckHandler, ContextMenuListener, ContextMenuBuilder} = require('electron-spellchecker');
 | 
						|
 | 
						|
function spellChecker() {
 | 
						|
	// Implement spellcheck using electron api
 | 
						|
	window.spellCheckHandler = new SpellCheckHandler();
 | 
						|
	window.spellCheckHandler.attachToInput();
 | 
						|
 | 
						|
	// Start off as US English
 | 
						|
	window.spellCheckHandler.switchLanguage('en-US');
 | 
						|
 | 
						|
	const contextMenuBuilder = new ContextMenuBuilder(window.spellCheckHandler);
 | 
						|
	const contextMenuListener = new ContextMenuListener(info => {
 | 
						|
		contextMenuBuilder.showPopupMenu(info);
 | 
						|
	});
 | 
						|
 | 
						|
	// Clean up events after you navigate away from this page;
 | 
						|
	// otherwise, you may experience errors
 | 
						|
	window.addEventListener('beforeunload', () => {
 | 
						|
	// eslint-disable-next-line no-undef
 | 
						|
		spellCheckHandler.unsubscribe();
 | 
						|
		contextMenuListener.unsubscribe();
 | 
						|
	});
 | 
						|
}
 | 
						|
 | 
						|
module.exports = {
 | 
						|
	spellChecker
 | 
						|
};
 |