[DE PE SSE] Edit code

This commit is contained in:
ShimaginAndrey 2021-08-13 16:11:40 +03:00
parent edf1d0f491
commit 80da6912b3
10 changed files with 92 additions and 76 deletions

View file

@ -536,6 +536,9 @@ 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(';') : [];
EditorUIController.initFonts && EditorUIController.initFonts(storeTextSettings);
EditorUIController.initFocusObjects && EditorUIController.initFocusObjects(this.props.storeFocusObjects);

View file

@ -1,5 +1,4 @@
import {action, observable, computed, makeObservable} from 'mobx';
import { LocalStorage } from '../../../../common/mobile/utils/LocalStorage';
export class storeTextSettings {
constructor() {
@ -84,9 +83,6 @@ export class storeTextSettings {
});
this.fontsArray = array;
this.arrayRecentFonts = LocalStorage.getItem('dde-settings-recent-fonts');
this.arrayRecentFonts = this.arrayRecentFonts ? this.arrayRecentFonts.split(';') : [];
}
resetFontName (font) {
let name = (typeof font.get_Name) === "function" ? font.get_Name() : font.asc_getName();
@ -187,11 +183,6 @@ export class storeTextSettings {
this.arrayRecentFonts.unshift(font);
if (this.arrayRecentFonts.length > 5) this.arrayRecentFonts.splice(4,1);
let arr = [];
this.arrayRecentFonts.forEach(item => arr.push(item));
arr = arr.join(';');
LocalStorage.setItem('dde-settings-recent-fonts', arr);
}
resetLineSpacing (vc) {

View file

@ -3,8 +3,8 @@ import {observer, inject} from "mobx-react";
import {f7, Swiper, View, SwiperSlide, List, ListItem, Icon, Row, Button, Page, Navbar, NavRight, Segmented, BlockTitle, Link} from 'framework7-react';
import { useTranslation } from 'react-i18next';
import {Device} from '../../../../../common/mobile/utils/device';
import { ThemeColorPalette, CustomColorPicker } from '../../../../../common/mobile/lib/component/ThemeColorPalette.jsx';
import { LocalStorage } from '../../../../../common/mobile/utils/LocalStorage';
const PageFonts = props => {
const isAndroid = Device.android;
@ -15,12 +15,18 @@ const PageFonts = props => {
const curFontName = storeTextSettings.fontName;
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 [vlFonts, setVlFonts] = useState({
vlData: {
items: [],
}
});
const renderExternal = (vl, vlData) => {
setVlFonts((prevState) => {
let fonts = [...prevState.vlData.items];
@ -59,18 +65,20 @@ const PageFonts = props => {
</ListItem>
</List>
<BlockTitle>{t('Edit.textFonts')}</BlockTitle>
<List>
{arrayFonts.map((item,index) => (
<ListItem
key={index}
radio
checked={curFontName === item}
title={item}
style={{fontFamily: `${item}`}}
onClick={() => {storeTextSettings.changeFontFamily(item); props.changeFontFamily(item);}}
/>
))}
</List>
{!!arrayFonts.length &&
<List>
{arrayFonts.map((item,index) => (
<ListItem
key={index}
radio
checked={curFontName === item}
title={item}
style={{fontFamily: `${item}`}}
onClick={() => {storeTextSettings.changeFontFamily(item); props.changeFontFamily(item);}}
/>
))}
</List>
}
<List virtualList virtualListParams={{
items: fonts,
renderExternal: renderExternal

View file

@ -325,6 +325,8 @@ 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(';') : [];
EditorUIController.initFonts && EditorUIController.initFonts(storeTextSettings);

View file

@ -1,5 +1,4 @@
import {action, observable, computed, makeObservable} from 'mobx';
import { LocalStorage } from '../../../../common/mobile/utils/LocalStorage';
export class storeTextSettings {
constructor() {
@ -85,9 +84,6 @@ export class storeTextSettings {
});
this.fontsArray = array;
this.arrayRecentFonts = LocalStorage.getItem('ppe-settings-recent-fonts');
this.arrayRecentFonts = this.arrayRecentFonts ? this.arrayRecentFonts.split(';') : [];
}
resetFontName (font) {
@ -218,11 +214,6 @@ export class storeTextSettings {
this.arrayRecentFonts.unshift(font);
if (this.arrayRecentFonts.length > 5) this.arrayRecentFonts.splice(4,1);
let arr = [];
this.arrayRecentFonts.forEach(item => arr.push(item));
arr = arr.join(';');
LocalStorage.setItem('ppe-settings-recent-fonts', arr);
}
resetLineSpacing (vc) {

View file

@ -4,6 +4,7 @@ import {f7, Swiper, View, SwiperSlide, List, ListItem, Icon, Row, Button, Page,
import { useTranslation } from 'react-i18next';
import {Device} from '../../../../../common/mobile/utils/device';
import { ThemeColorPalette, CustomColorPicker } from '../../../../../common/mobile/lib/component/ThemeColorPalette.jsx';
import { LocalStorage } from '../../../../../common/mobile/utils/LocalStorage';
const EditText = props => {
const isAndroid = Device.android;
@ -187,6 +188,11 @@ 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 [vlFonts, setVlFonts] = useState({
vlData: {
items: [],
@ -237,18 +243,20 @@ const PageFonts = props => {
</ListItem>
</List>
<BlockTitle>{_t.textFonts}</BlockTitle>
<List>
{arrayFonts.map((item,index) => (
<ListItem
key={index}
radio
checked={curFontName === item}
title={item}
style={{fontFamily: `${item}`}}
onClick={() => {props.changeFontFamily(item)}}
/>
))}
</List>
{!!arrayFonts.length &&
<List>
{arrayFonts.map((item,index) => (
<ListItem
key={index}
radio
checked={curFontName === item}
title={item}
style={{fontFamily: `${item}`}}
onClick={() => {props.changeFontFamily(item)}}
/>
))}
</List>
}
<List virtualList virtualListParams={{
items: fonts,
renderExternal: renderExternal

View file

@ -348,6 +348,12 @@ class MainController extends Component {
const styleSize = this.props.storeCellSettings.styleSize;
this.api.asc_setThumbnailStylesSizes(styleSize.width, styleSize.height);
// Text settings
const storeTextSettings = this.props.storeTextSettings;
storeTextSettings.arrayRecentFonts = LocalStorage.getItem('sse-settings-recent-fonts');
storeTextSettings.arrayRecentFonts = storeTextSettings.arrayRecentFonts ? storeTextSettings.arrayRecentFonts.split(';') : [];
// Spreadsheet Settings
this.api.asc_registerCallback('asc_onSendThemeColorSchemes', schemes => {

View file

@ -1,5 +1,4 @@
import {action, observable, makeObservable, computed} from 'mobx';
import { LocalStorage } from '../../../../common/mobile/utils/LocalStorage';
export class storeTextSettings {
constructor() {
@ -88,9 +87,6 @@ export class storeTextSettings {
});
this.fontsArray = array;
this.arrayRecentFonts = LocalStorage.getItem('sse-settings-recent-fonts');
this.arrayRecentFonts = this.arrayRecentFonts ? this.arrayRecentFonts.split(';') : [];
}
initFontInfo(fontObj) {
@ -104,11 +100,6 @@ export class storeTextSettings {
this.arrayRecentFonts.unshift(font);
if (this.arrayRecentFonts.length > 5) this.arrayRecentFonts.splice(4,1);
let arr = [];
this.arrayRecentFonts.forEach(item => arr.push(item));
arr = arr.join(';');
LocalStorage.setItem('sse-settings-recent-fonts', arr);
}
changeTextColor(value) {

View file

@ -4,6 +4,7 @@ import {f7, List, ListItem, Icon, Row, Button, Page, Navbar, Segmented, BlockTit
import { useTranslation } from 'react-i18next';
import {Device} from '../../../../../common/mobile/utils/device';
import { ThemeColorPalette, CustomColorPicker } from '../../../../../common/mobile/lib/component/ThemeColorPalette.jsx';
import { LocalStorage } from '../../../../../common/mobile/utils/LocalStorage';
const EditCell = props => {
const isAndroid = Device.android;
@ -128,6 +129,11 @@ 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 [vlFonts, setVlFonts] = useState({
vlData: {
items: [],
@ -176,18 +182,20 @@ const PageFontsCell = props => {
</ListItem>
</List>
<BlockTitle>{_t.textFonts}</BlockTitle>
<List>
{arrayFonts.map((item,index) => (
<ListItem
key={index}
radio
checked={curFontName === item}
title={item}
style={{fontFamily: `${item}`}}
onClick={() => {props.onFontClick(item)}}
/>
))}
</List>
{!!arrayFonts.length &&
<List>
{arrayFonts.map((item,index) => (
<ListItem
key={index}
radio
checked={curFontName === item}
title={item}
style={{fontFamily: `${item}`}}
onClick={() => {props.onFontClick(item)}}
/>
))}
</List>
}
<List virtualList virtualListParams={{
items: fonts,
renderExternal: renderExternal

View file

@ -4,6 +4,7 @@ import {f7, List, ListItem, Icon, Row, Button, Page, Navbar, NavRight, Segmented
import { useTranslation } from 'react-i18next';
import {Device} from '../../../../../common/mobile/utils/device';
import { ThemeColorPalette, CustomColorPicker } from '../../../../../common/mobile/lib/component/ThemeColorPalette.jsx';
import { LocalStorage } from '../../../../../common/mobile/utils/LocalStorage';
const EditText = props => {
const isAndroid = Device.android;
@ -100,6 +101,11 @@ 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 [vlFonts, setVlFonts] = useState({
vlData: {
items: [],
@ -142,18 +148,20 @@ const PageFonts = props => {
</ListItem>
</List>
<BlockTitle>{_t.textFonts}</BlockTitle>
<List>
{arrayFonts.map((item,index) => (
<ListItem
key={index}
radio
checked={curFontName === item}
title={item}
style={{fontFamily: `${item}`}}
onClick={() => {props.changeFontFamily(item)}}
/>
))}
</List>
{!!arrayFonts.length &&
<List>
{arrayFonts.map((item,index) => (
<ListItem
key={index}
radio
checked={curFontName === item}
title={item}
style={{fontFamily: `${item}`}}
onClick={() => {props.changeFontFamily(item)}}
/>
))}
</List>
}
<List virtualList virtualListParams={{
items: fonts,
renderExternal: renderExternal