mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-08-06 17:02:54 +02:00
#176 - Extra setting updates
This commit is contained in:
+18
-2
@@ -701,7 +701,18 @@
|
||||
"fields": {
|
||||
"$ref": "#contenttypefield"
|
||||
},
|
||||
"blockType": {
|
||||
"fieldGroup": {
|
||||
"type": [
|
||||
"string",
|
||||
"array"
|
||||
],
|
||||
"default": [],
|
||||
"description": "The ID(s) of your field group(s) defined in the `frontMatter.taxonomy.fieldGroups` setting",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"dataType": {
|
||||
"type": [
|
||||
"string",
|
||||
"array"
|
||||
@@ -711,6 +722,11 @@
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"taxonomyLimit": {
|
||||
"type": "number",
|
||||
"default": 0,
|
||||
"description": "Limit the number of taxonomies to select. Set to 0 to allow unlimited."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
@@ -771,7 +787,7 @@
|
||||
},
|
||||
"then": {
|
||||
"required": [
|
||||
"blockType"
|
||||
"fieldGroup"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
@@ -64,6 +64,7 @@ export interface Field {
|
||||
fields?: Field[];
|
||||
fieldGroup?: string | string[];
|
||||
dataType?: string | string[];
|
||||
taxonomyLimit?: number | string[];
|
||||
}
|
||||
|
||||
export interface DateInfo {
|
||||
|
||||
@@ -70,7 +70,6 @@ export const WrapperField: React.FunctionComponent<IWrapperFieldProps> = ({
|
||||
|
||||
useEffect(() => {
|
||||
let value: any = parent[field.name];
|
||||
let shouldSetField = false;
|
||||
|
||||
if (field.type === 'datetime') {
|
||||
value = getDate(value) || undefined;
|
||||
@@ -88,8 +87,6 @@ export const WrapperField: React.FunctionComponent<IWrapperFieldProps> = ({
|
||||
if (field.type === "tags" || field.type === "categories" || field.type === "taxonomy") {
|
||||
value = [];
|
||||
}
|
||||
|
||||
shouldSetField = true;
|
||||
}
|
||||
|
||||
// Check if the field value contains a placeholder
|
||||
@@ -211,7 +208,8 @@ export const WrapperField: React.FunctionComponent<IWrapperFieldProps> = ({
|
||||
focussed={focusElm === TagType.tags}
|
||||
unsetFocus={unsetFocus}
|
||||
parents={parentFields}
|
||||
blockData={blockData} />
|
||||
blockData={blockData}
|
||||
limit={field.taxonomyLimit} />
|
||||
</FieldBoundary>
|
||||
);
|
||||
} else if (field.type === 'taxonomy') {
|
||||
@@ -231,31 +229,25 @@ export const WrapperField: React.FunctionComponent<IWrapperFieldProps> = ({
|
||||
fieldName={field.name}
|
||||
taxonomyId={field.taxonomyId}
|
||||
parents={parentFields}
|
||||
blockData={blockData} />
|
||||
blockData={blockData}
|
||||
limit={field.taxonomyLimit} />
|
||||
</FieldBoundary>
|
||||
);
|
||||
} else if (field.type === 'categories') {
|
||||
let selectedValues = parent[field.name];
|
||||
if (!selectedValues && typeof parent[field.name] === "undefined" && field.default) {
|
||||
selectedValues = field.default;
|
||||
onSendUpdate(field.name, selectedValues, parentFields);
|
||||
} else {
|
||||
selectedValues = [];
|
||||
}
|
||||
|
||||
return (
|
||||
<FieldBoundary key={field.name} fieldName={field.title || field.name}>
|
||||
<TagPicker
|
||||
type={TagType.categories}
|
||||
label={field.title || field.name}
|
||||
icon={<ListUnorderedIcon />}
|
||||
crntSelected={selectedValues as string[] || []}
|
||||
crntSelected={fieldValue as string[] || []}
|
||||
options={settings.categories}
|
||||
freeform={settings.freeform || false}
|
||||
focussed={focusElm === TagType.categories}
|
||||
unsetFocus={unsetFocus}
|
||||
parents={parentFields}
|
||||
blockData={blockData} />
|
||||
blockData={blockData}
|
||||
limit={field.taxonomyLimit} />
|
||||
</FieldBoundary>
|
||||
);
|
||||
} else if (field.type === 'draft') {
|
||||
|
||||
Reference in New Issue
Block a user