mirror of
https://github.com/lostpaul/obsidian-folder-notes.git
synced 2026-07-22 07:40:24 +00:00
Fix canvas turning into markdown file
This commit is contained in:
parent
00046b6d9f
commit
ce21b2ebc0
2 changed files with 8 additions and 5 deletions
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Reference in a new issue