Skip to content

[Sprint 19] Restore markdown editor compile path - #329

Merged
mpaulosky merged 1 commit into
devfrom
squad/323-restore-markdown-editor-compile-path
May 13, 2026
Merged

[Sprint 19] Restore markdown editor compile path#329
mpaulosky merged 1 commit into
devfrom
squad/323-restore-markdown-editor-compile-path

Conversation

@mpaulosky

Copy link
Copy Markdown
Owner

Summary

Closes #323

Restores the compile path for the markdown editor by adding the two missing NuGet package references and defining the previously-undefined IFileStorage infrastructure layer that TextEditor.razor depends on.

Changes

Package references (Web.csproj)

  • Added PSC.Blazor.Components.MarkdownEditor (centrally pinned at 10.0.7)
  • Added Markdig (centrally pinned at 1.2.0)

New infrastructure layer (Infrastructure/FileStorage/)

  • IFileStorage — internal interface with AddFileAsync(FileData)
  • FileStorageModelsFileData and FileMetaData records
  • LocalDiskFileStorage — baseline impl saving to wwwroot/uploads; validates extension whitelist and 10 MB size cap
  • FileStorageExtensionsAddFileStorage() DI extension following project conventions

Wiring

  • GlobalUsings.csglobal using MyBlog.Web.Infrastructure.FileStorage;
  • Program.csbuilder.Services.AddFileStorage();
  • TextEditor.razor — added @using for new namespace; renamed AddFileAddFileAsync

