@using BLAIzor.Models @using BLAIzor.Services @using Microsoft.AspNetCore.Components.Authorization @inject ContentEditorService ContentEditorService @inject AuthenticationStateProvider AuthenticationStateProvider @inject CustomAuthenticationStateProvider CustomAuthProvider @inject NavigationManager navigationManager @inject IJSRuntime JSRuntime @code { [Parameter] public HtmlSnippet Snippet { get; set; } = new HtmlSnippet(); [Parameter] public EventCallback OnContentUpdated { get; set; } [Parameter] public int TemplateId { get; set; } private bool IsLoading = false; private string? userId; private string? userName; private AuthenticationState? authState; EventConsole console; public async void ShowSnippetPreview(HtmlSnippet snippet) { //navigationManager.NavigateTo($"/preview-snippet/{TemplateId}/{snippet.Name}"); // await JSRuntime.InvokeAsync("open", $"/preview-snippet/{TemplateId}/{snippet.Name}", "_blank"); await JSRuntime.InvokeVoidAsync("open", $"/preview-snippet/{TemplateId}/{snippet.Name}", "_blank"); } protected override async Task OnParametersSetAsync() { authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); if (authState.User.Identity?.IsAuthenticated == true) { userId = CustomAuthProvider.GetUserId(); userName = CustomAuthProvider.GetUserName(); } if(string.IsNullOrWhiteSpace(Snippet.Tags)) { Snippet.Tags = Snippet.Name; } if (string.IsNullOrWhiteSpace(Snippet.SampleHtml)) { Snippet.SampleHtml = Snippet.Html; } if (string.IsNullOrWhiteSpace(Snippet.Variant)) { Snippet.Variant = ""; } } async Task OnPaste(HtmlEditorPasteEventArgs args) { console.Log($"Paste: {args.Html}"); // await OnContentUpdated.InvokeAsync(MenuItem); } async Task OnChange(string html) { console.Log($"Change: {html}"); } async Task OnInput(string html) { console.Log($"Input: {html}"); } void OnExecute(HtmlEditorExecuteEventArgs args) { console.Log($"Execute: {args.CommandName}"); } void OnUploadComplete(UploadCompleteEventArgs args) { console.Log($"Upload complete: {args.RawResponse}"); } }