Rich Text Editor expects a JS data file with an HTML string to display. Check the data sample below:
const text =
`<p>Hello World</p>
<p><a href="https://docs.webix.com/desktop__richtext.html">Rich Text Editor</a></p>
<p>Sample text</p>`;
Rich Text Editor has the following services to work with data:
1. Upload
const upload = $$("editor").getService("upload");
upload.fileDialog(id); // opens a dialog for uploading
2. Operations
$$("editor").getService("operations").copy(); // copies the selected text
3. Backend
const back = $$("editor").getService("backend");
back.import(); // initiates the file dialog for importing .docx, .md, .txt
Study the models folder in the source code for method signatures.
To specify a value for Rich Text Editor, use the setValue() method of Rich Text Editor. The method takes the following parameters:
Note that the markdown parser of Rich Text Editor doesn't provide support for nested structures.
It means that such complex structures as, e.g. bold font style inside the italics one, or a link inside a list,
or multi-level lists won't work correctly while being pasted, added via the setValue() method
with the "markdown" format or imported in an .md file.
If the type parameter isn't specified, the method tries to treat content as HTML.
const text =
`<p>Hello World</p>
<p><a href="https://docs.webix.com/desktop__richtext.html">Rich Text Editor</a></p>
<p>Sample text</p>`;
$$("editor").setValue(text);
Related sample: Rich Text Editor: Setting HTML Value
To get the value of the widget, make use of the getValue() method. It takes one optional parameter:
The method returns the content of the widget in the specified format. If the type parameter hasn't been passed, the method returns a string HTML content.
const value = $$("editor").getValue();
// -> '<p>Sample text</p>'
Related sample: Rich Text Editor: Getting Value as Text and HTML
Back to top