Skip to content

Editor class

As a minimum the editor class needs the following parameters on initialization:

  1. A binding from the RDForms engine
  2. The HTML node where the editor will be inserted.

The Editor can also construct the binding itself by providing:

  1. An RDF graph to edit
  2. The resource to edit in the RDF graph
  3. The template to use when editing

The latter is the common approach, as examplified below:

const editor = new rdforms.Editor({
    resource,
    graph,
    template,
    compact: false ,
    includeLevel: 'recommended'
  },
  'rdformsEditorAnchor');

See the Nobel example for an illustration on how the different parameters can be initialized as well as how to provide the scaffolding around with html and loading the rdforms library.

The Editors constructor takes only two parameters, the first constructor parameter is an object containing all parameters except the HTML node which is provided as the second constructor parameter.

parameter type comment
resource String (a URI) The editor will edit triples starting from this resource according the template
graph rdfjson/Graph The RDF graph to edit, the Editor will match existing triples and delete, modify or create new according to the template and the user input.
template rdforms/template/Item The template, a top level group item, describes the RDF structure to edit
binding rdforms/model/Binding Can be provided instead of the graph, resource and template. The binding is the result of matching the template with the triples in the RDF graph by using the rdforms/model/Engine.
compact boolean If true the editor will be render more vertically compact with labels for non-nested structures on the same row as the input field.
includeLevel "mandatory" | "recommended" | "optional" Specifies which of the fields from the template that should be rendered in the editor when there are no matching RDF triples. Mandatory means that the cardinality restriction must be min > 0 for a field to show up. Recommended means that the cardinality restriction must be min > 0 or pref > 0 for anything to show up. If optional is specified a field show up independently of its cardinality restrictions.
filterPredicates Array | String A single or list of predicates that should be excluded from the editor. If a string is provided any commas is interpreted as separators. The predicate can be given namespaced. It is also possible to use identifiers for items instead of predicates.
showDescription boolean If true any provided description will be shown below the label.
fuzzy boolean If true the engine matches anything with the right property, wrong nodetype, pattern or missing constraints are ignored.

It is possible to change the includeLevel after the editor has been created by calling editor.setIncludeLevel('optional'). More fundamentally, it is possible to reinitialize the editor with all of the constructor parameters by calling editor.show(options).