Navigate: Copy Ref to Current Position and `Navigate: Copy Link to
Current Position` commands
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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):",
|
||||
|
||||
Reference in New Issue
Block a user