New option: Disable spell check
This commit is contained in:
parent
d5d6cdb250
commit
c517e4193b
9 changed files with 78 additions and 9 deletions
|
@ -160,6 +160,12 @@
|
|||
getAudioNotification: () => storage.get('audio-notification'),
|
||||
setAudioNotification: value => storage.put('audio-notification', value),
|
||||
|
||||
getSpellCheck: () => storage.get('spell-check', true),
|
||||
setSpellCheck: value => {
|
||||
storage.put('spell-check', value);
|
||||
startSpellCheck();
|
||||
},
|
||||
|
||||
// eslint-disable-next-line eqeqeq
|
||||
isPrimary: () => textsecure.storage.user.getDeviceId() == '1',
|
||||
getSyncRequest: () =>
|
||||
|
@ -185,6 +191,15 @@
|
|||
},
|
||||
};
|
||||
|
||||
const startSpellCheck = () => {
|
||||
if (window.Events.getSpellCheck()) {
|
||||
window.enableSpellCheck();
|
||||
} else {
|
||||
window.disableSpellCheck();
|
||||
}
|
||||
};
|
||||
startSpellCheck();
|
||||
|
||||
const themeSetting = window.Events.getThemeSetting();
|
||||
const newThemeSetting = mapOldThemeToNew(themeSetting);
|
||||
window.Events.setThemeSetting(newThemeSetting);
|
||||
|
|
|
@ -21,6 +21,8 @@ const getInitialData = async () => ({
|
|||
notificationSetting: await window.getNotificationSetting(),
|
||||
audioNotification: await window.getAudioNotification(),
|
||||
|
||||
spellCheck: await window.getSpellCheck(),
|
||||
|
||||
mediaPermissions: await window.getMediaPermissions(),
|
||||
|
||||
isPrimary: await window.isPrimary(),
|
||||
|
|
|
@ -118,17 +118,39 @@ const simpleChecker = {
|
|||
},
|
||||
};
|
||||
|
||||
const dummyChecker = {
|
||||
spellCheck() {
|
||||
return true;
|
||||
},
|
||||
isMisspelled() {
|
||||
return false;
|
||||
},
|
||||
getSuggestions() {
|
||||
return [];
|
||||
},
|
||||
add() {
|
||||
// nothing
|
||||
},
|
||||
};
|
||||
|
||||
window.spellChecker = simpleChecker;
|
||||
window.disableSpellCheck = () => {
|
||||
window.removeEventListener('contextmenu', spellCheckHandler);
|
||||
webFrame.setSpellCheckProvider('en-US', false, dummyChecker);
|
||||
};
|
||||
|
||||
webFrame.setSpellCheckProvider(
|
||||
'en-US',
|
||||
// Not sure what this parameter (`autoCorrectWord`) does: https://github.com/atom/electron/issues/4371
|
||||
// The documentation for `webFrame.setSpellCheckProvider` passes `true` so we do too.
|
||||
true,
|
||||
simpleChecker
|
||||
);
|
||||
window.enableSpellCheck = () => {
|
||||
webFrame.setSpellCheckProvider(
|
||||
'en-US',
|
||||
// Not sure what this parameter (`autoCorrectWord`) does: https://github.com/atom/electron/issues/4371
|
||||
// The documentation for `webFrame.setSpellCheckProvider` passes `true` so we do too.
|
||||
true,
|
||||
simpleChecker
|
||||
);
|
||||
window.addEventListener('contextmenu', spellCheckHandler);
|
||||
};
|
||||
|
||||
window.addEventListener('contextmenu', e => {
|
||||
const spellCheckHandler = e => {
|
||||
// Only show the context menu in text editors.
|
||||
if (!e.target.closest('textarea, input, [contenteditable="true"]')) {
|
||||
return;
|
||||
|
@ -150,4 +172,4 @@ window.addEventListener('contextmenu', e => {
|
|||
setTimeout(() => {
|
||||
menu.popup(remote.getCurrentWindow());
|
||||
}, 30);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -98,6 +98,11 @@
|
|||
setFn: window.setAudioNotification,
|
||||
});
|
||||
}
|
||||
new CheckboxView({
|
||||
el: this.$('.spell-check-setting'),
|
||||
value: window.initialData.spellCheck,
|
||||
setFn: window.setSpellCheck,
|
||||
});
|
||||
new CheckboxView({
|
||||
el: this.$('.menu-bar-setting'),
|
||||
value: window.initialData.hideMenuBar,
|
||||
|
@ -139,6 +144,8 @@
|
|||
clearDataExplanation: i18n('clearDataExplanation'),
|
||||
permissions: i18n('permissions'),
|
||||
mediaPermissionsDescription: i18n('mediaPermissionsDescription'),
|
||||
spellCheckHeader: i18n('spellCheck'),
|
||||
spellCheckDescription: i18n('spellCheckDescription'),
|
||||
};
|
||||
},
|
||||
onClose() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue