Skip to content

Commit 5abb817

Browse files
Merge branch 'development' into 966118-AI
2 parents 3b50069 + c9f2907 commit 5abb817

File tree

7 files changed

+199
-7
lines changed

7 files changed

+199
-7
lines changed

blazor-toc.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4168,6 +4168,7 @@
41684168
<li><a href="/blazor/rich-text-editor/tools/video">Insert video</a></li>
41694169
<li><a href="/blazor/rich-text-editor/tools/link-manipulation">Link manipulation</a></li>
41704170
<li><a href="/blazor/rich-text-editor/tools/table-manipulation">Table manipulation</a></li>
4171+
<li><a href="/blazor/rich-text-editor/tools/code-block">Code Block</a></li>
41714172
<li><a href="/blazor/rich-text-editor/tools/format-painter">Format Painter</a></li>
41724173
<li><a href="/blazor/rich-text-editor/tools/custom-tool">Custom Tool</a></li>
41734174
<li><a href="/blazor/rich-text-editor/tools/dialogSettings">Dialog Settings</a></li>

blazor/datagrid/batch-editing.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,4 +1037,17 @@ public class OrderDetails
10371037
{% endhighlight %}
10381038
{% endtabs %}
10391039

1040-
{% previewsample "https://blazorplayground.syncfusion.com/embed/hjrStoqXKmIboOTG?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" %}
1040+
{% previewsample "https://blazorplayground.syncfusion.com/embed/hjrStoqXKmIboOTG?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" %}
1041+
1042+
## Supported events for batch editing
1043+
1044+
Batch editing in the Syncfusion Blazor DataGrid offers a powerful way to edit multiple records simultaneously. Understanding the sequence and purpose of events triggered during this process enables users to customize or extend the data Grid's functionality. This section outlines the key events associated with batch editing, providing essential information to harness the full potential of this feature.
1045+
1046+
| Event | Description |
1047+
|-------|-------------|
1048+
| [OnBatchAdd](https://blazor.syncfusion.com/documentation/datagrid/events#onbatchadd) | Triggers before new records are added to the UI when the user clicks the add toolbar item or presses the insert key. |
1049+
| [OnBatchSave](https://blazor.syncfusion.com/documentation/datagrid/events#onbatchsave) | Triggers before batch changes (added, edited, deleted data) are saved to the data source. A confirmation popup is displayed when the Update button is clicked. |
1050+
| [OnBatchDelete](https://blazor.syncfusion.com/documentation/datagrid/events#onbatchdelete) | Triggers before records are deleted in the Grid. If no rows are selected, a popup prompts the user to select rows for deletion. |
1051+
| [OnCellEdit](https://blazor.syncfusion.com/documentation/datagrid/events#oncelledit) | Triggers before a cell enters edit mode in the UI, such as on double-click or pressing F2. |
1052+
| [OnCellSave](https://blazor.syncfusion.com/documentation/datagrid/events#oncellsave) | Triggers before cell changes are updated in the UI, such as on pressing Enter key or navigating to another cell. |
1053+
| [CellSaved](https://blazor.syncfusion.com/documentation/datagrid/events#cellsaved) | Triggers after cell changes are updated in the UI and the edited values are highlighted in the Grid. |

blazor/datagrid/dialog-editing.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,4 +779,6 @@ public class ProductDetails
779779
{% endhighlight %}
780780
{% endtabs %}
781781

782-
{% previewsample "https://blazorplayground.syncfusion.com/embed/LDLyXsZxfZTvqDJz?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" %}
782+
{% previewsample "https://blazorplayground.syncfusion.com/embed/LDLyXsZxfZTvqDJz?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" %}
783+
784+
> For information about the events triggered during `Dialog` editing, please refer to this [documentation](https://blazor.syncfusion.com/documentation/datagrid/in-line-editing#supported-events-for-inline-and-dialog-editing).

blazor/datagrid/in-line-editing.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,3 +1269,48 @@ public class OrderDetails
12691269
{% endtabs %}
12701270

12711271
{% previewsample "https://blazorplayground.syncfusion.com/embed/LthINCtgBmWlAIwy?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" %}
1272+
1273+
## Supported events for inline and dialog editing
1274+
1275+
Inline and dialog editing in the Syncfusion Blazor DataGrid provide flexible ways to modify records, catering to various user needs. This section outlines the key events triggered during the editing operations, including adding, editing, updating, deleting, and canceling, to help you effectively implement and customize the Grid’s behavior for enhanced user interaction.
1276+
1277+
**Sequence of events**
1278+
1279+
* **Adding a new record**
1280+
1281+
| Event | Description |
1282+
|-------|-------------|
1283+
| [RowCreating](https://blazor.syncfusion.com/documentation/datagrid/events#rowcreating) | Triggers before a new row is added to the Grid. This event is useful for initializing default values or conditionally preventing the add operation. |
1284+
| [RowCreated](https://blazor.syncfusion.com/documentation/datagrid/events#rowcreated) | Triggers after a new row is added to the Grid. |
1285+
1286+
* **Editing a record**
1287+
1288+
| Event | Description |
1289+
|-------|-------------|
1290+
| [OnRowEditStart](https://blazor.syncfusion.com/documentation/datagrid/events#onroweditstart) | Triggers before a row enters edit mode. Enables control over data cloning behavior and can be used to prepare the row for editing. |
1291+
| [OnBeginEdit](https://blazor.syncfusion.com/documentation/datagrid/events#onbeginedit) | Triggers before a row enters edit mode in the UI, such as on double-click or pressing F2. This event is useful for conditional editing logic. |
1292+
| [RowEditing](https://blazor.syncfusion.com/documentation/datagrid/events#rowediting) | Triggers before the edit action is performed. This event is useful for validation or dynamic configuration of the editing interface. |
1293+
| [RowEdited](https://blazor.syncfusion.com/documentation/datagrid/events#rowedited) | Triggers after the edit action is completed. |
1294+
1295+
* **Saving (Updating) a record**
1296+
1297+
| Event | Description |
1298+
|-------|-------------|
1299+
| [RowUpdating](https://blazor.syncfusion.com/documentation/datagrid/events#rowupdating) | Triggers before the edited or newly added data is saved. Used for validating or modifying data before it is committed to the data source. |
1300+
| [RowUpdated](https://blazor.syncfusion.com/documentation/datagrid/events#rowupdated) | Triggers after the edited or newly added data is saved to the data source. |
1301+
1302+
* **Deleting a record**
1303+
1304+
| Event | Description |
1305+
|-------|-------------|
1306+
| [RowDeleting](https://blazor.syncfusion.com/documentation/datagrid/events#rowdeleting) | Triggers before a row is deleted from the Grid. This event is used to confirm deletion or cancel the operation based on custom logic. |
1307+
| [RowDeleted](https://blazor.syncfusion.com/documentation/datagrid/events#rowdeleted) | Triggers after a row is deleted from the Grid. |
1308+
1309+
* **Canceling an edit operation**
1310+
1311+
| Event | Description |
1312+
|-------|-------------|
1313+
| [EditCanceling](https://blazor.syncfusion.com/documentation/datagrid/events#editcanceling) | Triggers before the cancellation of an edit operation. This event is useful for confirmation prompts or rollback logic before discarding changes. |
1314+
| [EditCanceled](https://blazor.syncfusion.com/documentation/datagrid/events#editcanceled) | Triggers after the cancellation of an edit operation. |
1315+
1316+
> The same events are also applicable when using **Dialog** editing mode.

blazor/getting-started/license-key/how-to-register-in-an-application.md

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,16 @@ N> * Place the license key between double quotes. Also, ensure that Syncfusion.
2424

2525
I> Syncfusion<sup style="font-size:70%">&reg;</sup> license keys can be validated during the Continuous Integration (CI) processes to ensure proper licensing and prevent licensing errors during deployment. Refer to the [CI License Validation](https://blazor.syncfusion.com/documentation/getting-started/license-key/ci-license-validation) section for detailed instructions on how to implement it.
2626

27-
## Blazor Web App
27+
| Blazor Mode | Project(s) to Register License Key | File(s) to Register License Key |
28+
|---------------------------------------|-----------------------------------------|-----------------------------------------|
29+
| Blazor Web App (Interactive Auto) | Server & Client | `Server/Program.cs`, `Client/Program.cs`|
30+
| Blazor Web App (Interactive Server) | Server | `Server/Program.cs` |
31+
| Blazor Web App (Interactive WASM) | Server & Client | `Server/Program.cs`, `Client/Program.cs`|
32+
| Blazor Standalone WebAssembly App | Client | `Program.cs` |
2833

29-
Open **~/Program.cs** file and register the Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor license key in the Blazor web app.
34+
## Blazor Web App (Interactive Auto)
3035

36+
Open **~/Program.cs** file in both the server and client projects of a Blazor Web App(Interactive Auto) and register the Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor license key.
3137
{% tabs %}
3238

3339
{% highlight C# tabtitle="Blazor Web App" hl_lines="1 2" %}
@@ -39,9 +45,9 @@ Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("YOUR LICENSE KEY
3945

4046
{% endtabs %}
4147

42-
## Blazor Server App
48+
## Blazor Web App (Interactive Server)
4349

44-
* For .NET 8 and .NET 9 app, open the **~/Program.cs** file and register the Syncfusion<sup style="font-size:70%">&reg;</sup> license key.
50+
* For .NET 8 and .NET 9, open the **~/Program.cs** file and register the Syncfusion<sup style="font-size:70%">&reg;</sup> license key.
4551

4652
{% tabs %}
4753

@@ -63,7 +69,21 @@ if (!app.Environment.IsDevelopment())
6369

6470
{% endtabs %}
6571

66-
## Blazor WebAssembly App
72+
## Blazor Web App (Interactive WebAssembly)
73+
74+
Open **~/Program.cs** file in both the server and client projects of a Blazor Web App(Interactive WebAssembly) and register the Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor license key.
75+
{% tabs %}
76+
77+
{% highlight C# tabtitle="Blazor Web App" hl_lines="1 2" %}
78+
79+
//Register Syncfusion license
80+
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("YOUR LICENSE KEY");
81+
82+
{% endhighlight %}
83+
84+
{% endtabs %}
85+
86+
## Blazor Standalone WebAssembly App
6787

6888
Open **~/Program.cs** file and register the Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor license key in the client web app.
6989

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
layout: post
3+
title: Code Block in Blazor RichTextEditor Component | Syncfusion
4+
description: Checkout and learn here all about Code Block in Syncfusion Blazor RichTextEditor component and much more.
5+
platform: Blazor
6+
control: RichTextEditor
7+
documentation: ug
8+
---
9+
10+
# Code Block in Blazor Rich Text Editor Component
11+
12+
The Code Block feature in the Rich Text Editor, enabling users to insert and format code snippets effectively. It covers configuring supported languages, integrating syntax highlighters, editing tips, and enabling tab-based indentation, making it ideal for technical documentation, tutorials, and code-heavy content. While live code block highlighting is not supported during editing, syntax highlighting can be applied when content is displayed on the frontend.
13+
14+
## Inserting a code block
15+
16+
The Code Block feature allows users to embed formatted code snippets within the Rich Text Editor. To insert a code block:
17+
18+
- **Using the Toolbar**: Click the **CodeBlock** button in the editor’s toolbar, typically represented by a code icon.
19+
- **Using the Shortcut**: Press `Ctrl+Shift+B` (or `Cmd+Shift+B` on macOS) to insert a code block at the cursor’s position.
20+
- A dropdown menu appears, allowing selection of the programming language for the code block, such as **JavaScript**, **Python**, **HTML**, or others configured in the system.
21+
22+
The code block is rendered with a monospaced font and preserved indentation for readability. Language selection applies syntax-specific formatting and prepares the block for syntax highlighting when displayed on the frontend.
23+
24+
## Configuring code block languages
25+
26+
The Code Block feature supports customizable programming languages via the `RichTextEditorCodeBlockSettings` property, specifically the `Languages` and `DefaultLanguage` options. The `Languages` property accepts an array of objects defining available languages, while `DefaultLanguage` sets the default language for new code blocks. This allows developers to customize the editor for project-specific languages.
27+
28+
Below is an example of how to configure the `RichTextEditorCodeBlockSettings` using the Rich Text Editor:
29+
30+
```cshtml
31+
32+
@using Syncfusion.Blazor.RichTextEditor
33+
<SfRichTextEditor ID="code-block">
34+
<RichTextEditorCodeBlockSettings Languages="languages" DefaultLanguage="plaintext"></RichTextEditorCodeBlockSettings>
35+
<RichTextEditorToolbarSettings Items="Tools"></RichTextEditorToolbarSettings>
36+
</SfRichTextEditor>
37+
@code {
38+
private List<CodeBlockLanguageModel> languages = new List<CodeBlockLanguageModel>
39+
{
40+
new CodeBlockLanguageModel { Label = "HTML", Language = "html" },
41+
new CodeBlockLanguageModel { Label = "JavaScript", Language = "javascript" },
42+
new CodeBlockLanguageModel { Label = "CSS", Language = "css" },
43+
new CodeBlockLanguageModel { Label = "Plain Text", Language = "plaintext" }
44+
};
45+
private List<ToolbarItemModel> Tools = new List<ToolbarItemModel>()
46+
{
47+
new ToolbarItemModel() { Command = ToolbarCommand.Undo },
48+
new ToolbarItemModel() { Command = ToolbarCommand.Redo },
49+
new ToolbarItemModel() { Command = ToolbarCommand.Separator },
50+
new ToolbarItemModel() { Command = ToolbarCommand.CodeBlock },
51+
new ToolbarItemModel() { Command = ToolbarCommand.Separator },
52+
new ToolbarItemModel() { Command = ToolbarCommand.Bold },
53+
new ToolbarItemModel() { Command = ToolbarCommand.Italic },
54+
new ToolbarItemModel() { Command = ToolbarCommand.Underline },
55+
new ToolbarItemModel() { Command = ToolbarCommand.StrikeThrough },
56+
new ToolbarItemModel() { Command = ToolbarCommand.InlineCode },
57+
new ToolbarItemModel() { Command = ToolbarCommand.CreateLink },
58+
new ToolbarItemModel() { Command = ToolbarCommand.Image },
59+
new ToolbarItemModel() { Command = ToolbarCommand.CreateTable },
60+
new ToolbarItemModel() { Command = ToolbarCommand.Blockquote },
61+
new ToolbarItemModel() { Command = ToolbarCommand.Separator },
62+
new ToolbarItemModel() { Command = ToolbarCommand.BulletFormatList },
63+
new ToolbarItemModel() { Command = ToolbarCommand.NumberFormatList },
64+
new ToolbarItemModel() { Command = ToolbarCommand.Separator },
65+
new ToolbarItemModel() { Command = ToolbarCommand.Formats },
66+
new ToolbarItemModel() { Command = ToolbarCommand.Alignments },
67+
new ToolbarItemModel() { Command = ToolbarCommand.Separator },
68+
new ToolbarItemModel() { Command = ToolbarCommand.Outdent },
69+
new ToolbarItemModel() { Command = ToolbarCommand.Indent },
70+
new ToolbarItemModel() { Command = ToolbarCommand.Separator },
71+
new ToolbarItemModel() { Command = ToolbarCommand.FontColor },
72+
new ToolbarItemModel() { Command = ToolbarCommand.BackgroundColor },
73+
new ToolbarItemModel() { Command = ToolbarCommand.FontName },
74+
new ToolbarItemModel() { Command = ToolbarCommand.FontColor },
75+
new ToolbarItemModel() { Command = ToolbarCommand.Separator },
76+
new ToolbarItemModel() { Command = ToolbarCommand.LowerCase },
77+
new ToolbarItemModel() { Command = ToolbarCommand.UpperCase },
78+
new ToolbarItemModel() { Command = ToolbarCommand.Separator },
79+
new ToolbarItemModel() { Command = ToolbarCommand.SourceCode },
80+
};
81+
}
82+
83+
```
84+
85+
In this example:
86+
87+
* The **Languages** array defines four supported languages: JavaScript, Python, HTML, and CSS.
88+
* The **DefaultLanguage** is set to **javascript**, so new code blocks default to JavaScript.
89+
* Each language object specifies a **Language** (for internal use, e.g., syntax highlighting) and a **Label** (displayed in the dropdown).
90+
91+
## Integrating syntax highlighters
92+
93+
To enhance code block readability, integrate a third-party syntax highlighter like [Prism.js](https://prismjs.com/) or [Highlight.js](https://highlightjs.org/), which supports numerous languages and customizable themes. Although live code block highlighting (real-time syntax highlighting during editing) is not possible in the Rich Text Editor, The highlighter can apply color-coded formatting to code blocks when the content is displayed on the frontend, such as in blog posts, website content, or preview mode. This ensures a polished presentation for end users.
94+
95+
## Tips for editing around code blocks
96+
97+
Editing content around code blocks requires care to preserve code integrity and maintain clean formatting. Follow these tips for a smooth editing experience:
98+
* **Inserting Text Before a Code Block**: Place the cursor at the start of the code block’s first line and press `Enter` to create an empty line above. Press Enter again to start a new paragraph for text.
99+
* **Inserting Text After a Code Block**: Place the cursor at the end of the code block’s last line and press `Enter` three times to exit the code block and create a new paragraph below.
100+
* **Preserving Formatting When Pasting**: Paste code into a code block using `Ctrl+Shift+V` (or `Cmd+Shift+V` on macOS) to avoid external formatting (e.g., fonts or colors) and maintain the monospaced style.
101+
* **Changing Languages**: When switching the language of a code block via the dropdown, verify that the code aligns with the new language for accurate syntax highlighting in the rendered output.
102+
* **Previewing Content**: Since live syntax highlighting is not available during editing, use the editor’s preview mode to verify how code blocks render with syntax highlighting before publishing.
103+
104+
## Enabling tab-based line indentation in code blocks
105+
106+
The Code Block feature supports tab-based indentation to align code properly, crucial for languages like Python where indentation is syntactically significant. The Rich Text Editor does not provide a specific property to configure the indentation character, but indentation can be enabled using the editor’s default behavior for the Tab key, toolbar commands, or custom event handling.
107+
108+
To enable tab-based indentation:
109+
110+
* **Using the Tab Key**: Pressing `Tab` within a code block typically inserts a tab character (\t) or spaces (usually four, depending on the editor’s default configuration). Use `Shift+Tab` to outdent selected lines.
111+
* **Toolbar Commands**: Include the `Indent` and `Outdent` buttons in the toolbar to increase or decrease indentation.
File renamed without changes.

0 commit comments

Comments
 (0)