[DE mobile] Added background color into edit paragraph settings

This commit is contained in:
JuliaSvinareva 2021-01-12 16:42:00 +03:00
parent c2ef4ad5ff
commit 0c74ef648a
5 changed files with 130 additions and 11 deletions

View file

@ -175,7 +175,8 @@
"textFontColors": "Font Colors", "textFontColors": "Font Colors",
"textAutomatic": "Automatic", "textAutomatic": "Automatic",
"textAddCustomColor": "Add Custom Color", "textAddCustomColor": "Add Custom Color",
"textCustomColor": "Custom Color" "textCustomColor": "Custom Color",
"textBackground": "Background"
}, },
"Add": { "Add": {
"textTable": "Table", "textTable": "Table",

View file

@ -1,9 +1,11 @@
import React, {Component} from 'react'; import React, {Component} from 'react';
import { EditParagraph } from '../../view/edit/EditParagraph' import { EditParagraph } from '../../view/edit/EditParagraph';
import {observer, inject} from "mobx-react";
class EditParagraphController extends Component { class EditParagraphController extends Component {
constructor (props) { constructor (props) {
super(props); super(props);
props.storeParagraphSettings.setBackColor(undefined);
} }
onStyleClick (name) { onStyleClick (name) {
@ -129,6 +131,19 @@ class EditParagraphController extends Component {
} }
} }
onBackgroundColor (color) {
const api = Common.EditorApi.get();
const properties = new Asc.asc_CParagraphProperty();
properties.put_Shade(new Asc.asc_CParagraphShd());
if (color == 'transparent') {
properties.get_Shade().put_Value(Asc.c_oAscShdNil);
} else {
properties.get_Shade().put_Value(Asc.c_oAscShdClear);
properties.get_Shade().put_Color(Common.Utils.ThemeColor.getRgbColor(color));
}
api.paraApply(properties);
}
render () { render () {
return ( return (
<EditParagraph onStyleClick={this.onStyleClick} <EditParagraph onStyleClick={this.onStyleClick}
@ -140,9 +155,10 @@ class EditParagraphController extends Component {
onOrphan={this.onOrphan} onOrphan={this.onOrphan}
onKeepTogether={this.onKeepTogether} onKeepTogether={this.onKeepTogether}
onKeepNext={this.onKeepNext} onKeepNext={this.onKeepNext}
onBackgroundColor={this.onBackgroundColor}
/> />
) )
} }
} }
export default EditParagraphController; export default inject("storeParagraphSettings")(observer(EditParagraphController));

View file

@ -25,4 +25,28 @@ export class storeParagraphSettings {
@action changeParaStyleName (name) { @action changeParaStyleName (name) {
this.styleName = name; this.styleName = name;
} }
@observable backColor = undefined;
setBackColor (color) {
this.backColor = color;
}
getBackgroundColor (paragraphObject) {
const shade = paragraphObject.get_Shade();
let backColor = 'transparent';
if (!!shade && shade.get_Value() === Asc.c_oAscShdClear) {
const color = shade.get_Color();
if (color) {
if (color.get_type() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) {
backColor = {
color: Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()),
effectValue: color.get_value()
};
} else {
backColor = Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b());
}
}
}
this.backColor = backColor;
return backColor;
}
} }

View file

