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 { import {
FileExplorerView,
FrontMatterCache, FrontMatterCache,
MetadataCache, MetadataCache,
Plugin, Plugin,
@ -684,8 +685,7 @@ export const determineBookmarksOrderIfNeeded = (folderItems: Array<FolderItemFor
}) })
} }
export const folderSort = function (sortingSpec: CustomSortSpec, ctx: ProcessingContext) { export const folderSort = function (sortingSpec: CustomSortSpec, ctx: ProcessingContext, fileExplorer: FileExplorerView) {
let fileExplorer = this.fileExplorer
// shallow copy of groups and expand folder-specific macros on them // shallow copy of groups and expand folder-specific macros on them
sortingSpec.groupsShadow = sortingSpec.groups?.map((group) => Object.assign({} as CustomSortGroup, group)) 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) { if (sortSpec) {
return folderSort.call(this, sortSpec, plugin.createProcessingContextForSorting(has)); return folderSort.call(this, sortSpec, plugin.createProcessingContextForSorting(has), patchableFileExplorer);
} else { } else {
return old.call(this, ...args); return old.call(this, ...args);
} }

View File

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