I use the WebView for Displaying the MonacoEditor in my Avalonia Project. And I'm trying to get the content of the Editor by executing window.monacoEditor.getValue() in JavaScript. Which works in a normal browser, but not with webView.EvaluateScript<T>().
Here's my implementation:
private async Task SaveCode()
{
if (_webView != null && _webView.IsJavascriptEngineInitialized)
{
var result = await _webView.EvaluateScript<string>("window.monacoEditor.getValue()");
Console.WriteLine("result: " + result);
}
}
But what works is _webView.ExecuteScript("window.monacoEditor.setValue('value')");. My I guess is that there might some type of timing issue.
I hope some of yall can help me out :)