You've already forked joplin
							
							
				mirror of
				https://github.com/laurent22/joplin.git
				synced 2025-10-31 00:07:48 +02:00 
			
		
		
		
	Mobile: Accessibility: Improve dialog accessibility (#11395)
This commit is contained in:
		| @@ -3,7 +3,6 @@ import * as React from 'react'; | ||||
| import useOnMessage, { HandleMessageCallback, OnMarkForDownloadCallback } from './hooks/useOnMessage'; | ||||
| import { useRef, useCallback, useState, useMemo } from 'react'; | ||||
| import { View, ViewStyle } from 'react-native'; | ||||
| import BackButtonDialogBox from '../BackButtonDialogBox'; | ||||
| import ExtendedWebView from '../ExtendedWebView'; | ||||
| import { WebViewControl } from '../ExtendedWebView/types'; | ||||
| import useOnResourceLongPress from './hooks/useOnResourceLongPress'; | ||||
| @@ -37,7 +36,6 @@ interface Props { | ||||
| } | ||||
|  | ||||
| export default function NoteBodyViewer(props: Props) { | ||||
| 	const dialogBoxRef = useRef(null); | ||||
| 	const webviewRef = useRef<WebViewControl>(null); | ||||
|  | ||||
| 	const onScroll = useCallback(async (scrollTop: number) => { | ||||
| @@ -49,7 +47,6 @@ export default function NoteBodyViewer(props: Props) { | ||||
| 			onJoplinLinkClick: props.onJoplinLinkClick, | ||||
| 			onRequestEditResource: props.onRequestEditResource, | ||||
| 		}, | ||||
| 		dialogBoxRef, | ||||
| 	); | ||||
|  | ||||
| 	const onPostMessage = useOnMessage(props.noteBody, { | ||||
| @@ -101,9 +98,6 @@ export default function NoteBodyViewer(props: Props) { | ||||
| 		if (props.onLoadEnd) props.onLoadEnd(); | ||||
| 	}, [props.onLoadEnd]); | ||||
|  | ||||
| 	// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied | ||||
| 	const BackButtonDialogBox_ = BackButtonDialogBox as any; | ||||
|  | ||||
| 	const { html, injectedJs } = useSource(tempDir, props.themeId); | ||||
|  | ||||
| 	return ( | ||||
| @@ -119,7 +113,6 @@ export default function NoteBodyViewer(props: Props) { | ||||
| 				onLoadEnd={onLoadEnd} | ||||
| 				onMessage={onWebViewMessage} | ||||
| 			/> | ||||
| 			<BackButtonDialogBox_ ref={dialogBoxRef}/> | ||||
| 		</View> | ||||
| 	); | ||||
| } | ||||
|   | ||||
| @@ -1,13 +1,13 @@ | ||||
| import { useCallback } from 'react'; | ||||
| import { useCallback, useContext } from 'react'; | ||||
|  | ||||
| const { _ } = require('@joplin/lib/locale.js'); | ||||
| const { dialogs } = require('../../../utils/dialogs.js'); | ||||
| import Resource from '@joplin/lib/models/Resource'; | ||||
| import { copyToCache } from '../../../utils/ShareUtils'; | ||||
| import isEditableResource from '../../NoteEditor/ImageEditor/isEditableResource'; | ||||
| import shim from '@joplin/lib/shim'; | ||||
| import shareFile from '../../../utils/shareFile'; | ||||
| import Logger from '@joplin/utils/Logger'; | ||||
| import { DialogContext } from '../../DialogManager'; | ||||
|  | ||||
| const logger = Logger.create('useOnResourceLongPress'); | ||||
|  | ||||
| @@ -16,10 +16,11 @@ interface Callbacks { | ||||
| 	onRequestEditResource: (message: string)=> void; | ||||
| } | ||||
|  | ||||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied | ||||
| export default function useOnResourceLongPress(callbacks: Callbacks, dialogBoxRef: any) { | ||||
| export default function useOnResourceLongPress(callbacks: Callbacks) { | ||||
| 	const { onJoplinLinkClick, onRequestEditResource } = callbacks; | ||||
|  | ||||
| 	const dialogManager = useContext(DialogContext); | ||||
|  | ||||
| 	return useCallback(async (msg: string) => { | ||||
| 		try { | ||||
| 			const resourceId = msg.split(':')[1]; | ||||
| @@ -42,7 +43,7 @@ export default function useOnResourceLongPress(callbacks: Callbacks, dialogBoxRe | ||||
| 			} | ||||
| 			actions.push({ text: _('Share'), id: 'share' }); | ||||
|  | ||||
| 			const action = await dialogs.pop({ dialogbox: dialogBoxRef.current }, name, actions); | ||||
| 			const action = await dialogManager.showMenu(name, actions); | ||||
|  | ||||
| 			if (action === 'open') { | ||||
| 				onJoplinLinkClick(`joplin://${resourceId}`); | ||||
| @@ -54,7 +55,7 @@ export default function useOnResourceLongPress(callbacks: Callbacks, dialogBoxRe | ||||
| 			} | ||||
| 		} catch (e) { | ||||
| 			logger.error('Could not handle link long press', e); | ||||
| 			void shim.showMessageBox(`An error occurred, check log for details: ${e}`); | ||||
| 			void shim.showErrorDialog(`An error occurred, check log for details: ${e}`); | ||||
| 		} | ||||
| 	}, [onJoplinLinkClick, onRequestEditResource, dialogBoxRef]); | ||||
| 	}, [onJoplinLinkClick, onRequestEditResource, dialogManager]); | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user