From fd76d435e8c6996501fbce0e415ef91117a6efb7 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 16 Oct 2020 11:59:35 +0300 Subject: [PATCH] [PE] Add settings for autoformat --- .../common/main/lib/view/AutoCorrectDialog.js | 22 +++++++++---------- .../main/app/controller/Main.js | 17 ++++++++++++++ apps/presentationeditor/main/locale/en.json | 7 ++++++ 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/apps/common/main/lib/view/AutoCorrectDialog.js b/apps/common/main/lib/view/AutoCorrectDialog.js index 9651fa4fa..62aba478e 100644 --- a/apps/common/main/lib/view/AutoCorrectDialog.js +++ b/apps/common/main/lib/view/AutoCorrectDialog.js @@ -62,7 +62,7 @@ define([ 'text!common/main/lib/template/AutoCorrectDialog.template', {panelId: 'id-autocorrect-dialog-settings-math', panelCaption: this.textMathCorrect}, {panelId: 'id-autocorrect-dialog-settings-recognized', panelCaption: this.textRecognized} ]; - if (this.appPrefix=='de-') + if (this.appPrefix=='de-' || this.appPrefix=='pe-') items.push({panelId: 'id-autocorrect-dialog-settings-de-autoformat', panelCaption: this.textAutoFormat}); else if (this.appPrefix=='sse-') items.push({panelId: 'id-autocorrect-dialog-settings-sse-autoformat', panelCaption: this.textAutoFormat}); @@ -106,28 +106,28 @@ define([ 'text!common/main/lib/template/AutoCorrectDialog.template', value = Common.Utils.InternalSettings.get(path + "-rem"); this.arrRemRec = value ? JSON.parse(value) : []; - if (this.appPrefix=='de-') { + if (this.appPrefix=='de-' || this.appPrefix=='pe-') { var me = this; this.options.handler = function(result, value) { if ( result == 'ok' ) { var value = me.chBulleted.getValue()==='checked'; - Common.localStorage.setBool("de-settings-autoformat-bulleted", value); - Common.Utils.InternalSettings.set("de-settings-autoformat-bulleted", value); + Common.localStorage.setBool(this.appPrefix + "settings-autoformat-bulleted", value); + Common.Utils.InternalSettings.set(this.appPrefix + "settings-autoformat-bulleted", value); me.api.asc_SetAutomaticBulletedLists(value); value = me.chNumbered.getValue()==='checked'; - Common.localStorage.setBool("de-settings-autoformat-numbered", value); - Common.Utils.InternalSettings.set("de-settings-autoformat-numbered", value); + Common.localStorage.setBool(this.appPrefix + "settings-autoformat-numbered", value); + Common.Utils.InternalSettings.set(this.appPrefix + "settings-autoformat-numbered", value); me.api.asc_SetAutomaticNumberedLists(value); value = me.chQuotes.getValue()==='checked'; - Common.localStorage.setBool("de-settings-autoformat-smart-quotes", value); - Common.Utils.InternalSettings.set("de-settings-autoformat-smart-quotes", value); + Common.localStorage.setBool(this.appPrefix + "settings-autoformat-smart-quotes", value); + Common.Utils.InternalSettings.set(this.appPrefix + "settings-autoformat-smart-quotes", value); me.api.asc_SetAutoCorrectSmartQuotes(value); value = me.chHyphens.getValue()==='checked'; - Common.localStorage.setBool("de-settings-autoformat-hyphens", value); - Common.Utils.InternalSettings.set("de-settings-autoformat-hyphens", value); + Common.localStorage.setBool(this.appPrefix + "settings-autoformat-hyphens", value); + Common.Utils.InternalSettings.set(this.appPrefix + "settings-autoformat-hyphens", value); me.api.asc_SetAutoCorrectHyphensWithDash(value); } }; @@ -316,7 +316,7 @@ define([ 'text!common/main/lib/template/AutoCorrectDialog.template', }); this.btnDeleteRec.on('click', _.bind(this.onDeleteRec, this, false)); - if (this.appPrefix=='de-') { + if (this.appPrefix=='de-' || this.appPrefix=='pe-') { this.chQuotes = new Common.UI.CheckBox({ el: $('#id-autocorrect-dialog-chk-quotes'), labelText: this.textQuotes, diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index d5ebf008a..5190c81be 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -1964,6 +1964,23 @@ define([ Common.Utils.InternalSettings.set("pe-settings-rec-functions-rem", value); arrRem = value ? JSON.parse(value) : []; me.api.asc_refreshOnStartAutoCorrectMathFunctions(arrRem, arrAdd); + + value = Common.localStorage.getBool("pe-settings-autoformat-bulleted", true); + Common.Utils.InternalSettings.set("pe-settings-autoformat-bulleted", value); + me.api.asc_SetAutomaticBulletedLists(value); + + value = Common.localStorage.getBool("pe-settings-autoformat-numbered", true); + Common.Utils.InternalSettings.set("pe-settings-autoformat-numbered", value); + me.api.asc_SetAutomaticNumberedLists(value); + + value = Common.localStorage.getBool("pe-settings-autoformat-smart-quotes", true); + Common.Utils.InternalSettings.set("pe-settings-autoformat-smart-quotes", value); + me.api.asc_SetAutoCorrectSmartQuotes(value); + + value = Common.localStorage.getBool("pe-settings-autoformat-hyphens", true); + Common.Utils.InternalSettings.set("pe-settings-autoformat-hyphens", value); + me.api.asc_SetAutoCorrectHyphensWithDash(value); + }, // Translation diff --git a/apps/presentationeditor/main/locale/en.json b/apps/presentationeditor/main/locale/en.json index 02d808736..c6ea60c43 100644 --- a/apps/presentationeditor/main/locale/en.json +++ b/apps/presentationeditor/main/locale/en.json @@ -74,6 +74,13 @@ "Common.Views.AutoCorrectDialog.textRecognizedDesc": "The following expressions are recognized math expressions. They will not be automatically italicized.", "Common.Views.AutoCorrectDialog.textWarnAddRec": "Recognized functions must contain only the letters A through Z, uppercase or lowercase.", "Common.Views.AutoCorrectDialog.textWarnResetRec": "Any expression you added will be removed and the removed ones will be restored. Do you want to continue?", + "Common.Views.AutoCorrectDialog.textAutoFormat": "AutoFormat As You Type", + "Common.Views.AutoCorrectDialog.textReplaceText": "Replace As You Type", + "Common.Views.AutoCorrectDialog.textApplyText": "Apply As You Type", + "Common.Views.AutoCorrectDialog.textQuotes": "\"Straight quotes\" with \"smart quotes\"", + "Common.Views.AutoCorrectDialog.textHyphens": "Hyphens (--) with dash (—)", + "Common.Views.AutoCorrectDialog.textBulleted": "Automatic bulleted lists", + "Common.Views.AutoCorrectDialog.textNumbered": "Automatic numbered lists", "Common.Views.AutoCorrectDialog.textTitle": "AutoCorrect", "Common.Views.Chat.textSend": "Send", "Common.Views.Comments.textAdd": "Add",