Merge branch 'dev'

This commit is contained in:
Elio Struyf
2021-09-24 10:35:47 +02:00
6 changed files with 57 additions and 9 deletions
+6
View File
@@ -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
+3 -1
View File
@@ -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);
}
}
/**
+28 -3
View File
@@ -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);
}
+11 -1
View File
@@ -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) {
@@ -26,7 +26,7 @@ export const TextField: React.FunctionComponent<ITextFieldProps> = ({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<ITextFieldProps> = ({limit, labe
}} />
{
limit && (text || "").length >= limit && (
limit && limit > 0 && (text || "").length > limit && (
<div className={`metadata_field__limit`}>
Field limit reached {(text || "").length}/{limit}
</div>
+7 -2
View File
@@ -123,7 +123,7 @@ export const TagPicker: React.FunctionComponent<ITagPickerProps> = (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<ITagPickerProps> = (props: React
}
</Downshift>
<Tags values={selected.sort((a: string, b: string) => a.toLowerCase() < b.toLowerCase() ? -1 : 1 )} onRemove={onRemove} onCreate={onCreate} options={options} disableConfigurable={!!disableConfigurable} />
<Tags
values={(selected || []).sort((a: string, b: string) => a.toLowerCase() < b.toLowerCase() ? -1 : 1 )}
onRemove={onRemove}
onCreate={onCreate}
options={options}
disableConfigurable={!!disableConfigurable} />
</div>
);
};