[PE][SSE] Add autocorrect options

This commit is contained in:
Julia Radzhabova 2020-07-03 15:15:17 +03:00
parent 5f58bd0ca0
commit ad49bc4e61
4 changed files with 83 additions and 6 deletions

View file

@ -239,7 +239,7 @@ define([
if ( !!this.api ) {
this.panels['info'].setApi(this.api);
this.panels['opts'].setApi(this.api);
if (this.panels['opts']) this.panels['opts'].setApi(this.api);
if ( this.panels['protect'] )
this.panels['protect'].setApi(this.api);
}
@ -374,7 +374,7 @@ define([
if ( this.rendered ) {
this.panels['info'].setApi(api);
this.panels['opts'].setApi(api);
if (this.panels['opts']) this.panels['opts'].setApi(api);
if (this.panels['protect']) this.panels['protect'].setApi(api);
}

View file

@ -223,6 +223,7 @@ define([
if ( !!this.api ) {
this.panels['info'].setApi(this.api);
if (this.panels['opts']) this.panels['opts'].setApi(this.api);
if ( this.panels['protect'] )
this.panels['protect'].setApi(this.api);
}
@ -352,6 +353,7 @@ define([
if ( this.rendered ) {
this.panels['info'].setApi(api);
if (this.panels['opts']) this.panels['opts'].setApi(api);
if (this.panels['protect']) this.panels['protect'].setApi(api);
}
this.api.asc_registerCallback('asc_onDocumentName', _.bind(this.onDocumentName, this));

View file

@ -42,6 +42,7 @@
define([
'common/main/lib/view/DocumentAccessDialog',
'common/main/lib/view/AutoCorrectDialog',
'common/main/lib/component/CheckBox'
], function () {
'use strict';
@ -184,6 +185,10 @@ define([
'<td class="left"><label><%= scope.txtSpellCheck %></label></td>',
'<td class="right"><div id="fms-chb-spell-check"></div></td>',
'</tr>','<tr class="divider edit"></tr>',
'<tr class="edit">',
'<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: 5px;padding-left: 5px;"><%= scope.txtAutoCorrect %></button></div></td>',
'</tr>','<tr class="divider edit"></tr>',
'<tr class="edit">',
'<td class="left"><label><%= scope.txtInput %></label></td>',
'<td class="right"><div id="fms-chb-input-mode"></div></td>',
@ -373,6 +378,11 @@ define([
labelText: this.strPasteButton
});
this.btnAutoCorrect = new Common.UI.Button({
el: $markup.findById('#fms-btn-auto-correct')
});
this.btnAutoCorrect.on('click', _.bind(this.autoCorrect, this));
this.btnApply = new Common.UI.Button({
el: $markup.findById('#fms-btn-apply')
});
@ -414,6 +424,11 @@ define([
$('tr.macros', this.el)[(mode.customization && mode.customization.macros===false) ? 'hide' : 'show']();
},
setApi: function(o) {
this.api = o;
return this;
},
updateSettings: function() {
this.chSpell.setValue(Common.Utils.InternalSettings.get("pe-settings-spellcheck"));
@ -506,6 +521,29 @@ define([
this._fontRender = combo.getValue();
},
autoCorrect: function() {
if (!this._mathCorrect) {
var arr = (this.api) ? this.api.asc_getAutoCorrectMathSymbols() : [],
data = [];
_.each(arr, function(item, index){
var itm = {replaced: item[0]};
if (typeof item[1]=='object') {
itm.by = '';
_.each(item[1], function(ch){
itm.by += Common.Utils.String.encodeSurrogateChar(ch);
});
} else {
itm.by = Common.Utils.String.encodeSurrogateChar(item[1]);
}
data.push(itm);
});
this._mathCorrect = data;
}
(new Common.Views.AutoCorrectDialog({
props: this._mathCorrect
})).show();
},
strInputMode: 'Turn on hieroglyphs',
strZoom: 'Default Zoom Value',
okButtonText: 'Apply',
@ -549,7 +587,9 @@ define([
txtRunMacrosDesc: 'Enable all macros without notification',
txtStopMacrosDesc: 'Disable all macros without notification',
strPaste: 'Cut, copy and paste',
strPasteButton: 'Show Paste Options button when content is pasted'
strPasteButton: 'Show Paste Options button when content is pasted',
txtProofing: 'Proofing',
txtAutoCorrect: 'AutoCorrect options...'
}, PE.Views.FileMenuPanels.Settings || {}));
PE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({

View file

@ -31,7 +31,8 @@
*
*/
define([
'common/main/lib/view/DocumentAccessDialog'
'common/main/lib/view/DocumentAccessDialog',
'common/main/lib/view/AutoCorrectDialog'
], function () {
'use strict';
@ -257,6 +258,7 @@ define([
setApi: function(api) {
this.generalSettings && this.generalSettings.setApi(api);
this.spellcheckSettings && this.spellcheckSettings.setApi(api);
},
txtGeneral: 'General',
@ -1237,6 +1239,10 @@ define([
'<td class="left"></td>',
'<td class="right"><span id="fms-chb-ignore-numbers-words"></span></td>',
'</tr>','<tr class="divider"></tr>',
'<tr>',
'<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: 5px;padding-left: 5px;"><%= scope.txtAutoCorrect %></button></div></td>',
'</tr>','<tr class="divider"></tr>',
'<tr>',
'<td class="left"></td>',
'<td class="right"><button id="fms-spellcheck-btn-apply" class="btn normal dlg-btn primary"><%= scope.okButtonText %></button></td>',
@ -1272,6 +1278,11 @@ define([
menuStyle: 'min-width: 267px; max-height: 209px;'
});
this.btnAutoCorrect = new Common.UI.Button({
el: $markup.findById('#fms-btn-auto-correct')
});
this.btnAutoCorrect.on('click', _.bind(this.autoCorrect, this));
this.btnApply = new Common.UI.Button({
el: $markup.findById('#fms-spellcheck-btn-apply')
});
@ -1362,11 +1373,35 @@ define([
}
},
autoCorrect: function() {
if (!this._mathCorrect) {
var arr = (this.api) ? this.api.asc_getAutoCorrectMathSymbols() : [],
data = [];
_.each(arr, function(item, index){
var itm = {replaced: item[0]};
if (typeof item[1]=='object') {
itm.by = '';
_.each(item[1], function(ch){
itm.by += Common.Utils.String.encodeSurrogateChar(ch);
});
} else {
itm.by = Common.Utils.String.encodeSurrogateChar(item[1]);
}
data.push(itm);
});
this._mathCorrect = data;
}
(new Common.Views.AutoCorrectDialog({
props: this._mathCorrect
})).show();
},
strIgnoreWordsInUPPERCASE: 'Ignore words in UPPERCASE',
strIgnoreWordsWithNumbers: 'Ignore words with numbers',
strDictionaryLanguage: 'Dictionary language',
okButtonText: 'Apply'
okButtonText: 'Apply',
txtProofing: 'Proofing',
txtAutoCorrect: 'AutoCorrect options...'
}, SSE.Views.FileMenuPanels.MainSpellCheckSettings || {}));
SSE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({