decap-cms
decap-cms copied to clipboard
registerEditorComponent: Named capture groups in pattern cause console warning.
Describe the bug
Using named capture groups in the registerEditorComponent pattern field causes a warning. I think this is because match[0] doesn't exist? Example of my code and the error:
CMS.registerEditorComponent({
id: "image",
label: "Afbeelding",
fields: [{
name: "caption",
label: "Onderschrift",
widget: "string",
},
{
name: "license",
label: "Licentie",
widget: "string",
required: false,
}],
pattern: /^{{< image\n?(?:\scaption="(?<caption>.+)")\n?(?:\slicense="(?<license>.+)")?\s?>}}/,
fromBlock: (match) => {
return {
caption: match.groups.caption,
license: match.groups.license,
};
},
toBlock: (obj) => {
return `{{< image caption="${obj.caption}" >}}`;
},
});
Sent invalid data to remark. Plugin: image. Value: {{< image caption="Characters and Caricaturas door William Hogarth.a" >}}. Data: {"caption":"Characters and Caricaturas door William Hogarth.a"}
Applicable Versions:
- Netlify CMS version: 2.15.72
- Git provider: Github
- OS: Alpine Linux
- Browser version: Safari
Hmm maybe this is not the fault of named capture groups but rather something akin to this: https://github.com/netlify/netlify-cms/issues/4895
Closing as duplicate of #4895