@ -15,7 +15,7 @@ import EditHyperlinkController from "../../controller/edit/EditHyperlink";
import EditHeaderController from "../../controller/edit/EditHeader"; import EditHeaderController from "../../controller/edit/EditHeader";
import {PageTextFonts, PageTextAddFormatting, PageTextBullets, PageTextNumbers, PageTextLineSpacing, PageTextFontColor, PageTextCustomFontColor, PageTextBackgroundColor, PageTextCustomBackColor} from "./EditText"; import {PageTextFonts, PageTextAddFormatting, PageTextBullets, PageTextNumbers, PageTextLineSpacing, PageTextFontColor, PageTextCustomFontColor, PageTextBackgroundColor, PageTextCustomBackColor} from "./EditText";
import {PageAdvancedSettings} from "./EditParagraph"; import {ParagraphAdvSettings, PageParagraphBackColor, PageParagraphCustomColor} from "./EditParagraph";
import {PageWrap, PageReorder, PageReplace} from "./EditShape"; import {PageWrap, PageReorder, PageReplace} from "./EditShape";
import {PageImageReorder, PageImageReplace, PageImageWrap, PageLinkSettings} from "./EditImage"; import {PageImageReorder, PageImageReplace, PageImageWrap, PageLinkSettings} from "./EditImage";
import {PageTableOptions, PageTableWrap, PageTableStyle} from "./EditTable"; import {PageTableOptions, PageTableWrap, PageTableStyle} from "./EditTable";
@ -62,7 +62,15 @@ const routes = [
//Edit paragraph //Edit paragraph
{ {
path: '/edit-paragraph-adv/', path: '/edit-paragraph-adv/',
component: PageAdvancedSettings, component: ParagraphAdvSettings,
},
{
path: '/edit-paragraph-back-color/',
component: PageParagraphBackColor,
},
{
path: '/edit-paragraph-custom-color/',
component: PageParagraphCustomColor,
}, },
//Edit shape //Edit shape
{ {

View file

@ -3,6 +3,7 @@ import {observer, inject} from "mobx-react";
import {List, ListItem, Icon, Button, Page, Navbar, Segmented, BlockTitle, Toggle} from 'framework7-react'; import {List, ListItem, Icon, Button, Page, Navbar, Segmented, BlockTitle, Toggle} from 'framework7-react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import {Device} from '../../../../../common/mobile/utils/device'; import {Device} from '../../../../../common/mobile/utils/device';
import { ThemeColorPalette, CustomColorPicker } from '../../../../../common/mobile/lib/component/ThemeColorPalette.jsx';
const PageAdvancedSettings = props => { const PageAdvancedSettings = props => {
const isAndroid = Device.android; const isAndroid = Device.android;
@ -99,21 +100,86 @@ const PageAdvancedSettings = props => {
) )
}; };
const PageCustomBackColor = props => {
const { t } = useTranslation();
const _t = t('Edit', {returnObjects: true});
let backgroundColor = props.storeParagraphSettings.backColor;
if (typeof backgroundColor === 'object') {
backgroundColor = backgroundColor.color;
}
const onAddNewColor = (colors, color) => {
props.storePalette.changeCustomColors(colors);
props.onBackgroundColor(color);
props.storeParagraphSettings.setBackColor(color);
props.f7router.back();
};
return(
<Page>
<Navbar title={_t.textCustomColor} backLink={_t.textBack} />
<CustomColorPicker currentColor={backgroundColor} onAddNewColor={onAddNewColor}/>
</Page>
)
};
const PageBackgroundColor = props => {
const { t } = useTranslation();
const _t = t('Edit', {returnObjects: true});
const backgroundColor = props.storeParagraphSettings.backColor;
const customColors = props.storePalette.customColors;
const changeColor = (color, effectId, effectValue) => {
if (color !== 'empty') {
if (effectId !==undefined ) {
const newColor = {color: color, effectId: effectId, effectValue: effectValue};
props.onBackgroundColor(newColor);
props.storeParagraphSettings.setBackColor(newColor);
} else {
props.onBackgroundColor(color);
props.storeParagraphSettings.setBackColor(color);
}
} else {
// open custom color menu
props.f7router.navigate('/edit-paragraph-custom-color/');
}
};
return(
<Page>
<Navbar title={_t.textBackground} backLink={_t.textBack} />
<ThemeColorPalette changeColor={changeColor} curColor={backgroundColor} customColors={customColors} transparent={true}/>
<List>
<ListItem title={_t.textAddCustomColor} link={'/edit-paragraph-custom-color/'} routeProps={{
onBackgroundColor: props.onBackgroundColor
}}></ListItem>
</List>
</Page>
)
};
const EditParagraph = props => { const EditParagraph = props => {
const { t } = useTranslation(); const { t } = useTranslation();
const _t = t('Edit', {returnObjects: true});
const storeParagraphSettings = props.storeParagraphSettings; const storeParagraphSettings = props.storeParagraphSettings;
const paragraphStyles = storeParagraphSettings.paragraphStyles; const paragraphStyles = storeParagraphSettings.paragraphStyles;
const curStyleName = storeParagraphSettings.styleName; const curStyleName = storeParagraphSettings.styleName;
const thumbSize = storeParagraphSettings.styleThumbSize; const thumbSize = storeParagraphSettings.styleThumbSize;
const paragraph = props.storeFocusObjects.paragraphObject;
const curBackColor = storeParagraphSettings.backColor ? storeParagraphSettings.backColor : storeParagraphSettings.getBackgroundColor(paragraph);
const background = curBackColor !== 'transparent' ? `#${(typeof curBackColor === "object" ? curBackColor.color : curBackColor)}` : curBackColor;
return ( return (
<Fragment> <Fragment>
<List> <List>
<ListItem title={t('Edit.textBackground')} link=''> <ListItem title={_t.textBackground} link='/edit-paragraph-back-color/' routeProps={{
<span className="color-preview" slot="after"></span> onBackgroundColor: props.onBackgroundColor
}}>
<span className="color-preview"
slot="after"
style={{ background: background}}
></span>
</ListItem> </ListItem>
</List> </List>
<List> <List>
<ListItem title={t('Edit.textAdvancedSettings')} link='/edit-paragraph-adv/' routeProps={{ <ListItem title={_t.textAdvancedSettings} link='/edit-paragraph-adv/' routeProps={{
onDistanceBefore: props.onDistanceBefore, onDistanceBefore: props.onDistanceBefore,
onDistanceAfter: props.onDistanceAfter, onDistanceAfter: props.onDistanceAfter,
onSpinFirstLine: props.onSpinFirstLine, onSpinFirstLine: props.onSpinFirstLine,
@ -124,7 +190,7 @@ const EditParagraph = props => {
onKeepNext: props.onKeepNext onKeepNext: props.onKeepNext
}}></ListItem> }}></ListItem>
</List> </List>
<BlockTitle>{t('Edit.textParagraphStyles')}</BlockTitle> <BlockTitle>{_t.textParagraphStyles}</BlockTitle>
<List> <List>
{paragraphStyles.map((style, index) => ( {paragraphStyles.map((style, index) => (
<ListItem <ListItem
@ -144,7 +210,11 @@ const EditParagraph = props => {
}; };
const EditParagraphContainer = inject("storeParagraphSettings", "storeFocusObjects")(observer(EditParagraph)); const EditParagraphContainer = inject("storeParagraphSettings", "storeFocusObjects")(observer(EditParagraph));
const AdvSettingsContainer = inject("storeParagraphSettings", "storeFocusObjects")(observer(PageAdvancedSettings)); const ParagraphAdvSettings = inject("storeParagraphSettings", "storeFocusObjects")(observer(PageAdvancedSettings));
const PageParagraphBackColor = inject("storeParagraphSettings", "storePalette")(observer(PageBackgroundColor));
const PageParagraphCustomColor = inject("storeParagraphSettings", "storePalette")(observer(PageCustomBackColor));
export {EditParagraphContainer as EditParagraph, export {EditParagraphContainer as EditParagraph,
AdvSettingsContainer as PageAdvancedSettings}; ParagraphAdvSettings,
PageParagraphBackColor,
PageParagraphCustomColor};