Skip to content

Instantly share code, notes, and snippets.

@Jinksi
Created February 21, 2018 05:37
Show Gist options
  • Save Jinksi/ffcb76e4040f9c47ff4cd3af69768cfb to your computer and use it in GitHub Desktop.
Save Jinksi/ffcb76e4040f9c47ff4cd3af69768cfb to your computer and use it in GitHub Desktop.
Netlify CMS base64 encode widget
var EncodeControl = createClass({
handleChange: function (e) {
this.props.onChange(btoa(e.target.value.trim()))
},
render: function () {
var value = this.props.value ? atob(this.props.value) : ''
return h('input', {
type: 'text',
value: value,
onChange: this.handleChange,
className: 'nc-controlPane-widget'
})
}
})
CMS.registerWidget('encode', EncodeControl)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment