AI agents: the content index is at /llms.txt. Every page is also available as Markdown — send the request header Accept: text/markdown, or append .md to the page URL.
Xperience Docs

Cookie consent

We use necessary cookies (opens in a new tab) to run our website and improve your experience while browsing. Additional cookies are only used with your consent. You may revoke your consent on the Cookies Policy (opens in a new tab) page or in your browser at any time.

Configure (opens in a new tab)
  • Documentation
    InstallationUsing the Xperience interfaceDeveloping websitesConfiguring XperienceManaging usersSecuring websitesDeploying websitesManaging website contentMultilingual websitesMacro expressionsExternal utilitiesIntegrating 3rd party systemsCustom developmentE-commerce featuresOn-line marketing featuresRelease notes - Xperience 13Xperience terminology glossary
  • Tutorial
    Using the Xperience interfaceDeveloper tutorialBusiness tutorialResource hub for marketers
  • API Examples
    ConfigurationContent managementDevelopmentE-commerceOn-line marketingSocial media
  • Community Questions & Answers (opens in a new tab)
  • Contact support (opens in a new tab)
  1. Home
  2. Configuring Xperience
  3. Configuring the environment for content editors
  4. Configuring the rich text editor for page builder
  5. Implementing rich text editor plugins

Implementing rich text editor plugins


Was this page helpful?

Send us feedback Go back to top

If your editors are missing a feature in the rich text editor for the page builder, you can extend the editor via plugins.

You can develop your own custom plugins or add existing Froala plugins. Many of the default Froala plugins are already included in the rich text editor. See the Froala documentation⁠ (opens in a new tab) to find a list of all available plugins and instructions on how to add them. Froala plugins are covered by your Kentico Xperience license, so you do not need to purchase them separately.

Certain plugins were adjusted for the Xperience environment and are not identical to the corresponding default Froala plugins even though they share the same name, e.g., Image or Link.

Implementing plugins

Within your live site project, create a JavaScript file for your plugins. It is recommended to store this file in the project's ~/wwwroot/Scripts or ~/Scripts folder.

Within the file, implement and add plugins according to the Froala documentation⁠ (opens in a new tab).

JS
(function (pageBuilder) {
    var richTextEditor = pageBuilder.richTextEditor = pageBuilder.richTextEditor || {};

    // Retrieves the collection of plugins
    var plugins = richTextEditor.plugins = richTextEditor.plugins || [];

    // Creates a plugin
    var myFirstPlugin = function (FroalaEditor) {
            ...
        };

    // Adds the plugin to the collection
    plugins.push(myFirstPlugin);
})(window.kentico.pageBuilder);

To make the plugins available for your entire site, include the scripts containing the plugins into the website's main layout (e.g. ~/Views/Shared/_Layout.cshtml). The scripts with plugins must be registered after page builder scripts.

C#
@using Kentico.PageBuilder.Web.Mvc

@* Registers page builder scripts *@
@Html.Kentico().PageBuilderScripts()

@* Registers plugin scripts *@
@if (Context.Kentico().PageBuilder().EditMode)
{     
    <script src="~/Scripts/sampleButtonPlugin.js"></script>
}
C#
@using Kentico.PageBuilder.Web.Mvc

@* Registers page builder scripts *@
@Html.Kentico().PageBuilderScripts()

@* Registers plugin scripts *@
@if (Context.Kentico().PageBuilder().EditMode)
{
    @Scripts.Render("~/Scripts/SamplePlugins.js")
}

After you create a new plugin, you need to add the given plugin to a toolbar configuration to make it available in the rich text editor.

Example – Creating a custom toolbar button

The following example shows you how to create a simple plugin that allows you to replace occurrences of the word 'you' with 'Thou'.

Create a new JavaScript file: ~/Scripts/sampleButtonPlugin.js

JSsampleButtonPlugin.js
(function (pageBuilder) {
    var richTextEditor = pageBuilder.richTextEditor = pageBuilder.richTextEditor || {};

    // Retrieves the collection of plugins
    var plugins = richTextEditor.plugins = richTextEditor.plugins || [];
    // Creates a new Sample Button
    var sampleButtonPlugin = function (FroalaEditor) {
            FroalaEditor.DefineIcon("sampleButtonIcon", { SVG_KEY: "help" });
            FroalaEditor.RegisterCommand("sampleButton", {
                title: "Sample Button",
                icon: "sampleButtonIcon",
                callback: function () {
                      var htmlContent = this.html.get();
                      htmlContent=htmlContent.replace(/you/gi, 'Thou');
                      this.html.set(htmlContent);
                }
            });
        };
    // Adds the plugin to the collection
    plugins.push(sampleButtonPlugin);

    // Retrieves the collection of toolbar configurations
    var configurations = richTextEditor.configurations = richTextEditor.configurations || {};
    // Overrides the default toolbar configuration to display the plugin button
    configurations["default"] = {
        toolbarButtons: ['paragraphFormat', '|', 'sampleButton', 'bold', 'italic', 'underline', '|', 'align', 'formatOL', 'formatUL']
    };
})(window.kentico.pageBuilder);

~/Views/Shared/_Layout.cshtml* file:

C#_Layout.cshtml
@if (Context.Kentico().PageBuilder().EditMode)
{
    <script src="~/Scripts/sampleButtonPlugin.js"></script>
}
C#_Layout.cshtml
@if (Context.Kentico().PageBuilder().EditMode)
{
    @Scripts.Render("~/Scripts/sampleButtonPlugin.js")
}

The functionality is now available under the '?' button in the toolbar of the default Rich text widget.

Related pages

  • Using the Rich text widget
  • Configuring the rich text editor for page builder