1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-23 18:53:36 +02:00

Desktop: Resolves #2810: Ctrl+Shift+B to viewer when editor invisible (#4537)

This commit is contained in:
Neeraj Kashyap 2021-03-14 08:06:38 -07:00 committed by GitHub
parent 6e0ec05d17
commit fd390dff6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -141,7 +141,11 @@ function CodeMirror(props: NoteBodyEditorProps, ref: any) {
reg.logger().warn('CodeMirror: unsupported drop item: ', cmd);
}
} else if (cmd.name === 'editor.focus') {
editorRef.current.focus();
if (props.visiblePanes.indexOf('editor') >= 0) {
editorRef.current.focus();
} else {
webviewRef.current.wrappedInstance.focus();
}
} else {
commandProcessed = false;
}
@ -242,7 +246,7 @@ function CodeMirror(props: NoteBodyEditorProps, ref: any) {
return commandOutput;
},
};
}, [props.content, addListItem, wrapSelectionWithStrings, setEditorPercentScroll, setViewerPercentScroll, resetScroll, renderedBody]);
}, [props.content, props.visiblePanes, addListItem, wrapSelectionWithStrings, setEditorPercentScroll, setViewerPercentScroll, resetScroll, renderedBody]);
const onEditorPaste = useCallback(async (event: any = null) => {
const resourceMds = await handlePasteEvent(event);

View File

@ -114,6 +114,12 @@ class NoteTextViewerComponent extends React.Component<Props, any> {
this.domReady_ = false;
}
focus() {
if (this.webviewRef_.current) {
this.webviewRef_.current.focus();
}
}
tryInit() {
if (!this.initialized_ && this.webviewRef_.current) {
this.initWebview();