Skip to content

Commit

Permalink
Merge pull request #211 from decaf-dev/dev
Browse files Browse the repository at this point in the history
1.26.0
  • Loading branch information
decaf-dev authored Jul 16, 2024
2 parents cb71be7 + b4e55fb commit e05a3e1
Show file tree
Hide file tree
Showing 31 changed files with 1,003 additions and 209 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "vault-explorer",
"name": "Vault Explorer",
"version": "1.25.2",
"version": "1.26.0",
"minAppVersion": "1.4.13",
"description": "Explore your vault in visual format",
"author": "DecafDev",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-vault-explorer",
"version": "1.25.2",
"version": "1.26.0",
"description": "Explore your vault in visual format",
"main": "main.js",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export const VAULT_EXPLORER_VIEW = "vault-explorer";
export const HOVER_LINK_SOURCE_ID = "vault-explorer-preview";

export const DEFAULT_SETTINGS: VaultExplorerPluginSettings = {
logLevel: LOG_LEVEL_WARN,
properties: {
favorite: "",
url: "",
Expand Down Expand Up @@ -75,5 +74,7 @@ export const DEFAULT_SETTINGS: VaultExplorerPluginSettings = {
filterGroupsWrapping: "nowrap",
pageSize: 25,
viewOrder: [TExplorerView.GRID, TExplorerView.LIST, TExplorerView.FEED],
configDir: ".vaultexplorer",
pluginVersion: null,
logLevel: LOG_LEVEL_WARN,
};
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export default class VaultExplorerPlugin extends Plugin {
//This will be undefined if the settings are from a version before 0.3.0
const loadedVersion =
(loadedData["pluginVersion"] as string) ?? null;

if (loadedVersion !== null) {
const newData = preformMigrations(loadedVersion, loadedData);
currentData = newData;
Expand Down
11 changes: 9 additions & 2 deletions src/migrations/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { TMigration } from "./types";
import Migrate_0_4_0 from "./migrate_0_4_0";
import Migrate_1_1_0 from "./migrate_1_1_0";
import Migrate_1_0_0 from "./migrate_1_0_0";
Expand All @@ -12,13 +11,16 @@ import Migrate_1_15_0 from "./migrate_1_15_0";
import Migrate_1_17_0 from "./migrate_1_17_0";
import Migrate_1_13_0 from "./migrate_1_13_0";
import Migrate_1_10_0 from "./migrate_1_10_0";
import { isVersionLessThan } from "src/utils";
import Migrate_1_21_0 from "./migrate_1_21_0";
import Migrate_1_22_0 from "./migrate_1_22_0";
import Migrate_1_23_0 from "./migrate_1_23_0";
import Migrate_1_23_1 from "./migrate_1_23_1";
import Migrate_1_24_0 from "./migrate_1_24_0";
import Migrate_1_25_0 from "./migrate_1_25_0";
import Migrate_1_26_0 from "./migrate_1_26_0";

import { TMigration } from "./types";
import { isVersionLessThan } from "src/utils";

const migrations: TMigration[] = [
{
Expand Down Expand Up @@ -116,6 +118,11 @@ const migrations: TMigration[] = [
to: "1.25.0",
migrate: Migrate_1_25_0,
},
{
from: "1.25.2",
to: "1.26.0",
migrate: Migrate_1_26_0,
},
];

export const preformMigrations = (
Expand Down
4 changes: 2 additions & 2 deletions src/migrations/migrate_1_25_0.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { VaultExplorerPluginSettings } from "src/types";
import MigrationInterface from "./migration_interface";
import { VaultExplorerPluginSettings_1_24_2 } from "src/types/types-1.24.2";
import { VaultExplorerPluginSettings_1_25_2 } from "src/types/types-1.25.2";

export default class Migrate_1_25_0 implements MigrationInterface {
migrate(data: Record<string, unknown>) {
const typedData = data as unknown as VaultExplorerPluginSettings_1_24_2;
const newData: VaultExplorerPluginSettings = {
const newData: VaultExplorerPluginSettings_1_25_2 = {
...typedData,
fileInteractionStyle: "content",
};
Expand Down
15 changes: 15 additions & 0 deletions src/migrations/migrate_1_26_0.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { VaultExplorerPluginSettings } from "src/types";
import MigrationInterface from "./migration_interface";
import { VaultExplorerPluginSettings_1_25_2 } from "src/types/types-1.25.2";

export default class Migrate_1_26_0 implements MigrationInterface {
migrate(data: Record<string, unknown>) {
const typedData = data as unknown as VaultExplorerPluginSettings_1_25_2;
const newData: VaultExplorerPluginSettings = {
...typedData,
configDir: ".vaultexplorer",
};

return newData as unknown as Record<string, unknown>;
}
}
14 changes: 12 additions & 2 deletions src/svelte/app/components/feed-card.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { onMount } from "svelte";
import { createEventDispatcher, onMount } from "svelte";
import { FileInteractionStyle, WordBreak } from "src/types";
import EventManager from "src/event/event-manager";
import VaultExplorerPlugin from "src/main";
Expand All @@ -26,6 +26,7 @@
export let tags: string[] | null;
export let createdMillis: number;
export let content: string | null;
export let isFavorite: boolean | null;
let ref: HTMLElement | null = null;
let wordBreak: WordBreak = "normal";
Expand All @@ -34,6 +35,8 @@
let contentModifierClassName = "";
let fileInteractionStyle: FileInteractionStyle = "content";
const dispatch = createEventDispatcher();
let plugin: VaultExplorerPlugin;
store.plugin.subscribe((value) => {
plugin = value;
Expand Down Expand Up @@ -153,9 +156,16 @@
openInCurrentTab(plugin, path);
}
function handleFavoriteChange(filePath: string, value: boolean) {
dispatch("favoritePropertyChange", { filePath, value });
}
function handleCardContextMenu(e: CustomEvent) {
const { nativeEvent } = e.detail;
openContextMenu(plugin, nativeEvent, path);
openContextMenu(plugin, path, nativeEvent, {
isFavorite,
onFavoriteChange: handleFavoriteChange,
});
}
function handleTitleContextMenu(e: CustomEvent) {
Expand Down
2 changes: 2 additions & 0 deletions src/svelte/app/components/feed-view.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
tags={fileRenderData.tags}
content={fileRenderData.content}
createdMillis={fileRenderData.createdMillis}
isFavorite={fileRenderData.isFavorite}
on:favoritePropertyChange
/>
{/each}
{/if}
Expand Down
149 changes: 87 additions & 62 deletions src/svelte/app/components/grid-card.svelte
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
<script lang="ts">
import { MarkdownView } from "obsidian";
import IconButton from "../../shared/components/icon-button.svelte";
import Tag from "../../shared/components/tag.svelte";
import Property from "../../shared/components/property.svelte";
import VaultExplorerPlugin from "src/main";
import store from "../../shared/services/store";
import Wrap from "src/svelte/shared/components/wrap.svelte";
import Stack from "src/svelte/shared/components/stack.svelte";
import { onMount } from "svelte";
import { createEventDispatcher, onMount } from "svelte";
import { FileInteractionStyle, 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 Spacer from "src/svelte/shared/components/spacer.svelte";
import License from "src/svelte/shared/services/license";
import { fetchSocialMediaImage } from "../services/social-media-image";
import { PluginEvent } from "src/event/types";
Expand All @@ -32,6 +30,7 @@
export let custom1: string | null;
export let custom2: string | null;
export let custom3: string | null;
export let isFavorite: boolean | null;
let plugin: VaultExplorerPlugin;
let wordBreak: WordBreak = "normal";
Expand All @@ -48,6 +47,8 @@
loadSocialMediaImage = plugin.settings.views.grid.loadSocialMediaImage;
});
const dispatch = createEventDispatcher();
License.getInstance()
.getIsDeviceRegisteredStore()
.subscribe((isRegistered) => {
Expand Down Expand Up @@ -148,9 +149,17 @@
openInCurrentTab(plugin, path);
}
function handleFavoriteChange(filePath: string, value: boolean) {
console.log("favoritePropertyChange", { filePath, value });
dispatch("favoritePropertyChange", { filePath, value });
}
function handleCardContextMenu(e: CustomEvent) {
const { nativeEvent } = e.detail;
openContextMenu(plugin, nativeEvent, path);
openContextMenu(plugin, path, nativeEvent, {
isFavorite,
onFavoriteChange: handleFavoriteChange,
});
}
function handleCardMouseOver(e: MouseEvent) {
Expand All @@ -177,6 +186,9 @@
}
$: loadSocialMediaImage, getSocialImageUrl();
$: hasBodyContent =
tags != null || custom1 != null || custom2 != null || custom3 != null;
</script>

<GridCardContainer
Expand All @@ -190,61 +202,69 @@
<!-- svelte-ignore a11y-missing-attribute -->
<img class="vault-explorer-grid-card__image" src={imageUrl} />
{/if}
</div>
<div class="vault-explorer-grid-card__header">
<GridCardTitle
{fileInteractionStyle}
on:click={handleTitleClick}
on:contextmenu={handleTitleContextMenu}
on:mouseover={handleTitleMouseOver}
>
<Stack spacing="xs">
{#if enableFileIcons}
<Icon iconId={getIconIdForFile(baseName, extension)} />
{/if}
<div class="vault-explorer-grid-card__title-text">
{displayName}
</div>
</Stack>
</GridCardTitle>
{#if url !== null}
<IconButton
iconId="external-link"
noPadding
on:click={handleUrlClick}
/>
{#if isFavorite === true}
<div class="vault-explorer-grid-card__favorite">
<Icon iconId="star" ariaLabel="Favorite" />
</div>
{/if}
</div>
<div class="vault-explorer-grid-card__content">
{#if tags !== null}
<div class="vault-explorer-grid-card__tags">
<Wrap spacingX="sm" spacingY="sm">
{#each tags as tag}
<Tag name={tag} />
{/each}
</Wrap>
<Stack spacing={hasBodyContent ? "sm" : "none"} direction="column">
<div class="vault-explorer-grid-card__head">
<GridCardTitle
{fileInteractionStyle}
on:click={handleTitleClick}
on:contextmenu={handleTitleContextMenu}
on:mouseover={handleTitleMouseOver}
>
<Stack spacing="xs">
{#if enableFileIcons}
<Icon
iconId={getIconIdForFile(baseName, extension)}
/>
{/if}
<div class="vault-explorer-grid-card__title-text">
{displayName}
</div>
</Stack>
</GridCardTitle>
{#if url !== null}
<IconButton
iconId="external-link"
ariaLabel="Open in browser"
noPadding
on:click={handleUrlClick}
/>
{/if}
</div>
{/if}
{#if custom1 !== null || custom2 !== null || custom3 !== null}
<Spacer size="sm" direction="vertical" />
{/if}
<Wrap spacingX="xs" spacingY="xs"
>{#if custom1 !== null}<Property
name={plugin.settings.properties.custom1}
value={custom1}
/>{/if}
{#if custom2 !== null}<Property
name={plugin.settings.properties.custom2}
value={custom2}
/>{/if}
{#if custom3 !== null}<Property
name={plugin.settings.properties.custom3}
value={custom3}
/>{/if}
</Wrap>
{#if tags != null || custom1 !== null || custom2 !== null || custom3 !== null}
<Spacer size="sm" direction="vertical" />
{/if}
{#if tags !== null}
<div class="vault-explorer-grid-card__tags">
<Wrap spacingX="sm" spacingY="sm">
{#each tags as tag}
<Tag name={tag} />
{/each}
</Wrap>
</div>
{/if}
{#if custom1 !== null || custom2 !== null || custom3 !== null}
<div class="vault-explorer-grid-card__properties">
<Wrap spacingX="xs" spacingY="xs"
>{#if custom1 !== null}<Property
name={plugin.settings.properties.custom1}
value={custom1}
/>{/if}
{#if custom2 !== null}<Property
name={plugin.settings.properties.custom2}
value={custom2}
/>{/if}
{#if custom3 !== null}<Property
name={plugin.settings.properties.custom3}
value={custom3}
/>{/if}
</Wrap>
</div>
{/if}
</Stack>
</div>
</GridCardContainer>

Expand All @@ -255,6 +275,13 @@
background-color: var(--background-modifier-border);
border-top-left-radius: var(--radius-m);
border-top-right-radius: var(--radius-m);
position: relative;
}
.vault-explorer-grid-card__favorite {
position: absolute;
top: 8px;
right: 8px;
}
.vault-explorer-grid-card__image {
Expand All @@ -265,17 +292,15 @@
border-top-right-radius: var(--radius-m);
}
.vault-explorer-grid-card__header {
.vault-explorer-grid-card__content {
padding: 8px 16px;
}
.vault-explorer-grid-card__head {
display: flex;
justify-content: space-between;
align-items: flex-start;
column-gap: 0.5rem;
padding: 8px 16px;
}
.vault-explorer-grid-card__content {
padding: 0px 16px;
position: relative;
}
.vault-explorer-grid-card__title-text {
Expand Down
2 changes: 2 additions & 0 deletions src/svelte/app/components/grid-view.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
custom1={fileRenderData.custom1}
custom2={fileRenderData.custom2}
custom3={fileRenderData.custom3}
isFavorite={fileRenderData.isFavorite}
on:favoritePropertyChange
/>
{/each}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/svelte/app/components/group-tag.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
>
{#if isSticky}
<Stack spacing="xs" align="center">
<Icon iconId="pin" xs />
<Icon iconId="pin" size="xs" />
<div>{name}</div>
</Stack>
{/if}
Expand Down
Loading

0 comments on commit e05a3e1

Please sign in to comment.