New option: Disable spell check
This commit is contained in:
parent
d5d6cdb250
commit
c517e4193b
9 changed files with 78 additions and 9 deletions
|
@ -969,6 +969,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":
|
||||
|
|
|
@ -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() {
|
||||
|
|
3
main.js
3
main.js
|
@ -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) => {
|
||||
|
|
|
@ -87,6 +87,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'>
|
||||
|
|
|
@ -35,6 +35,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…
Reference in a new issue