Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | 6x 4x 4x 4x 4x 4x 2x 4x 4x 4x 4x 3x 1x | import postRobot from "post-robot"; import Field from "./field.js"; import Window from "./window.js"; import Stack from "./stack.js"; import Entry from "./entry.js"; import EventEmitter from 'wolfy87-eventemitter'; const emitter = new EventEmitter(); /** Class representing a extension from contentstack ui. */ class Extension { constructor(initializationData) { /** * This method gives you the configuration parameters. Check out our [UI eEtension config documentation](https://www.contentstack.com/docs/apis/content-delivery-api/). * @type {Object} */ this.config = initializationData.data.config; /** * This object holds details of the current user. The details include roles assigned to users. * @type {Object} */ this.currentUser = initializationData.data.user; /** * type of extension, 'FIELD' || 'SIDEBAR'. * @type {string} */ this.type = initializationData.data.type || 'FIELD'; /** * This gives you the entry object which allows you to interact with the current entry. * @type {Entry} */ this.entry = new Entry(initializationData, postRobot, emitter); if (this.type === 'FIELD') { /** * Gives you the extension field object which allows you to interact with the field. * @type {Field} */ this.field = new Field(initializationData, postRobot, emitter); } /** * The window object provides users with methods that allow them to adjust the size of the iframe that contains the extension. * @type {Window} */ this.window = new Window(postRobot); /** * This method returns stack object which allows users to interact with the stack. * @type {Stack} */ this.stack = new Stack(initializationData.data.stack, postRobot); postRobot.on('entryUpdate', function (event) { emitter.emitEvent('entryUpdate', [event]); }) } static initialize() { return postRobot.sendToParent('init', {}) } setReady() { return postRobot.sendToParent('ready') } } export default Extension; |