How to add a callback handler?
The Callback Handler plugin (window.QA.author.qaCallbackManager) registers various callbacks to allow you to perform additional tasks.
To add Callback Handler plugin to Quark Author:
- Create a folder feature in the directory qaservice/ext in the s3 bucket.
- Create a folder callback-handler in the folder feature.
- Add the Callback Handler plugin to the folder callback-handler.
The name of the folder callback-handler must be the same as you have specified in the file qa-config.json under the property “extensions.”
Sample qa-config.json (available for every content type)
"extensions": [
"callback-handler"
]
The folder callback-handler also must contain the file “manifest.json” with the key “modules” with “type” defined as “qa-canvas-plugin” and “bundle” defined as JavaScript file path.
Sample manifest.json
{
"version": "0.0.1",
"modules": [
{
"type": "qa-canvas-plugin",
"name": "statusValidation",
"bundle": "statusValidation/plugin.js"
}
]
}
Callback Handler
To register callback hooks/events, you have to use a custom JavaScript file that must be specified in the file extensibility.json stored in the folder qaservice/conf on the s3 bucket.
The sample code to register a callback is as follows:
App level callback
window.QA.app.callbackManager.registerCallback(window.QA.app.callbackManager.Callbacks.BEFORE_NEW_DOC_META_POPULATE, (data) => {
console.log("beforeNewDocMetaPopulate", data);
});
Editor level callback
CKEDITOR.on("instanceReady", () => {
window.QA.author.qaCallbackManager.registerCallback(window.QA.author.qaCallbackManager.Callbacks.BEFORE_DOCUMENT_LOAD, (data) => {
console.log("beforeDocumentLoad", data);
});
window.QA.author.qaCallbackManager.registerCallback(window.QA.author.qaCallbackManager.Callbacks.BEFORE_REPLACE_COMPONENT, (data) => {
console.log("beforeReplaceComponent", data);
// return false to stop the replace operation
return {
targetComponent: {
"assetId": 6282,
"versionInfo": {
"majorVerion": 0,
"minorVersion": 2,
"branchId": 0,
},
}
};
});
});
To download sample, click here