Dear, I’m stuck on the following
Requirement:
- I need a custom widget (a customized PDF viewer based on pdf.js)
- that is able to communicate and transport objects to and from my appsmith space (e.g. to call an API, DBquery,…)
current solution:
a I’ve created a index.html file that displays a PDF on an html canvas using pdf.js and hosted this file on a personal domain
b. when I need to communicate from the custom PDFviewer in the Iframe to the parent appsmit app I call from within the ifram: parent.postMessage(“messageTxContent”, “*”);
c in my appsmith app I’ve created an IFRAME with as SRC that intex.html file
d in the IFRAME widget I’ve in the onMessageReceived property triggered an alert {{showAlert(‘YEEY’,‘success’)}}
All of the above works + the alert is shown but I cannot retreive the “messageTxContent” , questions:
Q1: I do not have any clue on how to replace the showAlert(‘YEEY’) content with the content passed by parent.postMessage(). (in my example it would be: “messageTxContent”). How to do this?
Q2: is there a smarter way to achieve all of this, create a custom ‘widget’/ be able to create a html canvas with my javascript code + the pdf.js library and let it’s data interact with the appsmith environment :)?
THANKS!