diff --git a/apps/mobile/initializer.root.js b/apps/mobile/initializer.root.js index 266442dcd..d5a5e9ec2 100644 --- a/apps/mobile/initializer.root.js +++ b/apps/mobile/initializer.root.js @@ -57,6 +57,7 @@ const onChangeTab = async (obj) => { if (getNote()?.locked) { eSendEvent(eClearEditor); } + eSendEvent("showTooltip"); editing.movedAway = true; tiny.call(EditorWebView, tiny.blur); } diff --git a/apps/mobile/src/views/Editor/EditorHeader.js b/apps/mobile/src/views/Editor/EditorHeader.js index 66c283f69..6aac6c956 100644 --- a/apps/mobile/src/views/Editor/EditorHeader.js +++ b/apps/mobile/src/views/Editor/EditorHeader.js @@ -32,6 +32,7 @@ import { } from './Functions'; import HistoryComponent from './HistoryComponent'; import tiny from './tiny/tiny'; +import { toolbarRef } from './tiny/toolbar/constants'; let handleBack; let tapCount = 0; @@ -46,23 +47,12 @@ const EditorHeader = () => { }, [colors.bg]); const _onBackPress = async () => { - if (sideMenuRef.current === null) { - if (tapCount > 0) { - tapCount = 0; - setIntent(false); - editing.currentlyEditing = false; - await clearEditor(); - RNExitApp.exitApp(); - } else { - await saveNote(); - tapCount = 1; - setTimeout(() => { - tapCount = 0; - }, 3000); - ToastEvent.show('Note saved, press back again to exit app.', 'success'); - } - return true; - } + eSendEvent("showTooltip"); + toolbarRef.current?.scrollTo({ + x:0, + y:0, + animated:false + }) editing.isFocused = false; editing.currentlyEditing = false; if (DDS.isLargeTablet()) { diff --git a/apps/mobile/src/views/Editor/EditorRoot.js b/apps/mobile/src/views/Editor/EditorRoot.js index fee8041d3..bfc171534 100644 --- a/apps/mobile/src/views/Editor/EditorRoot.js +++ b/apps/mobile/src/views/Editor/EditorRoot.js @@ -28,6 +28,7 @@ import { saveNote, setIntent, } from './Functions'; +import { toolbarRef } from './tiny/toolbar/constants'; let handleBack; let tapCount = 0; @@ -95,23 +96,12 @@ const EditorRoot = () => { }; const _onBackPress = async () => { - if (sideMenuRef.current === null) { - if (tapCount > 0) { - tapCount = 0; - setIntent(false); - editing.currentlyEditing = false; - await clearEditor(); - RNExitApp.exitApp(); - } else { - await saveNote(); - tapCount = 1; - setTimeout(() => { - tapCount = 0; - }, 3000); - ToastEvent.show('Note saved, press back again to exit app.', 'success'); - } - return true; - } + eSendEvent("showTooltip"); + toolbarRef.current?.scrollTo({ + x:0, + y:0, + animated:false + }) editing.currentlyEditing = false; if (DDS.isLargeTablet()) { if (fullscreen) { diff --git a/apps/mobile/src/views/Editor/tiny/toolbar/constants.js b/apps/mobile/src/views/Editor/tiny/toolbar/constants.js index f3c06a1d7..b30a35f2e 100644 --- a/apps/mobile/src/views/Editor/tiny/toolbar/constants.js +++ b/apps/mobile/src/views/Editor/tiny/toolbar/constants.js @@ -1,3 +1,4 @@ +import { createRef } from 'react'; import {Platform} from 'react-native'; import { eSendEvent } from '../../../../services/EventManager'; import {EditorWebView} from '../../Functions'; @@ -10,6 +11,8 @@ export const properties = { userBlur: false, }; +export const toolbarRef = createRef(); + export function formatSelection(command) { EditorWebView.current?.injectJavaScript(command); } diff --git a/apps/mobile/src/views/Editor/tiny/toolbar/index.js b/apps/mobile/src/views/Editor/tiny/toolbar/index.js index 51e1dd519..d96641bdf 100644 --- a/apps/mobile/src/views/Editor/tiny/toolbar/index.js +++ b/apps/mobile/src/views/Editor/tiny/toolbar/index.js @@ -4,7 +4,7 @@ import {ScrollView} from 'react-native'; import {useTracked} from '../../../../provider'; import {eSendEvent} from '../../../../services/EventManager'; import {TOOLBAR_CONFIG} from './config'; -import {properties} from './constants'; +import {properties, toolbarRef} from './constants'; import ToolbarGroup from './group'; import Tooltip from './tooltip'; @@ -29,6 +29,7 @@ const EditorToolbar = React.memo( }}>