Further iteration

This commit is contained in:
Zef Hemel
2023-08-30 17:25:54 +02:00
parent cbc00b73a0
commit 75da8e7ca9
18 changed files with 128 additions and 147 deletions
-1
View File
@@ -104,7 +104,6 @@ functions:
command:
name: "Text: Strikethrough"
key: "Ctrl-Shift-s"
mac: "Cmd-Shift-s"
wrapper: "~~"
marker:
path: ./text.ts:wrapSelection
+11 -4
View File
@@ -45,9 +45,7 @@ export async function renamePageCommand(cmdDef: any) {
throw e;
}
}
const updatedReferences = await renamePage(oldName, newName);
console.log("Navigating to new page");
await editor.navigate(newName, 0, true);
const updatedReferences = await renamePage(oldName, newName, true);
await editor.flashNotification(
`Renamed page, and updated ${updatedReferences} references`,
@@ -57,12 +55,21 @@ export async function renamePageCommand(cmdDef: any) {
}
}
async function renamePage(oldName: string, newName: string): Promise<number> {
async function renamePage(
oldName: string,
newName: string,
navigateThere = false,
): Promise<number> {
const text = await space.readPage(oldName);
console.log("Writing new page to space");
const newPageMeta = await space.writePage(newName, text);
if (navigateThere) {
console.log("Navigating to new page");
await editor.navigate(newName, 0, true);
}
const pagesToUpdate = await getBackLinks(oldName);
console.log("All pages containing backlinks", pagesToUpdate);