|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: Events in Blazor Block Editor Component | Syncfusion |
| 4 | +description: Checkout and learn about Events with Blazor Block Editor component in Blazor WebAssembly App. |
| 5 | +platform: Blazor |
| 6 | +control: Block Editor |
| 7 | +documentation: ug |
| 8 | +--- |
| 9 | + |
| 10 | +# Events in Blazor Block Editor Component |
| 11 | + |
| 12 | +The Block Editor component provides a comprehensive set of events that allow you to monitor and respond to various user interactions and editor state changes. These events enable you to implement custom behaviors, validation, logging, and integration with other systems. |
| 13 | + |
| 14 | +## Created |
| 15 | + |
| 16 | +The `Created` event is triggered when the Block Editor component is successfully initialized and ready for use. This event is useful for performing setup operations or initializing additional features after the editor is created. |
| 17 | + |
| 18 | +```cshtml |
| 19 | +
|
| 20 | +@using Syncfusion.Blazor.Block Editor; |
| 21 | +
|
| 22 | +<div id="container"> |
| 23 | + <SfBlock Editor ID="blockeditor" Created="@OnCreated"> |
| 24 | + </SfBlock Editor> |
| 25 | +</div> |
| 26 | +@code { |
| 27 | +
|
| 28 | + private void OnCreated() |
| 29 | + { |
| 30 | + // Your required actions here |
| 31 | + } |
| 32 | +} |
| 33 | +
|
| 34 | +``` |
| 35 | + |
| 36 | +## BlockChanged |
| 37 | + |
| 38 | +The `BlockChanged` event is triggered whenever the editor blocks are changed. This includes block additions, deletions, or any structural modifications to the document. Its event handler receives details about the changes. |
| 39 | + |
| 40 | +```cshtml |
| 41 | +
|
| 42 | +@using Syncfusion.Blazor.Block Editor; |
| 43 | +
|
| 44 | +<div id="container"> |
| 45 | + <SfBlock Editor ID="blockeditor" BlockChanged="@BlockChanged"> |
| 46 | + </SfBlock Editor> |
| 47 | +</div> |
| 48 | +@code { |
| 49 | +
|
| 50 | + private void BlockChanged(BlockChangedEventArgs args) |
| 51 | + { |
| 52 | + // Your required actions here |
| 53 | + } |
| 54 | +} |
| 55 | +
|
| 56 | +``` |
| 57 | + |
| 58 | +## SelectionChanged |
| 59 | + |
| 60 | +The `SelectionChanged` event is triggered when the user's text selection changes within the editor. The event arguments contain details about the new selection, which can be useful for updating UI elements. |
| 61 | + |
| 62 | +```cshtml |
| 63 | +
|
| 64 | +@using Syncfusion.Blazor.Block Editor; |
| 65 | +
|
| 66 | +<div id="container"> |
| 67 | + <SfBlock Editor ID="blockeditor" SelectionChanged="@SelectionChanged"> |
| 68 | + </SfBlock Editor> |
| 69 | +</div> |
| 70 | +@code { |
| 71 | +
|
| 72 | + private void SelectionChanged(SelectionChangedEventArgs args) |
| 73 | + { |
| 74 | + // Your required actions here |
| 75 | + } |
| 76 | +} |
| 77 | +
|
| 78 | +``` |
| 79 | + |
| 80 | +## Focus |
| 81 | + |
| 82 | +The `Focus` event is triggered when the editor gains focus. This is useful for updating UI states and managing editor interactions. |
| 83 | + |
| 84 | +```cshtml |
| 85 | +
|
| 86 | +@using Syncfusion.Blazor.Block Editor; |
| 87 | +
|
| 88 | +<div id="container"> |
| 89 | + <SfBlock Editor ID="blockeditor" Focus="@Focus"> |
| 90 | + </SfBlock Editor> |
| 91 | +</div> |
| 92 | +@code { |
| 93 | +
|
| 94 | + private void Focus(FocusEventArgs args) |
| 95 | + { |
| 96 | + // Your required actions here |
| 97 | + } |
| 98 | +} |
| 99 | +
|
| 100 | +``` |
| 101 | + |
| 102 | +## Blur |
| 103 | + |
| 104 | +The `Blur` event is triggered when the editor loses focus. This is commonly used for auto-saving content or hiding UI elements that should only be visible when the editor is active. |
| 105 | + |
| 106 | +```cshtml |
| 107 | +
|
| 108 | +@using Syncfusion.Blazor.Block Editor; |
| 109 | +
|
| 110 | +<div id="container"> |
| 111 | + <SfBlock Editor ID="blockeditor" Blur="@Blur"> |
| 112 | + </SfBlock Editor> |
| 113 | +</div> |
| 114 | +@code { |
| 115 | +
|
| 116 | + private void Blur(BlurEventArgs args) |
| 117 | + { |
| 118 | + // Your required actions here |
| 119 | + } |
| 120 | +} |
| 121 | +
|
| 122 | +``` |
| 123 | + |
| 124 | +## PasteCleanupStarting |
| 125 | + |
| 126 | +The `PasteCleanupStarting` event is triggered before content is pasted into the editor. This event allows you to inspect, modify, or cancel the paste operation via its event arguments. |
| 127 | + |
| 128 | +```cshtml |
| 129 | +
|
| 130 | +@using Syncfusion.Blazor.Block Editor; |
| 131 | +
|
| 132 | +<div id="container"> |
| 133 | + <SfBlock Editor ID="blockeditor" PasteCleanupStarting="@PasteCleanupStarting"> |
| 134 | + </SfBlock Editor> |
| 135 | +</div> |
| 136 | +@code { |
| 137 | +
|
| 138 | + private void PasteCleanupStarting(PasteCleanupStartingEventArgs args) |
| 139 | + { |
| 140 | + // Your required actions here |
| 141 | + } |
| 142 | +} |
| 143 | +
|
| 144 | +``` |
| 145 | + |
| 146 | +## PasteCleanupCompleted |
| 147 | + |
| 148 | +The `PasteCleanupCompleted` event is triggered after content has been successfully pasted into the editor. This is useful for post-processing pasted content or updating related UI elements. |
| 149 | + |
| 150 | +```cshtml |
| 151 | +
|
| 152 | +@using Syncfusion.Blazor.Block Editor; |
| 153 | +
|
| 154 | +<div id="container"> |
| 155 | + <SfBlock Editor ID="blockeditor" PasteCleanupCompleted="@PasteCleanupCompleted"> |
| 156 | + </SfBlock Editor> |
| 157 | +</div> |
| 158 | +@code { |
| 159 | +
|
| 160 | + private void PasteCleanupCompleted(PasteCleanupCompletedEventArgs args) |
| 161 | + { |
| 162 | + // Your required actions here |
| 163 | + } |
| 164 | +} |
| 165 | +
|
| 166 | +``` |
0 commit comments