Closed odf closed 9 years ago
On general level it could be handy if it was possible to implement custom types and renderers for them. Maybe this is possible already.
Yes, it's possible to define per-field custom handlers, and one can also abstract the necessary boilerplate using JSON-Schema's references. I've found that this works really nicely for things like file uploads. So I think I'll probably rip out the built-in file upload mechanism and update the example code to use a simple custom handler for uploading files.
Cool. That sounds like a good idea.
I guess you could push each type/renderer pair out of core into separate modules if you wanted to. That would improve the structure of the project but you would need to setup a build.
I agree that it could be useful to separate those out.
Do you want me to give it a go?
I would set up a build using Webpack. There would be extra step before publishing a release (need to update the dist version, i guess there's a prepublish
hook to achieve the same but then the dist won't be at repo, just NPM).
Sure, knock yourself out! I already have a Webpack-based setup for a library that needs a build step here: https://github.com/AppliedMathematicsANU/plexus-csp. I'll probably switch that over from Regenerator to Babel the next time I use it, since I'm fairly keen to start using ES6 goodies. I usually don't put the compiled code into the repo, but I'm not fundamentally opposed to it.
I'd really like to deprecate the build-in file uploader soon and maybe put example code for a very simple user-defined uploader into the documentation. Any objections?
Nope, sounds good!
Done! I've added a deprecation warning when this feature is used, removed the file upload part from the demo and changed the user-defined input component example in the readme from a mouse position tracer to a (very simplistic) file uploader. I reckon I'll leave the file field code in for v0.1.1, just in case, and remove it in v0.1.2.
I am not too happy with the way file uploads currently work, especially the fact that
FileField
instances need to callmakeFieldset
and the haphazard mix of user-defined and implied properties for upload elements. Maybe it would be cleaner to have a separate element typex-upload
(prefixed because it is not part of json-schema) that is treated like a primitive type.