CIB webRec technical documentation
CIB webRec integration
Integration using web component (modern way)
CIB webRec iframe can be controlled by commands from enclosing page. For this, library called webrec-component.js is used.
Examples in this section assume that some initialization is run. Here we assume that CIB webRec frame is available by id #webRec
//grab a handle to call methods on
var webRec = document.getElementById('webRec')
Methods are called:
webRec.blockUI(true)
All message passing to iframe is asynchronous. WebRecComponent uses promises for it, so that a result should be processed using .then handler:
webRec.saveRTF().then(function (rtfString) {
console.log('We have saved RTF of length ' + rtfString.length)
})
When an API method is said to return a value, it means that you will be given a promise which resolves to that value when the method is done. It is also not safe to call methods one after another without using .then and return
// WRONG!
webRec.blockUI(true) webRec.insertRTF(someRTF) // was the UI blocked? It might be not
webRec.blockUI(false) // was the RTF inserted? It might be not Page 8 of 15
// RIGHT!
webRec.blockUI(true)
.then(function() {
return webRec.insertRTF(someRTF) // UI was blocked
}).then(function() {
return
})
Additional information on promises is available at its API documentation page: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise