Skip to content

Commit f293dff

Browse files
committed
Merge branch 'master' into 171-poc-metadata-value-extractors-idea
2 parents c5e463b + b0d2140 commit f293dff

13 files changed

+942
-789
lines changed

package.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-custom-sort",
3-
"version": "2.1.15",
3+
"version": "3.0.0",
44
"description": "Custom Sort plugin for Obsidian (https://obsidian.md)",
55
"main": "main.js",
66
"scripts": {
@@ -24,12 +24,11 @@
2424
"builtin-modules": "3.3.0",
2525
"esbuild": "0.17.3",
2626
"eslint": "^8.29.0",
27-
"jest": "^28.1.1",
28-
"monkey-around": "^2.3.0",
29-
"obsidian": "^0.15.4",
30-
"obsidian-1.4.11": "npm:[email protected]",
31-
"ts-jest": "^28.0.5",
32-
"tslib": "2.4.0",
33-
"typescript": "4.7.4"
27+
"jest": "^29.7.0",
28+
"monkey-around": "^3.0.0",
29+
"obsidian": "^1.7.2",
30+
"ts-jest": "^29.2.5",
31+
"tslib": "2.8.1",
32+
"typescript": "5.7.2"
3433
}
3534
}

src/custom-sort/custom-sort-types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export enum CustomSortGroupType {
88
ExactSuffix,
99
ExactHeadAndTail, // Like W...n or Un...ed, which is shorter variant of typing the entire title
1010
HasMetadataField, // Notes (or folder's notes) containing a specific metadata field
11-
StarredOnly,
1211
BookmarkedOnly,
1312
HasIcon
1413
}

