Add MarkdownTablePasteService and integrate with NoteEditDialog and PageNoteDialog components

This commit introduces the MarkdownTablePasteService to facilitate markdown table pasting functionality. The service is registered in Program.cs and injected into NoteEditDialog and PageNoteDialog components. Additionally, OnAfterRenderAsync lifecycle methods are implemented in both dialog components to initialize the service after the editor is rendered, enhancing the user experience for note editing. This change supports improved markdown handling within the application.
This commit is contained in:
2026-01-17 11:33:57 -05:00
parent b4c11cd0a6
commit 84b31800ad
6 changed files with 313 additions and 1 deletions
@@ -1,6 +1,7 @@
@namespace WebApp.Components.Shared.Components
@inject INotesService NotesService
@inject ISnackbar Snackbar
@inject MarkdownTablePasteService MarkdownTablePasteService
@implements IAsyncDisposable
<MudDialog Class="@MarkdownHelper.GetNoteColorClass(_note.Id)">
@@ -77,6 +78,7 @@
private bool _isEditMode = false;
private CancellationTokenSource? _cancellationTokenSource;
private bool _isDisposed = false;
private bool _pasteMarkdownInitialized = false;
protected override void OnInitialized()
{
@@ -94,6 +96,20 @@
await LoadPageNote();
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender && _isEditMode && !_pasteMarkdownInitialized)
{
// Initialize paste-markdown after first render if already in edit mode
await Task.Delay(150); // Wait for EasyMDE to initialize
if (!_isDisposed)
{
await MarkdownTablePasteService.InitializeAsync();
_pasteMarkdownInitialized = true;
}
}
}
private async Task LoadPageNote()
{
if (_isDisposed) return;
@@ -201,11 +217,22 @@
}
}
private void EnterEditMode()
private async Task EnterEditMode()
{
if (_isDisposed) return;
_isEditMode = true;
StateHasChanged();
// Initialize paste-markdown after editor is rendered
if (!_pasteMarkdownInitialized)
{
await Task.Delay(150); // Wait for EasyMDE to initialize
if (!_isDisposed)
{
await MarkdownTablePasteService.InitializeAsync();
_pasteMarkdownInitialized = true;
}
}
}
private void Cancel()