BlazorBasics.RichTextEditor 1.0.7

dotnet add package BlazorBasics.RichTextEditor --version 1.0.7                
NuGet\Install-Package BlazorBasics.RichTextEditor -Version 1.0.7                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BlazorBasics.RichTextEditor" Version="1.0.7" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BlazorBasics.RichTextEditor --version 1.0.7                
#r "nuget: BlazorBasics.RichTextEditor, 1.0.7"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install BlazorBasics.RichTextEditor as a Cake Addin
#addin nuget:?package=BlazorBasics.RichTextEditor&version=1.0.7

// Install BlazorBasics.RichTextEditor as a Cake Tool
#tool nuget:?package=BlazorBasics.RichTextEditor&version=1.0.7                

Nuget Nuget

Description

A simple Rich Text Editor for Blazor Server or Blazor WebAssembly applications. This rich text editor is based in Quill JavaScript.

How to use

Nugget installation

PM> Install-Package BlazorBasics.RichTextEditor

Or clone the repository and add the project to your solution.<br/> Add the component where you want to show rich text editor like this example:


<RichTextEditorComponent Html=HtmlMarkupString OnSave="SaveHtml"/>

@code{
	MarkupString HtmlMarkupString = 
		new MarkupString("<p>A long time ago in a galaxi far, far away...</p>");
	
	void SaveHtml(string html){
		//process your data
	}
}

Options

  • Show/Hide Save button into the menu
  • Disable paste images if you don't like to allow base64 image insert into the document
  • Show/Hide Images button to allow or not user can insert images
  • You can use your API to upload images

Upload Images to the API

You will receive a object from the editor like

public class FileUpload
{
    public string FileName { get; set; }
    public byte[] FileBytes { get; set; }

    public FileUpload(string fileName, byte[] fileBytes)
    {
        FileName = fileName;
        FileBytes = fileBytes;
    }
}

Then need a Task to return a string with the URL about where is located the image. If don't return a url and return string.Empty editor add the image into de document like a image/base64 but you also can manage the image, to register in a database for example.

<RichTextEditorComponent Html=HtmlMarkupString OnSave="SaveHtml" UploadFile=UploadFile/>

@code{
	MarkupString HtmlMarkupString = 
		new MarkupString("<p>A long time ago in a galaxi far, far away...</p>");
	
	void SaveHtml(string html){
		//process your data
	}

    async Task<string> UploadFile(FileUpload file)
    {          
        string url = await YourApiToUploadFiles.SaveFile(file);
		return url;
    }
}

Disable upload and paste images

<RichTextEditorComponent Html=HtmlMarkupString OnSave="SaveHtml" HideImageButton=true AvoidPasteImages=true/>

@code{
	MarkupString HtmlMarkupString = 
		new MarkupString("<p>A long time ago in a galaxi far, far away...</p>");
	
	void SaveHtml(string html){
		//process your data
	}
}

If you want to use a external save button

If you want to use external save button it's much better use the property HideSaveButton=true to avoid user can see 2 save buttons, into the editor and outside the editor

<RichTextEditorComponent Html=HtmlMarkupString OnSave="SaveHtml" @ref=Editor HideSaveButton=true />

<button @onclick=Save>Save</button>

@code{
	RichTextEditorComponent Editor;
	MarkupString HtmlMarkupString = 
		new MarkupString("<p>A long time ago in a galaxi far, far away...</p>");
	string Html;

	void SaveHtml(string html){
		Html = html;
	}

	async Task Save(){
		await Editor.GetContent();
		//process your data
	}
}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.7 86 11/8/2024
1.0.6 84 10/30/2024
1.0.5 365 1/13/2024
1.0.4 403 8/11/2023
1.0.3 179 8/10/2023
1.0.2 167 8/3/2023
1.0.1 194 7/23/2023

Fixed undefined exception with dotNetObjectReference in JAVASCRIPT.