src/custom-sort/custom-sort-utils.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export interface HasSortingTypes {
1616

1717
export interface HasGroupingTypes {
1818
byBookmarks: number
19-
byStarred: number
2019
byIcon: number
2120
total: number
2221
}
@@ -31,10 +30,6 @@ export const checkByBookmark = (has: HasSortingOrGrouping, order?: CustomSortOrd
3130
(order === CustomSortOrder.byBookmarkOrder || order === CustomSortOrder.byBookmarkOrderReverse) && has.sorting.byBookmarks++;
3231
}
3332

34-
export const checkByStarred = (has: HasSortingOrGrouping, order?: CustomSortOrder, groupType?: CustomSortGroupType ) => {
35-
groupType === CustomSortGroupType.StarredOnly && has.grouping.byStarred++;
36-
}
37-
3833
export const checkByIcon = (has: HasSortingOrGrouping, order?: CustomSortOrder, groupType?: CustomSortGroupType ) => {
3934
groupType === CustomSortGroupType.HasIcon && has.grouping.byIcon++;
4035
}
@@ -45,7 +40,6 @@ export const checkStandardObsidian = (has: HasSortingOrGrouping, order?: CustomS
4540

4641
export const doCheck = (has: HasSortingOrGrouping, order?: CustomSortOrder, groupType?: CustomSortGroupType) => {
4742
checkByBookmark(has, order, groupType)
48-
checkByStarred(has, order, groupType)
4943
checkByIcon(has, order, groupType)
5044
checkStandardObsidian(has, order, groupType)
5145

@@ -56,7 +50,7 @@ export const doCheck = (has: HasSortingOrGrouping, order?: CustomSortOrder, grou
5650
export const collectSortingAndGroupingTypes = (sortSpec?: CustomSortSpec|null): HasSortingOrGrouping => {
5751
const has: HasSortingOrGrouping = {
5852
grouping: {
59-
byIcon: 0, byStarred: 0, byBookmarks: 0, total: 0
53+
byIcon: 0, byBookmarks: 0, total: 0
6054
},
6155
sorting: {
6256
byBookmarks: 0, standardObsidian: 0, total: 0

src/custom-sort/custom-sort.ts

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
import {
22
FrontMatterCache,
33
MetadataCache,
4-
Plugin,
5-
requireApiVersion,
64
TAbstractFile,
75
TFile,
86
TFolder,
97
Vault
108
} from 'obsidian';
11-
import {
12-
determineStarredStatusOf,
13-
Starred_PluginInstance
14-
} from '../utils/StarredPluginSignature';
159
import {
1610
determineIconOf,
1711
ObsidianIconFolder_PluginInstance
@@ -41,7 +35,6 @@ export interface ProcessingContext {
4135
// For internal transient use
4236
plugin?: CustomSortPluginAPI // to hand over the access to App instance to the sorting engine
4337
_mCache?: MetadataCache
44-
starredPluginInstance?: Starred_PluginInstance
4538
bookmarksPluginInstance?: BookmarksPluginInterface,
4639
iconFolderPluginInstance?: ObsidianIconFolder_PluginInstance
4740
}
@@ -497,14 +490,6 @@ export const determineSortingGroup = function (entry: TFile | TFolder, spec: Cus
497490
}
498491
}
499492
break
500-
case CustomSortGroupType.StarredOnly:
501-
if (ctx?.starredPluginInstance) {
502-
const starred: boolean = determineStarredStatusOf(entry, aFile, ctx.starredPluginInstance)
503-
if (starred) {
504-
determined = true
505-
}
506-
}
507-
break
508493
case CustomSortGroupType.BookmarkedOnly:
509494
if (ctx?.bookmarksPluginInstance) {
510495
const bookmarkOrder: number | undefined = ctx?.bookmarksPluginInstance.determineBookmarkOrder(entry.path)
@@ -750,28 +735,8 @@ export const determineBookmarksOrderIfNeeded = (folderItems: Array<FolderItemFor
750735
})
751736
}
752737

753-
// This function is a replacement for the Obsidian File Explorer function sort(...) up to Obsidian 1.6.0
754-
// when a major refactoring of sorting mechanics happened
755-
export const folderSort_vUpTo_1_6_0 = function (sortingSpec: CustomSortSpec, ctx: ProcessingContext) {
756-
757-
const fileExplorerView = this.fileExplorer ?? this.view // this.view replaces the former since 1.5.4 insider build
758-
const folderUnderSort = this.file as TFolder
759-
const sortOrder = this.sortOrder
760-
const allFileItemsCollection = fileExplorerView.fileItems
761-
762-
const items = folderSortCore(folderUnderSort, sortOrder, sortingSpec, allFileItemsCollection, ctx)
763-
764-
if (requireApiVersion && requireApiVersion("0.15.0")) {
765-
this.vChildren.setChildren(items);
766-
} else {
767-
this.children = items;
768-
}
769-
}
770-
771-
// This function is a replacement for the Obsidian File Explorer function getSortedFolderItems(...)
772-
// which first appeared in Obsidian 1.6.0 and simplified a bit the plugin integration point
773-
export const getSortedFolderItems_vFrom_1_6_0 = function (sortedFolder: TFolder, sortingSpec: CustomSortSpec, ctx: ProcessingContext) {
774-
const sortOrder = this.sortOrder
738+
export const getSortedFolderItems = function (sortedFolder: TFolder, sortingSpec: CustomSortSpec, ctx: ProcessingContext) {
739+
const sortOrder = this.sortOrder // this is bound to FileExplorer Obsidian component
775740
const allFileItemsCollection = this.fileItems
776741
return folderSortCore(sortedFolder, sortOrder, sortingSpec, allFileItemsCollection, ctx)
777742
}

src/custom-sort/sorting-spec-processor.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,6 @@ const MetadataFieldIndicatorLexeme: string = 'with-metadata:'
276276

277277
const BookmarkedItemIndicatorLexeme: string = 'bookmarked:'
278278

279-
const StarredItemsIndicatorLexeme: string = 'starred:'
280-
281279
const IconIndicatorLexeme: string = 'with-icon:'
282280

283281
const CommentPrefix: string = '//'
@@ -1743,13 +1741,6 @@ export class SortingSpecProcessor {
17431741
foldersOnly: spec.foldersOnly,
17441742
matchFilenameWithExt: spec.matchFilenameWithExt
17451743
}
1746-
} else if (theOnly.startsWith(StarredItemsIndicatorLexeme)) {
1747-
return {
1748-
type: CustomSortGroupType.StarredOnly,
1749-
filesOnly: spec.filesOnly,
1750-
foldersOnly: spec.foldersOnly,
1751-
matchFilenameWithExt: spec.matchFilenameWithExt
1752-
}
17531744
} else {
17541745
// For non-three dots single text line assume exact match group
17551746
return {

0 commit comments

Comments
 (0)