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",
|
"message": "Allow access to camera and microphone",
|
||||||
"description": "Description of the media permission description"
|
"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": {
|
"clearDataHeader": {
|
||||||
"message": "Clear Data",
|
"message": "Clear Data",
|
||||||
"description":
|
"description":
|
||||||
|
|
|
@ -160,6 +160,12 @@
|
||||||
getAudioNotification: () => storage.get('audio-notification'),
|
getAudioNotification: () => storage.get('audio-notification'),
|
||||||
setAudioNotification: value => storage.put('audio-notification', value),
|
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
|
// eslint-disable-next-line eqeqeq
|
||||||
isPrimary: () => textsecure.storage.user.getDeviceId() == '1',
|
isPrimary: () => textsecure.storage.user.getDeviceId() == '1',
|
||||||
getSyncRequest: () =>
|
getSyncRequest: () =>
|
||||||
|
@ -185,6 +191,15 @@
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const startSpellCheck = () => {
|
||||||
|
if (window.Events.getSpellCheck()) {
|
||||||
|
window.enableSpellCheck();
|
||||||
|
} else {
|
||||||
|
window.disableSpellCheck();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
startSpellCheck();
|
||||||
|
|
||||||
const themeSetting = window.Events.getThemeSetting();
|
const themeSetting = window.Events.getThemeSetting();
|
||||||
const newThemeSetting = mapOldThemeToNew(themeSetting);
|
const newThemeSetting = mapOldThemeToNew(themeSetting);
|
||||||
window.Events.setThemeSetting(newThemeSetting);
|
window.Events.setThemeSetting(newThemeSetting);
|
||||||
|
|
|
@ -21,6 +21,8 @@ const getInitialData = async () => ({
|
||||||
notificationSetting: await window.getNotificationSetting(),
|
notificationSetting: await window.getNotificationSetting(),
|
||||||
audioNotification: await window.getAudioNotification(),
|
audioNotification: await window.getAudioNotification(),
|
||||||
|
|
||||||
|
spellCheck: await window.getSpellCheck(),
|
||||||
|
|
||||||
mediaPermissions: await window.getMediaPermissions(),
|
mediaPermissions: await window.getMediaPermissions(),
|
||||||
|
|
||||||
isPrimary: await window.isPrimary(),
|
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.spellChecker = simpleChecker;
|
||||||
|
window.disableSpellCheck = () => {
|
||||||
|
window.removeEventListener('contextmenu', spellCheckHandler);
|
||||||
|
webFrame.setSpellCheckProvider('en-US', false, dummyChecker);
|
||||||
|
};
|
||||||
|
|
||||||
webFrame.setSpellCheckProvider(
|
window.enableSpellCheck = () => {
|
||||||
'en-US',
|
webFrame.setSpellCheckProvider(
|
||||||
// Not sure what this parameter (`autoCorrectWord`) does: https://github.com/atom/electron/issues/4371
|
'en-US',
|
||||||
// The documentation for `webFrame.setSpellCheckProvider` passes `true` so we do too.
|
// Not sure what this parameter (`autoCorrectWord`) does: https://github.com/atom/electron/issues/4371
|
||||||
true,
|
// The documentation for `webFrame.setSpellCheckProvider` passes `true` so we do too.
|
||||||
simpleChecker
|
true,
|
||||||
);
|
simpleChecker
|
||||||
|
);
|
||||||
|
window.addEventListener('contextmenu', spellCheckHandler);
|
||||||
|
};
|
||||||
|
|
||||||
window.addEventListener('contextmenu', e => {
|
const spellCheckHandler = e => {
|
||||||
// Only show the context menu in text editors.
|
// Only show the context menu in text editors.
|
||||||
if (!e.target.closest('textarea, input, [contenteditable="true"]')) {
|
if (!e.target.closest('textarea, input, [contenteditable="true"]')) {
|
||||||
return;
|
return;
|
||||||
|
@ -150,4 +172,4 @@ window.addEventListener('contextmenu', e => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
menu.popup(remote.getCurrentWindow());
|
menu.popup(remote.getCurrentWindow());
|
||||||
}, 30);
|
}, 30);
|
||||||
});
|
};
|
||||||
|
|
|
@ -98,6 +98,11 @@
|
||||||
setFn: window.setAudioNotification,
|
setFn: window.setAudioNotification,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
new CheckboxView({
|
||||||
|
el: this.$('.spell-check-setting'),
|
||||||
|
value: window.initialData.spellCheck,
|
||||||
|
setFn: window.setSpellCheck,
|
||||||
|
});
|
||||||
new CheckboxView({
|
new CheckboxView({
|
||||||
el: this.$('.menu-bar-setting'),
|
el: this.$('.menu-bar-setting'),
|
||||||
value: window.initialData.hideMenuBar,
|
value: window.initialData.hideMenuBar,
|
||||||
|
@ -139,6 +144,8 @@
|
||||||
clearDataExplanation: i18n('clearDataExplanation'),
|
clearDataExplanation: i18n('clearDataExplanation'),
|
||||||
permissions: i18n('permissions'),
|
permissions: i18n('permissions'),
|
||||||
mediaPermissionsDescription: i18n('mediaPermissionsDescription'),
|
mediaPermissionsDescription: i18n('mediaPermissionsDescription'),
|
||||||
|
spellCheckHeader: i18n('spellCheck'),
|
||||||
|
spellCheckDescription: i18n('spellCheckDescription'),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
onClose() {
|
onClose() {
|
||||||
|
|
3
main.js
3
main.js
|
@ -808,6 +808,9 @@ installSettingsSetter('notification-setting');
|
||||||
installSettingsGetter('audio-notification');
|
installSettingsGetter('audio-notification');
|
||||||
installSettingsSetter('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
|
// This one is different because its single source of truth is userConfig, not IndexedDB
|
||||||
ipc.on('get-media-permissions', event => {
|
ipc.on('get-media-permissions', event => {
|
||||||
event.sender.send(
|
event.sender.send(
|
||||||
|
|
|
@ -112,6 +112,9 @@ installSetter('notification-setting', 'setNotificationSetting');
|
||||||
installGetter('audio-notification', 'getAudioNotification');
|
installGetter('audio-notification', 'getAudioNotification');
|
||||||
installSetter('audio-notification', 'setAudioNotification');
|
installSetter('audio-notification', 'setAudioNotification');
|
||||||
|
|
||||||
|
installGetter('spell-check', 'getSpellCheck');
|
||||||
|
installSetter('spell-check', 'setSpellCheck');
|
||||||
|
|
||||||
window.getMediaPermissions = () =>
|
window.getMediaPermissions = () =>
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) => {
|
||||||
ipc.once('get-success-media-permissions', (_event, error, value) => {
|
ipc.once('get-success-media-permissions', (_event, error, value) => {
|
||||||
|
|
|
@ -87,6 +87,12 @@
|
||||||
</div>
|
</div>
|
||||||
{{ /isAudioNotificationSupported }}
|
{{ /isAudioNotificationSupported }}
|
||||||
<hr>
|
<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'>
|
<div class='permissions-setting'>
|
||||||
<h3>{{ permissions }}</h3>
|
<h3>{{ permissions }}</h3>
|
||||||
<div class='media-permissions'>
|
<div class='media-permissions'>
|
||||||
|
|
|
@ -35,6 +35,9 @@ window.setThemeSetting = makeSetter('theme-setting');
|
||||||
window.getHideMenuBar = makeGetter('hide-menu-bar');
|
window.getHideMenuBar = makeGetter('hide-menu-bar');
|
||||||
window.setHideMenuBar = makeSetter('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.getNotificationSetting = makeGetter('notification-setting');
|
||||||
window.setNotificationSetting = makeSetter('notification-setting');
|
window.setNotificationSetting = makeSetter('notification-setting');
|
||||||
window.getAudioNotification = makeGetter('audio-notification');
|
window.getAudioNotification = makeGetter('audio-notification');
|
||||||
|
|
Loading…
Reference in a new issue