mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-26 18:58:21 +02:00
parent
4115e2054f
commit
77e74112ad
@ -14,6 +14,7 @@ import createEditor from '@joplin/editor/CodeMirror/createEditor';
|
|||||||
import CodeMirrorControl from '@joplin/editor/CodeMirror/CodeMirrorControl';
|
import CodeMirrorControl from '@joplin/editor/CodeMirror/CodeMirrorControl';
|
||||||
import WebViewToRNMessenger from '../../../utils/ipc/WebViewToRNMessenger';
|
import WebViewToRNMessenger from '../../../utils/ipc/WebViewToRNMessenger';
|
||||||
import { WebViewToEditorApi } from '../types';
|
import { WebViewToEditorApi } from '../types';
|
||||||
|
import { focus } from '@joplin/lib/utils/focusHandler';
|
||||||
|
|
||||||
export const initCodeMirror = (
|
export const initCodeMirror = (
|
||||||
parentElement: HTMLElement,
|
parentElement: HTMLElement,
|
||||||
@ -47,6 +48,15 @@ export const initCodeMirror = (
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Note: Just adding an onclick listener seems sufficient to focus the editor when its background
|
||||||
|
// is tapped.
|
||||||
|
parentElement.addEventListener('click', (event) => {
|
||||||
|
const activeElement = document.querySelector(':focus');
|
||||||
|
if (!parentElement.contains(activeElement) && event.target === parentElement) {
|
||||||
|
focus('initial editor focus', control);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
messenger.setLocalInterface(control);
|
messenger.setLocalInterface(control);
|
||||||
return control;
|
return control;
|
||||||
};
|
};
|
||||||
|
@ -101,10 +101,6 @@ function useHtml(initialCss: string): string {
|
|||||||
scrolling. */
|
scrolling. */
|
||||||
.cm-scroller {
|
.cm-scroller {
|
||||||
overflow: none;
|
overflow: none;
|
||||||
|
|
||||||
/* Ensure that the editor can be focused by clicking on the lower half of the screen.
|
|
||||||
Don't use 100vh to prevent a scrollbar being present for empty notes. */
|
|
||||||
min-height: 80vh;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<style class=${JSON.stringify(themeStyleSheetClassName)}>
|
<style class=${JSON.stringify(themeStyleSheetClassName)}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user