mirror of https://github.com/laurent22/joplin.git
pull/6618/head^2
parent
8f3fd0bf8b
commit
c7e3245008
|
@ -26,8 +26,9 @@ interface CodeMirrorResult {
|
|||
editor: EditorView;
|
||||
undo: Function;
|
||||
redo: Function;
|
||||
select: (anchor: number, head: number)=> void;
|
||||
insertText: (text: string)=> void;
|
||||
select(anchor: number, head: number): void;
|
||||
scrollSelectionIntoView(): void;
|
||||
insertText(text: string): void;
|
||||
}
|
||||
|
||||
function postMessage(name: string, data: any) {
|
||||
|
@ -231,6 +232,11 @@ export function initCodeMirror(parentElement: any, initialText: string, theme: a
|
|||
scrollIntoView: true,
|
||||
}));
|
||||
},
|
||||
scrollSelectionIntoView: () => {
|
||||
editor.dispatch(editor.state.update({
|
||||
scrollIntoView: true,
|
||||
}));
|
||||
},
|
||||
insertText: (text: string) => {
|
||||
editor.dispatch(editor.state.replaceSelection(text));
|
||||
},
|
||||
|
|
|
@ -266,6 +266,11 @@ function NoteEditor(props: Props, ref: any) {
|
|||
|
||||
cm = codeMirrorBundle.initCodeMirror(parentElement, initialText, theme);
|
||||
${setInitialSelectionJS}
|
||||
|
||||
// Fixes https://github.com/laurent22/joplin/issues/5949
|
||||
window.onresize = () => {
|
||||
cm.scrollSelectionIntoView();
|
||||
};
|
||||
} catch (e) {
|
||||
window.ReactNativeWebView.postMessage("error:" + e.message + ": " + JSON.stringify(e))
|
||||
} finally {
|
||||
|
|
Loading…
Reference in New Issue