[SSE] Use FeaturesManager for spellcheck customization.

This commit is contained in:
Julia Radzhabova 2021-11-02 15:56:37 +03:00
parent fb66a79a0f
commit bad734bf2d
3 changed files with 24 additions and 15 deletions

View file

@ -239,7 +239,7 @@ define([
this.leftMenu.btnComments.hide(); this.leftMenu.btnComments.hide();
} }
if (this.mode.isEdit) { if (this.mode.isEdit && Common.UI.FeaturesManager.canChange('spellcheck')) {
Common.UI.LayoutManager.isElementVisible('leftMenu-spellcheck') && this.leftMenu.btnSpellcheck.show(); Common.UI.LayoutManager.isElementVisible('leftMenu-spellcheck') && this.leftMenu.btnSpellcheck.show();
this.leftMenu.setOptionsPanel('spellcheck', this.getApplication().getController('Spellcheck').getView('Spellcheck')); this.leftMenu.setOptionsPanel('spellcheck', this.getApplication().getController('Spellcheck').getView('Spellcheck'));
} }
@ -482,7 +482,7 @@ define([
}, },
applySpellcheckSettings: function(menu) { applySpellcheckSettings: function(menu) {
if (this.mode.isEdit && this.api) { if (this.mode.isEdit && this.api && Common.UI.FeaturesManager.canChange('spellcheck')) {
var value = Common.localStorage.getBool("sse-spellcheck-ignore-uppercase-words"); var value = Common.localStorage.getBool("sse-spellcheck-ignore-uppercase-words");
this.api.asc_ignoreUppercase(value); this.api.asc_ignoreUppercase(value);
value = Common.localStorage.getBool("sse-spellcheck-ignore-numbers-words"); value = Common.localStorage.getBool("sse-spellcheck-ignore-numbers-words");

View file

@ -858,6 +858,8 @@ define([
this.api.asc_setAutoSaveGap(Common.Utils.InternalSettings.get("sse-settings-autosave")); this.api.asc_setAutoSaveGap(Common.Utils.InternalSettings.get("sse-settings-autosave"));
/** coauthoring end **/ /** coauthoring end **/
// spellcheck
if (Common.UI.FeaturesManager.canChange('spellcheck')) { // get from local storage
/** spellcheck settings begin **/ /** spellcheck settings begin **/
var ignoreUppercase = Common.localStorage.getBool("sse-spellcheck-ignore-uppercase-words", true); var ignoreUppercase = Common.localStorage.getBool("sse-spellcheck-ignore-uppercase-words", true);
Common.Utils.InternalSettings.set("sse-spellcheck-ignore-uppercase-words", ignoreUppercase); Common.Utils.InternalSettings.set("sse-spellcheck-ignore-uppercase-words", ignoreUppercase);
@ -866,6 +868,7 @@ define([
Common.Utils.InternalSettings.set("sse-spellcheck-ignore-numbers-words", ignoreNumbers); Common.Utils.InternalSettings.set("sse-spellcheck-ignore-numbers-words", ignoreNumbers);
this.api.asc_ignoreNumbers(ignoreNumbers); this.api.asc_ignoreNumbers(ignoreNumbers);
/** spellcheck settings end **/ /** spellcheck settings end **/
}
me.api.asc_registerCallback('asc_onStartAction', _.bind(me.onLongActionBegin, me)); me.api.asc_registerCallback('asc_onStartAction', _.bind(me.onLongActionBegin, me));
me.api.asc_registerCallback('asc_onConfirmAction', _.bind(me.onConfirmAction, me)); me.api.asc_registerCallback('asc_onConfirmAction', _.bind(me.onConfirmAction, me));
@ -917,7 +920,7 @@ define([
this.formulaInput = celleditorController.getView('CellEditor').$el.find('textarea'); this.formulaInput = celleditorController.getView('CellEditor').$el.find('textarea');
if (me.appOptions.isEdit) { if (me.appOptions.isEdit) {
spellcheckController.setApi(me.api).setMode(me.appOptions); Common.UI.FeaturesManager.canChange('spellcheck') && spellcheckController.setApi(me.api).setMode(me.appOptions);
if (me.appOptions.canForcesave) {// use asc_setIsForceSaveOnUserSave only when customization->forcesave = true if (me.appOptions.canForcesave) {// use asc_setIsForceSaveOnUserSave only when customization->forcesave = true
me.appOptions.forcesave = Common.localStorage.getBool("sse-settings-forcesave", me.appOptions.canForcesave); me.appOptions.forcesave = Common.localStorage.getBool("sse-settings-forcesave", me.appOptions.canForcesave);
@ -1259,6 +1262,7 @@ define([
this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object' || this.editorConfig.plugins); this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object' || this.editorConfig.plugins);
this.getApplication().getController('Common.Controllers.Plugins').setMode(this.appOptions); this.getApplication().getController('Common.Controllers.Plugins').setMode(this.appOptions);
this.appOptions.canBrandingExt && this.editorConfig.customization && Common.UI.LayoutManager.init(this.editorConfig.customization.layout); this.appOptions.canBrandingExt && this.editorConfig.customization && Common.UI.LayoutManager.init(this.editorConfig.customization.layout);
this.appOptions.canBrandingExt && this.editorConfig.customization && Common.UI.FeaturesManager.init(this.editorConfig.customization.features);
} }
this.appOptions.canUseHistory = this.appOptions.canLicense && this.editorConfig.canUseHistory && this.appOptions.canCoAuthoring && !this.appOptions.isOffline; this.appOptions.canUseHistory = this.appOptions.canLicense && this.editorConfig.canUseHistory && this.appOptions.canCoAuthoring && !this.appOptions.isOffline;

View file

@ -1491,18 +1491,18 @@ define([
template: _.template([ template: _.template([
'<table class="main" style="margin: 30px 0;"><tbody>', '<table class="main" style="margin: 30px 0;"><tbody>',
'<tr>', '<tr class="spellcheck">',
'<td class="left" style="padding-bottom: 8px;"><label><%= scope.strDictionaryLanguage %></label></td>', '<td class="left" style="padding-bottom: 8px;"><label><%= scope.strDictionaryLanguage %></label></td>',
'<td class="right" style="padding-bottom: 8px;"><span id="fms-cmb-dictionary-language"></span></td>', '<td class="right" style="padding-bottom: 8px;"><span id="fms-cmb-dictionary-language"></span></td>',
'</tr>', '</tr>',
'<tr>', '<tr class="spellcheck">',
'<td class="left" style="padding-bottom: 8px;"></td>', '<td class="left" style="padding-bottom: 8px;"></td>',
'<td class="right" style="padding-bottom: 8px;"><span id="fms-chb-ignore-uppercase-words"></span></td>', '<td class="right" style="padding-bottom: 8px;"><span id="fms-chb-ignore-uppercase-words"></span></td>',
'</tr>', '</tr>',
'<tr>', '<tr class="spellcheck">',
'<td class="left"></td>', '<td class="left"></td>',
'<td class="right"><span id="fms-chb-ignore-numbers-words"></span></td>', '<td class="right"><span id="fms-chb-ignore-numbers-words"></span></td>',
'</tr>','<tr class="divider"></tr>', '</tr>','<tr class="divider spellcheck"></tr>',
'<tr>', '<tr>',
'<td class="left"><label><%= scope.txtProofing %></label></td>', '<td class="left"><label><%= scope.txtProofing %></label></td>',
'<td class="right"><button type="button" class="btn btn-text-default" id="fms-btn-auto-correct" style="width:auto; display: inline-block;padding-right: 10px;padding-left: 10px;" data-hint="3" data-hint-direction="bottom" data-hint-offset="big"><%= scope.txtAutoCorrect %></button></div></td>', '<td class="right"><button type="button" class="btn btn-text-default" id="fms-btn-auto-correct" style="width:auto; display: inline-block;padding-right: 10px;padding-left: 10px;" data-hint="3" data-hint-direction="bottom" data-hint-offset="big"><%= scope.txtAutoCorrect %></button></div></td>',
@ -1584,6 +1584,7 @@ define([
setMode: function(mode) { setMode: function(mode) {
this.mode = mode; this.mode = mode;
$('tr.spellcheck', this.el)[Common.UI.FeaturesManager.canChange('spellcheck') ? 'show' : 'hide']();
}, },
setApi: function(api) { setApi: function(api) {
@ -1591,6 +1592,8 @@ define([
}, },
updateSettings: function() { updateSettings: function() {
if (!Common.UI.FeaturesManager.canChange('spellcheck')) return;
var arrLang = SSE.getController('Spellcheck').loadLanguages(), var arrLang = SSE.getController('Spellcheck').loadLanguages(),
allLangs = arrLang[0], allLangs = arrLang[0],
langs = arrLang[1], langs = arrLang[1],
@ -1627,6 +1630,8 @@ define([
}, },
applySettings: function() { applySettings: function() {
if (!Common.UI.FeaturesManager.canChange('spellcheck')) return;
var value = this.chIgnoreUppercase.isChecked(); var value = this.chIgnoreUppercase.isChecked();
Common.localStorage.setBool("sse-spellcheck-ignore-uppercase-words", value); Common.localStorage.setBool("sse-spellcheck-ignore-uppercase-words", value);
Common.Utils.InternalSettings.set("sse-spellcheck-ignore-uppercase-words", value); Common.Utils.InternalSettings.set("sse-spellcheck-ignore-uppercase-words", value);