JS helpers (from #321 investigation)

  • wwwroot/js/markdown-editor-init.js
  • wwwroot/js/text-editor-helpers.js

Verification

  • Release build: 0 errors, 0 warnings
  • Tests: Architecture 16 / Domain 42 / Web.Tests 158 / bUnit 92 — all pass
  • All 6 pre-push gates passed (including integration tests)

Notes

Copilot AI review requested due to automatic review settings May 13, 2026 06:33
@github-actions github-actions Bot added the squad Squad triage inbox — Lead will assign to a member label May 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🏗️ PR Added to Squad Triage Queue

This PR has been labeled with squad and added to the triage queue.

Next steps:

  • The squad Lead will review and assign to an appropriate team member
  • A squad:member label will be added after triage

If you know which squad member should handle this, you can add the appropriate squad:member label yourself.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores a baseline markdown editor integration path in the Web project by adding required package references, introducing a minimal file-storage abstraction for image uploads, and adding supporting JS interop helpers.

Changes:

  • Added Web package references for Markdig and PSC.Blazor.Components.MarkdownEditor.
  • Introduced Infrastructure/FileStorage with IFileStorage + LocalDiskFileStorage and DI registration.
  • Added a shared TextEditor component and JS helper scripts intended to support editor initialization and selection handling.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/Web/wwwroot/js/text-editor-helpers.js Adds a JS helper (getSelectedText) intended for toolbar actions.
src/Web/wwwroot/js/markdown-editor-init.js Adds a custom EasyMDE initialization/disposal wrapper for interop.
src/Web/Web.csproj Adds new PackageReferences for markdown/editor dependencies.
src/Web/Program.cs Registers file storage in DI (AddFileStorage).
src/Web/Infrastructure/FileStorage/LocalDiskFileStorage.cs Implements local-disk storage to wwwroot/uploads with basic validation and logging.
src/Web/Infrastructure/FileStorage/IFileStorage.cs Defines the storage abstraction used by the editor component.
src/Web/Infrastructure/FileStorage/FileStorageModels.cs Adds FileData / FileMetaData records for storage operations.
src/Web/Infrastructure/FileStorage/FileStorageExtensions.cs Adds DI extension method to register the storage implementation.
src/Web/GlobalUsings.cs Adds a global using for the new file storage namespace.
src/Web/Components/Shared/TextEditor.razor Adds MarkdownEditor-based component with image upload + custom button handler.
src/AppHost/MongoDbResourceBuilderExtensions.cs Minor formatting adjustment in seed document construction.

Comment thread src/Web/Web.csproj
Comment on lines +15 to +19
<PackageReference Include="Markdig" />
<PackageReference Include="MediatR" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" />
<PackageReference Include="MongoDB.EntityFrameworkCore" />
<PackageReference Include="PSC.Blazor.Components.MarkdownEditor" />

// Persist the file and build a retrieval URL
var fileName = await FileStorage.AddFileAsync(new FileData(stream, new FileMetaData(file.Name, string.Empty, file.LastModified)));
file.UploadUrl = new Uri(new Uri(NavigationManager.BaseUri), $"/api/files/{fileName}").ToString();
Comment on lines +88 to +90
// Get the selected text using JavaScript
var selectedText = await JsRuntime.InvokeAsync<string>("getSelectedText", ".EasyMDEContainer textarea");

Comment on lines +94 to +98
var wrappedText = $"<div style='text-align:{args.Value}'>{selectedText}</div>";

// Replace the selected text in the editor
MyContent = MyContent.Replace(selectedText, wrappedText);

Comment on lines +72 to +75
public async Task<FileEntry> HandleImageUpload(MarkdownEditor editor, FileEntry file)
{
Console.WriteLine($"Image: {file.Name} Size: {file.Size}");

Comment on lines +76 to +82
// Convert the base64 string to a byte array and load it into a memory stream
var bytes = Convert.FromBase64String(file.ContentBase64);
var stream = new MemoryStream(bytes);

// Persist the file and build a retrieval URL
var fileName = await FileStorage.AddFileAsync(new FileData(stream, new FileMetaData(file.Name, string.Empty, file.LastModified)));
file.UploadUrl = new Uri(new Uri(NavigationManager.BaseUri), $"/api/files/{fileName}").ToString();
{
/// <summary>
/// Persists <paramref name="file"/> and returns the stored filename that callers
/// can use to build a retrieval URL (e.g. <c>/api/files/{filename}</c>).
var uniqueName = $"{Guid.NewGuid()}{extension}";
var filePath = Path.Combine(uploadsPath, uniqueName);

await using var fs = new FileStream(filePath, FileMode.Create, FileAccess.Write);
Comment on lines +69 to +71

// Ensure the interop is available globally
console.log('Markdown Editor Interop Loaded');
@mpaulosky
mpaulosky force-pushed the squad/323-restore-markdown-editor-compile-path branch from e6d474c to 8886140 Compare May 13, 2026 15:14
@github-actions

github-actions Bot commented May 13, 2026

Copy link
Copy Markdown
Contributor

Test Results Summary

378 tests  ±0   377 ✅ ±0   20s ⏱️ ±0s
  6 suites ±0     1 💤 ±0 
  6 files   ±0     0 ❌ ±0 

Results for commit 13b7269. ± Comparison against base commit 6d9ffd0.

♻️ This comment has been updated with latest results.

@codecov

codecov Bot commented May 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 55 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.64%. Comparing base (6d9ffd0) to head (13b7269).

Files with missing lines Patch % Lines
src/Web/Components/Shared/TextEditor.razor 0.00% 26 Missing and 2 partials ⚠️
...Infrastructure/FileStorage/LocalDiskFileStorage.cs 0.00% 20 Missing and 3 partials ⚠️
...nfrastructure/FileStorage/FileStorageExtensions.cs 0.00% 2 Missing ⚠️
...eb/Infrastructure/FileStorage/FileStorageModels.cs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #329      +/-   ##
==========================================
- Coverage   84.01%   80.64%   -3.38%     
==========================================
  Files          47       51       +4     
  Lines        1314     1369      +55     
  Branches      161      166       +5     
==========================================
  Hits         1104     1104              
- Misses        148      198      +50     
- Partials       62       67       +5     
Files with missing lines Coverage Δ
...nfrastructure/FileStorage/FileStorageExtensions.cs 0.00% <0.00%> (ø)
...eb/Infrastructure/FileStorage/FileStorageModels.cs 0.00% <0.00%> (ø)
...Infrastructure/FileStorage/LocalDiskFileStorage.cs 0.00% <0.00%> (ø)
src/Web/Components/Shared/TextEditor.razor 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mpaulosky

Copy link
Copy Markdown
Owner Author

🤖 Aragorn — Rebase complete

Branch squad/323-restore-markdown-editor-compile-path rebased onto origin/dev. Resolved Web.csproj conflict (kept PSC/Markdig, dropped RTBlazorfied). Added Directory.Packages.props version pins for Markdig v0.44.0 + PSC.Blazor.Components.MarkdownEditor v10.0.7. All pre-push gates passed ✅

- Add PSC.Blazor.Components.MarkdownEditor and Markdig package references
  to Web.csproj (both centrally pinned in Directory.Packages.props)
- Add IFileStorage infrastructure (interface, FileData/FileMetaData models,
  LocalDiskFileStorage impl, DI extension) under Infrastructure/FileStorage/
- Register IFileStorage via AddFileStorage() in Program.cs
- Fix TextEditor.razor: add @using for Infrastructure.FileStorage namespace,
  rename AddFile -> AddFileAsync to match the new interface
- Add GlobalUsings entry for MyBlog.Web.Infrastructure.FileStorage
- Include JS helpers (markdown-editor-init.js, text-editor-helpers.js)

Build: Release 0 errors
Tests: Architecture 16 / Domain 42 / Web.Tests 158 / bUnit 92 - all pass

Closes #323

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mpaulosky
mpaulosky force-pushed the squad/323-restore-markdown-editor-compile-path branch from 8886140 to 13b7269 Compare May 13, 2026 17:24
@mpaulosky

Copy link
Copy Markdown
Owner Author

🔁 Aragorn restack — rebased onto dev (6d9ffd0, post-#328). No conflicts. Force-pushed with --force-with-lease. Branch now at 13b7269.

@mpaulosky
mpaulosky enabled auto-merge May 13, 2026 17:25
@mpaulosky
mpaulosky merged commit a269e2a into dev May 13, 2026
18 checks passed
@mpaulosky
mpaulosky deleted the squad/323-restore-markdown-editor-compile-path branch May 13, 2026 17:42
mpaulosky added a commit that referenced this pull request May 13, 2026
## Summary

Closes #323

Restores the compile path for the markdown editor by adding the two
missing NuGet package references and defining the previously-undefined
`IFileStorage` infrastructure layer that `TextEditor.razor` depends on.

## Changes

### Package references (Web.csproj)
- Added `PSC.Blazor.Components.MarkdownEditor` (centrally pinned at
10.0.7)
- Added `Markdig` (centrally pinned at 1.2.0)

### New infrastructure layer (`Infrastructure/FileStorage/`)
- `IFileStorage` — internal interface with `AddFileAsync(FileData)`
- `FileStorageModels` — `FileData` and `FileMetaData` records
- `LocalDiskFileStorage` — baseline impl saving to `wwwroot/uploads`;
validates extension whitelist and 10 MB size cap
- `FileStorageExtensions` — `AddFileStorage()` DI extension following
project conventions

### Wiring
- `GlobalUsings.cs` — `global using
MyBlog.Web.Infrastructure.FileStorage;`
- `Program.cs` — `builder.Services.AddFileStorage();`
- `TextEditor.razor` — added `@using` for new namespace; renamed
`AddFile` → `AddFileAsync`

### JS helpers (from #321 investigation)
- `wwwroot/js/markdown-editor-init.js`
- `wwwroot/js/text-editor-helpers.js`

## Verification

- Release build: **0 errors, 0 warnings**
- Tests: Architecture 16 / Domain 42 / Web.Tests 158 / bUnit 92 — **all
pass**
- All 6 pre-push gates passed (including integration tests)

## Notes

- Full Create/Edit page migration is deferred to #324 and #325, now
unblocked by this fix.
- Working as **Sam** (Implementation)

Co-authored-by: Boromir <boromir@squad.dev>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

squad Squad triage inbox — Lead will assign to a member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Sprint 19] Restore markdown editor compile path end-to-end

2 participants