diff --git a/dist/bundle.js b/dist/bundle.js index efd8239..e322b14 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -970,6 +970,19 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ event: event }, callback); }; + /** + * Get ordered list of element IDs, for selector + * + * @param {String} selector the selector for finding the elements + * @param {Function} callback Receives an ordered array of element IDs + */ + + + AH5Communicator.prototype.getOrderedIDs = function (selector, callback) { + PluginAPI.request('get-ordered-ids', { + selector: selector + }, callback); + }; return new AH5Communicator(); }; @@ -1431,6 +1444,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ /** * Set the keyword-list on the article * + * @deprecated Use tags instead * @param {Array} keywords List of keywords to add * @param {Function} callback Function to call when keywords have been set */ @@ -1444,6 +1458,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ /** * Get the current set of keywords on the article * + * @deprecated Use tags instead * @param {Function} callback Function to call with the result */ diff --git a/dist/bundle.js.map b/dist/bundle.js.map index 65fe50b..9b51638 100644 --- a/dist/bundle.js.map +++ b/dist/bundle.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://PluginAPI/webpack/universalModuleDefinition","webpack://PluginAPI/webpack/bootstrap","webpack://PluginAPI/./js/AH5Communicator.js","webpack://PluginAPI/./js/ArticleCommunicator.js","webpack://PluginAPI/./js/Listeners.js","webpack://PluginAPI/./js/PluginAPI.js"],"names":["module","exports","PluginAPI","selectedPluginElement","AH5Communicator","DEBUG","on","pluginElementSelected","pluginElementDeselected","elementData","prototype","getActiveEditor","callback","request","registerMenuAction","action","registerHoverAction","getSelectedPluginElement","deSelectPluginElements","directionalCastle","elementId","direction","registerMenuActionGroup","group","getEditorType","replaceElementById","id","element","replacePluginElementById","setElementContentById","content","deleteElementById","getHTMLById","getHTMLBySelector","selector","getCategories","getParentCategories","category","getParentIds","getTagTypes","getTagType","clear","insertString","string","insertElement","options","select","outerHTML","removeClasses","classes","addClasses","getDataAttribute","attribute","updateDataAttribute","value","markAsActive","setAttributeById","setStyleById","initMenu","menus","openPluginElementEditor","getTotalWordCount","getTotalCharCount","updateAssetOption","dpArticleId","key","updateAssetData","data","getAssetData","insertNestedAsset","parentElementId","markup","self","createEmbeddedObject","embeddedTypeId","insert","updateEmbeddedAssetRequest","internalId","$element","$","attr","assetSource","externalId","dpDigitalAssetId","assetClass","addClass","html","Editor","d","document","createElement","innerHTML","firstChild","setAttribute","assetContainer","querySelector","isMultiple","append","get","insertEmbeddedAsset","updateContent","getAppName","showErrorMsg","Error","addEmbeddedAssetRequest","dataset","classList","add","getCurrentSelectionAbsolutePosition","wrapSelection","className","attributes","removeInPlace","triggerEvent","event","ArticleCommunicator","focusPlugin","focusApp","startPlugin","name","app","option","startApp","stopPlugin","stopApp","getId","getPackageId","getPackageGuid","clearMetaInfo","getTags","getCustomMeta","setCustomMeta","setMetaChanged","setTags","tags","save","addTags","errorFunction","onError","addTag","tag","removeTag","getSelectedCategories","saveCategories","categories","setCategories","addCategories","removeCategories","setMainCategory","getSource","setSource","source","getStatus","setStatus","status","getPublishedDatetime","setPublishedDatetime","published","getAuthors","setAuthors","authors","addAuthors","removeAuthors","setKeywords","keywords","getKeywords","getCurrentContent","setCurrentContent","setSubArticleContent","articleId","getArticletypeId","setArticletypeId","articletypeId","articletype","maximizePluginWindow","title","onClose","Date","getTime","eventListeners","removeAll","maximizeAppWindow","restorePluginWindow","restoreAppWindow","getByline","setByline","byline","setGeolocations","geolocations","getGeolocations","getProperties","setProperties","properties","setProperty","getTopic","setTopic","topic","getPackage","Listeners","_listeners","listeners","createCallback","eventName","hasOwnProperty","callWrapper","undefined","push","length","index","payload","returnValue","forEach","listenerFn","res","params","apply","ah5Communicator","articleCommunicator","Api","queryParameters","window","location","search","substr","split","queryPair","Version","Article","errorListeners","appName","jwt","standAlone","pm","bind","createEventFunction","updateObject","type","eventKey","map","notify","callSpec","console","info","getPluginName","func","remove","arguments","createCallbackObject","random","Math","floor","eventFunction","val","target","parent","success","error","origin","hash","openTagCreationDialog","reloadIframe","setPluginName","setAppName","showInfoMsg","msg","message","showWarningMsg","showLoader","hideLoader","__loadArticleRevision","revision","createTag","searchDrLib","query","access","secure","convertDomToHTML","dom","wrap","domClone","cloneNode","wrapper","appendChild","generateArticleUrl","extendApi","a","callExtendedApi","getCurrentUser","getConfiguration","getDrPublishConfiguration","setConfiguration","config","onlyPublication","emit","increaseRequiredActionCounter","decreaseRequiredActionCounter","clearRequiredActionCounter","setRequiredActionCounter","count","create","typeId","getEmbeddedObjectTypes","giveFocus","pluginName","argument","start","hide","createModal","updateModal","closeModal","destroy","getModalInputs","confirmAuthenticated","isStandAlone","getJWT","replaceEditorComponentsExtension","clearEditorComponentsExtension","highlightAnnotation","underemphasizeAnnotations","registerExternallyDefinedProperties"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AClFA;;;;;;;;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AJ,CAAcmT,mBAAd,GAAoC,UAAU1P,IAAV,EAAgB;AACnD,WAAKtD,OAAL,CAAa,sBAAb,EAAqCsD,IAArC;AACA,KAFD;;AAIAuJ,OAAG,CAAChN,SAAJ,CAAcoT,yBAAd,GAA0C,UAAU3P,IAAV,EAAgB;AACzD,WAAKtD,OAAL,CAAa,4BAAb,EAA2CsD,IAA3C;AACA,KAFD;;AAIAuJ,OAAG,CAAChN,SAAJ,CAAcqT,mCAAd,GAAoD,UAAU5P,IAAV,EAAgB;AACnE,WAAKtD,OAAL,CAAa,wCAAb,EAAuDsD,IAAvD;AACA,KAFD;;AAIA,WAAO,IAAIuJ,GAAJ,EAAP;AACA,GArrBiB,EAAlB;;AAurBAxN,WAAS,CAACiO,OAAV,GAAoBV,mBAAmB,CAACvN,SAAD,CAAvC;AACAA,WAAS,CAACqF,MAAV,GAAmBiI,eAAe,CAACtN,SAAD,CAAlC;AAEAF,QAAM,CAACC,OAAP,GAAiBC,SAAjB","file":"bundle.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"PluginAPI\"] = factory();\n\telse\n\t\troot[\"PluginAPI\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./js/PluginAPI.js\");\n","/**\n * @typedef {Object} selectedPluginElementData\n *\n * @property {String} id The DOM id of the selected element\n * @property {String} dpArticleId\n * @property {String} externalId\n * @property {Boolean} isDigitalAsset\n */\n\n/**\n * @param {Api} PluginAPI\n * @return {AH5Communicator}\n */\nmodule.exports = function (PluginAPI) {\n\n\t/** @type {selectedPluginElementData|null} */\n\tlet selectedPluginElement = null;\n\n\t/**\n\t * This will be used by editor apps to communicate with the editor\n\t *\n\t * Should be used like this:\n\t *\n\t * PluginAPI.Editor.insertString('string');\n\t *\n\t * @class\n\t * @classdesc Functions for talking with the AH5 editor. Accessed through PluginAPI.Editor\n\t * @exports PluginAPI/Editor\n\t */\n\t/* eslint max-statements: [\"error\", 50, { \"ignoreTopLevelFunctions\": true }]*/\n\tconst AH5Communicator = function () {\n\t\tthis.DEBUG = false;\n\t\tPluginAPI.on('pluginElementClicked', pluginElementSelected);\n\t\tPluginAPI.on('pluginElementDeselected', pluginElementDeselected);\n\n\t\t/**\n\t\t * @param {selectedPluginElementData} elementData\n\t\t */\n\t\tfunction pluginElementSelected(elementData) {\n\t\t\tselectedPluginElement = elementData;\n\t\t}\n\n\t\tfunction pluginElementDeselected() {\n\t\t\tselectedPluginElement = null;\n\t\t}\n\t};\n\n\t/**\n\t * Get name of current active editor\n\t *\n\t * @param {Function} callback function(String)\n\t */\n\tAH5Communicator.prototype.getActiveEditor = function (callback) {\n\t\tPluginAPI.request('get-active-editor', null, callback);\n\t};\n\n\t/**\n\t * Registers/Modifies a context menu items for a plugin element\n\t * The object send should have the following structure\n\t *\n\t * @param {Object} action The action object\n\t * @param {Function} callback function()\n\t *\n\t * @example\n\t * PluginAPI.Editor.registerMenuAction({\n\t *\t label: 'label in the menu',\n\t *\t icon: '[Optional] url to possible icon image',\n\t *\t trigger: '[Optional] css selector, only show menu element when this matches the element',\n\t *\t callback: function(id, clickedElementId) {\n\t *\t\t // callback function\n\t *\t\t // first parameter is id of the plugin element\n\t *\t\t // second paramter is id of closest element to the trigger element that has an id\n\t *\t\t //\t in code: $(event.triggerElement).closest('[id]').attr('id');\n\t *\t }\n\t * })\n\t */\n\tAH5Communicator.prototype.registerMenuAction = function (action, callback) {\n\t\tPluginAPI.request('register-menu-action', action, callback);\n\t};\n\n\t/**\n\t * Adds a mouseover action to plugin elements\n\t *\n\t * @param {function} action to perform\n\t * @param {function} callback function(String)\n\t */\n\tAH5Communicator.prototype.registerHoverAction = function (action, callback) {\n\t\tPluginAPI.request('register-hover-action', action, callback);\n\t};\n\n\t/**\n\t * Gets the selected plugin element from the editor\n\t *\n\t * @param {function} callback function(String)\n\t */\n\tAH5Communicator.prototype.getSelectedPluginElement = function (callback) {\n\t\tPluginAPI.request('get-selected-plugin-element', {}, callback);\n\t};\n\n\t/**\n\t * Deselect all plugin elements in editor\n\t *\n\t * @param {function} callback function(String)\n\t */\n\tAH5Communicator.prototype.deSelectPluginElements = function (callback) {\n\t\tPluginAPI.request('de-select-plugin-elements', {}, callback);\n\t};\n\n\t/**\n\t * Swap positions between the provided element and the adjacent one\n\t * in the specified direction\n\t * PluginAPI.Editor.directionalCastle({\n\t * elementId: 'the provided element id',\n\t * direction: 'forward/backward'\n\t * })\n\t * @param {String} elementId DOM element id\n\t * @param {String} direction Direction\n\t * @param {function} callback\n\t * */\n\tAH5Communicator.prototype.directionalCastle = function (elementId, direction, callback) {\n\t\tPluginAPI.request('editor-directional-castle', {\n\t\t\telementId: elementId,\n\t\t\tdirection: direction\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Registers/Modifies a group of items to in the context menu\n\t * The object send should have the following structure\n\t *\n\t * @example\n\t * PluginAPI.Editor.registerMenuActionGroup({\n\t *\t label: 'label for the group in the menu',\n\t *\t icon: '[Optional] url to possible icon image',\n\t *\t actions: [\n\t *\t\t {\n\t *\t\t\t label: 'label for the action #1',\n\t *\t\t\t callback: function(id, clickedElementId) {\n\t *\t\t\t\t // same as for registerMenuAction\n\t *\t\t\t }\n\t *\t\t },\n\t *\t\t {\n\t *\t\t\t label: 'label for the action #2',\n\t *\t\t\t callback: function(id, clickedElementId) {\n\t *\t\t\t\t // same as for registerMenuAction\n\t *\t\t\t }\n\t *\t\t }\n\t *\t ]\n\t * })\n\t *\n\t * @param {Object} group The action object\n\t * @param {function} callback function()\n\t */\n\tAH5Communicator.prototype.registerMenuActionGroup = function (group, callback) {\n\t\tPluginAPI.request('register-menu-action-group', group, callback);\n\t};\n\n\t/**\n\t * Retrieves the type of editor that currently has focus\n\t *\n\t * @param {function} callback function(String)\n\t */\n\tAH5Communicator.prototype.getEditorType = function (callback) {\n\t\tPluginAPI.request('editor-get-type', null, callback);\n\t};\n\n\t/**\n\t * Replace an element in the article\n\t *\n\t * @param {String} id Id of the element\n\t * @param {String} element The new element\n\t * @param {function} callback function(Boolean), called after replacement is done\n\t */\n\tAH5Communicator.prototype.replaceElementById = function (id, element, callback) {\n\t\tPluginAPI.request('editor-element-replace-byid', {\n\t\t\tid: id,\n\t\t\telement: element\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Replace a plugin element in the article\n\t *\n\t * @param {String} id Id of the element\n\t * @param {String} element The new element\n\t * @param {function} callback function(Boolean), called after replacement is done\n\t */\n\tAH5Communicator.prototype.replacePluginElementById = function (id, element, callback) {\n\t\tPluginAPI.request('editor-element-replace-plugin-element-byid', {\n\t\t\tid: id,\n\t\t\telement: element\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Set the content of an element in the article\n\t *\n\t * @param {String} id Id of the element\n\t * @param {String} content The new content\n\t * @param {function} callback function(Boolean), called when done\n\t */\n\tAH5Communicator.prototype.setElementContentById = function (id, content, callback) {\n\t\tPluginAPI.request('editor-element-set-byid', {\n\t\t\tid: id,\n\t\t\telement: content\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Delete an element in the article\n\t *\n\t * @param {String} id Id of the element\n\t * @param {function} callback function(Boolean), called after deletion is done\n\t */\n\tAH5Communicator.prototype.deleteElementById = function (id, callback) {\n\t\tPluginAPI.request('editor-element-delete-byid', {\n\t\t\tid: id\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Get HTML code of an element\n\t *\n\t * @param {String} id The element id\n\t * @param {function} callback function(String), html content of the element\n\t */\n\tAH5Communicator.prototype.getHTMLById = function (id, callback) {\n\t\tPluginAPI.request('editor-element-get-byid', {\n\t\t\tid: id\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Get HTML code of all elements that match the selector\n\t *\n\t * @param {String} selector The CSS selector\n\t * @param {function} callback function([String]), html content of matching elements\n\t */\n\tAH5Communicator.prototype.getHTMLBySelector = function (selector, callback) {\n\t\tPluginAPI.request('editor-elements-get-byselector', {\n\t\t\tselector: selector\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Get all categories\n\t *\n\t * @param {Function} callback function([Object Category]), list of Category objects with id, name and pid\n\t */\n\tAH5Communicator.prototype.getCategories = function (callback) {\n\t\tPluginAPI.request('get-categories', null, callback);\n\t};\n\n\t/**\n\t * Returns all the parent categories of the given category\n\t *\n\t * @param {Object} category The category to find parents of\n\t * @param {Function} callback function([Object Category]), array of parent Category objects\n\t */\n\tAH5Communicator.prototype.getParentCategories = function (category, callback) {\n\t\tPluginAPI.request('get-parent-categories', category, callback);\n\t};\n\n\t/**\n\t * Returns all the parent elements that match the selector\n\t *\n\t * @param {String} id Id of element to find parents of\n\t * @param {String} selector Selector to filter parent elements with\n\t * @param {Function} callback function([String]), array of ids\n\t */\n\tAH5Communicator.prototype.getParentIds = function (id, selector, callback) {\n\t\tPluginAPI.request('get-parent-ids', {\n\t\t\tid: id,\n\t\t\tselector: selector\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Retrieve information about all tagtypes\n\t *\n\t * @param {Function} callback function([Object Tagtype]), array of tagtypes with id, name and config object\n\t */\n\tAH5Communicator.prototype.getTagTypes = function (callback) {\n\t\tPluginAPI.request('get-tag-types', null, callback);\n\t};\n\n\t/**\n\t * Get information about the given tagtype\n\t *\n\t * @param {String} id The element id\n\t * @param {Function} callback function(Object Tagtype), tagtype object with id, name and config object\n\t */\n\tAH5Communicator.prototype.getTagType = function (id, callback) {\n\t\tPluginAPI.request('get-tag-type', {\n\t\t\tid: id\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Clears the editor contents\n\t *\n\t * @param {Function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.clear = function (callback) {\n\t\tPluginAPI.request('editor-clear', null, callback);\n\t};\n\n\t/**\n\t * Insert a string into the editor\n\t *\n\t * @param {String} string The string that should be inserted\n\t * @param {Function} callback function(String), id of the newly inserted element if it has one\n\t */\n\tAH5Communicator.prototype.insertString = function (string, callback) {\n\t\tPluginAPI.request('editor-insert-string', {\n\t\t\tstring: string\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Insert an element into the editor\n\t *\n\t * Note that the HTML of the element is what will be transferred, and nothing else!\n\t * The element will be given the class dp-plugin-element, and given a unique ID (if none is present)\n\t *\n\t * @param {Element} element The element that should be inserted\n\t * @param {Object | Function} options (can be omitted) Options object, supports option 'select' - set to true to automatically select the inserted element\n\t * @param {Function} [callback] function(String), id of the newly inserted element\n\t */\n\tAH5Communicator.prototype.insertElement = function (element, options, callback) {\n\t\tlet select = false;\n\t\tif (typeof options === 'object') {\n\t\t\toptions = options || {};\n\t\t\tselect = typeof options.select === 'boolean' ? options.select : false;\n\t\t} else if (typeof callback === 'undefined' && typeof options === 'function') {\n\t\t\tcallback = options;\n\t\t}\n\t\tPluginAPI.request('editor-insert-element', {\n\t\t\telement: element.outerHTML,\n\t\t\tselect: select,\n\t\t\toptions: options\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Remove classes from the element an element in the article\n\t *\n\t * @param {String} id Id of the element\n\t * @param {Array} classes Array of class names\n\t * @param {function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.removeClasses = function (id, classes, callback) {\n\t\tPluginAPI.request('editor-classes-remove', {\n\t\t\tid: id,\n\t\t\tclasses: classes\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Add new classes to an element\n\t *\n\t * @param {String} id Id of the element\n\t * @param {Array} classes Array of class names\n\t * @param {function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.addClasses = function (id, classes, callback) {\n\t\tPluginAPI.request('editor-classes-add', {\n\t\t\tid: id,\n\t\t\tclasses: classes\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Get data-attribute of the element\n\t *\n\t * @param {String} id Id of the element\n\t * @param {String} attribute attribute name\n\t * @param {function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.getDataAttribute = function (id, attribute, callback) {\n\t\tPluginAPI.request('editor-attribute-get', {\n\t\t\tid: id,\n\t\t\tattribute: 'data-' + attribute\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Update data-attribute of the element\n\t *\n\t * @param {String} id Id of the element\n\t * @param {String} attribute attribute name\n\t * @param {String} value attribute value\n\t * @param {function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.updateDataAttribute = function (id, attribute, value, callback) {\n\t\tPluginAPI.request('editor-attribute-update', {\n\t\t\tid: id,\n\t\t\tattribute: 'data-' + attribute,\n\t\t\tvalue: value\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Mark an element as currently selected (green border with default styling)\n\t *\n\t * @param {String} id Id of the element\n\t * @param {function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.markAsActive = function (id, callback) {\n\t\tPluginAPI.request('editor-mark-as-active', {\n\t\t\tid: id\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Sets the attribute of the element with the given ID to value\n\t *\n\t * @param {String} id The ID of the element to set the attribute on\n\t * @param {String} attribute The attribute to set\n\t * @param {String} value What to set the attribute to\n\t * @param {Function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.setAttributeById = function (id, attribute, value, callback) {\n\t\tPluginAPI.request('editor-element-attribute-set-byid', {\n\t\t\tid: id,\n\t\t\tattribute: attribute,\n\t\t\tvalue: value\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Sets a style of the element with the given ID to value\n\t *\n\t * @param {String} id The ID of the element to set the attribute on\n\t * @param {String} attribute The style attribute to set\n\t * @param {String} value What to set the attribute to\n\t * @param {Function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.setStyleById = function (id, attribute, value, callback) {\n\t\tPluginAPI.request('editor-element-style-set-byid', {\n\t\t\tid: id,\n\t\t\tattribute: attribute,\n\t\t\tvalue: value\n\t\t}, callback);\n\t};\n\n\n\t/**\n\t * Initialize pre registered menus\n\t *\n\t * Available options are: simplePluginMenu, editContext, deleteButton, floatButtons\n\t *\n\t * @param {Array} menus Array of menu names\n\t * @param {Function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.initMenu = function (menus, callback) {\n\t\tPluginAPI.request('editor-initialize-menu', {\n\t\t\tmenus: menus\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Opens the plugin editor for a given element.\n\t *\n\t * @param {String} id Plugin element ID\n\t */\n\tAH5Communicator.prototype.openPluginElementEditor = function (id) {\n\t\tPluginAPI.request('open-element-editor', {\n\t\t\tid: id\n\t\t});\n\t};\n\n\t/**\n\t * Returns the total number of words in the currently open article.\n\t *\n\t * @param {Function} callback Receives the total word count as its single parameter\n\t */\n\tAH5Communicator.prototype.getTotalWordCount = function (callback) {\n\t\tPluginAPI.request('total-word-count', null, callback);\n\t};\n\n\t/**\n\t * Returns the total number of characters in the currently open article.\n\t *\n\t * @param {Function} callback Receives the total character count as its single parameter\n\t */\n\tAH5Communicator.prototype.getTotalCharCount = function (callback) {\n\t\tPluginAPI.request('total-char-count', null, callback);\n\t};\n\n\t/**\n\t * Update one data option of the referenced embedded asset\n\t *\n\t * @param {Number} dpArticleId DrPublish's embedded asset id\n\t * @param {String} key Name of the property\n\t * @param {String} value Value of the property\n\t * @param {Function} callback Receives the total character count as its single parameter\n\t */\n\tAH5Communicator.prototype.updateAssetOption = function (dpArticleId, key, value, callback) {\n\t\tPluginAPI.request('update-asset-option', {dpArticleId: dpArticleId, key: key, value: value}, callback);\n\t};\n\n\t/**\n\t * Update all asset data of the referenced embedded asset\n\t *\n\t * @param {Object} data Updated data\n\t * @param {Function} callback Receives the total character count as its single parameter\n\t *\n\t * @example\n\t * var data = {\n\t * internalId: assetDpArticleId,\n\t * assetElementId: activeAssetId,\n\t * assetType: 'picture',\n\t * assetSource: PluginAPI.getPluginName(),\n\t * resourceUri: fullsizeUrl,\n\t * previewUri: fullsizeUrl,\n\t * renditions: {\n\t * highRes: {uri: fullsizeUrl},\n\t * thumbnail: {uri: thumbnailUrl}\n\t * },\n\t * options: {}\n\t * }\n\t * PluginAPI.Editor.updateAssetData(data);\n\t */\n\tAH5Communicator.prototype.updateAssetData = function (data, callback) {\n\t\tPluginAPI.request('update-asset-media', data, callback);\n\t};\n\n\t/**\n\t * Get all data option of the referenced embedded asset\n\t *\n\t * @param {Number} dpArticleId DrPublish's embedded asset id\n\t * @param {Function} callback Receives the total character count as its single parameter\n\t */\n\tAH5Communicator.prototype.getAssetData = function (dpArticleId, callback) {\n\t\tPluginAPI.request('get-asset-data', {data: dpArticleId}, callback);\n\t};\n\n\t/**\n\t * Insert an embedded asset inside of an existing one\n\t *\n\t * @param {Number} parentElementId DOM element id of the receiving asset\n\t * @param {String} markup HTML to inject\n\t * @param {Object} data Asset data\n\t * @param {Function} callback Receives the total character count as its single parameter\n\t *\n\t * @example\n\t * var title = response.data.title ? response.data.title : '';\n\t * var caption = response.data.description ? response.data.description : '';\n\t * var credit = response.data.byline ? response.data.byline : '';\n\t * var source = response.data.source ? response.data.source : '';\n\t * var markup = '
';\n\t * markup += '
' + title + '
...';\n\t * var options = response.data.options ? response.data.options : {};\n\t * var callback = function () {\n\t * // do something here\n\t * };\n\t * var rends = renditions || {};\n\t * rends.highRes = {uri: fullsizeUrl};\n\t * rends.preview = {uri: fullsizeUrl};\n\t * var drpdata = {\n\t * embeddedTypeId: 5,\n\t * isMultiple: true,\n\t * assetType: 'picture',\n\t * externalId: id,\n\t * assetClass: 'dp-picture',\n\t * assetSource: 'images',\n\t * resourceUri: fullsizeUrl,\n\t * previewUri: fullsizeUrl,\n\t * renditions: rends,\n\t * options: options\n\t * };\n\t * var insertNested = function () {\n\t * PluginAPI.Editor.insertNestedAsset(\n\t * selectedSlideshowAsset.id,\n\t * markup,\n\t * drpdata\n\t * };\n\t * PluginAPI.Editor.getSelectedPluginElement(insertNested);\n\t */\n\tAH5Communicator.prototype.insertNestedAsset = function (parentElementId, markup, data, callback) {\n\t\tconst self = this;\n\t\tPluginAPI.createEmbeddedObject(\n\t\t\tdata.embeddedTypeId,\n\t\t\t(dpArticleId) => {\n\t\t\t\tinsert(dpArticleId, parentElementId, (data) => {\n\t\t\t\t\treturn updateEmbeddedAssetRequest(callback);\n\t\t\t\t});\n\t\t\t}\n\t\t);\n\n\t\tfunction insert(dpArticleId, parentElementId, callback) {\n\t\t\tdata.internalId = dpArticleId;\n\t\t\tconst elementId = 'asset-' + dpArticleId;\n\t\t\tconst $element = $('
');\n\t\t\t$element.attr('id', elementId);\n\t\t\t$element.attr('data-internal-id', dpArticleId);\n\t\t\t$element.attr('data-ah5-type', data.assetSource);\n\t\t\tif (data.externalId) {\n\t\t\t\t$element.attr('data-external-id', data.externalId);\n\t\t\t}\n\t\t\tif (data.dpDigitalAssetId) {\n\t\t\t\t$element.attr('data-dp-digital-asset-id', data.dpDigitalAssetId);\n\t\t\t}\n\t\t\tif (data.assetClass) {\n\t\t\t\t$element.addClass(data.assetClass);\n\t\t\t}\n\t\t\t$element.addClass('dp-plugin-element');\n\t\t\t$element.html(markup);\n\t\t\tPluginAPI.Editor.getHTMLById(parentElementId, (html) => {\n\t\t\t\tlet d = document.createElement('div');\n\t\t\t\td.innerHTML = html;\n\t\t\t\td.firstChild.setAttribute('id', parentElementId + 'tmp');\n\t\t\t\tself.replacePluginElementById(parentElementId, d.innerHTML, () => {\n\t\t\t\t\td = document.createElement('div');\n\t\t\t\t\td.innerHTML = html;\n\t\t\t\t\tconst assetContainer = d.querySelector('.dp-fact-box-image, .dp-nested-asset-container');\n\t\t\t\t\tif (data.isMultiple) {\n\t\t\t\t\t\t$(assetContainer).append($element.get(0).outerHTML);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tassetContainer.innerHTML = $element.get(0).outerHTML;\n\t\t\t\t\t}\n\t\t\t\t\tself.replacePluginElementById(parentElementId + 'tmp', d.innerHTML, callback);\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\tfunction updateEmbeddedAssetRequest(callback) {\n\t\t\tPluginAPI.request('update-embedded-asset', data, callback);\n\t\t}\n\t};\n\n\t/**\n\t * Insert an embedded asset\n\t *\n\t * @param {String} markup HTML to inject\n\t * @param {Object} data Asset data\n\t * @param {Function} callback Receives the total character count as its single parameter\n\t *\n\t * @example\n\t * var title = response.data.title ? response.data.title : '';\n\t * var caption = response.data.description ? response.data.description : '';\n\t * var credit = response.data.byline ? response.data.byline : '';\n\t * var source = response.data.source ? response.data.source : '';\n\t * var markup = '
';\n\t * markup += '
' + title + '
';\n\t * markup += '
' + caption + '
...';\n\t * var options = response.data.options ? response.data.options : {};\n\t * var callback = function () {\n\t * // do something here\n\t * };\n\t * var rends = renditions || {};\n\t * rends.highRes = {uri: fullsizeUrl};\n\t * rends.preview = {uri: fullsizeUrl};\n\t * var drpdata = {\n\t * embeddedTypeId: 5,\n\t * isMultiple: true,\n\t * assetType: 'picture',\n\t * externalId: id,\n\t * assetClass: 'dp-picture',\n\t * assetSource: 'images',\n\t * resourceUri: fullsizeUrl,\n\t * previewUri: fullsizeUrl,\n\t * renditions: rends,\n\t * options: options\n\t * };\n\t * PluginAPI.Editor.insertEmbeddedAsset(markup, drpdata, callback);\n\t */\n\tAH5Communicator.prototype.insertEmbeddedAsset = function (markup, data, callback) {\n\t\tconst self = this;\n\t\tlet updateContent = false;\n\t\tif (selectedPluginElement) {\n\t\t\tif (data.assetSource !== PluginAPI.getAppName()) {\n\t\t\t\tPluginAPI.showErrorMsg('Can\\'t update selected plugin element since it doesn\\'t belong to the \\'' + PluginAPI.getAppName() + '\\' plugin');\n\t\t\t\treturn;\n\t\t\t} else {\n\t\t\t\tupdateContent = true;\n\t\t\t}\n\t\t}\n\n\t\tif (selectedPluginElement) {\n\t\t\tconst dpArticleId = selectedPluginElement.dpArticleId;\n\t\t\tif (!dpArticleId) {\n\t\t\t\tthrow Error('Selected plugin element: expected dpArticleId not found (tried reading from attribute \\'data-internal-id\\')');\n\t\t\t}\n\t\t\tinsert(dpArticleId, (data) => {\n\t\t\t\treturn updateEmbeddedAssetRequest(typeof callback === 'function' ? callback(data) : null);\n\t\t\t});\n\t\t} else {\n\t\t\tPluginAPI.createEmbeddedObject(\n\t\t\t\tdata.embeddedTypeId,\n\t\t\t\t(dpArticleId) => {\n\t\t\t\t\tinsert(dpArticleId, (data) => {\n\t\t\t\t\t\treturn addEmbeddedAssetRequest(typeof callback === 'function' ? callback(data) : null);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tfunction insert(dpArticleId, callback) {\n\t\t\tdata.internalId = dpArticleId;\n\t\t\tconst elementId = 'asset-' + dpArticleId;\n\t\t\tconst element = document.createElement('div');\n\t\t\telement.id = elementId;\n\t\t\telement.dataset.internalId = dpArticleId;\n\t\t\tif (data.externalId) {\n\t\t\t\telement.dataset.externalId = data.externalId;\n\t\t\t}\n\t\t\tif (data.dpDigitalAssetId) {\n\t\t\t\telement.dataset.dpDigitalAssetId = data.dpDigitalAssetId;\n\t\t\t}\n\t\t\tif (data.assetClass) {\n\t\t\t\telement.classList.add(data.assetClass);\n\t\t\t}\n\t\t\telement.innerHTML = markup;\n\t\t\tif (!updateContent) {\n\t\t\t\tdata.select = true;\n\t\t\t\tself.insertElement(element, data);\n\t\t\t} else {\n\t\t\t\tself.setElementContentById(elementId, element.innerHTML, null);\n\t\t\t}\n\t\t\tif (typeof callback === 'function') {\n\t\t\t\treturn callback();\n\t\t\t}\n\t\t}\n\n\t\tfunction addEmbeddedAssetRequest(callback) {\n\t\t\tPluginAPI.request('add-embedded-asset', data, callback);\n\t\t}\n\n\t\tfunction updateEmbeddedAssetRequest(callback) {\n\t\t\tPluginAPI.request('update-embedded-asset', data, callback);\n\t\t}\n\t};\n\n\t/**\n\t * Returns the total number of characters in the currently open article.\n\t *\n\t * @param {Function} callback Receives the total character count as its single parameter\n\t */\n\tAH5Communicator.prototype.getCurrentSelectionAbsolutePosition = function (callback) {\n\t\tPluginAPI.request('current-selection-absolute-position', null, callback);\n\t};\n\n\t/**\n\t * Wraps the current selection in a span\n\t *\n\t * @param {String} className the name of the class to apply\n\t * @param {Object} attributes to apply to the wrapper\n\t * @param {Function} callback\n\t */\n\tAH5Communicator.prototype.wrapSelection = function (className, attributes, callback) {\n\t\tPluginAPI.request('wrap-selection', {className: className, attributes: attributes}, callback);\n\t};\n\n\t/**\n\t * Removes the selected element, leaving all children in place\n\t *\n\t * @param {String} selector the selector for finding the elements to be removed\n\t * @param {Function} callback\n\t */\n\tAH5Communicator.prototype.removeInPlace = function (selector, callback) {\n\t\tPluginAPI.request('remove-in-place', {selector: selector}, callback);\n\t};\n\n\t/**\n\t * Triggers an event on all elements matching the selector\n\t *\n\t * @param {String} selector the selector for finding the elements\n\t * @param {String} event the event to trigger on the found elements\n\t * @param {Function} callback\n\t */\n\tAH5Communicator.prototype.triggerEvent = function (selector, event, callback) {\n\t\tPluginAPI.request('trigger-event', {selector: selector, event: event}, callback);\n\t};\n\n\treturn new AH5Communicator();\n};\n","/* eslint max-statements: [\"error\", 100000000] */\n/* eslint complexity: [\"error\", 100000000] */\nmodule.exports = function (PluginAPI) {\n\n\t/**\n * This class is used for communicating with the article, typically setting and getting values of metadata or in the article content itself.\n *\n * @class\n * @classdesc Functions for talking with the DrPublish article object. Accessed through PluginAPI.Article\n * @exports PluginAPI/Article\n */\n\tconst ArticleCommunicator = function () {\n\t\tthis.DEBUG = false;\n\t};\n\n\t/**\n * Give focus to yourself\n *\n * @param {Function} callback function(Boolean), called as the plugin gets focus\n */\n\tArticleCommunicator.prototype.focusPlugin = function (callback) {\n\t\tPluginAPI.request('app-focus', {}, callback);\n\t};\n\n\t/**\n * Give focus to yourself\n * @deprecated use focusPlugin instead\n * @param {Function} callback function(Boolean), called after plugin is started\n */\n\tArticleCommunicator.prototype.focusApp = function (callback) {\n\t\tthis.focusPlugin(callback);\n\t};\n\n\t/**\n * Start the given plugin\n *\n * @param {String} name Name of the plugin as defined on publication settings\n * @param {Object} options Options for initializing the plugin\n * @param {Function} callback function(Boolean), called after plugin is started\n */\n\tArticleCommunicator.prototype.startPlugin = function (name, options, callback) {\n\t\tPluginAPI.request('app-start', {\n\t\t\tapp: name,\n\t\t\toption: options\n\t\t}, callback);\n\t};\n\n\t/**\n * @deprecated use startPlugin instead\n * @param {String} name Name of the plugin as defined on publication settings\n * @param {Object} options Options for initializing the plugin\n * @param {Function} callback function(Boolean), called after plugin is started\n */\n\tArticleCommunicator.prototype.startApp = function (name, options, callback) {\n\t\tthis.startPlugin(name, options, callback);\n\t};\n\n\t/**\n * Stop the given plugin\n *\n * @param {String} name Name of the plugin, as defined on publication config\n */\n\tArticleCommunicator.prototype.stopPlugin = function (name) {\n\t\tPluginAPI.request('app-stop', {\n\t\t\tapp: name\n\t\t});\n\t};\n\n\t/**\n * @deprecated use stopPlugin instead\n * @param {String} name Name of the plugin, as defined on publication config\n */\n\tArticleCommunicator.prototype.stopApp = function (name) {\n\t\tthis.stopPlugin(name);\n\t};\n\n\t/**\n * Get the id of the article currently edited\n *\n * @param {Function} callback function(Int), id of the current article\n */\n\tArticleCommunicator.prototype.getId = function (callback) {\n\t\tPluginAPI.request('article-id-get', null, callback);\n\t};\n\n\t/**\n * Get the guid of the article package currently edited\n *\n * @param {Function} callback function(Int), id of the current article\n */\n\tArticleCommunicator.prototype.getPackageId = function (callback) {\n\t\tPluginAPI.request('package-id-get', null, callback);\n\t};\n\n\t/**\n * Get the guid of the article package currently edited\n *\n * @param {Function} callback function(Int), id of the current article\n */\n\tArticleCommunicator.prototype.getPackageGuid = function (callback) {\n\t\tPluginAPI.request('package-guid-get', null, callback);\n\t};\n\n\t/**\n * Clear the meta information summary\n *\n * @param {Function} callback function(Boolean), called when meta data has been cleared\n */\n\tArticleCommunicator.prototype.clearMetaInfo = function (callback) {\n\t\tPluginAPI.request('article-metainfo-clear', null, callback);\n\t};\n\n\t/**\n * Get tags used in the article\n *\n * @param {Function} callback function([Object Tag]), array with tags connected to an article\n */\n\tArticleCommunicator.prototype.getTags = function (callback) {\n\t\tPluginAPI.request('article-tags-get', null, callback);\n\t};\n\n\t/**\n * Retrieve custom meta value for the article\n *\n * @param {String} name Name of the custom meta value\n * @param {Function} callback function(Object), the parameter is an object containing the given custom meta value\n */\n\tArticleCommunicator.prototype.getCustomMeta = function (name, callback) {\n\t\tPluginAPI.request('article-custom-meta-get', {\n\t\t\tname: name\n\t\t}, callback);\n\t};\n\n\t/**\n * Set custom meta value for the article\n *\n * @param {String} name Name of the meta value\n * @param {Object} value Value to set\n * @param {Function} callback function()\n */\n\tArticleCommunicator.prototype.setCustomMeta = function (name, value, callback) {\n\t\tPluginAPI.request('article-custom-meta-set', {\n\t\t\tname: name,\n\t\t\tvalue: value\n\t\t}, callback);\n\t};\n\n\t/**\n * Marks article model as having meta data changes\n *\n * @param {Function} callback function()\n */\n\tArticleCommunicator.prototype.setMetaChanged = function (callback) {\n\t\tPluginAPI.request('article-meta-changed', null, callback);\n\t};\n\n\t/**\n * Set tags for the article\n *\n * @param {Array} tags List of tags that should be set\n * @param {Boolean} save Set to true to force save once the tags are updated\n * @param {Function} callback function(Boolean), called when tags have been set\n */\n\tArticleCommunicator.prototype.setTags = function (tags, save, callback) {\n\t\tPluginAPI.request('article-tags-set', {\n\t\t\tsave: save,\n\t\t\ttags: tags\n\t\t}, callback);\n\t};\n\n\t/**\n * Add tag for the article\n *\n * @param {Array} tags Tags to be added\n * @param {Function} errorFunction called if error\n * @param {Function} callback function(Boolean), called when tag has been set\n */\n\tArticleCommunicator.prototype.addTags = function (tags, errorFunction, callback) {\n\t\tPluginAPI.request('article-tags-add', {\n\t\t\ttags: tags,\n\t\t\tonError: errorFunction\n\t\t}, callback);\n\t};\n\n\t/**\n * Add tag for the article\n *\n * @param {String} tag Tag to be added\n * @param {Function} errorFunction called if error\n * @param {Function} callback function(Boolean), called when tag has been set\n */\n\tArticleCommunicator.prototype.addTag = function (tag, errorFunction, callback) {\n\t\tPluginAPI.request('article-tags-add', {\n\t\t\ttags: [tag],\n\t\t\tonError: errorFunction\n\t\t}, callback);\n\t};\n\n\t/**\n * Add tags for the article\n *\n * @param {String} tags Tags to be added\n * @param {Function} errorFunction called if error\n * @param {Function} callback function(Boolean), called when tag has been set\n */\n\tArticleCommunicator.prototype.addTags = function (tags, errorFunction, callback) {\n\t\tPluginAPI.request('article-tags-add', {\n\t\t\ttags: tags,\n\t\t\tonError: errorFunction\n\t\t}, callback);\n\t};\n\n\t/**\n * Remove tag from article\n *\n * @param {String} tag Tag to remove\n * @param {Function} callback function(Boolean), called when tag has been removed\n */\n\tArticleCommunicator.prototype.removeTag = function (tag, callback) {\n\t\tPluginAPI.request('article-tags-remove', {\n\t\t\ttag: tag\n\t\t}, callback);\n\t};\n\n\t/**\n * Get the selected categories\n *\n * @param {Function} callback function([String]), array with category ids\n */\n\tArticleCommunicator.prototype.getSelectedCategories = function (callback) {\n\t\tPluginAPI.request('article-categories-selected-get', null, callback);\n\t};\n\n\t/**\n * Save the currently selected categories\n *\n * @param {Function} callback function(Boolean), called when categories has been saved\n */\n\tArticleCommunicator.prototype.saveCategories = function (callback) {\n\t\tthis.getSelectedCategories(function (categories) {\n\t\t\tthis.setCategories(categories, callback);\n\t\t});\n\t};\n\n\t/**\n * Set selected categories\n *\n * @param {Array} categories List of category IDs that should be set\n * @param {Function} callback function(Boolean), called when categories have been set\n */\n\tArticleCommunicator.prototype.setCategories = function (categories, callback) {\n\t\tPluginAPI.request('article-categories-selected-set', {\n\t\t\tcategories: categories\n\t\t}, callback);\n\t};\n\n\t/**\n * Add the given categories to the list of categories\n *\n * @param {Array} categories List of category IDs to add\n * @param {Function} callback function(Boolean), called when the categories have been set\n */\n\tArticleCommunicator.prototype.addCategories = function (categories, callback) {\n\n\t\tPluginAPI.request('article-categories-add', {\n\t\t\tcategories: categories\n\t\t}, callback);\n\t};\n\n\t/**\n * Remove the given categories from the list of categories\n *\n * @param {Array} categories List of category IDs to remove\n * @param {Function} callback function(Boolean), called when the categories have been removed\n */\n\tArticleCommunicator.prototype.removeCategories = function (categories, callback) {\n\t\tPluginAPI.request('article-categories-remove', {\n\t\t\tcategories: categories\n\t\t}, callback);\n\t};\n\n\t/**\n * Set the main category of the current article\n *\n * @param {Number} category The ID of the category to set as the main category\n * @param {Function} callback function(Boolean), called when the main category has been set\n */\n\tArticleCommunicator.prototype.setMainCategory = function (category, callback) {\n\t\tPluginAPI.request('article-categories-main-set', {\n\t\t\tcategory: category\n\t\t}, callback);\n\t};\n\n\t/**\n * Get the source set for the article\n *\n * @param {Function} callback function(String), name of the source\n */\n\tArticleCommunicator.prototype.getSource = function (callback) {\n\n\t\tPluginAPI.request('article-source-get', null, callback);\n\t};\n\n\t/**\n * Set the source for the article\n *\n * @param {String} value The new value to be set as source\n * @param {Function} callback function(Boolean), called when the source has been set\n */\n\tArticleCommunicator.prototype.setSource = function (value, callback) {\n\t\tPluginAPI.request('article-source-set', {\n\t\t\tsource: value\n\t\t}, callback);\n\t};\n\n\t/**\n * Get the status for the article\n *\n * @param {Function} callback function(String), current status\n */\n\tArticleCommunicator.prototype.getStatus = function (callback) {\n\t\tPluginAPI.request('article-status-get', null, callback);\n\t};\n\n\t/**\n * Set the status for the article\n *\n * @param {String} status The new status to be set (draft, waiting, published)\n * @param {Function} callback function(Boolean), called when the source has been set\n */\n\tArticleCommunicator.prototype.setStatus = function (status, callback) {\n\t\tPluginAPI.request('article-status-set', {\n\t\t\tstatus: status\n\t\t}, callback);\n\t};\n\n\t/**\n * Get the published-date\n *\n * @param {Function} callback function(String), current published datetime\n */\n\tArticleCommunicator.prototype.getPublishedDatetime = function (callback) {\n\t\tPluginAPI.request('article-published-get', null, callback);\n\t};\n\n\t/**\n * Set the published-date\n *\n * @param {String} published Date to be set (YYYY-MM-DD HH:MM:SS)\n * @param {Function} callback function(Boolean), called when done\n */\n\tArticleCommunicator.prototype.setPublishedDatetime = function (published, callback) {\n\t\tPluginAPI.request('article-published-set', {\n\t\t\tpublished: published\n\t\t}, callback);\n\t};\n\n\t/**\n * Get the authors set in the article\n *\n * @param {Function} callback function([String]), currently set authors\n */\n\tArticleCommunicator.prototype.getAuthors = function (callback) {\n\t\tPluginAPI.request('article-authors-get', null, callback);\n\t};\n\n\t/**\n * Set authors for the article\n *\n * @param {Array} authors List of authors that should be set\n * @param {Function} callback function(Boolean), called when it has been set\n */\n\tArticleCommunicator.prototype.setAuthors = function (authors, callback) {\n\t\tPluginAPI.request('article-authors-set', {\n\t\t\tauthors: authors\n\t\t}, callback);\n\t};\n\n\t/**\n * Add the given authors to the list of authors\n *\n * @param {Array} authors List of authors to add\n * @param {Function} callback function(Boolean), called when it has been set\n */\n\tArticleCommunicator.prototype.addAuthors = function (authors, callback) {\n\t\tPluginAPI.request('article-authors-add', {\n\t\t\tauthors: authors\n\t\t}, callback);\n\t};\n\n\t/**\n * Remove the given authors from the list of authors\n *\n * @param {Array} authors List of authors to remove\n * @param {Function} callback function([String]), author list as it is after the authors has been removed\n */\n\tArticleCommunicator.prototype.removeAuthors = function (authors, callback) {\n\t\tPluginAPI.request('article-authors-remove', {\n\t\t\tauthors: authors\n\t\t}, callback);\n\t};\n\n\t/**\n * Set the keyword-list on the article\n *\n * @param {Array} keywords List of keywords to add\n * @param {Function} callback Function to call when keywords have been set\n */\n\tArticleCommunicator.prototype.setKeywords = function (keywords, callback) {\n\t\tPluginAPI.request('article-keywords-set', {\n\t\t\tkeywords: keywords\n\t\t}, callback);\n\t};\n\n\t/**\n * Get the current set of keywords on the article\n *\n * @param {Function} callback Function to call with the result\n */\n\tArticleCommunicator.prototype.getKeywords = function (callback) {\n\t\tPluginAPI.request('article-keywords-get', null, callback);\n\t};\n\n\t/**\n * Gets the main article content\n *\n * @param {Function} callback function(Object Content)\n */\n\tArticleCommunicator.prototype.getCurrentContent = function (callback) {\n\t\tPluginAPI.request('article-content-get', null, callback);\n\t};\n\n\t/**\n * Updates main article content\n *\n * @param {String} content The new content for the article\n * @param {Function} callback function(Boolean), called when it has been set\n */\n\tArticleCommunicator.prototype.setCurrentContent = function (content, callback) {\n\t\tPluginAPI.request('article-content-set', {\n\t\t\tcontent: content\n\t\t}, callback);\n\t};\n\t/**\n * Updates sub article content\n *\n * @param {Integer} articleId Sub article id\n * @param {String} content The new content for the sub article\n * @param {Function} callback function(Boolean), called when it has been set\n */\n\tArticleCommunicator.prototype.setSubArticleContent = function (articleId, content, callback) {\n\t\tPluginAPI.request('sub-article-content-set', {\n\t\t\tarticleId: articleId,\n\t\t\tcontent: content\n\t\t}, callback);\n\t};\n\n\t/**\n * Get the article type of the current article\n *\n * @param {Function} callback function(Int)\n */\n\tArticleCommunicator.prototype.getArticletypeId = function (callback) {\n\t\tPluginAPI.request('article-type-get', null, callback);\n\t};\n\n\t/**\n * Set the article type of the current article\n *\n * @param {Number} articletypeId The new article type of the article\n * @param {Function} callback function(Boolean), called when it has been set\n */\n\tArticleCommunicator.prototype.setArticletypeId = function (articletypeId, callback) {\n\t\tPluginAPI.request('article-type-set', {\n\t\t\tarticletype: articletypeId\n\t\t}, callback);\n\t};\n\n\t/**\n * Maximize the plugin view\n *\n * @param {String} title Title to give the maximized view\n * @param {function} onClose Function to call when the window is closed/minimized\n\t * @param {Function} callback function(Boolean)\n */\n\tArticleCommunicator.prototype.maximizePluginWindow = function (title, onClose, callback) {\n\t\tconst event = 'editor-pane-close-' + new Date().getTime();\n\n\t\tPluginAPI.request('editor-pane-maximize', {\n\t\t\ttitle: title,\n\t\t\tevent: event\n\t\t}, callback);\n\t\tPluginAPI.eventListeners.removeAll(event);\n\t\tPluginAPI.eventListeners.add(event, onClose);\n\t};\n\n\t/**\n * @deprecated use maximizePluginWindow instead\n * @param {String} title Window title\n * @param {function} onClose Callback to call after everything is done\n\t * @param {Function} callback function(Boolean), called when it has been set\n *\n */\n\tArticleCommunicator.prototype.maximizeAppWindow = function (title, onClose, callback) {\n\t\tthis.maximizePluginWindow(title, onClose, callback);\n\t};\n\n\t/**\n * Restore the plugin pane to the default size\n *\n * @param {function} callback Callback to call after everything is done\n */\n\tArticleCommunicator.prototype.restorePluginWindow = function (callback) {\n\t\tPluginAPI.request('restore-app-window', {}, callback);\n\t};\n\n\t/**\n * Restore the plugin pane to the default size\n *\n * @deprecated use restorPluginWindow instead\n * @param {function} callback Callback to call after everything is done\n */\n\tArticleCommunicator.prototype.restoreAppWindow = function (callback) {\n\t\tthis.restorePluginWindow(callback);\n\t};\n\n\t/**\n * Get the current byline\n *\n * @param {function} callback function(String), xml string with the current byline\n */\n\tArticleCommunicator.prototype.getByline = function (callback) {\n\t\tPluginAPI.request('article-byline-get', null, callback);\n\t};\n\n\t/**\n * Set the byline\n *\n * @param {String} byline XML version of byline to use\n * @param {Boolean} save If true, force save after updating byline information\n * @param {Function} callback function(Boolean), called when it has been set\n */\n\tArticleCommunicator.prototype.setByline = function (byline, save, callback) {\n\t\tPluginAPI.request('article-byline-set', {\n\t\t\tsave: save,\n\t\t\tbyline: byline\n\t\t}, callback);\n\t};\n\n\t/**\n * Set geolocation\n *\n * @param {Object} geolocations The location to set\n * @param {Function} callback function(Boolean), called when it has been set\n */\n\tArticleCommunicator.prototype.setGeolocations = function (geolocations, callback) {\n\t\tPluginAPI.request('article-geolocations-set', {\n\t\t\tgeolocations: geolocations\n\t\t}, callback);\n\t};\n\n\t/**\n * Get geolocation\n *\n * @param {Function} callback function(Object), retrieves the currently set geo location\n */\n\tArticleCommunicator.prototype.getGeolocations = function (callback) {\n\t\tPluginAPI.request('article-geolocations-get', null, callback);\n\t};\n\n\t/**\n * Fetches a list of all properties available to an article.\n *\n * @param {Function} callback Callback called with an array of property objects.\n */\n\tArticleCommunicator.prototype.getProperties = function (callback) {\n\t\tPluginAPI.request('article-properties-get', null, callback);\n\t};\n\n\t/**\n * Updates and saves one or more property values. The input is a simple object with property names and their\n * new value. The supplied callback is called with an updated list of properties.\n *\n * @example\n * PluginAPI.Article.setProperties({\n * fooProperty: \"bar\",\n * barProperty: \"foo\"\n * }, function(properties) {\n * // Returns a complete and updated list of properties.\n * })\n *\n * @param {Object} properties An object of property names and corresponding values.\n * @param {Function} callback Callback called with an updated list of properties.\n */\n\tArticleCommunicator.prototype.setProperties = function (properties, callback) {\n\t\tPluginAPI.request('article-properties-set', {\n\t\t\tproperties: properties\n\t\t}, callback);\n\t};\n\n\t/**\n * Updates and saves a single property.\n *\n * @param {String} name The property to update.\n * @param {Object} value The updated value.\n * @param {Function} callback Callback called with an updated list of properties.\n */\n\tArticleCommunicator.prototype.setProperty = function (name, value, callback) {\n\t\tconst data = {};\n\t\tdata[name] = value;\n\t\tPluginAPI.request('article-properties-set', {\n\t\t\tproperties: data\n\t\t}, callback);\n\t};\n\n\tArticleCommunicator.prototype.getTopic = function (callback) {\n\t\tPluginAPI.request('article-topic-get', null, callback);\n\t};\n\n\tArticleCommunicator.prototype.setTopic = function (name, callback) {\n\t\tPluginAPI.request('article-topic-set', {\n\t\t\ttopic: name\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Get article package data, including content of sub articles\n\t *\n\t * @param {Function} callback function(Object)\n\t */\n\tArticleCommunicator.prototype.getPackage = function (callback) {\n\t\tPluginAPI.request('package-get', null, callback);\n\t};\n\n\treturn new ArticleCommunicator();\n\n};\n","/**\n * @example\n * PluginAPI.on('afterCreate', function() {\n * PluginAPI.Article.setSource('Ny Times');\n * });\n * PluginAPI.on('beforeSave', function() {\n * if (!articleIsAwesome()) {\n * return false;\n * }\n * });\n *\n * @description\n *\n *

DrPublish provides a large set of default events that an plugin can listen for. All events that start their name with 'before' can be stopped by an plugin. This is done by returning 'false' from the callback function, as in the 'beforSave' example given bellow.

\n *

Other plugins can also supply their own events using the PluginAPI.emit(...) function. Documention on these events are up to each plugin to create.

\n *

Available Events

\n *

addCategory

\n *
\n *

triggered after a category has been added to the article

\n *
\n *

addTag

\n *
\n *

triggered after a tag had been added to the article

\n *
\n *

pluginWindowMaximized

\n *
\n *

triggered when the plugin pane is maximized

\n *
\n *

pluginWindowRestored

\n *
\n *

triggered when the plugin pane is restored to its' original size

\n *
\n *

changedCustomMeta

\n *
\n *

triggered when a custom meta property is changed/set, parameter is an object with property name and value

\n *
\n *

receivedFocus

\n *
\n *

triggered when a plugin receives focus. Receives a parameter object that has two predefined values: previousPluginName - name of previous plugin, givenFocus - true when focus was sent from another plugin. The parameter object can also contain other keys supplied by the plugin losing focus.

\n *
\n *

afterCreate

\n *
\n *

triggered after a new article has been created

\n *
\n *

beforeDelete

\n *
\n *

triggered before an article is deleted

\n *
\n *

afterDelete

\n *
\n *

triggered after an article has been deleted

\n *
\n *

afterLoad

\n *
\n *

triggered after an article has been loaded

\n *
\n *

afterPublish

\n *
\n *

triggered after an article has been published

\n *
\n *

afterSave

\n *
\n *

triggered after an article has been saved

\n *
\n *

beforeCreate

\n *
\n *

triggered before a new article is created

\n *
\n *

beforeLoad

\n *
\n *

triggered before an article is loaded into the editor

\n *
\n *

beforePreview

\n *
\n *

triggered before the article is opened in the preview

\n *
\n *

beforeSave

\n *
\n *

triggered before an article is saved

\n *
\n *

beforePublish

\n *
\n *

triggered before an article is published

\n *
\n *

editorFocus

\n *
\n *

triggered when an editor gets focus

\n *
\n *

editorUnfocus

\n *
\n *

triggered when an editor loses focus

\n *
\n *

editorsLostFocus

\n *
\n *

triggered when all editors loses focus

\n *
\n *

editorReady

\n *
\n *

triggered when the editor has been fully loaded and is ready for input

\n *
\n *

modifiedContent

\n *
\n *

triggered whenever content changes in the article

\n *
\n *

elementRemoved

\n *
\n *

triggered when a plugin element from the current plugin is removed, receives an object with element id as a parameter

\n *
\n *

pluginElementClicked

\n *
\n *

triggered when someone clicks on a plugin element in the editor

\n *
\n *

pluginElementSelected

\n *
\n *

triggers when someone selects a plugin element in the editor

\n *
\n *

pluginElementDeselected

\n *
\n *

triggered when someone deselects a plugin element in the editor

\n *
\n */\nclass Listeners {\n\tconstructor() {\n\t\tthis._listeners = {};\n\t}\n\n\n\t/**\n\t * @deprecated Use PluginAPI.on(...) instead\n\t * @param {Object} listeners\n\t */\n\taddAll(listeners) {\n\t\tconst PluginAPI = require('./PluginAPI');\n\t\t'use strict';\n\t\tconst createCallback = function (callback) {\n\t\t\treturn function (data) {\n\t\t\t\tcallback(data.data);\n\t\t\t};\n\t\t};\n\t\tfor (const eventName in listeners) {\n\t\t\tif (listeners.hasOwnProperty(eventName)) {\n\t\t\t\tconst callback = listeners[eventName];\n\t\t\t\tconst callWrapper = createCallback(callback);\n\t\t\t\tPluginAPI.on(eventName, callWrapper);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Adds a new listener\n\t *\n\t * @param {String} event Event name\n\t * @param {Function} callback Function to call when an even of the type is received\n\t * @return {number}\n\t */\n\tadd(event, callback) {\n\n\t\tif (typeof callback !== 'function') {\n\t\t\tthrow new Error('not a function');\n\t\t}\n\n\t\tif (this._listeners[event] === undefined) {\n\t\t\tthis._listeners[event] = [];\n\t\t}\n\n\t\tthis._listeners[event].push(callback);\n\t\treturn this._listeners[event].length - 1;\n\t}\n\n\t/**\n\t * Removes the listener at the given index\n\t *\n\t * @param {String} event Event type\n\t * @param {Function} index The index of the event handler to remove\n\t */\n\tremove(event, index) {\n\n\t\tif (this._listeners[event] === undefined || this._listeners[event][index] === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\t/*\n\t\t * Set to null instead of remove to retain callback indexes\n\t\t */\n\t\tthis._listeners[event][index] = false;\n\t}\n\n\t/**\n\t * Removes all listeners for the given event type, or if !event then removes all listeners\n\t *\n\t * @param {String} event Event type to remove handlers for (!event for all)\n\t */\n\tremoveAll(event) {\n\t\tif (!event) {\n\t\t\tthis._listeners = [];\n\t\t} else {\n\t\t\tthis._listeners[event] = [];\n\t\t}\n\t}\n\n\t/**\n\t * Notifies all registered listeners that an event has occurred\n\t *\n\t * @param {String} event Event type\n\t * @param {Object} payload The event data\n\t * @return {Boolean}\n\t */\n\tnotify(event, payload) {\n\t\tlet returnValue = true;\n\t\tif (this._listeners[event] === undefined) {\n\t\t\treturn returnValue;\n\t\t}\n\n\t\t// If the payload is an object with a key data, we use that value as the payload we pass to the listener functions.\n\t\t// This is needed as we have some inconsistencies in how we pass data around. This normalization should preferably\n\t\t// be done at the call site.\n\t\tthis._listeners[event].forEach((listenerFn) => {\n\t\t\tif (typeof listenerFn !== 'function') {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlet res = null;\n\t\t\tif (payload && payload.params && payload.params === true) {\n\t\t\t\tres = listenerFn.apply(null, payload.data);\n\t\t\t} else if (typeof payload === 'object' && payload !== null && typeof payload.data !== 'undefined') {\n\t\t\t\tres = listenerFn(payload.data);\n\t\t\t} else {\n\t\t\t\tres = listenerFn(payload);\n\t\t\t}\n\t\t\tif (res === false) {\n\t\t\t\treturnValue = false;\n\t\t\t}\n\t\t});\n\t\treturn returnValue;\n\t}\n\n}\n\nmodule.exports = Listeners;\n","/* eslint max-statements: [\"error\", 100000000] */\n/* eslint complexity: [\"error\", 100000000] */\n/* global pm */\n\nconst ah5Communicator = require('./AH5Communicator');\nconst articleCommunicator = require('./ArticleCommunicator');\nconst Listeners = require('./Listeners');\n\nconst PluginAPI = (function () {\n\n\t/**\n\t *\n\t * Namespace for all public DrPublish methods available from plugins.\n\t *\n\t * @class\n\t * @classdesc The basic API object\n\t * @exports PluginAPI\n\t *\n\t */\n\tconst Api = function () {\n\n\t\tconst queryParameters = {};\n\t\twindow.location.search.substr(1).split('&').forEach((queryPair) => {\n\t\t\tqueryParameters[queryPair.split('=')[0]] = queryPair.split('=')[1];\n\t\t});\n\n\n\t\tthis.DEBUG = false;\n\n\t\tthis.Version = '1.0';\n\t\tthis.Editor = null;\n\t\tthis.Article = null;\n\t\tthis.errorListeners = new Listeners();\n\t\tthis.eventListeners = new Listeners();\n\t\tthis.appName = queryParameters.appName || '';\n\t\tthis.jwt = queryParameters.jwt || '';\n\t\tthis.standAlone = queryParameters.standAlone && queryParameters.standAlone === 'true' || false;\n\t\tthis.selectedPluginElement = null;\n\n\t\tconst self = this;\n\n\t\tpm.bind('event', (data) => {\n\t\t\tconst createEventFunction = function (eventName) {\n\t\t\t\treturn function (data) {\n\t\t\t\t\tPluginAPI.request(eventName, data);\n\t\t\t\t};\n\t\t\t};\n\t\t\tconst updateObject = function (data) {\n\t\t\t\tfor (const key in data) {\n\t\t\t\t\tif (data.hasOwnProperty(key)) {\n\t\t\t\t\t\tif (typeof data[key] === 'object' && data[key] !== null && data[key].type === 'function') {\n\t\t\t\t\t\t\tdata[key] = createEventFunction(data[key].eventKey);\n\t\t\t\t\t\t} else if (typeof data[key] === 'object' && data[key] !== null && typeof data[key].map === 'function') {\n\t\t\t\t\t\t\tdata[key] = data[key].map(updateObject);\n\t\t\t\t\t\t} else if (typeof data[key] === 'object' && data[key] !== null) {\n\t\t\t\t\t\t\tdata[key] = updateObject(data[key]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn data;\n\t\t\t};\n\t\t\tdata.data = updateObject(data.data);\n\n\t\t\tdata = self.eventListeners.notify(data.type, data.data);\n\t\t\tif (typeof data === 'undefined') {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (data === false) {\n\t\t\t\treturn {'abort': true};\n\t\t\t}\n\t\t\treturn data;\n\t\t}, '*');\n\t};\n\n\t/**\n\t * Dispatches a request to DrPublish, and returns the reply to callback On error, notifies all error listeners based on the index .type of the thrown object\n\t *\n\t * @param {String} callSpec What do you want to call?\n\t * @param {Object} data The data attached to the request\n\t * @param {Function} callback The function to call upon return\n\t */\n\tApi.prototype.request = function (callSpec, data, callback) {\n\t\tconst self = this;\n\t\tif (this.DEBUG) {\n\t\t\tconsole.info(this.getPluginName() + ': Requesting ' + callSpec + ' from parent with data', data);\n\t\t}\n\n\t\tif (!data) {\n\t\t\tdata = {};\n\t\t}\n\n\t\tif (typeof callback === 'undefined') {\n\t\t\tcallback = null;\n\t\t}\n\n\t\tif (typeof data.length === 'number') {\n\t\t\tdata = {data: data};\n\t\t}\n\n\t\tdata['src_app'] = this.getPluginName();\n\n\t\tconst createEventFunction = function (func, eventKey) {\n\t\t\treturn function () {\n\t\t\t\tself.eventListeners.remove(eventKey, eventKey);\n\t\t\t\treturn func.apply(null, arguments);\n\t\t\t};\n\t\t};\n\n\n\t\tconst createCallbackObject = function (key, callback) {\n\t\t\tconst random = Math.floor(Math.random() * 1000);\n\t\t\tconst eventKey = key + random + 'functioncallback' + (new Date()).getTime();\n\t\t\tconst eventFunction = createEventFunction(callback, eventKey);\n\t\t\tself.eventListeners.add(eventKey, eventFunction);\n\t\t\treturn {\n\t\t\t\ttype: 'function',\n\t\t\t\teventKey: eventKey\n\t\t\t};\n\t\t};\n\n\t\tconst updateObject = function (data) {\n\t\t\tfor (const key in data) {\n\t\t\t\tif (data.hasOwnProperty(key)) {\n\t\t\t\t\tconst val = data[key];\n\t\t\t\t\tif (typeof val === 'function') {\n\t\t\t\t\t\tdata[key] = createCallbackObject(key, val);\n\t\t\t\t\t} else if (typeof val === 'object' && val !== null && typeof val.map === 'function') {\n\t\t\t\t\t\tdata[key] = val.map(updateObject);\n\t\t\t\t\t} else if (typeof val === 'object' && val !== null) {\n\t\t\t\t\t\tdata[key] = updateObject(val);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn data;\n\t\t};\n\t\tdata = updateObject(data);\n\n\t\tpm({\n\t\t\ttarget: parent,\n\t\t\ttype: callSpec,\n\t\t\tdata: data,\n\t\t\tsuccess: callback,\n\t\t\terror: (data) => {\n\t\t\t\tself.errorListeners.notify(data.type, data);\n\t\t\t},\n\t\t\torigin: '*', // TODO: Find a way of avoiding all-origins\n\t\t\thash: false\n\t\t});\n\t};\n\n\n\t/**\n\t * Creates a new tag\n\t *\n\t * @param {String} tag The tag to create\n\t * @param {Function} callback function(Boolean)\n\t */\n\tApi.prototype.openTagCreationDialog = function (tag, callback) {\n\t\tthis.request('create-tag', {\n\t\t\ttag: tag\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Reloads the plugins's iframe\n\t */\n\tApi.prototype.reloadIframe = function () {\n\n\t\tthis.request('app-reload', {\n\t\t\tapp: this.getPluginName()\n\t\t});\n\t};\n\n\t/**\n\t * Get the name of the loaded plugin\n\t *\n\t * @return {String} The name of the plugin, or false if it couldn't be detected\n\t */\n\tApi.prototype.getPluginName = function () {\n\t\treturn this.appName;\n\t};\n\n\t/**\n\t * Get the name of the loaded plugin\n\t * @deprecated: use getPluginName instead\n\t * @return {String} The name of the plugin, or false if it couldn't be detected\n\t */\n\tApi.prototype.getAppName = function () {\n\t\treturn this.getPluginName();\n\t};\n\n\t/**\n\t * Set the name of the plugin\n\t *\n\t * @param {String} name The name of the plugin\n\t */\n\tApi.prototype.setPluginName = function (name) {\n\t\tthis.appName = name;\n\t};\n\n\t/**\n\t * Set the name of the plugin\n\t * @deprecated: use setPluginName instead\n\t *\n\t * @param {String} name The name of the plugin\n\t */\n\tApi.prototype.setAppName = function (name) {\n\t\tthis.setPluginName(name);\n\t};\n\n\t/**\n\t * Show info-message to the user\n\t *\n\t * @param {String} msg Message to be displayed\n\t */\n\tApi.prototype.showInfoMsg = function (msg) {\n\n\t\tthis.request('show-message-info', {\n\t\t\tmessage: msg\n\t\t});\n\t};\n\n\t/**\n\t * Show warning-message to the user\n\t *\n\t * @param {String} msg Message to be displayed\n\t */\n\tApi.prototype.showWarningMsg = function (msg) {\n\n\t\tthis.request('show-message-warning', {\n\t\t\tmessage: msg\n\t\t});\n\t};\n\n\t/**\n\t * Show error-message to the user\n\t *\n\t * @param {String} msg Message to be displayed\n\t */\n\tApi.prototype.showErrorMsg = function (msg) {\n\n\t\tthis.request('show-message-error', {\n\t\t\tmessage: msg\n\t\t});\n\t};\n\n\t/**\n\t * Show the loader\n\t *\n\t * @param {String} msg Message to display in progress loader\n\t */\n\tApi.prototype.showLoader = function (msg) {\n\t\tthis.request('show-loader', {\n\t\t\tmessage: msg\n\t\t});\n\t};\n\n\t/**\n\t * Hide the loader\n\t */\n\tApi.prototype.hideLoader = function () {\n\t\tthis.request('hide-loader');\n\t};\n\n\n\t/**\n\t * Loads an old revision of an article\n\t *\n\t * @param {Number} id The id of the revision to load\n\t * @param {Function} callback The function to call when the new revision has been loaded\n\t * @private\n\t */\n\tApi.prototype.__loadArticleRevision = function (id, callback) {\n\t\tthis.request('load-revision', {\n\t\t\trevision: id\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Creates a new tag\n\t *\n\t * @param {String} tag JSON object with the tag to create, must contain tagTypeId and name properties\n\t * @param {Function} callback function(Boolean)\n\t */\n\tApi.prototype.createTag = function (tag, callback) {\n\t\tthis.request('tag-create', {\n\t\t\ttag: tag\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Sends a query to DrLib\n\t *\n\t * @example\n\t * PluginAPI.searchDrLib({\n\t * query: 'articles.json?q=awesome',\n\t * secure: true,\n\t * success: function(data) {\n\t * data.items.forEach(doStuffWithArticle);\n\t * },\n\t * error: function(data) {\n\t * console.warn('something went wrong');\n\t * }\n\t * })\n\t *\n\t * @param {Object} data Object with three properties; 'query' which is the query to send to DrLib, 'success' which is the callback to execute on success, and 'secure' a boolean to add the internal API key to the query and thus allow searching on unpublished article. This callback's parameter is an object which is the query result as an object. See the json output of DrLib to learn more about this object\n\t * @param {Function} callback function(Boolean)\n\t *\n\t */\n\tApi.prototype.searchDrLib = function (data, callback) {\n\t\tthis.request('drlib-search', {\n\t\t\tquery: data.query,\n\t\t\taccess: data.access,\n\t\t\tsecure: data.secure,\n\t\t\tsuccess: data.success,\n\t\t\terror: data.error\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Generates proper html code to represent the dom element. This is NOT an asynchronous function\n\t *\n\t * @param {Object} dom The dom node to convert\n\t * @return {String} The html code\n\t */\n\t// TODO: This function should also be able to take a DOMElement or similar.\n\tApi.prototype.convertDomToHTML = function (dom) {\n\t\tif (typeof dom === 'object' && typeof dom.wrap === 'function') {\n\t\t\treturn dom.wrap('
').parent().html();\n\t\t} else {\n\t\t\tconst domClone = dom.cloneNode(true);\n\t\t\tconst wrapper = document.createElement('div');\n\t\t\twrapper.appendChild(domClone);\n\t\t\treturn wrapper.innerHTML;\n\t\t}\n\t};\n\n\t/**\n\t * Generates an url to a published article\n\t *\n\t * @param {String} id The id of the article to generate url for\n\t * @param {Function} callback function(String), where the parameter is the generated url\n\t */\n\tApi.prototype.generateArticleUrl = function (id, callback) {\n\t\tthis.request('generate-article-url', {\n\t\t\tid: id\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Extends the PluginAPI with custom functionality that other plugins can use\n\t *\n\t * @param {String} group Group name for functionality to add\n\t * @param {String} name Name of the specific function to add\n\t * @param {Function} action function(Object) Function to call when the API is invoked, recieves one parameter as given in PluginAPI.callExtendedApi and return value is passed back to the caller\n\t */\n\tApi.prototype.extendApi = function (group, name, action) {\n\t\tconst self = this;\n\t\tthis.request('extend-api', {\n\t\t\tgroup: group,\n\t\t\tname: name,\n\t\t\taction: (data) => {\n\t\t\t\tconst a = action(data.data);\n\t\t\t\tself.request(data.eventKey, {'data': a});\n\t\t\t}\n\t\t});\n\t};\n\n\t/**\n\t * Call the extended PluginAPI\n\t *\n\t * @param {String} group Group name for functionality to call\n\t * @param {String} name Name of the specific function to call\n\t * @param {Object} data Data object to pass as parameter to the api call\n\t * @param {Function} callback function(Object) Function to recieve the API response, parameter is the response from the API call\n\t */\n\tApi.prototype.callExtendedApi = function (group, name, data, callback) {\n\t\tthis.request('call-extended-api', {\n\t\t\tgroup: group,\n\t\t\tname: name,\n\t\t\tdata: data,\n\t\t\tcallback: callback\n\t\t});\n\t};\n\n\t/**\n\t * Gets logged in user\n\t *\n\t * @param {Function} callback function(Object)\n\t */\n\tApi.prototype.getCurrentUser = function (callback) {\n\t\tthis.request('get-current-user', null, callback);\n\t};\n\n\t/**\n\t * Get configuration information about the plugin\n\t *\n\t * @param {Function} callback function(Object)\n\t */\n\tApi.prototype.getConfiguration = function (callback) {\n\t\tthis.request('get-configuration', null, callback);\n\t};\n\n\t/**\n\t * Get DrPublish configuration\n\t *\n\t * @param {Function} callback function(Object)\n\t */\n\tApi.prototype.getDrPublishConfiguration = function (callback) {\n\t\tthis.request('get-drpublish-configuration', null, callback);\n\t};\n\n\t/**\n\t * Set configuration information about the plugin\n\t *\n\t * @param {Object} config The configuration object to save\n\t * @param {Object} options Object, can have three keys.\n\t * 'onlyPublication' (boolean) If true the configuration is set for the current publication only\n\t * 'success' (function) Called if the configuration was saved successfully\n\t * 'error' (function) Called if there was an error, recieves and error object as first parameter\n\t * @param {Function} callback function()\n\t */\n\tApi.prototype.setConfiguration = function (config, options, callback) {\n\t\t// support old function signature\n\t\tif (typeof options === 'boolean') {\n\t\t\toptions = {\n\t\t\t\tonlyPublication: options\n\t\t\t};\n\t\t} else if (typeof options !== 'object' || options === null) {\n\t\t\toptions = {};\n\t\t}\n\t\tconst data = {\n\t\t\tconfig: config,\n\t\t\tonlyPublication: typeof options.onlyPublication === 'boolean' ? options.onlyPublication : false,\n\t\t\tsuccess: typeof options.success === 'function' ? options.success : null,\n\t\t\terror: typeof options.error === 'function' ? options.error : null\n\t\t};\n\t\tthis.request('set-configuration', data, callback);\n\t};\n\n\t/**\n\t * Emits an event to DrPublish, and possibly other apps\n\t *\n\t * @param {String} name Name of the event\n\t * @param {String} data Data object to send with the event\n\t */\n\tApi.prototype.emit = function (name, data) {\n\t\tthis.request('emit-api-event', {\n\t\t\tname: name,\n\t\t\tdata: data\n\t\t});\n\t};\n\n\t/**\n\t * Listen for an event. If the callback returns false the event may cancel continued actions, e.g beforeSave can cancel article save. Look at documentation for Listeners to learn more.\n\t *\n\t * @param {String} name Name of the event\n\t * @param {Function} callback function(Object) Function to call when the event is triggered. Recieves one data object parameter of the form {source: , data: }\n\t */\n\tApi.prototype.on = function (name, callback) {\n\t\tconst self = this;\n\t\tself.eventListeners.add(name, callback);\n\t\tthis.request('on-api-event', {\n\t\t\tname: name\n\t\t});\n\t};\n\n\t/**\n\t * Increase the counter of actions required by the user, used to tell the user that the plugin requires input of some kind\n\t *\n\t * @param {Function} callback function(Object) function to call once the counter has been increased, returns the new counter value\n\t */\n\tApi.prototype.increaseRequiredActionCounter = function (callback) {\n\t\tthis.request('increase-required-action-counter', {}, callback);\n\t};\n\n\t/**\n\t * Decrease the counter of actions required by the user, used to tell the user that the plugin requires input of some kind\n\t *\n\t * @param {Function} callback function(Object) function to call once the counter has been decrease, returns current counter value\n\t */\n\tApi.prototype.decreaseRequiredActionCounter = function (callback) {\n\t\tthis.request('decrease-required-action-counter', {}, callback);\n\t};\n\n\t/**\n\t * Clear the counter of actions required by the user, used to tell the user that the plugin requires input of some kind\n\t *\n\t * @param {Function} callback function(Object) function to call once the counter has been cleared\n\t */\n\tApi.prototype.clearRequiredActionCounter = function (callback) {\n\t\tthis.request('clear-required-action-counter', {}, callback);\n\t};\n\n\t/**\n\t * Set the counter of actions required by the user, used to tell the user that the plugin requires input of some kind\n\t *\n\t * @param {Number} count The value to set the counter to\n\t * @param {Function} callback function(Object) function to call once the counter has been cleared\n\t */\n\tApi.prototype.setRequiredActionCounter = function (count, callback) {\n\t\tthis.request('set-required-action-counter', {count: count}, callback);\n\t};\n\n\t/**\n\t * Create a new instance of the Api class\n\t *\n\t * @private\n\t * @return {Object}\n\t */\n\tApi.prototype.create = function () {\n\t\treturn new Api();\n\t};\n\n\t/**\n\t * Create an embedded object of the given type\n\t *\n\t * @param {Number} typeId Type Id of the embedded object to create\n\t * @param {Function} callback function(embeddedObjectId) called once the object has been created, first parameter is the new embedded object id\n\t */\n\tApi.prototype.createEmbeddedObject = function (typeId, callback) {\n\t\tthis.request('create-embedded-object', {typeId: typeId, callback: callback});\n\t};\n\n\t/**\n\t * Get information about the available embedded object types\n\t *\n\t * @param {Function} callback function([Object]) recieves an array with objects describing the available embedded object types in the form of `{typeId: 'embedded object type id', cssClass: 'css class used to style the objects'}`\n\t */\n\tApi.prototype.getEmbeddedObjectTypes = function (callback) {\n\t\tthis.request('get-embedded-object-types', null, callback);\n\t};\n\n\t/**\n\t * Gives focus to another plugin\n\t *\n\t * @param {String} pluginName The name of the plugin to recieve focus\n\t * @param {Object} argument Optional option argument to pass along to the plugin recieving focus\n\t * @param {Boolean} start Flag to decide if the plugin should be started if it has not been loaded previously, default true\n\t * @return {Boolean}\n\t */\n\tApi.prototype.giveFocus = function (pluginName, argument, start) {\n\t\tif (typeof pluginName !== 'string') {\n\t\t\treturn false;\n\t\t}\n\t\tif (typeof start !== 'boolean') {\n\t\t\tstart = true;\n\t\t}\n\t\tthis.request('give-focus', {pluginName: pluginName, start: start, argument: argument});\n\t\treturn true;\n\t};\n\n\n\t/**\n\t * Hide the plugin, so it is no longer visible on the list of open plugins\n\t * @return {Boolean}\n\t */\n\tApi.prototype.hide = function () {\n\t\tthis.request('hide');\n\t\treturn true;\n\t};\n\n\t/**\n\t *

Creates a jQuery UI modal in the main editor window, detached from the plugin itself. Modals are unique on a\n\t * per-plugin basis, meaning that a plugin can only have a single modal at a time. Creating a new modal will\n\t * overwrite the previous.

\n\t *\n\t * See the official documentation for a list of available options.

\n\t *\n\t *

Note that you do not have direct access to the DOM of the modal. Use the provided helper methods to\n\t * manipulate or read from the modal:\n\t *

\n\t *

\n\t *\n\t * @example\n\t *\n\t * PluginAPI.createModal('

This is a modal

', {\n\t * buttons: {\n\t * Ok: function () {\n\t * alert('Ok!');\n\t * }\n\t * }\n\t * });\n\t *\n\t * PluginAPI.updateModal('

This is the same modal

');\n\t *\n\t * PluginAPI.createModal('

This is a brand new modal

', {\n\t * buttons: {\n\t * cancel: function() {\n\t * PluginAPI.closeModal(true);\n\t * }\n\t * }\n\t * });\n\t *\n\t * @param {String} content An HTML string\n\t * @param {Object} options A standard jQuery UI options object.\n\t * @return {Boolean}\n\t */\n\tApi.prototype.createModal = function (content, options) {\n\t\tthis.request('create-custom-modal', {content: content, options: options});\n\t\treturn true;\n\t};\n\n\t/**\n\t * Updates the HTML content of a live modal. Has no effect if the modal does not exist.\n\t *\n\t * @param {String} content An HTML string\n\t * @return {Boolean}\n\t */\n\tApi.prototype.updateModal = function (content) {\n\t\tthis.request('update-custom-modal', {content: content});\n\t\treturn true;\n\t};\n\n\t/**\n\t * Closes and optionally deletes the modal. Has no effect if the modal does not exists.\n\t *\n\t * @param {Boolean} destroy Whether or not to delete the modal\n\t * @return {Boolean}\n\t */\n\tApi.prototype.closeModal = function (destroy) {\n\t\tthis.request('close-custom-modal', {destroy: destroy});\n\t\treturn true;\n\t};\n\n\t/**\n\t * Returns the values of all input or select elements within a modal.\n\t *\n\t * The values are keyed by one of the following properties in order of priority: element ID, element name\n\t * or input type + index.\n\t *\n\t * @example\n\t * Given a modal with the following HTML content:\n\t *\n\t *
\n\t * \n\t * \n\t * \n\t *
\n\t *\n\t * getModalInputs would return:\n\t *\n\t * {\n\t * \"number-0\": {VALUE}\n\t * \"name\": {VALUE},\n\t * \"languages\": \"en\"\n\t * }\n\t *\n\t * @param {Function} callback\n\t */\n\tApi.prototype.getModalInputs = function (callback) {\n\t\tthis.request('get-custom-modal-inputs', null, callback);\n\t};\n\n\tApi.prototype.confirmAuthenticated = function () {\n\t\tthis.request('confirm-authenticated', {\n\t\t\tpluginName: this.appName\n\t\t});\n\t};\n\n\tApi.prototype.isStandAlone = function () {\n\t\treturn this.standAlone;\n\n\t};\n\n\t/**\n * Get the JWT as defined on DrPublish publication config. This token can be used to authenticate the request\n * @return {*|string}\n */\n\tApi.prototype.getJWT = function () {\n\t\treturn this.jwt;\n\t};\n\n\tApi.prototype.replaceEditorComponentsExtension = function (data) {\n\t\tthis.request('replace-editor-components-extension', data);\n\t};\n\n\tApi.prototype.clearEditorComponentsExtension = function (data) {\n\t\tthis.request('clear-editor-components-extension', data);\n\t};\n\n\tApi.prototype.highlightAnnotation = function (data) {\n\t\tthis.request('highlight-annotation', data);\n\t};\n\n\tApi.prototype.underemphasizeAnnotations = function (data) {\n\t\tthis.request('underemphasize-annotations', data);\n\t};\n\n\tApi.prototype.registerExternallyDefinedProperties = function (data) {\n\t\tthis.request('register-externally-defined-properties', data);\n\t};\n\n\treturn new Api();\n})();\n\nPluginAPI.Article = articleCommunicator(PluginAPI);\nPluginAPI.Editor = ah5Communicator(PluginAPI);\n\nmodule.exports = PluginAPI;\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://PluginAPI/webpack/universalModuleDefinition","webpack://PluginAPI/webpack/bootstrap","webpack://PluginAPI/./js/AH5Communicator.js","webpack://PluginAPI/./js/ArticleCommunicator.js","webpack://PluginAPI/./js/Listeners.js","webpack://PluginAPI/./js/PluginAPI.js"],"names":["module","exports","PluginAPI","selectedPluginElement","AH5Communicator","DEBUG","on","pluginElementSelected","pluginElementDeselected","elementData","prototype","getActiveEditor","callback","request","registerMenuAction","action","registerHoverAction","getSelectedPluginElement","deSelectPluginElements","directionalCastle","elementId","direction","registerMenuActionGroup","group","getEditorType","replaceElementById","id","element","replacePluginElementById","setElementContentById","content","deleteElementById","getHTMLById","getHTMLBySelector","selector","getCategories","getParentCategories","category","getParentIds","getTagTypes","getTagType","clear","insertString","string","insertElement","options","select","outerHTML","removeClasses","classes","addClasses","getDataAttribute","attribute","updateDataAttribute","value","markAsActive","setAttributeById","setStyleById","initMenu","menus","openPluginElementEditor","getTotalWordCount","getTotalCharCount","updateAssetOption","dpArticleId","key","updateAssetData","data","getAssetData","insertNestedAsset","parentElementId","markup","self","createEmbeddedObject","embeddedTypeId","insert","updateEmbeddedAssetRequest","internalId","$element","$","attr","assetSource","externalId","dpDigitalAssetId","assetClass","addClass","html","Editor","d","document","createElement","innerHTML","firstChild","setAttribute","assetContainer","querySelector","isMultiple","append","get","insertEmbeddedAsset","updateContent","getAppName","showErrorMsg","Error","addEmbeddedAssetRequest","dataset","classList","add","getCurrentSelectionAbsolutePosition","wrapSelection","className","attributes","removeInPlace","triggerEvent","event","getOrderedIDs","ArticleCommunicator","focusPlugin","focusApp","startPlugin","name","app","option","startApp","stopPlugin","stopApp","getId","getPackageId","getPackageGuid","clearMetaInfo","getTags","getCustomMeta","setCustomMeta","setMetaChanged","setTags","tags","save","addTags","errorFunction","onError","addTag","tag","removeTag","getSelectedCategories","saveCategories","categories","setCategories","addCategories","removeCategories","setMainCategory","getSource","setSource","source","getStatus","setStatus","status","getPublishedDatetime","setPublishedDatetime","published","getAuthors","setAuthors","authors","addAuthors","removeAuthors","setKeywords","keywords","getKeywords","getCurrentContent","setCurrentContent","setSubArticleContent","articleId","getArticletypeId","setArticletypeId","articletypeId","articletype","maximizePluginWindow","title","onClose","Date","getTime","eventListeners","removeAll","maximizeAppWindow","restorePluginWindow","restoreAppWindow","getByline","setByline","byline","setGeolocations","geolocations","getGeolocations","getProperties","setProperties","properties","setProperty","getTopic","setTopic","topic","getPackage","Listeners","_listeners","listeners","createCallback","eventName","hasOwnProperty","callWrapper","undefined","push","length","index","payload","returnValue","forEach","listenerFn","res","params","apply","ah5Communicator","articleCommunicator","Api","queryParameters","window","location","search","substr","split","queryPair","Version","Article","errorListeners","appName","jwt","standAlone","pm","bind","createEventFunction","updateObject","type","eventKey","map","notify","callSpec","console","info","getPluginName","func","remove","arguments","createCallbackObject","random","Math","floor","eventFunction","val","target","parent","success","error","origin","hash","openTagCreationDialog","reloadIframe","setPluginName","setAppName","showInfoMsg","msg","message","showWarningMsg","showLoader","hideLoader","__loadArticleRevision","revision","createTag","searchDrLib","query","access","secure","convertDomToHTML","dom","wrap","domClone","cloneNode","wrapper","appendChild","generateArticleUrl","extendApi","a","callExtendedApi","getCurrentUser","getConfiguration","getDrPublishConfiguration","setConfiguration","config","onlyPublication","emit","increaseRequiredActionCounter","decreaseRequiredActionCounter","clearRequiredActionCounter","setRequiredActionCounter","count","create","typeId","getEmbeddedObjectTypes","giveFocus","pluginName","argument","start","hide","createModal","updateModal","closeModal","destroy","getModalInputs","confirmAuthenticated","isStandAlone","getJWT","replaceEditorComponentsExtension","clearEditorComponentsExtension","highlightAnnotation","underemphasizeAnnotations","registerExternallyDefinedProperties"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AClFA;;;;;;;;;AASA;;;;AAIAA,QAAM,CAACC,OAAP,GAAiB,UAAUC,SAAV,EAAqB;AAErC;AACA,QAAIC,qBAAqB,GAAG,IAA5B;AAEA;;;;;;;;;;;;AAWA;;AACA,QAAMC,eAAe,GAAG,SAAlBA,eAAkB,GAAY;AACnC,WAAKC,KAAL,GAAa,KAAb;AACAH,eAAS,CAACI,EAAV,CAAa,sBAAb,EAAqCC,qBAArC;AACAL,eAAS,CAACI,EAAV,CAAa,yBAAb,EAAwCE,uBAAxC;AAEA;;;;AAGA,eAASD,qBAAT,CAA+BE,WAA/B,EAA4C;AAC3CN,6BAAqB,GAAGM,WAAxB;AACA;;AAED,eAASD,uBAAT,GAAmC;AAClCL,6BAAqB,GAAG,IAAxB;AACA;AACD,KAfD;AAiBA;;;;;;;AAKAC,mBAAe,CAACM,SAAhB,CAA0BC,eAA1B,GAA4C,UAAUC,QAA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AG,CAACjN,SAAJ,CAAcsT,mCAAd,GAAoD,UAAU7P,IAAV,EAAgB;AACnE,WAAKtD,OAAL,CAAa,wCAAb,EAAuDsD,IAAvD;AACA,KAFD;;AAIA,WAAO,IAAIwJ,GAAJ,EAAP;AACA,GArrBiB,EAAlB;;AAurBAzN,WAAS,CAACkO,OAAV,GAAoBV,mBAAmB,CAACxN,SAAD,CAAvC;AACAA,WAAS,CAACqF,MAAV,GAAmBkI,eAAe,CAACvN,SAAD,CAAlC;AAEAF,QAAM,CAACC,OAAP,GAAiBC,SAAjB","file":"bundle.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"PluginAPI\"] = factory();\n\telse\n\t\troot[\"PluginAPI\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./js/PluginAPI.js\");\n","/**\n * @typedef {Object} selectedPluginElementData\n *\n * @property {String} id The DOM id of the selected element\n * @property {String} dpArticleId\n * @property {String} externalId\n * @property {Boolean} isDigitalAsset\n */\n\n/**\n * @param {Api} PluginAPI\n * @return {AH5Communicator}\n */\nmodule.exports = function (PluginAPI) {\n\n\t/** @type {selectedPluginElementData|null} */\n\tlet selectedPluginElement = null;\n\n\t/**\n\t * This will be used by editor apps to communicate with the editor\n\t *\n\t * Should be used like this:\n\t *\n\t * PluginAPI.Editor.insertString('string');\n\t *\n\t * @class\n\t * @classdesc Functions for talking with the AH5 editor. Accessed through PluginAPI.Editor\n\t * @exports PluginAPI/Editor\n\t */\n\t/* eslint max-statements: [\"error\", 50, { \"ignoreTopLevelFunctions\": true }]*/\n\tconst AH5Communicator = function () {\n\t\tthis.DEBUG = false;\n\t\tPluginAPI.on('pluginElementClicked', pluginElementSelected);\n\t\tPluginAPI.on('pluginElementDeselected', pluginElementDeselected);\n\n\t\t/**\n\t\t * @param {selectedPluginElementData} elementData\n\t\t */\n\t\tfunction pluginElementSelected(elementData) {\n\t\t\tselectedPluginElement = elementData;\n\t\t}\n\n\t\tfunction pluginElementDeselected() {\n\t\t\tselectedPluginElement = null;\n\t\t}\n\t};\n\n\t/**\n\t * Get name of current active editor\n\t *\n\t * @param {Function} callback function(String)\n\t */\n\tAH5Communicator.prototype.getActiveEditor = function (callback) {\n\t\tPluginAPI.request('get-active-editor', null, callback);\n\t};\n\n\t/**\n\t * Registers/Modifies a context menu items for a plugin element\n\t * The object send should have the following structure\n\t *\n\t * @param {Object} action The action object\n\t * @param {Function} callback function()\n\t *\n\t * @example\n\t * PluginAPI.Editor.registerMenuAction({\n\t *\t label: 'label in the menu',\n\t *\t icon: '[Optional] url to possible icon image',\n\t *\t trigger: '[Optional] css selector, only show menu element when this matches the element',\n\t *\t callback: function(id, clickedElementId) {\n\t *\t\t // callback function\n\t *\t\t // first parameter is id of the plugin element\n\t *\t\t // second paramter is id of closest element to the trigger element that has an id\n\t *\t\t //\t in code: $(event.triggerElement).closest('[id]').attr('id');\n\t *\t }\n\t * })\n\t */\n\tAH5Communicator.prototype.registerMenuAction = function (action, callback) {\n\t\tPluginAPI.request('register-menu-action', action, callback);\n\t};\n\n\t/**\n\t * Adds a mouseover action to plugin elements\n\t *\n\t * @param {function} action to perform\n\t * @param {function} callback function(String)\n\t */\n\tAH5Communicator.prototype.registerHoverAction = function (action, callback) {\n\t\tPluginAPI.request('register-hover-action', action, callback);\n\t};\n\n\t/**\n\t * Gets the selected plugin element from the editor\n\t *\n\t * @param {function} callback function(String)\n\t */\n\tAH5Communicator.prototype.getSelectedPluginElement = function (callback) {\n\t\tPluginAPI.request('get-selected-plugin-element', {}, callback);\n\t};\n\n\t/**\n\t * Deselect all plugin elements in editor\n\t *\n\t * @param {function} callback function(String)\n\t */\n\tAH5Communicator.prototype.deSelectPluginElements = function (callback) {\n\t\tPluginAPI.request('de-select-plugin-elements', {}, callback);\n\t};\n\n\t/**\n\t * Swap positions between the provided element and the adjacent one\n\t * in the specified direction\n\t * PluginAPI.Editor.directionalCastle({\n\t * elementId: 'the provided element id',\n\t * direction: 'forward/backward'\n\t * })\n\t * @param {String} elementId DOM element id\n\t * @param {String} direction Direction\n\t * @param {function} callback\n\t * */\n\tAH5Communicator.prototype.directionalCastle = function (elementId, direction, callback) {\n\t\tPluginAPI.request('editor-directional-castle', {\n\t\t\telementId: elementId,\n\t\t\tdirection: direction\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Registers/Modifies a group of items to in the context menu\n\t * The object send should have the following structure\n\t *\n\t * @example\n\t * PluginAPI.Editor.registerMenuActionGroup({\n\t *\t label: 'label for the group in the menu',\n\t *\t icon: '[Optional] url to possible icon image',\n\t *\t actions: [\n\t *\t\t {\n\t *\t\t\t label: 'label for the action #1',\n\t *\t\t\t callback: function(id, clickedElementId) {\n\t *\t\t\t\t // same as for registerMenuAction\n\t *\t\t\t }\n\t *\t\t },\n\t *\t\t {\n\t *\t\t\t label: 'label for the action #2',\n\t *\t\t\t callback: function(id, clickedElementId) {\n\t *\t\t\t\t // same as for registerMenuAction\n\t *\t\t\t }\n\t *\t\t }\n\t *\t ]\n\t * })\n\t *\n\t * @param {Object} group The action object\n\t * @param {function} callback function()\n\t */\n\tAH5Communicator.prototype.registerMenuActionGroup = function (group, callback) {\n\t\tPluginAPI.request('register-menu-action-group', group, callback);\n\t};\n\n\t/**\n\t * Retrieves the type of editor that currently has focus\n\t *\n\t * @param {function} callback function(String)\n\t */\n\tAH5Communicator.prototype.getEditorType = function (callback) {\n\t\tPluginAPI.request('editor-get-type', null, callback);\n\t};\n\n\t/**\n\t * Replace an element in the article\n\t *\n\t * @param {String} id Id of the element\n\t * @param {String} element The new element\n\t * @param {function} callback function(Boolean), called after replacement is done\n\t */\n\tAH5Communicator.prototype.replaceElementById = function (id, element, callback) {\n\t\tPluginAPI.request('editor-element-replace-byid', {\n\t\t\tid: id,\n\t\t\telement: element\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Replace a plugin element in the article\n\t *\n\t * @param {String} id Id of the element\n\t * @param {String} element The new element\n\t * @param {function} callback function(Boolean), called after replacement is done\n\t */\n\tAH5Communicator.prototype.replacePluginElementById = function (id, element, callback) {\n\t\tPluginAPI.request('editor-element-replace-plugin-element-byid', {\n\t\t\tid: id,\n\t\t\telement: element\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Set the content of an element in the article\n\t *\n\t * @param {String} id Id of the element\n\t * @param {String} content The new content\n\t * @param {function} callback function(Boolean), called when done\n\t */\n\tAH5Communicator.prototype.setElementContentById = function (id, content, callback) {\n\t\tPluginAPI.request('editor-element-set-byid', {\n\t\t\tid: id,\n\t\t\telement: content\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Delete an element in the article\n\t *\n\t * @param {String} id Id of the element\n\t * @param {function} callback function(Boolean), called after deletion is done\n\t */\n\tAH5Communicator.prototype.deleteElementById = function (id, callback) {\n\t\tPluginAPI.request('editor-element-delete-byid', {\n\t\t\tid: id\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Get HTML code of an element\n\t *\n\t * @param {String} id The element id\n\t * @param {function} callback function(String), html content of the element\n\t */\n\tAH5Communicator.prototype.getHTMLById = function (id, callback) {\n\t\tPluginAPI.request('editor-element-get-byid', {\n\t\t\tid: id\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Get HTML code of all elements that match the selector\n\t *\n\t * @param {String} selector The CSS selector\n\t * @param {function} callback function([String]), html content of matching elements\n\t */\n\tAH5Communicator.prototype.getHTMLBySelector = function (selector, callback) {\n\t\tPluginAPI.request('editor-elements-get-byselector', {\n\t\t\tselector: selector\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Get all categories\n\t *\n\t * @param {Function} callback function([Object Category]), list of Category objects with id, name and pid\n\t */\n\tAH5Communicator.prototype.getCategories = function (callback) {\n\t\tPluginAPI.request('get-categories', null, callback);\n\t};\n\n\t/**\n\t * Returns all the parent categories of the given category\n\t *\n\t * @param {Object} category The category to find parents of\n\t * @param {Function} callback function([Object Category]), array of parent Category objects\n\t */\n\tAH5Communicator.prototype.getParentCategories = function (category, callback) {\n\t\tPluginAPI.request('get-parent-categories', category, callback);\n\t};\n\n\t/**\n\t * Returns all the parent elements that match the selector\n\t *\n\t * @param {String} id Id of element to find parents of\n\t * @param {String} selector Selector to filter parent elements with\n\t * @param {Function} callback function([String]), array of ids\n\t */\n\tAH5Communicator.prototype.getParentIds = function (id, selector, callback) {\n\t\tPluginAPI.request('get-parent-ids', {\n\t\t\tid: id,\n\t\t\tselector: selector\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Retrieve information about all tagtypes\n\t *\n\t * @param {Function} callback function([Object Tagtype]), array of tagtypes with id, name and config object\n\t */\n\tAH5Communicator.prototype.getTagTypes = function (callback) {\n\t\tPluginAPI.request('get-tag-types', null, callback);\n\t};\n\n\t/**\n\t * Get information about the given tagtype\n\t *\n\t * @param {String} id The element id\n\t * @param {Function} callback function(Object Tagtype), tagtype object with id, name and config object\n\t */\n\tAH5Communicator.prototype.getTagType = function (id, callback) {\n\t\tPluginAPI.request('get-tag-type', {\n\t\t\tid: id\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Clears the editor contents\n\t *\n\t * @param {Function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.clear = function (callback) {\n\t\tPluginAPI.request('editor-clear', null, callback);\n\t};\n\n\t/**\n\t * Insert a string into the editor\n\t *\n\t * @param {String} string The string that should be inserted\n\t * @param {Function} callback function(String), id of the newly inserted element if it has one\n\t */\n\tAH5Communicator.prototype.insertString = function (string, callback) {\n\t\tPluginAPI.request('editor-insert-string', {\n\t\t\tstring: string\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Insert an element into the editor\n\t *\n\t * Note that the HTML of the element is what will be transferred, and nothing else!\n\t * The element will be given the class dp-plugin-element, and given a unique ID (if none is present)\n\t *\n\t * @param {Element} element The element that should be inserted\n\t * @param {Object | Function} options (can be omitted) Options object, supports option 'select' - set to true to automatically select the inserted element\n\t * @param {Function} [callback] function(String), id of the newly inserted element\n\t */\n\tAH5Communicator.prototype.insertElement = function (element, options, callback) {\n\t\tlet select = false;\n\t\tif (typeof options === 'object') {\n\t\t\toptions = options || {};\n\t\t\tselect = typeof options.select === 'boolean' ? options.select : false;\n\t\t} else if (typeof callback === 'undefined' && typeof options === 'function') {\n\t\t\tcallback = options;\n\t\t}\n\t\tPluginAPI.request('editor-insert-element', {\n\t\t\telement: element.outerHTML,\n\t\t\tselect: select,\n\t\t\toptions: options\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Remove classes from the element an element in the article\n\t *\n\t * @param {String} id Id of the element\n\t * @param {Array} classes Array of class names\n\t * @param {function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.removeClasses = function (id, classes, callback) {\n\t\tPluginAPI.request('editor-classes-remove', {\n\t\t\tid: id,\n\t\t\tclasses: classes\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Add new classes to an element\n\t *\n\t * @param {String} id Id of the element\n\t * @param {Array} classes Array of class names\n\t * @param {function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.addClasses = function (id, classes, callback) {\n\t\tPluginAPI.request('editor-classes-add', {\n\t\t\tid: id,\n\t\t\tclasses: classes\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Get data-attribute of the element\n\t *\n\t * @param {String} id Id of the element\n\t * @param {String} attribute attribute name\n\t * @param {function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.getDataAttribute = function (id, attribute, callback) {\n\t\tPluginAPI.request('editor-attribute-get', {\n\t\t\tid: id,\n\t\t\tattribute: 'data-' + attribute\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Update data-attribute of the element\n\t *\n\t * @param {String} id Id of the element\n\t * @param {String} attribute attribute name\n\t * @param {String} value attribute value\n\t * @param {function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.updateDataAttribute = function (id, attribute, value, callback) {\n\t\tPluginAPI.request('editor-attribute-update', {\n\t\t\tid: id,\n\t\t\tattribute: 'data-' + attribute,\n\t\t\tvalue: value\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Mark an element as currently selected (green border with default styling)\n\t *\n\t * @param {String} id Id of the element\n\t * @param {function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.markAsActive = function (id, callback) {\n\t\tPluginAPI.request('editor-mark-as-active', {\n\t\t\tid: id\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Sets the attribute of the element with the given ID to value\n\t *\n\t * @param {String} id The ID of the element to set the attribute on\n\t * @param {String} attribute The attribute to set\n\t * @param {String} value What to set the attribute to\n\t * @param {Function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.setAttributeById = function (id, attribute, value, callback) {\n\t\tPluginAPI.request('editor-element-attribute-set-byid', {\n\t\t\tid: id,\n\t\t\tattribute: attribute,\n\t\t\tvalue: value\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Sets a style of the element with the given ID to value\n\t *\n\t * @param {String} id The ID of the element to set the attribute on\n\t * @param {String} attribute The style attribute to set\n\t * @param {String} value What to set the attribute to\n\t * @param {Function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.setStyleById = function (id, attribute, value, callback) {\n\t\tPluginAPI.request('editor-element-style-set-byid', {\n\t\t\tid: id,\n\t\t\tattribute: attribute,\n\t\t\tvalue: value\n\t\t}, callback);\n\t};\n\n\n\t/**\n\t * Initialize pre registered menus\n\t *\n\t * Available options are: simplePluginMenu, editContext, deleteButton, floatButtons\n\t *\n\t * @param {Array} menus Array of menu names\n\t * @param {Function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.initMenu = function (menus, callback) {\n\t\tPluginAPI.request('editor-initialize-menu', {\n\t\t\tmenus: menus\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Opens the plugin editor for a given element.\n\t *\n\t * @param {String} id Plugin element ID\n\t */\n\tAH5Communicator.prototype.openPluginElementEditor = function (id) {\n\t\tPluginAPI.request('open-element-editor', {\n\t\t\tid: id\n\t\t});\n\t};\n\n\t/**\n\t * Returns the total number of words in the currently open article.\n\t *\n\t * @param {Function} callback Receives the total word count as its single parameter\n\t */\n\tAH5Communicator.prototype.getTotalWordCount = function (callback) {\n\t\tPluginAPI.request('total-word-count', null, callback);\n\t};\n\n\t/**\n\t * Returns the total number of characters in the currently open article.\n\t *\n\t * @param {Function} callback Receives the total character count as its single parameter\n\t */\n\tAH5Communicator.prototype.getTotalCharCount = function (callback) {\n\t\tPluginAPI.request('total-char-count', null, callback);\n\t};\n\n\t/**\n\t * Update one data option of the referenced embedded asset\n\t *\n\t * @param {Number} dpArticleId DrPublish's embedded asset id\n\t * @param {String} key Name of the property\n\t * @param {String} value Value of the property\n\t * @param {Function} callback Receives the total character count as its single parameter\n\t */\n\tAH5Communicator.prototype.updateAssetOption = function (dpArticleId, key, value, callback) {\n\t\tPluginAPI.request('update-asset-option', {dpArticleId: dpArticleId, key: key, value: value}, callback);\n\t};\n\n\t/**\n\t * Update all asset data of the referenced embedded asset\n\t *\n\t * @param {Object} data Updated data\n\t * @param {Function} callback Receives the total character count as its single parameter\n\t *\n\t * @example\n\t * var data = {\n\t * internalId: assetDpArticleId,\n\t * assetElementId: activeAssetId,\n\t * assetType: 'picture',\n\t * assetSource: PluginAPI.getPluginName(),\n\t * resourceUri: fullsizeUrl,\n\t * previewUri: fullsizeUrl,\n\t * renditions: {\n\t * highRes: {uri: fullsizeUrl},\n\t * thumbnail: {uri: thumbnailUrl}\n\t * },\n\t * options: {}\n\t * }\n\t * PluginAPI.Editor.updateAssetData(data);\n\t */\n\tAH5Communicator.prototype.updateAssetData = function (data, callback) {\n\t\tPluginAPI.request('update-asset-media', data, callback);\n\t};\n\n\t/**\n\t * Get all data option of the referenced embedded asset\n\t *\n\t * @param {Number} dpArticleId DrPublish's embedded asset id\n\t * @param {Function} callback Receives the total character count as its single parameter\n\t */\n\tAH5Communicator.prototype.getAssetData = function (dpArticleId, callback) {\n\t\tPluginAPI.request('get-asset-data', {data: dpArticleId}, callback);\n\t};\n\n\t/**\n\t * Insert an embedded asset inside of an existing one\n\t *\n\t * @param {Number} parentElementId DOM element id of the receiving asset\n\t * @param {String} markup HTML to inject\n\t * @param {Object} data Asset data\n\t * @param {Function} callback Receives the total character count as its single parameter\n\t *\n\t * @example\n\t * var title = response.data.title ? response.data.title : '';\n\t * var caption = response.data.description ? response.data.description : '';\n\t * var credit = response.data.byline ? response.data.byline : '';\n\t * var source = response.data.source ? response.data.source : '';\n\t * var markup = '
';\n\t * markup += '
' + title + '
...';\n\t * var options = response.data.options ? response.data.options : {};\n\t * var callback = function () {\n\t * // do something here\n\t * };\n\t * var rends = renditions || {};\n\t * rends.highRes = {uri: fullsizeUrl};\n\t * rends.preview = {uri: fullsizeUrl};\n\t * var drpdata = {\n\t * embeddedTypeId: 5,\n\t * isMultiple: true,\n\t * assetType: 'picture',\n\t * externalId: id,\n\t * assetClass: 'dp-picture',\n\t * assetSource: 'images',\n\t * resourceUri: fullsizeUrl,\n\t * previewUri: fullsizeUrl,\n\t * renditions: rends,\n\t * options: options\n\t * };\n\t * var insertNested = function () {\n\t * PluginAPI.Editor.insertNestedAsset(\n\t * selectedSlideshowAsset.id,\n\t * markup,\n\t * drpdata\n\t * };\n\t * PluginAPI.Editor.getSelectedPluginElement(insertNested);\n\t */\n\tAH5Communicator.prototype.insertNestedAsset = function (parentElementId, markup, data, callback) {\n\t\tconst self = this;\n\t\tPluginAPI.createEmbeddedObject(\n\t\t\tdata.embeddedTypeId,\n\t\t\t(dpArticleId) => {\n\t\t\t\tinsert(dpArticleId, parentElementId, (data) => {\n\t\t\t\t\treturn updateEmbeddedAssetRequest(callback);\n\t\t\t\t});\n\t\t\t}\n\t\t);\n\n\t\tfunction insert(dpArticleId, parentElementId, callback) {\n\t\t\tdata.internalId = dpArticleId;\n\t\t\tconst elementId = 'asset-' + dpArticleId;\n\t\t\tconst $element = $('
');\n\t\t\t$element.attr('id', elementId);\n\t\t\t$element.attr('data-internal-id', dpArticleId);\n\t\t\t$element.attr('data-ah5-type', data.assetSource);\n\t\t\tif (data.externalId) {\n\t\t\t\t$element.attr('data-external-id', data.externalId);\n\t\t\t}\n\t\t\tif (data.dpDigitalAssetId) {\n\t\t\t\t$element.attr('data-dp-digital-asset-id', data.dpDigitalAssetId);\n\t\t\t}\n\t\t\tif (data.assetClass) {\n\t\t\t\t$element.addClass(data.assetClass);\n\t\t\t}\n\t\t\t$element.addClass('dp-plugin-element');\n\t\t\t$element.html(markup);\n\t\t\tPluginAPI.Editor.getHTMLById(parentElementId, (html) => {\n\t\t\t\tlet d = document.createElement('div');\n\t\t\t\td.innerHTML = html;\n\t\t\t\td.firstChild.setAttribute('id', parentElementId + 'tmp');\n\t\t\t\tself.replacePluginElementById(parentElementId, d.innerHTML, () => {\n\t\t\t\t\td = document.createElement('div');\n\t\t\t\t\td.innerHTML = html;\n\t\t\t\t\tconst assetContainer = d.querySelector('.dp-fact-box-image, .dp-nested-asset-container');\n\t\t\t\t\tif (data.isMultiple) {\n\t\t\t\t\t\t$(assetContainer).append($element.get(0).outerHTML);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tassetContainer.innerHTML = $element.get(0).outerHTML;\n\t\t\t\t\t}\n\t\t\t\t\tself.replacePluginElementById(parentElementId + 'tmp', d.innerHTML, callback);\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\tfunction updateEmbeddedAssetRequest(callback) {\n\t\t\tPluginAPI.request('update-embedded-asset', data, callback);\n\t\t}\n\t};\n\n\t/**\n\t * Insert an embedded asset\n\t *\n\t * @param {String} markup HTML to inject\n\t * @param {Object} data Asset data\n\t * @param {Function} callback Receives the total character count as its single parameter\n\t *\n\t * @example\n\t * var title = response.data.title ? response.data.title : '';\n\t * var caption = response.data.description ? response.data.description : '';\n\t * var credit = response.data.byline ? response.data.byline : '';\n\t * var source = response.data.source ? response.data.source : '';\n\t * var markup = '
';\n\t * markup += '
' + title + '
';\n\t * markup += '
' + caption + '
...';\n\t * var options = response.data.options ? response.data.options : {};\n\t * var callback = function () {\n\t * // do something here\n\t * };\n\t * var rends = renditions || {};\n\t * rends.highRes = {uri: fullsizeUrl};\n\t * rends.preview = {uri: fullsizeUrl};\n\t * var drpdata = {\n\t * embeddedTypeId: 5,\n\t * isMultiple: true,\n\t * assetType: 'picture',\n\t * externalId: id,\n\t * assetClass: 'dp-picture',\n\t * assetSource: 'images',\n\t * resourceUri: fullsizeUrl,\n\t * previewUri: fullsizeUrl,\n\t * renditions: rends,\n\t * options: options\n\t * };\n\t * PluginAPI.Editor.insertEmbeddedAsset(markup, drpdata, callback);\n\t */\n\tAH5Communicator.prototype.insertEmbeddedAsset = function (markup, data, callback) {\n\t\tconst self = this;\n\t\tlet updateContent = false;\n\t\tif (selectedPluginElement) {\n\t\t\tif (data.assetSource !== PluginAPI.getAppName()) {\n\t\t\t\tPluginAPI.showErrorMsg('Can\\'t update selected plugin element since it doesn\\'t belong to the \\'' + PluginAPI.getAppName() + '\\' plugin');\n\t\t\t\treturn;\n\t\t\t} else {\n\t\t\t\tupdateContent = true;\n\t\t\t}\n\t\t}\n\n\t\tif (selectedPluginElement) {\n\t\t\tconst dpArticleId = selectedPluginElement.dpArticleId;\n\t\t\tif (!dpArticleId) {\n\t\t\t\tthrow Error('Selected plugin element: expected dpArticleId not found (tried reading from attribute \\'data-internal-id\\')');\n\t\t\t}\n\t\t\tinsert(dpArticleId, (data) => {\n\t\t\t\treturn updateEmbeddedAssetRequest(typeof callback === 'function' ? callback(data) : null);\n\t\t\t});\n\t\t} else {\n\t\t\tPluginAPI.createEmbeddedObject(\n\t\t\t\tdata.embeddedTypeId,\n\t\t\t\t(dpArticleId) => {\n\t\t\t\t\tinsert(dpArticleId, (data) => {\n\t\t\t\t\t\treturn addEmbeddedAssetRequest(typeof callback === 'function' ? callback(data) : null);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tfunction insert(dpArticleId, callback) {\n\t\t\tdata.internalId = dpArticleId;\n\t\t\tconst elementId = 'asset-' + dpArticleId;\n\t\t\tconst element = document.createElement('div');\n\t\t\telement.id = elementId;\n\t\t\telement.dataset.internalId = dpArticleId;\n\t\t\tif (data.externalId) {\n\t\t\t\telement.dataset.externalId = data.externalId;\n\t\t\t}\n\t\t\tif (data.dpDigitalAssetId) {\n\t\t\t\telement.dataset.dpDigitalAssetId = data.dpDigitalAssetId;\n\t\t\t}\n\t\t\tif (data.assetClass) {\n\t\t\t\telement.classList.add(data.assetClass);\n\t\t\t}\n\t\t\telement.innerHTML = markup;\n\t\t\tif (!updateContent) {\n\t\t\t\tdata.select = true;\n\t\t\t\tself.insertElement(element, data);\n\t\t\t} else {\n\t\t\t\tself.setElementContentById(elementId, element.innerHTML, null);\n\t\t\t}\n\t\t\tif (typeof callback === 'function') {\n\t\t\t\treturn callback();\n\t\t\t}\n\t\t}\n\n\t\tfunction addEmbeddedAssetRequest(callback) {\n\t\t\tPluginAPI.request('add-embedded-asset', data, callback);\n\t\t}\n\n\t\tfunction updateEmbeddedAssetRequest(callback) {\n\t\t\tPluginAPI.request('update-embedded-asset', data, callback);\n\t\t}\n\t};\n\n\t/**\n\t * Returns the total number of characters in the currently open article.\n\t *\n\t * @param {Function} callback Receives the total character count as its single parameter\n\t */\n\tAH5Communicator.prototype.getCurrentSelectionAbsolutePosition = function (callback) {\n\t\tPluginAPI.request('current-selection-absolute-position', null, callback);\n\t};\n\n\t/**\n\t * Wraps the current selection in a span\n\t *\n\t * @param {String} className the name of the class to apply\n\t * @param {Object} attributes to apply to the wrapper\n\t * @param {Function} callback\n\t */\n\tAH5Communicator.prototype.wrapSelection = function (className, attributes, callback) {\n\t\tPluginAPI.request('wrap-selection', {className: className, attributes: attributes}, callback);\n\t};\n\n\t/**\n\t * Removes the selected element, leaving all children in place\n\t *\n\t * @param {String} selector the selector for finding the elements to be removed\n\t * @param {Function} callback\n\t */\n\tAH5Communicator.prototype.removeInPlace = function (selector, callback) {\n\t\tPluginAPI.request('remove-in-place', {selector: selector}, callback);\n\t};\n\n\t/**\n\t * Triggers an event on all elements matching the selector\n\t *\n\t * @param {String} selector the selector for finding the elements\n\t * @param {String} event the event to trigger on the found elements\n\t * @param {Function} callback\n\t */\n\tAH5Communicator.prototype.triggerEvent = function (selector, event, callback) {\n\t\tPluginAPI.request('trigger-event', {selector: selector, event: event}, callback);\n\t};\n\n\t/**\n\t * Get ordered list of element IDs, for selector\n\t *\n\t * @param {String} selector the selector for finding the elements\n\t * @param {Function} callback Receives an ordered array of element IDs\n\t */\n\tAH5Communicator.prototype.getOrderedIDs = function (selector, callback) {\n\t\tPluginAPI.request('get-ordered-ids', {selector: selector}, callback);\n\t};\n\n\treturn new AH5Communicator();\n};\n","/* eslint max-statements: [\"error\", 100000000] */\n/* eslint complexity: [\"error\", 100000000] */\nmodule.exports = function (PluginAPI) {\n\n\t/**\n * This class is used for communicating with the article, typically setting and getting values of metadata or in the article content itself.\n *\n * @class\n * @classdesc Functions for talking with the DrPublish article object. Accessed through PluginAPI.Article\n * @exports PluginAPI/Article\n */\n\tconst ArticleCommunicator = function () {\n\t\tthis.DEBUG = false;\n\t};\n\n\t/**\n * Give focus to yourself\n *\n * @param {Function} callback function(Boolean), called as the plugin gets focus\n */\n\tArticleCommunicator.prototype.focusPlugin = function (callback) {\n\t\tPluginAPI.request('app-focus', {}, callback);\n\t};\n\n\t/**\n * Give focus to yourself\n * @deprecated use focusPlugin instead\n * @param {Function} callback function(Boolean), called after plugin is started\n */\n\tArticleCommunicator.prototype.focusApp = function (callback) {\n\t\tthis.focusPlugin(callback);\n\t};\n\n\t/**\n * Start the given plugin\n *\n * @param {String} name Name of the plugin as defined on publication settings\n * @param {Object} options Options for initializing the plugin\n * @param {Function} callback function(Boolean), called after plugin is started\n */\n\tArticleCommunicator.prototype.startPlugin = function (name, options, callback) {\n\t\tPluginAPI.request('app-start', {\n\t\t\tapp: name,\n\t\t\toption: options\n\t\t}, callback);\n\t};\n\n\t/**\n * @deprecated use startPlugin instead\n * @param {String} name Name of the plugin as defined on publication settings\n * @param {Object} options Options for initializing the plugin\n * @param {Function} callback function(Boolean), called after plugin is started\n */\n\tArticleCommunicator.prototype.startApp = function (name, options, callback) {\n\t\tthis.startPlugin(name, options, callback);\n\t};\n\n\t/**\n * Stop the given plugin\n *\n * @param {String} name Name of the plugin, as defined on publication config\n */\n\tArticleCommunicator.prototype.stopPlugin = function (name) {\n\t\tPluginAPI.request('app-stop', {\n\t\t\tapp: name\n\t\t});\n\t};\n\n\t/**\n * @deprecated use stopPlugin instead\n * @param {String} name Name of the plugin, as defined on publication config\n */\n\tArticleCommunicator.prototype.stopApp = function (name) {\n\t\tthis.stopPlugin(name);\n\t};\n\n\t/**\n * Get the id of the article currently edited\n *\n * @param {Function} callback function(Int), id of the current article\n */\n\tArticleCommunicator.prototype.getId = function (callback) {\n\t\tPluginAPI.request('article-id-get', null, callback);\n\t};\n\n\t/**\n * Get the guid of the article package currently edited\n *\n * @param {Function} callback function(Int), id of the current article\n */\n\tArticleCommunicator.prototype.getPackageId = function (callback) {\n\t\tPluginAPI.request('package-id-get', null, callback);\n\t};\n\n\t/**\n * Get the guid of the article package currently edited\n *\n * @param {Function} callback function(Int), id of the current article\n */\n\tArticleCommunicator.prototype.getPackageGuid = function (callback) {\n\t\tPluginAPI.request('package-guid-get', null, callback);\n\t};\n\n\t/**\n * Clear the meta information summary\n *\n * @param {Function} callback function(Boolean), called when meta data has been cleared\n */\n\tArticleCommunicator.prototype.clearMetaInfo = function (callback) {\n\t\tPluginAPI.request('article-metainfo-clear', null, callback);\n\t};\n\n\t/**\n * Get tags used in the article\n *\n * @param {Function} callback function([Object Tag]), array with tags connected to an article\n */\n\tArticleCommunicator.prototype.getTags = function (callback) {\n\t\tPluginAPI.request('article-tags-get', null, callback);\n\t};\n\n\t/**\n * Retrieve custom meta value for the article\n *\n * @param {String} name Name of the custom meta value\n * @param {Function} callback function(Object), the parameter is an object containing the given custom meta value\n */\n\tArticleCommunicator.prototype.getCustomMeta = function (name, callback) {\n\t\tPluginAPI.request('article-custom-meta-get', {\n\t\t\tname: name\n\t\t}, callback);\n\t};\n\n\t/**\n * Set custom meta value for the article\n *\n * @param {String} name Name of the meta value\n * @param {Object} value Value to set\n * @param {Function} callback function()\n */\n\tArticleCommunicator.prototype.setCustomMeta = function (name, value, callback) {\n\t\tPluginAPI.request('article-custom-meta-set', {\n\t\t\tname: name,\n\t\t\tvalue: value\n\t\t}, callback);\n\t};\n\n\t/**\n * Marks article model as having meta data changes\n *\n * @param {Function} callback function()\n */\n\tArticleCommunicator.prototype.setMetaChanged = function (callback) {\n\t\tPluginAPI.request('article-meta-changed', null, callback);\n\t};\n\n\t/**\n * Set tags for the article\n *\n * @param {Array} tags List of tags that should be set\n * @param {Boolean} save Set to true to force save once the tags are updated\n * @param {Function} callback function(Boolean), called when tags have been set\n */\n\tArticleCommunicator.prototype.setTags = function (tags, save, callback) {\n\t\tPluginAPI.request('article-tags-set', {\n\t\t\tsave: save,\n\t\t\ttags: tags\n\t\t}, callback);\n\t};\n\n\t/**\n * Add tag for the article\n *\n * @param {Array} tags Tags to be added\n * @param {Function} errorFunction called if error\n * @param {Function} callback function(Boolean), called when tag has been set\n */\n\tArticleCommunicator.prototype.addTags = function (tags, errorFunction, callback) {\n\t\tPluginAPI.request('article-tags-add', {\n\t\t\ttags: tags,\n\t\t\tonError: errorFunction\n\t\t}, callback);\n\t};\n\n\t/**\n * Add tag for the article\n *\n * @param {String} tag Tag to be added\n * @param {Function} errorFunction called if error\n * @param {Function} callback function(Boolean), called when tag has been set\n */\n\tArticleCommunicator.prototype.addTag = function (tag, errorFunction, callback) {\n\t\tPluginAPI.request('article-tags-add', {\n\t\t\ttags: [tag],\n\t\t\tonError: errorFunction\n\t\t}, callback);\n\t};\n\n\t/**\n * Add tags for the article\n *\n * @param {String} tags Tags to be added\n * @param {Function} errorFunction called if error\n * @param {Function} callback function(Boolean), called when tag has been set\n */\n\tArticleCommunicator.prototype.addTags = function (tags, errorFunction, callback) {\n\t\tPluginAPI.request('article-tags-add', {\n\t\t\ttags: tags,\n\t\t\tonError: errorFunction\n\t\t}, callback);\n\t};\n\n\t/**\n * Remove tag from article\n *\n * @param {String} tag Tag to remove\n * @param {Function} callback function(Boolean), called when tag has been removed\n */\n\tArticleCommunicator.prototype.removeTag = function (tag, callback) {\n\t\tPluginAPI.request('article-tags-remove', {\n\t\t\ttag: tag\n\t\t}, callback);\n\t};\n\n\t/**\n * Get the selected categories\n *\n * @param {Function} callback function([String]), array with category ids\n */\n\tArticleCommunicator.prototype.getSelectedCategories = function (callback) {\n\t\tPluginAPI.request('article-categories-selected-get', null, callback);\n\t};\n\n\t/**\n * Save the currently selected categories\n *\n * @param {Function} callback function(Boolean), called when categories has been saved\n */\n\tArticleCommunicator.prototype.saveCategories = function (callback) {\n\t\tthis.getSelectedCategories(function (categories) {\n\t\t\tthis.setCategories(categories, callback);\n\t\t});\n\t};\n\n\t/**\n * Set selected categories\n *\n * @param {Array} categories List of category IDs that should be set\n * @param {Function} callback function(Boolean), called when categories have been set\n */\n\tArticleCommunicator.prototype.setCategories = function (categories, callback) {\n\t\tPluginAPI.request('article-categories-selected-set', {\n\t\t\tcategories: categories\n\t\t}, callback);\n\t};\n\n\t/**\n * Add the given categories to the list of categories\n *\n * @param {Array} categories List of category IDs to add\n * @param {Function} callback function(Boolean), called when the categories have been set\n */\n\tArticleCommunicator.prototype.addCategories = function (categories, callback) {\n\n\t\tPluginAPI.request('article-categories-add', {\n\t\t\tcategories: categories\n\t\t}, callback);\n\t};\n\n\t/**\n * Remove the given categories from the list of categories\n *\n * @param {Array} categories List of category IDs to remove\n * @param {Function} callback function(Boolean), called when the categories have been removed\n */\n\tArticleCommunicator.prototype.removeCategories = function (categories, callback) {\n\t\tPluginAPI.request('article-categories-remove', {\n\t\t\tcategories: categories\n\t\t}, callback);\n\t};\n\n\t/**\n * Set the main category of the current article\n *\n * @param {Number} category The ID of the category to set as the main category\n * @param {Function} callback function(Boolean), called when the main category has been set\n */\n\tArticleCommunicator.prototype.setMainCategory = function (category, callback) {\n\t\tPluginAPI.request('article-categories-main-set', {\n\t\t\tcategory: category\n\t\t}, callback);\n\t};\n\n\t/**\n * Get the source set for the article\n *\n * @param {Function} callback function(String), name of the source\n */\n\tArticleCommunicator.prototype.getSource = function (callback) {\n\n\t\tPluginAPI.request('article-source-get', null, callback);\n\t};\n\n\t/**\n * Set the source for the article\n *\n * @param {String} value The new value to be set as source\n * @param {Function} callback function(Boolean), called when the source has been set\n */\n\tArticleCommunicator.prototype.setSource = function (value, callback) {\n\t\tPluginAPI.request('article-source-set', {\n\t\t\tsource: value\n\t\t}, callback);\n\t};\n\n\t/**\n * Get the status for the article\n *\n * @param {Function} callback function(String), current status\n */\n\tArticleCommunicator.prototype.getStatus = function (callback) {\n\t\tPluginAPI.request('article-status-get', null, callback);\n\t};\n\n\t/**\n * Set the status for the article\n *\n * @param {String} status The new status to be set (draft, waiting, published)\n * @param {Function} callback function(Boolean), called when the source has been set\n */\n\tArticleCommunicator.prototype.setStatus = function (status, callback) {\n\t\tPluginAPI.request('article-status-set', {\n\t\t\tstatus: status\n\t\t}, callback);\n\t};\n\n\t/**\n * Get the published-date\n *\n * @param {Function} callback function(String), current published datetime\n */\n\tArticleCommunicator.prototype.getPublishedDatetime = function (callback) {\n\t\tPluginAPI.request('article-published-get', null, callback);\n\t};\n\n\t/**\n * Set the published-date\n *\n * @param {String} published Date to be set (YYYY-MM-DD HH:MM:SS)\n * @param {Function} callback function(Boolean), called when done\n */\n\tArticleCommunicator.prototype.setPublishedDatetime = function (published, callback) {\n\t\tPluginAPI.request('article-published-set', {\n\t\t\tpublished: published\n\t\t}, callback);\n\t};\n\n\t/**\n * Get the authors set in the article\n *\n * @param {Function} callback function([String]), currently set authors\n */\n\tArticleCommunicator.prototype.getAuthors = function (callback) {\n\t\tPluginAPI.request('article-authors-get', null, callback);\n\t};\n\n\t/**\n * Set authors for the article\n *\n * @param {Array} authors List of authors that should be set\n * @param {Function} callback function(Boolean), called when it has been set\n */\n\tArticleCommunicator.prototype.setAuthors = function (authors, callback) {\n\t\tPluginAPI.request('article-authors-set', {\n\t\t\tauthors: authors\n\t\t}, callback);\n\t};\n\n\t/**\n * Add the given authors to the list of authors\n *\n * @param {Array} authors List of authors to add\n * @param {Function} callback function(Boolean), called when it has been set\n */\n\tArticleCommunicator.prototype.addAuthors = function (authors, callback) {\n\t\tPluginAPI.request('article-authors-add', {\n\t\t\tauthors: authors\n\t\t}, callback);\n\t};\n\n\t/**\n * Remove the given authors from the list of authors\n *\n * @param {Array} authors List of authors to remove\n * @param {Function} callback function([String]), author list as it is after the authors has been removed\n */\n\tArticleCommunicator.prototype.removeAuthors = function (authors, callback) {\n\t\tPluginAPI.request('article-authors-remove', {\n\t\t\tauthors: authors\n\t\t}, callback);\n\t};\n\n\t/**\n * Set the keyword-list on the article\n *\n * @deprecated Use tags instead\n * @param {Array} keywords List of keywords to add\n * @param {Function} callback Function to call when keywords have been set\n */\n\tArticleCommunicator.prototype.setKeywords = function (keywords, callback) {\n\t\tPluginAPI.request('article-keywords-set', {\n\t\t\tkeywords: keywords\n\t\t}, callback);\n\t};\n\n\t/**\n * Get the current set of keywords on the article\n *\n * @deprecated Use tags instead\n * @param {Function} callback Function to call with the result\n */\n\tArticleCommunicator.prototype.getKeywords = function (callback) {\n\t\tPluginAPI.request('article-keywords-get', null, callback);\n\t};\n\n\t/**\n * Gets the main article content\n *\n * @param {Function} callback function(Object Content)\n */\n\tArticleCommunicator.prototype.getCurrentContent = function (callback) {\n\t\tPluginAPI.request('article-content-get', null, callback);\n\t};\n\n\t/**\n * Updates main article content\n *\n * @param {String} content The new content for the article\n * @param {Function} callback function(Boolean), called when it has been set\n */\n\tArticleCommunicator.prototype.setCurrentContent = function (content, callback) {\n\t\tPluginAPI.request('article-content-set', {\n\t\t\tcontent: content\n\t\t}, callback);\n\t};\n\t/**\n * Updates sub article content\n *\n * @param {Integer} articleId Sub article id\n * @param {String} content The new content for the sub article\n * @param {Function} callback function(Boolean), called when it has been set\n */\n\tArticleCommunicator.prototype.setSubArticleContent = function (articleId, content, callback) {\n\t\tPluginAPI.request('sub-article-content-set', {\n\t\t\tarticleId: articleId,\n\t\t\tcontent: content\n\t\t}, callback);\n\t};\n\n\t/**\n * Get the article type of the current article\n *\n * @param {Function} callback function(Int)\n */\n\tArticleCommunicator.prototype.getArticletypeId = function (callback) {\n\t\tPluginAPI.request('article-type-get', null, callback);\n\t};\n\n\t/**\n * Set the article type of the current article\n *\n * @param {Number} articletypeId The new article type of the article\n * @param {Function} callback function(Boolean), called when it has been set\n */\n\tArticleCommunicator.prototype.setArticletypeId = function (articletypeId, callback) {\n\t\tPluginAPI.request('article-type-set', {\n\t\t\tarticletype: articletypeId\n\t\t}, callback);\n\t};\n\n\t/**\n * Maximize the plugin view\n *\n * @param {String} title Title to give the maximized view\n * @param {function} onClose Function to call when the window is closed/minimized\n\t * @param {Function} callback function(Boolean)\n */\n\tArticleCommunicator.prototype.maximizePluginWindow = function (title, onClose, callback) {\n\t\tconst event = 'editor-pane-close-' + new Date().getTime();\n\n\t\tPluginAPI.request('editor-pane-maximize', {\n\t\t\ttitle: title,\n\t\t\tevent: event\n\t\t}, callback);\n\t\tPluginAPI.eventListeners.removeAll(event);\n\t\tPluginAPI.eventListeners.add(event, onClose);\n\t};\n\n\t/**\n * @deprecated use maximizePluginWindow instead\n * @param {String} title Window title\n * @param {function} onClose Callback to call after everything is done\n\t * @param {Function} callback function(Boolean), called when it has been set\n *\n */\n\tArticleCommunicator.prototype.maximizeAppWindow = function (title, onClose, callback) {\n\t\tthis.maximizePluginWindow(title, onClose, callback);\n\t};\n\n\t/**\n * Restore the plugin pane to the default size\n *\n * @param {function} callback Callback to call after everything is done\n */\n\tArticleCommunicator.prototype.restorePluginWindow = function (callback) {\n\t\tPluginAPI.request('restore-app-window', {}, callback);\n\t};\n\n\t/**\n * Restore the plugin pane to the default size\n *\n * @deprecated use restorPluginWindow instead\n * @param {function} callback Callback to call after everything is done\n */\n\tArticleCommunicator.prototype.restoreAppWindow = function (callback) {\n\t\tthis.restorePluginWindow(callback);\n\t};\n\n\t/**\n * Get the current byline\n *\n * @param {function} callback function(String), xml string with the current byline\n */\n\tArticleCommunicator.prototype.getByline = function (callback) {\n\t\tPluginAPI.request('article-byline-get', null, callback);\n\t};\n\n\t/**\n * Set the byline\n *\n * @param {String} byline XML version of byline to use\n * @param {Boolean} save If true, force save after updating byline information\n * @param {Function} callback function(Boolean), called when it has been set\n */\n\tArticleCommunicator.prototype.setByline = function (byline, save, callback) {\n\t\tPluginAPI.request('article-byline-set', {\n\t\t\tsave: save,\n\t\t\tbyline: byline\n\t\t}, callback);\n\t};\n\n\t/**\n * Set geolocation\n *\n * @param {Object} geolocations The location to set\n * @param {Function} callback function(Boolean), called when it has been set\n */\n\tArticleCommunicator.prototype.setGeolocations = function (geolocations, callback) {\n\t\tPluginAPI.request('article-geolocations-set', {\n\t\t\tgeolocations: geolocations\n\t\t}, callback);\n\t};\n\n\t/**\n * Get geolocation\n *\n * @param {Function} callback function(Object), retrieves the currently set geo location\n */\n\tArticleCommunicator.prototype.getGeolocations = function (callback) {\n\t\tPluginAPI.request('article-geolocations-get', null, callback);\n\t};\n\n\t/**\n * Fetches a list of all properties available to an article.\n *\n * @param {Function} callback Callback called with an array of property objects.\n */\n\tArticleCommunicator.prototype.getProperties = function (callback) {\n\t\tPluginAPI.request('article-properties-get', null, callback);\n\t};\n\n\t/**\n * Updates and saves one or more property values. The input is a simple object with property names and their\n * new value. The supplied callback is called with an updated list of properties.\n *\n * @example\n * PluginAPI.Article.setProperties({\n * fooProperty: \"bar\",\n * barProperty: \"foo\"\n * }, function(properties) {\n * // Returns a complete and updated list of properties.\n * })\n *\n * @param {Object} properties An object of property names and corresponding values.\n * @param {Function} callback Callback called with an updated list of properties.\n */\n\tArticleCommunicator.prototype.setProperties = function (properties, callback) {\n\t\tPluginAPI.request('article-properties-set', {\n\t\t\tproperties: properties\n\t\t}, callback);\n\t};\n\n\t/**\n * Updates and saves a single property.\n *\n * @param {String} name The property to update.\n * @param {Object} value The updated value.\n * @param {Function} callback Callback called with an updated list of properties.\n */\n\tArticleCommunicator.prototype.setProperty = function (name, value, callback) {\n\t\tconst data = {};\n\t\tdata[name] = value;\n\t\tPluginAPI.request('article-properties-set', {\n\t\t\tproperties: data\n\t\t}, callback);\n\t};\n\n\tArticleCommunicator.prototype.getTopic = function (callback) {\n\t\tPluginAPI.request('article-topic-get', null, callback);\n\t};\n\n\tArticleCommunicator.prototype.setTopic = function (name, callback) {\n\t\tPluginAPI.request('article-topic-set', {\n\t\t\ttopic: name\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Get article package data, including content of sub articles\n\t *\n\t * @param {Function} callback function(Object)\n\t */\n\tArticleCommunicator.prototype.getPackage = function (callback) {\n\t\tPluginAPI.request('package-get', null, callback);\n\t};\n\n\treturn new ArticleCommunicator();\n\n};\n","/**\n * @example\n * PluginAPI.on('afterCreate', function() {\n * PluginAPI.Article.setSource('Ny Times');\n * });\n * PluginAPI.on('beforeSave', function() {\n * if (!articleIsAwesome()) {\n * return false;\n * }\n * });\n *\n * @description\n *\n *

DrPublish provides a large set of default events that an plugin can listen for. All events that start their name with 'before' can be stopped by an plugin. This is done by returning 'false' from the callback function, as in the 'beforSave' example given bellow.

\n *

Other plugins can also supply their own events using the PluginAPI.emit(...) function. Documention on these events are up to each plugin to create.

\n *

Available Events

\n *

addCategory

\n *
\n *

triggered after a category has been added to the article

\n *
\n *

addTag

\n *
\n *

triggered after a tag had been added to the article

\n *
\n *

pluginWindowMaximized

\n *
\n *

triggered when the plugin pane is maximized

\n *
\n *

pluginWindowRestored

\n *
\n *

triggered when the plugin pane is restored to its' original size

\n *
\n *

changedCustomMeta

\n *
\n *

triggered when a custom meta property is changed/set, parameter is an object with property name and value

\n *
\n *

receivedFocus

\n *
\n *

triggered when a plugin receives focus. Receives a parameter object that has two predefined values: previousPluginName - name of previous plugin, givenFocus - true when focus was sent from another plugin. The parameter object can also contain other keys supplied by the plugin losing focus.

\n *
\n *

afterCreate

\n *
\n *

triggered after a new article has been created

\n *
\n *

beforeDelete

\n *
\n *

triggered before an article is deleted

\n *
\n *

afterDelete

\n *
\n *

triggered after an article has been deleted

\n *
\n *

afterLoad

\n *
\n *

triggered after an article has been loaded

\n *
\n *

afterPublish

\n *
\n *

triggered after an article has been published

\n *
\n *

afterSave

\n *
\n *

triggered after an article has been saved

\n *
\n *

beforeCreate

\n *
\n *

triggered before a new article is created

\n *
\n *

beforeLoad

\n *
\n *

triggered before an article is loaded into the editor

\n *
\n *

beforePreview

\n *
\n *

triggered before the article is opened in the preview

\n *
\n *

beforeSave

\n *
\n *

triggered before an article is saved

\n *
\n *

beforePublish

\n *
\n *

triggered before an article is published

\n *
\n *

editorFocus

\n *
\n *

triggered when an editor gets focus

\n *
\n *

editorUnfocus

\n *
\n *

triggered when an editor loses focus

\n *
\n *

editorsLostFocus

\n *
\n *

triggered when all editors loses focus

\n *
\n *

editorReady

\n *
\n *

triggered when the editor has been fully loaded and is ready for input

\n *
\n *

modifiedContent

\n *
\n *

triggered whenever content changes in the article

\n *
\n *

elementRemoved

\n *
\n *

triggered when a plugin element from the current plugin is removed, receives an object with element id as a parameter

\n *
\n *

pluginElementClicked

\n *
\n *

triggered when someone clicks on a plugin element in the editor

\n *
\n *

pluginElementSelected

\n *
\n *

triggers when someone selects a plugin element in the editor

\n *
\n *

pluginElementDeselected

\n *
\n *

triggered when someone deselects a plugin element in the editor

\n *
\n */\nclass Listeners {\n\tconstructor() {\n\t\tthis._listeners = {};\n\t}\n\n\n\t/**\n\t * @deprecated Use PluginAPI.on(...) instead\n\t * @param {Object} listeners\n\t */\n\taddAll(listeners) {\n\t\tconst PluginAPI = require('./PluginAPI');\n\t\t'use strict';\n\t\tconst createCallback = function (callback) {\n\t\t\treturn function (data) {\n\t\t\t\tcallback(data.data);\n\t\t\t};\n\t\t};\n\t\tfor (const eventName in listeners) {\n\t\t\tif (listeners.hasOwnProperty(eventName)) {\n\t\t\t\tconst callback = listeners[eventName];\n\t\t\t\tconst callWrapper = createCallback(callback);\n\t\t\t\tPluginAPI.on(eventName, callWrapper);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Adds a new listener\n\t *\n\t * @param {String} event Event name\n\t * @param {Function} callback Function to call when an even of the type is received\n\t * @return {number}\n\t */\n\tadd(event, callback) {\n\n\t\tif (typeof callback !== 'function') {\n\t\t\tthrow new Error('not a function');\n\t\t}\n\n\t\tif (this._listeners[event] === undefined) {\n\t\t\tthis._listeners[event] = [];\n\t\t}\n\n\t\tthis._listeners[event].push(callback);\n\t\treturn this._listeners[event].length - 1;\n\t}\n\n\t/**\n\t * Removes the listener at the given index\n\t *\n\t * @param {String} event Event type\n\t * @param {Function} index The index of the event handler to remove\n\t */\n\tremove(event, index) {\n\n\t\tif (this._listeners[event] === undefined || this._listeners[event][index] === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\t/*\n\t\t * Set to null instead of remove to retain callback indexes\n\t\t */\n\t\tthis._listeners[event][index] = false;\n\t}\n\n\t/**\n\t * Removes all listeners for the given event type, or if !event then removes all listeners\n\t *\n\t * @param {String} event Event type to remove handlers for (!event for all)\n\t */\n\tremoveAll(event) {\n\t\tif (!event) {\n\t\t\tthis._listeners = [];\n\t\t} else {\n\t\t\tthis._listeners[event] = [];\n\t\t}\n\t}\n\n\t/**\n\t * Notifies all registered listeners that an event has occurred\n\t *\n\t * @param {String} event Event type\n\t * @param {Object} payload The event data\n\t * @return {Boolean}\n\t */\n\tnotify(event, payload) {\n\t\tlet returnValue = true;\n\t\tif (this._listeners[event] === undefined) {\n\t\t\treturn returnValue;\n\t\t}\n\n\t\t// If the payload is an object with a key data, we use that value as the payload we pass to the listener functions.\n\t\t// This is needed as we have some inconsistencies in how we pass data around. This normalization should preferably\n\t\t// be done at the call site.\n\t\tthis._listeners[event].forEach((listenerFn) => {\n\t\t\tif (typeof listenerFn !== 'function') {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlet res = null;\n\t\t\tif (payload && payload.params && payload.params === true) {\n\t\t\t\tres = listenerFn.apply(null, payload.data);\n\t\t\t} else if (typeof payload === 'object' && payload !== null && typeof payload.data !== 'undefined') {\n\t\t\t\tres = listenerFn(payload.data);\n\t\t\t} else {\n\t\t\t\tres = listenerFn(payload);\n\t\t\t}\n\t\t\tif (res === false) {\n\t\t\t\treturnValue = false;\n\t\t\t}\n\t\t});\n\t\treturn returnValue;\n\t}\n\n}\n\nmodule.exports = Listeners;\n","/* eslint max-statements: [\"error\", 100000000] */\n/* eslint complexity: [\"error\", 100000000] */\n/* global pm */\n\nconst ah5Communicator = require('./AH5Communicator');\nconst articleCommunicator = require('./ArticleCommunicator');\nconst Listeners = require('./Listeners');\n\nconst PluginAPI = (function () {\n\n\t/**\n\t *\n\t * Namespace for all public DrPublish methods available from plugins.\n\t *\n\t * @class\n\t * @classdesc The basic API object\n\t * @exports PluginAPI\n\t *\n\t */\n\tconst Api = function () {\n\n\t\tconst queryParameters = {};\n\t\twindow.location.search.substr(1).split('&').forEach((queryPair) => {\n\t\t\tqueryParameters[queryPair.split('=')[0]] = queryPair.split('=')[1];\n\t\t});\n\n\n\t\tthis.DEBUG = false;\n\n\t\tthis.Version = '1.0';\n\t\tthis.Editor = null;\n\t\tthis.Article = null;\n\t\tthis.errorListeners = new Listeners();\n\t\tthis.eventListeners = new Listeners();\n\t\tthis.appName = queryParameters.appName || '';\n\t\tthis.jwt = queryParameters.jwt || '';\n\t\tthis.standAlone = queryParameters.standAlone && queryParameters.standAlone === 'true' || false;\n\t\tthis.selectedPluginElement = null;\n\n\t\tconst self = this;\n\n\t\tpm.bind('event', (data) => {\n\t\t\tconst createEventFunction = function (eventName) {\n\t\t\t\treturn function (data) {\n\t\t\t\t\tPluginAPI.request(eventName, data);\n\t\t\t\t};\n\t\t\t};\n\t\t\tconst updateObject = function (data) {\n\t\t\t\tfor (const key in data) {\n\t\t\t\t\tif (data.hasOwnProperty(key)) {\n\t\t\t\t\t\tif (typeof data[key] === 'object' && data[key] !== null && data[key].type === 'function') {\n\t\t\t\t\t\t\tdata[key] = createEventFunction(data[key].eventKey);\n\t\t\t\t\t\t} else if (typeof data[key] === 'object' && data[key] !== null && typeof data[key].map === 'function') {\n\t\t\t\t\t\t\tdata[key] = data[key].map(updateObject);\n\t\t\t\t\t\t} else if (typeof data[key] === 'object' && data[key] !== null) {\n\t\t\t\t\t\t\tdata[key] = updateObject(data[key]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn data;\n\t\t\t};\n\t\t\tdata.data = updateObject(data.data);\n\n\t\t\tdata = self.eventListeners.notify(data.type, data.data);\n\t\t\tif (typeof data === 'undefined') {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (data === false) {\n\t\t\t\treturn {'abort': true};\n\t\t\t}\n\t\t\treturn data;\n\t\t}, '*');\n\t};\n\n\t/**\n\t * Dispatches a request to DrPublish, and returns the reply to callback On error, notifies all error listeners based on the index .type of the thrown object\n\t *\n\t * @param {String} callSpec What do you want to call?\n\t * @param {Object} data The data attached to the request\n\t * @param {Function} callback The function to call upon return\n\t */\n\tApi.prototype.request = function (callSpec, data, callback) {\n\t\tconst self = this;\n\t\tif (this.DEBUG) {\n\t\t\tconsole.info(this.getPluginName() + ': Requesting ' + callSpec + ' from parent with data', data);\n\t\t}\n\n\t\tif (!data) {\n\t\t\tdata = {};\n\t\t}\n\n\t\tif (typeof callback === 'undefined') {\n\t\t\tcallback = null;\n\t\t}\n\n\t\tif (typeof data.length === 'number') {\n\t\t\tdata = {data: data};\n\t\t}\n\n\t\tdata['src_app'] = this.getPluginName();\n\n\t\tconst createEventFunction = function (func, eventKey) {\n\t\t\treturn function () {\n\t\t\t\tself.eventListeners.remove(eventKey, eventKey);\n\t\t\t\treturn func.apply(null, arguments);\n\t\t\t};\n\t\t};\n\n\n\t\tconst createCallbackObject = function (key, callback) {\n\t\t\tconst random = Math.floor(Math.random() * 1000);\n\t\t\tconst eventKey = key + random + 'functioncallback' + (new Date()).getTime();\n\t\t\tconst eventFunction = createEventFunction(callback, eventKey);\n\t\t\tself.eventListeners.add(eventKey, eventFunction);\n\t\t\treturn {\n\t\t\t\ttype: 'function',\n\t\t\t\teventKey: eventKey\n\t\t\t};\n\t\t};\n\n\t\tconst updateObject = function (data) {\n\t\t\tfor (const key in data) {\n\t\t\t\tif (data.hasOwnProperty(key)) {\n\t\t\t\t\tconst val = data[key];\n\t\t\t\t\tif (typeof val === 'function') {\n\t\t\t\t\t\tdata[key] = createCallbackObject(key, val);\n\t\t\t\t\t} else if (typeof val === 'object' && val !== null && typeof val.map === 'function') {\n\t\t\t\t\t\tdata[key] = val.map(updateObject);\n\t\t\t\t\t} else if (typeof val === 'object' && val !== null) {\n\t\t\t\t\t\tdata[key] = updateObject(val);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn data;\n\t\t};\n\t\tdata = updateObject(data);\n\n\t\tpm({\n\t\t\ttarget: parent,\n\t\t\ttype: callSpec,\n\t\t\tdata: data,\n\t\t\tsuccess: callback,\n\t\t\terror: (data) => {\n\t\t\t\tself.errorListeners.notify(data.type, data);\n\t\t\t},\n\t\t\torigin: '*', // TODO: Find a way of avoiding all-origins\n\t\t\thash: false\n\t\t});\n\t};\n\n\n\t/**\n\t * Creates a new tag\n\t *\n\t * @param {String} tag The tag to create\n\t * @param {Function} callback function(Boolean)\n\t */\n\tApi.prototype.openTagCreationDialog = function (tag, callback) {\n\t\tthis.request('create-tag', {\n\t\t\ttag: tag\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Reloads the plugins's iframe\n\t */\n\tApi.prototype.reloadIframe = function () {\n\n\t\tthis.request('app-reload', {\n\t\t\tapp: this.getPluginName()\n\t\t});\n\t};\n\n\t/**\n\t * Get the name of the loaded plugin\n\t *\n\t * @return {String} The name of the plugin, or false if it couldn't be detected\n\t */\n\tApi.prototype.getPluginName = function () {\n\t\treturn this.appName;\n\t};\n\n\t/**\n\t * Get the name of the loaded plugin\n\t * @deprecated: use getPluginName instead\n\t * @return {String} The name of the plugin, or false if it couldn't be detected\n\t */\n\tApi.prototype.getAppName = function () {\n\t\treturn this.getPluginName();\n\t};\n\n\t/**\n\t * Set the name of the plugin\n\t *\n\t * @param {String} name The name of the plugin\n\t */\n\tApi.prototype.setPluginName = function (name) {\n\t\tthis.appName = name;\n\t};\n\n\t/**\n\t * Set the name of the plugin\n\t * @deprecated: use setPluginName instead\n\t *\n\t * @param {String} name The name of the plugin\n\t */\n\tApi.prototype.setAppName = function (name) {\n\t\tthis.setPluginName(name);\n\t};\n\n\t/**\n\t * Show info-message to the user\n\t *\n\t * @param {String} msg Message to be displayed\n\t */\n\tApi.prototype.showInfoMsg = function (msg) {\n\n\t\tthis.request('show-message-info', {\n\t\t\tmessage: msg\n\t\t});\n\t};\n\n\t/**\n\t * Show warning-message to the user\n\t *\n\t * @param {String} msg Message to be displayed\n\t */\n\tApi.prototype.showWarningMsg = function (msg) {\n\n\t\tthis.request('show-message-warning', {\n\t\t\tmessage: msg\n\t\t});\n\t};\n\n\t/**\n\t * Show error-message to the user\n\t *\n\t * @param {String} msg Message to be displayed\n\t */\n\tApi.prototype.showErrorMsg = function (msg) {\n\n\t\tthis.request('show-message-error', {\n\t\t\tmessage: msg\n\t\t});\n\t};\n\n\t/**\n\t * Show the loader\n\t *\n\t * @param {String} msg Message to display in progress loader\n\t */\n\tApi.prototype.showLoader = function (msg) {\n\t\tthis.request('show-loader', {\n\t\t\tmessage: msg\n\t\t});\n\t};\n\n\t/**\n\t * Hide the loader\n\t */\n\tApi.prototype.hideLoader = function () {\n\t\tthis.request('hide-loader');\n\t};\n\n\n\t/**\n\t * Loads an old revision of an article\n\t *\n\t * @param {Number} id The id of the revision to load\n\t * @param {Function} callback The function to call when the new revision has been loaded\n\t * @private\n\t */\n\tApi.prototype.__loadArticleRevision = function (id, callback) {\n\t\tthis.request('load-revision', {\n\t\t\trevision: id\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Creates a new tag\n\t *\n\t * @param {String} tag JSON object with the tag to create, must contain tagTypeId and name properties\n\t * @param {Function} callback function(Boolean)\n\t */\n\tApi.prototype.createTag = function (tag, callback) {\n\t\tthis.request('tag-create', {\n\t\t\ttag: tag\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Sends a query to DrLib\n\t *\n\t * @example\n\t * PluginAPI.searchDrLib({\n\t * query: 'articles.json?q=awesome',\n\t * secure: true,\n\t * success: function(data) {\n\t * data.items.forEach(doStuffWithArticle);\n\t * },\n\t * error: function(data) {\n\t * console.warn('something went wrong');\n\t * }\n\t * })\n\t *\n\t * @param {Object} data Object with three properties; 'query' which is the query to send to DrLib, 'success' which is the callback to execute on success, and 'secure' a boolean to add the internal API key to the query and thus allow searching on unpublished article. This callback's parameter is an object which is the query result as an object. See the json output of DrLib to learn more about this object\n\t * @param {Function} callback function(Boolean)\n\t *\n\t */\n\tApi.prototype.searchDrLib = function (data, callback) {\n\t\tthis.request('drlib-search', {\n\t\t\tquery: data.query,\n\t\t\taccess: data.access,\n\t\t\tsecure: data.secure,\n\t\t\tsuccess: data.success,\n\t\t\terror: data.error\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Generates proper html code to represent the dom element. This is NOT an asynchronous function\n\t *\n\t * @param {Object} dom The dom node to convert\n\t * @return {String} The html code\n\t */\n\t// TODO: This function should also be able to take a DOMElement or similar.\n\tApi.prototype.convertDomToHTML = function (dom) {\n\t\tif (typeof dom === 'object' && typeof dom.wrap === 'function') {\n\t\t\treturn dom.wrap('
').parent().html();\n\t\t} else {\n\t\t\tconst domClone = dom.cloneNode(true);\n\t\t\tconst wrapper = document.createElement('div');\n\t\t\twrapper.appendChild(domClone);\n\t\t\treturn wrapper.innerHTML;\n\t\t}\n\t};\n\n\t/**\n\t * Generates an url to a published article\n\t *\n\t * @param {String} id The id of the article to generate url for\n\t * @param {Function} callback function(String), where the parameter is the generated url\n\t */\n\tApi.prototype.generateArticleUrl = function (id, callback) {\n\t\tthis.request('generate-article-url', {\n\t\t\tid: id\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Extends the PluginAPI with custom functionality that other plugins can use\n\t *\n\t * @param {String} group Group name for functionality to add\n\t * @param {String} name Name of the specific function to add\n\t * @param {Function} action function(Object) Function to call when the API is invoked, recieves one parameter as given in PluginAPI.callExtendedApi and return value is passed back to the caller\n\t */\n\tApi.prototype.extendApi = function (group, name, action) {\n\t\tconst self = this;\n\t\tthis.request('extend-api', {\n\t\t\tgroup: group,\n\t\t\tname: name,\n\t\t\taction: (data) => {\n\t\t\t\tconst a = action(data.data);\n\t\t\t\tself.request(data.eventKey, {'data': a});\n\t\t\t}\n\t\t});\n\t};\n\n\t/**\n\t * Call the extended PluginAPI\n\t *\n\t * @param {String} group Group name for functionality to call\n\t * @param {String} name Name of the specific function to call\n\t * @param {Object} data Data object to pass as parameter to the api call\n\t * @param {Function} callback function(Object) Function to recieve the API response, parameter is the response from the API call\n\t */\n\tApi.prototype.callExtendedApi = function (group, name, data, callback) {\n\t\tthis.request('call-extended-api', {\n\t\t\tgroup: group,\n\t\t\tname: name,\n\t\t\tdata: data,\n\t\t\tcallback: callback\n\t\t});\n\t};\n\n\t/**\n\t * Gets logged in user\n\t *\n\t * @param {Function} callback function(Object)\n\t */\n\tApi.prototype.getCurrentUser = function (callback) {\n\t\tthis.request('get-current-user', null, callback);\n\t};\n\n\t/**\n\t * Get configuration information about the plugin\n\t *\n\t * @param {Function} callback function(Object)\n\t */\n\tApi.prototype.getConfiguration = function (callback) {\n\t\tthis.request('get-configuration', null, callback);\n\t};\n\n\t/**\n\t * Get DrPublish configuration\n\t *\n\t * @param {Function} callback function(Object)\n\t */\n\tApi.prototype.getDrPublishConfiguration = function (callback) {\n\t\tthis.request('get-drpublish-configuration', null, callback);\n\t};\n\n\t/**\n\t * Set configuration information about the plugin\n\t *\n\t * @param {Object} config The configuration object to save\n\t * @param {Object} options Object, can have three keys.\n\t * 'onlyPublication' (boolean) If true the configuration is set for the current publication only\n\t * 'success' (function) Called if the configuration was saved successfully\n\t * 'error' (function) Called if there was an error, recieves and error object as first parameter\n\t * @param {Function} callback function()\n\t */\n\tApi.prototype.setConfiguration = function (config, options, callback) {\n\t\t// support old function signature\n\t\tif (typeof options === 'boolean') {\n\t\t\toptions = {\n\t\t\t\tonlyPublication: options\n\t\t\t};\n\t\t} else if (typeof options !== 'object' || options === null) {\n\t\t\toptions = {};\n\t\t}\n\t\tconst data = {\n\t\t\tconfig: config,\n\t\t\tonlyPublication: typeof options.onlyPublication === 'boolean' ? options.onlyPublication : false,\n\t\t\tsuccess: typeof options.success === 'function' ? options.success : null,\n\t\t\terror: typeof options.error === 'function' ? options.error : null\n\t\t};\n\t\tthis.request('set-configuration', data, callback);\n\t};\n\n\t/**\n\t * Emits an event to DrPublish, and possibly other apps\n\t *\n\t * @param {String} name Name of the event\n\t * @param {String} data Data object to send with the event\n\t */\n\tApi.prototype.emit = function (name, data) {\n\t\tthis.request('emit-api-event', {\n\t\t\tname: name,\n\t\t\tdata: data\n\t\t});\n\t};\n\n\t/**\n\t * Listen for an event. If the callback returns false the event may cancel continued actions, e.g beforeSave can cancel article save. Look at documentation for Listeners to learn more.\n\t *\n\t * @param {String} name Name of the event\n\t * @param {Function} callback function(Object) Function to call when the event is triggered. Recieves one data object parameter of the form {source: , data: }\n\t */\n\tApi.prototype.on = function (name, callback) {\n\t\tconst self = this;\n\t\tself.eventListeners.add(name, callback);\n\t\tthis.request('on-api-event', {\n\t\t\tname: name\n\t\t});\n\t};\n\n\t/**\n\t * Increase the counter of actions required by the user, used to tell the user that the plugin requires input of some kind\n\t *\n\t * @param {Function} callback function(Object) function to call once the counter has been increased, returns the new counter value\n\t */\n\tApi.prototype.increaseRequiredActionCounter = function (callback) {\n\t\tthis.request('increase-required-action-counter', {}, callback);\n\t};\n\n\t/**\n\t * Decrease the counter of actions required by the user, used to tell the user that the plugin requires input of some kind\n\t *\n\t * @param {Function} callback function(Object) function to call once the counter has been decrease, returns current counter value\n\t */\n\tApi.prototype.decreaseRequiredActionCounter = function (callback) {\n\t\tthis.request('decrease-required-action-counter', {}, callback);\n\t};\n\n\t/**\n\t * Clear the counter of actions required by the user, used to tell the user that the plugin requires input of some kind\n\t *\n\t * @param {Function} callback function(Object) function to call once the counter has been cleared\n\t */\n\tApi.prototype.clearRequiredActionCounter = function (callback) {\n\t\tthis.request('clear-required-action-counter', {}, callback);\n\t};\n\n\t/**\n\t * Set the counter of actions required by the user, used to tell the user that the plugin requires input of some kind\n\t *\n\t * @param {Number} count The value to set the counter to\n\t * @param {Function} callback function(Object) function to call once the counter has been cleared\n\t */\n\tApi.prototype.setRequiredActionCounter = function (count, callback) {\n\t\tthis.request('set-required-action-counter', {count: count}, callback);\n\t};\n\n\t/**\n\t * Create a new instance of the Api class\n\t *\n\t * @private\n\t * @return {Object}\n\t */\n\tApi.prototype.create = function () {\n\t\treturn new Api();\n\t};\n\n\t/**\n\t * Create an embedded object of the given type\n\t *\n\t * @param {Number} typeId Type Id of the embedded object to create\n\t * @param {Function} callback function(embeddedObjectId) called once the object has been created, first parameter is the new embedded object id\n\t */\n\tApi.prototype.createEmbeddedObject = function (typeId, callback) {\n\t\tthis.request('create-embedded-object', {typeId: typeId, callback: callback});\n\t};\n\n\t/**\n\t * Get information about the available embedded object types\n\t *\n\t * @param {Function} callback function([Object]) recieves an array with objects describing the available embedded object types in the form of `{typeId: 'embedded object type id', cssClass: 'css class used to style the objects'}`\n\t */\n\tApi.prototype.getEmbeddedObjectTypes = function (callback) {\n\t\tthis.request('get-embedded-object-types', null, callback);\n\t};\n\n\t/**\n\t * Gives focus to another plugin\n\t *\n\t * @param {String} pluginName The name of the plugin to recieve focus\n\t * @param {Object} argument Optional option argument to pass along to the plugin recieving focus\n\t * @param {Boolean} start Flag to decide if the plugin should be started if it has not been loaded previously, default true\n\t * @return {Boolean}\n\t */\n\tApi.prototype.giveFocus = function (pluginName, argument, start) {\n\t\tif (typeof pluginName !== 'string') {\n\t\t\treturn false;\n\t\t}\n\t\tif (typeof start !== 'boolean') {\n\t\t\tstart = true;\n\t\t}\n\t\tthis.request('give-focus', {pluginName: pluginName, start: start, argument: argument});\n\t\treturn true;\n\t};\n\n\n\t/**\n\t * Hide the plugin, so it is no longer visible on the list of open plugins\n\t * @return {Boolean}\n\t */\n\tApi.prototype.hide = function () {\n\t\tthis.request('hide');\n\t\treturn true;\n\t};\n\n\t/**\n\t *

Creates a jQuery UI modal in the main editor window, detached from the plugin itself. Modals are unique on a\n\t * per-plugin basis, meaning that a plugin can only have a single modal at a time. Creating a new modal will\n\t * overwrite the previous.

\n\t *\n\t * See the official documentation for a list of available options.

\n\t *\n\t *

Note that you do not have direct access to the DOM of the modal. Use the provided helper methods to\n\t * manipulate or read from the modal:\n\t *

\n\t *

\n\t *\n\t * @example\n\t *\n\t * PluginAPI.createModal('

This is a modal

', {\n\t * buttons: {\n\t * Ok: function () {\n\t * alert('Ok!');\n\t * }\n\t * }\n\t * });\n\t *\n\t * PluginAPI.updateModal('

This is the same modal

');\n\t *\n\t * PluginAPI.createModal('

This is a brand new modal

', {\n\t * buttons: {\n\t * cancel: function() {\n\t * PluginAPI.closeModal(true);\n\t * }\n\t * }\n\t * });\n\t *\n\t * @param {String} content An HTML string\n\t * @param {Object} options A standard jQuery UI options object.\n\t * @return {Boolean}\n\t */\n\tApi.prototype.createModal = function (content, options) {\n\t\tthis.request('create-custom-modal', {content: content, options: options});\n\t\treturn true;\n\t};\n\n\t/**\n\t * Updates the HTML content of a live modal. Has no effect if the modal does not exist.\n\t *\n\t * @param {String} content An HTML string\n\t * @return {Boolean}\n\t */\n\tApi.prototype.updateModal = function (content) {\n\t\tthis.request('update-custom-modal', {content: content});\n\t\treturn true;\n\t};\n\n\t/**\n\t * Closes and optionally deletes the modal. Has no effect if the modal does not exists.\n\t *\n\t * @param {Boolean} destroy Whether or not to delete the modal\n\t * @return {Boolean}\n\t */\n\tApi.prototype.closeModal = function (destroy) {\n\t\tthis.request('close-custom-modal', {destroy: destroy});\n\t\treturn true;\n\t};\n\n\t/**\n\t * Returns the values of all input or select elements within a modal.\n\t *\n\t * The values are keyed by one of the following properties in order of priority: element ID, element name\n\t * or input type + index.\n\t *\n\t * @example\n\t * Given a modal with the following HTML content:\n\t *\n\t *
\n\t * \n\t * \n\t * \n\t *
\n\t *\n\t * getModalInputs would return:\n\t *\n\t * {\n\t * \"number-0\": {VALUE}\n\t * \"name\": {VALUE},\n\t * \"languages\": \"en\"\n\t * }\n\t *\n\t * @param {Function} callback\n\t */\n\tApi.prototype.getModalInputs = function (callback) {\n\t\tthis.request('get-custom-modal-inputs', null, callback);\n\t};\n\n\tApi.prototype.confirmAuthenticated = function () {\n\t\tthis.request('confirm-authenticated', {\n\t\t\tpluginName: this.appName\n\t\t});\n\t};\n\n\tApi.prototype.isStandAlone = function () {\n\t\treturn this.standAlone;\n\n\t};\n\n\t/**\n * Get the JWT as defined on DrPublish publication config. This token can be used to authenticate the request\n * @return {*|string}\n */\n\tApi.prototype.getJWT = function () {\n\t\treturn this.jwt;\n\t};\n\n\tApi.prototype.replaceEditorComponentsExtension = function (data) {\n\t\tthis.request('replace-editor-components-extension', data);\n\t};\n\n\tApi.prototype.clearEditorComponentsExtension = function (data) {\n\t\tthis.request('clear-editor-components-extension', data);\n\t};\n\n\tApi.prototype.highlightAnnotation = function (data) {\n\t\tthis.request('highlight-annotation', data);\n\t};\n\n\tApi.prototype.underemphasizeAnnotations = function (data) {\n\t\tthis.request('underemphasize-annotations', data);\n\t};\n\n\tApi.prototype.registerExternallyDefinedProperties = function (data) {\n\t\tthis.request('register-externally-defined-properties', data);\n\t};\n\n\treturn new Api();\n})();\n\nPluginAPI.Article = articleCommunicator(PluginAPI);\nPluginAPI.Editor = ah5Communicator(PluginAPI);\n\nmodule.exports = PluginAPI;\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/bundle.min.js b/dist/bundle.min.js index 74af221..4364eaa 100644 --- a/dist/bundle.min.js +++ b/dist/bundle.min.js @@ -1,2 +1,2 @@ -!function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t():"function"===typeof define&&define.amd?define([],t):"object"===typeof exports?exports.PluginAPI=t():e.PluginAPI=t()}(window,function(){return function(e){var t={};function o(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,o),r.l=!0,r.exports}return o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)o.d(n,r,function(t){return e[t]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=0)}([function(e,t,o){var n,r,i;r=[e,o(1),o(2),o(3)],void 0===(i="function"===typeof(n=function(e,t,o,n){"use strict";function r(e){return(r="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var i,u=((i=function(){this.DEBUG=!1,this.Version="1.0",this.Editor=null,this.Article=null,this.errorListeners=new n,this.eventListeners=new n,this.appName="",this.selectedPluginElement=null;var e=this;pm.bind("event",function(t){var o=function(e){return function(t){u.request(e,t)}};return t.data=function e(t){for(var n in t)t.hasOwnProperty(n)&&("object"===r(t[n])&&null!==t[n]&&"function"===t[n].type?t[n]=o(t[n].eventKey):"object"===r(t[n])&&null!==t[n]&&"function"===typeof t[n].map?t[n]=t[n].map(e):"object"===r(t[n])&&null!==t[n]&&(t[n]=e(t[n])));return t}(t.data),"undefined"===typeof(t=e.eventListeners.notify(t.type,t.data))||(!1===t?{abort:!0}:t)},"*")}).prototype.request=function(e,t,o){var n=this;this.DEBUG&&console.info(this.getAppName()+": Requesting "+e+" from parent with data",t),t||(t={}),"undefined"===typeof o&&(o=null),"number"===typeof t.length&&(t={data:t}),t.src_app=this.getAppName();var i=function(e,t){var o=Math.floor(1e3*Math.random()),r=e+o+"functioncallback"+(new Date).getTime(),i=function(e,t){return function(){return n.eventListeners.remove(t,t),e.apply(null,arguments)}}(t,r);return n.eventListeners.add(r,i),{type:"function",eventKey:r}};t=function e(t){for(var o in t)if(t.hasOwnProperty(o)){var n=t[o];"function"===typeof n?t[o]=i(o,n):"object"===r(n)&&null!==n&&"function"===typeof n.map?t[o]=n.map(e):"object"===r(n)&&null!==n&&(t[o]=e(n))}return t}(t),pm({target:parent,type:e,data:t,success:o,error:function(e){n.errorListeners.notify(e.type,e)},origin:"*",hash:!1})},i.prototype.openTagCreationDialog=function(e,t){this.request("create-tag",{tag:e},t)},i.prototype.reloadIframe=function(){this.request("app-reload",{app:this.getAppName()})},i.prototype.getAppName=function(){return this.appName},i.prototype.setAppName=function(e){this.appName=e},i.prototype.showInfoMsg=function(e){this.request("show-message-info",{message:e})},i.prototype.showWarningMsg=function(e){this.request("show-message-warning",{message:e})},i.prototype.showErrorMsg=function(e){this.request("show-message-error",{message:e})},i.prototype.showLoader=function(e){this.request("show-loader",{message:e})},i.prototype.hideLoader=function(){this.request("hide-loader")},i.prototype.addListeners=function(e){var t=function(e){return function(t){e(t.data)}};for(var o in e)if(e.hasOwnProperty(o)){var n=e[o],r=t(n);this.on(o,r)}},i.prototype.__loadArticleRevision=function(e,t){this.request("load-revision",{revision:e},t)},i.prototype.createTag=function(e,t){this.request("tag-create",{tag:e},t)},i.prototype.searchDrLib=function(e,t){this.request("drlib-search",{query:e.query,access:e.access,secure:e.secure,success:e.success,error:e.error},t)},i.prototype.convertDomToHTML=function(e){if("object"===r(e)&&"function"===typeof e.wrap)return e.wrap("
").parent().html();var t=e.cloneNode(!0),o=document.createElement("div");return o.appendChild(t),o.innerHTML},i.prototype.generateArticleUrl=function(e,t){this.request("generate-article-url",{id:e},t)},i.prototype.extendApi=function(e,t,o){var n=this;this.request("extend-api",{group:e,name:t,action:function(e){var t=o(e.data);n.request(e.eventKey,{data:t})}})},i.prototype.callExtendedApi=function(e,t,o,n){this.request("call-extended-api",{group:e,name:t,data:o,callback:n})},i.prototype.getCurrentUser=function(e){this.request("get-current-user",null,e)},i.prototype.getConfiguration=function(e){this.request("get-configuration",null,e)},i.prototype.getDrPublishConfiguration=function(e){this.request("get-drpublish-configuration",null,e)},i.prototype.setConfiguration=function(e,t,o){"boolean"===typeof t?t={onlyPublication:t}:"object"===r(t)&&null!==t||(t={});var n={config:e,onlyPublication:"boolean"===typeof t.onlyPublication&&t.onlyPublication,success:"function"===typeof t.success?t.success:null,error:"function"===typeof t.error?t.error:null};this.request("set-configuration",n,o)},i.prototype.emit=function(e,t){this.request("emit-api-event",{name:e,data:t})},i.prototype.on=function(e,t){this.eventListeners.add(e,t),this.request("on-api-event",{name:e})},i.prototype.increaseRequiredActionCounter=function(e){this.request("increase-required-action-counter",{},e)},i.prototype.decreaseRequiredActionCounter=function(e){this.request("decrease-required-action-counter",{},e)},i.prototype.clearRequiredActionCounter=function(e){this.request("clear-required-action-counter",{},e)},i.prototype.setRequiredActionCounter=function(e,t){this.request("set-required-action-counter",{count:e},t)},i.prototype.create=function(){return new i},i.prototype.createEmbeddedObject=function(e,t){this.request("create-embedded-object",{typeId:e,callback:t})},i.prototype.getEmbeddedObjectTypes=function(e){this.request("get-embedded-object-types",null,e)},i.prototype.giveFocus=function(e,t,o){return"string"===typeof e&&""!==e&&("boolean"!==typeof o&&(o=!0),this.request("give-focus",{pluginName:e,start:o,argument:t}),!0)},i.prototype.hide=function(){return this.request("hide"),!0},i.prototype.createModal=function(e,t){return this.request("create-custom-modal",{content:e,options:t}),!0},i.prototype.updateModal=function(e){return this.request("update-custom-modal",{content:e}),!0},i.prototype.closeModal=function(e){return this.request("close-custom-modal",{destroy:e}),!0},i.prototype.getModalInputs=function(e){this.request("get-custom-modal-inputs",null,e)},i.prototype.confirmAuthenticated=function(){this.request("confirm-authenticated",{pluginName:this.appName})},new i);u.Article=o(u),u.Editor=t(u),e.exports=u})?n.apply(t,r):n)||(e.exports=i)},function(e,t,o){var n,r,i;r=[e],void 0===(i="function"===typeof(n=function(e){"use strict";function t(e){return(t="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}e.exports=function(e){var o=null,n=function(){this.DEBUG=!1,e.on("pluginElementClicked",function(e){o=e}),e.on("pluginElementDeselected",function(){o=null})};return n.prototype.getActiveEditor=function(t){e.request("get-active-editor",null,t)},n.prototype.registerMenuAction=function(t,o){e.request("register-menu-action",t,o)},n.prototype.registerHoverAction=function(t,o){e.request("register-hover-action",t,o)},n.prototype.directionalCastle=function(t,o){e.request("editor-directional-castle",t,o)},n.prototype.registerMenuActionGroup=function(t,o){e.request("register-menu-action-group",t,o)},n.prototype.getEditorType=function(t){e.request("editor-get-type",null,t)},n.prototype.replaceElementById=function(t,o,n){e.request("editor-element-replace-byid",{id:t,element:o},n)},n.prototype.replacePluginElementById=function(t,o,n){e.request("editor-element-replace-plugin-element-byid",{id:t,element:o},n)},n.prototype.deleteElementById=function(t,o){e.request("editor-element-replace-byid",{id:t},o)},n.prototype.getHTMLById=function(t,o){e.request("editor-element-get-byid",{id:t},o)},n.prototype.getHTMLBySelector=function(t,o){e.request("editor-elements-get-byselector",{selector:t},o)},n.prototype.getCategories=function(t){e.request("get-categories",null,t)},n.prototype.getParentCategories=function(t,o){e.request("get-parent-categories",t,o)},n.prototype.getParentIds=function(t,o,n){e.request("get-parent-ids",{id:t,selector:o},n)},n.prototype.getTagTypes=function(t){e.request("get-tag-types",null,t)},n.prototype.getTagType=function(t,o){e.request("get-tag-type",{id:t},o)},n.prototype.clear=function(t){e.request("editor-clear",null,t)},n.prototype.insertString=function(t,o){e.request("editor-insert-string",{string:t},o)},n.prototype.insertElement=function(o,n,r){var i=!1;"object"===t(n)?i="boolean"===typeof(n=n||{}).select&&n.select:"undefined"===typeof r&&"function"===typeof n&&(r=n),e.request("editor-insert-element",{element:o.outerHTML,select:i},r)},n.prototype.removeClasses=function(t,o,n){e.request("editor-classes-remove",{id:t,classes:o},n)},n.prototype.addClasses=function(t,o,n){e.request("editor-classes-add",{id:t,classes:o},n)},n.prototype.markAsActive=function(t,o){e.request("editor-mark-as-active",{id:t},o)},n.prototype.setAttributeById=function(t,o,n,r){e.request("editor-element-attribute-set-byid",{id:t,attribute:o,value:n},r)},n.prototype.setStyleById=function(t,o,n,r){e.request("editor-element-style-set-byid",{id:t,attribute:o,value:n},r)},n.prototype.initMenu=function(t,o){e.request("editor-initialize-menu",{menus:t},o)},n.prototype.openPluginElementEditor=function(t){e.request("open-element-editor",{id:t})},n.prototype.getTotalWordCount=function(t){e.request("total-word-count",null,t)},n.prototype.getTotalCharCount=function(t){e.request("total-char-count",null,t)},n.prototype.updateAssetOption=function(t,o,n,r){e.request("update-asset-option",{dpArticleId:t,key:o,value:n},r)},n.prototype.updateAssetData=function(t,o){e.request("update-asset-media",t,o)},n.prototype.getAssetData=function(t,o){e.request("get-asset-data",{data:t},o)},n.prototype.insertNestedAsset=function(t,o,n,r){var i=this;function u(t){e.request("update-embedded-asset",n,t)}e.createEmbeddedObject(n.embeddedTypeId,function(s){!function(t,r,u){n.internalId=t;var s="asset-"+t,a=$("
");a.attr("id",s),a.attr("data-internal-id",t),a.attr("data-ah5-type",n.assetSource),n.externalId&&a.attr("data-external-id",n.externalId),n.assetClass&&a.addClass(n.assetClass),a.addClass("dp-plugin-element"),a.html(o),e.Editor.getHTMLById(r,function(e){var t=document.createElement("div");t.innerHTML=e,t.firstChild.setAttribute("id",r+"tmp"),i.replacePluginElementById(r,t.innerHTML,function(){(t=document.createElement("div")).innerHTML=e;var o=t.querySelector(".dp-fact-box-image, .dp-nested-asset-container");n.isMultiple?$(o).append(a.get(0).outerHTML):o.innerHTML=a.get(0).outerHTML,i.replacePluginElementById(r+"tmp",t.innerHTML,u)})})}(s,t,function(e){return u(r)})})},n.prototype.insertEmbeddedAsset=function(t,n,r){var i=this,u=!1;if(o){if(n.assetSource!==e.getAppName())return void e.showErrorMsg("Can't update selected plugin element since it doesn't belong to the '"+e.getAppName()+"' plugin");u=!0}if(o){var s=o.dpArticleId;if(!s)throw Error("Selected plugin element: expected dpArticleId not found (tried reading from attribute 'data-internal-id')");a(s,function(e){return c("function"===typeof r?r(e):null)})}else e.createEmbeddedObject(n.embeddedTypeId,function(e){a(e,function(e){return p("function"===typeof r?r(e):null)})});function a(e,o){n.internalId=e;var r="asset-"+e,s=document.createElement("div");if(s.id=r,s.dataset.internalId=e,n.externalId&&(s.dataset.externalId=n.externalId),n.assetClass&&s.classList.add(n.assetClass),s.innerHTML=t,u?i.replaceElementById(r,s.outerHTML,null):i.insertElement(s,{select:!0}),"function"===typeof o)return o()}function p(t){e.request("add-embedded-asset",n,t)}function c(t){e.request("update-embedded-asset",n,t)}},n.prototype.getSelectedPluginElement=function(t){e.request("get-selected-plugin-element",{},t)},new n}})?n.apply(t,r):n)||(e.exports=i)},function(e,t,o){var n,r,i;r=[e],void 0===(i="function"===typeof(n=function(e){"use strict";e.exports=function(e){var t=function(){this.DEBUG=!1};return t.prototype.focusApp=function(t){e.request("app-focus",{},t)},t.prototype.startApp=function(t,o,n){e.request("app-start",{app:t,option:o},n)},t.prototype.stopApp=function(t){e.request("app-stop",{app:t})},t.prototype.getId=function(t){e.request("article-id-get",null,t)},t.prototype.getPackageId=function(t){e.request("package-id-get",null,t)},t.prototype.getPackageGuid=function(t){e.request("package-guid-get",null,t)},t.prototype.clearMetaInfo=function(t){e.request("article-metainfo-clear",null,t)},t.prototype.getTags=function(t){e.request("article-tags-get",null,t)},t.prototype.getCustomMeta=function(t,o){e.request("article-custom-meta-get",{name:t},o)},t.prototype.setCustomMeta=function(t,o,n){e.request("article-custom-meta-set",{name:t,value:o},n)},t.prototype.setMetaChanged=function(t){e.request("article-meta-changed",null,t)},t.prototype.setTags=function(t,o,n){e.request("article-tags-set",{save:o,tags:t},n)},t.prototype.addTags=function(t,o,n){e.request("article-tags-add",{tags:t,onError:o},n)},t.prototype.addTag=function(t,o,n){e.request("article-tags-add",{tags:[t],onError:o},n)},t.prototype.addTags=function(t,o,n){e.request("article-tags-add",{tags:t,onError:o},n)},t.prototype.removeTag=function(t,o){e.request("article-tags-remove",{tag:t},o)},t.prototype.getSelectedCategories=function(t){e.request("article-categories-selected-get",null,t)},t.prototype.saveCategories=function(e){this.getSelectedCategories(function(t){this.setCategories(t,e)})},t.prototype.setCategories=function(t,o){e.request("article-categories-selected-set",{categories:t},o)},t.prototype.addCategories=function(t,o){e.request("article-categories-add",{categories:t},o)},t.prototype.removeCategories=function(t,o){e.request("article-categories-remove",{categories:t},o)},t.prototype.setMainCategory=function(t,o){e.request("article-categories-main-set",{category:t},o)},t.prototype.getSource=function(t){e.request("article-source-get",null,t)},t.prototype.setSource=function(t,o){e.request("article-source-set",{source:t},o)},t.prototype.getStatus=function(t){e.request("article-status-get",null,t)},t.prototype.setStatus=function(t,o){e.request("article-status-set",{status:t},o)},t.prototype.getPublishedDatetime=function(t){e.request("article-published-get",null,t)},t.prototype.setPublishedDatetime=function(t,o){e.request("article-published-set",{published:t},o)},t.prototype.getAuthors=function(t){e.request("article-authors-get",null,t)},t.prototype.setAuthors=function(t,o){e.request("article-authors-set",{authors:t},o)},t.prototype.addAuthors=function(t,o){e.request("article-authors-add",{authors:t},o)},t.prototype.removeAuthors=function(t,o){e.request("article-authors-remove",{authors:t},o)},t.prototype.setKeywords=function(t,o){e.request("article-keywords-set",{keywords:t},o)},t.prototype.getKeywords=function(t){e.request("article-keywords-get",null,t)},t.prototype.getCurrentContent=function(t){e.request("article-content-get",null,t)},t.prototype.setCurrentContent=function(t,o){e.request("article-content-set",{content:t},o)},t.prototype.getArticletypeId=function(t){e.request("article-type-get",null,t)},t.prototype.setArticletypeId=function(t,o){e.request("article-type-set",{articletype:t},o)},t.prototype.maximizeAppWindow=function(t,o){var n="editor-pane-close-"+(new Date).getTime();e.request("editor-pane-maximize",{title:t,event:n}),e.eventListeners.removeAll(n),e.eventListeners.add(n,o)},t.prototype.restoreAppWindow=function(t){e.request("restore-app-window",{},t)},t.prototype.getByline=function(t){e.request("article-byline-get",null,t)},t.prototype.setByline=function(t,o,n){e.request("article-byline-set",{save:o,byline:t},n)},t.prototype.setGeolocations=function(t,o){e.request("article-geolocations-set",{geolocations:t},o)},t.prototype.getGeolocations=function(t){e.request("article-geolocations-get",null,t)},t.prototype.getProperties=function(t){e.request("article-properties-get",null,t)},t.prototype.setProperties=function(t,o){e.request("article-properties-set",{properties:t},o)},t.prototype.setProperty=function(t,o,n){var r={};r[t]=o,e.request("article-properties-set",{properties:r},n)},t.prototype.getTopic=function(t){e.request("article-topic-get",null,t)},t.prototype.setTopic=function(t,o){e.request("article-topic-set",{topic:t},o)},new t}})?n.apply(t,r):n)||(e.exports=i)},function(e,t,o){var n,r,i;r=[e,o(0)],void 0===(i="function"===typeof(n=function(e,t){"use strict";function o(e){return(o="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e,t){for(var o=0;o").parent().html();var e=t.cloneNode(!0),o=document.createElement("div");return o.appendChild(e),o.innerHTML},i.prototype.generateArticleUrl=function(t,e){this.request("generate-article-url",{id:t},e)},i.prototype.extendApi=function(t,e,o){var n=this;this.request("extend-api",{group:t,name:e,action:function(t){var e=o(t.data);n.request(t.eventKey,{data:e})}})},i.prototype.callExtendedApi=function(t,e,o,n){this.request("call-extended-api",{group:t,name:e,data:o,callback:n})},i.prototype.getCurrentUser=function(t){this.request("get-current-user",null,t)},i.prototype.getConfiguration=function(t){this.request("get-configuration",null,t)},i.prototype.getDrPublishConfiguration=function(t){this.request("get-drpublish-configuration",null,t)},i.prototype.setConfiguration=function(t,e,o){"boolean"===typeof e?e={onlyPublication:e}:"object"===r(e)&&null!==e||(e={});var n={config:t,onlyPublication:"boolean"===typeof e.onlyPublication&&e.onlyPublication,success:"function"===typeof e.success?e.success:null,error:"function"===typeof e.error?e.error:null};this.request("set-configuration",n,o)},i.prototype.emit=function(t,e){this.request("emit-api-event",{name:t,data:e})},i.prototype.on=function(t,e){this.eventListeners.add(t,e),this.request("on-api-event",{name:t})},i.prototype.increaseRequiredActionCounter=function(t){this.request("increase-required-action-counter",{},t)},i.prototype.decreaseRequiredActionCounter=function(t){this.request("decrease-required-action-counter",{},t)},i.prototype.clearRequiredActionCounter=function(t){this.request("clear-required-action-counter",{},t)},i.prototype.setRequiredActionCounter=function(t,e){this.request("set-required-action-counter",{count:t},e)},i.prototype.create=function(){return new i},i.prototype.createEmbeddedObject=function(t,e){this.request("create-embedded-object",{typeId:t,callback:e})},i.prototype.getEmbeddedObjectTypes=function(t){this.request("get-embedded-object-types",null,t)},i.prototype.giveFocus=function(t,e,o){return"string"===typeof t&&("boolean"!==typeof o&&(o=!0),this.request("give-focus",{pluginName:t,start:o,argument:e}),!0)},i.prototype.hide=function(){return this.request("hide"),!0},i.prototype.createModal=function(t,e){return this.request("create-custom-modal",{content:t,options:e}),!0},i.prototype.updateModal=function(t){return this.request("update-custom-modal",{content:t}),!0},i.prototype.closeModal=function(t){return this.request("close-custom-modal",{destroy:t}),!0},i.prototype.getModalInputs=function(t){this.request("get-custom-modal-inputs",null,t)},i.prototype.confirmAuthenticated=function(){this.request("confirm-authenticated",{pluginName:this.appName})},i.prototype.isStandAlone=function(){return this.standAlone},i.prototype.getJWT=function(){return this.jwt},i.prototype.replaceEditorComponentsExtension=function(t){this.request("replace-editor-components-extension",t)},i.prototype.clearEditorComponentsExtension=function(t){this.request("clear-editor-components-extension",t)},i.prototype.highlightAnnotation=function(t){this.request("highlight-annotation",t)},i.prototype.underemphasizeAnnotations=function(t){this.request("underemphasize-annotations",t)},i.prototype.registerExternallyDefinedProperties=function(t){this.request("register-externally-defined-properties",t)},new i);s.Article=o(s),s.Editor=e(s),t.exports=s})?n.apply(e,r):n)||(t.exports=i)},function(t,e,o){var n,r,i;r=[t],void 0===(i="function"===typeof(n=function(t){"use strict";function e(t){return(e="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}t.exports=function(t){var o=null,n=function(){this.DEBUG=!1,t.on("pluginElementClicked",function(t){o=t}),t.on("pluginElementDeselected",function(){o=null})};return n.prototype.getActiveEditor=function(e){t.request("get-active-editor",null,e)},n.prototype.registerMenuAction=function(e,o){t.request("register-menu-action",e,o)},n.prototype.registerHoverAction=function(e,o){t.request("register-hover-action",e,o)},n.prototype.getSelectedPluginElement=function(e){t.request("get-selected-plugin-element",{},e)},n.prototype.deSelectPluginElements=function(e){t.request("de-select-plugin-elements",{},e)},n.prototype.directionalCastle=function(e,o,n){t.request("editor-directional-castle",{elementId:e,direction:o},n)},n.prototype.registerMenuActionGroup=function(e,o){t.request("register-menu-action-group",e,o)},n.prototype.getEditorType=function(e){t.request("editor-get-type",null,e)},n.prototype.replaceElementById=function(e,o,n){t.request("editor-element-replace-byid",{id:e,element:o},n)},n.prototype.replacePluginElementById=function(e,o,n){t.request("editor-element-replace-plugin-element-byid",{id:e,element:o},n)},n.prototype.setElementContentById=function(e,o,n){t.request("editor-element-set-byid",{id:e,element:o},n)},n.prototype.deleteElementById=function(e,o){t.request("editor-element-delete-byid",{id:e},o)},n.prototype.getHTMLById=function(e,o){t.request("editor-element-get-byid",{id:e},o)},n.prototype.getHTMLBySelector=function(e,o){t.request("editor-elements-get-byselector",{selector:e},o)},n.prototype.getCategories=function(e){t.request("get-categories",null,e)},n.prototype.getParentCategories=function(e,o){t.request("get-parent-categories",e,o)},n.prototype.getParentIds=function(e,o,n){t.request("get-parent-ids",{id:e,selector:o},n)},n.prototype.getTagTypes=function(e){t.request("get-tag-types",null,e)},n.prototype.getTagType=function(e,o){t.request("get-tag-type",{id:e},o)},n.prototype.clear=function(e){t.request("editor-clear",null,e)},n.prototype.insertString=function(e,o){t.request("editor-insert-string",{string:e},o)},n.prototype.insertElement=function(o,n,r){var i=!1;"object"===e(n)?i="boolean"===typeof(n=n||{}).select&&n.select:"undefined"===typeof r&&"function"===typeof n&&(r=n),t.request("editor-insert-element",{element:o.outerHTML,select:i,options:n},r)},n.prototype.removeClasses=function(e,o,n){t.request("editor-classes-remove",{id:e,classes:o},n)},n.prototype.addClasses=function(e,o,n){t.request("editor-classes-add",{id:e,classes:o},n)},n.prototype.getDataAttribute=function(e,o,n){t.request("editor-attribute-get",{id:e,attribute:"data-"+o},n)},n.prototype.updateDataAttribute=function(e,o,n,r){t.request("editor-attribute-update",{id:e,attribute:"data-"+o,value:n},r)},n.prototype.markAsActive=function(e,o){t.request("editor-mark-as-active",{id:e},o)},n.prototype.setAttributeById=function(e,o,n,r){t.request("editor-element-attribute-set-byid",{id:e,attribute:o,value:n},r)},n.prototype.setStyleById=function(e,o,n,r){t.request("editor-element-style-set-byid",{id:e,attribute:o,value:n},r)},n.prototype.initMenu=function(e,o){t.request("editor-initialize-menu",{menus:e},o)},n.prototype.openPluginElementEditor=function(e){t.request("open-element-editor",{id:e})},n.prototype.getTotalWordCount=function(e){t.request("total-word-count",null,e)},n.prototype.getTotalCharCount=function(e){t.request("total-char-count",null,e)},n.prototype.updateAssetOption=function(e,o,n,r){t.request("update-asset-option",{dpArticleId:e,key:o,value:n},r)},n.prototype.updateAssetData=function(e,o){t.request("update-asset-media",e,o)},n.prototype.getAssetData=function(e,o){t.request("get-asset-data",{data:e},o)},n.prototype.insertNestedAsset=function(e,o,n,r){var i=this;function s(e){t.request("update-embedded-asset",n,e)}t.createEmbeddedObject(n.embeddedTypeId,function(u){!function(e,r,s){n.internalId=e;var u="asset-"+e,a=$("
");a.attr("id",u),a.attr("data-internal-id",e),a.attr("data-ah5-type",n.assetSource),n.externalId&&a.attr("data-external-id",n.externalId),n.dpDigitalAssetId&&a.attr("data-dp-digital-asset-id",n.dpDigitalAssetId),n.assetClass&&a.addClass(n.assetClass),a.addClass("dp-plugin-element"),a.html(o),t.Editor.getHTMLById(r,function(t){var e=document.createElement("div");e.innerHTML=t,e.firstChild.setAttribute("id",r+"tmp"),i.replacePluginElementById(r,e.innerHTML,function(){(e=document.createElement("div")).innerHTML=t;var o=e.querySelector(".dp-fact-box-image, .dp-nested-asset-container");n.isMultiple?$(o).append(a.get(0).outerHTML):o.innerHTML=a.get(0).outerHTML,i.replacePluginElementById(r+"tmp",e.innerHTML,s)})})}(u,e,function(t){return s(r)})})},n.prototype.insertEmbeddedAsset=function(e,n,r){var i=this,s=!1;if(o){if(n.assetSource!==t.getAppName())return void t.showErrorMsg("Can't update selected plugin element since it doesn't belong to the '"+t.getAppName()+"' plugin");s=!0}if(o){var u=o.dpArticleId;if(!u)throw Error("Selected plugin element: expected dpArticleId not found (tried reading from attribute 'data-internal-id')");a(u,function(t){return c("function"===typeof r?r(t):null)})}else t.createEmbeddedObject(n.embeddedTypeId,function(t){a(t,function(t){return p("function"===typeof r?r(t):null)})});function a(t,o){n.internalId=t;var r="asset-"+t,u=document.createElement("div");if(u.id=r,u.dataset.internalId=t,n.externalId&&(u.dataset.externalId=n.externalId),n.dpDigitalAssetId&&(u.dataset.dpDigitalAssetId=n.dpDigitalAssetId),n.assetClass&&u.classList.add(n.assetClass),u.innerHTML=e,s?i.setElementContentById(r,u.innerHTML,null):(n.select=!0,i.insertElement(u,n)),"function"===typeof o)return o()}function p(e){t.request("add-embedded-asset",n,e)}function c(e){t.request("update-embedded-asset",n,e)}},n.prototype.getCurrentSelectionAbsolutePosition=function(e){t.request("current-selection-absolute-position",null,e)},n.prototype.wrapSelection=function(e,o,n){t.request("wrap-selection",{className:e,attributes:o},n)},n.prototype.removeInPlace=function(e,o){t.request("remove-in-place",{selector:e},o)},n.prototype.triggerEvent=function(e,o,n){t.request("trigger-event",{selector:e,event:o},n)},n.prototype.getOrderedIDs=function(e,o){t.request("get-ordered-ids",{selector:e},o)},new n}})?n.apply(e,r):n)||(t.exports=i)},function(t,e,o){var n,r,i;r=[t],void 0===(i="function"===typeof(n=function(t){"use strict";t.exports=function(t){var e=function(){this.DEBUG=!1};return e.prototype.focusPlugin=function(e){t.request("app-focus",{},e)},e.prototype.focusApp=function(t){this.focusPlugin(t)},e.prototype.startPlugin=function(e,o,n){t.request("app-start",{app:e,option:o},n)},e.prototype.startApp=function(t,e,o){this.startPlugin(t,e,o)},e.prototype.stopPlugin=function(e){t.request("app-stop",{app:e})},e.prototype.stopApp=function(t){this.stopPlugin(t)},e.prototype.getId=function(e){t.request("article-id-get",null,e)},e.prototype.getPackageId=function(e){t.request("package-id-get",null,e)},e.prototype.getPackageGuid=function(e){t.request("package-guid-get",null,e)},e.prototype.clearMetaInfo=function(e){t.request("article-metainfo-clear",null,e)},e.prototype.getTags=function(e){t.request("article-tags-get",null,e)},e.prototype.getCustomMeta=function(e,o){t.request("article-custom-meta-get",{name:e},o)},e.prototype.setCustomMeta=function(e,o,n){t.request("article-custom-meta-set",{name:e,value:o},n)},e.prototype.setMetaChanged=function(e){t.request("article-meta-changed",null,e)},e.prototype.setTags=function(e,o,n){t.request("article-tags-set",{save:o,tags:e},n)},e.prototype.addTags=function(e,o,n){t.request("article-tags-add",{tags:e,onError:o},n)},e.prototype.addTag=function(e,o,n){t.request("article-tags-add",{tags:[e],onError:o},n)},e.prototype.addTags=function(e,o,n){t.request("article-tags-add",{tags:e,onError:o},n)},e.prototype.removeTag=function(e,o){t.request("article-tags-remove",{tag:e},o)},e.prototype.getSelectedCategories=function(e){t.request("article-categories-selected-get",null,e)},e.prototype.saveCategories=function(t){this.getSelectedCategories(function(e){this.setCategories(e,t)})},e.prototype.setCategories=function(e,o){t.request("article-categories-selected-set",{categories:e},o)},e.prototype.addCategories=function(e,o){t.request("article-categories-add",{categories:e},o)},e.prototype.removeCategories=function(e,o){t.request("article-categories-remove",{categories:e},o)},e.prototype.setMainCategory=function(e,o){t.request("article-categories-main-set",{category:e},o)},e.prototype.getSource=function(e){t.request("article-source-get",null,e)},e.prototype.setSource=function(e,o){t.request("article-source-set",{source:e},o)},e.prototype.getStatus=function(e){t.request("article-status-get",null,e)},e.prototype.setStatus=function(e,o){t.request("article-status-set",{status:e},o)},e.prototype.getPublishedDatetime=function(e){t.request("article-published-get",null,e)},e.prototype.setPublishedDatetime=function(e,o){t.request("article-published-set",{published:e},o)},e.prototype.getAuthors=function(e){t.request("article-authors-get",null,e)},e.prototype.setAuthors=function(e,o){t.request("article-authors-set",{authors:e},o)},e.prototype.addAuthors=function(e,o){t.request("article-authors-add",{authors:e},o)},e.prototype.removeAuthors=function(e,o){t.request("article-authors-remove",{authors:e},o)},e.prototype.setKeywords=function(e,o){t.request("article-keywords-set",{keywords:e},o)},e.prototype.getKeywords=function(e){t.request("article-keywords-get",null,e)},e.prototype.getCurrentContent=function(e){t.request("article-content-get",null,e)},e.prototype.setCurrentContent=function(e,o){t.request("article-content-set",{content:e},o)},e.prototype.setSubArticleContent=function(e,o,n){t.request("sub-article-content-set",{articleId:e,content:o},n)},e.prototype.getArticletypeId=function(e){t.request("article-type-get",null,e)},e.prototype.setArticletypeId=function(e,o){t.request("article-type-set",{articletype:e},o)},e.prototype.maximizePluginWindow=function(e,o,n){var r="editor-pane-close-"+(new Date).getTime();t.request("editor-pane-maximize",{title:e,event:r},n),t.eventListeners.removeAll(r),t.eventListeners.add(r,o)},e.prototype.maximizeAppWindow=function(t,e,o){this.maximizePluginWindow(t,e,o)},e.prototype.restorePluginWindow=function(e){t.request("restore-app-window",{},e)},e.prototype.restoreAppWindow=function(t){this.restorePluginWindow(t)},e.prototype.getByline=function(e){t.request("article-byline-get",null,e)},e.prototype.setByline=function(e,o,n){t.request("article-byline-set",{save:o,byline:e},n)},e.prototype.setGeolocations=function(e,o){t.request("article-geolocations-set",{geolocations:e},o)},e.prototype.getGeolocations=function(e){t.request("article-geolocations-get",null,e)},e.prototype.getProperties=function(e){t.request("article-properties-get",null,e)},e.prototype.setProperties=function(e,o){t.request("article-properties-set",{properties:e},o)},e.prototype.setProperty=function(e,o,n){var r={};r[e]=o,t.request("article-properties-set",{properties:r},n)},e.prototype.getTopic=function(e){t.request("article-topic-get",null,e)},e.prototype.setTopic=function(e,o){t.request("article-topic-set",{topic:e},o)},e.prototype.getPackage=function(e){t.request("package-get",null,e)},new e}})?n.apply(e,r):n)||(t.exports=i)},function(t,e,o){var n,r,i;r=[t,o(0)],void 0===(i="function"===typeof(n=function(t,e){"use strict";function o(t){return(o="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e){for(var o=0;o {\n\t\t\tconst createEventFunction = function (eventName) {\n\t\t\t\treturn function (data) {\n\t\t\t\t\tPluginAPI.request(eventName, data);\n\t\t\t\t};\n\t\t\t};\n\t\t\tconst updateObject = function (data) {\n\t\t\t\tfor (const key in data) {\n\t\t\t\t\tif (data.hasOwnProperty(key)) {\n\t\t\t\t\t\tif (typeof data[key] === 'object' && data[key] !== null && data[key].type === 'function') {\n\t\t\t\t\t\t\tdata[key] = createEventFunction(data[key].eventKey);\n\t\t\t\t\t\t} else if (typeof data[key] === 'object' && data[key] !== null && typeof data[key].map === 'function') {\n\t\t\t\t\t\t\tdata[key] = data[key].map(updateObject);\n\t\t\t\t\t\t} else if (typeof data[key] === 'object' && data[key] !== null) {\n\t\t\t\t\t\t\tdata[key] = updateObject(data[key]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn data;\n\t\t\t};\n\t\t\tdata.data = updateObject(data.data);\n\n\t\t\tdata = self.eventListeners.notify(data.type, data.data);\n\t\t\tif (typeof data === 'undefined') {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (data === false) {\n\t\t\t\treturn {'abort': true};\n\t\t\t}\n\t\t\treturn data;\n\t\t}, '*');\n\t};\n\n\t/**\n\t * Dispatches a request to DrPublish, and returns the reply to callback On error, notifies all error listeners based on the index .type of the thrown object\n\t *\n\t * @param {String} callSpec What do you want to call?\n\t * @param {Object} data The data attached to the request\n\t * @param {Function} callback The function to call upon return\n\t */\n\tApi.prototype.request = function (callSpec, data, callback) {\n\t\tconst self = this;\n\t\tif (this.DEBUG) {\n\t\t\tconsole.info(this.getAppName() + ': Requesting ' + callSpec + ' from parent with data', data);\n\t\t}\n\n\t\tif (!data) {\n\t\t\tdata = {};\n\t\t}\n\n\t\tif (typeof callback === 'undefined') {\n\t\t\tcallback = null;\n\t\t}\n\n\t\tif (typeof data.length === 'number') {\n\t\t\tdata = {data: data};\n\t\t}\n\n\t\tdata['src_app'] = this.getAppName();\n\n\t\tconst createEventFunction = function (func, eventKey) {\n\t\t\treturn function () {\n\t\t\t\tself.eventListeners.remove(eventKey, eventKey);\n\t\t\t\treturn func.apply(null, arguments);\n\t\t\t};\n\t\t};\n\n\n\t\tconst createCallbackObject = function (key, callback) {\n\t\t\tconst random = Math.floor(Math.random() * 1000);\n\t\t\tconst eventKey = key + random + 'functioncallback' + (new Date()).getTime();\n\t\t\tconst eventFunction = createEventFunction(callback, eventKey);\n\t\t\tself.eventListeners.add(eventKey, eventFunction);\n\t\t\treturn {\n\t\t\t\ttype: 'function',\n\t\t\t\teventKey: eventKey\n\t\t\t};\n\t\t};\n\n\t\tconst updateObject = function (data) {\n\t\t\tfor (const key in data) {\n\t\t\t\tif (data.hasOwnProperty(key)) {\n\t\t\t\t\tconst val = data[key];\n\t\t\t\t\tif (typeof val === 'function') {\n\t\t\t\t\t\tdata[key] = createCallbackObject(key, val);\n\t\t\t\t\t} else if (typeof val === 'object' && val !== null && typeof val.map === 'function') {\n\t\t\t\t\t\tdata[key] = val.map(updateObject);\n\t\t\t\t\t} else if (typeof val === 'object' && val !== null) {\n\t\t\t\t\t\tdata[key] = updateObject(val);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn data;\n\t\t};\n\t\tdata = updateObject(data);\n\n\t\tpm({\n\t\t\ttarget: parent,\n\t\t\ttype: callSpec,\n\t\t\tdata: data,\n\t\t\tsuccess: callback,\n\t\t\terror: (data) => {\n\t\t\t\tself.errorListeners.notify(data.type, data);\n\t\t\t},\n\t\t\torigin: '*', // TODO: Find a way of avoiding all-origins\n\t\t\thash: false\n\t\t});\n\t};\n\n\n\t/**\n\t * Creates a new tag\n\t *\n\t * @param {String} tag The tag to create\n\t * @param {Function} callback function(Boolean)\n\t */\n\tApi.prototype.openTagCreationDialog = function (tag, callback) {\n\t\tthis.request('create-tag', {\n\t\t\ttag: tag\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Reloads the app's iframe\n\t */\n\tApi.prototype.reloadIframe = function () {\n\n\t\tthis.request('app-reload', {\n\t\t\tapp: this.getAppName()\n\t\t});\n\t};\n\n\t/**\n\t * Get the name of the loaded app\n\t *\n\t * @return {String} The name of the app, or false if it couldn't be detected\n\t */\n\tApi.prototype.getAppName = function () {\n\t\treturn this.appName;\n\t};\n\n\t/**\n\t * Set the name of the app\n\t *\n\t * @param {String} name The name of the app\n\t */\n\tApi.prototype.setAppName = function (name) {\n\t\tthis.appName = name;\n\t};\n\n\t/**\n\t * Show info-message to the user\n\t *\n\t * @param {String} msg Message to be displayed\n\t */\n\tApi.prototype.showInfoMsg = function (msg) {\n\n\t\tthis.request('show-message-info', {\n\t\t\tmessage: msg\n\t\t});\n\t};\n\n\t/**\n\t * Show warning-message to the user\n\t *\n\t * @param {String} msg Message to be displayed\n\t */\n\tApi.prototype.showWarningMsg = function (msg) {\n\n\t\tthis.request('show-message-warning', {\n\t\t\tmessage: msg\n\t\t});\n\t};\n\n\t/**\n\t * Show error-message to the user\n\t *\n\t * @param {String} msg Message to be displayed\n\t */\n\tApi.prototype.showErrorMsg = function (msg) {\n\n\t\tthis.request('show-message-error', {\n\t\t\tmessage: msg\n\t\t});\n\t};\n\n\t/**\n\t * Show the loader\n\t *\n\t * @param {String} msg Message to display in progress loader\n\t */\n\tApi.prototype.showLoader = function (msg) {\n\t\tthis.request('show-loader', {\n\t\t\tmessage: msg\n\t\t});\n\t};\n\n\t/**\n\t * Hide the loader\n\t */\n\tApi.prototype.hideLoader = function () {\n\t\tthis.request('hide-loader');\n\t};\n\n\t/**\n\t * @deprecated Use PluginAPI.on(...) instead\n\t * @param {Object} listeners\n\t */\n\tApi.prototype.addListeners = function (listeners) {\n\t\tconst createCallback = function (callback) {\n\t\t\treturn function (data) {\n\t\t\t\tcallback(data.data);\n\t\t\t};\n\t\t};\n\t\tfor (const eventName in listeners) {\n\t\t\tif (listeners.hasOwnProperty(eventName)) {\n\t\t\t\tconst callback = listeners[eventName];\n\t\t\t\tconst callWrapper = createCallback(callback);\n\t\t\t\tthis.on(eventName, callWrapper);\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * Loads an old revision of an article\n\t *\n\t * @param {Number} id The id of the revision to load\n\t * @param {Function} callback The function to call when the new revision has been loaded\n\t * @private\n\t */\n\tApi.prototype.__loadArticleRevision = function (id, callback) {\n\t\tthis.request('load-revision', {\n\t\t\trevision: id\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Creates a new tag\n\t *\n\t * @param {String} tag JSON object with the tag to create, must contain tagTypeId and name properties\n\t * @param {Function} callback function(Boolean)\n\t */\n\tApi.prototype.createTag = function (tag, callback) {\n\t\tthis.request('tag-create', {\n\t\t\ttag: tag\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Sends a query to DrLib\n\t *\n\t * @example\n\t * PluginAPI.searchDrLib({\n\t * query: 'articles.json?q=awesome',\n\t * secure: true,\n\t * success: function(data) {\n\t * data.items.forEach(doStuffWithArticle);\n\t * },\n\t * error: function(data) {\n\t * console.warn('something went wrong');\n\t * }\n\t * })\n\t *\n\t * @param {Object} data Object with three properties; 'query' which is the query to send to DrLib, 'success' which is the callback to execute on success, and 'secure' a boolean to add the internal API key to the query and thus allow searching on unpublished article. This callback's parameter is an object which is the query result as an object. See the json output of DrLib to learn more about this object\n\t * @param {Function} callback function(Boolean)\n\t *\n\t */\n\tApi.prototype.searchDrLib = function (data, callback) {\n\t\tthis.request('drlib-search', {\n\t\t\tquery: data.query,\n\t\t\taccess: data.access,\n\t\t\tsecure: data.secure,\n\t\t\tsuccess: data.success,\n\t\t\terror: data.error\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Generates proper html code to represent the dom element. This is NOT an asynchronous function\n\t *\n\t * @param {Object} dom The dom node to convert\n\t * @return {String} The html code\n\t */\n\t// TODO: This function should also be able to take a DOMElement or similar.\n\tApi.prototype.convertDomToHTML = function (dom) {\n\t\tif (typeof dom === 'object' && typeof dom.wrap === 'function') {\n\t\t\treturn dom.wrap('
').parent().html();\n\t\t} else {\n\t\t\tconst domClone = dom.cloneNode(true);\n\t\t\tconst wrapper = document.createElement('div');\n\t\t\twrapper.appendChild(domClone);\n\t\t\treturn wrapper.innerHTML;\n\t\t}\n\t};\n\n\t/**\n\t * Generates an url to a published article\n\t *\n\t * @param {String} id The id of the article to generate url for\n\t * @param {Function} callback function(String), where the parameter is the generated url\n\t */\n\tApi.prototype.generateArticleUrl = function (id, callback) {\n\t\tthis.request('generate-article-url', {\n\t\t\tid: id\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Extends the PluginAPI with custom functionality that other apps can use\n\t *\n\t * @param {String} group Group name for functionality to add\n\t * @param {String} name Name of the specific function to add\n\t * @param {Function} action function(Object) Function to call when the API is invoked, recieves one parameter as given in PluginAPI.callExtendedApi and return value is passed back to the caller\n\t */\n\tApi.prototype.extendApi = function (group, name, action) {\n\t\tconst self = this;\n\t\tthis.request('extend-api', {\n\t\t\tgroup: group,\n\t\t\tname: name,\n\t\t\taction: (data) => {\n\t\t\t\tconst a = action(data.data);\n\t\t\t\tself.request(data.eventKey, {'data': a});\n\t\t\t}\n\t\t});\n\t};\n\n\t/**\n\t * Call the extended PluginAPI\n\t *\n\t * @param {String} group Group name for functionality to call\n\t * @param {String} name Name of the specific function to call\n\t * @param {Object} data Data object to pass as parameter to the api call\n\t * @param {Function} callback function(Object) Function to recieve the API response, parameter is the response from the API call\n\t */\n\tApi.prototype.callExtendedApi = function (group, name, data, callback) {\n\t\tthis.request('call-extended-api', {\n\t\t\tgroup: group,\n\t\t\tname: name,\n\t\t\tdata: data,\n\t\t\tcallback: callback\n\t\t});\n\t};\n\n\t/**\n\t * Gets logged in user\n\t *\n\t * @param {Function} callback function(Object)\n\t */\n\tApi.prototype.getCurrentUser = function (callback) {\n\t\tthis.request('get-current-user', null, callback);\n\t};\n\n\t/**\n\t * Get configuration information about the app\n\t *\n\t * @param {Function} callback function(Object)\n\t */\n\tApi.prototype.getConfiguration = function (callback) {\n\t\tthis.request('get-configuration', null, callback);\n\t};\n\n\t/**\n\t * Get DrPublish configuratin\n\t *\n\t * @param {Function} callback function(Object)\n\t */\n\tApi.prototype.getDrPublishConfiguration = function (callback) {\n\t\tthis.request('get-drpublish-configuration', null, callback);\n\t};\n\n\t/**\n\t * Set configuration information about the app\n\t *\n\t * @param {Object} config The configuration object to save\n\t * @param {Object} options Object, can have three keys.\n\t * 'onlyPublication' (boolean) If true the configuration is set for the current publication only\n\t * 'success' (function) Called if the configuration was saved successfully\n\t * 'error' (function) Called if there was an error, recieves and error object as first parameter\n\t * @param {Function} callback function()\n\t */\n\tApi.prototype.setConfiguration = function (config, options, callback) {\n\t\t// support old function signature\n\t\tif (typeof options === 'boolean') {\n\t\t\toptions = {\n\t\t\t\tonlyPublication: options\n\t\t\t};\n\t\t} else if (typeof options !== 'object' || options === null) {\n\t\t\toptions = {};\n\t\t}\n\t\tconst data = {\n\t\t\tconfig: config,\n\t\t\tonlyPublication: typeof options.onlyPublication === 'boolean' ? options.onlyPublication : false,\n\t\t\tsuccess: typeof options.success === 'function' ? options.success : null,\n\t\t\terror: typeof options.error === 'function' ? options.error : null\n\t\t};\n\t\tthis.request('set-configuration', data, callback);\n\t};\n\n\t/**\n\t * Emits an event to DrPublish, and possibly other apps\n\t *\n\t * @param {String} name Name of the event\n\t * @param {String} data Data object to send with the event\n\t */\n\tApi.prototype.emit = function (name, data) {\n\t\tthis.request('emit-api-event', {\n\t\t\tname: name,\n\t\t\tdata: data\n\t\t});\n\t};\n\n\t/**\n\t * Listen for an event. If the callback returns false the event may cancel continued actions, e.g beforeSave can cancel article save. Look at documentation for Listeners to learn more.\n\t *\n\t * @param {String} name Name of the event\n\t * @param {Function} callback function(Object) Function to call when the event is triggered. Recieves one data object parameter of the form {source: , data: }\n\t */\n\tApi.prototype.on = function (name, callback) {\n\t\tconst self = this;\n\t\tself.eventListeners.add(name, callback);\n\t\tthis.request('on-api-event', {\n\t\t\tname: name\n\t\t});\n\t};\n\n\t/**\n\t * Increase the counter of actions required by the user, used to tell the user that the plugin requires input of some kind\n\t *\n\t * @param {Function} callback function(Object) function to call once the counter has been increased, returns the new counter value\n\t */\n\tApi.prototype.increaseRequiredActionCounter = function (callback) {\n\t\tthis.request('increase-required-action-counter', {}, callback);\n\t};\n\n\t/**\n\t * Decrease the counter of actions required by the user, used to tell the user that the plugin requires input of some kind\n\t *\n\t * @param {Function} callback function(Object) function to call once the counter has been decrease, returns current counter value\n\t */\n\tApi.prototype.decreaseRequiredActionCounter = function (callback) {\n\t\tthis.request('decrease-required-action-counter', {}, callback);\n\t};\n\n\t/**\n\t * Clear the counter of actions required by the user, used to tell the user that the plugin requires input of some kind\n\t *\n\t * @param {Function} callback function(Object) function to call once the counter has been cleared\n\t */\n\tApi.prototype.clearRequiredActionCounter = function (callback) {\n\t\tthis.request('clear-required-action-counter', {}, callback);\n\t};\n\n\t/**\n\t * Set the counter of actions required by the user, used to tell the user that the plugin requires input of some kind\n\t *\n\t * @param {Number} count The value to set the counter to\n\t * @param {Function} callback function(Object) function to call once the counter has been cleared\n\t */\n\tApi.prototype.setRequiredActionCounter = function (count, callback) {\n\t\tthis.request('set-required-action-counter', {count: count}, callback);\n\t};\n\n\t/**\n\t * Create a new instance of the Api class\n\t *\n\t * @private\n\t * @return {Object}\n\t */\n\tApi.prototype.create = function () {\n\t\treturn new Api();\n\t};\n\n\t/**\n\t * Create an embedded object of the given type\n\t *\n\t * @param {Number} typeId Type Id of the embedded object to create\n\t * @param {Function} callback function(embeddedObjectId) called once the object has been created, first parameter is the new embedded object id\n\t */\n\tApi.prototype.createEmbeddedObject = function (typeId, callback) {\n\t\tthis.request('create-embedded-object', {typeId: typeId, callback: callback});\n\t};\n\n\t/**\n\t * Get information about the available embedded object types\n\t *\n\t * @param {Function} callback function([Object]) recieves an array with objects describing the available embedded object types in the form of `{typeId: 'embedded object type id', cssClass: 'css class used to style the objects'}`\n\t */\n\tApi.prototype.getEmbeddedObjectTypes = function (callback) {\n\t\tthis.request('get-embedded-object-types', null, callback);\n\t};\n\n\t/**\n\t * Gives focus to another plugin\n\t *\n\t * @param {String} pluginName The name of the plugin to recieve focus\n\t * @param {Object} argument Optional option argument to pass along to the plugin recieving focus\n\t * @param {Boolean} start Flag to decide if the plugin should be started if it has not been loaded previously, default true\n\t * @return {Boolean}\n\t */\n\tApi.prototype.giveFocus = function (pluginName, argument, start) {\n\t\tif (typeof pluginName !== 'string' || pluginName === '') {\n\t\t\treturn false;\n\t\t}\n\t\tif (typeof start !== 'boolean') {\n\t\t\tstart = true;\n\t\t}\n\t\tthis.request('give-focus', {pluginName: pluginName, start: start, argument: argument});\n\t\treturn true;\n\t};\n\n\n\t/**\n\t * Hide the plugin, so it is no longer visible on the list of open plugins\n\t * @return {Boolean}\n\t */\n\tApi.prototype.hide = function () {\n\t\tthis.request('hide');\n\t\treturn true;\n\t};\n\n\t/**\n\t *

Creates a jQuery UI modal in the main editor window, detached from the plugin itself. Modals are unique on a\n\t * per-plugin basis, meaning that a plugin can only have a single modal at a time. Creating a new modal will\n\t * overwrite the previous.

\n\t *\n\t * See the official documentation for a list of available options.

\n\t *\n\t *

Note that you do not have direct access to the DOM of the modal. Use the provided helper methods to\n\t * manipulate or read from the modal:\n\t *

\n\t *

\n\t *\n\t * @example\n\t *\n\t * PluginAPI.createModal('

This is a modal

', {\n\t * buttons: {\n\t * Ok: function () {\n\t * alert('Ok!');\n\t * }\n\t * }\n\t * });\n\t *\n\t * PluginAPI.updateModal('

This is the same modal

');\n\t *\n\t * PluginAPI.createModal('

This is a brand new modal

', {\n\t * buttons: {\n\t * cancel: function() {\n\t * PluginAPI.closeModal(true);\n\t * }\n\t * }\n\t * });\n\t *\n\t * @param {String} content An HTML string\n\t * @param {Object} options A standard jQuery UI options object.\n\t * @return {Boolean}\n\t */\n\tApi.prototype.createModal = function (content, options) {\n\t\tthis.request('create-custom-modal', {content: content, options: options});\n\t\treturn true;\n\t};\n\n\t/**\n\t * Updates the HTML content of a live modal. Has no effect if the modal does not exist.\n\t *\n\t * @param {String} content An HTML string\n\t * @return {Boolean}\n\t */\n\tApi.prototype.updateModal = function (content) {\n\t\tthis.request('update-custom-modal', {content: content});\n\t\treturn true;\n\t};\n\n\t/**\n\t * Closes and optionally deletes the modal. Has no effect if the modal does not exists.\n\t *\n\t * @param {Boolean} destroy Whether or not to delete the modal\n\t * @return {Boolean}\n\t */\n\tApi.prototype.closeModal = function (destroy) {\n\t\tthis.request('close-custom-modal', {destroy: destroy});\n\t\treturn true;\n\t};\n\n\t/**\n\t * Returns the values of all input or select elements within a modal.\n\t *\n\t * The values are keyed by one of the following properties in order of priority: element ID, element name\n\t * or input type + index.\n\t *\n\t * @example\n\t * Given a modal with the following HTML content:\n\t *\n\t *
\n\t * \n\t * \n\t * \n\t *
\n\t *\n\t * getModalInputs would return:\n\t *\n\t * {\n\t * \"number-0\": {VALUE}\n\t * \"name\": {VALUE},\n\t * \"languages\": \"en\"\n\t * }\n\t *\n\t * @param {Function} callback\n\t */\n\tApi.prototype.getModalInputs = function (callback) {\n\t\tthis.request('get-custom-modal-inputs', null, callback);\n\t};\n\n\tApi.prototype.confirmAuthenticated = function () {\n\t\tthis.request('confirm-authenticated', {\n\t\t\tpluginName: this.appName\n\t\t});\n\t};\n\n\treturn new Api();\n})();\n\nPluginAPI.Article = articleCommunicator(PluginAPI);\nPluginAPI.Editor = ah5Communicator(PluginAPI);\n\nmodule.exports = PluginAPI;\n","/**\n * @typedef {Object} selectedPluginElementData\n *\n * @property {String} id The DOM id of the selected element\n * @property {String} dpArticleId\n * @property {String} externalId\n * @property {Boolean} isDigitalAsset\n */\n\n/**\n * @param {Api} PluginAPI\n * @return {AH5Communicator}\n */\nmodule.exports = function (PluginAPI) {\n\n\t/** @type {selectedPluginElementData|null} */\n\tlet selectedPluginElement = null;\n\n\t/**\n\t * This will be used by editor apps to communicate with the editor\n\t *\n\t * Should be used like this:\n\t *\n\t * PluginAPI.Editor.insertString('string');\n\t *\n\t * @class\n\t * @classdesc Functions for talking with the AH5 editor. Accessed through PluginAPI.Editor\n\t * @exports PluginAPI/Editor\n\t */\n\t/* eslint max-statements: [\"error\", 50, { \"ignoreTopLevelFunctions\": true }]*/\n\tconst AH5Communicator = function () {\n\t\tthis.DEBUG = false;\n\t\tPluginAPI.on('pluginElementClicked', pluginElementSelected);\n\t\tPluginAPI.on('pluginElementDeselected', pluginElementDeselected);\n\n\t\t/**\n\t\t * @param {selectedPluginElementData} elementData\n\t\t */\n\t\tfunction pluginElementSelected(elementData) {\n\t\t\tselectedPluginElement = elementData;\n\t\t}\n\n\t\tfunction pluginElementDeselected() {\n\t\t\tselectedPluginElement = null;\n\t\t}\n\t};\n\n\t/**\n\t * Get name of current active editor\n\t *\n\t * @param {function} callback function(String)\n\t */\n\tAH5Communicator.prototype.getActiveEditor = function (callback) {\n\t\tPluginAPI.request('get-active-editor', null, callback);\n\t};\n\n\t/**\n\t * Registers/Modifies a context menu items for a app element\n\t * The object send should have the following structure\n\t *\n\t * @param {Object} action The action object\n\t * @param {function} callback function()\n\t *\n\t * @example\n\t * PluginAPI.Editor.registerMenuAction({\n\t *\t label: 'label in the menu',\n\t *\t icon: '[Optional] url to possible icon image',\n\t *\t trigger: '[Optional] css selector, only show menu element when this matches the element',\n\t *\t callback: function(id, clickedElementId) {\n\t *\t\t // callback function\n\t *\t\t // first parameter is id of the app element\n\t *\t\t // second paramter is id of closest element to the trigger element that has an id\n\t *\t\t //\t in code: $(event.triggerElement).closest('[id]').attr('id');\n\t *\t }\n\t * })\n\t */\n\tAH5Communicator.prototype.registerMenuAction = function (action, callback) {\n\t\tPluginAPI.request('register-menu-action', action, callback);\n\t};\n\n\n\tAH5Communicator.prototype.registerHoverAction = function (action, callback) {\n\t\tPluginAPI.request('register-hover-action', action, callback);\n\t};\n\n\t/**\n\t * Swap positions between the provided element and the adjacent one\n\t * in the specified direction\n\t * PluginAPI.Editor.directionalCastle({\n\t * elementId: 'the provided element id',\n\t * direction: 'forward/backward'\n\t * })\n\t * @param {String} movement Direction\n\t * @param {Function} callback\n\t * */\n\tAH5Communicator.prototype.directionalCastle = function (movement, callback) {\n\t\tPluginAPI.request('editor-directional-castle', movement, callback);\n\t};\n\n\t/**\n\t * Registers/Modifies a group of items to in the context menu\n\t * The object send should have the following structure\n\t *\n\t * @example\n\t * PluginAPI.Editor.registerMenuActionGroup({\n\t *\t label: 'label for the group in the menu',\n\t *\t icon: '[Optional] url to possible icon image',\n\t *\t actions: [\n\t *\t\t {\n\t *\t\t\t label: 'label for the action #1',\n\t *\t\t\t callback: function(id, clickedElementId) {\n\t *\t\t\t\t // same as for registerMenuAction\n\t *\t\t\t }\n\t *\t\t },\n\t *\t\t {\n\t *\t\t\t label: 'label for the action #2',\n\t *\t\t\t callback: function(id, clickedElementId) {\n\t *\t\t\t\t // same as for registerMenuAction\n\t *\t\t\t }\n\t *\t\t }\n\t *\t ]\n\t * })\n\t *\n\t * @param {Object} group The action object\n\t * @param {function} callback function()\n\t */\n\tAH5Communicator.prototype.registerMenuActionGroup = function (group, callback) {\n\t\tPluginAPI.request('register-menu-action-group', group, callback);\n\t};\n\n\t/**\n\t * Retrieves the type of editor that currently has focus\n\t *\n\t * @param {function} callback function(String)\n\t */\n\tAH5Communicator.prototype.getEditorType = function (callback) {\n\t\tPluginAPI.request('editor-get-type', null, callback);\n\t};\n\n\t/**\n\t * Replace an element in the article\n\t *\n\t * @param {String} id Id of the element\n\t * @param {String} element The new element\n\t * @param {function} callback function(Boolean), called after replacement is done\n\t */\n\tAH5Communicator.prototype.replaceElementById = function (id, element, callback) {\n\t\tPluginAPI.request('editor-element-replace-byid', {\n\t\t\tid: id,\n\t\t\telement: element\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Replace a plugin element in the article\n\t *\n\t * @param {String} id Id of the element\n\t * @param {String} element The new element\n\t * @param {function} callback function(Boolean), called after replacement is done\n\t */\n\tAH5Communicator.prototype.replacePluginElementById = function (id, element, callback) {\n\t\tPluginAPI.request('editor-element-replace-plugin-element-byid', {\n\t\t\tid: id,\n\t\t\telement: element\n\t\t}, callback);\n\t};\n\n\n\t/**\n\t * Delete an element in the article\n\t *\n\t * @param {String} id Id of the element\n\t * @param {function} callback function(Boolean), called after deletion is done\n\t */\n\tAH5Communicator.prototype.deleteElementById = function (id, callback) {\n\t\tPluginAPI.request('editor-element-replace-byid', {\n\t\t\tid: id\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Get HTML code of an element\n\t *\n\t * @param {String} id The element id\n\t * @param {function} callback function(String), html content of the element\n\t */\n\tAH5Communicator.prototype.getHTMLById = function (id, callback) {\n\t\tPluginAPI.request('editor-element-get-byid', {\n\t\t\tid: id\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Get HTML code of all elements that match the selector\n\t *\n\t * @param {String} selector The CSS selector\n\t * @param {function} callback function([String]), html content of matching elements\n\t */\n\tAH5Communicator.prototype.getHTMLBySelector = function (selector, callback) {\n\t\tPluginAPI.request('editor-elements-get-byselector', {\n\t\t\tselector: selector\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Get all categories\n\t *\n\t * @param {Function} callback function([Object Category]), list of Category objects with id, name and pid\n\t */\n\tAH5Communicator.prototype.getCategories = function (callback) {\n\t\tPluginAPI.request('get-categories', null, callback);\n\t};\n\n\t/**\n\t * Returns all the parent categories of the given category\n\t *\n\t * @param {Object} category The category to find parents of\n\t * @param {Function} callback function([Object Category]), array of parent Category objects\n\t */\n\tAH5Communicator.prototype.getParentCategories = function (category, callback) {\n\t\tPluginAPI.request('get-parent-categories', category, callback);\n\t};\n\n\t/**\n\t * Returns all the parent elements that match the selector\n\t *\n\t * @param {String} id Id of element to find parents of\n\t * @param {String} selector Selector to filter parent elements with\n\t * @param {Function} callback function([String]), array of ids\n\t */\n\tAH5Communicator.prototype.getParentIds = function (id, selector, callback) {\n\t\tPluginAPI.request('get-parent-ids', {\n\t\t\tid: id,\n\t\t\tselector: selector\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Retrieve information about all tagtypes\n\t *\n\t * @param {Function} callback function([Object Tagtype]), array of tagtypes with id, name and config object\n\t */\n\tAH5Communicator.prototype.getTagTypes = function (callback) {\n\t\tPluginAPI.request('get-tag-types', null, callback);\n\t};\n\n\t/**\n\t * Get information about the given tagtype\n\t *\n\t * @param {String} id The element id\n\t * @param {Function} callback function(Object Tagtype), tagtype object with id, name and config object\n\t */\n\tAH5Communicator.prototype.getTagType = function (id, callback) {\n\t\tPluginAPI.request('get-tag-type', {\n\t\t\tid: id\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Clears the editor contents\n\t *\n\t * @param {Function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.clear = function (callback) {\n\t\tPluginAPI.request('editor-clear', null, callback);\n\t};\n\n\t/**\n\t * Insert a string into the editor\n\t *\n\t * @param {String} string The string that should be inserted\n\t * @param {Function} callback function(String), id of the newly inserted element if it has one\n\t */\n\tAH5Communicator.prototype.insertString = function (string, callback) {\n\t\tPluginAPI.request('editor-insert-string', {\n\t\t\tstring: string\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Insert an element into the editor\n\t *\n\t * Note that the HTML of the element is what will be transferred, and nothing else!\n\t * The element will be given the class dp-app-element, and given a unique ID (if none is present)\n\t *\n\t * @param {Element} element The element that should be inserted\n\t * @param {Object/Function} options (can be omitted) Options object, supports option 'select' - set to true to automatically select the inserted element\n\t * @param {Function} [callback] function(String), id of the newly inserted element\n\t */\n\tAH5Communicator.prototype.insertElement = function (element, options, callback) {\n\t\tlet select = false;\n\t\tif (typeof options === 'object') {\n\t\t\toptions = options || {};\n\t\t\tselect = typeof options.select === 'boolean' ? options.select : false;\n\t\t} else if (typeof callback === 'undefined' && typeof options === 'function') {\n\t\t\tcallback = options;\n\t\t}\n\t\tPluginAPI.request('editor-insert-element', {\n\t\t\telement: element.outerHTML,\n\t\t\tselect: select\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Remove classes from the element an element in the article\n\t *\n\t * @param {String} id Id of the element\n\t * @param {Array} classes Array of class names\n\t * @param {function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.removeClasses = function (id, classes, callback) {\n\t\tPluginAPI.request('editor-classes-remove', {\n\t\t\tid: id,\n\t\t\tclasses: classes\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Add new classes to an element\n\t *\n\t * @param {String} id Id of the element\n\t * @param {Array} classes Array of class names\n\t * @param {function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.addClasses = function (id, classes, callback) {\n\t\tPluginAPI.request('editor-classes-add', {\n\t\t\tid: id,\n\t\t\tclasses: classes\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Mark an element as currently selected (green border with default styling)\n\t *\n\t * @param {String} id Id of the element\n\t * @param {function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.markAsActive = function (id, callback) {\n\t\tPluginAPI.request('editor-mark-as-active', {\n\t\t\tid: id\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Sets the attribute of the element with the given ID to value\n\t *\n\t * @param {String} id The ID of the element to set the attribute on\n\t * @param {String} attribute The attribute to set\n\t * @param {String} value What to set the attribute to\n\t * @param {Function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.setAttributeById = function (id, attribute, value, callback) {\n\t\tPluginAPI.request('editor-element-attribute-set-byid', {\n\t\t\tid: id,\n\t\t\tattribute: attribute,\n\t\t\tvalue: value\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Sets a style of the element with the given ID to value\n\t *\n\t * @param {String} id The ID of the element to set the attribute on\n\t * @param {String} attribute The style attribute to set\n\t * @param {String} value What to set the attribute to\n\t * @param {Function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.setStyleById = function (id, attribute, value, callback) {\n\t\tPluginAPI.request('editor-element-style-set-byid', {\n\t\t\tid: id,\n\t\t\tattribute: attribute,\n\t\t\tvalue: value\n\t\t}, callback);\n\t};\n\n\n\t/**\n\t * Initialize pre registered menus\n\t *\n\t * Available options are: simplePluginMenu, editContext, deleteButton, floatButtons\n\t *\n\t * @param {Array} menus Array of menu names\n\t * @param {Function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.initMenu = function (menus, callback) {\n\t\tPluginAPI.request('editor-initialize-menu', {\n\t\t\tmenus: menus\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Opens the plugin editor for a given element.\n\t *\n\t * @param {String} id Plugin element ID\n\t */\n\tAH5Communicator.prototype.openPluginElementEditor = function (id) {\n\t\tPluginAPI.request('open-element-editor', {\n\t\t\tid: id\n\t\t});\n\t};\n\n\t/**\n\t * Returns the total number of words in the currently open article.\n\t *\n\t * @param {Function} callback Receives the total word count as its single parameter\n\t */\n\tAH5Communicator.prototype.getTotalWordCount = function (callback) {\n\t\tPluginAPI.request('total-word-count', null, callback);\n\t};\n\n\t/**\n\t * Returns the total number of characters in the currently open article.\n\t *\n\t * @param {Function} callback Receives the total character count as its single parameter\n\t */\n\tAH5Communicator.prototype.getTotalCharCount = function (callback) {\n\t\tPluginAPI.request('total-char-count', null, callback);\n\t};\n\n\tAH5Communicator.prototype.updateAssetOption = function (dpArticleId, key, value, callback) {\n\t\tPluginAPI.request('update-asset-option', {dpArticleId: dpArticleId, key: key, value: value}, callback);\n\t};\n\n\tAH5Communicator.prototype.updateAssetData = function (data, callback) {\n\t\tPluginAPI.request('update-asset-media', data, callback);\n\t};\n\n\tAH5Communicator.prototype.getAssetData = function (dpArticleId, callback) {\n\t\tPluginAPI.request('get-asset-data', {data: dpArticleId}, callback);\n\t};\n\n\tAH5Communicator.prototype.insertNestedAsset = function (parentElementId, markup, data, callback) {\n\t\tconst self = this;\n\t\tPluginAPI.createEmbeddedObject(\n\t\t\tdata.embeddedTypeId,\n\t\t\t(dpArticleId) => {\n\t\t\t\tinsert(dpArticleId, parentElementId, (data) => {\n\t\t\t\t\treturn updateEmbeddedAssetRequest(callback);\n\t\t\t\t});\n\t\t\t}\n\t\t);\n\n\t\tfunction insert(dpArticleId, parentElementId, callback) {\n\t\t\tdata.internalId = dpArticleId;\n\t\t\tconst elementId = 'asset-' + dpArticleId;\n\t\t\tconst $element = $('
');\n\t\t\t$element.attr('id', elementId);\n\t\t\t$element.attr('data-internal-id', dpArticleId);\n\t\t\t$element.attr('data-ah5-type', data.assetSource);\n\t\t\tif (data.externalId) {\n\t\t\t\t$element.attr('data-external-id', data.externalId);\n\t\t\t}\n\t\t\tif (data.assetClass) {\n\t\t\t\t$element.addClass(data.assetClass);\n\t\t\t}\n\t\t\t$element.addClass('dp-plugin-element');\n\t\t\t$element.html(markup);\n\t\t\tPluginAPI.Editor.getHTMLById(parentElementId, (html) => {\n\t\t\t\tlet d = document.createElement('div');\n\t\t\t\td.innerHTML = html;\n\t\t\t\td.firstChild.setAttribute('id', parentElementId + 'tmp');\n\t\t\t\tself.replacePluginElementById(parentElementId, d.innerHTML, () => {\n\t\t\t\t\td = document.createElement('div');\n\t\t\t\t\td.innerHTML = html;\n\t\t\t\t\tconst assetContainer = d.querySelector('.dp-fact-box-image, .dp-nested-asset-container');\n\t\t\t\t\tif (data.isMultiple) {\n\t\t\t\t\t\t$(assetContainer).append($element.get(0).outerHTML);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tassetContainer.innerHTML = $element.get(0).outerHTML;\n\t\t\t\t\t}\n\t\t\t\t\tself.replacePluginElementById(parentElementId + 'tmp', d.innerHTML, callback);\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\tfunction updateEmbeddedAssetRequest(callback) {\n\t\t\tPluginAPI.request('update-embedded-asset', data, callback);\n\t\t}\n\t};\n\n\tAH5Communicator.prototype.insertEmbeddedAsset = function (markup, data, callback) {\n\t\tconst self = this;\n\t\tlet replaceElement = false;\n\t\tif (selectedPluginElement) {\n\t\t\tif (data.assetSource !== PluginAPI.getAppName()) {\n\t\t\t\tPluginAPI.showErrorMsg('Can\\'t update selected plugin element since it doesn\\'t belong to the \\'' + PluginAPI.getAppName() + '\\' plugin');\n\t\t\t\treturn;\n\t\t\t} else {\n\t\t\t\treplaceElement = true;\n\t\t\t}\n\t\t}\n\n\t\tif (selectedPluginElement) {\n\t\t\tconst dpArticleId = selectedPluginElement.dpArticleId;\n\t\t\tif (!dpArticleId) {\n\t\t\t\tthrow Error('Selected plugin element: expected dpArticleId not found (tried reading from attribute \\'data-internal-id\\')');\n\t\t\t}\n\t\t\tinsert(dpArticleId, (data) => {\n\t\t\t\treturn updateEmbeddedAssetRequest(typeof callback === 'function' ? callback(data) : null);\n\t\t\t});\n\t\t} else {\n\t\t\tPluginAPI.createEmbeddedObject(\n\t\t\t\tdata.embeddedTypeId,\n\t\t\t\t(dpArticleId) => {\n\t\t\t\t\tinsert(dpArticleId, (data) => {\n\t\t\t\t\t\treturn addEmbeddedAssetRequest(typeof callback === 'function' ? callback(data) : null);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tfunction insert(dpArticleId, callback) {\n\t\t\tdata.internalId = dpArticleId;\n\t\t\tconst elementId = 'asset-' + dpArticleId;\n\t\t\tconst element = document.createElement('div');\n\t\t\telement.id = elementId;\n\t\t\telement.dataset.internalId = dpArticleId;\n\t\t\tif (data.externalId) {\n\t\t\t\telement.dataset.externalId = data.externalId;\n\t\t\t}\n\t\t\tif (data.assetClass) {\n\t\t\t\telement.classList.add(data.assetClass);\n\t\t\t}\n\t\t\telement.innerHTML = markup;\n\t\t\tif (!replaceElement) {\n\t\t\t\tself.insertElement(element, {select: true});\n\t\t\t} else {\n\t\t\t\tself.replaceElementById(elementId, element.outerHTML, null);\n\t\t\t}\n\t\t\tif (typeof callback === 'function') {\n\t\t\t\treturn callback();\n\t\t\t}\n\t\t}\n\n\t\tfunction addEmbeddedAssetRequest(callback) {\n\t\t\tPluginAPI.request('add-embedded-asset', data, callback);\n\t\t}\n\n\t\tfunction updateEmbeddedAssetRequest(callback) {\n\t\t\tPluginAPI.request('update-embedded-asset', data, callback);\n\t\t}\n\t};\n\n\tAH5Communicator.prototype.getSelectedPluginElement = function (callback) {\n\t\tPluginAPI.request('get-selected-plugin-element', {}, callback);\n\t};\n\n\treturn new AH5Communicator();\n};\n","/* jshint maxstatements:52 */\nmodule.exports = function (PluginAPI) {\n\n\t/**\n\t * This class is used for communicating with the article, typically setting and getting values of metadata or in the article content itself.\n\t *\n\t * @class\n\t * @classdesc Functions for talking with the DrPublish article object. Accessed through PluginAPI.Article\n\t * @exports PluginAPI/Article\n\t */\n\tconst ArticleCommunicator = function () {\n\t\tthis.DEBUG = false;\n\t};\n\n\t/**\n\t * Give focus to yourself\n\t *\n\t * @param {Function} callback function(Boolean), called as the app gets focus\n\t */\n\tArticleCommunicator.prototype.focusApp = function (callback) {\n\t\tPluginAPI.request('app-focus', {}, callback);\n\t};\n\t/**\n\t * Start the given app\n\t *\n\t * @param {String} name Name of the app from settings.php\n\t * @param {Object} options Options for initializing the app\n\t * @param {Function} callback function(Boolean), called after app is started\n\t */\n\tArticleCommunicator.prototype.startApp = function (name, options, callback) {\n\t\tPluginAPI.request('app-start', {\n\t\t\tapp: name,\n\t\t\toption: options\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Stop the given app\n\t *\n\t * @param {String} name Name of the app from settings.php\n\t */\n\tArticleCommunicator.prototype.stopApp = function (name) {\n\t\tPluginAPI.request('app-stop', {\n\t\t\tapp: name\n\t\t});\n\t};\n\n\t/**\n\t * Get the id of the article currently edited\n\t *\n\t * @param {Function} callback function(Int), id of the current article\n\t */\n\tArticleCommunicator.prototype.getId = function (callback) {\n\t\tPluginAPI.request('article-id-get', null, callback);\n\t};\n\n\n\t/**\n\t * Get the guid of the article package currently edited\n\t *\n\t * @param {Function} callback function(Int), id of the current article\n\t */\n\tArticleCommunicator.prototype.getPackageId = function (callback) {\n\t\tPluginAPI.request('package-id-get', null, callback);\n\t};\n\n\n\t/**\n\t * Get the guid of the article package currently edited\n\t *\n\t * @param {Function} callback function(Int), id of the current article\n\t */\n\tArticleCommunicator.prototype.getPackageGuid = function (callback) {\n\t\tPluginAPI.request('package-guid-get', null, callback);\n\t};\n\n\t/**\n\t * Clear the meta information summary\n\t *\n\t * @param {Function} callback function(Boolean), called when meta data has been cleared\n\t */\n\tArticleCommunicator.prototype.clearMetaInfo = function (callback) {\n\t\tPluginAPI.request('article-metainfo-clear', null, callback);\n\t};\n\n\t/**\n\t * Get tags used in the article\n\t *\n\t * @param {Function} callback function([Object Tag]), array with tags connected to an article\n\t */\n\tArticleCommunicator.prototype.getTags = function (callback) {\n\t\tPluginAPI.request('article-tags-get', null, callback);\n\t};\n\n\t/**\n\t * Retrieve custom meta value for the article\n\t *\n\t * @param {String} name Name of the custom meta value\n\t * @param {Function} callback function(Object), the parameter is an object containing the given custom meta value\n\t */\n\tArticleCommunicator.prototype.getCustomMeta = function (name, callback) {\n\t\tPluginAPI.request('article-custom-meta-get', {\n\t\t\tname: name\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Set custom meta value for the article\n\t *\n\t * @param {String} name Name of the meta value\n\t * @param {Object} value Value to set\n\t * @param {Function} callback function()\n\t */\n\tArticleCommunicator.prototype.setCustomMeta = function (name, value, callback) {\n\t\tPluginAPI.request('article-custom-meta-set', {\n\t\t\tname: name,\n\t\t\tvalue: value\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Marks article model as having meta data changes\n\t *\n\t * @param {Function} callback function()\n\t */\n\tArticleCommunicator.prototype.setMetaChanged = function (callback) {\n\t\tPluginAPI.request('article-meta-changed', null, callback);\n\t};\n\n\t/**\n\t * Set tags for the article\n\t *\n\t * @param {Array} tags List of tags that should be set\n\t * @param {Boolean} save Set to true to force save once the tags are updated\n\t * @param {Function} callback function(Boolean), called when tags have been set\n\t */\n\tArticleCommunicator.prototype.setTags = function (tags, save, callback) {\n\t\tPluginAPI.request('article-tags-set', {\n\t\t\tsave: save,\n\t\t\ttags: tags\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Add tag for the article\n\t *\n\t * @param {Array} tags Tags to be added\n\t * @param {Function} errorFunction called if error\n\t * @param {Function} callback function(Boolean), called when tag has been set\n\t */\n\tArticleCommunicator.prototype.addTags = function (tags, errorFunction, callback) {\n\t\tPluginAPI.request('article-tags-add', {\n\t\t\ttags: tags,\n\t\t\tonError: errorFunction\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Add tag for the article\n\t *\n\t * @param {String} tag Tag to be added\n\t * @param {Function} errorFunction called if error\n\t * @param {Function} callback function(Boolean), called when tag has been set\n\t */\n\tArticleCommunicator.prototype.addTag = function (tag, errorFunction, callback) {\n\t\tPluginAPI.request('article-tags-add', {\n\t\t\ttags: [tag],\n\t\t\tonError: errorFunction\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Add tags for the article\n\t *\n\t * @param {String} tags Tags to be added\n\t * @param {Function} errorFunction called if error\n\t * @param {Function} callback function(Boolean), called when tag has been set\n\t */\n\tArticleCommunicator.prototype.addTags = function (tags, errorFunction, callback) {\n\t\tPluginAPI.request('article-tags-add', {\n\t\t\ttags: tags,\n\t\t\tonError: errorFunction\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Remove tag from article\n\t *\n\t * @param {String} tag Tag to remove\n\t * @param {Function} callback function(Boolean), called when tag has been removed\n\t */\n\tArticleCommunicator.prototype.removeTag = function (tag, callback) {\n\t\tPluginAPI.request('article-tags-remove', {\n\t\t\ttag: tag\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Get the selected categories\n\t *\n\t * @param {Function} callback function([String]), array with category ids\n\t */\n\tArticleCommunicator.prototype.getSelectedCategories = function (callback) {\n\t\tPluginAPI.request('article-categories-selected-get', null, callback);\n\t};\n\n\t/**\n\t * Save the currently selected categories\n\t *\n\t * @param {Function} callback function(Boolean), called when categories has been saved\n\t */\n\tArticleCommunicator.prototype.saveCategories = function (callback) {\n\t\tthis.getSelectedCategories(function (categories) {\n\t\t\tthis.setCategories(categories, callback);\n\t\t});\n\t};\n\n\t/**\n\t * Set selected categories\n\t *\n\t * @param {Array} categories List of category IDs that should be set\n\t * @param {Function} callback function(Boolean), called when categories have been set\n\t */\n\tArticleCommunicator.prototype.setCategories = function (categories, callback) {\n\t\tPluginAPI.request('article-categories-selected-set', {\n\t\t\tcategories: categories\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Add the given categories to the list of categories\n\t *\n\t * @param {Array} categories List of category IDs to add\n\t * @param {Function} callback function(Boolean), called when the categories have been set\n\t */\n\tArticleCommunicator.prototype.addCategories = function (categories, callback) {\n\n\t\tPluginAPI.request('article-categories-add', {\n\t\t\tcategories: categories\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Remove the given categories from the list of categories\n\t *\n\t * @param {Array} categories List of category IDs to remove\n\t * @param {Function} callback function(Boolean), called when the categories have been removed\n\t */\n\tArticleCommunicator.prototype.removeCategories = function (categories, callback) {\n\t\tPluginAPI.request('article-categories-remove', {\n\t\t\tcategories: categories\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Set the main category of the current article\n\t *\n\t * @param {Number} category The ID of the category to set as the main category\n\t * @param {Function} callback function(Boolean), called when the main category has been set\n\t */\n\tArticleCommunicator.prototype.setMainCategory = function (category, callback) {\n\t\tPluginAPI.request('article-categories-main-set', {\n\t\t\tcategory: category\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Get the source set for the article\n\t *\n\t * @param {Function} callback function(String), name of the source\n\t */\n\tArticleCommunicator.prototype.getSource = function (callback) {\n\n\t\tPluginAPI.request('article-source-get', null, callback);\n\t};\n\n\t/**\n\t * Set the source for the article\n\t *\n\t * @param {String} value The new value to be set as source\n\t * @param {Function} callback function(Boolean), called when the source has been set\n\t */\n\tArticleCommunicator.prototype.setSource = function (value, callback) {\n\t\tPluginAPI.request('article-source-set', {\n\t\t\tsource: value\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Get the status for the article\n\t *\n\t * @param {Function} callback function(String), current status\n\t */\n\tArticleCommunicator.prototype.getStatus = function (callback) {\n\t\tPluginAPI.request('article-status-get', null, callback);\n\t};\n\n\t/**\n\t * Set the status for the article\n\t *\n\t * @param {String} status The new status to be set (draft, waiting, published)\n\t * @param {Function} callback function(Boolean), called when the source has been set\n\t */\n\tArticleCommunicator.prototype.setStatus = function (status, callback) {\n\t\tPluginAPI.request('article-status-set', {\n\t\t\tstatus: status\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Get the published-date\n\t *\n\t * @param {Function} callback function(String), current published datetime\n\t */\n\tArticleCommunicator.prototype.getPublishedDatetime = function (callback) {\n\t\tPluginAPI.request('article-published-get', null, callback);\n\t};\n\n\t/**\n\t * Set the published-date\n\t *\n\t * @param {String} published Date to be set (YYYY-MM-DD HH:MM:SS)\n\t * @param {Function} callback function(Boolean), called when done\n\t */\n\tArticleCommunicator.prototype.setPublishedDatetime = function (published, callback) {\n\t\tPluginAPI.request('article-published-set', {\n\t\t\tpublished: published\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Get the authors set in the article\n\t *\n\t * @param {Function} callback function([String]), currently set authors\n\t */\n\tArticleCommunicator.prototype.getAuthors = function (callback) {\n\t\tPluginAPI.request('article-authors-get', null, callback);\n\t};\n\n\t/**\n\t * Set authors for the article\n\t *\n\t * @param {Array} authors List of authors that should be set\n\t * @param {Function} callback function(Boolean), called when it has been set\n\t */\n\tArticleCommunicator.prototype.setAuthors = function (authors, callback) {\n\t\tPluginAPI.request('article-authors-set', {\n\t\t\tauthors: authors\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Add the given authors to the list of authors\n\t *\n\t * @param {Array} authors List of authors to add\n\t * @param {Function} callback function(Boolean), called when it has been set\n\t */\n\tArticleCommunicator.prototype.addAuthors = function (authors, callback) {\n\t\tPluginAPI.request('article-authors-add', {\n\t\t\tauthors: authors\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Remove the given authors from the list of authors\n\t *\n\t * @param {Array} authors List of authors to remove\n\t * @param {Function} callback function([String]), author list as it is after the authors has been removed\n\t */\n\tArticleCommunicator.prototype.removeAuthors = function (authors, callback) {\n\t\tPluginAPI.request('article-authors-remove', {\n\t\t\tauthors: authors\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Set the keyword-list on the article\n\t *\n\t * @param {Array} keywords List of keywords to add\n\t * @param {Function} callback Function to call when keywords have been set\n\t */\n\tArticleCommunicator.prototype.setKeywords = function (keywords, callback) {\n\t\tPluginAPI.request('article-keywords-set', {\n\t\t\tkeywords: keywords\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Get the current set of keywords on the article\n\t *\n\t * @param {Function} callback Function to call with the result\n\t */\n\tArticleCommunicator.prototype.getKeywords = function (callback) {\n\t\tPluginAPI.request('article-keywords-get', null, callback);\n\t};\n\n\t/**\n\t * Gets the current article content\n\t *\n\t * @param {Function} callback function(Object Content)\n\t */\n\tArticleCommunicator.prototype.getCurrentContent = function (callback) {\n\t\tPluginAPI.request('article-content-get', null, callback);\n\t};\n\n\t/**\n\t * Updates current article content\n\t *\n\t * @param {String} content The new content for the article\n\t * @param {Function} callback function(Boolean), called when it has been set\n\t */\n\tArticleCommunicator.prototype.setCurrentContent = function (content, callback) {\n\t\tPluginAPI.request('article-content-set', {\n\t\t\tcontent: content\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Get the article type of the current article\n\t *\n\t * @param {Function} callback function(Int)\n\t */\n\tArticleCommunicator.prototype.getArticletypeId = function (callback) {\n\t\tPluginAPI.request('article-type-get', null, callback);\n\t};\n\n\t/**\n\t * Set the article type of the current article\n\t *\n\t * @param {Number} articletypeId The new article type of the article\n\t * @param {Function} callback function(Boolean), called when it has been set\n\t */\n\tArticleCommunicator.prototype.setArticletypeId = function (articletypeId, callback) {\n\t\tPluginAPI.request('article-type-set', {\n\t\t\tarticletype: articletypeId\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Maximize the app view\n\t *\n\t * @param {String} title Title to give the maximized view\n\t * @param {function} onClose Function to call when the window is closed/minimized\n\t */\n\tArticleCommunicator.prototype.maximizeAppWindow = function (title, onClose) {\n\t\tconst event = 'editor-pane-close-' + new Date().getTime();\n\n\t\tPluginAPI.request('editor-pane-maximize', {\n\t\t\ttitle: title,\n\t\t\tevent: event\n\t\t});\n\t\tPluginAPI.eventListeners.removeAll(event);\n\t\tPluginAPI.eventListeners.add(event, onClose);\n\t};\n\n\t/**\n\t * Restore the app pane to the default size\n\t *\n\t * @param {function} callback Callback to call after everything is done\n\t */\n\tArticleCommunicator.prototype.restoreAppWindow = function (callback) {\n\t\tPluginAPI.request('restore-app-window', {}, callback);\n\t};\n\n\t/**\n\t * Get the current byline\n\t *\n\t * @param {function} callback function(String), xml string with the current byline\n\t */\n\tArticleCommunicator.prototype.getByline = function (callback) {\n\t\tPluginAPI.request('article-byline-get', null, callback);\n\t};\n\n\t/**\n\t * Set the byline\n\t *\n\t * @param {String} byline XML version of byline to use\n\t * @param {Boolean} save If true, force save after updating byline information\n\t * @param {Function} callback function(Boolean), called when it has been set\n\t */\n\tArticleCommunicator.prototype.setByline = function (byline, save, callback) {\n\t\tPluginAPI.request('article-byline-set', {\n\t\t\tsave: save,\n\t\t\tbyline: byline\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Set geolocation\n\t *\n\t * @param {Object} geolocations The location to set\n\t * @param {Function} callback function(Boolean), called when it has been set\n\t */\n\tArticleCommunicator.prototype.setGeolocations = function (geolocations, callback) {\n\t\tPluginAPI.request('article-geolocations-set', {\n\t\t\tgeolocations: geolocations\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Get geolocation\n\t *\n\t * @param {Function} callback function(Object), retrieves the currently set geo location\n\t */\n\tArticleCommunicator.prototype.getGeolocations = function (callback) {\n\t\tPluginAPI.request('article-geolocations-get', null, callback);\n\t};\n\n\t/**\n\t * Fetches a list of all properties available to an article.\n\t *\n\t * @param {Function} callback Callback called with an array of property objects.\n\t */\n\tArticleCommunicator.prototype.getProperties = function (callback) {\n\t\tPluginAPI.request('article-properties-get', null, callback);\n\t};\n\n\t/**\n\t * Updates and saves one or more property values. The input is a simple object with property names and their\n\t * new value. The supplied callback is called with an updated list of properties.\n\t *\n\t * @example\n\t * PluginAPI.Article.setProperties({\n\t * fooProperty: \"bar\",\n\t * barProperty: \"foo\"\n\t * }, function(properties) {\n\t * // Returns a complete and updated list of properties.\n\t * })\n\t *\n\t * @param {Object} properties An object of property names and corresponding values.\n\t * @param {Function} callback Callback called with an updated list of properties.\n\t */\n\tArticleCommunicator.prototype.setProperties = function (properties, callback) {\n\t\tPluginAPI.request('article-properties-set', {\n\t\t\tproperties: properties\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Updates and saves a single property.\n\t *\n\t * @param {String} name The property to update.\n\t * @param {Object} value The updated value.\n\t * @param {Function} callback Callback called with an updated list of properties.\n\t */\n\tArticleCommunicator.prototype.setProperty = function (name, value, callback) {\n\t\tconst data = {};\n\t\tdata[name] = value;\n\t\tPluginAPI.request('article-properties-set', {\n\t\t\tproperties: data\n\t\t}, callback);\n\t};\n\n\tArticleCommunicator.prototype.getTopic = function (callback) {\n\t\tPluginAPI.request('article-topic-get', null, callback);\n\t};\n\n\tArticleCommunicator.prototype.setTopic = function (name, callback) {\n\t\tPluginAPI.request('article-topic-set', {\n\t\t\ttopic: name\n\t\t}, callback);\n\t};\n\n\treturn new ArticleCommunicator();\n\n};\n","/**\n * @example\n * PluginAPI.on('afterCreate', function() {\n * PluginAPI.Article.setSource('Ny Times');\n * });\n * PluginAPI.on('beforeSave', function() {\n * if (!articleIsAwesome()) {\n * return false;\n * }\n * });\n *\n * @description\n *\n *

DrPublish provides a large set of default events that an app can listen for. All events that start their name with 'before' can be stopped by an app. This is done by returning 'false' from the callback function, as in the 'beforSave' example given bellow.

\n *

Other apps can also supply their own events using the PluginAPI.emit(...) function. Documention on these events are up to each app to create.

\n *

Available Events

\n *

addCategory

\n *
\n *

triggered after a category has been added to the article

\n *
\n *

addTag

\n *
\n *

triggered after a tag had been added to the article

\n *
\n *

appPaneMaximized

\n *
\n *

triggered when the app pane is maximized

\n *
\n *

appPaneRestored

\n *
\n *

triggered when the app pane is restored to its' original size

\n *
\n *

appAuthenticated

\n *
\n *

triggered when an app has been authenticated

\n *
\n *

changedCustomMeta

\n *
\n *

triggered when a custom meta property is changed/set, parameter is an object with property name and value

\n *
\n *

receivedFocus

\n *
\n *

triggered when a plugin receives focus. Receives a parameter object that has two predefined values: previousPluginName - name of previous plugin, givenFocus - true when focus was sent from another plugin. The parameter object can also contain other keys supplied by the plugin losing focus.

\n *
\n *

afterCreate

\n *
\n *

triggered after a new article has been created

\n *
\n *

beforeDelete

\n *
\n *

triggered before an article is deleted

\n *
\n *

afterDelete

\n *
\n *

triggered after an article has been deleted

\n *
\n *

afterLoad

\n *
\n *

triggered after an article has been loaded

\n *
\n *

afterPublish

\n *
\n *

triggered after an article has been published

\n *
\n *

afterSave

\n *
\n *

triggered after an article has been saved

\n *
\n *

beforeCreate

\n *
\n *

triggered before a new article is created

\n *
\n *

beforeLoad

\n *
\n *

triggered before an article is loaded into the editor

\n *
\n *

beforePreview

\n *
\n *

triggered before the article is opened in the preview

\n *
\n *

beforeSave

\n *
\n *

triggered before an article is saved

\n *
\n *

beforePublish

\n *
\n *

triggered before an article is published

\n *
\n *

editorFocus

\n *
\n *

triggered when an editor gets focus

\n *
\n *

editorUnfocus

\n *
\n *

triggered when an editor loses focus

\n *
\n *

editorsLostFocus

\n *
\n *

triggered when all editors loses focus

\n *
\n *

editorReady

\n *
\n *

triggered when the editor has been fully loaded and is ready for input

\n *
\n *

modifiedContent

\n *
\n *

triggered whenever content changes in the article

\n *
\n *

elementRemoved

\n *
\n *

triggered when a plugin element from the current plugin is removed, receives an object with element id as a parameter

\n *
\n *

pluginElementClicked

\n *
\n *

triggered when someone clicks on a plugin element in the editor

\n *
\n *

pluginElementSelected

\n *
\n *

triggers when someone selects a plugin element in the editor

\n *
\n *

pluginElementDeselected

\n *
\n *

triggered when someone deselects a plugin element in the editor

\n *
\n */\nclass Listeners {\n\tconstructor() {\n\t\tthis._listeners = {};\n\t}\n\n\n\t/**\n\t * @deprecated Use PluginAPI.on(...) instead\n\t * @param {Object} listeners\n\t */\n\taddAll(listeners) {\n\t\tconst PluginAPI = require('./PluginAPI');\n\t\t'use strict';\n\t\tconst createCallback = function (callback) {\n\t\t\treturn function (data) {\n\t\t\t\tcallback(data.data);\n\t\t\t};\n\t\t};\n\t\tfor (const eventName in listeners) {\n\t\t\tif (listeners.hasOwnProperty(eventName)) {\n\t\t\t\tconst callback = listeners[eventName];\n\t\t\t\tconst callWrapper = createCallback(callback);\n\t\t\t\tPluginAPI.on(eventName, callWrapper);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Adds a new listener\n\t *\n\t * @param {String} event Event name\n\t * @param {Function} callback Function to call when an even of the type is received\n\t * @return {number}\n\t */\n\tadd(event, callback) {\n\n\t\tif (typeof callback !== 'function') {\n\t\t\tthrow new Error('not a function');\n\t\t}\n\n\t\tif (this._listeners[event] === undefined) {\n\t\t\tthis._listeners[event] = [];\n\t\t}\n\n\t\tthis._listeners[event].push(callback);\n\t\treturn this._listeners[event].length - 1;\n\t}\n\n\t/**\n\t * Removes the listener at the given index\n\t *\n\t * @param {String} event Event type\n\t * @param {Function} index The index of the event handler to remove\n\t */\n\tremove(event, index) {\n\n\t\tif (this._listeners[event] === undefined || this._listeners[event][index] === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\t/*\n\t\t * Set to null instead of remove to retain callback indexes\n\t\t */\n\t\tthis._listeners[event][index] = false;\n\t}\n\n\t/**\n\t * Removes all listeners for the given event type, or if !event then removes all listeners\n\t *\n\t * @param {String} event Event type to remove handlers for (!event for all)\n\t */\n\tremoveAll(event) {\n\t\tif (!event) {\n\t\t\tthis._listeners = [];\n\t\t} else {\n\t\t\tthis._listeners[event] = [];\n\t\t}\n\t}\n\n\t/**\n\t * Notifies all registered listeners that an event has occurred\n\t *\n\t * @param {String} event Event type\n\t * @param {Object} payload The event data\n\t * @return {Boolean}\n\t */\n\tnotify(event, payload) {\n\t\tlet returnValue = true;\n\t\tif (this._listeners[event] === undefined) {\n\t\t\treturn returnValue;\n\t\t}\n\n\t\t// If the payload is an object with a key data, we use that value as the payload we pass to the listener functions.\n\t\t// This is needed as we have some inconsistencies in how we pass data around. This normalization should preferably\n\t\t// be done at the call site.\n\t\tthis._listeners[event].forEach((listenerFn) => {\n\t\t\tif (typeof listenerFn !== 'function') {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlet res = null;\n\t\t\tif (payload && payload.params && payload.params === true) {\n\t\t\t\tres = listenerFn.apply(null, payload.data);\n\t\t\t} else if (typeof payload === 'object' && payload !== null && typeof payload.data !== 'undefined') {\n\t\t\t\tres = listenerFn(payload.data);\n\t\t\t} else {\n\t\t\t\tres = listenerFn(payload);\n\t\t\t}\n\t\t\tif (res === false) {\n\t\t\t\treturnValue = false;\n\t\t\t}\n\t\t});\n\t\treturn returnValue;\n\t}\n\n}\n\nmodule.exports = Listeners;\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://PluginAPI/webpack/universalModuleDefinition","webpack://PluginAPI/webpack/bootstrap","webpack://PluginAPI/./js/PluginAPI.js","webpack://PluginAPI/./js/AH5Communicator.js","webpack://PluginAPI/./js/ArticleCommunicator.js","webpack://PluginAPI/./js/Listeners.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","ah5Communicator","articleCommunicator","Listeners","Api","PluginAPI","queryParameters","location","search","substr","split","forEach","queryPair","this","DEBUG","Version","Editor","Article","errorListeners","eventListeners","appName","jwt","standAlone","selectedPluginElement","self","pm","data","createEventFunction","eventName","request","updateObject","_typeof","type","eventKey","map","notify","abort","callSpec","callback","console","info","getPluginName","length","createCallbackObject","random","Math","floor","Date","getTime","eventFunction","func","remove","apply","arguments","add","val","target","parent","success","error","origin","hash","openTagCreationDialog","tag","reloadIframe","app","getAppName","setPluginName","setAppName","showInfoMsg","msg","message","showWarningMsg","showErrorMsg","showLoader","hideLoader","__loadArticleRevision","id","revision","createTag","searchDrLib","query","access","secure","convertDomToHTML","dom","wrap","html","domClone","cloneNode","wrapper","document","createElement","appendChild","innerHTML","generateArticleUrl","extendApi","group","action","a","callExtendedApi","getCurrentUser","getConfiguration","getDrPublishConfiguration","setConfiguration","config","options","onlyPublication","emit","on","increaseRequiredActionCounter","decreaseRequiredActionCounter","clearRequiredActionCounter","setRequiredActionCounter","count","createEmbeddedObject","typeId","getEmbeddedObjectTypes","giveFocus","pluginName","argument","start","hide","createModal","content","updateModal","closeModal","destroy","getModalInputs","confirmAuthenticated","isStandAlone","getJWT","replaceEditorComponentsExtension","clearEditorComponentsExtension","highlightAnnotation","underemphasizeAnnotations","registerExternallyDefinedProperties","AH5Communicator","elementData","getActiveEditor","registerMenuAction","registerHoverAction","getSelectedPluginElement","deSelectPluginElements","directionalCastle","elementId","direction","registerMenuActionGroup","getEditorType","replaceElementById","element","replacePluginElementById","setElementContentById","deleteElementById","getHTMLById","getHTMLBySelector","selector","getCategories","getParentCategories","category","getParentIds","getTagTypes","getTagType","clear","insertString","string","insertElement","select","outerHTML","removeClasses","classes","addClasses","getDataAttribute","attribute","updateDataAttribute","markAsActive","setAttributeById","setStyleById","initMenu","menus","openPluginElementEditor","getTotalWordCount","getTotalCharCount","updateAssetOption","dpArticleId","updateAssetData","getAssetData","insertNestedAsset","parentElementId","markup","updateEmbeddedAssetRequest","embeddedTypeId","internalId","$element","$","attr","assetSource","externalId","dpDigitalAssetId","assetClass","addClass","firstChild","setAttribute","assetContainer","querySelector","isMultiple","append","insert","insertEmbeddedAsset","updateContent","Error","addEmbeddedAssetRequest","dataset","classList","getCurrentSelectionAbsolutePosition","wrapSelection","className","attributes","removeInPlace","triggerEvent","event","getOrderedIDs","ArticleCommunicator","focusPlugin","focusApp","startPlugin","option","startApp","stopPlugin","stopApp","getId","getPackageId","getPackageGuid","clearMetaInfo","getTags","getCustomMeta","setCustomMeta","setMetaChanged","setTags","tags","save","addTags","errorFunction","onError","addTag","removeTag","getSelectedCategories","saveCategories","categories","setCategories","addCategories","removeCategories","setMainCategory","getSource","setSource","source","getStatus","setStatus","status","getPublishedDatetime","setPublishedDatetime","published","getAuthors","setAuthors","authors","addAuthors","removeAuthors","setKeywords","keywords","getKeywords","getCurrentContent","setCurrentContent","setSubArticleContent","articleId","getArticletypeId","setArticletypeId","articletypeId","articletype","maximizePluginWindow","title","onClose","removeAll","maximizeAppWindow","restorePluginWindow","restoreAppWindow","getByline","setByline","byline","setGeolocations","geolocations","getGeolocations","getProperties","setProperties","properties","setProperty","getTopic","setTopic","topic","getPackage","_classCallCheck","_listeners","listeners","createCallback","callWrapper","undefined","push","index","payload","returnValue","listenerFn","params"],"mappings":"CAAA,SAAAA,EAAAC,GACA,kBAAAC,SAAA,kBAAAC,OACAA,OAAAD,QAAAD,IACA,oBAAAG,eAAAC,IACAD,OAAA,GAAAH,GACA,kBAAAC,QACAA,QAAA,UAAAD,IAEAD,EAAA,UAAAC,IARA,CASCK,OAAA,WACD,mBCTA,IAAAC,EAAA,GAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAP,QAGA,IAAAC,EAAAI,EAAAE,GAAA,CACAC,EAAAD,EACAE,GAAA,EACAT,QAAA,IAUA,OANAU,EAAAH,GAAAI,KAAAV,EAAAD,QAAAC,IAAAD,QAAAM,GAGAL,EAAAQ,GAAA,EAGAR,EAAAD,QA0DA,OArDAM,EAAAM,EAAAF,EAGAJ,EAAAO,EAAAR,EAGAC,EAAAQ,EAAA,SAAAd,EAAAe,EAAAC,GACAV,EAAAW,EAAAjB,EAAAe,IACAG,OAAAC,eAAAnB,EAAAe,EAAA,CAA0CK,YAAA,EAAAC,IAAAL,KAK1CV,EAAAgB,EAAA,SAAAtB,GACA,qBAAAuB,eAAAC,aACAN,OAAAC,eAAAnB,EAAAuB,OAAAC,YAAA,CAAwDC,MAAA,WAExDP,OAAAC,eAAAnB,EAAA,cAAiDyB,OAAA,KAQjDnB,EAAAoB,EAAA,SAAAD,EAAAE,GAEA,GADA,EAAAA,IAAAF,EAAAnB,EAAAmB,IACA,EAAAE,EAAA,OAAAF,EACA,KAAAE,GAAA,kBAAAF,QAAAG,WAAA,OAAAH,EACA,IAAAI,EAAAX,OAAAY,OAAA,MAGA,GAFAxB,EAAAgB,EAAAO,GACAX,OAAAC,eAAAU,EAAA,WAAyCT,YAAA,EAAAK,UACzC,EAAAE,GAAA,iBAAAF,EAAA,QAAAM,KAAAN,EAAAnB,EAAAQ,EAAAe,EAAAE,EAAA,SAAAA,GAAgH,OAAAN,EAAAM,IA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EV,GAAwB,oBAAbA,EACV,MAAM,IAAI4K,MAAM,kBAQjB,YAL+B8F,IAA3BnS,KAAK+R,WAAWhF,KACnB/M,KAAK+R,WAAWhF,GAAS,IAG1B/M,KAAK+R,WAAWhF,GAAOqF,KAAK3Q,GACrBzB,KAAK+R,WAAWhF,GAAOlL,OAAS,iCASjCkL,EAAOsF,QAEkBF,IAA3BnS,KAAK+R,WAAWhF,SAA0DoF,IAAlCnS,KAAK+R,WAAWhF,GAAOsF,KAOnErS,KAAK+R,WAAWhF,GAAOsF,IAAS,qCAQvBtF,GACJA,EAGJ/M,KAAK+R,WAAWhF,GAAS,GAFzB/M,KAAK+R,WAAa,kCAabhF,EAAOuF,GACb,IAAIC,GAAc,EAClB,YAA+BJ,IAA3BnS,KAAK+R,WAAWhF,GACZwF,GAMRvS,KAAK+R,WAAWhF,GAAOjN,QAAQ,SAAC0S,GACL,oBAAfA,IAWC,KAPRF,GAAWA,EAAQG,SAA6B,IAAnBH,EAAQG,OAClCD,EAAWjQ,MAAM,KAAM+P,EAAQzR,MACR,WAAnBK,EAAOoR,IAAoC,OAAZA,GAA4C,qBAAjBA,EAAQzR,KACtE2R,EAAWF,EAAQzR,MAEnB2R,EAAWF,MAGjBC,GAAc,KAGTA,kDAKT1V,EAAOD,QAAU0C","file":"bundle.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"PluginAPI\"] = factory();\n\telse\n\t\troot[\"PluginAPI\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","/* eslint max-statements: [\"error\", 100000000] */\n/* eslint complexity: [\"error\", 100000000] */\n/* global pm */\n\nconst ah5Communicator = require('./AH5Communicator');\nconst articleCommunicator = require('./ArticleCommunicator');\nconst Listeners = require('./Listeners');\n\nconst PluginAPI = (function () {\n\n\t/**\n\t *\n\t * Namespace for all public DrPublish methods available from plugins.\n\t *\n\t * @class\n\t * @classdesc The basic API object\n\t * @exports PluginAPI\n\t *\n\t */\n\tconst Api = function () {\n\n\t\tconst queryParameters = {};\n\t\twindow.location.search.substr(1).split('&').forEach((queryPair) => {\n\t\t\tqueryParameters[queryPair.split('=')[0]] = queryPair.split('=')[1];\n\t\t});\n\n\n\t\tthis.DEBUG = false;\n\n\t\tthis.Version = '1.0';\n\t\tthis.Editor = null;\n\t\tthis.Article = null;\n\t\tthis.errorListeners = new Listeners();\n\t\tthis.eventListeners = new Listeners();\n\t\tthis.appName = queryParameters.appName || '';\n\t\tthis.jwt = queryParameters.jwt || '';\n\t\tthis.standAlone = queryParameters.standAlone && queryParameters.standAlone === 'true' || false;\n\t\tthis.selectedPluginElement = null;\n\n\t\tconst self = this;\n\n\t\tpm.bind('event', (data) => {\n\t\t\tconst createEventFunction = function (eventName) {\n\t\t\t\treturn function (data) {\n\t\t\t\t\tPluginAPI.request(eventName, data);\n\t\t\t\t};\n\t\t\t};\n\t\t\tconst updateObject = function (data) {\n\t\t\t\tfor (const key in data) {\n\t\t\t\t\tif (data.hasOwnProperty(key)) {\n\t\t\t\t\t\tif (typeof data[key] === 'object' && data[key] !== null && data[key].type === 'function') {\n\t\t\t\t\t\t\tdata[key] = createEventFunction(data[key].eventKey);\n\t\t\t\t\t\t} else if (typeof data[key] === 'object' && data[key] !== null && typeof data[key].map === 'function') {\n\t\t\t\t\t\t\tdata[key] = data[key].map(updateObject);\n\t\t\t\t\t\t} else if (typeof data[key] === 'object' && data[key] !== null) {\n\t\t\t\t\t\t\tdata[key] = updateObject(data[key]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn data;\n\t\t\t};\n\t\t\tdata.data = updateObject(data.data);\n\n\t\t\tdata = self.eventListeners.notify(data.type, data.data);\n\t\t\tif (typeof data === 'undefined') {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (data === false) {\n\t\t\t\treturn {'abort': true};\n\t\t\t}\n\t\t\treturn data;\n\t\t}, '*');\n\t};\n\n\t/**\n\t * Dispatches a request to DrPublish, and returns the reply to callback On error, notifies all error listeners based on the index .type of the thrown object\n\t *\n\t * @param {String} callSpec What do you want to call?\n\t * @param {Object} data The data attached to the request\n\t * @param {Function} callback The function to call upon return\n\t */\n\tApi.prototype.request = function (callSpec, data, callback) {\n\t\tconst self = this;\n\t\tif (this.DEBUG) {\n\t\t\tconsole.info(this.getPluginName() + ': Requesting ' + callSpec + ' from parent with data', data);\n\t\t}\n\n\t\tif (!data) {\n\t\t\tdata = {};\n\t\t}\n\n\t\tif (typeof callback === 'undefined') {\n\t\t\tcallback = null;\n\t\t}\n\n\t\tif (typeof data.length === 'number') {\n\t\t\tdata = {data: data};\n\t\t}\n\n\t\tdata['src_app'] = this.getPluginName();\n\n\t\tconst createEventFunction = function (func, eventKey) {\n\t\t\treturn function () {\n\t\t\t\tself.eventListeners.remove(eventKey, eventKey);\n\t\t\t\treturn func.apply(null, arguments);\n\t\t\t};\n\t\t};\n\n\n\t\tconst createCallbackObject = function (key, callback) {\n\t\t\tconst random = Math.floor(Math.random() * 1000);\n\t\t\tconst eventKey = key + random + 'functioncallback' + (new Date()).getTime();\n\t\t\tconst eventFunction = createEventFunction(callback, eventKey);\n\t\t\tself.eventListeners.add(eventKey, eventFunction);\n\t\t\treturn {\n\t\t\t\ttype: 'function',\n\t\t\t\teventKey: eventKey\n\t\t\t};\n\t\t};\n\n\t\tconst updateObject = function (data) {\n\t\t\tfor (const key in data) {\n\t\t\t\tif (data.hasOwnProperty(key)) {\n\t\t\t\t\tconst val = data[key];\n\t\t\t\t\tif (typeof val === 'function') {\n\t\t\t\t\t\tdata[key] = createCallbackObject(key, val);\n\t\t\t\t\t} else if (typeof val === 'object' && val !== null && typeof val.map === 'function') {\n\t\t\t\t\t\tdata[key] = val.map(updateObject);\n\t\t\t\t\t} else if (typeof val === 'object' && val !== null) {\n\t\t\t\t\t\tdata[key] = updateObject(val);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn data;\n\t\t};\n\t\tdata = updateObject(data);\n\n\t\tpm({\n\t\t\ttarget: parent,\n\t\t\ttype: callSpec,\n\t\t\tdata: data,\n\t\t\tsuccess: callback,\n\t\t\terror: (data) => {\n\t\t\t\tself.errorListeners.notify(data.type, data);\n\t\t\t},\n\t\t\torigin: '*', // TODO: Find a way of avoiding all-origins\n\t\t\thash: false\n\t\t});\n\t};\n\n\n\t/**\n\t * Creates a new tag\n\t *\n\t * @param {String} tag The tag to create\n\t * @param {Function} callback function(Boolean)\n\t */\n\tApi.prototype.openTagCreationDialog = function (tag, callback) {\n\t\tthis.request('create-tag', {\n\t\t\ttag: tag\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Reloads the plugins's iframe\n\t */\n\tApi.prototype.reloadIframe = function () {\n\n\t\tthis.request('app-reload', {\n\t\t\tapp: this.getPluginName()\n\t\t});\n\t};\n\n\t/**\n\t * Get the name of the loaded plugin\n\t *\n\t * @return {String} The name of the plugin, or false if it couldn't be detected\n\t */\n\tApi.prototype.getPluginName = function () {\n\t\treturn this.appName;\n\t};\n\n\t/**\n\t * Get the name of the loaded plugin\n\t * @deprecated: use getPluginName instead\n\t * @return {String} The name of the plugin, or false if it couldn't be detected\n\t */\n\tApi.prototype.getAppName = function () {\n\t\treturn this.getPluginName();\n\t};\n\n\t/**\n\t * Set the name of the plugin\n\t *\n\t * @param {String} name The name of the plugin\n\t */\n\tApi.prototype.setPluginName = function (name) {\n\t\tthis.appName = name;\n\t};\n\n\t/**\n\t * Set the name of the plugin\n\t * @deprecated: use setPluginName instead\n\t *\n\t * @param {String} name The name of the plugin\n\t */\n\tApi.prototype.setAppName = function (name) {\n\t\tthis.setPluginName(name);\n\t};\n\n\t/**\n\t * Show info-message to the user\n\t *\n\t * @param {String} msg Message to be displayed\n\t */\n\tApi.prototype.showInfoMsg = function (msg) {\n\n\t\tthis.request('show-message-info', {\n\t\t\tmessage: msg\n\t\t});\n\t};\n\n\t/**\n\t * Show warning-message to the user\n\t *\n\t * @param {String} msg Message to be displayed\n\t */\n\tApi.prototype.showWarningMsg = function (msg) {\n\n\t\tthis.request('show-message-warning', {\n\t\t\tmessage: msg\n\t\t});\n\t};\n\n\t/**\n\t * Show error-message to the user\n\t *\n\t * @param {String} msg Message to be displayed\n\t */\n\tApi.prototype.showErrorMsg = function (msg) {\n\n\t\tthis.request('show-message-error', {\n\t\t\tmessage: msg\n\t\t});\n\t};\n\n\t/**\n\t * Show the loader\n\t *\n\t * @param {String} msg Message to display in progress loader\n\t */\n\tApi.prototype.showLoader = function (msg) {\n\t\tthis.request('show-loader', {\n\t\t\tmessage: msg\n\t\t});\n\t};\n\n\t/**\n\t * Hide the loader\n\t */\n\tApi.prototype.hideLoader = function () {\n\t\tthis.request('hide-loader');\n\t};\n\n\n\t/**\n\t * Loads an old revision of an article\n\t *\n\t * @param {Number} id The id of the revision to load\n\t * @param {Function} callback The function to call when the new revision has been loaded\n\t * @private\n\t */\n\tApi.prototype.__loadArticleRevision = function (id, callback) {\n\t\tthis.request('load-revision', {\n\t\t\trevision: id\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Creates a new tag\n\t *\n\t * @param {String} tag JSON object with the tag to create, must contain tagTypeId and name properties\n\t * @param {Function} callback function(Boolean)\n\t */\n\tApi.prototype.createTag = function (tag, callback) {\n\t\tthis.request('tag-create', {\n\t\t\ttag: tag\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Sends a query to DrLib\n\t *\n\t * @example\n\t * PluginAPI.searchDrLib({\n\t * query: 'articles.json?q=awesome',\n\t * secure: true,\n\t * success: function(data) {\n\t * data.items.forEach(doStuffWithArticle);\n\t * },\n\t * error: function(data) {\n\t * console.warn('something went wrong');\n\t * }\n\t * })\n\t *\n\t * @param {Object} data Object with three properties; 'query' which is the query to send to DrLib, 'success' which is the callback to execute on success, and 'secure' a boolean to add the internal API key to the query and thus allow searching on unpublished article. This callback's parameter is an object which is the query result as an object. See the json output of DrLib to learn more about this object\n\t * @param {Function} callback function(Boolean)\n\t *\n\t */\n\tApi.prototype.searchDrLib = function (data, callback) {\n\t\tthis.request('drlib-search', {\n\t\t\tquery: data.query,\n\t\t\taccess: data.access,\n\t\t\tsecure: data.secure,\n\t\t\tsuccess: data.success,\n\t\t\terror: data.error\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Generates proper html code to represent the dom element. This is NOT an asynchronous function\n\t *\n\t * @param {Object} dom The dom node to convert\n\t * @return {String} The html code\n\t */\n\t// TODO: This function should also be able to take a DOMElement or similar.\n\tApi.prototype.convertDomToHTML = function (dom) {\n\t\tif (typeof dom === 'object' && typeof dom.wrap === 'function') {\n\t\t\treturn dom.wrap('
').parent().html();\n\t\t} else {\n\t\t\tconst domClone = dom.cloneNode(true);\n\t\t\tconst wrapper = document.createElement('div');\n\t\t\twrapper.appendChild(domClone);\n\t\t\treturn wrapper.innerHTML;\n\t\t}\n\t};\n\n\t/**\n\t * Generates an url to a published article\n\t *\n\t * @param {String} id The id of the article to generate url for\n\t * @param {Function} callback function(String), where the parameter is the generated url\n\t */\n\tApi.prototype.generateArticleUrl = function (id, callback) {\n\t\tthis.request('generate-article-url', {\n\t\t\tid: id\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Extends the PluginAPI with custom functionality that other plugins can use\n\t *\n\t * @param {String} group Group name for functionality to add\n\t * @param {String} name Name of the specific function to add\n\t * @param {Function} action function(Object) Function to call when the API is invoked, recieves one parameter as given in PluginAPI.callExtendedApi and return value is passed back to the caller\n\t */\n\tApi.prototype.extendApi = function (group, name, action) {\n\t\tconst self = this;\n\t\tthis.request('extend-api', {\n\t\t\tgroup: group,\n\t\t\tname: name,\n\t\t\taction: (data) => {\n\t\t\t\tconst a = action(data.data);\n\t\t\t\tself.request(data.eventKey, {'data': a});\n\t\t\t}\n\t\t});\n\t};\n\n\t/**\n\t * Call the extended PluginAPI\n\t *\n\t * @param {String} group Group name for functionality to call\n\t * @param {String} name Name of the specific function to call\n\t * @param {Object} data Data object to pass as parameter to the api call\n\t * @param {Function} callback function(Object) Function to recieve the API response, parameter is the response from the API call\n\t */\n\tApi.prototype.callExtendedApi = function (group, name, data, callback) {\n\t\tthis.request('call-extended-api', {\n\t\t\tgroup: group,\n\t\t\tname: name,\n\t\t\tdata: data,\n\t\t\tcallback: callback\n\t\t});\n\t};\n\n\t/**\n\t * Gets logged in user\n\t *\n\t * @param {Function} callback function(Object)\n\t */\n\tApi.prototype.getCurrentUser = function (callback) {\n\t\tthis.request('get-current-user', null, callback);\n\t};\n\n\t/**\n\t * Get configuration information about the plugin\n\t *\n\t * @param {Function} callback function(Object)\n\t */\n\tApi.prototype.getConfiguration = function (callback) {\n\t\tthis.request('get-configuration', null, callback);\n\t};\n\n\t/**\n\t * Get DrPublish configuration\n\t *\n\t * @param {Function} callback function(Object)\n\t */\n\tApi.prototype.getDrPublishConfiguration = function (callback) {\n\t\tthis.request('get-drpublish-configuration', null, callback);\n\t};\n\n\t/**\n\t * Set configuration information about the plugin\n\t *\n\t * @param {Object} config The configuration object to save\n\t * @param {Object} options Object, can have three keys.\n\t * 'onlyPublication' (boolean) If true the configuration is set for the current publication only\n\t * 'success' (function) Called if the configuration was saved successfully\n\t * 'error' (function) Called if there was an error, recieves and error object as first parameter\n\t * @param {Function} callback function()\n\t */\n\tApi.prototype.setConfiguration = function (config, options, callback) {\n\t\t// support old function signature\n\t\tif (typeof options === 'boolean') {\n\t\t\toptions = {\n\t\t\t\tonlyPublication: options\n\t\t\t};\n\t\t} else if (typeof options !== 'object' || options === null) {\n\t\t\toptions = {};\n\t\t}\n\t\tconst data = {\n\t\t\tconfig: config,\n\t\t\tonlyPublication: typeof options.onlyPublication === 'boolean' ? options.onlyPublication : false,\n\t\t\tsuccess: typeof options.success === 'function' ? options.success : null,\n\t\t\terror: typeof options.error === 'function' ? options.error : null\n\t\t};\n\t\tthis.request('set-configuration', data, callback);\n\t};\n\n\t/**\n\t * Emits an event to DrPublish, and possibly other apps\n\t *\n\t * @param {String} name Name of the event\n\t * @param {String} data Data object to send with the event\n\t */\n\tApi.prototype.emit = function (name, data) {\n\t\tthis.request('emit-api-event', {\n\t\t\tname: name,\n\t\t\tdata: data\n\t\t});\n\t};\n\n\t/**\n\t * Listen for an event. If the callback returns false the event may cancel continued actions, e.g beforeSave can cancel article save. Look at documentation for Listeners to learn more.\n\t *\n\t * @param {String} name Name of the event\n\t * @param {Function} callback function(Object) Function to call when the event is triggered. Recieves one data object parameter of the form {source: , data: }\n\t */\n\tApi.prototype.on = function (name, callback) {\n\t\tconst self = this;\n\t\tself.eventListeners.add(name, callback);\n\t\tthis.request('on-api-event', {\n\t\t\tname: name\n\t\t});\n\t};\n\n\t/**\n\t * Increase the counter of actions required by the user, used to tell the user that the plugin requires input of some kind\n\t *\n\t * @param {Function} callback function(Object) function to call once the counter has been increased, returns the new counter value\n\t */\n\tApi.prototype.increaseRequiredActionCounter = function (callback) {\n\t\tthis.request('increase-required-action-counter', {}, callback);\n\t};\n\n\t/**\n\t * Decrease the counter of actions required by the user, used to tell the user that the plugin requires input of some kind\n\t *\n\t * @param {Function} callback function(Object) function to call once the counter has been decrease, returns current counter value\n\t */\n\tApi.prototype.decreaseRequiredActionCounter = function (callback) {\n\t\tthis.request('decrease-required-action-counter', {}, callback);\n\t};\n\n\t/**\n\t * Clear the counter of actions required by the user, used to tell the user that the plugin requires input of some kind\n\t *\n\t * @param {Function} callback function(Object) function to call once the counter has been cleared\n\t */\n\tApi.prototype.clearRequiredActionCounter = function (callback) {\n\t\tthis.request('clear-required-action-counter', {}, callback);\n\t};\n\n\t/**\n\t * Set the counter of actions required by the user, used to tell the user that the plugin requires input of some kind\n\t *\n\t * @param {Number} count The value to set the counter to\n\t * @param {Function} callback function(Object) function to call once the counter has been cleared\n\t */\n\tApi.prototype.setRequiredActionCounter = function (count, callback) {\n\t\tthis.request('set-required-action-counter', {count: count}, callback);\n\t};\n\n\t/**\n\t * Create a new instance of the Api class\n\t *\n\t * @private\n\t * @return {Object}\n\t */\n\tApi.prototype.create = function () {\n\t\treturn new Api();\n\t};\n\n\t/**\n\t * Create an embedded object of the given type\n\t *\n\t * @param {Number} typeId Type Id of the embedded object to create\n\t * @param {Function} callback function(embeddedObjectId) called once the object has been created, first parameter is the new embedded object id\n\t */\n\tApi.prototype.createEmbeddedObject = function (typeId, callback) {\n\t\tthis.request('create-embedded-object', {typeId: typeId, callback: callback});\n\t};\n\n\t/**\n\t * Get information about the available embedded object types\n\t *\n\t * @param {Function} callback function([Object]) recieves an array with objects describing the available embedded object types in the form of `{typeId: 'embedded object type id', cssClass: 'css class used to style the objects'}`\n\t */\n\tApi.prototype.getEmbeddedObjectTypes = function (callback) {\n\t\tthis.request('get-embedded-object-types', null, callback);\n\t};\n\n\t/**\n\t * Gives focus to another plugin\n\t *\n\t * @param {String} pluginName The name of the plugin to recieve focus\n\t * @param {Object} argument Optional option argument to pass along to the plugin recieving focus\n\t * @param {Boolean} start Flag to decide if the plugin should be started if it has not been loaded previously, default true\n\t * @return {Boolean}\n\t */\n\tApi.prototype.giveFocus = function (pluginName, argument, start) {\n\t\tif (typeof pluginName !== 'string') {\n\t\t\treturn false;\n\t\t}\n\t\tif (typeof start !== 'boolean') {\n\t\t\tstart = true;\n\t\t}\n\t\tthis.request('give-focus', {pluginName: pluginName, start: start, argument: argument});\n\t\treturn true;\n\t};\n\n\n\t/**\n\t * Hide the plugin, so it is no longer visible on the list of open plugins\n\t * @return {Boolean}\n\t */\n\tApi.prototype.hide = function () {\n\t\tthis.request('hide');\n\t\treturn true;\n\t};\n\n\t/**\n\t *

Creates a jQuery UI modal in the main editor window, detached from the plugin itself. Modals are unique on a\n\t * per-plugin basis, meaning that a plugin can only have a single modal at a time. Creating a new modal will\n\t * overwrite the previous.

\n\t *\n\t * See the official documentation for a list of available options.

\n\t *\n\t *

Note that you do not have direct access to the DOM of the modal. Use the provided helper methods to\n\t * manipulate or read from the modal:\n\t *

\n\t *

\n\t *\n\t * @example\n\t *\n\t * PluginAPI.createModal('

This is a modal

', {\n\t * buttons: {\n\t * Ok: function () {\n\t * alert('Ok!');\n\t * }\n\t * }\n\t * });\n\t *\n\t * PluginAPI.updateModal('

This is the same modal

');\n\t *\n\t * PluginAPI.createModal('

This is a brand new modal

', {\n\t * buttons: {\n\t * cancel: function() {\n\t * PluginAPI.closeModal(true);\n\t * }\n\t * }\n\t * });\n\t *\n\t * @param {String} content An HTML string\n\t * @param {Object} options A standard jQuery UI options object.\n\t * @return {Boolean}\n\t */\n\tApi.prototype.createModal = function (content, options) {\n\t\tthis.request('create-custom-modal', {content: content, options: options});\n\t\treturn true;\n\t};\n\n\t/**\n\t * Updates the HTML content of a live modal. Has no effect if the modal does not exist.\n\t *\n\t * @param {String} content An HTML string\n\t * @return {Boolean}\n\t */\n\tApi.prototype.updateModal = function (content) {\n\t\tthis.request('update-custom-modal', {content: content});\n\t\treturn true;\n\t};\n\n\t/**\n\t * Closes and optionally deletes the modal. Has no effect if the modal does not exists.\n\t *\n\t * @param {Boolean} destroy Whether or not to delete the modal\n\t * @return {Boolean}\n\t */\n\tApi.prototype.closeModal = function (destroy) {\n\t\tthis.request('close-custom-modal', {destroy: destroy});\n\t\treturn true;\n\t};\n\n\t/**\n\t * Returns the values of all input or select elements within a modal.\n\t *\n\t * The values are keyed by one of the following properties in order of priority: element ID, element name\n\t * or input type + index.\n\t *\n\t * @example\n\t * Given a modal with the following HTML content:\n\t *\n\t *
\n\t * \n\t * \n\t * \n\t *
\n\t *\n\t * getModalInputs would return:\n\t *\n\t * {\n\t * \"number-0\": {VALUE}\n\t * \"name\": {VALUE},\n\t * \"languages\": \"en\"\n\t * }\n\t *\n\t * @param {Function} callback\n\t */\n\tApi.prototype.getModalInputs = function (callback) {\n\t\tthis.request('get-custom-modal-inputs', null, callback);\n\t};\n\n\tApi.prototype.confirmAuthenticated = function () {\n\t\tthis.request('confirm-authenticated', {\n\t\t\tpluginName: this.appName\n\t\t});\n\t};\n\n\tApi.prototype.isStandAlone = function () {\n\t\treturn this.standAlone;\n\n\t};\n\n\t/**\n * Get the JWT as defined on DrPublish publication config. This token can be used to authenticate the request\n * @return {*|string}\n */\n\tApi.prototype.getJWT = function () {\n\t\treturn this.jwt;\n\t};\n\n\tApi.prototype.replaceEditorComponentsExtension = function (data) {\n\t\tthis.request('replace-editor-components-extension', data);\n\t};\n\n\tApi.prototype.clearEditorComponentsExtension = function (data) {\n\t\tthis.request('clear-editor-components-extension', data);\n\t};\n\n\tApi.prototype.highlightAnnotation = function (data) {\n\t\tthis.request('highlight-annotation', data);\n\t};\n\n\tApi.prototype.underemphasizeAnnotations = function (data) {\n\t\tthis.request('underemphasize-annotations', data);\n\t};\n\n\tApi.prototype.registerExternallyDefinedProperties = function (data) {\n\t\tthis.request('register-externally-defined-properties', data);\n\t};\n\n\treturn new Api();\n})();\n\nPluginAPI.Article = articleCommunicator(PluginAPI);\nPluginAPI.Editor = ah5Communicator(PluginAPI);\n\nmodule.exports = PluginAPI;\n","/**\n * @typedef {Object} selectedPluginElementData\n *\n * @property {String} id The DOM id of the selected element\n * @property {String} dpArticleId\n * @property {String} externalId\n * @property {Boolean} isDigitalAsset\n */\n\n/**\n * @param {Api} PluginAPI\n * @return {AH5Communicator}\n */\nmodule.exports = function (PluginAPI) {\n\n\t/** @type {selectedPluginElementData|null} */\n\tlet selectedPluginElement = null;\n\n\t/**\n\t * This will be used by editor apps to communicate with the editor\n\t *\n\t * Should be used like this:\n\t *\n\t * PluginAPI.Editor.insertString('string');\n\t *\n\t * @class\n\t * @classdesc Functions for talking with the AH5 editor. Accessed through PluginAPI.Editor\n\t * @exports PluginAPI/Editor\n\t */\n\t/* eslint max-statements: [\"error\", 50, { \"ignoreTopLevelFunctions\": true }]*/\n\tconst AH5Communicator = function () {\n\t\tthis.DEBUG = false;\n\t\tPluginAPI.on('pluginElementClicked', pluginElementSelected);\n\t\tPluginAPI.on('pluginElementDeselected', pluginElementDeselected);\n\n\t\t/**\n\t\t * @param {selectedPluginElementData} elementData\n\t\t */\n\t\tfunction pluginElementSelected(elementData) {\n\t\t\tselectedPluginElement = elementData;\n\t\t}\n\n\t\tfunction pluginElementDeselected() {\n\t\t\tselectedPluginElement = null;\n\t\t}\n\t};\n\n\t/**\n\t * Get name of current active editor\n\t *\n\t * @param {Function} callback function(String)\n\t */\n\tAH5Communicator.prototype.getActiveEditor = function (callback) {\n\t\tPluginAPI.request('get-active-editor', null, callback);\n\t};\n\n\t/**\n\t * Registers/Modifies a context menu items for a plugin element\n\t * The object send should have the following structure\n\t *\n\t * @param {Object} action The action object\n\t * @param {Function} callback function()\n\t *\n\t * @example\n\t * PluginAPI.Editor.registerMenuAction({\n\t *\t label: 'label in the menu',\n\t *\t icon: '[Optional] url to possible icon image',\n\t *\t trigger: '[Optional] css selector, only show menu element when this matches the element',\n\t *\t callback: function(id, clickedElementId) {\n\t *\t\t // callback function\n\t *\t\t // first parameter is id of the plugin element\n\t *\t\t // second paramter is id of closest element to the trigger element that has an id\n\t *\t\t //\t in code: $(event.triggerElement).closest('[id]').attr('id');\n\t *\t }\n\t * })\n\t */\n\tAH5Communicator.prototype.registerMenuAction = function (action, callback) {\n\t\tPluginAPI.request('register-menu-action', action, callback);\n\t};\n\n\t/**\n\t * Adds a mouseover action to plugin elements\n\t *\n\t * @param {function} action to perform\n\t * @param {function} callback function(String)\n\t */\n\tAH5Communicator.prototype.registerHoverAction = function (action, callback) {\n\t\tPluginAPI.request('register-hover-action', action, callback);\n\t};\n\n\t/**\n\t * Gets the selected plugin element from the editor\n\t *\n\t * @param {function} callback function(String)\n\t */\n\tAH5Communicator.prototype.getSelectedPluginElement = function (callback) {\n\t\tPluginAPI.request('get-selected-plugin-element', {}, callback);\n\t};\n\n\t/**\n\t * Deselect all plugin elements in editor\n\t *\n\t * @param {function} callback function(String)\n\t */\n\tAH5Communicator.prototype.deSelectPluginElements = function (callback) {\n\t\tPluginAPI.request('de-select-plugin-elements', {}, callback);\n\t};\n\n\t/**\n\t * Swap positions between the provided element and the adjacent one\n\t * in the specified direction\n\t * PluginAPI.Editor.directionalCastle({\n\t * elementId: 'the provided element id',\n\t * direction: 'forward/backward'\n\t * })\n\t * @param {String} elementId DOM element id\n\t * @param {String} direction Direction\n\t * @param {function} callback\n\t * */\n\tAH5Communicator.prototype.directionalCastle = function (elementId, direction, callback) {\n\t\tPluginAPI.request('editor-directional-castle', {\n\t\t\telementId: elementId,\n\t\t\tdirection: direction\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Registers/Modifies a group of items to in the context menu\n\t * The object send should have the following structure\n\t *\n\t * @example\n\t * PluginAPI.Editor.registerMenuActionGroup({\n\t *\t label: 'label for the group in the menu',\n\t *\t icon: '[Optional] url to possible icon image',\n\t *\t actions: [\n\t *\t\t {\n\t *\t\t\t label: 'label for the action #1',\n\t *\t\t\t callback: function(id, clickedElementId) {\n\t *\t\t\t\t // same as for registerMenuAction\n\t *\t\t\t }\n\t *\t\t },\n\t *\t\t {\n\t *\t\t\t label: 'label for the action #2',\n\t *\t\t\t callback: function(id, clickedElementId) {\n\t *\t\t\t\t // same as for registerMenuAction\n\t *\t\t\t }\n\t *\t\t }\n\t *\t ]\n\t * })\n\t *\n\t * @param {Object} group The action object\n\t * @param {function} callback function()\n\t */\n\tAH5Communicator.prototype.registerMenuActionGroup = function (group, callback) {\n\t\tPluginAPI.request('register-menu-action-group', group, callback);\n\t};\n\n\t/**\n\t * Retrieves the type of editor that currently has focus\n\t *\n\t * @param {function} callback function(String)\n\t */\n\tAH5Communicator.prototype.getEditorType = function (callback) {\n\t\tPluginAPI.request('editor-get-type', null, callback);\n\t};\n\n\t/**\n\t * Replace an element in the article\n\t *\n\t * @param {String} id Id of the element\n\t * @param {String} element The new element\n\t * @param {function} callback function(Boolean), called after replacement is done\n\t */\n\tAH5Communicator.prototype.replaceElementById = function (id, element, callback) {\n\t\tPluginAPI.request('editor-element-replace-byid', {\n\t\t\tid: id,\n\t\t\telement: element\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Replace a plugin element in the article\n\t *\n\t * @param {String} id Id of the element\n\t * @param {String} element The new element\n\t * @param {function} callback function(Boolean), called after replacement is done\n\t */\n\tAH5Communicator.prototype.replacePluginElementById = function (id, element, callback) {\n\t\tPluginAPI.request('editor-element-replace-plugin-element-byid', {\n\t\t\tid: id,\n\t\t\telement: element\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Set the content of an element in the article\n\t *\n\t * @param {String} id Id of the element\n\t * @param {String} content The new content\n\t * @param {function} callback function(Boolean), called when done\n\t */\n\tAH5Communicator.prototype.setElementContentById = function (id, content, callback) {\n\t\tPluginAPI.request('editor-element-set-byid', {\n\t\t\tid: id,\n\t\t\telement: content\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Delete an element in the article\n\t *\n\t * @param {String} id Id of the element\n\t * @param {function} callback function(Boolean), called after deletion is done\n\t */\n\tAH5Communicator.prototype.deleteElementById = function (id, callback) {\n\t\tPluginAPI.request('editor-element-delete-byid', {\n\t\t\tid: id\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Get HTML code of an element\n\t *\n\t * @param {String} id The element id\n\t * @param {function} callback function(String), html content of the element\n\t */\n\tAH5Communicator.prototype.getHTMLById = function (id, callback) {\n\t\tPluginAPI.request('editor-element-get-byid', {\n\t\t\tid: id\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Get HTML code of all elements that match the selector\n\t *\n\t * @param {String} selector The CSS selector\n\t * @param {function} callback function([String]), html content of matching elements\n\t */\n\tAH5Communicator.prototype.getHTMLBySelector = function (selector, callback) {\n\t\tPluginAPI.request('editor-elements-get-byselector', {\n\t\t\tselector: selector\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Get all categories\n\t *\n\t * @param {Function} callback function([Object Category]), list of Category objects with id, name and pid\n\t */\n\tAH5Communicator.prototype.getCategories = function (callback) {\n\t\tPluginAPI.request('get-categories', null, callback);\n\t};\n\n\t/**\n\t * Returns all the parent categories of the given category\n\t *\n\t * @param {Object} category The category to find parents of\n\t * @param {Function} callback function([Object Category]), array of parent Category objects\n\t */\n\tAH5Communicator.prototype.getParentCategories = function (category, callback) {\n\t\tPluginAPI.request('get-parent-categories', category, callback);\n\t};\n\n\t/**\n\t * Returns all the parent elements that match the selector\n\t *\n\t * @param {String} id Id of element to find parents of\n\t * @param {String} selector Selector to filter parent elements with\n\t * @param {Function} callback function([String]), array of ids\n\t */\n\tAH5Communicator.prototype.getParentIds = function (id, selector, callback) {\n\t\tPluginAPI.request('get-parent-ids', {\n\t\t\tid: id,\n\t\t\tselector: selector\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Retrieve information about all tagtypes\n\t *\n\t * @param {Function} callback function([Object Tagtype]), array of tagtypes with id, name and config object\n\t */\n\tAH5Communicator.prototype.getTagTypes = function (callback) {\n\t\tPluginAPI.request('get-tag-types', null, callback);\n\t};\n\n\t/**\n\t * Get information about the given tagtype\n\t *\n\t * @param {String} id The element id\n\t * @param {Function} callback function(Object Tagtype), tagtype object with id, name and config object\n\t */\n\tAH5Communicator.prototype.getTagType = function (id, callback) {\n\t\tPluginAPI.request('get-tag-type', {\n\t\t\tid: id\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Clears the editor contents\n\t *\n\t * @param {Function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.clear = function (callback) {\n\t\tPluginAPI.request('editor-clear', null, callback);\n\t};\n\n\t/**\n\t * Insert a string into the editor\n\t *\n\t * @param {String} string The string that should be inserted\n\t * @param {Function} callback function(String), id of the newly inserted element if it has one\n\t */\n\tAH5Communicator.prototype.insertString = function (string, callback) {\n\t\tPluginAPI.request('editor-insert-string', {\n\t\t\tstring: string\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Insert an element into the editor\n\t *\n\t * Note that the HTML of the element is what will be transferred, and nothing else!\n\t * The element will be given the class dp-plugin-element, and given a unique ID (if none is present)\n\t *\n\t * @param {Element} element The element that should be inserted\n\t * @param {Object | Function} options (can be omitted) Options object, supports option 'select' - set to true to automatically select the inserted element\n\t * @param {Function} [callback] function(String), id of the newly inserted element\n\t */\n\tAH5Communicator.prototype.insertElement = function (element, options, callback) {\n\t\tlet select = false;\n\t\tif (typeof options === 'object') {\n\t\t\toptions = options || {};\n\t\t\tselect = typeof options.select === 'boolean' ? options.select : false;\n\t\t} else if (typeof callback === 'undefined' && typeof options === 'function') {\n\t\t\tcallback = options;\n\t\t}\n\t\tPluginAPI.request('editor-insert-element', {\n\t\t\telement: element.outerHTML,\n\t\t\tselect: select,\n\t\t\toptions: options\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Remove classes from the element an element in the article\n\t *\n\t * @param {String} id Id of the element\n\t * @param {Array} classes Array of class names\n\t * @param {function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.removeClasses = function (id, classes, callback) {\n\t\tPluginAPI.request('editor-classes-remove', {\n\t\t\tid: id,\n\t\t\tclasses: classes\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Add new classes to an element\n\t *\n\t * @param {String} id Id of the element\n\t * @param {Array} classes Array of class names\n\t * @param {function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.addClasses = function (id, classes, callback) {\n\t\tPluginAPI.request('editor-classes-add', {\n\t\t\tid: id,\n\t\t\tclasses: classes\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Get data-attribute of the element\n\t *\n\t * @param {String} id Id of the element\n\t * @param {String} attribute attribute name\n\t * @param {function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.getDataAttribute = function (id, attribute, callback) {\n\t\tPluginAPI.request('editor-attribute-get', {\n\t\t\tid: id,\n\t\t\tattribute: 'data-' + attribute\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Update data-attribute of the element\n\t *\n\t * @param {String} id Id of the element\n\t * @param {String} attribute attribute name\n\t * @param {String} value attribute value\n\t * @param {function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.updateDataAttribute = function (id, attribute, value, callback) {\n\t\tPluginAPI.request('editor-attribute-update', {\n\t\t\tid: id,\n\t\t\tattribute: 'data-' + attribute,\n\t\t\tvalue: value\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Mark an element as currently selected (green border with default styling)\n\t *\n\t * @param {String} id Id of the element\n\t * @param {function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.markAsActive = function (id, callback) {\n\t\tPluginAPI.request('editor-mark-as-active', {\n\t\t\tid: id\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Sets the attribute of the element with the given ID to value\n\t *\n\t * @param {String} id The ID of the element to set the attribute on\n\t * @param {String} attribute The attribute to set\n\t * @param {String} value What to set the attribute to\n\t * @param {Function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.setAttributeById = function (id, attribute, value, callback) {\n\t\tPluginAPI.request('editor-element-attribute-set-byid', {\n\t\t\tid: id,\n\t\t\tattribute: attribute,\n\t\t\tvalue: value\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Sets a style of the element with the given ID to value\n\t *\n\t * @param {String} id The ID of the element to set the attribute on\n\t * @param {String} attribute The style attribute to set\n\t * @param {String} value What to set the attribute to\n\t * @param {Function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.setStyleById = function (id, attribute, value, callback) {\n\t\tPluginAPI.request('editor-element-style-set-byid', {\n\t\t\tid: id,\n\t\t\tattribute: attribute,\n\t\t\tvalue: value\n\t\t}, callback);\n\t};\n\n\n\t/**\n\t * Initialize pre registered menus\n\t *\n\t * Available options are: simplePluginMenu, editContext, deleteButton, floatButtons\n\t *\n\t * @param {Array} menus Array of menu names\n\t * @param {Function} callback function(Boolean)\n\t */\n\tAH5Communicator.prototype.initMenu = function (menus, callback) {\n\t\tPluginAPI.request('editor-initialize-menu', {\n\t\t\tmenus: menus\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Opens the plugin editor for a given element.\n\t *\n\t * @param {String} id Plugin element ID\n\t */\n\tAH5Communicator.prototype.openPluginElementEditor = function (id) {\n\t\tPluginAPI.request('open-element-editor', {\n\t\t\tid: id\n\t\t});\n\t};\n\n\t/**\n\t * Returns the total number of words in the currently open article.\n\t *\n\t * @param {Function} callback Receives the total word count as its single parameter\n\t */\n\tAH5Communicator.prototype.getTotalWordCount = function (callback) {\n\t\tPluginAPI.request('total-word-count', null, callback);\n\t};\n\n\t/**\n\t * Returns the total number of characters in the currently open article.\n\t *\n\t * @param {Function} callback Receives the total character count as its single parameter\n\t */\n\tAH5Communicator.prototype.getTotalCharCount = function (callback) {\n\t\tPluginAPI.request('total-char-count', null, callback);\n\t};\n\n\t/**\n\t * Update one data option of the referenced embedded asset\n\t *\n\t * @param {Number} dpArticleId DrPublish's embedded asset id\n\t * @param {String} key Name of the property\n\t * @param {String} value Value of the property\n\t * @param {Function} callback Receives the total character count as its single parameter\n\t */\n\tAH5Communicator.prototype.updateAssetOption = function (dpArticleId, key, value, callback) {\n\t\tPluginAPI.request('update-asset-option', {dpArticleId: dpArticleId, key: key, value: value}, callback);\n\t};\n\n\t/**\n\t * Update all asset data of the referenced embedded asset\n\t *\n\t * @param {Object} data Updated data\n\t * @param {Function} callback Receives the total character count as its single parameter\n\t *\n\t * @example\n\t * var data = {\n\t * internalId: assetDpArticleId,\n\t * assetElementId: activeAssetId,\n\t * assetType: 'picture',\n\t * assetSource: PluginAPI.getPluginName(),\n\t * resourceUri: fullsizeUrl,\n\t * previewUri: fullsizeUrl,\n\t * renditions: {\n\t * highRes: {uri: fullsizeUrl},\n\t * thumbnail: {uri: thumbnailUrl}\n\t * },\n\t * options: {}\n\t * }\n\t * PluginAPI.Editor.updateAssetData(data);\n\t */\n\tAH5Communicator.prototype.updateAssetData = function (data, callback) {\n\t\tPluginAPI.request('update-asset-media', data, callback);\n\t};\n\n\t/**\n\t * Get all data option of the referenced embedded asset\n\t *\n\t * @param {Number} dpArticleId DrPublish's embedded asset id\n\t * @param {Function} callback Receives the total character count as its single parameter\n\t */\n\tAH5Communicator.prototype.getAssetData = function (dpArticleId, callback) {\n\t\tPluginAPI.request('get-asset-data', {data: dpArticleId}, callback);\n\t};\n\n\t/**\n\t * Insert an embedded asset inside of an existing one\n\t *\n\t * @param {Number} parentElementId DOM element id of the receiving asset\n\t * @param {String} markup HTML to inject\n\t * @param {Object} data Asset data\n\t * @param {Function} callback Receives the total character count as its single parameter\n\t *\n\t * @example\n\t * var title = response.data.title ? response.data.title : '';\n\t * var caption = response.data.description ? response.data.description : '';\n\t * var credit = response.data.byline ? response.data.byline : '';\n\t * var source = response.data.source ? response.data.source : '';\n\t * var markup = '
';\n\t * markup += '
' + title + '
...';\n\t * var options = response.data.options ? response.data.options : {};\n\t * var callback = function () {\n\t * // do something here\n\t * };\n\t * var rends = renditions || {};\n\t * rends.highRes = {uri: fullsizeUrl};\n\t * rends.preview = {uri: fullsizeUrl};\n\t * var drpdata = {\n\t * embeddedTypeId: 5,\n\t * isMultiple: true,\n\t * assetType: 'picture',\n\t * externalId: id,\n\t * assetClass: 'dp-picture',\n\t * assetSource: 'images',\n\t * resourceUri: fullsizeUrl,\n\t * previewUri: fullsizeUrl,\n\t * renditions: rends,\n\t * options: options\n\t * };\n\t * var insertNested = function () {\n\t * PluginAPI.Editor.insertNestedAsset(\n\t * selectedSlideshowAsset.id,\n\t * markup,\n\t * drpdata\n\t * };\n\t * PluginAPI.Editor.getSelectedPluginElement(insertNested);\n\t */\n\tAH5Communicator.prototype.insertNestedAsset = function (parentElementId, markup, data, callback) {\n\t\tconst self = this;\n\t\tPluginAPI.createEmbeddedObject(\n\t\t\tdata.embeddedTypeId,\n\t\t\t(dpArticleId) => {\n\t\t\t\tinsert(dpArticleId, parentElementId, (data) => {\n\t\t\t\t\treturn updateEmbeddedAssetRequest(callback);\n\t\t\t\t});\n\t\t\t}\n\t\t);\n\n\t\tfunction insert(dpArticleId, parentElementId, callback) {\n\t\t\tdata.internalId = dpArticleId;\n\t\t\tconst elementId = 'asset-' + dpArticleId;\n\t\t\tconst $element = $('
');\n\t\t\t$element.attr('id', elementId);\n\t\t\t$element.attr('data-internal-id', dpArticleId);\n\t\t\t$element.attr('data-ah5-type', data.assetSource);\n\t\t\tif (data.externalId) {\n\t\t\t\t$element.attr('data-external-id', data.externalId);\n\t\t\t}\n\t\t\tif (data.dpDigitalAssetId) {\n\t\t\t\t$element.attr('data-dp-digital-asset-id', data.dpDigitalAssetId);\n\t\t\t}\n\t\t\tif (data.assetClass) {\n\t\t\t\t$element.addClass(data.assetClass);\n\t\t\t}\n\t\t\t$element.addClass('dp-plugin-element');\n\t\t\t$element.html(markup);\n\t\t\tPluginAPI.Editor.getHTMLById(parentElementId, (html) => {\n\t\t\t\tlet d = document.createElement('div');\n\t\t\t\td.innerHTML = html;\n\t\t\t\td.firstChild.setAttribute('id', parentElementId + 'tmp');\n\t\t\t\tself.replacePluginElementById(parentElementId, d.innerHTML, () => {\n\t\t\t\t\td = document.createElement('div');\n\t\t\t\t\td.innerHTML = html;\n\t\t\t\t\tconst assetContainer = d.querySelector('.dp-fact-box-image, .dp-nested-asset-container');\n\t\t\t\t\tif (data.isMultiple) {\n\t\t\t\t\t\t$(assetContainer).append($element.get(0).outerHTML);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tassetContainer.innerHTML = $element.get(0).outerHTML;\n\t\t\t\t\t}\n\t\t\t\t\tself.replacePluginElementById(parentElementId + 'tmp', d.innerHTML, callback);\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\tfunction updateEmbeddedAssetRequest(callback) {\n\t\t\tPluginAPI.request('update-embedded-asset', data, callback);\n\t\t}\n\t};\n\n\t/**\n\t * Insert an embedded asset\n\t *\n\t * @param {String} markup HTML to inject\n\t * @param {Object} data Asset data\n\t * @param {Function} callback Receives the total character count as its single parameter\n\t *\n\t * @example\n\t * var title = response.data.title ? response.data.title : '';\n\t * var caption = response.data.description ? response.data.description : '';\n\t * var credit = response.data.byline ? response.data.byline : '';\n\t * var source = response.data.source ? response.data.source : '';\n\t * var markup = '
';\n\t * markup += '
' + title + '
';\n\t * markup += '
' + caption + '
...';\n\t * var options = response.data.options ? response.data.options : {};\n\t * var callback = function () {\n\t * // do something here\n\t * };\n\t * var rends = renditions || {};\n\t * rends.highRes = {uri: fullsizeUrl};\n\t * rends.preview = {uri: fullsizeUrl};\n\t * var drpdata = {\n\t * embeddedTypeId: 5,\n\t * isMultiple: true,\n\t * assetType: 'picture',\n\t * externalId: id,\n\t * assetClass: 'dp-picture',\n\t * assetSource: 'images',\n\t * resourceUri: fullsizeUrl,\n\t * previewUri: fullsizeUrl,\n\t * renditions: rends,\n\t * options: options\n\t * };\n\t * PluginAPI.Editor.insertEmbeddedAsset(markup, drpdata, callback);\n\t */\n\tAH5Communicator.prototype.insertEmbeddedAsset = function (markup, data, callback) {\n\t\tconst self = this;\n\t\tlet updateContent = false;\n\t\tif (selectedPluginElement) {\n\t\t\tif (data.assetSource !== PluginAPI.getAppName()) {\n\t\t\t\tPluginAPI.showErrorMsg('Can\\'t update selected plugin element since it doesn\\'t belong to the \\'' + PluginAPI.getAppName() + '\\' plugin');\n\t\t\t\treturn;\n\t\t\t} else {\n\t\t\t\tupdateContent = true;\n\t\t\t}\n\t\t}\n\n\t\tif (selectedPluginElement) {\n\t\t\tconst dpArticleId = selectedPluginElement.dpArticleId;\n\t\t\tif (!dpArticleId) {\n\t\t\t\tthrow Error('Selected plugin element: expected dpArticleId not found (tried reading from attribute \\'data-internal-id\\')');\n\t\t\t}\n\t\t\tinsert(dpArticleId, (data) => {\n\t\t\t\treturn updateEmbeddedAssetRequest(typeof callback === 'function' ? callback(data) : null);\n\t\t\t});\n\t\t} else {\n\t\t\tPluginAPI.createEmbeddedObject(\n\t\t\t\tdata.embeddedTypeId,\n\t\t\t\t(dpArticleId) => {\n\t\t\t\t\tinsert(dpArticleId, (data) => {\n\t\t\t\t\t\treturn addEmbeddedAssetRequest(typeof callback === 'function' ? callback(data) : null);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tfunction insert(dpArticleId, callback) {\n\t\t\tdata.internalId = dpArticleId;\n\t\t\tconst elementId = 'asset-' + dpArticleId;\n\t\t\tconst element = document.createElement('div');\n\t\t\telement.id = elementId;\n\t\t\telement.dataset.internalId = dpArticleId;\n\t\t\tif (data.externalId) {\n\t\t\t\telement.dataset.externalId = data.externalId;\n\t\t\t}\n\t\t\tif (data.dpDigitalAssetId) {\n\t\t\t\telement.dataset.dpDigitalAssetId = data.dpDigitalAssetId;\n\t\t\t}\n\t\t\tif (data.assetClass) {\n\t\t\t\telement.classList.add(data.assetClass);\n\t\t\t}\n\t\t\telement.innerHTML = markup;\n\t\t\tif (!updateContent) {\n\t\t\t\tdata.select = true;\n\t\t\t\tself.insertElement(element, data);\n\t\t\t} else {\n\t\t\t\tself.setElementContentById(elementId, element.innerHTML, null);\n\t\t\t}\n\t\t\tif (typeof callback === 'function') {\n\t\t\t\treturn callback();\n\t\t\t}\n\t\t}\n\n\t\tfunction addEmbeddedAssetRequest(callback) {\n\t\t\tPluginAPI.request('add-embedded-asset', data, callback);\n\t\t}\n\n\t\tfunction updateEmbeddedAssetRequest(callback) {\n\t\t\tPluginAPI.request('update-embedded-asset', data, callback);\n\t\t}\n\t};\n\n\t/**\n\t * Returns the total number of characters in the currently open article.\n\t *\n\t * @param {Function} callback Receives the total character count as its single parameter\n\t */\n\tAH5Communicator.prototype.getCurrentSelectionAbsolutePosition = function (callback) {\n\t\tPluginAPI.request('current-selection-absolute-position', null, callback);\n\t};\n\n\t/**\n\t * Wraps the current selection in a span\n\t *\n\t * @param {String} className the name of the class to apply\n\t * @param {Object} attributes to apply to the wrapper\n\t * @param {Function} callback\n\t */\n\tAH5Communicator.prototype.wrapSelection = function (className, attributes, callback) {\n\t\tPluginAPI.request('wrap-selection', {className: className, attributes: attributes}, callback);\n\t};\n\n\t/**\n\t * Removes the selected element, leaving all children in place\n\t *\n\t * @param {String} selector the selector for finding the elements to be removed\n\t * @param {Function} callback\n\t */\n\tAH5Communicator.prototype.removeInPlace = function (selector, callback) {\n\t\tPluginAPI.request('remove-in-place', {selector: selector}, callback);\n\t};\n\n\t/**\n\t * Triggers an event on all elements matching the selector\n\t *\n\t * @param {String} selector the selector for finding the elements\n\t * @param {String} event the event to trigger on the found elements\n\t * @param {Function} callback\n\t */\n\tAH5Communicator.prototype.triggerEvent = function (selector, event, callback) {\n\t\tPluginAPI.request('trigger-event', {selector: selector, event: event}, callback);\n\t};\n\n\t/**\n\t * Get ordered list of element IDs, for selector\n\t *\n\t * @param {String} selector the selector for finding the elements\n\t * @param {Function} callback Receives an ordered array of element IDs\n\t */\n\tAH5Communicator.prototype.getOrderedIDs = function (selector, callback) {\n\t\tPluginAPI.request('get-ordered-ids', {selector: selector}, callback);\n\t};\n\n\treturn new AH5Communicator();\n};\n","/* eslint max-statements: [\"error\", 100000000] */\n/* eslint complexity: [\"error\", 100000000] */\nmodule.exports = function (PluginAPI) {\n\n\t/**\n * This class is used for communicating with the article, typically setting and getting values of metadata or in the article content itself.\n *\n * @class\n * @classdesc Functions for talking with the DrPublish article object. Accessed through PluginAPI.Article\n * @exports PluginAPI/Article\n */\n\tconst ArticleCommunicator = function () {\n\t\tthis.DEBUG = false;\n\t};\n\n\t/**\n * Give focus to yourself\n *\n * @param {Function} callback function(Boolean), called as the plugin gets focus\n */\n\tArticleCommunicator.prototype.focusPlugin = function (callback) {\n\t\tPluginAPI.request('app-focus', {}, callback);\n\t};\n\n\t/**\n * Give focus to yourself\n * @deprecated use focusPlugin instead\n * @param {Function} callback function(Boolean), called after plugin is started\n */\n\tArticleCommunicator.prototype.focusApp = function (callback) {\n\t\tthis.focusPlugin(callback);\n\t};\n\n\t/**\n * Start the given plugin\n *\n * @param {String} name Name of the plugin as defined on publication settings\n * @param {Object} options Options for initializing the plugin\n * @param {Function} callback function(Boolean), called after plugin is started\n */\n\tArticleCommunicator.prototype.startPlugin = function (name, options, callback) {\n\t\tPluginAPI.request('app-start', {\n\t\t\tapp: name,\n\t\t\toption: options\n\t\t}, callback);\n\t};\n\n\t/**\n * @deprecated use startPlugin instead\n * @param {String} name Name of the plugin as defined on publication settings\n * @param {Object} options Options for initializing the plugin\n * @param {Function} callback function(Boolean), called after plugin is started\n */\n\tArticleCommunicator.prototype.startApp = function (name, options, callback) {\n\t\tthis.startPlugin(name, options, callback);\n\t};\n\n\t/**\n * Stop the given plugin\n *\n * @param {String} name Name of the plugin, as defined on publication config\n */\n\tArticleCommunicator.prototype.stopPlugin = function (name) {\n\t\tPluginAPI.request('app-stop', {\n\t\t\tapp: name\n\t\t});\n\t};\n\n\t/**\n * @deprecated use stopPlugin instead\n * @param {String} name Name of the plugin, as defined on publication config\n */\n\tArticleCommunicator.prototype.stopApp = function (name) {\n\t\tthis.stopPlugin(name);\n\t};\n\n\t/**\n * Get the id of the article currently edited\n *\n * @param {Function} callback function(Int), id of the current article\n */\n\tArticleCommunicator.prototype.getId = function (callback) {\n\t\tPluginAPI.request('article-id-get', null, callback);\n\t};\n\n\t/**\n * Get the guid of the article package currently edited\n *\n * @param {Function} callback function(Int), id of the current article\n */\n\tArticleCommunicator.prototype.getPackageId = function (callback) {\n\t\tPluginAPI.request('package-id-get', null, callback);\n\t};\n\n\t/**\n * Get the guid of the article package currently edited\n *\n * @param {Function} callback function(Int), id of the current article\n */\n\tArticleCommunicator.prototype.getPackageGuid = function (callback) {\n\t\tPluginAPI.request('package-guid-get', null, callback);\n\t};\n\n\t/**\n * Clear the meta information summary\n *\n * @param {Function} callback function(Boolean), called when meta data has been cleared\n */\n\tArticleCommunicator.prototype.clearMetaInfo = function (callback) {\n\t\tPluginAPI.request('article-metainfo-clear', null, callback);\n\t};\n\n\t/**\n * Get tags used in the article\n *\n * @param {Function} callback function([Object Tag]), array with tags connected to an article\n */\n\tArticleCommunicator.prototype.getTags = function (callback) {\n\t\tPluginAPI.request('article-tags-get', null, callback);\n\t};\n\n\t/**\n * Retrieve custom meta value for the article\n *\n * @param {String} name Name of the custom meta value\n * @param {Function} callback function(Object), the parameter is an object containing the given custom meta value\n */\n\tArticleCommunicator.prototype.getCustomMeta = function (name, callback) {\n\t\tPluginAPI.request('article-custom-meta-get', {\n\t\t\tname: name\n\t\t}, callback);\n\t};\n\n\t/**\n * Set custom meta value for the article\n *\n * @param {String} name Name of the meta value\n * @param {Object} value Value to set\n * @param {Function} callback function()\n */\n\tArticleCommunicator.prototype.setCustomMeta = function (name, value, callback) {\n\t\tPluginAPI.request('article-custom-meta-set', {\n\t\t\tname: name,\n\t\t\tvalue: value\n\t\t}, callback);\n\t};\n\n\t/**\n * Marks article model as having meta data changes\n *\n * @param {Function} callback function()\n */\n\tArticleCommunicator.prototype.setMetaChanged = function (callback) {\n\t\tPluginAPI.request('article-meta-changed', null, callback);\n\t};\n\n\t/**\n * Set tags for the article\n *\n * @param {Array} tags List of tags that should be set\n * @param {Boolean} save Set to true to force save once the tags are updated\n * @param {Function} callback function(Boolean), called when tags have been set\n */\n\tArticleCommunicator.prototype.setTags = function (tags, save, callback) {\n\t\tPluginAPI.request('article-tags-set', {\n\t\t\tsave: save,\n\t\t\ttags: tags\n\t\t}, callback);\n\t};\n\n\t/**\n * Add tag for the article\n *\n * @param {Array} tags Tags to be added\n * @param {Function} errorFunction called if error\n * @param {Function} callback function(Boolean), called when tag has been set\n */\n\tArticleCommunicator.prototype.addTags = function (tags, errorFunction, callback) {\n\t\tPluginAPI.request('article-tags-add', {\n\t\t\ttags: tags,\n\t\t\tonError: errorFunction\n\t\t}, callback);\n\t};\n\n\t/**\n * Add tag for the article\n *\n * @param {String} tag Tag to be added\n * @param {Function} errorFunction called if error\n * @param {Function} callback function(Boolean), called when tag has been set\n */\n\tArticleCommunicator.prototype.addTag = function (tag, errorFunction, callback) {\n\t\tPluginAPI.request('article-tags-add', {\n\t\t\ttags: [tag],\n\t\t\tonError: errorFunction\n\t\t}, callback);\n\t};\n\n\t/**\n * Add tags for the article\n *\n * @param {String} tags Tags to be added\n * @param {Function} errorFunction called if error\n * @param {Function} callback function(Boolean), called when tag has been set\n */\n\tArticleCommunicator.prototype.addTags = function (tags, errorFunction, callback) {\n\t\tPluginAPI.request('article-tags-add', {\n\t\t\ttags: tags,\n\t\t\tonError: errorFunction\n\t\t}, callback);\n\t};\n\n\t/**\n * Remove tag from article\n *\n * @param {String} tag Tag to remove\n * @param {Function} callback function(Boolean), called when tag has been removed\n */\n\tArticleCommunicator.prototype.removeTag = function (tag, callback) {\n\t\tPluginAPI.request('article-tags-remove', {\n\t\t\ttag: tag\n\t\t}, callback);\n\t};\n\n\t/**\n * Get the selected categories\n *\n * @param {Function} callback function([String]), array with category ids\n */\n\tArticleCommunicator.prototype.getSelectedCategories = function (callback) {\n\t\tPluginAPI.request('article-categories-selected-get', null, callback);\n\t};\n\n\t/**\n * Save the currently selected categories\n *\n * @param {Function} callback function(Boolean), called when categories has been saved\n */\n\tArticleCommunicator.prototype.saveCategories = function (callback) {\n\t\tthis.getSelectedCategories(function (categories) {\n\t\t\tthis.setCategories(categories, callback);\n\t\t});\n\t};\n\n\t/**\n * Set selected categories\n *\n * @param {Array} categories List of category IDs that should be set\n * @param {Function} callback function(Boolean), called when categories have been set\n */\n\tArticleCommunicator.prototype.setCategories = function (categories, callback) {\n\t\tPluginAPI.request('article-categories-selected-set', {\n\t\t\tcategories: categories\n\t\t}, callback);\n\t};\n\n\t/**\n * Add the given categories to the list of categories\n *\n * @param {Array} categories List of category IDs to add\n * @param {Function} callback function(Boolean), called when the categories have been set\n */\n\tArticleCommunicator.prototype.addCategories = function (categories, callback) {\n\n\t\tPluginAPI.request('article-categories-add', {\n\t\t\tcategories: categories\n\t\t}, callback);\n\t};\n\n\t/**\n * Remove the given categories from the list of categories\n *\n * @param {Array} categories List of category IDs to remove\n * @param {Function} callback function(Boolean), called when the categories have been removed\n */\n\tArticleCommunicator.prototype.removeCategories = function (categories, callback) {\n\t\tPluginAPI.request('article-categories-remove', {\n\t\t\tcategories: categories\n\t\t}, callback);\n\t};\n\n\t/**\n * Set the main category of the current article\n *\n * @param {Number} category The ID of the category to set as the main category\n * @param {Function} callback function(Boolean), called when the main category has been set\n */\n\tArticleCommunicator.prototype.setMainCategory = function (category, callback) {\n\t\tPluginAPI.request('article-categories-main-set', {\n\t\t\tcategory: category\n\t\t}, callback);\n\t};\n\n\t/**\n * Get the source set for the article\n *\n * @param {Function} callback function(String), name of the source\n */\n\tArticleCommunicator.prototype.getSource = function (callback) {\n\n\t\tPluginAPI.request('article-source-get', null, callback);\n\t};\n\n\t/**\n * Set the source for the article\n *\n * @param {String} value The new value to be set as source\n * @param {Function} callback function(Boolean), called when the source has been set\n */\n\tArticleCommunicator.prototype.setSource = function (value, callback) {\n\t\tPluginAPI.request('article-source-set', {\n\t\t\tsource: value\n\t\t}, callback);\n\t};\n\n\t/**\n * Get the status for the article\n *\n * @param {Function} callback function(String), current status\n */\n\tArticleCommunicator.prototype.getStatus = function (callback) {\n\t\tPluginAPI.request('article-status-get', null, callback);\n\t};\n\n\t/**\n * Set the status for the article\n *\n * @param {String} status The new status to be set (draft, waiting, published)\n * @param {Function} callback function(Boolean), called when the source has been set\n */\n\tArticleCommunicator.prototype.setStatus = function (status, callback) {\n\t\tPluginAPI.request('article-status-set', {\n\t\t\tstatus: status\n\t\t}, callback);\n\t};\n\n\t/**\n * Get the published-date\n *\n * @param {Function} callback function(String), current published datetime\n */\n\tArticleCommunicator.prototype.getPublishedDatetime = function (callback) {\n\t\tPluginAPI.request('article-published-get', null, callback);\n\t};\n\n\t/**\n * Set the published-date\n *\n * @param {String} published Date to be set (YYYY-MM-DD HH:MM:SS)\n * @param {Function} callback function(Boolean), called when done\n */\n\tArticleCommunicator.prototype.setPublishedDatetime = function (published, callback) {\n\t\tPluginAPI.request('article-published-set', {\n\t\t\tpublished: published\n\t\t}, callback);\n\t};\n\n\t/**\n * Get the authors set in the article\n *\n * @param {Function} callback function([String]), currently set authors\n */\n\tArticleCommunicator.prototype.getAuthors = function (callback) {\n\t\tPluginAPI.request('article-authors-get', null, callback);\n\t};\n\n\t/**\n * Set authors for the article\n *\n * @param {Array} authors List of authors that should be set\n * @param {Function} callback function(Boolean), called when it has been set\n */\n\tArticleCommunicator.prototype.setAuthors = function (authors, callback) {\n\t\tPluginAPI.request('article-authors-set', {\n\t\t\tauthors: authors\n\t\t}, callback);\n\t};\n\n\t/**\n * Add the given authors to the list of authors\n *\n * @param {Array} authors List of authors to add\n * @param {Function} callback function(Boolean), called when it has been set\n */\n\tArticleCommunicator.prototype.addAuthors = function (authors, callback) {\n\t\tPluginAPI.request('article-authors-add', {\n\t\t\tauthors: authors\n\t\t}, callback);\n\t};\n\n\t/**\n * Remove the given authors from the list of authors\n *\n * @param {Array} authors List of authors to remove\n * @param {Function} callback function([String]), author list as it is after the authors has been removed\n */\n\tArticleCommunicator.prototype.removeAuthors = function (authors, callback) {\n\t\tPluginAPI.request('article-authors-remove', {\n\t\t\tauthors: authors\n\t\t}, callback);\n\t};\n\n\t/**\n * Set the keyword-list on the article\n *\n * @deprecated Use tags instead\n * @param {Array} keywords List of keywords to add\n * @param {Function} callback Function to call when keywords have been set\n */\n\tArticleCommunicator.prototype.setKeywords = function (keywords, callback) {\n\t\tPluginAPI.request('article-keywords-set', {\n\t\t\tkeywords: keywords\n\t\t}, callback);\n\t};\n\n\t/**\n * Get the current set of keywords on the article\n *\n * @deprecated Use tags instead\n * @param {Function} callback Function to call with the result\n */\n\tArticleCommunicator.prototype.getKeywords = function (callback) {\n\t\tPluginAPI.request('article-keywords-get', null, callback);\n\t};\n\n\t/**\n * Gets the main article content\n *\n * @param {Function} callback function(Object Content)\n */\n\tArticleCommunicator.prototype.getCurrentContent = function (callback) {\n\t\tPluginAPI.request('article-content-get', null, callback);\n\t};\n\n\t/**\n * Updates main article content\n *\n * @param {String} content The new content for the article\n * @param {Function} callback function(Boolean), called when it has been set\n */\n\tArticleCommunicator.prototype.setCurrentContent = function (content, callback) {\n\t\tPluginAPI.request('article-content-set', {\n\t\t\tcontent: content\n\t\t}, callback);\n\t};\n\t/**\n * Updates sub article content\n *\n * @param {Integer} articleId Sub article id\n * @param {String} content The new content for the sub article\n * @param {Function} callback function(Boolean), called when it has been set\n */\n\tArticleCommunicator.prototype.setSubArticleContent = function (articleId, content, callback) {\n\t\tPluginAPI.request('sub-article-content-set', {\n\t\t\tarticleId: articleId,\n\t\t\tcontent: content\n\t\t}, callback);\n\t};\n\n\t/**\n * Get the article type of the current article\n *\n * @param {Function} callback function(Int)\n */\n\tArticleCommunicator.prototype.getArticletypeId = function (callback) {\n\t\tPluginAPI.request('article-type-get', null, callback);\n\t};\n\n\t/**\n * Set the article type of the current article\n *\n * @param {Number} articletypeId The new article type of the article\n * @param {Function} callback function(Boolean), called when it has been set\n */\n\tArticleCommunicator.prototype.setArticletypeId = function (articletypeId, callback) {\n\t\tPluginAPI.request('article-type-set', {\n\t\t\tarticletype: articletypeId\n\t\t}, callback);\n\t};\n\n\t/**\n * Maximize the plugin view\n *\n * @param {String} title Title to give the maximized view\n * @param {function} onClose Function to call when the window is closed/minimized\n\t * @param {Function} callback function(Boolean)\n */\n\tArticleCommunicator.prototype.maximizePluginWindow = function (title, onClose, callback) {\n\t\tconst event = 'editor-pane-close-' + new Date().getTime();\n\n\t\tPluginAPI.request('editor-pane-maximize', {\n\t\t\ttitle: title,\n\t\t\tevent: event\n\t\t}, callback);\n\t\tPluginAPI.eventListeners.removeAll(event);\n\t\tPluginAPI.eventListeners.add(event, onClose);\n\t};\n\n\t/**\n * @deprecated use maximizePluginWindow instead\n * @param {String} title Window title\n * @param {function} onClose Callback to call after everything is done\n\t * @param {Function} callback function(Boolean), called when it has been set\n *\n */\n\tArticleCommunicator.prototype.maximizeAppWindow = function (title, onClose, callback) {\n\t\tthis.maximizePluginWindow(title, onClose, callback);\n\t};\n\n\t/**\n * Restore the plugin pane to the default size\n *\n * @param {function} callback Callback to call after everything is done\n */\n\tArticleCommunicator.prototype.restorePluginWindow = function (callback) {\n\t\tPluginAPI.request('restore-app-window', {}, callback);\n\t};\n\n\t/**\n * Restore the plugin pane to the default size\n *\n * @deprecated use restorPluginWindow instead\n * @param {function} callback Callback to call after everything is done\n */\n\tArticleCommunicator.prototype.restoreAppWindow = function (callback) {\n\t\tthis.restorePluginWindow(callback);\n\t};\n\n\t/**\n * Get the current byline\n *\n * @param {function} callback function(String), xml string with the current byline\n */\n\tArticleCommunicator.prototype.getByline = function (callback) {\n\t\tPluginAPI.request('article-byline-get', null, callback);\n\t};\n\n\t/**\n * Set the byline\n *\n * @param {String} byline XML version of byline to use\n * @param {Boolean} save If true, force save after updating byline information\n * @param {Function} callback function(Boolean), called when it has been set\n */\n\tArticleCommunicator.prototype.setByline = function (byline, save, callback) {\n\t\tPluginAPI.request('article-byline-set', {\n\t\t\tsave: save,\n\t\t\tbyline: byline\n\t\t}, callback);\n\t};\n\n\t/**\n * Set geolocation\n *\n * @param {Object} geolocations The location to set\n * @param {Function} callback function(Boolean), called when it has been set\n */\n\tArticleCommunicator.prototype.setGeolocations = function (geolocations, callback) {\n\t\tPluginAPI.request('article-geolocations-set', {\n\t\t\tgeolocations: geolocations\n\t\t}, callback);\n\t};\n\n\t/**\n * Get geolocation\n *\n * @param {Function} callback function(Object), retrieves the currently set geo location\n */\n\tArticleCommunicator.prototype.getGeolocations = function (callback) {\n\t\tPluginAPI.request('article-geolocations-get', null, callback);\n\t};\n\n\t/**\n * Fetches a list of all properties available to an article.\n *\n * @param {Function} callback Callback called with an array of property objects.\n */\n\tArticleCommunicator.prototype.getProperties = function (callback) {\n\t\tPluginAPI.request('article-properties-get', null, callback);\n\t};\n\n\t/**\n * Updates and saves one or more property values. The input is a simple object with property names and their\n * new value. The supplied callback is called with an updated list of properties.\n *\n * @example\n * PluginAPI.Article.setProperties({\n * fooProperty: \"bar\",\n * barProperty: \"foo\"\n * }, function(properties) {\n * // Returns a complete and updated list of properties.\n * })\n *\n * @param {Object} properties An object of property names and corresponding values.\n * @param {Function} callback Callback called with an updated list of properties.\n */\n\tArticleCommunicator.prototype.setProperties = function (properties, callback) {\n\t\tPluginAPI.request('article-properties-set', {\n\t\t\tproperties: properties\n\t\t}, callback);\n\t};\n\n\t/**\n * Updates and saves a single property.\n *\n * @param {String} name The property to update.\n * @param {Object} value The updated value.\n * @param {Function} callback Callback called with an updated list of properties.\n */\n\tArticleCommunicator.prototype.setProperty = function (name, value, callback) {\n\t\tconst data = {};\n\t\tdata[name] = value;\n\t\tPluginAPI.request('article-properties-set', {\n\t\t\tproperties: data\n\t\t}, callback);\n\t};\n\n\tArticleCommunicator.prototype.getTopic = function (callback) {\n\t\tPluginAPI.request('article-topic-get', null, callback);\n\t};\n\n\tArticleCommunicator.prototype.setTopic = function (name, callback) {\n\t\tPluginAPI.request('article-topic-set', {\n\t\t\ttopic: name\n\t\t}, callback);\n\t};\n\n\t/**\n\t * Get article package data, including content of sub articles\n\t *\n\t * @param {Function} callback function(Object)\n\t */\n\tArticleCommunicator.prototype.getPackage = function (callback) {\n\t\tPluginAPI.request('package-get', null, callback);\n\t};\n\n\treturn new ArticleCommunicator();\n\n};\n","/**\n * @example\n * PluginAPI.on('afterCreate', function() {\n * PluginAPI.Article.setSource('Ny Times');\n * });\n * PluginAPI.on('beforeSave', function() {\n * if (!articleIsAwesome()) {\n * return false;\n * }\n * });\n *\n * @description\n *\n *

DrPublish provides a large set of default events that an plugin can listen for. All events that start their name with 'before' can be stopped by an plugin. This is done by returning 'false' from the callback function, as in the 'beforSave' example given bellow.

\n *

Other plugins can also supply their own events using the PluginAPI.emit(...) function. Documention on these events are up to each plugin to create.

\n *

Available Events

\n *

addCategory

\n *
\n *

triggered after a category has been added to the article

\n *
\n *

addTag

\n *
\n *

triggered after a tag had been added to the article

\n *
\n *

pluginWindowMaximized

\n *
\n *

triggered when the plugin pane is maximized

\n *
\n *

pluginWindowRestored

\n *
\n *

triggered when the plugin pane is restored to its' original size

\n *
\n *

changedCustomMeta

\n *
\n *

triggered when a custom meta property is changed/set, parameter is an object with property name and value

\n *
\n *

receivedFocus

\n *
\n *

triggered when a plugin receives focus. Receives a parameter object that has two predefined values: previousPluginName - name of previous plugin, givenFocus - true when focus was sent from another plugin. The parameter object can also contain other keys supplied by the plugin losing focus.

\n *
\n *

afterCreate

\n *
\n *

triggered after a new article has been created

\n *
\n *

beforeDelete

\n *
\n *

triggered before an article is deleted

\n *
\n *

afterDelete

\n *
\n *

triggered after an article has been deleted

\n *
\n *

afterLoad

\n *
\n *

triggered after an article has been loaded

\n *
\n *

afterPublish

\n *
\n *

triggered after an article has been published

\n *
\n *

afterSave

\n *
\n *

triggered after an article has been saved

\n *
\n *

beforeCreate

\n *
\n *

triggered before a new article is created

\n *
\n *

beforeLoad

\n *
\n *

triggered before an article is loaded into the editor

\n *
\n *

beforePreview

\n *
\n *

triggered before the article is opened in the preview

\n *
\n *

beforeSave

\n *
\n *

triggered before an article is saved

\n *
\n *

beforePublish

\n *
\n *

triggered before an article is published

\n *
\n *

editorFocus

\n *
\n *

triggered when an editor gets focus

\n *
\n *

editorUnfocus

\n *
\n *

triggered when an editor loses focus

\n *
\n *

editorsLostFocus

\n *
\n *

triggered when all editors loses focus

\n *
\n *

editorReady

\n *
\n *

triggered when the editor has been fully loaded and is ready for input

\n *
\n *

modifiedContent

\n *
\n *

triggered whenever content changes in the article

\n *
\n *

elementRemoved

\n *
\n *

triggered when a plugin element from the current plugin is removed, receives an object with element id as a parameter

\n *
\n *

pluginElementClicked

\n *
\n *

triggered when someone clicks on a plugin element in the editor

\n *
\n *

pluginElementSelected

\n *
\n *

triggers when someone selects a plugin element in the editor

\n *
\n *

pluginElementDeselected

\n *
\n *

triggered when someone deselects a plugin element in the editor

\n *
\n */\nclass Listeners {\n\tconstructor() {\n\t\tthis._listeners = {};\n\t}\n\n\n\t/**\n\t * @deprecated Use PluginAPI.on(...) instead\n\t * @param {Object} listeners\n\t */\n\taddAll(listeners) {\n\t\tconst PluginAPI = require('./PluginAPI');\n\t\t'use strict';\n\t\tconst createCallback = function (callback) {\n\t\t\treturn function (data) {\n\t\t\t\tcallback(data.data);\n\t\t\t};\n\t\t};\n\t\tfor (const eventName in listeners) {\n\t\t\tif (listeners.hasOwnProperty(eventName)) {\n\t\t\t\tconst callback = listeners[eventName];\n\t\t\t\tconst callWrapper = createCallback(callback);\n\t\t\t\tPluginAPI.on(eventName, callWrapper);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Adds a new listener\n\t *\n\t * @param {String} event Event name\n\t * @param {Function} callback Function to call when an even of the type is received\n\t * @return {number}\n\t */\n\tadd(event, callback) {\n\n\t\tif (typeof callback !== 'function') {\n\t\t\tthrow new Error('not a function');\n\t\t}\n\n\t\tif (this._listeners[event] === undefined) {\n\t\t\tthis._listeners[event] = [];\n\t\t}\n\n\t\tthis._listeners[event].push(callback);\n\t\treturn this._listeners[event].length - 1;\n\t}\n\n\t/**\n\t * Removes the listener at the given index\n\t *\n\t * @param {String} event Event type\n\t * @param {Function} index The index of the event handler to remove\n\t */\n\tremove(event, index) {\n\n\t\tif (this._listeners[event] === undefined || this._listeners[event][index] === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\t/*\n\t\t * Set to null instead of remove to retain callback indexes\n\t\t */\n\t\tthis._listeners[event][index] = false;\n\t}\n\n\t/**\n\t * Removes all listeners for the given event type, or if !event then removes all listeners\n\t *\n\t * @param {String} event Event type to remove handlers for (!event for all)\n\t */\n\tremoveAll(event) {\n\t\tif (!event) {\n\t\t\tthis._listeners = [];\n\t\t} else {\n\t\t\tthis._listeners[event] = [];\n\t\t}\n\t}\n\n\t/**\n\t * Notifies all registered listeners that an event has occurred\n\t *\n\t * @param {String} event Event type\n\t * @param {Object} payload The event data\n\t * @return {Boolean}\n\t */\n\tnotify(event, payload) {\n\t\tlet returnValue = true;\n\t\tif (this._listeners[event] === undefined) {\n\t\t\treturn returnValue;\n\t\t}\n\n\t\t// If the payload is an object with a key data, we use that value as the payload we pass to the listener functions.\n\t\t// This is needed as we have some inconsistencies in how we pass data around. This normalization should preferably\n\t\t// be done at the call site.\n\t\tthis._listeners[event].forEach((listenerFn) => {\n\t\t\tif (typeof listenerFn !== 'function') {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlet res = null;\n\t\t\tif (payload && payload.params && payload.params === true) {\n\t\t\t\tres = listenerFn.apply(null, payload.data);\n\t\t\t} else if (typeof payload === 'object' && payload !== null && typeof payload.data !== 'undefined') {\n\t\t\t\tres = listenerFn(payload.data);\n\t\t\t} else {\n\t\t\t\tres = listenerFn(payload);\n\t\t\t}\n\t\t\tif (res === false) {\n\t\t\t\treturnValue = false;\n\t\t\t}\n\t\t});\n\t\treturn returnValue;\n\t}\n\n}\n\nmodule.exports = Listeners;\n"],"sourceRoot":""} \ No newline at end of file diff --git a/package.json b/package.json index 137fcd7..bfd5c60 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@aptoma/drpublish-plugin-api", - "version": "3.12.18", + "version": "3.13.0", "repository": { "type": "git", "url": "https://github.com/aptoma/drpublish-plugin-api.git"