The Editor SDK provides Editor, an abstract base JavaScript extension. The Editor extension defines the life cycle for executing a custom editor.

Custom editors extend the base Editor class.

The framework invokes the initialize life cycle method immediately after the instantiation of the editor that passes the template configuration object and content item.

When initialization is finished, the framework binds editors to the view and moves them to Loading phase. The actual data binding occurs in the editorReady method.

Once initialization is successful, the framework invokes the editorReady life cycle method and passes the appropriate property instance created by the framework.

An editor can override this method, if it needs to wrap the property using any custom extension to the property API or any computations regarding the property value. If overridden, this method must explicitly call editorReady from it's super class Editor: Editor.prototype.editorReady.call (this, pProperty)

For more information on the property API, see Property API.

In the editorReady method of an editor, you can load any data needed by an editor asynchronously. For example, DimensionListEditor needs to load dimension names from MDEX. You should ensure that the editorReady method in the super class is called only when all asynchronous calls have completed. This allows the framework to call editorReady on individual editors asynchronously. When an editor is ready, the framework removes the Loading phase and renders the user interface using the editor's own HTML template.

This JavaScript-based property API is used for the following functions:

Class

Description

Methods

Property

The core property class that wraps the property's raw JSON data.

It also defines custom Knockout subscriptions to track changes made to a property value. Whenever there is a change in a property value, a EditorEvents.PROPERTY_CHANGED event is triggered.. The property reference that was modified is passed as the event payload.

Every editor has an observable property that is set to the property reference that editor works with.

copyFrom (pProperty) - Accepts raw the JSON object that represents a valid property with a name, type, and an optional value.

Used to update any bindings that are needed by the user interface. Basic functionality is to set value as a Knockout observable or observableArray.

toJSON() - Converts the property instance to JSON, in a format to be stored in the ECR.

For example, a property instance will have observable or observableArray to bind value to the editor, which has to be converted to normal value.

StringProperty

A subclass of Property class. Deals with property objects. Value type is a String.

 

BooleanProperty

A subclass to Property class. Deals with property objects. Value type is a Boolean.

Overrides the copyFrom method, and wraps property's value in a Boolean.

JSONProperty

A subclass to Property for Item and List types. This is used to wrap properties whose values are either JSONObject or JSONArray. When the framework parses a content item, in case of a list, it would not be possible to distinguish whether the value is a primitive list or an object list. Also in case of Item, it is not possible to determine value is of which object type.

In these scenarios, the framework wraps a property in JSONProperty and passes it to the editorReady method of the corresponding editor. Within the editorReady method, the corresponding property instance (ObjectProperty, ListProperty, ObjectListProperty, or any extension to Property that customers might develop and plug in) can be created as an editor will know about the value type that it is working with.

This is also used when there is no type specified for a property.

Overrides copyFrom method and sets property's value as an observable or observableArray based on the type.

Overrides toJSON method and converts the property instance to JSON, in a format to be stored in ECR.

ObjectProperty

A subclass to Property class for property objects whose value is an object. This is needed to manipulate internal attributes of the object. Otherwise JSONProperty works with Object.

For example in case of media property in MediaBanner cartridge, whose value is an object, there are attributes which are computed based on some other attributes in the object.

"media": {
        "@class": "com.endeca.infront.
          cartridge.model.MediaObject",
        "uri": "banner_bags_761x225.jpg",
        "contentWidth": "761",
        "contentHeight": "225",
        "contentBytes": "3546313",
        "contentType": "Image",
        "contentSrcKey": "default"
    }

In this object, based on the image that we select, for example the uri attribute, other attributes like contentWidth, contentHeight, contentBytes, contentType are computed. We can define a Image.js model object that uses a Knockout computed observables concept to compute these attributes based on the uri attribute. This Image must be wrapped using ObjectProperty.

Overrides the following methods:

copyFrom: Copies property's value into corresponding ObjectValue instance.

toJSON: Converts the property's value into JSON format, in a format to be stored in ECR.

ObjectListProperty

A subclass to Property for property objects whose value is an array or a list built from objects. As described for ObjectProperty, this is needed only when performing custom manipulations on an object's attributes. Otherwise use JSONProperty.

Overrides the following methods:

copyFrom: Copies each object in the list into corresponding ObjectValue instance.

toJSON: Converts each object in the value list into JSON format, in a format to be stored in ECR.

ContentItemProperty

A subclass to ObjectProperty for property objects whose value is an object of type ContentItem.

 

ContentItemListProperty

A subclass to ObjectListProperty for property objects whose value is an array or a list built from objects, of type ContentItem. This also stores data in a tree structure.

 

ObjectValue

A wrapper to property value which is an object. Provides method signatures to be implemented by any object values.

copyFrom(pPropertyValue): Copies plain JSON object into the ObjectValue. For example, in SortOption, there can be an observable label, which would be populated under the copyFrom(..) method.

toJSON(): In Experience Manager, the implementation converts the Knockout object back to a plain JSON object.


Copyright © Legal Notices