You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-26 22:41:17 +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')};
|
${shim.injectedJs('codeMirrorBundle')};
|
||||||
|
|
||||||
const parentElement = document.getElementsByClassName('CodeMirror')[0];
|
const parentElement = document.getElementsByClassName('CodeMirror')[0];
|
||||||
const initialText = ${JSON.stringify(props.initialText)};
|
// On Android, injectJavaScript is run twice -- once before the parent element exists.
|
||||||
const settings = ${JSON.stringify(editorSettings)};
|
// 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 = () => {
|
window.onresize = () => {
|
||||||
cm.execCommand('scrollSelectionIntoView');
|
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) {
|
} catch (e) {
|
||||||
window.ReactNativeWebView.postMessage("error:" + e.message + ": " + JSON.stringify(e))
|
window.ReactNativeWebView.postMessage("error:" + e.message + ": " + JSON.stringify(e))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user