You've already forked joplin
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:
@ -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');
|
||||
|
Reference in New Issue
Block a user