Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface EditorInterface

Hierarchy

Index

Properties

Optional controls

controls: Control[]

Array of fields and it's associated widgetId

Optional editor

editor: Editor

Legacy singular editor override

Optional editors

editors: Editor[]

Array of editors. Defaults will be used if property is missing.

Optional sidebar

sidebar: SidebarItem[]

Array of sidebar widgerts. Defaults will be used if property is missing.

sys

sys: MetaSysProps & { contentType: { sys: MetaLinkProps }; environment: { sys: MetaLinkProps }; space: { sys: MetaLinkProps } }

Methods

getControlForField

  • getControlForField(id: string): null | Control
  • Gets a control for a specific field

    Parameters

    • id: string

    Returns null | Control

    control object for specific field

    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getEnvironment('<environment_id>'))
    .then((environment) => environment.getContentType('<contentType_id>'))
    .then((contentType) => contentType.getEditorInterface())
    .then((editorInterface) => {
     control = editorInterface.getControlForField('<field-id>')
     console.log(control)
    })
    .catch(console.error)
    

toPlainObject

update

  • Sends an update to the server with any changes made to the object's properties

    Returns Promise<EditorInterface>

    Object returned from the server with updated changes.

    const contentful = require('contentful-management')
    
    const client = contentful.createClient({
      accessToken: '<content_management_api_key>'
    })
    
    client.getSpace('<space_id>')
    .then((space) => space.getEnvironment('<environment_id>'))
    .then((environment) => environment.getContentType('<contentType_id>'))
    .then((contentType) => contentType.getEditorInterface())
    .then((editorInterface) => {
     editorInterface.controls[0] = { "fieldId": "title", "widgetId": "singleLine"}
     editorInterface.editors = [
       { "widgetId": "custom-widget", "widgetNamespace": "app" }
     ]
     return editorInterface.update()
    })
    .catch(console.error)