diff --git a/.github/workflows/check-console-log.yml b/.github/workflows/check-console-log.yml index 34b7eb9..0f6d140 100644 --- a/.github/workflows/check-console-log.yml +++ b/.github/workflows/check-console-log.yml @@ -1,4 +1,4 @@ -name: Check Console Log +name: Check for console.log statements on: pull_request diff --git a/README.md b/README.md index 30c765e..9f5bf59 100644 --- a/README.md +++ b/README.md @@ -58,14 +58,6 @@ Vault Explorer is a work in progress. Please check the GitHub repository and doc -### Favorites - -![](/readme/favorites-filter.png) - -### Timestamp filter - -![](/readme/timestamp-filter.png) - ### Sort filter ![](/readme/sort-filter.png) @@ -95,75 +87,70 @@ Please do not share your license key with anyone. Shared license keys will be de ## Features -| Name | Categories | Documented | -| --------------------------------------------------------------------------- | -------------------- | ---------- | -| Move focus with left and right arrows | Accessibility | ✅ | -| See an image placeholder on the grid card | Cover image | ✅ | -| Load a cover image from the image property | Cover | ✅ | -| Load images from the url property | Cover image | ✅ | -| Load images from the first link in the frontmatter (wiki link or url) | Cover image | ✅ | -| Load images from the first link the body (internal embed or external embed) | Cover image | ✅ | -| Change the order of cover image sources | Cover image, Setting | ✅ | -| Enable/disable cover image sources | Cover image, Setting | ✅ | -| Cache social media images | Cover image | ✅ | -| Filter files by favorite property | Favorites filter | ✅ | -| Favorites support for non-markdown files | Favorites filter | ✅ | -| Add to favorites button in context menu | Favorites filter | ✅ | -| Remove from favorites button in context menu | Favorites filter | ✅ | -| See a favorite icon in the grid card | Favorites filter | ✅ | -| Reorder the filter group list | Filter group | ✅ | -| Add a filter group | Filter group | ✅ | -| Delete a filter group | Filter group | ✅ | -| Set a filter group as sticky | Filter group | ✅ | -| Unset a filter group as sticky | Filter group | ✅ | -| Right click to edit a filter group item | Filter group | | -| Add a filter rule | Filter rule | ✅ | -| Delete a filter rule | Filter rule | ✅ | -| Duplicate a filter rule | Filter rule | ✅ | -| Match when property doesn't exist toggle | Filter rule | ✅ | -| Filter files by folder | Filter rule | ✅ | -| Filter by frontmatter property | Filter rule | ✅ | -| Select a condition | Filter rule | ✅ | -| Select a logical operator: `and`, `or` | Filter rule | ✅ | -| Filter files by folder | Filter rule | ✅ | -| Filter files by file content | Filter rule | ✅ | -| Filter files by file name | Filter rule | ✅ | -| Enable/disable a filter rule | Filter rule | ✅ | -| Set the log level | Logging | ✅ | -| Filter by search | Search filter | ✅ | -| Set page size | Setting | ✅ | -| Set property for modification date | Setting | ✅ | -| Set property for creation date | Setting | ✅ | -| Set a url property | Setting | ✅ | -| Set a favorite property | Setting | ✅ | -| Set custom text property | Setting | ✅ | -| Toggle file icons | Setting | ✅ | -| Change the filter groups wrap | Setting | ✅ | -| Enable/disable loading the social media image | Setting | ✅ | -| Change the collapse style for feed content | Setting | ✅ | -| Remove H1 from feed content | Setting | ✅ | -| Remove markdown from feed content | Setting | ✅ | -| Enable/disable tags on a list item | Setting | ✅ | -| Change the plugin configuration folder | Setting, Data | ✅ | -| Clear the social media cache | Setting, Data | ✅ | -| Change the feed content line clamp for small screens | Setting, Feed view | ✅ | -| Change the feed content line clamp for medium screens | Setting, Feed view | ✅ | -| Change the feed content line clamp for large screens | Setting, Feed view | ✅ | -| Enter a license key | Setting, License | ✅ | -| Sort by title: `asc`, `desc` | Sort order | ✅ | -| Sort by modification date: `asc`, `desc` | Sort order | ✅ | -| Randomly sort files | Sort order | ✅ | -| Filter by creation date: `1 day`, `1 week`, `2 weeks` | Timestamp filter | ✅ | -| Filter by modification date: `1 day`, `1 week`, `2 weeks` | Timestamp filter | ✅ | -| See vault files in a grid view | View | ✅ | -| See vault files in a list view | View | ✅ | -| See vault files in a feed view | View | ✅ | -| Change the view list order | View | | -| Limit displayed files with pagination | View | | -| Search for a tag when clicked | View | ✅ | -| See a file preview when mouse hovers link and ctrl/cmd is pressed | View | | -| Search for property when clicked | View | ✅ | -| See files icons next to the file name | View | ✅ | +| Name | Categories | Documented | +| --------------------------------------------------------------------------- | ---------------------- | ---------- | +| Move focus with left and right arrows | Accessibility | ✅ | +| See an image placeholder on the grid card | Cover image | ✅ | +| Load a cover image from the image property | Cover image | ✅ | +| Load images from the url property | Cover image | ✅ | +| Load images from the first link in the frontmatter (wiki link or url) | Cover image | ✅ | +| Load images from the first link the body (internal embed or external embed) | Cover image | ✅ | +| Cache social media images | Cover image | ✅ | +| Change the order of cover image sources | Cover image, Setting | ✅ | +| Enable/disable cover image sources | Cover image, Setting | ✅ | +| Enable/disable loading the social media image | Cover image, Setting | ✅ | +| Clear the social media cache | Cover image, Setting | ✅ | +| Change the collapse style for feed content | Feed view, Setting | ✅ | +| Remove H1 from feed content | Feed view, Setting | ✅ | +| Remove markdown from feed content | Feed view, Setting | ✅ | +| Change the feed content line clamp for small screens | Feed view, Setting | ✅ | +| Change the feed content line clamp for medium screens | Feed view, Setting | ✅ | +| Change the feed content line clamp for large screens | Feed view, Setting | ✅ | +| See files icons next to the file name | File icons | ✅ | +| Toggle file icons | File icons, Setting | ✅ | +| Reorder the filter group list | Filter group | ✅ | +| Add a filter group | Filter group | ✅ | +| Delete a filter group | Filter group | ✅ | +| Set a filter group as sticky | Filter group | ✅ | +| Unset a filter group as sticky | Filter group | ✅ | +| Right click to edit a filter group item | Filter group | | +| Change the filter groups wrap | Filter groups, Setting | ✅ | +| Add a filter rule | Filter rule | ✅ | +| Delete a filter rule | Filter rule | ✅ | +| Duplicate a filter rule | Filter rule | ✅ | +| Match when property doesn't exist toggle | Filter rule | ✅ | +| Filter files by folder | Filter rule | ✅ | +| Filter by frontmatter property | Filter rule | ✅ | +| Select a condition | Filter rule | ✅ | +| Select a logical operator: `and`, `or` | Filter rule | ✅ | +| Filter files by folder | Filter rule | ✅ | +| Filter files by file content | Filter rule | ✅ | +| Filter files by file name | Filter rule | ✅ | +| Enable/disable a filter rule | Filter rule | ✅ | +| Enter a license key | License, Setting | ✅ | +| Enable/disable tags on a list item | List view, Setting | ✅ | +| Set the log level | Logging | ✅ | +| Filter by search | Search filter | ✅ | +| Change the plugin configuration folder | Setting | ✅ | +| Sort by title: `asc`, `desc` | Sort order | ✅ | +| Sort by modification date: `asc`, `desc` | Sort order | ✅ | +| Randomly sort files | Sort order | ✅ | +| Set property for modification date | Setting | ✅ | +| Set property for creation date | Setting | ✅ | +| See vault files in a grid view | View | ✅ | +| See vault files in a list view | View | ✅ | +| See vault files in a feed view | View | ✅ | +| See vault files in a table view | View | ✅ | +| Change the view list order | View | | +| Limit displayed files with pagination | View | | +| Search for a tag when clicked | View | ✅ | +| See a file preview when mouse hovers link and ctrl/cmd is pressed | View | | +| Search for property when clicked | View | ✅ | +| Load tags from the body of a markdown notes | View | ✅ | +| Set page size | View, Setting | ✅ | +| Set a url property | View, Setting | ✅ | +| Set custom text property | View, Setting | ✅ | +| Enable/disable load tags from a markdown note | View, Setting | ✅ | ## Network use diff --git a/manifest.json b/manifest.json index 673281e..9c76180 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "vault-explorer", "name": "Vault Explorer", - "version": "1.41.1", + "version": "1.42.0", "minAppVersion": "1.4.13", "description": "Explore your vault in visual format", "author": "DecafDev", diff --git a/package.json b/package.json index e730b76..cd5a4f1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-vault-explorer", - "version": "1.41.1", + "version": "1.42.0", "description": "Explore your vault in visual format", "main": "main.js", "scripts": { diff --git a/readme/favorites-filter.png b/readme/favorites-filter.png deleted file mode 100644 index 451bddd..0000000 Binary files a/readme/favorites-filter.png and /dev/null differ diff --git a/readme/timestamp-filter.png b/readme/timestamp-filter.png deleted file mode 100644 index 6d6981d..0000000 Binary files a/readme/timestamp-filter.png and /dev/null differ diff --git a/src/constants.ts b/src/constants.ts index 218f30a..8075c94 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -7,10 +7,9 @@ export const HOVER_LINK_SOURCE_ID = "vault-explorer-preview"; export const DEFAULT_SETTINGS: VaultExplorerPluginSettings = { properties: { - favorite: "", - url: "", - image: "", - coverImageFit: "", + url: "url", + image: "image", + coverImageFit: "image-fit", createdDate: "", modifiedDate: "", custom1: "", @@ -22,14 +21,6 @@ export const DEFAULT_SETTINGS: VaultExplorerPluginSettings = { isEnabled: true, value: "", }, - favorites: { - isEnabled: true, - value: false, - }, - timestamp: { - isEnabled: true, - value: "all", - }, sort: { isEnabled: true, value: "file-name-asc", @@ -94,8 +85,6 @@ export const DEFAULT_SETTINGS: VaultExplorerPluginSettings = { enableClockUpdates: true, enableFileIcons: false, loadBodyTags: true, - filterGroupsWidth: "300px", - shouldWrapFilterGroups: false, shouldCollapseFilters: false, pageSize: 25, viewOrder: [ diff --git a/src/event/types.ts b/src/event/types.ts index 64a5ebe..5d92567 100644 --- a/src/event/types.ts +++ b/src/event/types.ts @@ -21,7 +21,6 @@ export enum PluginEvent { VIEW_TOGGLE_SETTING_CHANGE = "view-toggle-setting-change", FILE_ICONS_SETTING_CHANGE = "file-icons-setting-change", LOAD_BODY_TAGS_SETTING_CHANGE = "load-body-tags-setting-change", - WRAP_FILTER_GROUPS_SETTING_CHANGE = "wrap-filter-groups-setting-change", LOAD_SOCIAL_MEDIA_IMAGE_SETTING_CHANGE = "load-social-media-image-setting-change", SHOW_TAGS_SETTING_CHANGE = "show-tags-setting-change", } diff --git a/src/main.ts b/src/main.ts index c047ce7..7afa086 100644 --- a/src/main.ts +++ b/src/main.ts @@ -20,6 +20,7 @@ import { isVersionLessThan } from "./utils"; import License from "./svelte/shared/services/license"; import { clearSocialMediaImageCache } from "./svelte/app/services/social-media-image-cache"; import store from "./svelte/shared/services/store"; +import "./styles.css"; export default class VaultExplorerPlugin extends Plugin { settings: VaultExplorerPluginSettings = DEFAULT_SETTINGS; @@ -63,6 +64,22 @@ export default class VaultExplorerPlugin extends Plugin { } private registerEvents() { + this.registerEvent( + this.app.workspace.on("active-leaf-change", () => { + const explorerLeaf = + this.app.workspace.getActiveViewOfType(VaultExplorerView); + const statusBar = document.querySelector( + ".status-bar" + ) as HTMLElement | null; + if (!statusBar) return; + if (explorerLeaf) { + statusBar.classList.add("vault-explorer-status-bar"); + } else { + statusBar.classList.remove("vault-explorer-status-bar"); + } + }) + ); + //Callback if the file is renamed or moved //This callback is already debounced by Obsidian this.registerEvent( @@ -228,7 +245,7 @@ export default class VaultExplorerPlugin extends Plugin { const leaf = leaves[0]; this.app.workspace.revealLeaf(leaf); } else { - this.app.workspace.getLeaf().setViewState({ + this.app.workspace.getLeaf("tab").setViewState({ type: VAULT_EXPLORER_VIEW, active: true, }); diff --git a/src/migrations/index.ts b/src/migrations/index.ts index 9dd64c3..463cdfa 100644 --- a/src/migrations/index.ts +++ b/src/migrations/index.ts @@ -31,6 +31,7 @@ import Migrate_1_38_0 from "./migrate_1_38_0"; import Migrate_1_39_0 from "./migrate_1_39_0"; import Migrate_1_40_0 from "./migrate_1_40_0"; import Migrate_1_41_0 from "./migrate_1_41_0"; +import Migrate_1_42_0 from "./migrate_1_42_0"; const migrations: TMigration[] = [ { @@ -183,6 +184,11 @@ const migrations: TMigration[] = [ to: "1.41.0", migrate: Migrate_1_41_0, }, + { + from: "1.41.1", + to: "1.42.0", + migrate: Migrate_1_42_0, + }, ]; export const preformMigrations = ( diff --git a/src/migrations/migrate_1_42_0.ts b/src/migrations/migrate_1_42_0.ts new file mode 100644 index 0000000..e27cfe3 --- /dev/null +++ b/src/migrations/migrate_1_42_0.ts @@ -0,0 +1,18 @@ +import { VaultExplorerPluginSettings } from "src/types"; +import MigrationInterface from "./migration_interface"; +import { VaultExplorerPluginSettings_1_41_1 } from "src/types/types-1.41.1"; + +export default class Migrate_1_42_0 implements MigrationInterface { + migrate(data: Record) { + const typedData = data as unknown as VaultExplorerPluginSettings_1_41_1; + const newData: VaultExplorerPluginSettings = { + ...typedData, + }; + delete (newData as any).filterGroupsWidth; + delete (newData as any).shouldWrapFilterGroups; + delete (newData as any).filters.favorites; + delete (newData as any).filters.timestamp; + + return newData as unknown as Record; + } +} diff --git a/src/obsidian/utils.ts b/src/obsidian/utils.ts index 07f2a01..07f1dfc 100644 --- a/src/obsidian/utils.ts +++ b/src/obsidian/utils.ts @@ -1,4 +1,4 @@ -import { App } from "obsidian" +import { App } from "obsidian"; import { ObsidianProperty, ObsidianPropertyType } from "./types"; /** @@ -6,17 +6,34 @@ import { ObsidianProperty, ObsidianPropertyType } from "./types"; * NOTE: This is an undocumented API function and may break in future versions of Obsidian */ export const getAllObsidianProperties = (app: App) => { - const properties = (app as any).metadataTypeManager.getAllProperties() as Record; - return Object.values(properties).sort((a: ObsidianProperty, b: ObsidianProperty) => a.name.localeCompare(b.name)); + const properties = ( + app as any + ).metadataTypeManager.getAllProperties() as Record< + string, + ObsidianProperty + >; + return Object.values(properties).sort( + (a: ObsidianProperty, b: ObsidianProperty) => + a.name.localeCompare(b.name) + ); }; -export const getObsidianPropertiesByType = (app: App, type: ObsidianPropertyType) => { +export const getObsidianPropertiesByType = ( + app: App, + type: ObsidianPropertyType +) => { return getAllObsidianProperties(app).filter((p) => p.type === type); -} +}; -export const getDropdownOptionsForProperties = (properties: ObsidianProperty[]) => { - return properties.reduce((acc: Record, cur: ObsidianProperty) => { - acc[cur.name] = cur.name; - return acc; - }, { "": "Select a property" }); -} +export const getDropdownOptionsForProperties = ( + properties: ObsidianProperty[], + defaultValue: Record = { "": "Select a property" } +) => { + return properties.reduce( + (acc: Record, cur: ObsidianProperty) => { + acc[cur.name] = cur.name; + return acc; + }, + defaultValue + ); +}; diff --git a/src/obsidian/vault-explorer-settings-tab.ts b/src/obsidian/vault-explorer-settings-tab.ts index a2024d3..8f7e690 100644 --- a/src/obsidian/vault-explorer-settings-tab.ts +++ b/src/obsidian/vault-explorer-settings-tab.ts @@ -108,20 +108,6 @@ export default class VaultExplorerSettingsTab extends PluginSettingTab { }) ); - new Setting(containerEl) - .setName("Wrap filter groups") - .addToggle((toggle) => - toggle - .setValue(this.plugin.settings.shouldWrapFilterGroups) - .onChange(async (value) => { - this.plugin.settings.shouldWrapFilterGroups = value; - await this.plugin.saveSettings(); - EventManager.getInstance().emit( - PluginEvent.WRAP_FILTER_GROUPS_SETTING_CHANGE - ); - }) - ); - new Setting(containerEl).setName("Filters").setHeading(); new Setting(containerEl).setName("Search filter").addToggle((toggle) => @@ -136,36 +122,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) => - toggle - .setValue(this.plugin.settings.filters.timestamp.isEnabled) - .onChange(async (value) => { - this.plugin.settings.filters.timestamp.isEnabled = - value; - await this.plugin.saveSettings(); - EventManager.getInstance().emit( - PluginEvent.FILTER_TOGGLE_SETTING_CHANGE - ); - }) - ); - new Setting(containerEl).setName("Sort filter").addToggle((toggle) => toggle .setValue(this.plugin.settings.filters.sort.isEnabled) @@ -490,26 +446,6 @@ export default class VaultExplorerSettingsTab extends PluginSettingTab { new Setting(containerEl).setName("Built-in properties").setHeading(); - new Setting(containerEl) - .setName("Favorite property") - .setDesc( - "Property used to mark a note as a favorite. This must be a checkbox property." - ) - .addDropdown((dropdown) => - dropdown - .addOptions( - getDropdownOptionsForProperties(checkboxProperties) - ) - .setValue(this.plugin.settings.properties.favorite) - .onChange(async (value) => { - this.plugin.settings.properties.favorite = value; - await this.plugin.saveSettings(); - EventManager.getInstance().emit( - PluginEvent.PROPERTY_SETTING_CHANGE - ); - }) - ); - new Setting(containerEl) .setName("Cover image property") .setDesc( @@ -517,7 +453,11 @@ export default class VaultExplorerSettingsTab extends PluginSettingTab { ) .addDropdown((dropdown) => dropdown - .addOptions(getDropdownOptionsForProperties(textProperties)) + .addOptions( + getDropdownOptionsForProperties(textProperties, { + image: "image", + }) + ) .setValue(this.plugin.settings.properties.image) .onChange(async (value) => { this.plugin.settings.properties.image = value; @@ -535,7 +475,11 @@ export default class VaultExplorerSettingsTab extends PluginSettingTab { ) .addDropdown((dropdown) => dropdown - .addOptions(getDropdownOptionsForProperties(textProperties)) + .addOptions( + getDropdownOptionsForProperties(textProperties, { + "image-fit": "image-fit", + }) + ) .setValue(this.plugin.settings.properties.coverImageFit) .onChange(async (value) => { this.plugin.settings.properties.coverImageFit = value; @@ -553,7 +497,11 @@ export default class VaultExplorerSettingsTab extends PluginSettingTab { ) .addDropdown((dropdown) => dropdown - .addOptions(getDropdownOptionsForProperties(textProperties)) + .addOptions( + getDropdownOptionsForProperties(textProperties, { + url: "url", + }) + ) .setValue(this.plugin.settings.properties.url) .onChange(async (value) => { this.plugin.settings.properties.url = value; @@ -569,7 +517,7 @@ export default class VaultExplorerSettingsTab extends PluginSettingTab { text: "Property used to store a creation date. This must be a date or datetime property.", }); creationDateDesc.createDiv({ - text: "If set to 'Select a property', the file's created at date will be used.", + text: "If set, the property will be preferred over the file's creation date.", }); new Setting(containerEl) @@ -598,7 +546,7 @@ export default class VaultExplorerSettingsTab extends PluginSettingTab { text: "Property used to store a modification date. This must be a date or datetime property.", }); modificationDateDesc.createDiv({ - text: "If set to 'Select a property', the file's modified at date will be used.", + text: "If set, the property will be preferred over the file's modification date.", }); new Setting(containerEl) @@ -744,16 +692,14 @@ export default class VaultExplorerSettingsTab extends PluginSettingTab { }) ); - new Setting(containerEl) - .setName("Social media image cache") - .addButton((button) => - button - .setClass("mod-destructive") - .setButtonText("Clear cache") - .onClick(async () => { - await clearSocialMediaImageCache(); - }) - ); + new Setting(containerEl).setName("Image cache").addButton((button) => + button + .setClass("mod-destructive") + .setButtonText("Clear cache") + .onClick(async () => { + await clearSocialMediaImageCache(); + }) + ); } onClose() { diff --git a/src/styles.css b/src/styles.css new file mode 100644 index 0000000..fc16996 --- /dev/null +++ b/src/styles.css @@ -0,0 +1,3 @@ +.vault-explorer-status-bar { + display: none; +} diff --git a/src/svelte/app/components/favorites-filter.svelte b/src/svelte/app/components/favorites-filter.svelte deleted file mode 100644 index 48fa017..0000000 --- a/src/svelte/app/components/favorites-filter.svelte +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/src/svelte/app/components/feed-card.svelte b/src/svelte/app/components/feed-card.svelte index aa56dfd..ccfc82d 100644 --- a/src/svelte/app/components/feed-card.svelte +++ b/src/svelte/app/components/feed-card.svelte @@ -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) { diff --git a/src/svelte/app/components/feed-view.svelte b/src/svelte/app/components/feed-view.svelte index 7c01b14..b9e8d2b 100644 --- a/src/svelte/app/components/feed-view.svelte +++ b/src/svelte/app/components/feed-view.svelte @@ -46,8 +46,6 @@ path={fileRenderData.path} content={fileRenderData.content} createdMillis={fileRenderData.createdMillis} - isFavorite={fileRenderData.isFavorite} - on:favoritePropertyChange /> {/each} {/if} diff --git a/src/svelte/app/components/filter-group-list.svelte b/src/svelte/app/components/filter-group-list.svelte index 8269f8d..5ac3b48 100644 --- a/src/svelte/app/components/filter-group-list.svelte +++ b/src/svelte/app/components/filter-group-list.svelte @@ -3,115 +3,50 @@ import _ from "lodash"; import VaultExplorerPlugin from "src/main"; import store from "src/svelte/shared/services/store"; - import { onMount } from "svelte"; - import Wrap from "src/svelte/shared/components/wrap.svelte"; - import EventManager from "src/event/event-manager"; - import { PluginEvent } from "src/event/types"; import FilterGroup from "./filter-group.svelte"; + import Stack from "src/svelte/shared/components/stack.svelte"; export let groups: TFilterGroup[] = []; - let containerRef: HTMLDivElement | null = null; - let shouldWrapFilterGroups: boolean = false; - - const debounceSaveContainerWidth = _.debounce(saveContainerWidth, 200); - let plugin: VaultExplorerPlugin; store.plugin.subscribe((p) => { plugin = p; - shouldWrapFilterGroups = plugin.settings.shouldWrapFilterGroups; }); - - onMount(() => { - function handleWrapFilterGroupsSettingChange() { - shouldWrapFilterGroups = plugin.settings.shouldWrapFilterGroups; - } - - EventManager.getInstance().on( - PluginEvent.WRAP_FILTER_GROUPS_SETTING_CHANGE, - handleWrapFilterGroupsSettingChange, - ); - return () => { - EventManager.getInstance().off( - PluginEvent.WRAP_FILTER_GROUPS_SETTING_CHANGE, - handleWrapFilterGroupsSettingChange, - ); - }; - }); - - onMount(() => { - let resizeObserver: ResizeObserver; - - if (containerRef) { - containerRef.style.width = plugin.settings.filterGroupsWidth; - - resizeObserver = new ResizeObserver(() => { - debounceSaveContainerWidth(); - }); - resizeObserver.observe(containerRef); - } - - return () => { - resizeObserver?.disconnect(); - }; - }); - - async function saveContainerWidth() { - if (containerRef) { - plugin.settings.filterGroupsWidth = containerRef.style.width; - await plugin.saveSettings(); - } - }
-
+ {#if groups.length > 0} - - {#each groups as group (group.id)} - - {/each} - + {#each groups as group (group.id)} + + {/each} {/if} {#if groups.length === 0} - No groups + No groups to display {/if} -
+
diff --git a/src/svelte/app/components/filter-group.svelte b/src/svelte/app/components/filter-group.svelte index 08e3ef5..1716e7d 100644 --- a/src/svelte/app/components/filter-group.svelte +++ b/src/svelte/app/components/filter-group.svelte @@ -66,18 +66,16 @@ diff --git a/src/svelte/app/components/search-filter.svelte b/src/svelte/app/components/search-filter.svelte index c08291f..ae39c82 100644 --- a/src/svelte/app/components/search-filter.svelte +++ b/src/svelte/app/components/search-filter.svelte @@ -1,36 +1,67 @@ -
- - {#if value.length > 0} -
handleClearClick()} - on:keydown={(e) => { - if (e.key === "Enter") { - handleClearClick(); - } - }} + +
+ - {/if} -
+ {#if value.length > 0} +
handleClearClick()} + on:keydown={(e) => { + if (e.key === "Enter") { + handleClearClick(); + } + }} + /> + {/if} +
+ handleIconClick()} + /> +
diff --git a/src/svelte/app/services/context-menu.ts b/src/svelte/app/services/context-menu.ts index 7ef61cd..9609a91 100644 --- a/src/svelte/app/services/context-menu.ts +++ b/src/svelte/app/services/context-menu.ts @@ -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,25 +31,15 @@ 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) => { - item.setTitle("Cover image fit: cover"); + item.setTitle("Cover"); item.setChecked(coverImageFit === "cover"); item.onClick(() => onCoverImageFitChange(filePath, "cover")); }); menu.addItem((item) => { - item.setTitle("Cover image fit: contain"); + item.setTitle("Contain"); item.setChecked(coverImageFit === "contain"); item.onClick(() => onCoverImageFitChange(filePath, "contain")); }); diff --git a/src/svelte/app/services/filters/favorite-filter.ts b/src/svelte/app/services/filters/favorite-filter.ts deleted file mode 100644 index 4b4673c..0000000 --- a/src/svelte/app/services/filters/favorite-filter.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { FileRenderData } from "../../types"; - -export const filterByFavorites = ( - file: FileRenderData, - onlyFavorites: boolean -) => { - if (onlyFavorites) { - return file.isFavorite; - } - return true; -}; diff --git a/src/svelte/app/services/filters/timestamp-filter.ts b/src/svelte/app/services/filters/timestamp-filter.ts deleted file mode 100644 index 55684dd..0000000 --- a/src/svelte/app/services/filters/timestamp-filter.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { TimestampFilterOption } from "src/types"; - -interface FilterByTimestampParams { - value: TimestampFilterOption; - createdMillis: number; - modifiedMillis: number; - startOfTodayMillis: number; - startOfThisWeekMillis: number; - startOfLastWeekMillis: number; -} - -export const filterByTimestamp = ({ - value, - createdMillis, - modifiedMillis, - startOfTodayMillis, - startOfThisWeekMillis, - startOfLastWeekMillis, -}: FilterByTimestampParams) => { - if (value === "modified-this-week") { - return modifiedMillis > startOfThisWeekMillis; - } else if (value === "created-this-week") { - return createdMillis > startOfThisWeekMillis; - } else if (value === "modified-2-weeks") { - return modifiedMillis > startOfLastWeekMillis; - } else if (value === "created-2-weeks") { - return createdMillis > startOfLastWeekMillis; - } else if (value === "modified-today") { - return modifiedMillis > startOfTodayMillis; - } else if (value === "created-today") { - return createdMillis > startOfTodayMillis; - } - return true; -} diff --git a/src/svelte/app/services/render-data.ts b/src/svelte/app/services/render-data.ts index f468d08..bb39f03 100644 --- a/src/svelte/app/services/render-data.ts +++ b/src/svelte/app/services/render-data.ts @@ -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; @@ -67,7 +65,6 @@ export const formatFileDataForRender = ({ url: urlProp, image: imageProp, coverImageFit: coverImageFitProp, - favorite: favoriteProp, custom1: custom1Prop, custom2: custom2Prop, custom3: custom3Prop, @@ -96,17 +93,6 @@ export const formatFileDataForRender = ({ PropertyType.TEXT ); - let isFavorite: boolean | null; - if (fileFavorite === null) { - isFavorite = loadPropertyValue( - fileFrontmatter, - favoriteProp, - PropertyType.CHECKBOX - ); - } else { - isFavorite = fileFavorite; - } - let coverImageFit: CoverImageFit | null = loadPropertyValue( fileFrontmatter, coverImageFitProp, @@ -250,7 +236,6 @@ export const formatFileDataForRender = ({ content: fileContent, tags, imageUrl, - isFavorite, createdMillis, modifiedMillis, custom1, diff --git a/src/svelte/app/services/social-media-image-cache.ts b/src/svelte/app/services/social-media-image-cache.ts index c122694..72e44c7 100644 --- a/src/svelte/app/services/social-media-image-cache.ts +++ b/src/svelte/app/services/social-media-image-cache.ts @@ -61,9 +61,9 @@ export const clearSocialMediaImageCache = async () => { try { const db = await openDatabase(); await db.clear(STORE_NAME); - new Notice("Vault Explorer: social media image cache cleared"); + new Notice("Vault Explorer: Image cache cleared"); } catch (err) { - new Notice("Failed to clear social media image cache"); + new Notice("Vault Explorer: Failed to clear image cache"); const error = err as Error; Logger.error( { diff --git a/src/svelte/app/services/time-string.ts b/src/svelte/app/services/time-string.ts index e8ca6bd..0c5e53e 100644 --- a/src/svelte/app/services/time-string.ts +++ b/src/svelte/app/services/time-string.ts @@ -19,7 +19,7 @@ export const formatAsBearTimeString = (milliseconds: number) => { return `${diffInHours} hours ago`; } if (diffInDays === 1) { - return `Yesterday at ${time.format("hh:mm A")}`; + return `Yesterday at ${time.format("h:mm A")}`; } if (time.year() === now.year()) { return time.format("MMMM D"); diff --git a/src/svelte/app/types.ts b/src/svelte/app/types.ts index b0b16cb..282a464 100644 --- a/src/svelte/app/types.ts +++ b/src/svelte/app/types.ts @@ -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; diff --git a/src/svelte/shared/components/icon-button.svelte b/src/svelte/shared/components/icon-button.svelte index ab7cabc..28595a9 100644 --- a/src/svelte/shared/components/icon-button.svelte +++ b/src/svelte/shared/components/icon-button.svelte @@ -26,6 +26,7 @@ } $: className = getClassName(noPadding); + $: hasSlotContent = !!$$slots.default; + + {#if hasSlotContent} +
+ +
+ {/if} +