Categories > Coding > C# >
CefSharp / Monaco issue?
Posted
I've recently tried using cefsharp & monaco but when i try loading certain scripts into the editor i get this error
Uncaught SyntaxError: Invalid or unexpected token
@ about:blank:1:9
Has anyone else had this issue? Im using default monaco
Ill supply some code now just incase someone decides to help.
Edit: Fixed it by parsing the script :facepalm:
var escapedScript = script.Replace("\\", "\\\\").Replace("'", "\\'").Replace("\"", "\\\"").Replace("\n", "\\n").Replace("\r", "\\r");
here's my fix for anyone who needs it.
// Class for loading data into the editor
public async void SetValue(ChromiumWebBrowser webBrowser, string script)
{
//MessageBox.Show(script);
var result = await webBrowser.EvaluateScriptAsync($"setValue('{script}')");
if (!result.Success)
{
MessageBox.Show($"An error occurred while loading the script: {result.Message}. This error has been copied to your clipboard.");
Clipboard.SetText(result.Message);
}
}
// Load text from the txt and use the SetValue method
private void scriptsListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
string script = File.ReadAllText("./Scripts/" + scriptsListBox.SelectedItem);
editor.SetValue(wb, script);
}
// JS stuff
function setValue(value) {
editor.setValue(value);
}
Added
@tempegoreng, It's not a huge deal tbh this is just a executor im making for myself because syn is going sub based. Thanks for the suggestion tho.
Cancel
Post
Rust is the best language
Users viewing this thread:
( Members: 0, Guests: 1, Total: 1 )
Cancel
Post