From ed550f1dceaf84344cceb600343e2894b916353d Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Tue, 2 Mar 2021 22:33:26 +0300 Subject: [PATCH] [DE mobile] Added replacing --- apps/common/mobile/lib/view/Search.jsx | 49 ++++++++++++++++--- apps/documenteditor/mobile/locale/en.json | 5 +- .../mobile/src/controller/Search.jsx | 22 ++++++--- apps/documenteditor/mobile/src/page/main.jsx | 8 +-- .../mobile/src/view/settings/Settings.jsx | 10 +++- 5 files changed, 75 insertions(+), 19 deletions(-) diff --git a/apps/common/mobile/lib/view/Search.jsx b/apps/common/mobile/lib/view/Search.jsx index 51bca9ca5..b65518223 100644 --- a/apps/common/mobile/lib/view/Search.jsx +++ b/apps/common/mobile/lib/view/Search.jsx @@ -76,6 +76,11 @@ class SearchView extends Component { constructor(props) { super(props); + this.state = { + searchQuery: '', + replaceQuery: '' + }; + $$(document).on('page:init', (e, page) => { if ( page.name == 'home' ) { this.searchbar = f7.searchbar.create({ @@ -114,16 +119,18 @@ class SearchView extends Component { this.onSettingsClick = this.onSettingsClick.bind(this); this.onSearchClick = this.onSearchClick.bind(this); + this.onReplaceClick = this.onReplaceClick.bind(this); } componentDidMount(){ const $$ = Dom7; - this.$repalce = $$('#idx-replace-val'); + this.$replace = $$('#idx-replace-val'); } onSettingsClick(e) { if ( Device.phone ) { // f7.popup.open('.settings-popup'); + f7.popover.open('#idx-search-settings', '#idx-btn-search-settings'); } else f7.popover.open('#idx-search-settings', '#idx-btn-search-settings'); } @@ -149,9 +156,18 @@ class SearchView extends Component { } } + onReplaceClick() { + if ( this.searchbar && this.searchbar.query) { + if ( this.props.onReplaceQuery ) { + let params = this.searchParams(); + this.props.onReplaceQuery(params); + } + } + } + onSearchbarShow(isshowed, bar) { if ( !isshowed ) { - this.$repalce.val(''); + this.$replace.val(''); } } @@ -187,9 +203,27 @@ class SearchView extends Component { return out; } + changeSearchQuery(value) { + this.setState({ + searchQuery: value + }); + } + + changeReplaceQuery(value) { + this.setState({ + replaceQuery: value + }); + } + render() { const usereplace = searchOptions.usereplace; const hidden = {display: "none"}; + const searchQuery = this.state.searchQuery; + const replaceQuery = this.state.replaceQuery; + + // console.log(searchQuery); + // console.log(replaceQuery) + return (
@@ -200,20 +234,23 @@ class SearchView extends Component {
- + {this.changeSearchQuery(e.target.value)}} />
- + {this.changeReplaceQuery(e.target.value)}} />
- this.onSearchClick(SEARCH_BACKWARD)}> + this.onReplaceClick()}>Replace + this.onSearchClick(SEARCH_BACKWARD)}> - this.onSearchClick(SEARCH_FORWARD)}> + this.onSearchClick(SEARCH_FORWARD)}>
diff --git a/apps/documenteditor/mobile/locale/en.json b/apps/documenteditor/mobile/locale/en.json index 00f9f0ea6..cbecaa31a 100644 --- a/apps/documenteditor/mobile/locale/en.json +++ b/apps/documenteditor/mobile/locale/en.json @@ -194,7 +194,9 @@ "advDRMPassword": "Password", "closeButtonText": "Close File", "advDRMOptions": "Protected File", - "txtProtected": "Once you enter the password and open the file, the current password to the file will be reset" + "txtProtected": "Once you enter the password and open the file, the current password to the file will be reset", + "textNoTextFound": "Text not found", + "textReplaceAll": "Replace All" }, "Edit": { "textClose": "Close", @@ -295,7 +297,6 @@ "textAutomatic": "Automatic", "textAddCustomColor": "Add Custom Color", "textCustomColor": "Custom Color", - "textBackground": "Background", "textFill": "Fill", "textBorder": "Border", "textEffects": "Effects", diff --git a/apps/documenteditor/mobile/src/controller/Search.jsx b/apps/documenteditor/mobile/src/controller/Search.jsx index 99ac30ccc..75dce02b5 100644 --- a/apps/documenteditor/mobile/src/controller/Search.jsx +++ b/apps/documenteditor/mobile/src/controller/Search.jsx @@ -2,7 +2,7 @@ import React from 'react'; import { List, ListItem, Toggle } from 'framework7-react'; import { SearchController, SearchView, SearchSettingsView } from '../../../../common/mobile/lib/controller/Search'; import { f7 } from 'framework7-react'; - +// import { useTranslation, withTranslation } from 'react-i18next'; class SearchSettings extends SearchSettingsView { constructor(props) { @@ -58,18 +58,26 @@ class DESearchView extends SearchView { } const Search = props => { + const onSearchQuery = params => { const api = Common.EditorApi.get(); - - if ( !params.replace ) { - if ( !api.asc_findText(params.find, params.forward, params.caseSensitive, params.highlight) ) { - f7.dialog.alert('there are no more results', e => { - }); + + if (params.find && params.find.length) { + if (!api.asc_findText(params.find, params.forward, params.caseSensitive, params.highlight) ) { + f7.dialog.alert(null, 'Text not Found'); } } }; - return + const onReplaceQuery = params => { + const api = Common.EditorApi.get(); + + if (params.find && params.find.length) { + api.asc_replaceText(params.find, params.replace, false, params.caseSensitive, params.highlight); + } + } + + return }; export {Search, SearchSettings} diff --git a/apps/documenteditor/mobile/src/page/main.jsx b/apps/documenteditor/mobile/src/page/main.jsx index 8775dcdd7..93e165f05 100644 --- a/apps/documenteditor/mobile/src/page/main.jsx +++ b/apps/documenteditor/mobile/src/page/main.jsx @@ -71,15 +71,17 @@ export default class MainPage extends Component { this.handleClickToOpenOptions('coauth')}> this.handleClickToOpenOptions('settings')}> - { Device.phone ? null : } + {/* { Device.phone ? null : } */} + {/* Page content */} - { + {/* { Device.phone ? null : - } + } */} + { !this.state.editOptionsVisible ? null : diff --git a/apps/documenteditor/mobile/src/view/settings/Settings.jsx b/apps/documenteditor/mobile/src/view/settings/Settings.jsx index 8d74639b9..a199d82e3 100644 --- a/apps/documenteditor/mobile/src/view/settings/Settings.jsx +++ b/apps/documenteditor/mobile/src/view/settings/Settings.jsx @@ -64,6 +64,14 @@ const SettingsList = inject("storeAppOptions")( observer( withTranslation()( pro props.onOptionClick(page) }; + const closeModal = () => { + if (Device.phone) { + f7.sheet.close('.settings-popup', true); + } else { + f7.popover.close('#settings-popover'); + } + }; + useEffect(() => { }); @@ -100,7 +108,7 @@ const SettingsList = inject("storeAppOptions")( observer( withTranslation()( pro {navbar} {!props.inPopover && - + }