Skip to content

Commit e6d461b

Browse files
committed
Update readme
1 parent 22d1ae7 commit e6d461b

2 files changed

Lines changed: 130 additions & 116 deletions

File tree

README.md

Lines changed: 130 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,63 @@
1-
# Blazor Text Diff
2-
A component to display side by side text diff using the [DiffPlex](https://github.com/mmanela/diffplex) library. There is probably some issues that I have looked over so if you notice one please submit an issue or do a pull request!
1+
# BlazorTextDiff 🔍
32

3+
A modern Blazor component for displaying side-by-side text differences with syntax highlighting and advanced comparison features. Built on top of the powerful [DiffPlex](https://github.com/mmanela/diffplex) library.
4+
5+
## 🚀 Features
6+
7+
- **Side-by-side comparison** with clear visual indicators
8+
- **Syntax highlighting** for better readability
9+
- **Ignore case and whitespace** options
10+
- **Async diff processing** for large texts
11+
- **Customizable headers** with diff statistics
12+
- **Responsive design** that works on all devices
13+
- **Easy integration** with existing Blazor applications
14+
15+
## 📊 Status
416

517
[![Build and Publish Packages](https://github.com/lzinga/BlazorTextDiff/actions/workflows/publish-packages.yml/badge.svg)](https://github.com/lzinga/BlazorTextDiff/actions/workflows/publish-packages.yml)
18+
[![Deploy to GitHub Pages](https://github.com/lzinga/BlazorTextDiff/actions/workflows/deploy-pages.yml/badge.svg)](https://github.com/lzinga/BlazorTextDiff/actions/workflows/deploy-pages.yml)
19+
[![NuGet](https://img.shields.io/nuget/v/BlazorTextDiff.svg)](https://www.nuget.org/packages/BlazorTextDiff/)
20+
[![NuGet Downloads](https://img.shields.io/nuget/dt/BlazorTextDiff.svg)](https://www.nuget.org/packages/BlazorTextDiff/)
621

22+
## 🎮 Live Demo
23+
24+
Try the interactive demo: [https://lzinga.github.io/BlazorTextDiff/](https://lzinga.github.io/BlazorTextDiff/)
25+
26+
## 📸 Screenshots
727

828
![Static Diff](https://i.imgur.com/t0nJPeZ.png)
29+
*Basic text comparison showing additions, deletions, and modifications*
30+
931
![Async Diff](https://i.imgur.com/lzjfjhF.png)
32+
*Async processing for large text comparisons*
33+
34+
## 📦 Installation
35+
36+
Install the NuGet package:
37+
38+
```bash
39+
dotnet add package BlazorTextDiff
40+
```
41+
42+
You'll also need the DiffPlex library:
1043

11-
# Installation
12-
You will need to add the nuget package DiffPlex into your project for this to work. An example project can be found in the [Samples Folder](https://github.com/lzinga/BlazorTextDiff/tree/master/samples/BlazorTextDiff.Web) for implementation.
44+
```bash
45+
dotnet add package DiffPlex
46+
```
47+
48+
## ⚙️ Setup
49+
50+
### 1. Configure Services
51+
52+
Add the required services to your `Program.cs`:
1353

1454
```csharp
1555
// Program.cs
1656
public static async Task Main(string[] args)
1757
{
1858
var builder = WebAssemblyHostBuilder.CreateDefault(args);
1959

20-
// These must be injected into your application to supply the component with its diff checking.
60+
// Register BlazorTextDiff dependencies
2161
builder.Services.AddScoped<ISideBySideDiffBuilder, SideBySideDiffBuilder>();
2262
builder.Services.AddScoped<IDiffer, Differ>();
2363

@@ -27,36 +67,101 @@ public static async Task Main(string[] args)
2767
}
2868
```
2969

70+
### 2. Include Styles and Scripts
71+
72+
Add to your `index.html` or `_Host.cshtml`:
73+
3074
```html
31-
<!-- Index.html -->
75+
<!-- Required CSS -->
3276
<link href="_content/BlazorTextDiff/css/BlazorDiff.css" rel="stylesheet" />
77+
78+
<!-- Required JavaScript -->
3379
<script src="_content/BlazorTextDiff/js/BlazorTextDiff.js"></script>
3480
```
3581

82+
## 🎯 Usage
3683

37-
# Usage
38-
```html
39-
<TextDiff
84+
### Basic Comparison
4085

41-
<!-- The left side of the comparison -->
42-
OldText="Old Text"
43-
44-
<!-- The right side of the comparison -->
45-
NewText="New Text"
86+
```html
87+
<TextDiff OldText="@oldText" NewText="@newText" />
88+
```
4689

47-
<!-- Determines if the div containing the diffs should be collapsed if there is a lot of data. -->
48-
<!-- There is currently an issue where the toggling doesn't work accurately with the js interop. -->
49-
CollapseContent="true"
50-
51-
<!-- Converts space values into \u00B7 and tab values into \u00B7\u00B7 -->
52-
ShowWhiteSpace="true"
90+
### Advanced Features
5391

54-
>
92+
```html
93+
<TextDiff
94+
OldText="@oldText"
95+
NewText="@newText"
96+
CollapseContent="true"
97+
ShowWhiteSpace="true"
98+
IgnoreCase="true"
99+
IgnoreWhiteSpace="false">
100+
55101
<Header>
56-
<!-- Context Variables -->
57-
<!-- @context.Additions -->
58-
<!-- @context.Modifications -->
59-
<!-- @context.Deletions -->
102+
<div class="diff-stats">
103+
<span class="badge bg-success">+@context.Additions</span>
104+
<span class="badge bg-warning">~@context.Modifications</span>
105+
<span class="badge bg-danger">-@context.Deletions</span>
106+
</div>
60107
</Header>
61108
</TextDiff>
62109
```
110+
111+
### Async Processing
112+
113+
For large texts, use async processing:
114+
115+
```csharp
116+
@code {
117+
private string oldText = "";
118+
private string newText = "";
119+
private bool isProcessing = false;
120+
121+
private async Task ProcessLargeDiff()
122+
{
123+
isProcessing = true;
124+
// Your async logic here
125+
await Task.Delay(100); // Simulate processing
126+
isProcessing = false;
127+
}
128+
}
129+
```
130+
131+
## 🔧 Component Parameters
132+
133+
| Parameter | Type | Default | Description |
134+
|-----------|------|---------|-------------|
135+
| `OldText` | `string` | `""` | The original text (left side) |
136+
| `NewText` | `string` | `""` | The modified text (right side) |
137+
| `CollapseContent` | `bool` | `false` | Collapse large diff sections |
138+
| `ShowWhiteSpace` | `bool` | `false` | Visualize spaces and tabs |
139+
| `IgnoreCase` | `bool` | `false` | Ignore case differences |
140+
| `IgnoreWhiteSpace` | `bool` | `false` | Ignore whitespace differences |
141+
142+
## 🎨 Customization
143+
144+
The component uses CSS classes that you can override:
145+
146+
```css
147+
.diff-container { /* Main container */ }
148+
.diff-line-added { /* Added lines */ }
149+
.diff-line-deleted { /* Deleted lines */ }
150+
.diff-line-modified { /* Modified lines */ }
151+
.diff-line-unchanged { /* Unchanged lines */ }
152+
```
153+
154+
## 📄 License
155+
156+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
157+
158+
## 🙏 Acknowledgments
159+
160+
- [DiffPlex](https://github.com/mmanela/diffplex) - The core diffing library
161+
- [Blazor](https://blazor.net/) - The web framework that makes this possible
162+
163+
---
164+
165+
<div align="center">
166+
Made with ❤️ for the Blazor community
167+
</div>

temp-ref-workflow.yml

Lines changed: 0 additions & 91 deletions
This file was deleted.

0 commit comments

Comments
 (0)