mirror of
https://github.com/laurent22/joplin.git
synced 2025-02-01 19:15:01 +02:00
Deskop: Fixed shortcut to focus the note body (#5597)
This commit is contained in:
parent
0b01b5b0ef
commit
8de9032321
@ -147,7 +147,9 @@ function CodeMirror(props: NoteBodyEditorProps, ref: any) {
|
|||||||
if (props.visiblePanes.indexOf('editor') >= 0) {
|
if (props.visiblePanes.indexOf('editor') >= 0) {
|
||||||
editorRef.current.focus();
|
editorRef.current.focus();
|
||||||
} else {
|
} else {
|
||||||
webviewRef.current.wrappedInstance.focus();
|
// If we just call wrappedInstance.focus() then the iframe is focused,
|
||||||
|
// but not its content, such that scrolling up / down with arrow keys fails
|
||||||
|
webviewRef.current.wrappedInstance.send('focus');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
commandProcessed = false;
|
commandProcessed = false;
|
||||||
|
@ -146,6 +146,10 @@ class NoteTextViewerComponent extends React.Component<Props, any> {
|
|||||||
send(channel: string, arg0: any = null, arg1: any = null) {
|
send(channel: string, arg0: any = null, arg1: any = null) {
|
||||||
const win = this.webviewRef_.current.contentWindow;
|
const win = this.webviewRef_.current.contentWindow;
|
||||||
|
|
||||||
|
if (channel === 'focus') {
|
||||||
|
win.postMessage({ target: 'webview', name: 'focus', data: {} }, '*');
|
||||||
|
}
|
||||||
|
|
||||||
if (channel === 'setHtml') {
|
if (channel === 'setHtml') {
|
||||||
win.postMessage({ target: 'webview', name: 'setHtml', data: { html: arg0, options: arg1 } }, '*');
|
win.postMessage({ target: 'webview', name: 'setHtml', data: { html: arg0, options: arg1 } }, '*');
|
||||||
}
|
}
|
||||||
|
@ -197,6 +197,17 @@
|
|||||||
|
|
||||||
let checkAllImageLoadedIID_ = null;
|
let checkAllImageLoadedIID_ = null;
|
||||||
|
|
||||||
|
ipc.focus = (event) => {
|
||||||
|
const dummyID = 'joplin-content-focus-dummy';
|
||||||
|
if (! document.getElementById(dummyID)) {
|
||||||
|
const focusDummy = '<div style="width: 0; height: 0; overflow: hidden"><a id="' + dummyID + '" href="#">focus dummy</a></div>';
|
||||||
|
contentElement.insertAdjacentHTML("afterbegin", focusDummy);
|
||||||
|
}
|
||||||
|
const scrollTop = contentElement.scrollTop;
|
||||||
|
document.getElementById(dummyID).focus();
|
||||||
|
contentElement.scrollTop = scrollTop;
|
||||||
|
}
|
||||||
|
|
||||||
ipc.setHtml = (event) => {
|
ipc.setHtml = (event) => {
|
||||||
const html = event.html;
|
const html = event.html;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user