Feature summary:
json-editor is a nice javascript lib to create html forms from json-schema.
Due to its flexibility, it can be used to edit arbitrary content.
For a multi-slot editor, for example, a schema can be automatically generated from the content models (properties = slots)
{ "title": <page-title>, "type": "object", "properties": { "main": { "type": "string", "format": "visualeditor"}, "jsondata": { "type": "string", "format": "json"} } }
which renders as (wikitext => VEForAll, json=> CodeEditor/ace)
If a slot with content-model json is provided with a particular json-schema (e. g. stored under MediaWiki:Slot-jsonschema-<slot-name>.json) json-editor would automatical render an appropriate sub-editor which can be uses also as a stand-alone version:
Example slot-schema for slot "jsondata"
{ "title": "jsondata", "type": "object", "properties": { "str-property": { "type": "string"}, "int-proptery": { "type": "integer", "format": "number"}, "obj-array-property": { "type": "array", "format": "table", "items": { "$ref": "#"} } } }
with auto-generated slot-schema
{ "title": <page-title>, "type": "object", "properties": { "main": { "type": "string", "format": "visualeditor"}, "jsondata": { "$ref": "/wiki/MediaWiki:Slot-jsonschema-jsondata.json?action=raw" } } }
renders as
Of course, this could also be extended to slots with binary data (e. g. images => render upload button or drawing area)
I've already started some work here (alpha-status!), but it would be interesting to know whether this approach is of general interest.
Use case(s):
There is a general need to visually edit slot content regardless of its content model. As far as I know, there is no concrete solution available yet.
Benefits:
The approach chosen is generic and independent of the content model. It can also be built on established standards (jsonschema) and an existing code base (json-editor). The manual creation of specific forms and validation of the input is no longer necessary.