Note: The default ITS GitLab runner is a shared resource and is subject to slowdowns during heavy usage.
You can run your own GitLab runner that is dedicated just to your group if you need to avoid processing delays.

Commit 8678d145 authored by Seth A Johnson's avatar Seth A Johnson
Browse files

Add Widget that allows linking to a file in the Media Gallery,

such as a PDF, from the markdown body
parent c9201eb2
import CMS from 'netlify-cms-app';
import LinkFileComponent from "./components/linkFileComponent"
CMS.registerEditorComponent(LinkFileComponent);
CMS.init();
const LinkFileComponent = {
// Widget that allows linking to a file in the Media Gallery,
// such as a PDF, from the markdown body
id: "LinkFile",
label: "Link File",
fields: [
{name: 'text', label: 'Link Text', widget: 'string'},
{name: 'file', label: 'File', widget: 'file' }
],
pattern: /^<a href="(.*)">(.*)<\/a>$/,
fromBlock: function(match) {
return {
file: match[1],
text: match[2]
};
},
toBlock: function({file, text}) {
return `<a href="${file}">${text}</a>`
},
toPreview: function({file, text}) {
return `<a href="${file}">${text}</a>`
}
}
export default LinkFileComponent
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment