Fix canvas turning into markdown file

This commit is contained in:
Lost Paul 2023-08-15 20:39:06 +02:00
parent 00046b6d9f
commit ce21b2ebc0
2 changed files with 8 additions and 5 deletions

View file

@ -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",

View file

@ -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();
@ -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) {
@ -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');