mirror of
https://github.com/ozntel/oz-calendar.git
synced 2026-07-22 07:40:24 +00:00
New Note Creation Fix for Slashes
This commit is contained in:
parent
bb136ad115
commit
2229d8c95c
1 changed files with 33 additions and 24 deletions
33
src/modal.ts
33
src/modal.ts
|
|
@ -60,32 +60,41 @@ export class CreateNoteModal extends Modal {
|
|||
|
||||
const onClickCreateButton = async () => {
|
||||
let newFileName = fileNameInputEl.value;
|
||||
if (newFileName !== '') {
|
||||
|
||||
if (newFileName === '') {
|
||||
new Notice('You didnt provide file name');
|
||||
return;
|
||||
}
|
||||
|
||||
if (newFileName.includes('/')) {
|
||||
new Notice('You can not have a slash (/) in file name');
|
||||
return;
|
||||
}
|
||||
|
||||
let defFolderSrc = folderInputEl ? folderInputEl.value : this.plugin.settings.defaultFolder;
|
||||
let defFolder = this.app.vault.getAbstractFileByPath(defFolderSrc);
|
||||
if (defFolder && defFolder instanceof TFolder) {
|
||||
|
||||
if (!defFolder || !(defFolder instanceof TFolder)) {
|
||||
new Notice('Folder couldnt be found in the Vault');
|
||||
return;
|
||||
}
|
||||
|
||||
// Default Text Preparation for File with YAML and Date
|
||||
let defaultNewFileText = stripIndents`
|
||||
---
|
||||
${this.plugin.settings.yamlKey}: ${dayjs(this.destinationDate).format(
|
||||
this.plugin.settings.dateFormat
|
||||
)}
|
||||
${this.plugin.settings.yamlKey}: ${dayjs(this.destinationDate).format(this.plugin.settings.dateFormat)}
|
||||
---
|
||||
`;
|
||||
|
||||
// Create the MD File and close the modal
|
||||
await createNewMarkdownFile(
|
||||
this.plugin,
|
||||
defFolder,
|
||||
defFolder as TFolder,
|
||||
newFileName,
|
||||
this.plugin.settings.dateSource === 'yaml' ? defaultNewFileText : ''
|
||||
);
|
||||
|
||||
thisModal.close();
|
||||
} else {
|
||||
new Notice('Folder couldnt be found in the Vault');
|
||||
}
|
||||
} else {
|
||||
new Notice('You didnt provide file name');
|
||||
}
|
||||
};
|
||||
|
||||
createButton.addEventListener('click', onClickCreateButton);
|
||||
|
|
|
|||
Loading…
Reference in a new issue