Page MenuHomePhabricator

Single- and multi-slot editor based on json-editor
Open, Needs TriagePublicFeature

Assigned To
None
Authored By
Simontaurus
Dec 12 2022, 6:11 AM
Referenced Files
F35858883: Multi-Slot-Editor_SlotSchema.PNG
Dec 12 2022, 6:13 AM
F35858881: Multi-Slot-Editor.PNG
Dec 12 2022, 6:13 AM
Restricted File
Dec 12 2022, 6:11 AM
Restricted File
Dec 12 2022, 6:11 AM

Description

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)

Multi-Slot-Editor.PNG (977×1 px, 81 KB)

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

Multi-Slot-Editor_SlotSchema.PNG (1×2 px, 113 KB)

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.

Related Objects

StatusSubtypeAssignedTask
Declineddchen
OpenNone
OpenNone
DuplicateNone
OpenFeatureNone
OpenBUG REPORTNone
OpenNone
StalledNone
OpenFeatureNone
DuplicateNone
ResolvedNone
OpenNone
OpenNone
OpenFeatureNone
OpenNone
ResolvedNone
ResolvedNone
OpenFeatureNone
OpenNone
OpenFeatureNone
StalledNone
OpenNone
OpenNone
OpenNone
Resolveddaniel
OpenNone
ResolvedAnomie
ResolvedAnomie
ResolvedTgr
ResolvedTgr
OpenNone
OpenNone
OpenFeatureNone
OpenNone
Resolveddaniel
Resolveddaniel
InvalidTgr
ResolvedAnomie
ResolvedAnomie
ResolvedPRODUCTION ERRORFunc
OpenFeatureSimontaurus