mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
fix scroll to top for read only / editable text note after switching note
This commit is contained in:
parent
28cb3976e5
commit
04ea8dd4b3
@ -2,6 +2,7 @@ import treeService from './tree.js';
|
|||||||
import contextMenu from "./context_menu.js";
|
import contextMenu from "./context_menu.js";
|
||||||
import appContext from "./app_context.js";
|
import appContext from "./app_context.js";
|
||||||
import treeCache from "./tree_cache.js";
|
import treeCache from "./tree_cache.js";
|
||||||
|
import utils from "./utils.js";
|
||||||
|
|
||||||
function getNotePathFromUrl(url) {
|
function getNotePathFromUrl(url) {
|
||||||
const notePathMatch = /#(root[A-Za-z0-9/]*)$/.exec(url);
|
const notePathMatch = /#(root[A-Za-z0-9/]*)$/.exec(url);
|
||||||
@ -89,9 +90,16 @@ function goToLink(e) {
|
|||||||
|| $link.hasClass("ck-link-actions__preview") // within edit link dialog single click suffices
|
|| $link.hasClass("ck-link-actions__preview") // within edit link dialog single click suffices
|
||||||
) {
|
) {
|
||||||
const address = $link.attr('href');
|
const address = $link.attr('href');
|
||||||
|
console.log("address", address);
|
||||||
|
if (address) {
|
||||||
|
if (address.toLowerCase().startsWith('http')) {
|
||||||
|
window.open(address, '_blank');
|
||||||
|
}
|
||||||
|
else if (address.toLowerCase().startsWith('file:') && utils.isElectron()) {
|
||||||
|
const electron = utils.dynamicRequire('electron');
|
||||||
|
|
||||||
if (address && address.startsWith('http')) {
|
electron.shell.openPath(address);
|
||||||
window.open(address, '_blank');
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,10 +65,6 @@ export default class ReadOnlyTextTypeWidget extends AbstractTextTypeWidget {
|
|||||||
this.$content.html('');
|
this.$content.html('');
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollToTop() {
|
|
||||||
this.$content.scrollTop(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
async doRefresh(note) {
|
async doRefresh(note) {
|
||||||
const noteComplement = await treeCache.getNoteComplement(note.noteId);
|
const noteComplement = await treeCache.getNoteComplement(note.noteId);
|
||||||
|
|
||||||
|
@ -25,6 +25,12 @@ export default class TypeWidget extends TabAwareWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async noteSwitched() {
|
||||||
|
this.scrollToTop();
|
||||||
|
|
||||||
|
await super.noteSwitched();
|
||||||
|
}
|
||||||
|
|
||||||
isActive() {
|
isActive() {
|
||||||
return this.$widget.is(":visible");
|
return this.$widget.is(":visible");
|
||||||
}
|
}
|
||||||
@ -54,4 +60,4 @@ export default class TypeWidget extends TabAwareWidget {
|
|||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user