You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-16 00:14:34 +02:00
Android: Fix error logged when opening the note editor (#11761)
This commit is contained in:
@ -376,16 +376,22 @@ function NoteEditor(props: Props, ref: any) {
|
||||
${shim.injectedJs('codeMirrorBundle')};
|
||||
|
||||
const parentElement = document.getElementsByClassName('CodeMirror')[0];
|
||||
const initialText = ${JSON.stringify(props.initialText)};
|
||||
const settings = ${JSON.stringify(editorSettings)};
|
||||
// On Android, injectJavaScript is run twice -- once before the parent element exists.
|
||||
// To avoid logging unnecessary errors to the console, skip setup in this case:
|
||||
if (parentElement) {
|
||||
const initialText = ${JSON.stringify(props.initialText)};
|
||||
const settings = ${JSON.stringify(editorSettings)};
|
||||
|
||||
window.cm = codeMirrorBundle.initCodeMirror(parentElement, initialText, settings);
|
||||
window.cm = codeMirrorBundle.initCodeMirror(parentElement, initialText, settings);
|
||||
|
||||
${setInitialSelectionJS}
|
||||
${setInitialSelectionJS}
|
||||
|
||||
window.onresize = () => {
|
||||
cm.execCommand('scrollSelectionIntoView');
|
||||
};
|
||||
window.onresize = () => {
|
||||
cm.execCommand('scrollSelectionIntoView');
|
||||
};
|
||||
} else {
|
||||
console.warn('No parent element for the editor found. This may mean that the editor HTML is still loading.');
|
||||
}
|
||||
} catch (e) {
|
||||
window.ReactNativeWebView.postMessage("error:" + e.message + ": " + JSON.stringify(e))
|
||||
}
|
||||
|
Reference in New Issue
Block a user