Close Menu
Junkcommunity
    Facebook X (Twitter) Pinterest
    Monday, June 16
    Facebook X (Twitter) Pinterest
    Junkcommunity
    • Business Central
      • Consulting Firm
      • Commercial
      • Consumer Services
      • Digital marketing agency
    • Industrial
      • Airport
      • Real Estate
      • Work Space
    • Fashion
      • Hair Salon
    • Health
      • Healthcare
      • Baby care
      • Pet Products
    • Junk Stories
      • Home Automation
      • Home Space
      • DIY
      • Recycling
      • Resources
    • Medical Imaging
      • Smart tech products
      • Uncategorized
      • Azure Synapse machine learning
    Junkcommunity
    Home » How to Easily Add Custom Buttons to the SharePoint Rich Text Editor?

    How to Easily Add Custom Buttons to the SharePoint Rich Text Editor?

    Humberto WelchBy Humberto WelchSeptember 11, 2024No Comments3 Mins Read
    Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
    Share
    Facebook Twitter LinkedIn Pinterest Email

    The SharePoint rich text editor provides users with basic text formatting options out of the box.

    However, you may want additional functionality like buttons to add custom templates, insert brand assets, or apply specialized formatting.

    Fortunately, it’s straightforward to augment the rich text editor by adding custom buttons with JavaScript.

    We’ll walk through the whole process step-by-step in this article. By the end, you’ll know how to configure and code custom buttons that insert content into the editor with the click of a mouse!

    Prerequisites

    Before adding custom buttons to the rich text editor, make sure you have:

    • SharePoint Online – Will not work with SharePoint Server
    • Permission to add and customize Web Parts

    Some JavaScript knowledge is helpful but not required. We’ll provide code snippets you can reuse as-is.

    Step 1: Add a Content Editor Web Part

    The first step is to add a Content Editor Web Part (CEWP) to the page with the rich text editor. The CEWP allows executing custom JavaScript that modifies other Web Parts on that page.

    Here are the basic steps to add a CEWP:

    1. Edit the page
    2. Select “Add a Web Part” from the Web Part toolbar
    3. Choose the Content Editor Web Part
    4. Set its location below the rich text editor

    Step 2: Reference Editor JavaScript Library

    Next, reference the rich text editor’s JavaScript library in the CEWP. This library allows programmatically interacting with the editor through JavaScript.

    Here are the necessary script references:

    Step 3: Define Custom Button JavaScript

    Finally, we’ll write JavaScript to define the custom button and insert content when clicked:

    var customButton = new CustomButton({

      name: “Insert Custom Text”,

      icon: “Globe”,

      onClick: function() {

        SP.SOD.executeOrDelayUntilScriptLoaded(insertCustomText, ‘sp.richtext.js’);

      }

    });

    function insertCustomText() {

      var editor = SP.RTE.GetActiveEditor();

      editor.insertHtml(“This is custom text inserted!”);

    }

    Let’s break this down:

    • CustomButton defines button properties like the name, icon, and click handler
    • onClick calls our insertCustomText method
    • insertCustomText gets the active editor instance and inserts HTML

    Adjust the inserted content by customizing the .insertHtml() text.

    SharePoint rich text editor

    Adding Multiple Buttons

    To add another button, define and register another CustomButton:

    var secondButton = new CustomButton({

      // Button definition

    });

    customButton.register();

    secondButton.register();

    Ensure all buttons are registered by calling .register().

    Result: Custom Insert Buttons

    After adding JavaScript to define custom buttons, our customized rich text editor now has extra functionality:

    Recap

    To quickly recap the process:

    1. Added a Content Editor Web Part
    2. Referenced editor JavaScript library
    3. Wrote JavaScript for custom buttons

    This allowed creating custom insert buttons for the rich text editor with just a few lines of code.

    You can now augment any SharePoint rich text editor to better suit your needs. The possibilities are endless!

    Try adding buttons to insert templates, branding, signatures, and more. Turbocharge your editors using the simple framework outlined above.

    The SharePoint rich text editor allows authors to format text, add images and links, create tables, and more. This guide teaches you how to extend the editor.

    Humberto Welch
    Humberto Welch
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Humberto Welch
    • Website

    Related Posts

    Bridging Medicine and Code: Implementing Medical Imaging Standards

    April 5, 2025

    Why Some Mac DICOM Viewers Struggle with Large Dataset Loading?

    December 11, 2024

    Evaluating and Improving Web DICOM Viewer Speed

    August 22, 2024

    Comments are closed.

    Don't Miss

    The Ultimate Showdown: Wegovy vs Mounjaro – Which Weight Loss Medicine Works Better?

    Health May 9, 2025

    Discover the key differences between Mounjaro and Wegovy in their weight loss mechanisms, effectiveness, and…

    Medical vs. Non-Medical Weight Loss Services: Which Path Is Right For You?

    April 27, 2025

    Is Your Business Missing from Local Searches? Citation Consistency Could Be the Culprit

    April 26, 2025

    Bridging Medicine and Code: Implementing Medical Imaging Standards

    April 5, 2025
    Categories
    • Airport (2)
    • Azure Synapse machine learning (1)
    • Baby care (1)
    • Business Central (1)
    • Commercial (2)
    • Consulting Firm (2)
    • Consumer Services (4)
    • Digital marketing agency (5)
    • DIY (2)
    • Fashion (7)
    • Gear Accessories (1)
    • Hair Salon (1)
    • Health (8)
    • Healthcare (5)
    • Home Automation (1)
    • Home Space (3)
    • Industrial (1)
    • Junk Stories (8)
    • Medical Imaging (7)
    • Pet Products (3)
    • Real Estate (1)
    • Recycling (1)
    • Resources (1)
    • Smart tech products (3)
    • Uncategorized (12)
    • Work Space (1)
    Our Picks

    Should I Be Concerned That My Baby Carrier Is Causing Hip Issues?

    February 3, 2022

    Unleash the Power of DICOM Medical Imaging Data on Your Mac – It’s Easier Than You Think

    March 26, 2024

    What is the Importance of the Miami Trash Removal Services?

    December 27, 2018

    Tips to Know for Your Kitchen to Prep It for Resale

    July 3, 2019

    Subscribe to Updates

    Get the latest creative news from about Healthcare, Health, Fashion, Medical Imaging, Junk Stories and more.

    • Contact Us
    • Write For Us
    • Privacy Policy
    • Terms and Conditions
    © 2025 Designed and Developed by JunkCommunity

    Type above and press Enter to search. Press Esc to cancel.