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

@ -48,6 +48,7 @@ describe('NoteEditor', () => {
<NoteEditor
themeId={Setting.THEME_ARITIM_DARK}
initialText='Testing...'
globalSearch=''
noteId=''
noteHash=''
style={{}}

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');

View File

@ -1587,6 +1587,7 @@ class NoteScreenComponent extends BaseScreenComponent<ComponentProps, State> imp
noteHash={this.props.noteHash}
initialText={note.body}
initialSelection={this.selection}
globalSearch={this.props.searchQuery}
onChange={this.onMarkdownEditorTextChange}
onSelectionChange={this.onMarkdownEditorSelectionChange}
onUndoRedoDepthChange={this.onUndoRedoDepthChange}