diff --git a/CHANGELOG.md b/CHANGELOG.md index f8b7a48a..f1986bd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # 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 +- [#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) - [#101](https://github.com/estruyf/vscode-front-matter/issues/101): Date picker available on the metadata section 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/helpers/Extension.ts b/src/helpers/Extension.ts index 2f5f0e93..6a5ef072 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, 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"; @@ -39,7 +39,32 @@ 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 githubTitle = `Give it a ⭐️`; + + const whatIsNew = { + title: whatIsNewTitle, + run: () => { + const uri = Uri.file(`${Extension.getInstance().extensionPath.fsPath}/CHANGELOG.md`); + workspace.openTextDocument(uri).then((() => { + commands.executeCommand("markdown.showPreview", uri) + })); + } + }; + + 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(); + } + })); + this.setVersion(installedVersion); } 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) { 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}
diff --git a/src/panelWebView/components/TagPicker.tsx b/src/panelWebView/components/TagPicker.tsx index 877515e5..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]); @@ -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