diff --git a/apps/common/mobile/resources/less/icons.less b/apps/common/mobile/resources/less/icons.less index 076f36865..26b236ec4 100644 --- a/apps/common/mobile/resources/less/icons.less +++ b/apps/common/mobile/resources/less/icons.less @@ -30,6 +30,11 @@ i.icon { height: 24px; .encoded-svg-background(''); } + &.icon-remove-style { + width: 24px; + height: 24px; + .encoded-svg-background('') + } // Formats diff --git a/apps/documenteditor/mobile/src/controller/edit/EditParagraph.jsx b/apps/documenteditor/mobile/src/controller/edit/EditParagraph.jsx index 20aabc0a4..71c5c7794 100644 --- a/apps/documenteditor/mobile/src/controller/edit/EditParagraph.jsx +++ b/apps/documenteditor/mobile/src/controller/edit/EditParagraph.jsx @@ -6,7 +6,9 @@ class EditParagraphController extends Component { constructor (props) { super(props); props.storeParagraphSettings.setBackColor(undefined); + this.onStyleClick = this.onStyleClick.bind(this); + this.onSaveStyle = this.onSaveStyle.bind(this); } onStyleClick (name) { @@ -17,6 +19,21 @@ class EditParagraphController extends Component { } } + onSaveStyle(title, nextParagraphStyle) { + const api = Common.EditorApi.get(); + const curStyleName = this.props.storeParagraphSettings.styleName; + let newStyle = new Asc.asc_CStyle(); + + newStyle.put_Name(title); + // console.log(newStyle.get_Name()); + newStyle.put_Next(nextParagraphStyle ? nextParagraphStyle : null); + newStyle.put_BasedOn(curStyleName); + // console.log(newStyle); + + api.asc_AddNewStyle(newStyle); + this.props.storeParagraphSettings.changeParaStyleName(newStyle.get_Name()); + } + onDistanceBefore (distance, isDecrement) { const api = Common.EditorApi.get(); if (api) { @@ -156,6 +173,7 @@ class EditParagraphController extends Component { onKeepTogether={this.onKeepTogether} onKeepNext={this.onKeepNext} onBackgroundColor={this.onBackgroundColor} + onSaveStyle={this.onSaveStyle} /> ) } diff --git a/apps/documenteditor/mobile/src/view/edit/EditParagraph.jsx b/apps/documenteditor/mobile/src/view/edit/EditParagraph.jsx index ce5fb3e0f..edb1f8f14 100644 --- a/apps/documenteditor/mobile/src/view/edit/EditParagraph.jsx +++ b/apps/documenteditor/mobile/src/view/edit/EditParagraph.jsx @@ -203,7 +203,10 @@ const EditParagraph = props => { {t('Edit.textParagraphStyle')} - +
@@ -256,7 +259,9 @@ const EditParagraphStyle = props => { } - + {paragraphStyles.map((style, index) => ( @@ -280,20 +285,21 @@ const EditParagraphStyle = props => { ) } -const CreateTextStyle = () => { +const CreateTextStyle = props => { const { t } = useTranslation(); const _t = t('Edit', {returnObjects: true}); const [titleNewStyle, setTitle] = useState(''); - const [nextParagraphStyle, setParagraph] = useState('Same'); + const [nextParagraphStyle, setParagraph] = useState(''); return ( {t('Edit.textCreateTextStyle')} - { - if(titleNewStyle.trim()) { - // console.log(titleNewStyle); + { + let title = titleNewStyle.trim(); + if(title) { + props.onSaveStyle(title, nextParagraphStyle); } }}>{t('Edit.textDone')} @@ -311,7 +317,7 @@ const CreateTextStyle = () => { {t('Edit.textNextParagraphStyle')} - @@ -326,7 +332,6 @@ const ChangeNextParagraphStyle = props => { const nextParagraphStyle = props.nextParagraphStyle; const storeParagraphSettings = props.storeParagraphSettings; const paragraphStyles = storeParagraphSettings.paragraphStyles; - // const curStyleName = storeParagraphSettings.styleName; const thumbSize = storeParagraphSettings.styleThumbSize; const activeStyle = Device.android ? 'link no-active-state' : 'no-active-state'; const [newParagraph, setParagraph] = useState(nextParagraphStyle); @@ -335,10 +340,10 @@ const ChangeNextParagraphStyle = props => { - { - if(nextParagraphStyle !== 'Same') { - setParagraph('Same'); - props.setParagraph('Same'); + { + if(nextParagraphStyle) { + setParagraph(''); + props.setParagraph(''); } }} title={t('Edit.textSameCreatedNewStyle')}> {paragraphStyles.map((style, index) => (