erossini / BlazorMarkdownEditor

Complete Markdown Editor component for Blazor WebAssembly and Blazor Server. Full of functionalities
https://www.puresourcecode.com/dotnet/blazor/markdown-editor-component-for-blazor/
MIT License
117 stars 13 forks source link

OnInitializedAsync Value initialization #9

Closed dor1202 closed 2 years ago

dor1202 commented 2 years ago

Hi! First of all, amazing component. Second, I have 2 issues in 1.

  1. OnInitialized function will update the value but OnInitializedAsync will not when using async await for http client.
  2. there isn't any Toolbar documentation.

Adding a code sample for the issue:

` <MarkdownEditor Value="@Value" Toolbar={????}/>

@code {
   [Parameter]
   public string Value { get; set; } = string.Empty;

   protected override async Task OnInitializedAsync()
   {
        // Will Not Work
        var Http = new HttpClient() { BaseAddress = new Uri(MyNavigationManager.BaseUri) };
        var tmp = await Http.GetStringAsync("md/ReleaseNotesTemplate.md");
        Value = tmp;
   }

   protected override void OnInitialized()
   {
      // Will Work
      Value = "# Sample Template For comments";
   }
}

`

erossini commented 2 years ago

Hello! You're right, there is not a big documentation about the toolbar but you can refer to the official website for it for now.

Did you try to call StateHasChanged() after setting a new Value?

dor1202 commented 2 years ago

Hello @erossini , thank you for the response. Yes, I tried to call StateHasChanged()

erossini commented 2 years ago

Have you done any progress? I've just came back from holidays and I'll look at it in the next few days.

dor1202 commented 2 years ago

Hi, @erossini hope you had a good holiday. Unfortunately, I couldn't find a solution to the problem even after investing a few days. Hope you will find the bug. I will be happy to be notified if any progress is done!

erossini commented 2 years ago

@dor1202 Hey! I found the issue! In an hour you have the new version. Also, you will find some examples of toolbar and the documentation.

The live example will be available here.

dor1202 commented 2 years ago

@erossini Wow! amazing, I will update and check this out for sure!

Seikon commented 4 months ago

For me worked render component after async operations has finished on OnInitializedAsync. I control the whole flow with a flag (Loaded) that indicates all operations has finished:

@if(!Loaded) {

Cargando

} else {

Result

@((MarkupString)MarkdownHTML)