[SSE] Load spellcheck languages

This commit is contained in:
Julia Radzhabova 2019-08-05 16:37:09 +03:00
parent b73a916af4
commit 57d7a0c701
3 changed files with 53 additions and 22 deletions

View file

@ -164,6 +164,7 @@ define([
this.api.asc_registerCallback('asc_onDocumentName', _.bind(this.onDocumentName, this));
this.api.asc_registerCallback('asc_onPrintUrl', _.bind(this.onPrintUrl, this));
this.api.asc_registerCallback('asc_onMeta', _.bind(this.onMeta, this));
this.api.asc_registerCallback('asc_onSpellCheckInit', _.bind(this.loadLanguages, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this));
Common.NotificationCenter.on('goback', _.bind(this.goBack, this));
Common.NotificationCenter.on('namedrange:locked', _.bind(this.onNamedRangeLocked, this));
@ -742,6 +743,7 @@ define([
documentHolderView.createDelayedElements();
toolbarController.createDelayedElements();
me.setLanguages();
if (!me.appOptions.isEditMailMerge && !me.appOptions.isEditDiagram) {
var shapes = me.api.asc_getPropertyEditorShapes();
@ -1817,6 +1819,15 @@ define([
}
},
loadLanguages: function(apiLangs) {
this.languages = apiLangs;
window.styles_loaded && this.setLanguages();
},
setLanguages: function() {
this.getApplication().getController('Spellcheck').setLanguages(this.languages);
},
onInternalCommand: function(data) {
if (data) {
switch (data.command) {

View file

@ -54,6 +54,7 @@ define([
this.addListeners({
'Spellcheck': {
'show': function() {
me.loadLanguages();
if (me.api) {
me.api.asc_startSpellCheck();
}
@ -76,18 +77,21 @@ define([
setApi: function(api) {
this.api = api;
this.api.asc_registerCallback('asc_onSpellCheckInit',_.bind(this.loadLanguages, this));
return this;
},
setMode: function(mode) {
this.mode = mode;
if (this.panelSpellcheck) {
this.panelSpellcheck.btnToDictionary.setVisible(mode.isDesktopApp);
}
return this;
},
onAfterRender: function(panelSpellcheck) {
panelSpellcheck.buttonPreview.on('click', _.bind(this.onClickPreview, this));
panelSpellcheck.buttonNext.on('click', _.bind(this.onClickNext, this));
panelSpellcheck.btnToDictionary.on('click', _.bind(this.onDictionary, this));
panelSpellcheck.cmbDictionaryLanguage.on('selected', _.bind(this.onSelectLanguage, this));
},
@ -103,29 +107,42 @@ define([
}
},
onDictionary: function() {
if (this.api) {
var rec = this.panelSpellcheck.suggestionList.getSelectedRec();
rec && this.api.asc_AddToDictionary(rec.get('value'));
}
},
SetDisabled: function(state) {
this._isDisabled = state;
},
loadLanguages: function (apiLangs) {
var langs = [], info,
allLangs = Common.util.LanguageInfo.getLanguages();
apiLangs.forEach(function (code) {
if (allLangs.hasOwnProperty(parseInt(code))) {
info = allLangs[parseInt(code)];
langs.push({
displayValue: info[1],
value: info[0],
code: parseInt(code),
});
}
});
this.languages = langs;
this.panelSpellcheck.cmbDictionaryLanguage.setData(this.languages);
/*var codeCurLang = this.api.asc_getDefaultLanguage();*/
var codeCurLang = 1036;
var curLang = allLangs[codeCurLang][0];
this.panelSpellcheck.cmbDictionaryLanguage.setValue(curLang);
setLanguages: function (array) {
this.languages = array;
},
loadLanguages: function () {
if (this.languages && this.languages.length>0) {
var langs = [], info,
allLangs = Common.util.LanguageInfo.getLanguages();
this.languages.forEach(function (code) {
if (allLangs.hasOwnProperty(parseInt(code))) {
info = allLangs[parseInt(code)];
langs.push({
displayValue: info[1],
value: info[0],
code: parseInt(code)
});
}
});
this.panelSpellcheck.cmbDictionaryLanguage.setData(langs);
/*var codeCurLang = this.api.asc_getDefaultLanguage();*/
var codeCurLang = 1036;
var curLang = allLangs[codeCurLang][0];
this.panelSpellcheck.cmbDictionaryLanguage.setValue(curLang);
} else
this.panelSpellcheck.cmbDictionaryLanguage.setDisabled(true);
},
onSelectLanguage: function (combo, record) {

View file

@ -56,7 +56,7 @@ define([
'<div style="display: flex; width: 100%; padding-bottom: 8px;"><div id="spellcheck-current-word" style="vertical-align: top; width: 100%; display: inline-block;"></div><div id="spellcheck-preview" style="display: inline-block;"></div><div id="spellcheck-next" style="display: inline-block;"></div></div>',
'<div id="spellcheck-suggestions-list" style="width: 100%; height: 100px; background-color: #fff; margin-bottom: 8px;"></div>',
'<div id="spellcheck-change" style="width: 105px; display: inline-block; padding-bottom: 16px;"></div><div id="spellcheck-ignore" class="padding-large" style="margin-left: 19px; width: 105px; display: inline-block;"></div>',
'<div id="spellcheck-add-to-dictionary" style="padding-bottom: 16px;"><button class="btn btn-text-default" style="width: auto; padding: 0 15px;"><%= scope.txtAddToDictionary %></button></div>',
'<button class="btn btn-text-default" id="spellcheck-add-to-dictionary" style="width: 105px; display: block; margin-bottom: 16px;"><%= scope.txtAddToDictionary %></button>',
'<label class="header"><%= scope.txtDictionaryLanguage %></label><div id="spellcheck-dictionary-language" style="margin-top: 3px; padding-bottom: 16px;"></div>',
'<div id="spellcheck-complete" style="display: flex;"><i class="img-commonctrl img-complete" style="display: inline-block;margin-right: 10px;"></i><%= scope.txtComplete %></div>',
'</div>'
@ -151,11 +151,14 @@ define([
this.cmbDictionaryLanguage = new Common.UI.ComboBox({
el : $('#spellcheck-dictionary-language'),
style : 'width: 230px',
menuStyle : 'min-width: 230px;max-height: 300px;',
menuStyle : 'min-width: 230px;max-height: 200px;',
editable : false,
cls : 'input-group-nr'
});
this.btnToDictionary = new Common.UI.Button({
el: $('#spellcheck-add-to-dictionary')
});
this.trigger('render:after', this);
return this;