Navigate: Copy Ref to Current Position and `Navigate: Copy Link to

Current Position` commands
This commit is contained in:
Zef Hemel
2026-01-13 15:46:27 +01:00
parent 50f418d41a
commit ef961d5f79
2 changed files with 24 additions and 0 deletions
+10
View File
@@ -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:
+14
View File
@@ -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):",