diff --git a/.github/workflows/check-console-log.yml b/.github/workflows/check-console-log.yml new file mode 100644 index 0000000..34b7eb9 --- /dev/null +++ b/.github/workflows/check-console-log.yml @@ -0,0 +1,20 @@ +name: Check Console Log + +on: pull_request + +jobs: + check_console_log: + runs-on: ubuntu-latest + steps: + - name: checkout code + uses: actions/checkout@v3 + + - name: Run console.log check + run: | + found=$(find src/ -type f ! -name "main.ts" ! -path "*/migrations/index.ts" | xargs grep "console.log" || true) + if [ -n "$found" ]; then + echo "console.log found in the following files:" + echo "$found" + exit 1 + fi + echo "No console.log statements found!" diff --git a/manifest.json b/manifest.json index c739319..673281e 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "vault-explorer", "name": "Vault Explorer", - "version": "1.41.0", + "version": "1.41.1", "minAppVersion": "1.4.13", "description": "Explore your vault in visual format", "author": "DecafDev", diff --git a/package.json b/package.json index fbd593c..e730b76 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-vault-explorer", - "version": "1.41.0", + "version": "1.41.1", "description": "Explore your vault in visual format", "main": "main.js", "scripts": { diff --git a/src/obsidian/vault-explorer-settings-tab.ts b/src/obsidian/vault-explorer-settings-tab.ts index 8b779c2..a2024d3 100644 --- a/src/obsidian/vault-explorer-settings-tab.ts +++ b/src/obsidian/vault-explorer-settings-tab.ts @@ -1,4 +1,4 @@ -import { App, PluginSettingTab, Setting } from "obsidian"; +import { App, PluginSettingTab, Setting, SliderComponent } from "obsidian"; import VaultExplorerPlugin from "src/main"; import { getDropdownOptionsForProperties, @@ -386,59 +386,107 @@ export default class VaultExplorerSettingsTab extends PluginSettingTab { }) ); + let largeScreenLineClampSlider: SliderComponent | null = null; new Setting(containerEl) .setName("Large screen line clamp") .setDesc( - "Number of lines to clamp on large screens (>= 1024px). (2-8, default 5)" + "Number of lines to clamp on large screens (>= 1024px) (2-8, default 5)" ) - .addSlider((component) => - component + .addExtraButton((button) => + button + .setIcon("reset") + .setTooltip("Restore default") + .onClick(async () => { + this.plugin.settings.views.feed.lineClampLarge = 5; + largeScreenLineClampSlider?.setValue(5); + await this.plugin.saveSettings(); + EventManager.getInstance().emit( + PluginEvent.FEED_CONTENT_SETTING_CHANGE + ); + }) + ) + .addSlider((component) => { + largeScreenLineClampSlider = component; + return component .setValue(this.plugin.settings.views.feed.lineClampLarge) .setLimits(2, 8, 1) + .setDynamicTooltip() .onChange(async (value) => { this.plugin.settings.views.feed.lineClampLarge = value; await this.plugin.saveSettings(); EventManager.getInstance().emit( PluginEvent.FEED_CONTENT_SETTING_CHANGE ); - }) - ); + }); + }); + let mediumScreenLineClampSlider: SliderComponent | null = null; new Setting(containerEl) .setName("Medium screen line clamp") .setDesc( - "Number of lines to clamp on medium screens (>= 600px and < 1024px). (2-8, default 3)" + "Number of lines to clamp on medium screens (>= 600px and < 1024px) (2-8, default 3)" ) - .addSlider((component) => - component + .addExtraButton((button) => + button + .setIcon("reset") + .setTooltip("Restore default") + .onClick(async () => { + this.plugin.settings.views.feed.lineClampLarge = 3; + mediumScreenLineClampSlider?.setValue(3); + await this.plugin.saveSettings(); + EventManager.getInstance().emit( + PluginEvent.FEED_CONTENT_SETTING_CHANGE + ); + }) + ) + .addSlider((component) => { + mediumScreenLineClampSlider = component; + return component .setValue(this.plugin.settings.views.feed.lineClampMedium) .setLimits(2, 8, 1) + .setDynamicTooltip() .onChange(async (value) => { this.plugin.settings.views.feed.lineClampMedium = value; await this.plugin.saveSettings(); EventManager.getInstance().emit( PluginEvent.FEED_CONTENT_SETTING_CHANGE ); - }) - ); + }); + }); + let smallScreenLineClampSlider: SliderComponent | null = null; new Setting(containerEl) .setName("Small screen line clamp") .setDesc( - "Number of lines to clamp on small screens (< 600px). (2-8, default 2)" + "Number of lines to clamp on small screens (< 600px) (2-8, default 2)" ) - .addSlider((component) => - component + .addExtraButton((button) => + button + .setIcon("reset") + .setTooltip("Restore default") + .onClick(async () => { + this.plugin.settings.views.feed.lineClampLarge = 2; + smallScreenLineClampSlider?.setValue(2); + await this.plugin.saveSettings(); + EventManager.getInstance().emit( + PluginEvent.FEED_CONTENT_SETTING_CHANGE + ); + }) + ) + .addSlider((component) => { + smallScreenLineClampSlider = component; + return component .setValue(this.plugin.settings.views.feed.lineClampSmall) .setLimits(2, 8, 1) + .setDynamicTooltip() .onChange(async (value) => { this.plugin.settings.views.feed.lineClampSmall = value; await this.plugin.saveSettings(); EventManager.getInstance().emit( PluginEvent.FEED_CONTENT_SETTING_CHANGE ); - }) - ); + }); + }); new Setting(containerEl).setName("Built-in properties").setHeading(); diff --git a/src/svelte/app/index.svelte b/src/svelte/app/index.svelte index 23118d6..36a8bfe 100644 --- a/src/svelte/app/index.svelte +++ b/src/svelte/app/index.svelte @@ -790,8 +790,6 @@ value: CoverImageFit; }; - console.log(filePath, value); - const { properties } = plugin.settings; const { coverImageFit: coverImageFitProperty } = properties; @@ -897,11 +895,7 @@ ) { formatted = filteredCustom.map((loadedFile) => { const { id, file } = loadedFile; - const frontmatter = - plugin.app.metadataCache.getFileCache(file)?.frontmatter; - const isFavorite = favoritesCache.get(file.path) ?? null; - const content = contentCache.get(file.path) ?? null; return formatFileDataForRender({ @@ -909,7 +903,6 @@ settings: plugin.settings, fileId: id, file, - fileFrontmatter: frontmatter, fileContent: content, fileFavorite: isFavorite, }); diff --git a/src/svelte/app/services/render-data.ts b/src/svelte/app/services/render-data.ts index 2cb015f..f468d08 100644 --- a/src/svelte/app/services/render-data.ts +++ b/src/svelte/app/services/render-data.ts @@ -45,7 +45,6 @@ export const formatFileDataForRender = ({ settings, file, fileId, - fileFrontmatter, fileContent, fileFavorite, }: { @@ -53,12 +52,13 @@ export const formatFileDataForRender = ({ settings: VaultExplorerPluginSettings; file: TFile; fileId: string; - fileFrontmatter: FrontMatterCache | undefined; fileContent: string | null; fileFavorite: boolean | null; }): FileRenderData => { const { name, basename, extension, path } = file; + const fileFrontmatter = app.metadataCache.getFileCache(file)?.frontmatter; + const { loadBodyTags } = settings; const { coverImageSources } = settings.views.grid; const { @@ -78,15 +78,14 @@ export const formatFileDataForRender = ({ "tags", PropertyType.LIST ); - if (fileContent && loadBodyTags) { - const body = removeFrontmatter(fileContent); - const TAG_REGEX = /#\w+(\/\w+)*/g; - const bodyTags = body.match(TAG_REGEX); + + if (loadBodyTags) { + const bodyTags = app.metadataCache.getFileCache(file)?.tags; //Keep the tags array null if there are no tags in the frontmatter or body - if (bodyTags !== null && bodyTags.length > 0) { + if (bodyTags) { //Remove the hash from the tags - const tagsWithoutHash = bodyTags.map((tag) => tag.slice(1)); + const tagsWithoutHash = bodyTags.map((t) => t.tag.slice(1)); tags = Array.from(new Set([...(tags ?? []), ...tagsWithoutHash])); } } diff --git a/test-vault/.obsidian/core-plugins-migration.json b/test-vault/.obsidian/core-plugins-migration.json index 1788030..32ca11c 100644 --- a/test-vault/.obsidian/core-plugins-migration.json +++ b/test-vault/.obsidian/core-plugins-migration.json @@ -7,7 +7,7 @@ "canvas": true, "outgoing-link": true, "tag-pane": true, - "properties": false, + "properties": true, "page-preview": true, "daily-notes": false, "templates": false, diff --git a/test-vault/.obsidian/core-plugins.json b/test-vault/.obsidian/core-plugins.json index 4cdd59a..cc7214c 100644 --- a/test-vault/.obsidian/core-plugins.json +++ b/test-vault/.obsidian/core-plugins.json @@ -7,6 +7,7 @@ "canvas", "outgoing-link", "tag-pane", + "properties", "page-preview", "note-composer", "command-palette", diff --git a/test-vault/.obsidian/plugins/vault-explorer/data.json b/test-vault/.obsidian/plugins/vault-explorer/data.json index d4e779c..4be5278 100644 --- a/test-vault/.obsidian/plugins/vault-explorer/data.json +++ b/test-vault/.obsidian/plugins/vault-explorer/data.json @@ -8,7 +8,8 @@ "creationDate": "creation", "modifiedDate": "modification", "createdDate": "creation", - "image": "image" + "image": "image", + "coverImageFit": "" }, "filters": { "search": { @@ -60,7 +61,8 @@ "type": "body", "isEnabled": true } - ] + ], + "coverImageFit": "cover" }, "list": { "isEnabled": true, @@ -103,6 +105,6 @@ "feed" ], "configDir": ".vaultexplorer", - "pluginVersion": "1.40.0", + "pluginVersion": "1.41.0", "logLevel": "trace" } \ No newline at end of file diff --git a/test-vault/Frontmatter tags with body tags.md b/test-vault/Frontmatter tags with body tags.md index 7b25dfb..44c5684 100644 --- a/test-vault/Frontmatter tags with body tags.md +++ b/test-vault/Frontmatter tags with body tags.md @@ -1,10 +1,11 @@ --- tags: - - tag1 - - tag2 - - tag3 + - tag1 + - tag2 + - tag3 --- -#tag4 + +#tag4 Some text #tag5 @@ -12,4 +13,6 @@ Some text #tag5 This is some text #tag6 -#tag/subtag \ No newline at end of file +#tag/subtag + +#1111 diff --git a/versions.json b/versions.json index 44ff2df..4566abc 100644 --- a/versions.json +++ b/versions.json @@ -135,5 +135,6 @@ "1.40.0": "1.4.13", "1.40.1": "1.4.13", "1.40.2": "1.4.13", - "1.41.0": "1.4.13" + "1.41.0": "1.4.13", + "1.41.1": "1.4.13" }