Comments (5)
Now we have spell checker 😄
from rocket.chat.electron.
@rodrigok is this still osx only or is windows support there? Cause i'm not seeing this in the v1.0.0 release on windows either 😦
from rocket.chat.electron.
The spell checker code is working, but I can't compile the dictionary for windows, so, you can use on windows now.
Maybe you can try to compile this module
from rocket.chat.electron.
So the currently implement of spell checking leaves some things to be desired. It seems to be based off the suggestion here electron/electron#942, but that implementation is flawed because it builds the context menu at the time of the word being checked, not at right-click time which leads to weird graphical inconsistencies. For example, try misspelling a word and then right-clicking somewhere outside the current text area: you'll see the list of possible replacements but selecting an option does nothing.
Replacing the current implementation in preload.js with the below code yields much better results for me.
var remote = require('remote');
var spellchecker = require('spellchecker')
var Menu = remote.require('menu');
var template = [
{
label: "Undo",
click: function(item, window) {
remote.getCurrentWebContents().undo();
}
},
{
label: "Redo",
click: function(item, window) {
remote.getCurrentWebContents().redo();
}
},
{
type: 'separator'
},
{
label: "Cut",
click: function(item, window) {
remote.getCurrentWebContents().cut();
}
},
{
label: "Copy",
click: function(item, window) {
remote.getCurrentWebContents().copy();
}
},
{
label: "Paste",
click: function(item, window) {
remote.getCurrentWebContents().paste();
}
},
{
type: 'separator'
},
{
label: "Select All",
click: function(item, window) {
remote.getCurrentWebContents().selectAll();
}
}];
require('web-frame').setSpellCheckProvider((localStorage.getItem('userLanguage') || "en-US"),
false, {
spellCheck: function(text) {
return !(spellchecker.isMisspelled(text));
}
});
window.addEventListener('contextmenu', function(event) {
switch(event.target.nodeName) {
case 'TEXTAREA':
var value = event.target.value;
var cursor = event.target.selectionStart;
var strLength = value.length;
event.preventDefault();
if (cursor == strLength || value.charAt(cursor) == " ") {
var menu = Menu.buildFromTemplate(template);
menu.popup(remote.getCurrentWindow());
}
else {
var end = value.indexOf(" ", cursor);
end = end == -1 ? strLength : end;
var start = value.lastIndexOf(" ", cursor) + 1;
var text = value.substring(start, end);
var bad = spellchecker.isMisspelled(text);
var newTemplate = template.slice();
if (bad) {
var replacements = spellchecker.getCorrectionsForMisspelling(text);
var num = replacements.length ? replacements.length : 0;
var maxItems = num > 7 ? 7 : num;
var items = [];
for (var i = 0; i < maxItems; i++) {
var item = replacements[i];
items.push({
label: item,
click : function(menuItem, window) {
remote.getCurrentWebContents().replaceMisspelling(menuItem.label);
}
});
}
if (maxItems > 0) {
newTemplate.push({
type: 'separator'
});
newTemplate.push({
label: "Spelling suggestions",
submenu: items
});
}
}
var menu = Menu.buildFromTemplate(newTemplate);
menu.popup(remote.getCurrentWindow());
}
break;
default:
var menu = Menu.buildFromTemplate(template);
menu.popup(remote.getCurrentWindow());
break;
}
}, false);
from rocket.chat.electron.
@crimsoncor see #121 and #122
Thanks
from rocket.chat.electron.
Related Issues (20)
- Opening a downloaded file could be more convenient HOT 5
- app crash when clicking share button in jitsi call using "WebRTCPipeWireCapturer" to support desktop share on waylandBug title
- RANT: App threatens to cut user.... off
- [Feature Request] UI/UX Enhancement - Creating a back button on relevant modals/dialogs/views HOT 4
- MSI package broken since 3.9.12.0 HOT 2
- Missing hindi language translations for i18n
- Add missing translations for various languages: French, Japanese, Russian, Turkish
- Add missing translations for various languages: Italian, Chinese, Chinese simplified, Chinese (Traditional)
- Add missing translations for various languages: Arabian, German, Finnish, Polish, Portuguese (Brazil), Ukrainian
- Markdown links added in the Team or Channel Topic don't work
- Add members dropdown while creating new team/channel not working properly
- App crashes on downloading an image HOT 1
- Download error when cancelling "Save as" dialog HOT 1
- "Reload" reloads wrong workspace HOT 2
- Sidebar does not highlight workspace with new messages HOT 7
- Menu options not available after adding server HOT 1
- Misleading error message about the supported Rocket.Chat version HOT 2
- Windows app push notifications not working.
- Add Mac OS Keychain integration
- E2E Encryption password not displayed in the German version, shows `%s` instead HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rocket.chat.electron.