Skip to content

Build your personal knowledge base with Trilium Notes

chore(desktop): solve more clipboard deprecation issues

Elian Doran8c6d2b00899c
diff --git a/apps/client/src/services/clipboard.ts b/apps/client/src/services/clipboard.ts
index 9ca5f9d092..741e2c4c60 100644
--- a/apps/client/src/services/clipboard.ts
+++ b/apps/client/src/services/clipboard.ts
@@ -79,15 +79,21 @@ async function copy(branchIds: string[]) {
if (utils.isElectron()) {
// https://github.com/zadam/trilium/issues/2401
- const { clipboard } = require("electron");
- const links: string[] = [];
+ const htmlParts: string[] = [];
+ const textParts: string[] = [];
for (const branch of froca.getBranches(clipboardBranchIds)) {
const $link = await linkService.createLink(`${branch.parentNoteId}/${branch.noteId}`, { referenceLink: true });
- links.push($link[0].outerHTML);
+ htmlParts.push($link[0].outerHTML);
+ textParts.push($link.text());
}
- clipboard.writeHTML(links.join(", "));
+ await navigator.clipboard.write([
+ new ClipboardItem({
+ "text/html": new Blob([htmlParts.join(", ")], { type: "text/html" }),
+ "text/plain": new Blob([textParts.join(", ")], { type: "text/plain" })
+ })
+ ]);
}
toastService.showMessage(t("clipboard.copied"));