From 952fba59ba3610a80ab3932df955164448a95ede Mon Sep 17 00:00:00 2001 From: ShimaginAndrey Date: Fri, 13 Aug 2021 17:26:36 +0300 Subject: [PATCH] Edit code v2 --- apps/documenteditor/mobile/src/controller/Main.jsx | 3 +-- .../documenteditor/mobile/src/store/textSettings.js | 7 +++++++ .../mobile/src/view/edit/EditText.jsx | 12 +++++++----- .../mobile/src/controller/Main.jsx | 3 +-- .../mobile/src/store/textSettings.js | 6 ++++++ .../mobile/src/view/edit/EditText.jsx | 13 ++++++++----- .../mobile/src/controller/Main.jsx | 3 +-- .../mobile/src/store/textSettings.js | 6 ++++++ .../mobile/src/view/edit/EditCell.jsx | 13 ++++++++----- .../mobile/src/view/edit/EditText.jsx | 13 ++++++++----- 10 files changed, 53 insertions(+), 26 deletions(-) diff --git a/apps/documenteditor/mobile/src/controller/Main.jsx b/apps/documenteditor/mobile/src/controller/Main.jsx index 716c2d444..c8f2b7f82 100644 --- a/apps/documenteditor/mobile/src/controller/Main.jsx +++ b/apps/documenteditor/mobile/src/controller/Main.jsx @@ -536,8 +536,7 @@ class MainController extends Component { //text settings const storeTextSettings = this.props.storeTextSettings; - storeTextSettings.arrayRecentFonts = LocalStorage.getItem('dde-settings-recent-fonts'); - storeTextSettings.arrayRecentFonts = storeTextSettings.arrayRecentFonts ? storeTextSettings.arrayRecentFonts.split(';') : []; + storeTextSettings.resetFontsRecent(LocalStorage.getItem('dde-settings-recent-fonts')); EditorUIController.initFonts && EditorUIController.initFonts(storeTextSettings); EditorUIController.initFocusObjects && EditorUIController.initFocusObjects(this.props.storeFocusObjects); diff --git a/apps/documenteditor/mobile/src/store/textSettings.js b/apps/documenteditor/mobile/src/store/textSettings.js index 0bc46bef3..c35369f92 100644 --- a/apps/documenteditor/mobile/src/store/textSettings.js +++ b/apps/documenteditor/mobile/src/store/textSettings.js @@ -23,6 +23,7 @@ export class storeTextSettings { backgroundColor: observable, initEditorFonts: action, resetFontName: action, + resetFontsRecent:action, resetFontSize: action, resetIsBold: action, resetIsItalic: action, @@ -88,6 +89,12 @@ export class storeTextSettings { let name = (typeof font.get_Name) === "function" ? font.get_Name() : font.asc_getName(); this.fontName = name; } + + resetFontsRecent(fonts) { + this.arrayRecentFonts = fonts; + this.arrayRecentFonts = this.arrayRecentFonts ? this.arrayRecentFonts.split(';') : []; + } + resetFontSize (size) { this.fontSize = size; } diff --git a/apps/documenteditor/mobile/src/view/edit/EditText.jsx b/apps/documenteditor/mobile/src/view/edit/EditText.jsx index 8611dbcfd..a64fcfea7 100644 --- a/apps/documenteditor/mobile/src/view/edit/EditText.jsx +++ b/apps/documenteditor/mobile/src/view/edit/EditText.jsx @@ -16,10 +16,12 @@ const PageFonts = props => { const fonts = storeTextSettings.fontsArray; const arrayFonts = storeTextSettings.arrayRecentFonts; - let arr = []; - arrayFonts.forEach(item => arr.push(item)); - arr = arr.join(';'); - LocalStorage.setItem('dde-settings-recent-fonts', arr); + const addRecentStorage = () => { + let arr = []; + arrayFonts.forEach(item => arr.push(item)); + arr = arr.join(';'); + LocalStorage.setItem('dde-settings-recent-fonts', arr); + } const [vlFonts, setVlFonts] = useState({ vlData: { @@ -92,7 +94,7 @@ const PageFonts = props => { title={item.name} style={{fontFamily: `${item.name}`}} onClick={() => {storeTextSettings.changeFontFamily(item.name); props.changeFontFamily(item.name); - storeTextSettings.addFontToRecent(item.name)}} + storeTextSettings.addFontToRecent(item.name); addRecentStorage()}} > ))} diff --git a/apps/presentationeditor/mobile/src/controller/Main.jsx b/apps/presentationeditor/mobile/src/controller/Main.jsx index 661c804d5..fc61c7668 100644 --- a/apps/presentationeditor/mobile/src/controller/Main.jsx +++ b/apps/presentationeditor/mobile/src/controller/Main.jsx @@ -325,8 +325,7 @@ class MainController extends Component { // Text settings const storeTextSettings = this.props.storeTextSettings; - storeTextSettings.arrayRecentFonts = LocalStorage.getItem('ppe-settings-recent-fonts'); - storeTextSettings.arrayRecentFonts = storeTextSettings.arrayRecentFonts ? storeTextSettings.arrayRecentFonts.split(';') : []; + storeTextSettings.resetFontsRecent(LocalStorage.getItem('ppe-settings-recent-fonts')); EditorUIController.initFonts && EditorUIController.initFonts(storeTextSettings); diff --git a/apps/presentationeditor/mobile/src/store/textSettings.js b/apps/presentationeditor/mobile/src/store/textSettings.js index 1f1e9cd08..e4b97a118 100644 --- a/apps/presentationeditor/mobile/src/store/textSettings.js +++ b/apps/presentationeditor/mobile/src/store/textSettings.js @@ -24,6 +24,7 @@ export class storeTextSettings { lineSpacing: observable, initEditorFonts: action, resetFontName: action, + resetFontsRecent:action, resetFontSize: action, resetIsBold: action, resetIsItalic: action, @@ -91,6 +92,11 @@ export class storeTextSettings { this.fontName = name; } + resetFontsRecent(fonts) { + this.arrayRecentFonts = fonts; + this.arrayRecentFonts = this.arrayRecentFonts ? this.arrayRecentFonts.split(';') : []; + } + resetFontSize (size) { this.fontSize = size; } diff --git a/apps/presentationeditor/mobile/src/view/edit/EditText.jsx b/apps/presentationeditor/mobile/src/view/edit/EditText.jsx index 4aa5d8557..2e9fcd1ae 100644 --- a/apps/presentationeditor/mobile/src/view/edit/EditText.jsx +++ b/apps/presentationeditor/mobile/src/view/edit/EditText.jsx @@ -188,10 +188,12 @@ const PageFonts = props => { const fonts = storeTextSettings.fontsArray; const arrayFonts = storeTextSettings.arrayRecentFonts; - let arr = []; - arrayFonts.forEach(item => arr.push(item)); - arr = arr.join(';'); - LocalStorage.setItem('ppe-settings-recent-fonts', arr); + const addRecentStorage = () => { + let arr = []; + arrayFonts.forEach(item => arr.push(item)); + arr = arr.join(';'); + LocalStorage.setItem('ppe-settings-recent-fonts', arr); + } const [vlFonts, setVlFonts] = useState({ vlData: { @@ -269,7 +271,8 @@ const PageFonts = props => { checked={curFontName === item.name} title={item.name} style={{fontFamily: `${item.name}`}} - onClick={() => {props.changeFontFamily(item.name); storeTextSettings.addFontToRecent(item.name)}} + onClick={() => {props.changeFontFamily(item.name); storeTextSettings.addFontToRecent(item.name); + addRecentStorage()}} > ))} diff --git a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx index a8e98b4ad..c71941916 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx @@ -351,8 +351,7 @@ class MainController extends Component { // Text settings const storeTextSettings = this.props.storeTextSettings; - storeTextSettings.arrayRecentFonts = LocalStorage.getItem('sse-settings-recent-fonts'); - storeTextSettings.arrayRecentFonts = storeTextSettings.arrayRecentFonts ? storeTextSettings.arrayRecentFonts.split(';') : []; + storeTextSettings.resetFontsRecent(LocalStorage.getItem('sse-settings-recent-fonts')); // Spreadsheet Settings diff --git a/apps/spreadsheeteditor/mobile/src/store/textSettings.js b/apps/spreadsheeteditor/mobile/src/store/textSettings.js index bb4d86441..1f577ddf5 100644 --- a/apps/spreadsheeteditor/mobile/src/store/textSettings.js +++ b/apps/spreadsheeteditor/mobile/src/store/textSettings.js @@ -16,6 +16,7 @@ export class storeTextSettings { paragraphAlign: observable, paragraphValign: observable, textIn: observable, + resetFontsRecent:action, initTextSettings: action, initFontSettings: action, initEditorFonts: action, @@ -127,6 +128,11 @@ export class storeTextSettings { return value; } + resetFontsRecent(fonts) { + this.arrayRecentFonts = fonts; + this.arrayRecentFonts = this.arrayRecentFonts ? this.arrayRecentFonts.split(';') : []; + } + changeCustomTextColors (colors) { this.customTextColors = colors; } diff --git a/apps/spreadsheeteditor/mobile/src/view/edit/EditCell.jsx b/apps/spreadsheeteditor/mobile/src/view/edit/EditCell.jsx index 2fa730ed9..a309fdf66 100644 --- a/apps/spreadsheeteditor/mobile/src/view/edit/EditCell.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/edit/EditCell.jsx @@ -129,10 +129,12 @@ const PageFontsCell = props => { const fonts = storeCellSettings.fontsArray; const arrayFonts = storeTextSettings.arrayRecentFonts; - let arr = []; - arrayFonts.forEach(item => arr.push(item)); - arr = arr.join(';'); - LocalStorage.setItem('sse-settings-recent-fonts', arr); + const addRecentStorage = () => { + let arr = []; + arrayFonts.forEach(item => arr.push(item)); + arr = arr.join(';'); + LocalStorage.setItem('sse-settings-recent-fonts', arr); + } const [vlFonts, setVlFonts] = useState({ vlData: { @@ -208,7 +210,8 @@ const PageFontsCell = props => { checked={curFontName === item.name} title={item.name} style={{fontFamily: `${item.name}`}} - onClick={() => {props.onFontClick(item.name); storeTextSettings.addFontToRecent(item.name)}} + onClick={() => {props.onFontClick(item.name); storeTextSettings.addFontToRecent(item.name); + addRecentStorage()}} > ))} diff --git a/apps/spreadsheeteditor/mobile/src/view/edit/EditText.jsx b/apps/spreadsheeteditor/mobile/src/view/edit/EditText.jsx index 2f2fda0ad..4628aad5f 100644 --- a/apps/spreadsheeteditor/mobile/src/view/edit/EditText.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/edit/EditText.jsx @@ -101,10 +101,12 @@ const PageFonts = props => { const fonts = storeTextSettings.fontsArray; const arrayFonts = storeTextSettings.arrayRecentFonts; - let arr = []; - arrayFonts.forEach(item => arr.push(item)); - arr = arr.join(';'); - LocalStorage.setItem('sse-settings-recent-fonts', arr); + const addRecentStorage = () => { + let arr = []; + arrayFonts.forEach(item => arr.push(item)); + arr = arr.join(';'); + LocalStorage.setItem('sse-settings-recent-fonts', arr); + } const [vlFonts, setVlFonts] = useState({ vlData: { @@ -174,7 +176,8 @@ const PageFonts = props => { checked={curFontName === item.name} title={item.name} style={{fontFamily: `${item.name}`}} - onClick={() => {props.changeFontFamily(item.name); storeTextSettings.addFontToRecent(item.name)}} + onClick={() => {props.changeFontFamily(item.name); storeTextSettings.addFontToRecent(item.name); + addRecentStorage()}} > ))}