diff --git a/manifest.json b/manifest.json index 7fc2274..f42b5b0 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "vault-explorer", "name": "Vault Explorer", - "version": "1.32.2", + "version": "1.33.0", "minAppVersion": "1.4.13", "description": "Explore your vault in visual format", "author": "DecafDev", diff --git a/package.json b/package.json index f22105c..7986452 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-vault-explorer", - "version": "1.32.2", + "version": "1.33.0", "description": "Explore your vault in visual format", "main": "main.js", "scripts": { diff --git a/src/constants.ts b/src/constants.ts index 80ae483..e56f2bb 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -75,7 +75,6 @@ export const DEFAULT_SETTINGS: VaultExplorerPluginSettings = { enableClockUpdates: true, enableFileIcons: false, enableScrollButtons: true, - fileInteractionStyle: "content", filterGroupsWidth: "300px", shouldWrapFilterGroups: false, pageSize: 25, diff --git a/src/event/types.ts b/src/event/types.ts index c379782..aae0f4b 100644 --- a/src/event/types.ts +++ b/src/event/types.ts @@ -10,7 +10,6 @@ export enum PluginEvent { FOLDER_CREATE = "folder-create", PAGE_SIZE_SETTING_CHANGE = "page-size-setting-change", TITLE_WRAPPING_SETTING_CHANGE = "title-wrapping-setting-change", - FILE_INTERACTION_STYLE = "file-interaction-style-setting-change", FEED_CONTENT_SETTING_CHANGE = "feed-content-setting-change", COVER_IMAGE_SOURCE_SETTING_CHANGE = "cover-image-source-setting-change", PROPERTY_SETTING_CHANGE = "property-setting-change", diff --git a/src/migrations/index.ts b/src/migrations/index.ts index 57ce61e..1bbee7b 100644 --- a/src/migrations/index.ts +++ b/src/migrations/index.ts @@ -25,6 +25,7 @@ import Migrate_1_27_0 from "./migrate_1_27_0"; import Migrate_1_29_0 from "./migrate_1_29_0"; import Migrate_1_30_0 from "./migrate_1_30_5"; import Migrate_1_31_0 from "./migrate_1_31_0"; +import Migrate_1_33_0 from "./migrate_1_33_0"; const migrations: TMigration[] = [ { @@ -147,6 +148,11 @@ const migrations: TMigration[] = [ to: "1.31.0", migrate: Migrate_1_31_0, }, + { + from: "1.32.2", + to: "1.33.0", + migrate: Migrate_1_33_0, + }, ]; export const preformMigrations = ( diff --git a/src/migrations/migrate_1_33_0.ts b/src/migrations/migrate_1_33_0.ts new file mode 100644 index 0000000..5c2c38d --- /dev/null +++ b/src/migrations/migrate_1_33_0.ts @@ -0,0 +1,15 @@ +import { VaultExplorerPluginSettings } from "src/types"; +import MigrationInterface from "./migration_interface"; +import { VaultExplorerPluginSettings_1_32_2 } from "src/types/types-1.32.2"; + +export default class Migrate_1_33_0 implements MigrationInterface { + migrate(data: Record) { + const typedData = data as unknown as VaultExplorerPluginSettings_1_32_2; + const newData: VaultExplorerPluginSettings = { + ...typedData, + }; + + delete (newData as any).fileInteractionStyle; + return newData as unknown as Record; + } +} diff --git a/src/obsidian/vault-explorer-settings-tab.ts b/src/obsidian/vault-explorer-settings-tab.ts index cf5fb42..11e5931 100644 --- a/src/obsidian/vault-explorer-settings-tab.ts +++ b/src/obsidian/vault-explorer-settings-tab.ts @@ -53,26 +53,6 @@ export default class VaultExplorerSettingsTab extends PluginSettingTab { new Setting(containerEl).setName("General").setHeading(); - new Setting(containerEl) - .setName("File interaction") - .setDesc("Set how a file should be interacted with.") - .addDropdown((cb) => { - cb.addOptions({ - content: "Click on content", - title: "Click on title", - }); - cb.setValue(this.plugin.settings.fileInteractionStyle).onChange( - async (value) => { - this.plugin.settings.fileInteractionStyle = - value as FileInteractionStyle; - await this.plugin.saveSettings(); - EventManager.getInstance().emit( - PluginEvent.FILE_INTERACTION_STYLE - ); - } - ); - }); - // new Setting(containerEl) // .setName("Title wrapping") // .setDesc("Set the wrapping style for the title.") diff --git a/src/svelte/app/components/feed-card-container.svelte b/src/svelte/app/components/feed-card-container.svelte deleted file mode 100644 index af907a1..0000000 --- a/src/svelte/app/components/feed-card-container.svelte +++ /dev/null @@ -1,61 +0,0 @@ - - -{#if fileInteractionStyle === "content"} -
{ - if (e.key === "Enter" || e.key === " ") { - handleClick(); - } - }} - on:contextmenu={(e) => { - e.preventDefault(); - handleContextMenu(e); - }} - on:focus={() => {}} - on:mouseover - > - -
-{/if} - -{#if fileInteractionStyle === "title"} -
- -
-{/if} - - diff --git a/src/svelte/app/components/feed-card-title.svelte b/src/svelte/app/components/feed-card-title.svelte index 59d0a2f..9722c15 100644 --- a/src/svelte/app/components/feed-card-title.svelte +++ b/src/svelte/app/components/feed-card-title.svelte @@ -21,7 +21,7 @@
{}} on:click={(e) => { e.preventDefault(); diff --git a/src/svelte/app/components/feed-card.svelte b/src/svelte/app/components/feed-card.svelte index ed41e46..2465ea9 100644 --- a/src/svelte/app/components/feed-card.svelte +++ b/src/svelte/app/components/feed-card.svelte @@ -1,6 +1,6 @@ - { + if (e.key === "Enter" || e.key === " ") { + handleCardClick(); + } + }} + on:contextmenu={(e) => { + e.preventDefault(); + handleCardContextMenu(e); + }} + on:focus={() => {}} + on:mouseover > - {}} + on:click={(e) => { + e.preventDefault(); + handleTitleClick(); + }} + on:contextmenu={(e) => { + e.preventDefault(); + handleTitleContextMenu(e); + }} + on:keydown={(e) => { + if (e.key === "Enter" || e.key === " ") { + e.preventDefault(); + handleTitleClick(); + } + }} on:mouseover={handleTitleMouseOver} > @@ -278,7 +283,7 @@ {displayName}
- + {#if displayContent != null && displayContent.length > 0}
- +
diff --git a/src/svelte/app/components/grid-card-title.svelte b/src/svelte/app/components/grid-card-title.svelte deleted file mode 100644 index 00637de..0000000 --- a/src/svelte/app/components/grid-card-title.svelte +++ /dev/null @@ -1,66 +0,0 @@ - - -{#if fileInteractionStyle === "title"} -
{}} - on:click={(e) => { - e.preventDefault(); - handleClick(); - }} - on:contextmenu={(e) => { - e.preventDefault(); - handleContextMenu(e); - }} - on:keydown={(e) => { - if (e.key === "Enter" || e.key === " ") { - e.preventDefault(); - handleClick(); - } - }} - on:mouseover - > - -
-{/if} - -{#if fileInteractionStyle === "content"} -
- -
-{/if} - - diff --git a/src/svelte/app/components/grid-card.svelte b/src/svelte/app/components/grid-card.svelte index 3198b09..a963f4c 100644 --- a/src/svelte/app/components/grid-card.svelte +++ b/src/svelte/app/components/grid-card.svelte @@ -7,15 +7,13 @@ import Wrap from "src/svelte/shared/components/wrap.svelte"; import Stack from "src/svelte/shared/components/stack.svelte"; import { createEventDispatcher, onMount } from "svelte"; - import { FileInteractionStyle, WordBreak } from "src/types"; + import { WordBreak } from "src/types"; import { HOVER_LINK_SOURCE_ID } from "src/constants"; import EventManager from "src/event/event-manager"; import Icon from "src/svelte/shared/components/icon.svelte"; import { getIconIdForFile } from "../services/file-icon"; import { fetchSocialImage } from "../services/social-media-image"; import { PluginEvent } from "src/event/types"; - import GridCardContainer from "./grid-card-container.svelte"; - import GridCardTitle from "./grid-card-title.svelte"; import { openContextMenu } from "../services/context-menu"; import { openInCurrentTab } from "../services/open-file"; import Flex from "src/svelte/shared/components/flex.svelte"; @@ -39,13 +37,11 @@ let wordBreak: WordBreak = "normal"; let enableFileIcons: boolean = false; let loadSocialMediaImage: boolean = true; - let fileInteractionStyle: FileInteractionStyle = "content"; let imgSrc: string | null = null; store.plugin.subscribe((p) => { plugin = p; wordBreak = plugin.settings.titleWrapping; - fileInteractionStyle = plugin.settings.fileInteractionStyle; enableFileIcons = plugin.settings.enableFileIcons; loadSocialMediaImage = plugin.settings.views.grid.loadSocialMediaImage; }); @@ -64,23 +60,6 @@ } }); - onMount(() => { - function handleFileInteractionStyleChange() { - fileInteractionStyle = plugin.settings.fileInteractionStyle; - } - - EventManager.getInstance().on( - PluginEvent.FILE_INTERACTION_STYLE, - handleFileInteractionStyleChange, - ); - return () => { - EventManager.getInstance().off( - PluginEvent.FILE_INTERACTION_STYLE, - handleFileInteractionStyleChange, - ); - }; - }); - onMount(() => { function handleLoadSocialMediaImageChange() { const newValue = plugin.settings.views.grid.loadSocialMediaImage; @@ -173,8 +152,8 @@ dispatch("favoritePropertyChange", { filePath, value }); } - function handleCardContextMenu(e: CustomEvent) { - const { nativeEvent } = e.detail; + function handleCardContextMenu(e: Event) { + const nativeEvent = e as MouseEvent; openContextMenu(plugin, path, nativeEvent, { isFavorite, onFavoriteChange: handleFavoriteChange, @@ -196,7 +175,7 @@ handleCardClick(); } - function handleTitleContextMenu(e: CustomEvent) { + function handleTitleContextMenu(e: Event) { handleCardContextMenu(e); } @@ -208,11 +187,22 @@ tags != null || custom1 != null || custom2 != null || custom3 != null; - { + if (e.key === "Enter" || e.key === " ") { + handleCardClick(); + } + }} + on:contextmenu={(e) => { + e.preventDefault(); + handleCardContextMenu(e); + }} + on:focus={() => {}} + on:mouseover >
{#if imgSrc !== null} @@ -234,10 +224,25 @@
- {}} + on:click={(e) => { + e.preventDefault(); + handleTitleClick(); + }} + on:contextmenu={(e) => { + e.preventDefault(); + handleTitleContextMenu(e); + }} + on:keydown={(e) => { + if (e.key === "Enter" || e.key === " ") { + e.preventDefault(); + handleTitleClick(); + } + }} on:mouseover={handleTitleMouseOver} > @@ -248,7 +253,7 @@ {displayName}
- +
{#if url !== null} {/if} -
+ diff --git a/src/svelte/app/components/list-item-container.svelte b/src/svelte/app/components/list-item-container.svelte deleted file mode 100644 index 20638f9..0000000 --- a/src/svelte/app/components/list-item-container.svelte +++ /dev/null @@ -1,61 +0,0 @@ - - -{#if fileInteractionStyle === "content"} -
{ - if (e.key === "Enter" || e.key === " ") { - handleClick(); - } - }} - on:contextmenu={(e) => { - e.preventDefault(); - handleContextMenu(e); - }} - on:focus={() => {}} - on:mouseover - > - -
-{/if} - -{#if fileInteractionStyle === "title"} -
- -
-{/if} - - diff --git a/src/svelte/app/components/list-item-title.svelte b/src/svelte/app/components/list-item-title.svelte deleted file mode 100644 index 3f0152d..0000000 --- a/src/svelte/app/components/list-item-title.svelte +++ /dev/null @@ -1,70 +0,0 @@ - - -{#if fileInteractionStyle === "title"} -
{}} - on:click={(e) => { - e.preventDefault(); - handleClick(); - }} - on:contextmenu={(e) => { - e.preventDefault(); - handleContextMenu(e); - }} - on:keydown={(e) => { - if (e.key === "Enter" || e.key === " ") { - e.preventDefault(); - handleClick(); - } - }} - on:mouseover - > - -
-{/if} - -{#if fileInteractionStyle === "content"} -
- -
-{/if} - - diff --git a/src/svelte/app/components/list-item.svelte b/src/svelte/app/components/list-item.svelte index 5d0b768..35c7483 100644 --- a/src/svelte/app/components/list-item.svelte +++ b/src/svelte/app/components/list-item.svelte @@ -9,11 +9,8 @@ import { createEventDispatcher, onMount } from "svelte"; import EventManager from "src/event/event-manager"; import { PluginEvent } from "src/event/types"; - import ListItemContainer from "./list-item-container.svelte"; - import { FileInteractionStyle } from "src/types"; import { openContextMenu } from "../services/context-menu"; import { openInCurrentTab } from "../services/open-file"; - import ListItemTitle from "./list-item-title.svelte"; import { HOVER_LINK_SOURCE_ID } from "src/constants"; import { SCREEN_SIZE_MD } from "../constants"; @@ -25,7 +22,6 @@ export let isFavorite: boolean | null; let enableFileIcons: boolean = false; - let fileInteractionStyle: FileInteractionStyle = "content"; let isSmallScreenSize: boolean = false; let ref: HTMLElement | null = null; let showTags: boolean = true; @@ -36,7 +32,6 @@ store.plugin.subscribe((p) => { plugin = p; enableFileIcons = plugin.settings.enableFileIcons; - fileInteractionStyle = plugin.settings.fileInteractionStyle; showTags = plugin.settings.views.list.showTags; }); @@ -74,23 +69,6 @@ }; }); - onMount(() => { - function handleFileInteractionStyleChange() { - fileInteractionStyle = plugin.settings.fileInteractionStyle; - } - - EventManager.getInstance().on( - PluginEvent.FILE_INTERACTION_STYLE, - handleFileInteractionStyleChange, - ); - return () => { - EventManager.getInstance().off( - PluginEvent.FILE_INTERACTION_STYLE, - handleFileInteractionStyleChange, - ); - }; - }); - onMount(() => { let resizeObserver: ResizeObserver; @@ -128,7 +106,7 @@ openInCurrentTab(plugin, path); } - function handleTitleContextMenu(e: CustomEvent) { + function handleTitleContextMenu(e: Event) { handleItemContextMenu(e); } @@ -136,8 +114,8 @@ dispatch("favoritePropertyChange", { filePath, value }); } - function handleItemContextMenu(e: CustomEvent) { - const { nativeEvent } = e.detail; + function handleItemContextMenu(e: Event) { + const nativeEvent = e as MouseEvent; openContextMenu(plugin, path, nativeEvent, { isFavorite, onFavoriteChange: handleFavoriteChange, @@ -160,14 +138,26 @@ } $: tagsClassName = `vault-explorer-list-item__tags ${isSmallScreenSize ? "vault-explorer-list-item__tags--screen-size-sm" : ""}`; + $: titleClassName = `vault-explorer-list-item__title ${isSmallScreenSize ? "vault-explorer-list-item__title--screen-size-sm" : ""}`; - { + if (e.key === "Enter" || e.key === " ") { + handleItemClick(); + } + }} + on:contextmenu={(e) => { + e.preventDefault(); + handleItemContextMenu(e); + }} + on:focus={() => {}} + on:mouseover > - {}} + on:click={(e) => { + e.preventDefault(); + handleTitleClick(); + }} + on:contextmenu={(e) => { + e.preventDefault(); + handleTitleContextMenu(e); + }} + on:keydown={(e) => { + if (e.key === "Enter" || e.key === " ") { + e.preventDefault(); + handleTitleClick(); + } + }} on:mouseover={handleTitleMouseOver} > @@ -190,7 +194,7 @@ {displayName} - + {#if showTags}
{#if tags !== null} @@ -207,9 +211,36 @@
{/if}
-
+