mirror of
https://github.com/lostpaul/obsidian-folder-notes.git
synced 2026-07-22 07:40:24 +00:00
Add missing plugin objects
This commit is contained in:
parent
f37a9d7a83
commit
ca194f7172
2 changed files with 15 additions and 13 deletions
|
|
@ -1,28 +1,30 @@
|
|||
import { TAbstractFile, TFolder, TFile } from 'obsidian';
|
||||
import FolderNotesPlugin from 'src/main';
|
||||
import { getFolderNote, getFolder } from 'src/functions/folderNoteFunctions';
|
||||
import { removeCSSClassFromEL, addCSSClassToTitleEL } from 'src/functions/styleFunctions';
|
||||
import { getFolderPathFromString } from 'src/functions/utils';
|
||||
|
||||
export function handleDelete(file: TAbstractFile, plugin: FolderNotesPlugin) {
|
||||
const folder = this.app.vault.getAbstractFileByPath(this.getFolderPathFromString(file.path));
|
||||
const folder = plugin.app.vault.getAbstractFileByPath(getFolderPathFromString(file.path));
|
||||
if (folder instanceof TFolder) {
|
||||
if (this.isEmptyFolderNoteFolder(folder)) {
|
||||
this.addCSSClassToTitleEL(folder.path, 'only-has-folder-note');
|
||||
if (plugin.isEmptyFolderNoteFolder(folder)) {
|
||||
addCSSClassToTitleEL(folder.path, 'only-has-folder-note');
|
||||
} else if (folder.children.length == 0 || folder.children.length > 1) {
|
||||
this.removeCSSClassFromEL(folder.path, 'only-has-folder-note');
|
||||
removeCSSClassFromEL(folder.path, 'only-has-folder-note');
|
||||
}
|
||||
}
|
||||
|
||||
if (file instanceof TFile) {
|
||||
const folder = getFolder(this, file);
|
||||
const folder = getFolder(plugin, file);
|
||||
if (!folder) { return; }
|
||||
this.removeCSSClassFromEL(folder.path, 'has-folder-note');
|
||||
this.removeCSSClassFromEL(folder.path, 'only-has-folder-note');
|
||||
removeCSSClassFromEL(folder.path, 'has-folder-note');
|
||||
removeCSSClassFromEL(folder.path, 'only-has-folder-note');
|
||||
}
|
||||
|
||||
if (!(file instanceof TFolder)) { return; }
|
||||
const folderNote = getFolderNote(this, file.path);
|
||||
const folderNote = getFolderNote(plugin, file.path);
|
||||
if (!folderNote) { return; }
|
||||
this.removeCSSClassFromEL(folderNote.path, 'is-folder-note');
|
||||
if (!this.settings.syncDelete) { return; }
|
||||
this.app.vault.delete(folderNote);
|
||||
removeCSSClassFromEL(folderNote.path, 'is-folder-note');
|
||||
if (!plugin.settings.syncDelete) { return; }
|
||||
plugin.app.vault.delete(folderNote);
|
||||
}
|
||||
|
|
@ -32,10 +32,10 @@ export function handleRename(file: TAbstractFile, oldPath: string, plugin: Folde
|
|||
|
||||
if (file instanceof TFolder) {
|
||||
plugin.tabManager.updateTab(file.path);
|
||||
return handleFolderRename(file, oldPath, this);
|
||||
return handleFolderRename(file, oldPath, plugin);
|
||||
|
||||
} else if (file instanceof TFile) {
|
||||
return handleFileRename(file, oldPath, this);
|
||||
return handleFileRename(file, oldPath, plugin);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue