# RichTextEditorLegacy
## Description
RichTextEditor is a WYSIWYG text editor, utilizing the famous Quill.js library.
## Parameters
| Name | Type | Default Value | Description |
| :--- | :--- | :------------ | :---------- |
| Classes | `BitRichTextEditorLegacyClassStyles?` | null | Custom CSS classes for different parts of the rich text editor. |
| EditorTemplate | `RenderFragment?` | null | Custom template for the editor content. |
| FullToolbar | `bool` | false | Renders the full toolbar with all of the available features. |
| Modules | `IEnumerable<BitRichTextEditorLegacyModule>?` | null | Custom Quill modules to be registered at first render (<see href="https://quilljs.com/docs/guides/building-a-custom-module"/>). |
| OnEditorReady | `EventCallback<string>` | | Callback for when the editor instance is created and ready to use. |
| OnQuillReady | `EventCallback` | | Callback for when the Quill scripts is loaded and the Quill api is ready to use. It allows for custom actions to be performed at that moment. |
| OnQuillModulesReady | `EventCallback` | | Callback for when the scripts of the provided Quill Modules are loaded and their api are ready to use. |
| Placeholder | `string?` | null | The placeholder value of the editor. |
| ReadOnly | `bool` | false | Makes the editor readonly. |
| Reversed | `bool` | false | Reverses the location of the Toolbar and the Editor. |
| Styles | `BitRichTextEditorLegacyClassStyles?` | null | Custom CSS styles for different parts of the rich text editor. |
| Theme | `BitRichTextEditorLegacyTheme?` | null | The theme of the editor. |
| ToolbarTemplate | `RenderFragment?` | null | Custom template for the toolbar content. |
| AriaLabel | `string?` | null | Gets or sets the accessible label for the component, used by assistive technologies. |
| Class | `string?` | null | Gets or sets the CSS class name(s) to apply to the rendered element. |
| Dir | `BitDir?` | null | Gets or sets the text directionality for the component's content. |
| HtmlAttributes | `Dictionary<string, object>` | new Dictionary<string, object>() | Captures additional HTML attributes to be applied to the rendered element, in addition to the component's parameters. |
| Id | `string?` | null | Gets or sets the unique identifier for the component's root element. |
| IsEnabled | `bool` | true | Gets or sets a value indicating whether the component is enabled and can respond to user interaction. |
| Style | `string?` | null | Gets or sets the CSS style string to apply to the rendered element. |
| TabIndex | `string?` | null | Gets or sets the tab order index for the component when navigating with the keyboard. |
| Visibility | `BitVisibility` | BitVisibility.Visible | Gets or sets the visibility state (visible, hidden, or collapsed) of the component. |
## Public Members
| Name | Type | Default Value | Description |
| :--- | :--- | :------------ | :---------- |
| GetText | `Func<ValueTask<string>>` | | Gets the current text content of the editor. |
| GetHtml | `Func<ValueTask<string>>` | | Gets the current html content of the editor. |
| GetContent | `Func<ValueTask<string>>` | | Gets the current content of the editor in JSON format. |
| SetText | `Action<ValueTask<string?>>` | | Sets the current text content of the editor. |
| SetHtml | `Action<ValueTask<string?>>` | | Sets the current html content of the editor. |
| SetContent | `Action<ValueTask<string?>>` | | Sets the current content of the editor in JSON format. |
| UniqueId | `Guid` | Guid.NewGuid() | Gets the readonly unique identifier for the component's root element, assigned when the component instance is constructed. |
| RootElement | `ElementReference` | | Gets the reference to the root HTML element associated with this component. |
## Enums
### BitRichTextEditorLegacyTheme Enum
| Name | Value | Description |
| :--- | :--- | :---------- |
| Snow | 0 | |
| Bubble | 1 | |
### BitVisibility Enum
| Name | Value | Description |
| :--- | :--- | :---------- |
| Visible | 0 | The content of the component is visible. |
| Hidden | 1 | The content of the component is hidden, but the space it takes on the page remains (visibility:hidden). |
| Collapsed | 2 | The component is hidden (display:none). |
### BitDir Enum
| Name | Value | Description |
| :--- | :--- | :---------- |
| Ltr | 0 | Ltr (left to right) is to be used for languages that are written from the left to the right (like English). |
| Rtl | 1 | Rtl (right to left) is to be used for languages that are written from the right to the left (like Arabic). |
| Auto | 2 | Auto lets the user agent decide. It uses a basic algorithm as it parses the characters inside the element until it finds a character with a strong directionality, then applies that directionality to the whole element. |
## Sub Classes
### BitRichTextEditorLegacyClassStyles Properties
| Name | Type | Default Value | Description |
| :--- | :--- | :------------ | :---------- |
| Root | `string?` | null | Custom CSS classes/styles for the root of the BitRichTextEditorLegacy. |
| Toolbar | `string?` | null | Custom CSS classes/styles for the toolbar of the BitRichTextEditorLegacy. |
| Editor | `string?` | null | Custom CSS classes/styles for the editor container of the BitRichTextEditorLegacy. |
### BitRichTextEditorLegacyModule Properties
Represents a Quill custom module specifications.
| Name | Type | Default Value | Description |
| :--- | :--- | :------------ | :---------- |
| Name | `string` | | The name of the Quill custom module. |
| Src | `string` | | The script src of the Quill custom module to load at firt render. |
| Config | `object` | | The configuration object that applies the settings of the Quill custom module. |
## Examples
\n**Basic**:
```razor
```
\n**Placeholder**:
```razor
```
\n**Readonly**:
```razor
```
\n**Reversed**:
```razor
```
\n**FullToolbar**:
```razor
```
\n**Style & Class**:
```razor
```
\n**Get APIs**:
```razor
GetText
GetHtml
GetContent
SetText
SetHtml
SetContent
```
```csharp
private BitRichTextEditorLegacy setEditorRef = default!;
private string? setValue;
private async Task SetText()
{
await setEditorRef.SetText(setValue);
}
private async Task SetHtml()
{
await setEditorRef.SetHtml(setValue);
}
private async Task SetContent()
{
await setEditorRef.SetContent(setValue);
}
```
\n**Templates**:
```razor
```
\n**Custom fonts**:
```razor
```
```csharp
private async Task HandleOnQuillReady()
{
await JSRuntime.InvokeVoidAsync("registerQuillCustomFonts");
}
```
\n**Quill custom modules**:
```razor
```
```csharp
private List modules = [
new()
{
Name = "imageResize",
Src = "/scripts/quill-image-resize-module.js",
Config = new { displaySize = true }
}
];
```
result:
@result``` ```csharp private BitRichTextEditorLegacy getEditorRef = default!; private string? result; private async Task GetText() { result = await getEditorRef.GetText(); } private async Task GetHtml() { result = await getEditorRef.GetHtml(); } private async Task GetContent() { result = await getEditorRef.GetContent(); } ``` \n**Set APIs**: ```razor
this is bold
this is italic
this is italic & bold
this is a sample of adding custom fonts to the BitRichTextEditorLegacy!