Edit code v2

This commit is contained in:
ShimaginAndrey 2021-08-13 17:26:36 +03:00
parent 80da6912b3
commit 952fba59ba
10 changed files with 53 additions and 26 deletions

View file

@ -536,8 +536,7 @@ class MainController extends Component {
//text settings //text settings
const storeTextSettings = this.props.storeTextSettings; const storeTextSettings = this.props.storeTextSettings;
storeTextSettings.arrayRecentFonts = LocalStorage.getItem('dde-settings-recent-fonts'); storeTextSettings.resetFontsRecent(LocalStorage.getItem('dde-settings-recent-fonts'));
storeTextSettings.arrayRecentFonts = storeTextSettings.arrayRecentFonts ? storeTextSettings.arrayRecentFonts.split(';') : [];
EditorUIController.initFonts && EditorUIController.initFonts(storeTextSettings); EditorUIController.initFonts && EditorUIController.initFonts(storeTextSettings);
EditorUIController.initFocusObjects && EditorUIController.initFocusObjects(this.props.storeFocusObjects); EditorUIController.initFocusObjects && EditorUIController.initFocusObjects(this.props.storeFocusObjects);

View file

@ -23,6 +23,7 @@ export class storeTextSettings {
backgroundColor: observable, backgroundColor: observable,
initEditorFonts: action, initEditorFonts: action,
resetFontName: action, resetFontName: action,
resetFontsRecent:action,
resetFontSize: action, resetFontSize: action,
resetIsBold: action, resetIsBold: action,
resetIsItalic: action, resetIsItalic: action,
@ -88,6 +89,12 @@ export class storeTextSettings {
let name = (typeof font.get_Name) === "function" ? font.get_Name() : font.asc_getName(); let name = (typeof font.get_Name) === "function" ? font.get_Name() : font.asc_getName();
this.fontName = name; this.fontName = name;
} }
resetFontsRecent(fonts) {
this.arrayRecentFonts = fonts;
this.arrayRecentFonts = this.arrayRecentFonts ? this.arrayRecentFonts.split(';') : [];
}
resetFontSize (size) { resetFontSize (size) {
this.fontSize = size; this.fontSize = size;
} }

View file

@ -16,10 +16,12 @@ const PageFonts = props => {
const fonts = storeTextSettings.fontsArray; const fonts = storeTextSettings.fontsArray;
const arrayFonts = storeTextSettings.arrayRecentFonts; const arrayFonts = storeTextSettings.arrayRecentFonts;
const addRecentStorage = () => {
let arr = []; let arr = [];
arrayFonts.forEach(item => arr.push(item)); arrayFonts.forEach(item => arr.push(item));
arr = arr.join(';'); arr = arr.join(';');
LocalStorage.setItem('dde-settings-recent-fonts', arr); LocalStorage.setItem('dde-settings-recent-fonts', arr);
}
const [vlFonts, setVlFonts] = useState({ const [vlFonts, setVlFonts] = useState({
vlData: { vlData: {
@ -92,7 +94,7 @@ const PageFonts = props => {
title={item.name} title={item.name}
style={{fontFamily: `${item.name}`}} style={{fontFamily: `${item.name}`}}
onClick={() => {storeTextSettings.changeFontFamily(item.name); props.changeFontFamily(item.name); onClick={() => {storeTextSettings.changeFontFamily(item.name); props.changeFontFamily(item.name);
storeTextSettings.addFontToRecent(item.name)}} storeTextSettings.addFontToRecent(item.name); addRecentStorage()}}
></ListItem> ></ListItem>
))} ))}
</ul> </ul>

View file

@ -325,8 +325,7 @@ class MainController extends Component {
// Text settings // Text settings
const storeTextSettings = this.props.storeTextSettings; const storeTextSettings = this.props.storeTextSettings;
storeTextSettings.arrayRecentFonts = LocalStorage.getItem('ppe-settings-recent-fonts'); storeTextSettings.resetFontsRecent(LocalStorage.getItem('ppe-settings-recent-fonts'));
storeTextSettings.arrayRecentFonts = storeTextSettings.arrayRecentFonts ? storeTextSettings.arrayRecentFonts.split(';') : [];
EditorUIController.initFonts && EditorUIController.initFonts(storeTextSettings); EditorUIController.initFonts && EditorUIController.initFonts(storeTextSettings);

View file

@ -24,6 +24,7 @@ export class storeTextSettings {
lineSpacing: observable, lineSpacing: observable,
initEditorFonts: action, initEditorFonts: action,
resetFontName: action, resetFontName: action,
resetFontsRecent:action,
resetFontSize: action, resetFontSize: action,
resetIsBold: action, resetIsBold: action,
resetIsItalic: action, resetIsItalic: action,
@ -91,6 +92,11 @@ export class storeTextSettings {
this.fontName = name; this.fontName = name;
} }
resetFontsRecent(fonts) {
this.arrayRecentFonts = fonts;
this.arrayRecentFonts = this.arrayRecentFonts ? this.arrayRecentFonts.split(';') : [];
}
resetFontSize (size) { resetFontSize (size) {
this.fontSize = size; this.fontSize = size;
} }

View file

@ -188,10 +188,12 @@ const PageFonts = props => {
const fonts = storeTextSettings.fontsArray; const fonts = storeTextSettings.fontsArray;
const arrayFonts = storeTextSettings.arrayRecentFonts; const arrayFonts = storeTextSettings.arrayRecentFonts;
const addRecentStorage = () => {
let arr = []; let arr = [];
arrayFonts.forEach(item => arr.push(item)); arrayFonts.forEach(item => arr.push(item));
arr = arr.join(';'); arr = arr.join(';');
LocalStorage.setItem('ppe-settings-recent-fonts', arr); LocalStorage.setItem('ppe-settings-recent-fonts', arr);
}
const [vlFonts, setVlFonts] = useState({ const [vlFonts, setVlFonts] = useState({
vlData: { vlData: {
@ -269,7 +271,8 @@ const PageFonts = props => {
checked={curFontName === item.name} checked={curFontName === item.name}
title={item.name} title={item.name}
style={{fontFamily: `${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()}}
></ListItem> ></ListItem>
))} ))}
</ul> </ul>

View file

@ -351,8 +351,7 @@ class MainController extends Component {
// Text settings // Text settings
const storeTextSettings = this.props.storeTextSettings; const storeTextSettings = this.props.storeTextSettings;
storeTextSettings.arrayRecentFonts = LocalStorage.getItem('sse-settings-recent-fonts'); storeTextSettings.resetFontsRecent(LocalStorage.getItem('sse-settings-recent-fonts'));
storeTextSettings.arrayRecentFonts = storeTextSettings.arrayRecentFonts ? storeTextSettings.arrayRecentFonts.split(';') : [];
// Spreadsheet Settings // Spreadsheet Settings

View file

@ -16,6 +16,7 @@ export class storeTextSettings {
paragraphAlign: observable, paragraphAlign: observable,
paragraphValign: observable, paragraphValign: observable,
textIn: observable, textIn: observable,
resetFontsRecent:action,
initTextSettings: action, initTextSettings: action,
initFontSettings: action, initFontSettings: action,
initEditorFonts: action, initEditorFonts: action,
@ -127,6 +128,11 @@ export class storeTextSettings {
return value; return value;
} }
resetFontsRecent(fonts) {
this.arrayRecentFonts = fonts;
this.arrayRecentFonts = this.arrayRecentFonts ? this.arrayRecentFonts.split(';') : [];
}
changeCustomTextColors (colors) { changeCustomTextColors (colors) {
this.customTextColors = colors; this.customTextColors = colors;
} }

View file

@ -129,10 +129,12 @@ const PageFontsCell = props => {
const fonts = storeCellSettings.fontsArray; const fonts = storeCellSettings.fontsArray;
const arrayFonts = storeTextSettings.arrayRecentFonts; const arrayFonts = storeTextSettings.arrayRecentFonts;
const addRecentStorage = () => {
let arr = []; let arr = [];
arrayFonts.forEach(item => arr.push(item)); arrayFonts.forEach(item => arr.push(item));
arr = arr.join(';'); arr = arr.join(';');
LocalStorage.setItem('sse-settings-recent-fonts', arr); LocalStorage.setItem('sse-settings-recent-fonts', arr);
}
const [vlFonts, setVlFonts] = useState({ const [vlFonts, setVlFonts] = useState({
vlData: { vlData: {
@ -208,7 +210,8 @@ const PageFontsCell = props => {
checked={curFontName === item.name} checked={curFontName === item.name}
title={item.name} title={item.name}
style={{fontFamily: `${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()}}
></ListItem> ></ListItem>
))} ))}
</ul> </ul>

View file

@ -101,10 +101,12 @@ const PageFonts = props => {
const fonts = storeTextSettings.fontsArray; const fonts = storeTextSettings.fontsArray;
const arrayFonts = storeTextSettings.arrayRecentFonts; const arrayFonts = storeTextSettings.arrayRecentFonts;
const addRecentStorage = () => {
let arr = []; let arr = [];
arrayFonts.forEach(item => arr.push(item)); arrayFonts.forEach(item => arr.push(item));
arr = arr.join(';'); arr = arr.join(';');
LocalStorage.setItem('sse-settings-recent-fonts', arr); LocalStorage.setItem('sse-settings-recent-fonts', arr);
}
const [vlFonts, setVlFonts] = useState({ const [vlFonts, setVlFonts] = useState({
vlData: { vlData: {
@ -174,7 +176,8 @@ const PageFonts = props => {
checked={curFontName === item.name} checked={curFontName === item.name}
title={item.name} title={item.name}
style={{fontFamily: `${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()}}
></ListItem> ></ListItem>
))} ))}
</ul> </ul>