UNPKG

custom-code-editor-a3

Version:
28 lines (25 loc) 717 B
module.exports = function(self) { return { addCodeFieldType() { self.apos.schema.addFieldType({ name: 'custom-code-editor-a3', convert: self.convertInput, vueComponent: 'CustomCodeEditor' }); }, async convertInput(req, field, data, object) { const input = data[field.name]; if (!data[field.name]) { if (field.required) { throw self.apos.error('notfound', 'Field for \'' + field.name + '\' is required'); } object[field.name] = null; } else { object[field.name] = { code: self.apos.launder.string(input.code), type: self.apos.launder.string(input.type) }; } } }; };