-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
You can't load the text editor within the OnInitialized event. Is there another way? #32
Comments
Please see the example here: https://github.com/Blazored/TextEditor/blob/main/samples/BlazorServerSide/Pages/Index.razor It has code like this:
Basically you load content from the database and store it in the The You can see how I implement that in Blazor Blogs: https://github.com/ADefWebserver/Blazor-Blogs/blob/main/BlazorBlogsLibrary/Pages/BlogAdministration.razor |
Really appreciate the swift response. I'll try that now and let you know how it goes. |
Thanks for posting this, I had the same question and the suggested solution works great. |
No there is not. QuillNative uses the "Delta" format, that is what you are seeing. To use it, you have to call special JavaScript methods. That is why the Blazored Text Editor does not try to do interactive binding. |
That makes sense. Thank you for your swift response! |
I just wanted to share my way. It's maybe not the cleanest one, but it works for me. The component gets the NewsBoard as a parameter [Parameter]
public NewsBoard? NewsBoard { get; set; } And here the editor declaration for completion. private BlazoredTextEditor _quillEditor = new BlazoredTextEditor(); I'm calling a async method in the OnParametersSetAsync method. protected override Task OnParametersSetAsync()
{
LoadHtml();
return base.OnParametersSetAsync();
} And this is the method that loads the HTML into the TextEditor. private async Task LoadHtml()
{
await Task.Delay(1200);
await _quillEditor.LoadHTMLContent(NewsBoard?.Content);
StateHasChanged();
} |
@DaNeubi - I am curious, does setting |
For me it wasn't working because it wasn't creating an instance of an object. It took me a day to figure out what was going on, when it was clear that the console was showing the error. But works without problems. PS: Always watch the console, it can save you a lot of time. |
@DaNeubi - Thank you for following up. That will help others. |
I want to load the editor when the form starts up, with existing content that has been saved in a database. Currently I can't see any way of doing this as the only way to load the editor is by using an async method - which is not permitted in the onInitialized event. There are also no events on the editor itself (i.e. onloaded).
Other than clicking a button to load the editor, I can't see any other way of loading the editor?
If you can help - would be much obliged as this must be common request.
Anton
The text was updated successfully, but these errors were encountered: