From 0e13a3783f2166d32649806ea5352f0fbc4e0221 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Thu, 23 Sep 2021 08:41:09 +0200 Subject: [PATCH 1/8] Better notification --- src/helpers/Extension.ts | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/helpers/Extension.ts b/src/helpers/Extension.ts index 2f5f0e93..f9a3ade2 100644 --- a/src/helpers/Extension.ts +++ b/src/helpers/Extension.ts @@ -1,7 +1,7 @@ import { basename } from "path"; -import { extensions, Uri, ExtensionContext } from "vscode"; +import { extensions, Uri, ExtensionContext, window, workspace, commands } from "vscode"; import { Folders, WORKSPACE_PLACEHOLDER } from "../commands/Folders"; -import { SETTINGS_CONTENT_FOLDERS, SETTINGS_CONTENT_PAGE_FOLDERS, SETTING_DATE_FIELD, SETTING_MODIFIED_FIELD, SETTING_SEO_DESCRIPTION_FIELD, SETTING_TAXONOMY_CONTENT_TYPES } from "../constants"; +import { EXTENSION_NAME, SETTINGS_CONTENT_FOLDERS, SETTINGS_CONTENT_PAGE_FOLDERS, SETTING_DATE_FIELD, SETTING_MODIFIED_FIELD, SETTING_SEO_DESCRIPTION_FIELD, SETTING_TAXONOMY_CONTENT_TYPES } from "../constants"; import { DEFAULT_CONTENT_TYPE_NAME } from "../constants/ContentType"; import { EXTENSION_BETA_ID, EXTENSION_ID, EXTENSION_STATE_VERSION } from "../constants/Extension"; import { ContentType } from "../models"; @@ -39,7 +39,23 @@ export class Extension { } if (usedVersion !== installedVersion) { - Notifications.info(`Find out what is new at [v${installedVersion} release notes](https://${this.isBetaVersion() ? 'beta.' : ''}frontmatter.codes/updates)`); + const whatIsNewTitle = `Check the changelog`; + const whatIsNew = { + title: whatIsNewTitle, + run: () => { + const uri = Uri.file(`${Extension.getInstance().extensionPath.fsPath}/CHANGELOG.md`); + workspace.openTextDocument(uri).then((() => { + commands.executeCommand("markdown.showPreview", uri) + })); + } + }; + + window.showInformationMessage(`${EXTENSION_NAME} has been updated to v${installedVersion} — check out what's new!`, whatIsNew).then((selection => { + if (selection?.title === whatIsNewTitle) { + selection.run(); + } + })); + this.setVersion(installedVersion); } From 12d816b761b06f4f150c9b6330be3393967c63b2 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Fri, 24 Sep 2021 08:45:45 +0200 Subject: [PATCH 2/8] #114 - Empty array fix + empty data --- src/explorerView/ExplorerView.ts | 4 +++- src/panelWebView/components/TagPicker.tsx | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/explorerView/ExplorerView.ts b/src/explorerView/ExplorerView.ts index 30ecfa11..3f2a4ab3 100644 --- a/src/explorerView/ExplorerView.ts +++ b/src/explorerView/ExplorerView.ts @@ -433,7 +433,9 @@ export class ExplorerView implements WebviewViewProvider, Disposable { } const article = ArticleHelper.getFrontMatter(editor); - this.pushMetadata(article!.data); + if (article?.data) { + this.pushMetadata(article!.data); + } } /** diff --git a/src/panelWebView/components/TagPicker.tsx b/src/panelWebView/components/TagPicker.tsx index 877515e5..19b254e6 100644 --- a/src/panelWebView/components/TagPicker.tsx +++ b/src/panelWebView/components/TagPicker.tsx @@ -186,7 +186,12 @@ export const TagPicker: React.FunctionComponent = (props: React } - a.toLowerCase() < b.toLowerCase() ? -1 : 1 )} onRemove={onRemove} onCreate={onCreate} options={options} disableConfigurable={!!disableConfigurable} /> + a.toLowerCase() < b.toLowerCase() ? -1 : 1 )} + onRemove={onRemove} + onCreate={onCreate} + options={options} + disableConfigurable={!!disableConfigurable} /> ); }; \ No newline at end of file From 24f69ea8197ee5ce3493bff70cdf8dea53a11dab Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Fri, 24 Sep 2021 10:03:47 +0200 Subject: [PATCH 3/8] Adding start --- src/helpers/Extension.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/helpers/Extension.ts b/src/helpers/Extension.ts index f9a3ade2..c2c472ae 100644 --- a/src/helpers/Extension.ts +++ b/src/helpers/Extension.ts @@ -1,7 +1,7 @@ import { basename } from "path"; import { extensions, Uri, ExtensionContext, window, workspace, commands } from "vscode"; import { Folders, WORKSPACE_PLACEHOLDER } from "../commands/Folders"; -import { EXTENSION_NAME, SETTINGS_CONTENT_FOLDERS, SETTINGS_CONTENT_PAGE_FOLDERS, SETTING_DATE_FIELD, SETTING_MODIFIED_FIELD, SETTING_SEO_DESCRIPTION_FIELD, SETTING_TAXONOMY_CONTENT_TYPES } from "../constants"; +import { EXTENSION_NAME, GITHUB_LINK, SETTINGS_CONTENT_FOLDERS, SETTINGS_CONTENT_PAGE_FOLDERS, SETTING_DATE_FIELD, SETTING_MODIFIED_FIELD, SETTING_SEO_DESCRIPTION_FIELD, SETTING_TAXONOMY_CONTENT_TYPES } from "../constants"; import { DEFAULT_CONTENT_TYPE_NAME } from "../constants/ContentType"; import { EXTENSION_BETA_ID, EXTENSION_ID, EXTENSION_STATE_VERSION } from "../constants/Extension"; import { ContentType } from "../models"; @@ -38,8 +38,10 @@ export class Extension { installedVersion = `${installedVersion}-beta`; } - if (usedVersion !== installedVersion) { + if (usedVersion !== installedVersion + 1) { const whatIsNewTitle = `Check the changelog`; + const githubTitle = `Give it a ⭐️`; + const whatIsNew = { title: whatIsNewTitle, run: () => { @@ -50,8 +52,15 @@ export class Extension { } }; - window.showInformationMessage(`${EXTENSION_NAME} has been updated to v${installedVersion} — check out what's new!`, whatIsNew).then((selection => { - if (selection?.title === whatIsNewTitle) { + const starGitHub = { + title: githubTitle, + run: () => { + commands.executeCommand('vscode.open', Uri.parse(GITHUB_LINK)); + } + }; + + window.showInformationMessage(`${EXTENSION_NAME} has been updated to v${installedVersion} — check out what's new!`, starGitHub, whatIsNew).then((selection => { + if (selection?.title === whatIsNewTitle || selection?.title === githubTitle) { selection.run(); } })); From a523c4ab63aee49026b3c7738009dbd9db878077 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Fri, 24 Sep 2021 10:07:15 +0200 Subject: [PATCH 4/8] #114 - Fix for category/tag provides as string --- src/panelWebView/components/TagPicker.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/panelWebView/components/TagPicker.tsx b/src/panelWebView/components/TagPicker.tsx index 19b254e6..2afdba20 100644 --- a/src/panelWebView/components/TagPicker.tsx +++ b/src/panelWebView/components/TagPicker.tsx @@ -123,7 +123,7 @@ export const TagPicker: React.FunctionComponent = (props: React React.useEffect(() => { if (prevSelected !== crntSelected) { - setSelected(crntSelected); + setSelected(typeof crntSelected === "string" ? [crntSelected] : crntSelected); } }, [crntSelected]); From 3260c2b3e0459bb9924737a1008a6d1bd75a7683 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Fri, 24 Sep 2021 10:11:38 +0200 Subject: [PATCH 5/8] Updated changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8b7a48a..3d6db454 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## [4.0.1] - 2021-09-24 + +- [#114](https://github.com/estruyf/vscode-front-matter/issues/114): Fix for categories/tags provided as string in YAML + ## [4.0.0] - 2021-09-22 - [Release Notes](https://beta.frontmatter.codes/updates/v4_0_0) - [#101](https://github.com/estruyf/vscode-front-matter/issues/101): Date picker available on the metadata section From 71c03605231ed127145985447c1f609653465385 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Fri, 24 Sep 2021 10:14:52 +0200 Subject: [PATCH 6/8] Remove +1 --- src/helpers/Extension.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/Extension.ts b/src/helpers/Extension.ts index c2c472ae..6a5ef072 100644 --- a/src/helpers/Extension.ts +++ b/src/helpers/Extension.ts @@ -38,7 +38,7 @@ export class Extension { installedVersion = `${installedVersion}-beta`; } - if (usedVersion !== installedVersion + 1) { + if (usedVersion !== installedVersion) { const whatIsNewTitle = `Check the changelog`; const githubTitle = `Give it a ⭐️`; From d8bffdcf6cfb239c3a249136d83d86b657e8fbc6 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Fri, 24 Sep 2021 10:24:33 +0200 Subject: [PATCH 7/8] #115 - Fix for updating added categories/tags --- CHANGELOG.md | 1 + src/helpers/SettingsHelper.ts | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d6db454..2e68dc04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## [4.0.1] - 2021-09-24 - [#114](https://github.com/estruyf/vscode-front-matter/issues/114): Fix for categories/tags provided as string in YAML +- [#115](https://github.com/estruyf/vscode-front-matter/issues/115): Fix for updating added categories/tags ## [4.0.0] - 2021-09-22 - [Release Notes](https://beta.frontmatter.codes/updates/v4_0_0) diff --git a/src/helpers/SettingsHelper.ts b/src/helpers/SettingsHelper.ts index 2c328535..cdabfc6b 100644 --- a/src/helpers/SettingsHelper.ts +++ b/src/helpers/SettingsHelper.ts @@ -5,7 +5,7 @@ import { TaxonomyType } from '../models'; import { SETTING_TAXONOMY_TAGS, SETTING_TAXONOMY_CATEGORIES, CONFIG_KEY } from '../constants'; import { Folders } from '../commands/Folders'; import { join, basename } from 'path'; -import { existsSync, readFileSync, writeFileSync } from 'fs'; +import { existsSync, readFileSync, watch, writeFileSync } from 'fs'; import { Extension } from './Extension'; export class Settings { @@ -38,12 +38,22 @@ export class Settings { * @param callback */ public static onConfigChange(callback: (global?: any) => void) { + const projectConfig = Settings.projectConfigPath; + workspace.onDidChangeConfiguration(() => { callback(); }); + // Background listener for when it is not a user interaction + if (projectConfig && existsSync(projectConfig)) { + watch(projectConfig, () => { + callback(); + }); + } + workspace.onDidSaveTextDocument(async (e) => { const filename = e.uri.fsPath; + if (Settings.checkProjectConfig(filename)) { const file = await workspace.openTextDocument(e.uri); if (file) { From b8f5e10f4bd7b721f1cb0589bc92dc7cba2aa736 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Fri, 24 Sep 2021 10:27:49 +0200 Subject: [PATCH 8/8] #116 - Fix for not showing the `-1` limit on inputs --- CHANGELOG.md | 1 + src/panelWebView/components/Fields/TextField.tsx | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e68dc04..f1986bd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - [#114](https://github.com/estruyf/vscode-front-matter/issues/114): Fix for categories/tags provided as string in YAML - [#115](https://github.com/estruyf/vscode-front-matter/issues/115): Fix for updating added categories/tags +- [#116](https://github.com/estruyf/vscode-front-matter/issues/116): Fix for not showing the `-1` limit on inputs ## [4.0.0] - 2021-09-22 - [Release Notes](https://beta.frontmatter.codes/updates/v4_0_0) diff --git a/src/panelWebView/components/Fields/TextField.tsx b/src/panelWebView/components/Fields/TextField.tsx index 8339e301..5a1ea116 100644 --- a/src/panelWebView/components/Fields/TextField.tsx +++ b/src/panelWebView/components/Fields/TextField.tsx @@ -26,7 +26,7 @@ export const TextField: React.FunctionComponent = ({limit, labe let isValid = true; if (limit && limit !== -1) { - isValid = ((text || "").length < limit); + isValid = ((text || "").length <= limit); } return ( @@ -46,7 +46,7 @@ export const TextField: React.FunctionComponent = ({limit, labe }} /> { - limit && (text || "").length >= limit && ( + limit && limit > 0 && (text || "").length > limit && (
Field limit reached {(text || "").length}/{limit}