mirror of
https://github.com/zadam/trilium.git
synced 2025-01-15 03:27:44 +08:00
add help button to attachment list
This commit is contained in:
parent
30bcd1764a
commit
906082a6b2
5 changed files with 36 additions and 15 deletions
|
@ -332,17 +332,22 @@ function initHelpDropdown($el) {
|
||||||
|
|
||||||
const wikiBaseUrl = "https://github.com/zadam/trilium/wiki/";
|
const wikiBaseUrl = "https://github.com/zadam/trilium/wiki/";
|
||||||
|
|
||||||
function openHelp(e) {
|
function openHelp($button) {
|
||||||
window.open(wikiBaseUrl + $(e.target).attr("data-help-page"), '_blank');
|
const helpPage = $button.attr("data-help-page");
|
||||||
|
|
||||||
|
if (helpPage) {
|
||||||
|
const url = wikiBaseUrl + helpPage;
|
||||||
|
|
||||||
|
window.open(url, '_blank');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function initHelpButtons($el) {
|
function initHelpButtons($el) {
|
||||||
// for some reason, the .on(event, listener, handler) does not work here (e.g. Options -> Sync -> Help button)
|
// for some reason, the .on(event, listener, handler) does not work here (e.g. Options -> Sync -> Help button)
|
||||||
// so we do it manually
|
// so we do it manually
|
||||||
$el.on("click", e => {
|
$el.on("click", e => {
|
||||||
if ($(e.target).attr("data-help-page")) {
|
const $helpButton = $(e.target).closest("[data-help-page]");
|
||||||
openHelp(e);
|
openHelp($helpButton);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ export default class SharedSwitchWidget extends SwitchWidget {
|
||||||
this.$switchOffButton.attr("title", "Unshare the note");
|
this.$switchOffButton.attr("title", "Unshare the note");
|
||||||
|
|
||||||
this.$helpButton.attr("data-help-page", "Sharing").show();
|
this.$helpButton.attr("data-help-page", "Sharing").show();
|
||||||
this.$helpButton.on('click', e => utils.openHelp(e));
|
this.$helpButton.on('click', e => utils.openHelp($(e.target)));
|
||||||
}
|
}
|
||||||
|
|
||||||
async switchOn() {
|
async switchOn() {
|
||||||
|
|
|
@ -110,7 +110,6 @@ export default class SwitchWidget extends NoteContextAwareWidget {
|
||||||
this.$switchOffButton.on('click', () => this.toggle(false));
|
this.$switchOffButton.on('click', () => this.toggle(false));
|
||||||
|
|
||||||
this.$helpButton = this.$widget.find(".switch-help-button");
|
this.$helpButton = this.$widget.find(".switch-help-button");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toggle(state) {
|
toggle(state) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import TypeWidget from "./type_widget.js";
|
import TypeWidget from "./type_widget.js";
|
||||||
import AttachmentDetailWidget from "../attachment_detail.js";
|
import AttachmentDetailWidget from "../attachment_detail.js";
|
||||||
import linkService from "../../services/link.js";
|
import linkService from "../../services/link.js";
|
||||||
|
import utils from "../../services/utils.js";
|
||||||
|
|
||||||
const TPL = `
|
const TPL = `
|
||||||
<div class="attachment-list note-detail-printable">
|
<div class="attachment-list note-detail-printable">
|
||||||
|
@ -14,6 +15,18 @@ const TPL = `
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
align-items: baseline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.attachment-help-button {
|
||||||
|
font-size: xx-large;
|
||||||
|
border: 0;
|
||||||
|
background: none;
|
||||||
|
cursor: pointer;
|
||||||
|
color: var(--main-text-color);
|
||||||
|
margin-left: 20px;
|
||||||
|
position: relative;
|
||||||
|
top: 8px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
@ -36,14 +49,20 @@ export default class AttachmentListTypeWidget extends TypeWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
async doRefresh(note) {
|
async doRefresh(note) {
|
||||||
|
const $helpButton = $('<button class="attachment-help-button" type="button" data-help-page="attachments" title="Open help page on attachments"><span class="bx bx-help-circle"></span></button>');
|
||||||
|
utils.initHelpButtons($helpButton);
|
||||||
|
|
||||||
this.$linksWrapper.empty().append(
|
this.$linksWrapper.empty().append(
|
||||||
$('<div>').append(
|
$('<div>').append(
|
||||||
"Owning note: ",
|
"Owning note: ",
|
||||||
await linkService.createLink(this.noteId),
|
await linkService.createLink(this.noteId),
|
||||||
),
|
),
|
||||||
$('<button class="btn btn-sm">')
|
$('<div>').append(
|
||||||
.text("Upload attachments")
|
$('<button class="btn btn-sm">')
|
||||||
.on('click', () => this.triggerCommand("showUploadAttachmentsDialog", {noteId: this.noteId}))
|
.text("Upload attachments")
|
||||||
|
.on('click', () => this.triggerCommand("showUploadAttachmentsDialog", {noteId: this.noteId})),
|
||||||
|
$helpButton
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
this.$list.empty();
|
this.$list.empty();
|
||||||
|
|
|
@ -98,11 +98,9 @@ async function createMainWindow(app) {
|
||||||
function configureWebContents(webContents, spellcheckEnabled) {
|
function configureWebContents(webContents, spellcheckEnabled) {
|
||||||
require("@electron/remote/main").enable(webContents);
|
require("@electron/remote/main").enable(webContents);
|
||||||
|
|
||||||
webContents.on('new-window', (e, url) => {
|
mainWindow.webContents.setWindowOpenHandler((details) => {
|
||||||
if (url !== webContents.getURL()) {
|
require("electron").shell.openExternal(details.url);
|
||||||
e.preventDefault();
|
return { action: 'deny' }
|
||||||
require('electron').shell.openExternal(url);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// prevent drag & drop to navigate away from trilium
|
// prevent drag & drop to navigate away from trilium
|
||||||
|
|
Loading…
Reference in a new issue