mirror of
https://github.com/decaf-dev/obsidian-vault-explorer.git
synced 2026-07-22 10:10:31 +00:00
feat: rename to loadSocialMediaImage
This commit is contained in:
parent
3074e056ef
commit
02ec868d60
14 changed files with 358 additions and 25 deletions
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "vault-explorer",
|
||||
"name": "Vault Explorer",
|
||||
"version": "1.23.2",
|
||||
"version": "1.24.0",
|
||||
"minAppVersion": "1.4.13",
|
||||
"description": "Explore your vault in visual format",
|
||||
"author": "DecafDev",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "obsidian-vault-explorer",
|
||||
"version": "1.23.2",
|
||||
"version": "1.24.0",
|
||||
"description": "Explore your vault in visual format",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ export const DEFAULT_SETTINGS: VaultExplorerPluginSettings = {
|
|||
},
|
||||
grid: {
|
||||
isEnabled: true,
|
||||
fetchSocialMediaImage: false,
|
||||
loadSocialMediaImage: false,
|
||||
},
|
||||
list: {
|
||||
isEnabled: true,
|
||||
|
|
|
|||
|
|
@ -18,6 +18,6 @@ export type PluginEvent =
|
|||
| "view-toggle-setting-change"
|
||||
| "file-icons-setting-change"
|
||||
| "filter-groups-wrapping-setting-change"
|
||||
| "fetch-social-media-image-setting-change";
|
||||
| "load-social-media-image-setting-change";
|
||||
|
||||
export type EventCallback = (...data: unknown[]) => void;
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ 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";
|
||||
|
||||
const migrations: TMigration[] = [
|
||||
{
|
||||
|
|
@ -104,6 +105,11 @@ const migrations: TMigration[] = [
|
|||
to: "1.23.1",
|
||||
migrate: Migrate_1_23_1,
|
||||
},
|
||||
{
|
||||
from: "1.23.2",
|
||||
to: "1.24.0",
|
||||
migrate: Migrate_1_24_0,
|
||||
},
|
||||
];
|
||||
|
||||
export const preformMigrations = (
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { VaultExplorerPluginSettings } from "src/types";
|
||||
import MigrationInterface from "./migration_interface";
|
||||
import { VaultExplorerPluginSettings_1_23_0 } from "src/types/types-1.23.0";
|
||||
import { VaultExplorerPluginSettings_1_23_2 } from "src/types/types-1.23.2";
|
||||
|
||||
export default class Migrate_1_23_1 implements MigrationInterface {
|
||||
migrate(data: Record<string, unknown>) {
|
||||
const typedData = data as unknown as VaultExplorerPluginSettings_1_23_0;
|
||||
const newData: VaultExplorerPluginSettings = {
|
||||
const newData: VaultExplorerPluginSettings_1_23_2 = {
|
||||
...typedData,
|
||||
filterGroupsWidth: "100%",
|
||||
};
|
||||
|
|
|
|||
23
src/migrations/migrate_1_24_0.ts
Normal file
23
src/migrations/migrate_1_24_0.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { VaultExplorerPluginSettings } from "src/types";
|
||||
import MigrationInterface from "./migration_interface";
|
||||
import { VaultExplorerPluginSettings_1_23_2 } from "src/types/types-1.23.2";
|
||||
|
||||
export default class Migrate_1_24_0 implements MigrationInterface {
|
||||
migrate(data: Record<string, unknown>) {
|
||||
const typedData = data as unknown as VaultExplorerPluginSettings_1_23_2;
|
||||
const newData: VaultExplorerPluginSettings = {
|
||||
...typedData,
|
||||
views: {
|
||||
...typedData.views,
|
||||
grid: {
|
||||
...typedData.views.grid,
|
||||
loadSocialMediaImage:
|
||||
typedData.views.grid.fetchSocialMediaImage,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
delete (newData as any).views.grid.fetchSocialMediaImage;
|
||||
return newData as unknown as Record<string, unknown>;
|
||||
}
|
||||
}
|
||||
|
|
@ -582,14 +582,14 @@ export default class VaultExplorerSettingsTab extends PluginSettingTab {
|
|||
toggle
|
||||
.setDisabled(!isDeviceRegistered)
|
||||
.setValue(
|
||||
this.plugin.settings.views.grid.fetchSocialMediaImage
|
||||
this.plugin.settings.views.grid.loadSocialMediaImage
|
||||
)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.views.grid.fetchSocialMediaImage =
|
||||
this.plugin.settings.views.grid.loadSocialMediaImage =
|
||||
value;
|
||||
await this.plugin.saveSettings();
|
||||
EventManager.getInstance().emit(
|
||||
"fetch-social-media-image-setting-change"
|
||||
"load-social-media-image-setting-change"
|
||||
);
|
||||
})
|
||||
);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
// let enableScrollButtons: boolean = false;
|
||||
// let renderScrollLeftButton = false;
|
||||
// let renderScrollRightButton = false;
|
||||
let fetchSocialMediaImage = true;
|
||||
let loadSocialMediaImage = true;
|
||||
let isDeviceRegistered = false;
|
||||
|
||||
let plugin: VaultExplorerPlugin;
|
||||
|
|
@ -44,8 +44,7 @@
|
|||
wordBreak = plugin.settings.titleWrapping;
|
||||
// enableScrollButtons = plugin.settings.enableScrollButtons;
|
||||
enableFileIcons = plugin.settings.enableFileIcons;
|
||||
fetchSocialMediaImage =
|
||||
plugin.settings.views.grid.fetchSocialMediaImage;
|
||||
loadSocialMediaImage = plugin.settings.views.grid.loadSocialMediaImage;
|
||||
});
|
||||
|
||||
License.getInstance()
|
||||
|
|
@ -56,7 +55,7 @@
|
|||
|
||||
async function getSocialImageUrl() {
|
||||
if (!isDeviceRegistered) return;
|
||||
if (!fetchSocialMediaImage) return;
|
||||
if (!loadSocialMediaImage) return;
|
||||
if (imageUrl === null && url !== null) {
|
||||
imageUrl = await fetchSocialImage(url);
|
||||
}
|
||||
|
|
@ -66,22 +65,22 @@
|
|||
getSocialImageUrl();
|
||||
});
|
||||
|
||||
$: fetchSocialMediaImage, getSocialImageUrl();
|
||||
$: loadSocialMediaImage, getSocialImageUrl();
|
||||
|
||||
onMount(() => {
|
||||
function handleFetchSocialMediaImageForUrlChange() {
|
||||
fetchSocialMediaImage =
|
||||
plugin.settings.views.grid.fetchSocialMediaImage;
|
||||
function handleLoadSocialMediaImageChange() {
|
||||
loadSocialMediaImage =
|
||||
plugin.settings.views.grid.loadSocialMediaImage;
|
||||
}
|
||||
|
||||
EventManager.getInstance().on(
|
||||
"fetch-social-media-image-setting-change",
|
||||
handleFetchSocialMediaImageForUrlChange,
|
||||
"load-social-media-image-setting-change",
|
||||
handleLoadSocialMediaImageChange,
|
||||
);
|
||||
return () => {
|
||||
EventManager.getInstance().off(
|
||||
"fetch-social-media-image-setting-change",
|
||||
handleFetchSocialMediaImageForUrlChange,
|
||||
"load-social-media-image-setting-change",
|
||||
handleLoadSocialMediaImageChange,
|
||||
);
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@
|
|||
};
|
||||
|
||||
let gridView: TGridView = {
|
||||
fetchSocialMediaImage: false,
|
||||
loadSocialMediaImage: false,
|
||||
isEnabled: false,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -595,7 +595,7 @@ export function isVaultExplorerPluginSettings(obj: unknown): obj is VaultExplore
|
|||
typeof typedObj["views"]["grid"] === "object" ||
|
||||
typeof typedObj["views"]["grid"] === "function") &&
|
||||
typeof typedObj["views"]["grid"]["isEnabled"] === "boolean" &&
|
||||
typeof typedObj["views"]["grid"]["fetchSocialMediaImage"] === "boolean" &&
|
||||
typeof typedObj["views"]["grid"]["loadSocialMediaImage"] === "boolean" &&
|
||||
(typedObj["views"]["list"] !== null &&
|
||||
typeof typedObj["views"]["list"] === "object" ||
|
||||
typeof typedObj["views"]["list"] === "function") &&
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ export interface TTableView extends BaseView {}
|
|||
export interface TListView extends BaseView {}
|
||||
|
||||
export interface TGridView extends BaseView {
|
||||
fetchSocialMediaImage: boolean;
|
||||
loadSocialMediaImage: boolean;
|
||||
}
|
||||
|
||||
export interface TDashboardView extends BaseView {}
|
||||
|
|
|
|||
304
src/types/types-1.23.2.ts
Normal file
304
src/types/types-1.23.2.ts
Normal file
|
|
@ -0,0 +1,304 @@
|
|||
export interface VaultExplorerPluginSettings_1_23_2 {
|
||||
properties: {
|
||||
favorite: string;
|
||||
url: string;
|
||||
imageUrl: 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;
|
||||
currentView: TExplorerView | null;
|
||||
enableScrollButtons: boolean;
|
||||
pageSize: number;
|
||||
filterGroupsWidth: string;
|
||||
filterGroupsWrapping: FlexWrap;
|
||||
pluginVersion: string | null;
|
||||
viewOrder: TExplorerView[];
|
||||
logLevel: string;
|
||||
}
|
||||
|
||||
interface BaseView {
|
||||
isEnabled: boolean;
|
||||
}
|
||||
|
||||
interface TTableView extends BaseView {}
|
||||
|
||||
interface TListView extends BaseView {}
|
||||
|
||||
interface TGridView extends BaseView {
|
||||
fetchSocialMediaImage: boolean;
|
||||
}
|
||||
|
||||
interface TDashboardView extends BaseView {}
|
||||
|
||||
interface TFeedView extends BaseView {}
|
||||
|
||||
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";
|
||||
|
||||
type FlexWrap = "wrap" | "nowrap";
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
@ -88,5 +88,6 @@
|
|||
"1.22.0": "1.4.13",
|
||||
"1.23.0": "1.4.13",
|
||||
"1.23.1": "1.4.13",
|
||||
"1.23.2": "1.4.13"
|
||||
"1.23.2": "1.4.13",
|
||||
"1.24.0": "1.4.13"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue