mirror of
https://github.com/decaf-dev/obsidian-vault-explorer.git
synced 2026-07-22 10:10:31 +00:00
feat: remove favorites filter
This commit is contained in:
parent
64ca177978
commit
525fd3e276
19 changed files with 344 additions and 172 deletions
|
|
@ -22,10 +22,6 @@ export const DEFAULT_SETTINGS: VaultExplorerPluginSettings = {
|
|||
isEnabled: true,
|
||||
value: "",
|
||||
},
|
||||
favorites: {
|
||||
isEnabled: true,
|
||||
value: false,
|
||||
},
|
||||
timestamp: {
|
||||
isEnabled: true,
|
||||
value: "all",
|
||||
|
|
|
|||
|
|
@ -136,21 +136,6 @@ export default class VaultExplorerSettingsTab extends PluginSettingTab {
|
|||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Favorites filter")
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.filters.favorites.isEnabled)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.filters.favorites.isEnabled =
|
||||
value;
|
||||
await this.plugin.saveSettings();
|
||||
EventManager.getInstance().emit(
|
||||
PluginEvent.FILTER_TOGGLE_SETTING_CHANGE
|
||||
);
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Timestamp filter")
|
||||
.addToggle((toggle) =>
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
<script lang="ts">
|
||||
import Checkbox from "src/svelte/shared/components/checkbox.svelte";
|
||||
|
||||
export let value: boolean;
|
||||
</script>
|
||||
|
||||
<Checkbox id="favorites" label="Favorites" {value} on:change />
|
||||
|
|
@ -35,7 +35,6 @@
|
|||
export let path: string;
|
||||
export let createdMillis: number;
|
||||
export let content: string | null;
|
||||
export let isFavorite: boolean | null;
|
||||
|
||||
let ref: HTMLElement | null = null;
|
||||
let enableFileIcons = false;
|
||||
|
|
@ -146,16 +145,9 @@
|
|||
openInCurrentTab(plugin, path);
|
||||
}
|
||||
|
||||
function handleFavoriteChange(filePath: string, value: boolean) {
|
||||
dispatch("favoritePropertyChange", { filePath, value });
|
||||
}
|
||||
|
||||
function handleCardContextMenu(e: Event) {
|
||||
const nativeEvent = e as MouseEvent;
|
||||
openContextMenu(plugin, path, nativeEvent, {
|
||||
isFavorite,
|
||||
onFavoriteChange: handleFavoriteChange,
|
||||
});
|
||||
openContextMenu(plugin, path, nativeEvent, {});
|
||||
}
|
||||
|
||||
function handleCardMouseOver(e: MouseEvent) {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@
|
|||
path={fileRenderData.path}
|
||||
content={fileRenderData.content}
|
||||
createdMillis={fileRenderData.createdMillis}
|
||||
isFavorite={fileRenderData.isFavorite}
|
||||
on:favoritePropertyChange
|
||||
/>
|
||||
{/each}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@
|
|||
export let custom1: string | null;
|
||||
export let custom2: string | null;
|
||||
export let custom3: string | null;
|
||||
export let isFavorite: boolean | null;
|
||||
export let coverImageFit: CoverImageFit;
|
||||
|
||||
let plugin: VaultExplorerPlugin;
|
||||
|
|
@ -147,9 +146,7 @@
|
|||
|
||||
const showCoverImageOptions = path.endsWith(".md");
|
||||
openContextMenu(plugin, path, nativeEvent, {
|
||||
isFavorite,
|
||||
coverImageFit: showCoverImageOptions ? coverImageFit : undefined,
|
||||
onFavoriteChange: handleFavoriteChange,
|
||||
onCoverImageFitChange: showCoverImageOptions
|
||||
? handleCoverImageFitChange
|
||||
: undefined,
|
||||
|
|
@ -231,7 +228,7 @@
|
|||
{#if imageUrl === null}
|
||||
<div class="vault-explorer-grid-card__image"></div>
|
||||
{/if}
|
||||
{#if isFavorite === true}
|
||||
<!-- {#if isFavorite === true}
|
||||
<div class="vault-explorer-grid-card__favorite">
|
||||
<Flex
|
||||
justify="center"
|
||||
|
|
@ -242,7 +239,7 @@
|
|||
<Icon iconId="star" ariaLabel="Favorite" />
|
||||
</Flex>
|
||||
</div>
|
||||
{/if}
|
||||
{/if} -->
|
||||
</div>
|
||||
<div class="vault-explorer-grid-card__body">
|
||||
<div
|
||||
|
|
@ -348,14 +345,7 @@
|
|||
border-top-right-radius: var(--radius-m);
|
||||
}
|
||||
|
||||
.vault-explorer-grid-card__cover-icon {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.vault-explorer-grid-card__favorite {
|
||||
/* .vault-explorer-grid-card__favorite {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
right: 8px;
|
||||
|
|
@ -363,7 +353,7 @@
|
|||
height: 20px;
|
||||
background-color: var(--background-primary);
|
||||
border-radius: 50%;
|
||||
}
|
||||
} */
|
||||
|
||||
.vault-explorer-grid-card__body {
|
||||
padding: 8px 16px;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@
|
|||
custom1={fileRenderData.custom1}
|
||||
custom2={fileRenderData.custom2}
|
||||
custom3={fileRenderData.custom3}
|
||||
isFavorite={fileRenderData.isFavorite}
|
||||
on:favoritePropertyChange
|
||||
on:coverImageFitChange
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
export let extension: string;
|
||||
export let path: string;
|
||||
export let tags: string[] | null;
|
||||
export let isFavorite: boolean | null;
|
||||
export let showTags: boolean;
|
||||
export let isSmallScreenSize: boolean;
|
||||
|
||||
|
|
@ -82,10 +81,7 @@
|
|||
|
||||
function handleItemContextMenu(e: Event) {
|
||||
const nativeEvent = e as MouseEvent;
|
||||
openContextMenu(plugin, path, nativeEvent, {
|
||||
isFavorite,
|
||||
onFavoriteChange: handleFavoriteChange,
|
||||
});
|
||||
openContextMenu(plugin, path, nativeEvent, {});
|
||||
}
|
||||
|
||||
function handleItemMouseOver(e: MouseEvent) {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@
|
|||
{isSmallScreenSize}
|
||||
path={fileRenderData.path}
|
||||
tags={fileRenderData.tags}
|
||||
isFavorite={fileRenderData.isFavorite}
|
||||
on:favoritePropertyChange
|
||||
/>
|
||||
{/each}
|
||||
|
|
|
|||
|
|
@ -42,11 +42,6 @@
|
|||
key: "tags",
|
||||
label: "Tags",
|
||||
},
|
||||
{
|
||||
key: "isFavorite",
|
||||
label: "Favorite",
|
||||
format: (value: unknown) => (value === true ? "Yes" : "No"),
|
||||
},
|
||||
{
|
||||
key: "createdMillis",
|
||||
label: "Created",
|
||||
|
|
@ -85,10 +80,6 @@
|
|||
};
|
||||
});
|
||||
|
||||
function handleFavoriteChange(filePath: string, value: boolean) {
|
||||
dispatch("favoritePropertyChange", { filePath, value });
|
||||
}
|
||||
|
||||
function handleRowClick(path: string) {
|
||||
if (plugin === null) return;
|
||||
|
||||
|
|
@ -108,18 +99,11 @@
|
|||
});
|
||||
}
|
||||
|
||||
function handleRowContextMenu(
|
||||
e: Event,
|
||||
path: string,
|
||||
isFavorite: boolean | null,
|
||||
) {
|
||||
function handleRowContextMenu(e: Event, path: string) {
|
||||
if (plugin === null) return;
|
||||
|
||||
const nativeEvent = e as MouseEvent;
|
||||
openContextMenu(plugin, path, nativeEvent, {
|
||||
isFavorite,
|
||||
onFavoriteChange: handleFavoriteChange,
|
||||
});
|
||||
openContextMenu(plugin, path, nativeEvent, {});
|
||||
}
|
||||
|
||||
function getValue(item: FileRenderData, column: TColumn): unknown {
|
||||
|
|
@ -171,11 +155,7 @@
|
|||
}}
|
||||
on:focus={() => {}}
|
||||
on:contextmenu={(e) =>
|
||||
handleRowContextMenu(
|
||||
e,
|
||||
filteredItem.path,
|
||||
filteredItem.isFavorite,
|
||||
)}
|
||||
handleRowContextMenu(e, filteredItem.path)}
|
||||
on:mouseover={(e) =>
|
||||
handleRowMouseOver(e, filteredItem.path)}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -4,13 +4,11 @@
|
|||
// ============================================
|
||||
import Stack from "../shared/components/stack.svelte";
|
||||
import Flex from "../shared/components/flex.svelte";
|
||||
import FavoritesFilter from "./components/favorites-filter.svelte";
|
||||
import TabList from "../shared/components/tab-list.svelte";
|
||||
import Tab from "../shared/components/tab.svelte";
|
||||
import { Notice, TFile } from "obsidian";
|
||||
import {
|
||||
TCustomFilter,
|
||||
TFavoritesFilter,
|
||||
TSearchFilter,
|
||||
TSortFilter,
|
||||
TTimestampFilter,
|
||||
|
|
@ -21,7 +19,6 @@
|
|||
import VaultExplorerPlugin from "src/main";
|
||||
import GridView from "./components/grid-view.svelte";
|
||||
import ListView from "./components/list-view.svelte";
|
||||
import { filterByFavorites } from "./services/filters/favorite-filter";
|
||||
import { filterBySearch } from "./services/filters/search-filter";
|
||||
import { filterByTimestamp } from "./services/filters/timestamp-filter";
|
||||
import { filterByGroups } from "./services/filters/custom/filter-by-groups";
|
||||
|
|
@ -82,10 +79,6 @@
|
|||
isEnabled: true,
|
||||
value: "",
|
||||
};
|
||||
let favoritesFilter: TFavoritesFilter = {
|
||||
isEnabled: false,
|
||||
value: false,
|
||||
};
|
||||
let timestampFilter: TTimestampFilter = {
|
||||
isEnabled: true,
|
||||
value: "all",
|
||||
|
|
@ -146,7 +139,6 @@
|
|||
shouldCollapseFilters = settings.shouldCollapseFilters;
|
||||
pageSize = settings.pageSize;
|
||||
searchFilter = settings.filters.search;
|
||||
favoritesFilter = settings.filters.favorites;
|
||||
sortFilter = settings.filters.sort;
|
||||
timestampFilter = settings.filters.timestamp;
|
||||
currentView = settings.currentView;
|
||||
|
|
@ -171,7 +163,6 @@
|
|||
});
|
||||
|
||||
searchFilter = plugin.settings.filters.search;
|
||||
favoritesFilter = plugin.settings.filters.favorites;
|
||||
sortFilter = plugin.settings.filters.sort;
|
||||
timestampFilter = plugin.settings.filters.timestamp;
|
||||
customFilter = plugin.settings.filters.custom;
|
||||
|
|
@ -579,10 +570,6 @@
|
|||
searchFilter.value = e.target.value;
|
||||
}, DEBOUNCE_INPUT_TIME);
|
||||
|
||||
const debounceFavoriteFilterChange = _.debounce((value) => {
|
||||
favoritesFilter.value = value;
|
||||
}, DEBOUNCE_INPUT_TIME);
|
||||
|
||||
function handleReshuffleClick() {
|
||||
randomFileSortStore.load(plugin.app);
|
||||
}
|
||||
|
|
@ -620,7 +607,6 @@
|
|||
plugin.settings.filters.search = searchFilter;
|
||||
plugin.settings.filters.sort = sortFilter;
|
||||
plugin.settings.filters.timestamp = timestampFilter;
|
||||
plugin.settings.filters.favorites = favoritesFilter;
|
||||
plugin.settings.currentView = currentView;
|
||||
plugin.settings.filters.custom = customFilter;
|
||||
plugin.settings.viewOrder = viewOrder;
|
||||
|
|
@ -778,12 +764,6 @@
|
|||
sortFilter.value = value;
|
||||
}
|
||||
|
||||
function handleFavoritesChange(e: CustomEvent) {
|
||||
const nativeEvent = e.detail.nativeEvent;
|
||||
const value = (nativeEvent.target as HTMLInputElement).checked;
|
||||
debounceFavoriteFilterChange(value);
|
||||
}
|
||||
|
||||
function handleCoverImageFitChange(e: CustomEvent) {
|
||||
const { filePath, value } = e.detail as {
|
||||
filePath: string;
|
||||
|
|
@ -895,7 +875,6 @@
|
|||
) {
|
||||
formatted = filteredCustom.map((loadedFile) => {
|
||||
const { id, file } = loadedFile;
|
||||
const isFavorite = favoritesCache.get(file.path) ?? null;
|
||||
const content = contentCache.get(file.path) ?? null;
|
||||
|
||||
return formatFileDataForRender({
|
||||
|
|
@ -904,7 +883,6 @@
|
|||
fileId: id,
|
||||
file,
|
||||
fileContent: content,
|
||||
fileFavorite: isFavorite,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -917,15 +895,7 @@
|
|||
return true;
|
||||
});
|
||||
|
||||
$: filteredFavorites = filteredSearch.filter((file) => {
|
||||
const { isEnabled, value } = favoritesFilter;
|
||||
if (isEnabled) {
|
||||
return filterByFavorites(file, value);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
$: filteredTimestamp = filteredFavorites.filter((file) => {
|
||||
$: filteredTimestamp = filteredSearch.filter((file) => {
|
||||
const { modifiedMillis, createdMillis } = file;
|
||||
return filterByTimestamp({
|
||||
value: timestampFilter.value,
|
||||
|
|
@ -967,7 +937,6 @@
|
|||
$: searchFilter,
|
||||
sortFilter,
|
||||
timestampFilter,
|
||||
favoritesFilter,
|
||||
currentView,
|
||||
customFilter,
|
||||
viewOrder,
|
||||
|
|
@ -1003,12 +972,6 @@
|
|||
<Stack direction="column" spacing="sm">
|
||||
<Flex justify="space-between">
|
||||
<Stack spacing="sm">
|
||||
{#if favoritesFilter.isEnabled}
|
||||
<FavoritesFilter
|
||||
value={favoritesFilter.value}
|
||||
on:change={handleFavoritesChange}
|
||||
/>
|
||||
{/if}
|
||||
<Flex>
|
||||
{#if timestampFilter.isEnabled}
|
||||
<TimestampFilter
|
||||
|
|
|
|||
|
|
@ -7,14 +7,10 @@ export const openContextMenu = (
|
|||
filePath: string,
|
||||
e: MouseEvent,
|
||||
{
|
||||
isFavorite,
|
||||
coverImageFit,
|
||||
onFavoriteChange,
|
||||
onCoverImageFitChange,
|
||||
}: {
|
||||
isFavorite: boolean | null;
|
||||
coverImageFit?: CoverImageFit;
|
||||
onFavoriteChange: (filePath: string, value: boolean) => void;
|
||||
onCoverImageFitChange?: (
|
||||
filePath: string,
|
||||
value: CoverImageFit
|
||||
|
|
@ -35,16 +31,6 @@ export const openContextMenu = (
|
|||
item.setTitle("Open in new window");
|
||||
item.onClick(() => openInNewWindow(plugin, filePath));
|
||||
});
|
||||
menu.addSeparator();
|
||||
menu.addItem((item) => {
|
||||
item.setTitle(
|
||||
isFavorite ? "Remove from favorites" : "Add to favorites"
|
||||
);
|
||||
item.onClick(() => {
|
||||
const newValue = isFavorite !== null ? !isFavorite : true;
|
||||
onFavoriteChange(filePath, newValue);
|
||||
});
|
||||
});
|
||||
if (coverImageFit !== undefined && onCoverImageFitChange !== undefined) {
|
||||
menu.addSeparator();
|
||||
menu.addItem((item) => {
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
import { FileRenderData } from "../../types";
|
||||
|
||||
export const filterByFavorites = (
|
||||
file: FileRenderData,
|
||||
onlyFavorites: boolean
|
||||
) => {
|
||||
if (onlyFavorites) {
|
||||
return file.isFavorite;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
|
@ -46,14 +46,12 @@ export const formatFileDataForRender = ({
|
|||
file,
|
||||
fileId,
|
||||
fileContent,
|
||||
fileFavorite,
|
||||
}: {
|
||||
app: App;
|
||||
settings: VaultExplorerPluginSettings;
|
||||
file: TFile;
|
||||
fileId: string;
|
||||
fileContent: string | null;
|
||||
fileFavorite: boolean | null;
|
||||
}): FileRenderData => {
|
||||
const { name, basename, extension, path } = file;
|
||||
|
||||
|
|
@ -96,17 +94,6 @@ export const formatFileDataForRender = ({
|
|||
PropertyType.TEXT
|
||||
);
|
||||
|
||||
let isFavorite: boolean | null;
|
||||
if (fileFavorite === null) {
|
||||
isFavorite = loadPropertyValue<boolean>(
|
||||
fileFrontmatter,
|
||||
favoriteProp,
|
||||
PropertyType.CHECKBOX
|
||||
);
|
||||
} else {
|
||||
isFavorite = fileFavorite;
|
||||
}
|
||||
|
||||
let coverImageFit: CoverImageFit | null = loadPropertyValue<string>(
|
||||
fileFrontmatter,
|
||||
coverImageFitProp,
|
||||
|
|
@ -250,7 +237,6 @@ export const formatFileDataForRender = ({
|
|||
content: fileContent,
|
||||
tags,
|
||||
imageUrl,
|
||||
isFavorite,
|
||||
createdMillis,
|
||||
modifiedMillis,
|
||||
custom1,
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ export interface FileRenderData {
|
|||
url: string | null;
|
||||
imageUrl: string | null;
|
||||
tags: string[] | null;
|
||||
isFavorite: boolean | null;
|
||||
createdMillis: number;
|
||||
modifiedMillis: number;
|
||||
custom1: string | null;
|
||||
|
|
|
|||
|
|
@ -30,11 +30,6 @@ export function isVaultExplorerPluginSettings(obj: unknown): obj is VaultExplore
|
|||
typeof typedObj["filters"]["search"] === "function") &&
|
||||
typeof typedObj["filters"]["search"]["isEnabled"] === "boolean" &&
|
||||
typeof typedObj["filters"]["search"]["value"] === "string" &&
|
||||
(typedObj["filters"]["favorites"] !== null &&
|
||||
typeof typedObj["filters"]["favorites"] === "object" ||
|
||||
typeof typedObj["filters"]["favorites"] === "function") &&
|
||||
typeof typedObj["filters"]["favorites"]["isEnabled"] === "boolean" &&
|
||||
typeof typedObj["filters"]["favorites"]["value"] === "boolean" &&
|
||||
(typedObj["filters"]["sort"] !== null &&
|
||||
typeof typedObj["filters"]["sort"] === "object" ||
|
||||
typeof typedObj["filters"]["sort"] === "function") &&
|
||||
|
|
@ -608,9 +603,7 @@ export function isVaultExplorerPluginSettings(obj: unknown): obj is VaultExplore
|
|||
typeof e["isEnabled"] === "boolean"
|
||||
) &&
|
||||
(typedObj["views"]["grid"]["coverImageFit"] === "cover" ||
|
||||
typedObj["views"]["grid"]["coverImageFit"] === "contain" ||
|
||||
typedObj["views"]["grid"]["coverImageFit"] === "scale-down" ||
|
||||
typedObj["views"]["grid"]["coverImageFit"] === "none") &&
|
||||
typedObj["views"]["grid"]["coverImageFit"] === "contain") &&
|
||||
typeof typedObj["views"]["grid"]["loadSocialMediaImage"] === "boolean" &&
|
||||
(typedObj["views"]["list"] !== null &&
|
||||
typeof typedObj["views"]["list"] === "object" ||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ export interface VaultExplorerPluginSettings {
|
|||
};
|
||||
filters: {
|
||||
search: TSearchFilter;
|
||||
favorites: TFavoritesFilter;
|
||||
sort: TSortFilter;
|
||||
timestamp: TTimestampFilter;
|
||||
custom: TCustomFilter;
|
||||
|
|
@ -97,10 +96,6 @@ export interface TSearchFilter extends BaseFilter {
|
|||
value: string;
|
||||
}
|
||||
|
||||
export interface TFavoritesFilter extends BaseFilter {
|
||||
value: boolean;
|
||||
}
|
||||
|
||||
export interface TSortFilter extends BaseFilter {
|
||||
value: SortFilterOption;
|
||||
}
|
||||
|
|
|
|||
332
src/types/types-1.41.1.ts
Normal file
332
src/types/types-1.41.1.ts
Normal file
|
|
@ -0,0 +1,332 @@
|
|||
export interface VaultExplorerPluginSettings_1_41_1 {
|
||||
properties: {
|
||||
favorite: string;
|
||||
url: string;
|
||||
image: string;
|
||||
coverImageFit: string;
|
||||
createdDate: string;
|
||||
modifiedDate: string;
|
||||
custom1: string;
|
||||
custom2: string;
|
||||
custom3: string;
|
||||
};
|
||||
filters: {
|
||||
search: TSearchFilter;
|
||||
favorites: TFavoritesFilter;
|
||||
sort: TSortFilter;
|
||||
timestamp: TTimestampFilter;
|
||||
custom: TCustomFilter;
|
||||
};
|
||||
views: {
|
||||
dashboard: TDashboardView;
|
||||
grid: TGridView;
|
||||
list: TListView;
|
||||
table: TTableView;
|
||||
feed: TFeedView;
|
||||
recommended: TRecommendedView;
|
||||
related: TRelatedView;
|
||||
};
|
||||
titleWrapping: WordBreak;
|
||||
enableClockUpdates: boolean;
|
||||
enableFileIcons: boolean;
|
||||
loadBodyTags: boolean;
|
||||
currentView: TExplorerView | null;
|
||||
pageSize: number;
|
||||
filterGroupsWidth: string;
|
||||
shouldWrapFilterGroups: boolean;
|
||||
shouldCollapseFilters: boolean;
|
||||
viewOrder: TExplorerView[];
|
||||
configDir: string;
|
||||
pluginVersion: string | null;
|
||||
logLevel: string;
|
||||
}
|
||||
|
||||
type FileInteractionStyle = "title" | "content";
|
||||
|
||||
interface BaseView {
|
||||
isEnabled: boolean;
|
||||
}
|
||||
|
||||
interface TTableView extends BaseView {}
|
||||
|
||||
interface TListView extends BaseView {
|
||||
showTags: boolean;
|
||||
}
|
||||
|
||||
interface TGridView extends BaseView {
|
||||
coverImageSources: CoverImageSource[];
|
||||
coverImageFit: CoverImageFit;
|
||||
loadSocialMediaImage: boolean;
|
||||
}
|
||||
|
||||
interface CoverImageSource {
|
||||
type: CoverImageSourceType;
|
||||
isEnabled: boolean;
|
||||
}
|
||||
|
||||
type CoverImageFit = "cover" | "contain";
|
||||
|
||||
type CoverImageSourceType =
|
||||
| "image-property"
|
||||
| "url-property"
|
||||
| "frontmatter"
|
||||
| "body";
|
||||
|
||||
interface TDashboardView extends BaseView {}
|
||||
|
||||
type CollapseStyle = "no-new-lines" | "no-extra-new-lines";
|
||||
|
||||
interface TFeedView extends BaseView {
|
||||
collapseStyle: CollapseStyle;
|
||||
removeH1: boolean;
|
||||
lineClampSmall: number;
|
||||
lineClampMedium: number;
|
||||
lineClampLarge: number;
|
||||
}
|
||||
|
||||
interface TRecommendedView extends BaseView {}
|
||||
|
||||
interface TRelatedView extends BaseView {}
|
||||
|
||||
interface BaseFilter {
|
||||
isEnabled: boolean;
|
||||
}
|
||||
|
||||
interface TSearchFilter extends BaseFilter {
|
||||
value: string;
|
||||
}
|
||||
|
||||
interface TFavoritesFilter extends BaseFilter {
|
||||
value: boolean;
|
||||
}
|
||||
|
||||
interface TSortFilter extends BaseFilter {
|
||||
value: SortFilterOption;
|
||||
}
|
||||
|
||||
interface TTimestampFilter extends BaseFilter {
|
||||
value: TimestampFilterOption;
|
||||
}
|
||||
|
||||
interface TCustomFilter extends BaseFilter {
|
||||
selectedGroupId: string;
|
||||
groups: TFilterGroup[];
|
||||
}
|
||||
|
||||
type TimestampFilterOption =
|
||||
| "created-today"
|
||||
| "modified-today"
|
||||
| "created-this-week"
|
||||
| "modified-this-week"
|
||||
| "created-2-weeks"
|
||||
| "modified-2-weeks"
|
||||
| "all";
|
||||
|
||||
type SortFilterOption =
|
||||
| "file-name-asc"
|
||||
| "file-name-desc"
|
||||
| "modified-asc"
|
||||
| "modified-desc"
|
||||
| "random";
|
||||
|
||||
type WordBreak = "normal" | "break-word";
|
||||
|
||||
enum TExplorerView {
|
||||
DASHBOARD = "dashboard",
|
||||
GRID = "grid",
|
||||
LIST = "list",
|
||||
FEED = "feed",
|
||||
TABLE = "table",
|
||||
RECOMMENDED = "recommended",
|
||||
RELATED = "related",
|
||||
}
|
||||
|
||||
type FilterOperator = "and" | "or";
|
||||
|
||||
enum TextFilterCondition {
|
||||
IS = "is",
|
||||
IS_NOT = "is-not",
|
||||
CONTAINS = "contains",
|
||||
DOES_NOT_CONTAIN = "does-not-contain",
|
||||
STARTS_WITH = "starts-with",
|
||||
ENDS_WITH = "ends-with",
|
||||
EXISTS = "exists",
|
||||
DOES_NOT_EXIST = "does-not-exist",
|
||||
}
|
||||
|
||||
enum ListFilterCondition {
|
||||
CONTAINS = "contains",
|
||||
DOES_NOT_CONTAIN = "does-not-contain",
|
||||
EXISTS = "exists",
|
||||
DOES_NOT_EXIST = "does-not-exist",
|
||||
}
|
||||
|
||||
enum NumberFilterCondition {
|
||||
IS_EQUAL = "is-equal",
|
||||
IS_NOT_EQUAL = "is-not-equal",
|
||||
IS_GREATER = "is-greater",
|
||||
IS_LESS = "is-less",
|
||||
IS_GREATER_OR_EQUAL = "is-greater-or-equal",
|
||||
IS_LESS_OR_EQUAL = "is-less-or-equal",
|
||||
EXISTS = "exists",
|
||||
DOES_NOT_EXIST = "does-not-exist",
|
||||
}
|
||||
|
||||
enum CheckboxFilterCondition {
|
||||
IS = "is",
|
||||
IS_NOT = "is-not",
|
||||
EXISTS = "exists",
|
||||
DOES_NOT_EXIST = "does-not-exist",
|
||||
}
|
||||
|
||||
enum DateFilterCondition {
|
||||
IS = "is",
|
||||
IS_BEFORE = "is-before",
|
||||
IS_AFTER = "is-after",
|
||||
IS_ON_OR_BEFORE = "is-on-or-before",
|
||||
IS_ON_OR_AFTER = "is-on-or-after",
|
||||
EXISTS = "exists",
|
||||
DOES_NOT_EXIST = "does-not-exist",
|
||||
}
|
||||
|
||||
enum ContentFilterCondition {
|
||||
CONTAINS = "contains",
|
||||
DOES_NOT_CONTAIN = "does-not-contain",
|
||||
IS_EMPTY = "is-empty",
|
||||
IS_NOT_EMPTY = "is-not-empty",
|
||||
}
|
||||
|
||||
enum FolderFilterCondition {
|
||||
IS = "is",
|
||||
IS_NOT = "is-not",
|
||||
}
|
||||
|
||||
enum FileNameFilterCondition {
|
||||
IS = "is",
|
||||
IS_NOT = "is-not",
|
||||
CONTAINS = "contains",
|
||||
DOES_NOT_CONTAIN = "does-not-contain",
|
||||
STARTS_WITH = "starts-with",
|
||||
ENDS_WITH = "ends-with",
|
||||
}
|
||||
|
||||
type FilterCondition =
|
||||
| TextFilterCondition
|
||||
| NumberFilterCondition
|
||||
| DateFilterCondition
|
||||
| CheckboxFilterCondition
|
||||
| ListFilterCondition
|
||||
| ContentFilterCondition
|
||||
| FolderFilterCondition
|
||||
| FileNameFilterCondition;
|
||||
|
||||
//This matches the Obsidian property types
|
||||
enum PropertyType {
|
||||
TEXT = "text",
|
||||
NUMBER = "number",
|
||||
LIST = "list",
|
||||
CHECKBOX = "checkbox",
|
||||
DATE = "date",
|
||||
DATETIME = "datetime",
|
||||
}
|
||||
|
||||
enum FilterRuleType {
|
||||
PROPERTY = "property",
|
||||
FOLDER = "folder",
|
||||
FILE_NAME = "file-name",
|
||||
CONTENT = "content",
|
||||
}
|
||||
|
||||
enum DatePropertyFilterValue {
|
||||
TODAY = "today",
|
||||
TOMORROW = "tomorrow",
|
||||
YESTERDAY = "yesterday",
|
||||
ONE_WEEK_FROM_NOW = "one-week-from-now",
|
||||
ONE_WEEK_AGO = "one-week-ago",
|
||||
ONE_MONTH_FROM_NOW = "one-month-from-now",
|
||||
ONE_MONTH_AGO = "one-month-ago",
|
||||
CUSTOM = "custom",
|
||||
}
|
||||
|
||||
interface BaseFilterRule {
|
||||
id: string;
|
||||
operator: FilterOperator;
|
||||
type: FilterRuleType;
|
||||
condition: FilterCondition;
|
||||
isEnabled: boolean;
|
||||
value: string;
|
||||
matchWhenPropertyDNE: boolean;
|
||||
}
|
||||
|
||||
interface TextPropertyFilterRule extends BaseFilterRule {
|
||||
type: FilterRuleType.PROPERTY;
|
||||
propertyType: PropertyType.TEXT;
|
||||
propertyName: string;
|
||||
condition: TextFilterCondition;
|
||||
}
|
||||
|
||||
interface NumberPropertyFilterRule extends BaseFilterRule {
|
||||
type: FilterRuleType.PROPERTY;
|
||||
propertyType: PropertyType.NUMBER;
|
||||
propertyName: string;
|
||||
condition: NumberFilterCondition;
|
||||
}
|
||||
|
||||
interface ListPropertyFilterRule extends BaseFilterRule {
|
||||
type: FilterRuleType.PROPERTY;
|
||||
propertyType: PropertyType.LIST;
|
||||
propertyName: string;
|
||||
condition: ListFilterCondition;
|
||||
}
|
||||
|
||||
interface CheckboxPropertyFilterRule extends BaseFilterRule {
|
||||
type: FilterRuleType.PROPERTY;
|
||||
propertyType: PropertyType.CHECKBOX;
|
||||
propertyName: string;
|
||||
condition: CheckboxFilterCondition;
|
||||
}
|
||||
|
||||
interface DatePropertyFilterRule extends BaseFilterRule {
|
||||
type: FilterRuleType.PROPERTY;
|
||||
propertyType: PropertyType.DATE | PropertyType.DATETIME;
|
||||
propertyName: string;
|
||||
condition: DateFilterCondition;
|
||||
valueData: string;
|
||||
}
|
||||
|
||||
interface FolderFilterRule extends BaseFilterRule {
|
||||
type: FilterRuleType.FOLDER;
|
||||
condition: FolderFilterCondition;
|
||||
includeSubfolders: boolean;
|
||||
}
|
||||
|
||||
interface FileNameFilterRule extends BaseFilterRule {
|
||||
type: FilterRuleType.FILE_NAME;
|
||||
condition: FileNameFilterCondition;
|
||||
}
|
||||
|
||||
interface ContentFilterRule extends BaseFilterRule {
|
||||
type: FilterRuleType.CONTENT;
|
||||
condition: ContentFilterCondition;
|
||||
}
|
||||
|
||||
type TFilterRule =
|
||||
| PropertyFilterRule
|
||||
| FolderFilterRule
|
||||
| FileNameFilterRule
|
||||
| ContentFilterRule;
|
||||
|
||||
type PropertyFilterRule =
|
||||
| TextPropertyFilterRule
|
||||
| NumberPropertyFilterRule
|
||||
| ListPropertyFilterRule
|
||||
| CheckboxPropertyFilterRule
|
||||
| DatePropertyFilterRule;
|
||||
|
||||
interface TFilterGroup {
|
||||
id: string;
|
||||
name: string;
|
||||
rules: TFilterRule[];
|
||||
isEnabled: boolean;
|
||||
isSticky: boolean;
|
||||
}
|
||||
|
|
@ -105,6 +105,6 @@
|
|||
"feed"
|
||||
],
|
||||
"configDir": ".vaultexplorer",
|
||||
"pluginVersion": "1.41.0",
|
||||
"pluginVersion": "1.41.1",
|
||||
"logLevel": "trace"
|
||||
}
|
||||
Loading…
Reference in a new issue