Skip to content

Commit 3071436

Browse files
Merge pull request #80 from AlexHedley/codeblock
Added Code Block Syntax Highlighting
2 parents ded7e0f + 8b18733 commit 3071436

23 files changed

+313
-74
lines changed

Blazored.TextEditor.sln

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.29519.87
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35527.113
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blazored.TextEditor", "src\Blazored.TextEditor\Blazored.TextEditor.csproj", "{A76F9184-D5C2-42AE-9BFA-BDF33A3B1434}"
77
EndProject
@@ -13,10 +13,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{666C
1313
EndProject
1414
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5DCD4124-DAD2-4777-92CB-16ABA93847C1}"
1515
ProjectSection(SolutionItems) = preProject
16-
DeltaExample.png = DeltaExample.png
17-
HTMLExample.png = HTMLExample.png
18-
InlineEditingExample.png = InlineEditingExample.png
16+
docs\images\DeltaExample.png = docs\images\DeltaExample.png
17+
docs\images\HTMLExample.png = docs\images\HTMLExample.png
18+
docs\images\InlineEditingExample.png = docs\images\InlineEditingExample.png
1919
README.md = README.md
20+
docs\images\SyntaxHighlighterExample.png = docs\images\SyntaxHighlighterExample.png
2021
EndProjectSection
2122
EndProject
2223
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TextEditorDemo", "samples\TextEditorDemo\TextEditorDemo.csproj", "{91541C38-9A34-4AC1-B5F8-BD80DBC5012F}"

