mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
copy action in the tree (or ctrl+c) will also save note links to the clipboard, fixes #2401
This commit is contained in:
parent
630d9f2e45
commit
c4ab6b4866
@ -1,7 +1,8 @@
|
||||
import branchService from "./branches.js";
|
||||
import toastService from "./toast.js";
|
||||
import hoistedNoteService from "./hoisted_note.js";
|
||||
import froca from "./froca.js";
|
||||
import linkService from "./link.js";
|
||||
import utils from "./utils.js";
|
||||
|
||||
let clipboardBranchIds = [];
|
||||
let clipboardMode = null;
|
||||
@ -60,10 +61,22 @@ async function pasteInto(parentBranchId) {
|
||||
}
|
||||
}
|
||||
|
||||
function copy(branchIds) {
|
||||
async function copy(branchIds) {
|
||||
clipboardBranchIds = branchIds;
|
||||
clipboardMode = 'copy';
|
||||
|
||||
if (utils.isElectron()) {
|
||||
const {clipboard} = require('electron');
|
||||
const links = [];
|
||||
|
||||
for (const branch of froca.getBranches(clipboardBranchIds)) {
|
||||
const $link = await linkService.createNoteLink(branch.parentNoteId + '/' + branch.noteId);
|
||||
links.push($link[0].outerHTML);
|
||||
}
|
||||
|
||||
clipboard.writeHTML(links.join(', '));
|
||||
}
|
||||
|
||||
toastService.showMessage("Note(s) have been copied into clipboard.");
|
||||
}
|
||||
|
||||
|
@ -261,6 +261,7 @@ class Froca {
|
||||
return (await this.getNotes([noteId], silentNotFoundError))[0];
|
||||
}
|
||||
|
||||
/** @returns {Note|null} */
|
||||
getNoteFromCache(noteId) {
|
||||
if (!noteId) {
|
||||
throw new Error("Empty noteId");
|
||||
@ -269,6 +270,7 @@ class Froca {
|
||||
return this.notes[noteId];
|
||||
}
|
||||
|
||||
/** @returns {Branch[]} */
|
||||
getBranches(branchIds, silentNotFoundError = false) {
|
||||
return branchIds
|
||||
.map(branchId => this.getBranch(branchId, silentNotFoundError))
|
||||
|
Loading…
x
Reference in New Issue
Block a user