-
New Feature
-
Resolution: Done
-
Normal
-
9.0.0
-
Security Level: Jimmy
-
ZK 9.5.1 S1
-
None
Current state
The pdfviewer component contains inline lambdas used in promises.
This makes overrides very difficult / impossible without replacing the whole JS file due to the code being unreachable in client.
Ex: zkex/pdfviewer/Pdfviewer.ts
_getPage(pageNum) has a structure such as:
_getPage(pageNum: number, pdfFirstRender = false) { ... return this._pdf.getPage(pageNum).then(page => { ... return page.render({...}) .promise .then(() => page.getTextContent({})) .then(textContent => { ...
Desired state
Instead of using inline promises, the promise could access a function defined at class level.
ex:
_getPage(pageNum: number, pdfFirstRender = false) { ... return this._pdf.getPage(pageNum).then(promiseGetPageAfterPdfGetPage); //end of instance-level function, start of class-level functions },{ promiseGetPageAfterPdfGetPage: function (page) { ... return page.render({...}) .promise .then(promiseGetPageGetTextContent) }, promiseGetPageGetTextContent: function(){ ... } }
etc.
This would allow developers to set overrides granularly without having to replace the whole JS file.
Workaround
Compile and replace the whole pdfviewer.tf source by the updated replacement.