Black Lives Matter. Please consider donating to Black Girls Code today.

How to receive data from Javascript variable embedded in an iframe?(dev.:markdown editor tool)

I want to build up Markdown Editor in plotly dash. So I build up a small script to render a html template and provide it to the layout:

# Import required libraries
import dash
from jinja2 import FileSystemLoader, Environment
import dash_html_components as html

app = dash.Dash(
    __name__, meta_tags=[{"name": "viewport", "content": "width=device-width"}]
server = app.server

file_loader = FileSystemLoader('/home/daniel/projects/forecast-system/meteoIntelligence-dashboard/apps/assets')
env = Environment(loader=file_loader)

markdown_editor = env.get_template('markdown_editor_base.html')
markdown_editor = markdown_editor.render()

app.layout = html.Div(
                        html.Iframe(srcDoc=markdown_editor, id='markdown_editor', style={'border': 0, 'margin-bottom': -10, 'margin-top': -5},
                                    width="100%", height=400)

                    className="pretty_container eight columns",

                    className="pretty_container four columns",

         ], className="row flex-display"),

        ], id="mainContainer", style={"display": "flex", "flex-direction": "column"})

    dash.dependencies.Output('test-output', 'children'),
    [dash.dependencies.Input('markdown_editor', 'srcDoc')])
def update_forecast_data(markdown_data):
    return html.P(markdown_data)

if __name__ == "__main__":
    app.run_server(debug=True, host='')

And here is the required html template:

<!DOCTYPE html>
        <html lang="en">
<link rel="stylesheet" href="">
<script src=""></script>
<p id="p1"></p>
var easyMDE = new EasyMDE();
easyMDE.codemirror.on("change", function(){
document.getElementById("p1").innerHTML = easyMDE.value();


My issue is now to receive the data/value of easyMDE.value() whichis the markdown output. As you can see I tried to receive the data via a div or p box but the srcDoc does not change and the iframe javascript does not write any data to the p1 element.