TinyMCE.Blazor 2.0.0

dotnet add package TinyMCE.Blazor --version 2.0.0                
NuGet\Install-Package TinyMCE.Blazor -Version 2.0.0                
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="TinyMCE.Blazor" Version="2.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TinyMCE.Blazor --version 2.0.0                
#r "nuget: TinyMCE.Blazor, 2.0.0"                
#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 TinyMCE.Blazor as a Cake Addin
#addin nuget:?package=TinyMCE.Blazor&version=2.0.0

// Install TinyMCE.Blazor as a Cake Tool
#tool nuget:?package=TinyMCE.Blazor&version=2.0.0                

TinyMCE Blazor component

About

This package is a wrapper around TinyMCE to facilitate its use in Blazor applications.

Issues

Have you found an issue with tinymce-blazor or do you have a feature request? Open up an issue and let us know or submit a pull request. Note: for issues related to TinyMCE please visit the TinyMCE repository.

TinyMCE Quick Start guide

Create a new project and add the TinyMCE.Blazor component

From the command line

Create a new project

dotnet new blazorserver -o BlazorApp --no-https

Go into your new directory

cd BlazorApp

Install the TinyMCE Blazor integration

dotnet add package TinyMCE.Blazor

Verify by checking the ItemGroup references in BlazorApp.csproj

  <script src="_framework/blazor.server.js"></script>
  <script src="_content/TinyMCE.Blazor/tinymce-blazor.js"></script>
  ...
Using Visual Studio

On your Visual Studio select New Project and Blazor Server App template.

Use the NuGet package manager console and install the tinyMCE.Blazor package using Install-Package TinyMCE.Blazor

Using the Editor Component

Add the Editor component to your page

You can use the component name only with the using directive

@using TinyMCE.Blazor
<Editor />

Or you can refer to the component using its package name

<TinyMCE.Blazor.Editor />

To use the Editor output you can access the Value property or the read-only Text property.

For code samples check out this Blazor sample project using the TinyMCE Blazor integration

TinyMCE Blazor technical reference

Configuring the TinyMCE Blazor integration

The editor component accepts the following properties:

<Editor
  Id="uuid"
  Inline=false
  CloudChannel="7"
  Value=""
  Disable=false
  JsConfSrc="<path_to_jsObj>"
  Conf="@yourConf"
  ApiKey="your-api-key"
  LicenseKey="your-license-key"
  ClassName="tinymce-wrapper"
/>

None of the configuration properties are required for TinymceBlazor to work.

ApiKey

Tiny Cloud API key. Required for deployments using the Tiny Cloud to provide the TinyMCE editor.

Default value: no-api-key Type: string

Example using ApiKey
<Editor
  ApiKey="your-api-key"
/>
CloudChannel

Specifies the Tiny Cloud channel to use. For more information on TinyMCE development channels, see: Specifying the TinyMCE editor version deployed from Cloud - dev, testing, and stable releases

Default value: '5' Type: string

Example using CloudChannel
<Editor
  CloudChannel="5-dev"
/>
LicenseKey

Specifies the license key to be used with TinyMCE. This option does not need to be specified if you are using TinyMCE cloud.

Example using LicenseKey
<Editor
  LicenseKey="your-license-key"
/>
Id

Specified an Id for the editor. Used for retrieving the editor instance using the tinymce.get('ID') method.

Default value: Automatically generated UUID Type: string

Example using Id
<Editor
  Id="my-unique-identifier"
/>
Inline

Set the editor to inline mode.

Default value: false Type: bool

Example using Inline
<Editor
  Inline=true
/>
Disable

Set the editor to readonly mode.

Default value: false Type: bool

Example using Disable
<Editor
  Disable=@disable
/>
<button @onclick="@(() => disable = !disable)">Toggle</button>
JsConfSrc

Use a JS object as base configuration for the editor by specifying the path to the object relative to the window object.

Default: null Type: string

Example using JsConfSrc

In your _Host.cshtml:

window.sample = {
  height: 300,
  toolbar: 'undo redo | bold italic'
}

In your component:

<Editor
  JsConfSrc="sample"
/>
Conf

Specify a set of properties for the Tinymce.init method to initialize the editor.

Default value: null Type: Dictionary<string, object>

Example using Conf
<Editor
  Conf="@editorConf"
/>

@code {
  private Dictionary<string. object> editorConf = new Dictionary<string, object>{
    {"toolbar", "undo redo | bold italic"},
    {"width", 400}
  };
}
ClassName

Specify the class for the Editor container div in the component. This div is the parent of the Editor and adding styles to it will not add styles to the editor.

Example using ClassName
<Editor ClassName="my-editor-container" />

