taylorkelley.dev

UI Kit with Blazor

Blazor UI Showcase
The Context

Blazor-based Rich Text Editor and UI Components

TypeBlazor Component Library (RCL)
LicenseMIT
Target Version.Net 8 SSR & WASM Compatible
CategoryUI/UX | Frontend
A custom Blazor component library built from the ground up to address the lack of safe, robust rich text editing tools in the ecosystem. By parsing the raw HTML from a content-editable input, it provides an object-driven editor built via vanilla JavaScript and robust C# Interop.
Component Architecture

The Pathway Between C# Code and JavaScript Execution

Tech Stack

C#BlazorJavaScript

Centralized Service Injections

All components utilize a base class (ComponentMain) to seamlessly cascade core services like JS Runtime, navigation management, and application toast services without manual boilerplate code for every component.

Cascading Form States

All input controls automatically register validation delegates into parent forms through the cFormState class, allowing for more reactive form loading and submission states.

100%XSS-Safe Object-style Storage
Deep Dive

Deep Dive: Wrangling the Virtual DOM

The single largest technical hurdle was managing Blazor's strict Virtual DOM reconciliation algorithm against a native HTML contenteditable node. Because Blazor attempts to add/remove elements from the input which changes based on user input, the content-editable can easily fall out of sync with server state, causing the V-DOM synchronization to fail and crash the site.

The resolution required encapsulating the editing interface deeply inside vanilla JavaScript, cutting the V-DOM out of the loop entirely during active text manipulation. Interop calls then transmit data structures back to C# when the user stops typing in the field, preventing stuttering from constant DOM updates and keeping the browser more performant for large text blocks.

Data Architecture Strategy

Transforming strings into structured collections enables flexible server-side rendering without dangerous HTML sanitization procedures. Image assets are completely split from the primary text stream, mapping unique string identifiers to a string dictionary store. This ensures massive inline base64 blobs remain detached from core content metadata structures.

Evaluator Interop

Global Eval Execution Pattern

A limitation with earlier .Net Core RCLs is that JavaScript (and any wwwroot content) is not properly bundled along with the DLL. Thus a solution to this was to use JavaScript's `eval` function, allowing for inline JavaScript code bundled directly with C#. Among the many trade-offs, the fact that the `eval` function cannot accept parameters is a bit easier to overcome with a global helper function injected upon the first render through all components base class.

Global Extension of eval()javascript