README.md

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,37 @@
11
# Blazored TextEditor
2-
Rich Text Editor for Blazor applications - Uses [Quill JS](https://quilljs.com/ "Quill JS.com")
32

4-
![Screenshot](HTMLExample.png)
3+
<!-- ![Blazored Icon](https://avatars.githubusercontent.com/u/39194025?s=200&v=4 "Blazored Icon") -->
54

6-
### Sample Applications
5+
[![Blazor](https://img.shields.io/badge/blazor-5C2D91.svg?style=for-the-badge&logo=blazor&logoColor=white)](https://dotnet.microsoft.com/en-us/apps/aspnet/web-apps/blazor) [![C#](https://img.shields.io/badge/c%23-239120.svg?style=for-the-badge&logo=c-sharp&logoColor=white)](https://learn.microsoft.com/en-us/dotnet/csharp/)
6+
7+
[![Build & Test Main](https://github.com/Blazored/TextEditor/actions/workflows/ci-main.yml/badge.svg)](https://github.com/Blazored/TextEditor/actions/workflows/ci-main.yml)
8+
[![Build & Test PR](https://github.com/Blazored/TextEditor/actions/workflows/ci-pr.yml/badge.svg)](https://github.com/Blazored/TextEditor/actions/workflows/ci-pr.yml)
9+
[![CodeQL](https://github.com/Blazored/TextEditor/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/Blazored/TextEditor/actions/workflows/codeql-analysis.yml)
10+
[![Release Drafter](https://github.com/Blazored/TextEditor/actions/workflows/release-drafter.yml/badge.svg)](https://github.com/Blazored/TextEditor/actions/workflows/release-drafter.yml)
11+
12+
> Rich Text Editor for Blazor applications - Uses [Quill JS](https://quilljs.com/ "Quill JS.com")
13+
14+
![HTML Example](docs/images/HTMLExample.png "HTML Example]")
15+
16+
## Sample Applications
717

818
* [Simple blogging application written in Microsoft Server Side Blazor](https://github.com/ADefWebserver/Blazor-Blogs "Blazor Blogs") - [Contains an example of uploading images]
919

10-
### Helpful Articles
20+
## Helpful Articles
1121

1222
* [Creating Reusable Custom Blazor Controls](https://blazorhelpwebsite.com/ViewBlogPost/11 "BlazorHelpWebsite.com")
1323
* [Creating A Rich Text Editor In Blazor Using Quill](https://blazorhelpwebsite.com/ViewBlogPost/12 "BlazorHelpWebsite.com")
1424

15-
### Installing
25+
## Installing
1626

1727
You can install from NuGet using the following command:
1828

1929
`Install-Package Blazored.TextEditor`
2030

2131
Or via the Visual Studio package manger.
2232

23-
### Setup
33+
## Setup
34+
2435
Blazor Server applications will need to include the following CSS and JS files in their `Pages\_Host.cshtml` (or `Pages/_Layout.cshtml` if using .Net 6).
2536

2637
In the `head` tag add the following CSS.
@@ -61,6 +72,7 @@ Below is a list of all the options available on the Text Editor.
6172
- `Placeholder` (Optional - Default: `Compose an epic...`) - The text to show when editor is empty.
6273
- `Theme` (Optional - Default: `snow`) - Use `snow` to show the Toolbar on top of the editor, and `bubble` for inline editing.
6374
- `DebugLevel` (Optional - Default: `info`) - Determines the level of debug information returned to the web browser console window. Options are `error`, `warn`, `log`, or `info`.
75+
- `Syntax` (Optional - Default: `false`) - The Syntax Module enhances the Code Block format by automatically detecting and applying syntax highlighting.
6476

6577
**Methods**
6678

@@ -72,9 +84,13 @@ Below is a list of all the options available on the Text Editor.
7284
- `InsertImage` (`string`) - Inserts an image at the current point in the editor.
7385
- `InsertText` (`string`) - Inserts text at the current point in the editor.
7486

87+
## Basic Example
88+
89+
(see code in the [`Index.razor` page](https://github.com/Blazored/TextEditor/blob/main/samples/BlazorServerSide/Pages/Index.razor) in the repo for more examples)
90+
91+
<details>
92+
<summary>Code</summary>
7593

76-
### Basic Example
77-
(see code in the [Index.razor page](https://github.com/Blazored/TextEditor/blob/main/samples/BlazorServerSide/Pages/Index.razor) in the repo for more examples)
7894
```cs
7995
@using Blazored.TextEditor
8096

@@ -148,8 +164,15 @@ string QuillHTMLContent;
148164
}
149165
```
150166

167+
</details>
168+
151169
### Alternative Using of the BlazoredTextEditor Component
152-
Depending on our use case, we may want to add some styling to the Toolbar or Editor. We can also place the Toolbar below the Editor by setting the BottomToolbar property totruein the BlazoredTextEditor component:
170+
171+
Depending on our use case, we may want to add some styling to the _Toolbar_ or _Editor_. We can also place the _Toolbar_ below the _Editor_ by setting the `BottomToolbar` property to `"true"` in the **BlazoredTextEditor** component:
172+
173+
<details>
174+
<summary>Code</summary>
175+
153176
```csharp
154177
<style>
155178
.rounded {
@@ -260,11 +283,28 @@ Depending on our use case, we may want to add some styling to the Toolbar or Edi
260283
}
261284
}
262285
```
286+
287+
</details>
288+
289+
## Screenshots
290+
263291
![examples_screenshot.png](samples%2FTextEditorDemo%2Fwwwroot%2Fexamples_screenshot.png)
292+
264293
### Rich Text Screenshot
265-
![Screenshot](DeltaExample.png)
294+
295+
![Delta Example](docs/images/DeltaExample.png "Delta Example")
296+
266297
### Read Only Screenshot
267-
![Screenshot](InlineEditingExample.png)
298+
299+
![Inline Editing Example](docs/images/InlineEditingExample.png "Inline Editing Example")
300+
301+
## Adding Syntax Highlighting
302+
303+
See [Syntax Highlighter Example](docs/SyntaxHighlighterExample.md) docs for more information.
304+
305+
![Syntax Highlighter Example](docs/images/SyntaxHighlighterExample.png "Syntax Highlighter Example")
306+
307+
---
268308

269309
# Blazored TextEditor Forks
270310

docs/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Docs
2+
3+
- [Syntax Highlighter](SyntaxHighlighterExample.md)
4+
5+
## Images
6+
7+
- [Images](images/README.md)

docs/SyntaxHighlighterExample.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Syntax Highlighter Example
2+
3+
See [Syntax Highlighter Module](https://quilljs.com/docs/modules/syntax) from the _QuillJS_ docs for more information.
4+
5+
![Syntax Highlighter Example](images/SyntaxHighlighterExample.png "Syntax Highlighter Example")
6+
7+
To turn on _Syntax Highlighting_ in your **Blazored Text Editor** just pass the property `Syntax="true"` and add the necessary library files (css/js).
8+
9+
Then add the `ql-code-block` to your _Toolbar_.
10+
11+
```html
12+
<BlazoredTextEditor Syntax="true">
13+
<ToolbarContent>
14+
...
15+
<span class="ql-formats">
16+
<button class="ql-code-block"></button>
17+
</span>
18+
</ToolbarContent>
19+
<EditorContent>
20+
...
21+
</EditorContent>
22+
</BlazoredTextEditor>
23+
```
24+
25+
## Blazor WASM
26+
27+
Add to the `index.html` both CSS and JS for a syntax highlighter, for these examples I've chosen [highlight.js](https://highlightjs.org/).
28+
29+
```html
30+
<head>
31+
...
32+
<!-- Include your favorite highlight.js stylesheet -->
33+
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/atom-one-dark.min.css" rel="stylesheet">
34+
...
35+
</head>
36+
```
37+
38+
Make sure to add the `js` before your Quill js library or you will get an error.
39+
40+
```html
41+
<body>
42+
<!-- Include the highlight.js library -->
43+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
44+
<!-- Quill library -->
45+
</body>
46+
```
47+
48+
## Blazor Server
49+
50+
Repeat the above but instead of the `index.html` you will want to add / update your `_Host.cshtml`.
File renamed without changes.
File renamed without changes.
File renamed without changes.

docs/images/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Images
2+
3+
## HTML Example
4+
5+
![HTML Example](HTMLExample.png "HTML Example")
6+
7+
## Delta Example
8+
9+
![Delta Example](DeltaExample.png "Delta Example")
10+
11+
## Inline Editing Example
12+
13+
![Inline Editing Example](InlineEditingExample.png "Inline Editing Example")
14+
15+
## Syntax Highlighter Example
16+
17+
![Syntax Highlighter Example](SyntaxHighlighterExample.png "Syntax Highlighter Example")
14.7 KB
Loading

samples/BlazorClientSide/Pages/Counter.razor

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

0 commit comments

Comments
 (0)