Skip to content

Commit

Permalink
Fix canvas turning into markdown file
Browse files Browse the repository at this point in the history
  • Loading branch information
LostPaul committed Aug 15, 2023
1 parent 00046b6 commit ce21b2e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "folder-notes",
"name": "Folder notes",
"version": "1.5.11",
"version": "1.5.12",
"minAppVersion": "0.15.0",
"description": "Create notes within folders that can be accessed without collapsing the folder, similar to the functionality offered in Notion.",
"author": "Lost Paul",
Expand Down
11 changes: 7 additions & 4 deletions src/functions/folderNoteFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export async function createFolderNote(plugin: FolderNotesPlugin, folderPath: st
}

export async function turnIntoFolderNote(plugin: FolderNotesPlugin, file: TFile, folder: TFolder, folderNote?: TFile | null | TAbstractFile, skipConfirmation?: boolean) {
const extension = file.extension
if (folderNote) {
if (plugin.settings.showRenameConfirmation && !skipConfirmation) {
return new ExistingFolderNoteModal(plugin.app, plugin, file, folder, folderNote).open();
Expand All @@ -61,7 +62,7 @@ export async function turnIntoFolderNote(plugin: FolderNotesPlugin, file: TFile,
excludedFolder.disableSync = true;
updateExcludedFolder(plugin, excludedFolder, excludedFolder);
}
const newPath = `${folder.path}/${folder.name} (${file.stat.ctime.toString().slice(10) + Math.floor(Math.random() * 1000)})${plugin.settings.folderNoteType}`;
const newPath = `${folder.path}/${folder.name} (${file.stat.ctime.toString().slice(10) + Math.floor(Math.random() * 1000)}).${extension}`;
plugin.app.vault.rename(folderNote, newPath).then(() => {
if (!excludedFolder) { return; }
if (!excludedFolderExisted) {
Expand All @@ -74,16 +75,18 @@ export async function turnIntoFolderNote(plugin: FolderNotesPlugin, file: TFile,
}
const folderName = folder.name;
const fileName = plugin.settings.folderNoteName.replace('{{folder_name}}', folderName);
let path = `${folder.path}/${fileName}${plugin.settings.folderNoteType}`;

let path = `${folder.path}/${fileName}.${extension}`;
if (plugin.settings.storageLocation === 'parentFolder') {
const parentFolderPath = folder.parent?.path;
if (!parentFolderPath) return;
if (parentFolderPath.trim() === '') {
path = `${fileName}${plugin.settings.folderNoteType}`;
path = `${fileName}.${extension}`;
} else {
path = `${parentFolderPath}/${fileName}${plugin.settings.folderNoteType}`;
path = `${parentFolderPath}/${fileName}.${extension}`;
}
}

await plugin.app.vault.rename(file, path);
plugin.addCSSClassToTitleEL(path, 'is-folder-note', true);
plugin.addCSSClassToTitleEL(folder.path, 'has-folder-note');
Expand Down

0 comments on commit ce21b2e

Please sign in to comment.