From ef961d5f790ed6c0b6c77a2c06b62425aaad5602 Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Tue, 13 Jan 2026 15:46:27 +0100 Subject: [PATCH] `Navigate: Copy Ref to Current Position` and `Navigate: Copy Link to Current Position` commands --- plugs/editor/editor.plug.yaml | 10 ++++++++++ plugs/editor/editor.ts | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/plugs/editor/editor.plug.yaml b/plugs/editor/editor.plug.yaml index c6315356..7a9dc5a7 100644 --- a/plugs/editor/editor.plug.yaml +++ b/plugs/editor/editor.plug.yaml @@ -121,6 +121,16 @@ functions: command: name: "Navigate: To Position" requireEditor: page + copyRefCommand: + path: "./editor.ts:copyRefCommand" + command: + name: "Navigate: Copy Ref To Current Position" + requireEditor: page + copyLinkCommand: + path: "./editor.ts:copyLinkCommand" + command: + name: "Navigate: Copy Link To Current Position" + requireEditor: page moveToLine: path: "./editor.ts:moveToLineCommand" command: diff --git a/plugs/editor/editor.ts b/plugs/editor/editor.ts index 821f2970..e2915475 100644 --- a/plugs/editor/editor.ts +++ b/plugs/editor/editor.ts @@ -117,6 +117,20 @@ export async function moveToPosCommand() { await editor.moveCursor(pos, true); // showing the movement for better UX } +export async function copyRefCommand() { + const page = await editor.getCurrentPage(); + const pos = await editor.getCursor(); + await editor.copyToClipboard(`[[${page}@${pos}]]`); + await editor.flashNotification("Ref copied to clipboard"); +} + +export async function copyLinkCommand() { + const page = await editor.getCurrentPage(); + const pos = await editor.getCursor(); + await editor.copyToClipboard(`${await system.getBaseURI()}${page}@${pos}`); + await editor.flashNotification("Link copied to clipboard"); +} + export async function moveToLineCommand() { const lineString = await editor.prompt( "Move to line (and optionally column):",