mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-11 11:02:27 +08:00
Open an image in a new tab using ctrl+shift+click
This commit is contained in:
parent
9765f2f6d7
commit
5944d0acf4
@ -20,9 +20,10 @@ export default class AbstractTextTypeWidget extends TypeWidget {
|
|||||||
const isLeftClick = e.which === 1;
|
const isLeftClick = e.which === 1;
|
||||||
const isMiddleClick = e.which === 2;
|
const isMiddleClick = e.which === 2;
|
||||||
const ctrlKey = utils.isCtrlKey(e);
|
const ctrlKey = utils.isCtrlKey(e);
|
||||||
|
const activate = (isLeftClick && ctrlKey && e.shiftKey) || (isMiddleClick && e.shiftKey);
|
||||||
|
|
||||||
if ((isLeftClick && ctrlKey) || isMiddleClick) {
|
if ((isLeftClick && ctrlKey) || isMiddleClick) {
|
||||||
this.openImageInNewTab($(e.target));
|
this.openImageInNewTab($(e.target), activate);
|
||||||
} else if (isLeftClick && singleClickOpens) {
|
} else if (isLeftClick && singleClickOpens) {
|
||||||
this.openImageInCurrentTab($(e.target));
|
this.openImageInCurrentTab($(e.target));
|
||||||
}
|
}
|
||||||
@ -39,11 +40,11 @@ export default class AbstractTextTypeWidget extends TypeWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async openImageInNewTab($img: JQuery<HTMLElement>) {
|
async openImageInNewTab($img: JQuery<HTMLElement>, activate: boolean = false) {
|
||||||
const parsedImage = await this.parseFromImage($img);
|
const parsedImage = await this.parseFromImage($img);
|
||||||
|
|
||||||
if (parsedImage) {
|
if (parsedImage) {
|
||||||
appContext.tabManager.openTabWithNoteWithHoisting(parsedImage.noteId, { viewScope: parsedImage.viewScope });
|
appContext.tabManager.openTabWithNoteWithHoisting(parsedImage.noteId, { activate, viewScope: parsedImage.viewScope });
|
||||||
} else {
|
} else {
|
||||||
window.open($img.prop("src"), "_blank");
|
window.open($img.prop("src"), "_blank");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user