I'm using Blazored.TextEditor 1.1.3 in a Blazor server app. The default behaviour seems to be that when you start entering text, the editor wraps the value in a
tag. I need to remove this unless the user actively presses enter. This is because I want to capture the htmlContent and ultimately inject the value onto another web page and I dont necassarily want it to start on a new line.
I thought I might just be able to suppress it with:
[JSInvokable]public async Task OnKeyPressedWithContent(string key, string htmlContent){ //the editor returns the first entry in a <p> tag we do not want this unless the user has pressed enter string pattern = @"<p>.*?</p>"; if (htmlContent.Length == 8 && System.Text.RegularExpressions.Regex.IsMatch(htmlContent, pattern)) { htmlContent = htmlContent.Substring(3, 1); } if (htmlContent == defaultWhenEmpty) htmlContent = string.Empty; await OnContentChanged.InvokeAsync(htmlContent);}Which works when a single letter is pressed, but then on subsequent key presses the editor then wraps the value back into a
element.