<Editor ClassName="@((isEditorActive) ? "active-editor-div" : "default-editor-div")" />

Component binding

Input binding

The @bind-Value directive can be used to create a two-way data binding.

Example using input binding
<Editor
  @bind-Value=content
/>

<textarea @bind=content @bind:event="oninput"></textarea>

@code {
  private string content = "<p>Hello world</p>";
}
Enable Form Validation

When the Editor is used part of a form inside an EditForm, specifying Field directive will enable form validation behaviours like Blazor's build in form components.

By default the Editor trigger validation when onchange event fires. You can change the trigger to oninput by specifying ValidateOnInput to true.

<EditForm EditContext="@CurrentEditContext">
    <DataAnnotationsValidator />
    <p>
        <label>Content</label>

        <Editor Field="() => Model.Content"
          @bind-Value="Model.Content"
          ValidationOnInput="@true"/>

        <ValidationMessage For="() => Model.Content" />
    </p>
</EditForm>

@code {
    private Model Model { get; set; } = new Model();
    private EditContext? CurrentEditContext;

    protected override void OnInitialized()
    {
        CurrentEditContext = new(Model);
        base.OnInitialized();
    }
}
Binding Text output

Starting from v0.0.4 you can use the @bind-Text property to hook the text output of the editor into a variable

Product Compatible and additional computed target framework versions.
.NET 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 (3)

Showing the top 3 NuGet packages that depend on TinyMCE.Blazor:

Package Downloads
DragonFly.Client

Headless CMS based on ASP.NET Core and Blazor

ZauberCMS.Components

ZauberCMS components package

InputTinyMCEEditor.Blazor

An Input component wrapping TinyMCE Blazor Component, to be used inside an EditForm component. It offers the same validations experience as Blazor’s build-in form components out of the box.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on TinyMCE.Blazor:

Repository Stars
CervantesSec/cervantes
Cervantes is an open-source, collaborative platform designed specifically for pentesters and red teams. It serves as a comprehensive management tool, streamlining the organization of projects, clients, vulnerabilities, and reports in a single, centralized location.
Version Downloads Last updated
2.0.0 2,828 11/5/2024
1.0.4 470,093 5/20/2022
1.0.3 35,035 4/27/2022
1.0.2 5,395 4/8/2022
1.0.1 3,818 3/22/2022
1.0.0 1,053 3/22/2022
0.0.10 1,000 3/21/2022
0.0.9 17,250 12/8/2021
0.0.8 9,973 10/13/2021
0.0.7 24,601 8/26/2021
0.0.6 6,590 5/17/2021
0.0.5 959 5/12/2021
0.0.4 982 5/7/2021
0.0.3 4,629 1/10/2021
0.0.2 934 1/7/2021
0.0.1 1,019 1/6/2021

# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

## 2.0.0 - 2024-10-31

### Added
- New `LicenseKey` property to be used with self hosted TinyMCE.

### Changed
- Default cloud channel to '7'.
- Dropped support for .NET 5 and 6 in favor of 8 since they are out of service more details can be found at https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core

### Fixed
- Custom ClassName would not be used if the component was not rendered inside an EditForm. Patch contributed by Kamil Kuklinski.

## 1.0.4 - 2022-05-20

### Fixed
- Disposing of dot net reference calls
- `InsertContent` correct function call

## 1.0.3 - 2022-04-27

### Changed
- Chunking size limit value

## 1.0.2 - 2022-04-08

### Added
- `InsertContent` API to insert content at caret position

### Fixed
- Default cloud channel back to '6'
- Editor not cleaning up pop-up after disposing

## 1.0.1 - 2022-03-23

### Fixed
- Default cloud channel reverted to '5' until the release of '6'

## 1.0.0 - 2022-03-08

### Changed
- License: Code provided under MIT license
- Default cloud channel to '6'

## 0.0.9 - 2021-12-04

### Added
- Support for EditContext

## 0.0.8 - 2021-10-13

### Added
- ClassName parameter for outside container

## 0.0.7 - 2021-08-26

### Added
- Disable property

## 0.0.6 - 2021-05-18

### Changed
- Remove event listeners when disposing

## 0.0.5 - 2021-05-12

### Changed
- Setup callback to execute after initial setup

## 0.0.4 - 2021-05-07

### Added
- Support for text output
- IDisposable implementation

### Changed
- Typo triggering multiple script downloads
- Fix reference when reseting to null

## 0.0.3 - 2021-01-11

### Changed
* Update package metadata

## 0.0.2 - 2021-01-07

### Changed
* Update package metadata

## 0.0.1 - 2021-01-07

### Added
* Editor wrapper for blazor