1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-16 00:14:34 +02:00

Mobile: Accessibility: Auto-fill the editor search input with the global search (#12291)

This commit is contained in:
Henry Heino
2025-05-19 14:55:32 -07:00
committed by GitHub
parent 1a6059072a
commit 12c688eb83
3 changed files with 12 additions and 2 deletions

View File

@ -43,6 +43,7 @@ interface Props {
initialText: string;
noteId: string;
noteHash: string;
globalSearch: string;
initialSelection?: SelectionRange;
style: ViewStyle;
toolbarEnabled: boolean;
@ -329,13 +330,19 @@ const useEditorControl = (
function NoteEditor(props: Props, ref: any) {
const webviewRef = useRef<WebViewControl>(null);
const setInitialSelectionJS = props.initialSelection ? `
const setInitialSelectionJs = props.initialSelection ? `
cm.select(${props.initialSelection.start}, ${props.initialSelection.end});
cm.execCommand('scrollSelectionIntoView');
` : '';
const jumpToHashJs = props.noteHash ? `
cm.jumpToHash(${JSON.stringify(props.noteHash)});
` : '';
const setInitialSearchJs = props.globalSearch ? `
cm.setSearchState(${JSON.stringify({
...defaultSearchState,
searchText: props.globalSearch,
})})
` : '';
const editorSettings: EditorSettings = useMemo(() => ({
themeId: props.themeId,
@ -398,7 +405,8 @@ function NoteEditor(props: Props, ref: any) {
${jumpToHashJs}
// Set the initial selection after jumping to the header -- the initial selection,
// if specified, should take precedence.
${setInitialSelectionJS}
${setInitialSelectionJs}
${setInitialSearchJs}
window.onresize = () => {
cm.execCommand('scrollSelectionIntoView');