From 68854f47ddebaace2f9714bf94fdc11f016f0931 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Thu, 21 Jan 2021 23:25:12 +0300 Subject: [PATCH] [DE mobile] Added the ability to insert page number --- apps/documenteditor/mobile/locale/en.json | 10 ++++- .../mobile/src/controller/add/AddOther.jsx | 39 +++++++++++++++++++ .../mobile/src/view/add/Add.jsx | 6 ++- .../mobile/src/view/add/AddOther.jsx | 27 ++++++++++++- 4 files changed, 78 insertions(+), 4 deletions(-) diff --git a/apps/documenteditor/mobile/locale/en.json b/apps/documenteditor/mobile/locale/en.json index ca2b5abc6..01e15bc60 100644 --- a/apps/documenteditor/mobile/locale/en.json +++ b/apps/documenteditor/mobile/locale/en.json @@ -246,6 +246,14 @@ "textAddLink": "Add Link", "textDisplay": "Display", "textScreenTip": "Screen Tip", - "textInsert": "Insert" + "textInsert": "Insert", + "textPosition": "Position", + "textLeftTop": "Left Top", + "textCenterTop": "Center Top", + "textRightTop": "Right Top", + "textLeftBottom": "Left Bottom", + "textCenterBottom": "Center Bottom", + "textRightBottom": "Right Bottom", + "textCurrentPosition": "Current Position" } } \ No newline at end of file diff --git a/apps/documenteditor/mobile/src/controller/add/AddOther.jsx b/apps/documenteditor/mobile/src/controller/add/AddOther.jsx index f577e8fd7..19412ca62 100644 --- a/apps/documenteditor/mobile/src/controller/add/AddOther.jsx +++ b/apps/documenteditor/mobile/src/controller/add/AddOther.jsx @@ -9,6 +9,7 @@ class AddOtherController extends Component { constructor (props) { super(props); this.onInsertLink = this.onInsertLink.bind(this); + this.onInsertPageNumber = this.onInsertPageNumber.bind(this); } closeModal () { @@ -55,10 +56,48 @@ class AddOtherController extends Component { this.closeModal(); } + onInsertPageNumber (type) { + const api = Common.EditorApi.get(); + + let value = -1; + + if (2 == type.length) { + const c_pageNumPosition = { + PAGE_NUM_POSITION_TOP: 0x01, + PAGE_NUM_POSITION_BOTTOM: 0x02, + PAGE_NUM_POSITION_RIGHT: 0, + PAGE_NUM_POSITION_LEFT: 1, + PAGE_NUM_POSITION_CENTER: 2 + }; + value = {}; + + if (type[0] == 'l') { + value.subtype = c_pageNumPosition.PAGE_NUM_POSITION_LEFT; + } else if (type[0] == 'c') { + value.subtype = c_pageNumPosition.PAGE_NUM_POSITION_CENTER; + } else if (type[0] == 'r') { + value.subtype = c_pageNumPosition.PAGE_NUM_POSITION_RIGHT; + } + + if (type[1] == 't') { + value.type = c_pageNumPosition.PAGE_NUM_POSITION_TOP; + } else if (type[1] == 'b') { + value.type = c_pageNumPosition.PAGE_NUM_POSITION_BOTTOM; + } + + api.put_PageNum(value.type, value.subtype); + } else { + api.put_PageNum(value); + } + + this.closeModal(); + } + render () { return ( ) } diff --git a/apps/documenteditor/mobile/src/view/add/Add.jsx b/apps/documenteditor/mobile/src/view/add/Add.jsx index ad283016b..df4d740e6 100644 --- a/apps/documenteditor/mobile/src/view/add/Add.jsx +++ b/apps/documenteditor/mobile/src/view/add/Add.jsx @@ -11,7 +11,7 @@ import {AddImageController} from "../../controller/add/AddImage"; import {AddOtherController} from "../../controller/add/AddOther"; import {PageImageLinkSettings} from "../add/AddImage"; -import {PageAddLink} from "../add/AddOther"; +import {PageAddLink, PageAddNumber} from "../add/AddOther"; const routes = [ // Image @@ -24,6 +24,10 @@ const routes = [ path: '/add-link/', component: PageAddLink, }, + { + path: '/add-page-number/', + component: PageAddNumber, + }, ]; const AddLayoutNavbar = ({ tabs, inPopover }) => { diff --git a/apps/documenteditor/mobile/src/view/add/AddOther.jsx b/apps/documenteditor/mobile/src/view/add/AddOther.jsx index 91d6df2ab..f24f930ea 100644 --- a/apps/documenteditor/mobile/src/view/add/AddOther.jsx +++ b/apps/documenteditor/mobile/src/view/add/AddOther.jsx @@ -48,6 +48,25 @@ const PageLink = props => { ) }; +const PageNumber = props => { + const { t } = useTranslation(); + const _t = t('Add', {returnObjects: true}); + return ( + + + + {props.onInsertPageNumber('lt')}}> + {props.onInsertPageNumber('ct')}}> + {props.onInsertPageNumber('rt')}}> + {props.onInsertPageNumber('lb')}}> + {props.onInsertPageNumber('cb')}}> + {props.onInsertPageNumber('rb')}}> + {props.onInsertPageNumber('current')}}> + + + ) +}; + const AddOther = props => { const { t } = useTranslation(); const _t = t('Add', {returnObjects: true}); @@ -62,7 +81,9 @@ const AddOther = props => { }}> - + @@ -75,4 +96,6 @@ const AddOther = props => { ) }; -export {AddOther, PageLink as PageAddLink}; \ No newline at end of file +export {AddOther, + PageLink as PageAddLink, + PageNumber as PageAddNumber}; \ No newline at end of file