From de79f6e5260e154c286148909264c38e59209d00 Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Wed, 10 Mar 2021 19:51:22 +0300 Subject: [PATCH] [PE mobile] Added Find and Replace --- apps/common/mobile/lib/view/Search.jsx | 7 +- .../mobile/src/controller/Search.jsx | 2 - apps/presentationeditor/mobile/locale/en.json | 10 ++- .../mobile/src/controller/Search.jsx | 81 +++++++++++++++++++ .../mobile/src/less/app.less | 4 + .../mobile/src/page/main.jsx | 9 ++- .../mobile/src/view/settings/Settings.jsx | 6 +- 7 files changed, 110 insertions(+), 9 deletions(-) create mode 100644 apps/presentationeditor/mobile/src/controller/Search.jsx diff --git a/apps/common/mobile/lib/view/Search.jsx b/apps/common/mobile/lib/view/Search.jsx index 51c911cda..68a57f341 100644 --- a/apps/common/mobile/lib/view/Search.jsx +++ b/apps/common/mobile/lib/view/Search.jsx @@ -55,7 +55,7 @@ class SearchSettingsView extends Component { ; const extra = this.extraSearchOptions(); const content = - + {navbar} @@ -83,6 +83,8 @@ class SearchView extends Component { replaceQuery: '' }; + const $$ = Dom7; + $$(document).on('page:init', (e, page) => { if ( page.name == 'home' ) { this.searchbar = f7.searchbar.create({ @@ -104,7 +106,6 @@ class SearchView extends Component { // return (m = /(iPad|iPhone|iphone).*?(OS |os |OS\_)(\d+((_|\.)\d)?((_|\.)\d)?)/.exec(ua)) ? parseFloat(m[3]) : 0; // } - const $$ = Dom7; const $editor = $$('#editor_sdk'); const $replaceLink = $$('#replace-link'); @@ -195,10 +196,12 @@ class SearchView extends Component { onEditorTouchStart(e) { this.startPoint = this.pointerPosition(e); + // console.log(this.startPoint); } onEditorTouchEnd(e) { const endPoint = this.pointerPosition(e); + // console.log(endPoint); if ( this.searchbar.enabled ) { const distance = (this.startPoint.x === undefined || this.startPoint.y === undefined) ? 0 : diff --git a/apps/documenteditor/mobile/src/controller/Search.jsx b/apps/documenteditor/mobile/src/controller/Search.jsx index 3f7bb08bf..0da97f37e 100644 --- a/apps/documenteditor/mobile/src/controller/Search.jsx +++ b/apps/documenteditor/mobile/src/controller/Search.jsx @@ -66,8 +66,6 @@ const Search = props => { if (params.find && params.find.length) { if (!api.asc_findText(params.find, params.forward, params.caseSensitive, params.highlight) ) { - // const { t } = useTranslation(); - // const _t = t('View.Settings', {returnObjects: true}); f7.dialog.alert(null, 'Text not Found'); } } diff --git a/apps/presentationeditor/mobile/locale/en.json b/apps/presentationeditor/mobile/locale/en.json index 9f00933f2..ea418aa9c 100644 --- a/apps/presentationeditor/mobile/locale/en.json +++ b/apps/presentationeditor/mobile/locale/en.json @@ -244,7 +244,15 @@ "textRemoveLink": "Remove Link", "textDisplay": "Display", "textScreenTip": "Screen Tip", - "textDefault": "Selected text" + "textDefault": "Selected text", + "textNoTextFound": "Text not found", + "textReplaceAll": "Replace All", + "textFind": "Find", + "textFindAndReplace": "Find and Replace", + "textDone": "Done", + "textSearch": "Search", + "textCase": "Case sensitive", + "textHighlight": "Highlight results" } }, "Common": { diff --git a/apps/presentationeditor/mobile/src/controller/Search.jsx b/apps/presentationeditor/mobile/src/controller/Search.jsx new file mode 100644 index 000000000..37f8f7548 --- /dev/null +++ b/apps/presentationeditor/mobile/src/controller/Search.jsx @@ -0,0 +1,81 @@ +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) { + super(props); + } + + extraSearchOptions() { + const anc_markup = super.extraSearchOptions(); + + const markup = + + + + ; + + return {...anc_markup, ...markup}; + } +} + +class PESearchView extends SearchView { + searchParams() { + let params = super.searchParams(); + + const checkboxCaseSensitive = f7.toggle.get('.toggle-case-sensitive'); + const searchOptions = { + caseSensitive: checkboxCaseSensitive.checked, + }; + + return {...params, ...searchOptions}; + } + + onSearchbarShow(isshowed, bar) { + super.onSearchbarShow(isshowed, bar); + + // const api = Common.EditorApi.get(); + // if ( isshowed ) { + // const checkboxMarkResults = f7.toggle.get('.toggle-mark-results'); + // api.asc_selectSearchingResults(checkboxMarkResults.checked); + // } else api.asc_selectSearchingResults(false); + } +} + +const Search = props => { + // const { t } = useTranslation(); + // const _t = t('View.Settings', {returnObjects: true}); + + const onSearchQuery = params => { + const api = Common.EditorApi.get(); + + if (params.find && params.find.length) { + if (!api.findText(params.find, params.forward, params.caseSensitive) ) { + f7.dialog.alert(null, 'Text not Found'); + } + } + }; + + const onReplaceQuery = params => { + const api = Common.EditorApi.get(); + + if (params.find && params.find.length) { + api.asc_replaceText(params.find, params.replace, false, params.caseSensitive); + } + } + + const onReplaceAllQuery = params => { + const api = Common.EditorApi.get(); + + if (params.find && params.find.length) { + api.asc_replaceText(params.find, params.replace, true, params.caseSensitive); + } + } + + return +}; + +export {Search, SearchSettings} diff --git a/apps/presentationeditor/mobile/src/less/app.less b/apps/presentationeditor/mobile/src/less/app.less index 5d0124ddb..4297bfb61 100644 --- a/apps/presentationeditor/mobile/src/less/app.less +++ b/apps/presentationeditor/mobile/src/less/app.less @@ -1,12 +1,16 @@ @themeColor: #aa5252; +@import '../../../../../vendor/framework7-react/node_modules/framework7/less/mixins.less'; + @import '../../../../common/mobile/resources/less/_mixins.less'; @import '../../../../common/mobile/resources/less/collaboration.less'; @import '../../../../common/mobile/resources/less/common.less'; @import '../../../../common/mobile/resources/less/common-ios.less'; @import '../../../../common/mobile/resources/less/common-material.less'; +@import '../../../../common/mobile/resources/less/icons.less'; @import '../../../../common/mobile/resources/less/dataview.less'; @import '../../../../common/mobile/resources/less/about.less'; +@import '../../../../common/mobile/resources/less/search.less'; @import './app-material.less'; @import './app-ios.less'; @import './icons-ios.less'; diff --git a/apps/presentationeditor/mobile/src/page/main.jsx b/apps/presentationeditor/mobile/src/page/main.jsx index 5bd43e73b..2f4844379 100644 --- a/apps/presentationeditor/mobile/src/page/main.jsx +++ b/apps/presentationeditor/mobile/src/page/main.jsx @@ -4,7 +4,9 @@ import { Page, View, Navbar, NavLeft, NavRight, Link, Icon } from 'framework7-re import EditOptions from '../view/edit/Edit'; import AddOptions from '../view/add/Add'; import Settings from '../view/settings/Settings'; -import CollaborationView from '../../../../common/mobile/lib/view/collaboration/Collaboration.jsx' +import CollaborationView from '../../../../common/mobile/lib/view/collaboration/Collaboration.jsx'; +import { Device } from '../../../../common/mobile/utils/device'; +import { Search, SearchSettings } from '../controller/Search'; export default class MainPage extends Component { constructor(props) { @@ -58,12 +60,17 @@ export default class MainPage extends Component { this.handleClickToOpenOptions('edit')}> this.handleClickToOpenOptions('add')}> + { Device.phone ? null : } this.handleClickToOpenOptions('coauth')}> this.handleClickToOpenOptions('settings')}> + {/* Page content */} + + + { !this.state.editOptionsVisible ? null : diff --git a/apps/presentationeditor/mobile/src/view/settings/Settings.jsx b/apps/presentationeditor/mobile/src/view/settings/Settings.jsx index 094ecb6cf..43deb4bdf 100644 --- a/apps/presentationeditor/mobile/src/view/settings/Settings.jsx +++ b/apps/presentationeditor/mobile/src/view/settings/Settings.jsx @@ -106,9 +106,9 @@ const SettingsList = withTranslation()(props => { {navbar} {!props.inPopover && - - - + + + }