Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(client/ts): port services/clipboard
Elian Doran911323c0990c
diff --git a/src/public/app/services/branches.ts b/src/public/app/services/branches.tsindex 20a8ec5527..6eb5c07ff0 100644--- a/src/public/app/services/branches.ts+++ b/src/public/app/services/branches.ts@@ -255,7 +255,7 @@ ws.subscribeToMessages(async message => {}});-async function cloneNoteToBranch(childNoteId: string, parentBranchId: string, prefix: string) {+async function cloneNoteToBranch(childNoteId: string, parentBranchId: string, prefix?: string) {const resp = await server.put<Response>(`notes/${childNoteId}/clone-to-branch/${parentBranchId}`, {prefix: prefix});diff --git a/src/public/app/services/clipboard.js b/src/public/app/services/clipboard.tssimilarity index 83%rename from src/public/app/services/clipboard.jsrename to src/public/app/services/clipboard.tsindex dda27f5980..d1cb708e39 100644--- a/src/public/app/services/clipboard.js+++ b/src/public/app/services/clipboard.ts@@ -5,10 +5,10 @@ import linkService from "./link.js";import utils from "./utils.js";import { t } from "./i18n.js";-let clipboardBranchIds = [];-let clipboardMode = null;+let clipboardBranchIds: string[] = [];+let clipboardMode: string | null = null;-async function pasteAfter(afterBranchId) {+async function pasteAfter(afterBranchId: string) {if (isClipboardEmpty()) {return;}@@ -23,7 +23,14 @@ async function pasteAfter(afterBranchId) {const clipboardBranches = clipboardBranchIds.map(branchId => froca.getBranch(branchId));for (const clipboardBranch of clipboardBranches) {+ if (!clipboardBranch) {+ continue;+ }+const clipboardNote = await clipboardBranch.getNote();+ if (!clipboardNote) {+ continue;+ }await branchService.cloneNoteAfter(clipboardNote.noteId, afterBranchId);}@@ -35,7 +42,7 @@ async function pasteAfter(afterBranchId) {}}-async function pasteInto(parentBranchId) {+async function pasteInto(parentBranchId: string) {if (isClipboardEmpty()) {return;}@@ -50,7 +57,14 @@ async function pasteInto(parentBranchId) {const clipboardBranches = clipboardBranchIds.map(branchId => froca.getBranch(branchId));for (const clipboardBranch of clipboardBranches) {+ if (!clipboardBranch) {+ continue;+ }+const clipboardNote = await clipboardBranch.getNote();+ if (!clipboardNote) {+ continue;+ }await branchService.cloneNoteToBranch(clipboardNote.noteId, parentBranchId);}@@ -62,7 +76,7 @@ async function pasteInto(parentBranchId) {}}-async function copy(branchIds) {+async function copy(branchIds: string[]) {clipboardBranchIds = branchIds;clipboardMode = 'copy';@@ -82,7 +96,7 @@ async function copy(branchIds) {toastService.showMessage(t("clipboard.copied"));}-function cut(branchIds) {+function cut(branchIds: string[]) {clipboardBranchIds = branchIds;if (clipboardBranchIds.length > 0) {