Obsidian introduced breaking changes around File Explorer JS structure which prevented this custom-sort plugin from working.
This commit is contained in:
SebastianMC 2024-02-07 23:34:27 +01:00
parent a2a808e78b
commit 238c027903
3 changed files with 4 additions and 4 deletions

View File

@ -1,4 +1,5 @@
import {
FileExplorerView,
FrontMatterCache,
MetadataCache,
Plugin,
@ -684,8 +685,7 @@ export const determineBookmarksOrderIfNeeded = (folderItems: Array<FolderItemFor
})
}
export const folderSort = function (sortingSpec: CustomSortSpec, ctx: ProcessingContext) {
let fileExplorer = this.fileExplorer
export const folderSort = function (sortingSpec: CustomSortSpec, ctx: ProcessingContext, fileExplorer: FileExplorerView) {
// shallow copy of groups and expand folder-specific macros on them
sortingSpec.groupsShadow = sortingSpec.groups?.map((group) => Object.assign({} as CustomSortGroup, group))

View File

@ -622,7 +622,7 @@ export default class CustomSortPlugin extends Plugin {
}
if (sortSpec) {
return folderSort.call(this, sortSpec, plugin.createProcessingContextForSorting(has));
return folderSort.call(this, sortSpec, plugin.createProcessingContextForSorting(has), patchableFileExplorer);
} else {
return old.call(this, ...args);
}

View File

@ -51,7 +51,7 @@ declare module 'obsidian' {
export interface FileExplorerView extends View {
createFolderDom(folder: TFolder): FileExplorerFolder;
fileItems: any;
requestSort(): void;
sortOrder: string