Currently, to cut some corners and to ensure it uses the same build, the same script is run both for the editor and inside the iframe.
This causes double work, and makes the script more complex than it has to be for both cases.
The script also grew over time to support multiple small cases, and should probably be revised and split up.
Luckily, everything can be simplified a lot, as postMessage is not needed to interact with and read data from the frame. All code that was written under that false assumption can be moved to the main window quite easily. Shouldn't be much left after that is done.
Current situation
Currently, to cut some corners and to ensure it uses the same build, the same script is run both for the editor and inside the iframe.
This causes double work, and makes the script more complex than it has to be for both cases.
The script also grew over time to support multiple small cases, and should probably be revised and split up.
Luckily, everything can be simplified a lot, as
postMessage
is not needed to interact with and read data from the frame. All code that was written under that false assumption can be moved to the main window quite easily. Shouldn't be much left after that is done.