Skip to main content

set-text-color

Description

Fires when setting a text color and/or a background text color

Usage

"set-text-color": (ITextColor) => boolean | void;

interface ITextColor {
color?: string;
background?: string;
}

Parameters

The callback of the set-text-color event can take an object with the following parameters:

  • color - a text color
  • background - a text background color
info

For handling the inner events you can use the Event Bus methods

Example

// initialize RichText
const editor = new richtext.Richtext("#root", {
// configuration properties
});
// subscribe to the "set-text-color" event
editor.api.on("set-text-color", (obj) => {
console.log(obj);
console.log("The text color and/or background text color were changed");
});
// apply text color and background
editor.api.exec("set-text-color", {
color: "red",
background: "blue"
});

Change log: The event was added in v2.0