New option: Disable spell check

pull/749/head
Scott Nonnenberg 7 years ago
parent 97f494f4e1
commit 57107d9b21

@ -819,6 +819,14 @@
"message": "Allow access to camera and microphone",
"description": "Description of the media permission description"
},
"spellCheck": {
"message": "Spell Check",
"description": "Description of the media permission description"
},
"spellCheckDescription": {
"message": "Enable spell check of text entered in message composition box",
"description": "Description of the media permission description"
},
"clearDataHeader": {
"message": "Clear Data",
"description": "Header in the settings dialog for the section dealing with data deletion"

@ -146,6 +146,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: () =>
@ -171,6 +177,15 @@
},
};
const startSpellCheck = () => {
if (window.Events.getSpellCheck()) {
window.enableSpellCheck();
} else {
window.disableSpellCheck();
}
};
startSpellCheck();
try {
await ConversationController.load();
} finally {

@ -16,6 +16,8 @@ const getInitialData = async () => ({
notificationSetting: await window.getNotificationSetting(),
audioNotification: await window.getAudioNotification(),
spellCheck: await window.getSpellCheck(),
mediaPermissions: await window.getMediaPermissions(),
isPrimary: await window.isPrimary(),

@ -119,15 +119,39 @@
},
});
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', function(e) {
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);
};
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);
};
const spellCheckHandler = e => {
// Only show the context menu in text editors.
if (!e.target.closest('textarea, input, [contenteditable="true"]')) {
return;
@ -148,5 +172,5 @@
setTimeout(function() {
menu.popup(remote.getCurrentWindow());
}, 30);
});
};
})();

@ -99,6 +99,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() {

@ -808,6 +808,9 @@ installSettingsSetter('notification-setting');
installSettingsGetter('audio-notification');
installSettingsSetter('audio-notification');
installSettingsGetter('spell-check');
installSettingsSetter('spell-check');
// This one is different because its single source of truth is userConfig, not IndexedDB
ipc.on('get-media-permissions', event => {
event.sender.send(

@ -112,6 +112,9 @@ installSetter('notification-setting', 'setNotificationSetting');
installGetter('audio-notification', 'getAudioNotification');
installSetter('audio-notification', 'setAudioNotification');
installGetter('spell-check', 'getSpellCheck');
installSetter('spell-check', 'setSpellCheck');
window.getMediaPermissions = () =>
new Promise((resolve, reject) => {
ipc.once('get-success-media-permissions', (_event, error, value) => {

@ -91,6 +91,12 @@
</div>
{{ /isAudioNotificationSupported }}
<hr>
<div class='spell-check-setting'>
<h3>{{ spellCheckHeader }}</h3>
<input type='checkbox' name='spell-check-setting' />
<label for='spell-check-setting'>{{ spellCheckDescription }}</label>
</div>
<hr>
<div class='permissions-setting'>
<h3>{{ permissions }}</h3>
<div class='media-permissions'>

@ -33,6 +33,9 @@ window.setThemeSetting = makeSetter('theme-setting');
window.getHideMenuBar = makeGetter('hide-menu-bar');
window.setHideMenuBar = makeSetter('hide-menu-bar');
window.getSpellCheck = makeGetter('spell-check');
window.setSpellCheck = makeSetter('spell-check');
window.getNotificationSetting = makeGetter('notification-setting');
window.setNotificationSetting = makeSetter('notification-setting');
window.getAudioNotification = makeGetter('audio-notification');

Loading…
Cancel
Save