feat: edit print templates on the printer page and store them on presets

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-03 22:45:56 -04:00
co-authored by Cursor
parent 1337d9833d
commit c03ffc0833
18 changed files with 904 additions and 293 deletions
@@ -38,4 +38,55 @@ public class MarkdownTablePasteService
_logger.LogError(ex, "Unexpected error initializing paste-markdown for editor {EditorId}", editorId ?? "unknown");
}
}
public async Task<string?> GetValueAsync(string editorId)
{
try
{
return await _jsRuntime.InvokeAsync<string?>("markdownTablePaste.getValue", editorId);
}
catch (JSDisconnectedException)
{
return null;
}
catch (JSException ex)
{
_logger.LogWarning(ex, "Failed to read markdown editor {EditorId}", editorId);
return null;
}
}
public async Task<bool> SetValueAsync(string editorId, string text)
{
try
{
return await _jsRuntime.InvokeAsync<bool>("markdownTablePaste.setValue", editorId, text);
}
catch (JSDisconnectedException)
{
return false;
}
catch (JSException ex)
{
_logger.LogWarning(ex, "Failed to set markdown editor {EditorId}", editorId);
return false;
}
}
public async Task<bool> InsertAtCursorAsync(string editorId, string text)
{
try
{
return await _jsRuntime.InvokeAsync<bool>("markdownTablePaste.insertAtCursor", editorId, text);
}
catch (JSDisconnectedException)
{
return false;
}
catch (JSException ex)
{
_logger.LogWarning(ex, "Failed to insert into markdown editor {EditorId}", editorId);
return false;
}
}
}
+2 -4
View File
@@ -19,7 +19,6 @@ public class PrintPresetService : IPrintPresetService
{
return await _context.PrintPresets
.AsNoTracking()
.Include(p => p.Note)
.OrderBy(p => p.Name)
.ToListAsync(cancellationToken);
}
@@ -28,7 +27,6 @@ public class PrintPresetService : IPrintPresetService
{
return await _context.PrintPresets
.AsNoTracking()
.Include(p => p.Note)
.FirstOrDefaultAsync(p => p.Id == id, cancellationToken);
}
@@ -48,7 +46,7 @@ public class PrintPresetService : IPrintPresetService
{
preset.Name = preset.Name.Trim();
preset.UpdatedAt = DateTime.UtcNow;
preset.Note = null!;
preset.TemplateMarkdown ??= string.Empty;
if (await NameExistsAsync(preset.Name, null, cancellationToken))
throw new InvalidOperationException($"A print preset named '{preset.Name}' already exists.");
@@ -72,7 +70,7 @@ public class PrintPresetService : IPrintPresetService
throw new InvalidOperationException($"A print preset named '{name}' already exists.");
existing.Name = name;
existing.NoteId = preset.NoteId;
existing.TemplateMarkdown = preset.TemplateMarkdown ?? string.Empty;
existing.EntityType = preset.EntityType;
existing.FiltersJson = preset.FiltersJson;
existing.UpdatedAt = DateTime.UtcNow;