Skip to main content

getValue()

Description

Returns the RichText value

Usage

getValue(encoder?: any): string;

Parameters

  • encoder - (optional) a parser used to encode the RichText's content into a custom format. The following formats are available: html (default) and text

You can get the required encoder in the following way:

const toTextEncoder = richtext.text.toText; // text encoder
const toHTMLEncoder = richtext.html.toHTML; // html encoder

Example

const editor = new richtext.Richtext("#root", {
value: "Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos." // sets the default value (HTML format)
// other configuration properties
});

const toTextEncoder = richtext.text.toText;
const editor_value = editor.getValue(toTextEncoder);
console.log(editor_value);

Change log: The method was updated in v2.0. The mode parameter was removed. The encoder parameter was added