React HtmlEditor Methods
See Also
- Call Methods: Angular | Vue | React | jQuery | AngularJS | Knockout | ASP.NET MVC 5 | ASP.NET Core
beginUpdate()
Prevents the UI component from refreshing until the endUpdate() method is called.
The beginUpdate() and endUpdate() methods prevent the UI component from excessive updates when you are changing multiple UI component settings at once. After the beginUpdate() method is called, the UI component does not update its UI until the endUpdate() method is called.
See Also
- Call Methods: Angular | Vue | React | jQuery | AngularJS | Knockout | ASP.NET MVC 5 | ASP.NET Core
defaultOptions(rule)
defaultOptions is a static method that the UI component class supports. The following code demonstrates how to specify default properties for all instances of the HtmlEditor UI component in an application executed on the desktop.
- import React from "react";
- import dxHtmlEditor from "devextreme/ui/html_editor";
- import HtmlEditor from "devextreme-react/html-editor";
- class App extends React.Component {
- render () {
- dxHtmlEditor.defaultOptions({
- device: { deviceType: "desktop" },
- options: {
- // Here go the HtmlEditor options
- }
- })
- return (
- <div>
- <HtmlEditor id="htmlEditor1" />
- <HtmlEditor id="htmlEditor2" />
- </div>
- )
- }
- }
- export default App;
delete(index, length)
dispose()
After calling this method, remove the DOM element associated with the UI component:
- $("#myHtmlEditor").dxHtmlEditor("dispose");
- $("#myHtmlEditor").remove();
Use this method only if the UI component was created with jQuery or pure JavaScript. In Angular, Vue, and React, use conditional rendering:
- import React from 'react';
- import HtmlEditor from 'devextreme-react/html-editor';
- function DxHtmlEditor(props) {
- if (!props.shouldRender) {
- return null;
- }
- return (
- <HtmlEditor ... >
- </HtmlEditor>
- );
- }
- class App extends React.Component {
- render() {
- return (
- <DxHtmlEditor shouldRender="condition" />
- );
- }
- }
- export default App;
See Also
element()
An HTML element or a jQuery element when you use jQuery.
See Also
- Call Methods: Angular | Vue | React | jQuery | AngularJS | Knockout | ASP.NET MVC 5 | ASP.NET Core
endUpdate()
Refreshes the UI component after a call of the beginUpdate() method.
Main article: beginUpdate()
See Also
- Call Methods: Angular | Vue | React | jQuery | AngularJS | Knockout | ASP.NET MVC 5 | ASP.NET Core
focus()
See Also
- Call Methods: Angular | Vue | React | jQuery | AngularJS | Knockout | ASP.NET MVC 5 | ASP.NET Core
format(formatName, formatValue)
Applies a format to the selected content. Cannot be used with embedded formats.
A format name.
formatLine(index, length, formatName, formatValue)
Applies a single block format to all lines in the given range.
The length of the content to be formatted.
Embedded items have a length of 1.
See Also
formatLine(index, length, formats)
Applies several block formats to all lines in the given range.
The length of the content to be formatted.
Embedded items have a length of 1.
See Also
formatText(index, length, formatName, formatValue)
Applies a single text format to all characters in the given range.
The length of the content to be formatted.
Embedded items have a length of 1.
formatText(index, length, formats)
Applies several text formats to all characters in the given range.
The length of the content to be formatted.
Embedded items have a length of 1.
get(componentPath)
Gets a format, module, or Parchment.
You can perform the following tasks after getting a format, module, or Parchment:
Modify the format
You can change the markup tag associated with the format and allowed format values, as shown in the code example after this list.Extend the format or module
You can extend HtmlEditor's formats and modules and also Quill's formats and modules. See the Extend Built-In Formats and Modules topic for the code example.Create a custom format based on the Parchment
Refer to the Parchment documentation for more information.
In the following code, the bold
format is associated with the <b>
tag instead of the default <strong>
tag. After the modification, the format is registered.
- import React from 'react';
- import 'devextreme/dist/css/dx.common.css';
- import 'devextreme/dist/css/dx.light.css';
- import HtmlEditor from 'devextreme-react/html-editor';
- class App extends React.Component {
- constructor(props) {
- super(props);
- this.htmlEditorRef = React.createRef();
- }
- get htmlEditor() {
- return this.htmlEditorRef.current.instance;
- }
- render() {
- return (
- <HtmlEditor ...
- ref={this.htmlEditorRef}>
- </HtmlEditor>
- );
- }
- componentDidMount() {
- let Bold = this.htmlEditor.get("formats/bold");
- Bold.tagName = "b";
- this.htmlEditor.register({ "formats/bold": Bold });
- }
- }
- export default App;
See Also
getFormat(index, length)
getInstance(element)
getInstance is a static method that the UI component class supports. The following code demonstrates how to get the HtmlEditor instance found in an element with the myHtmlEditor
ID:
- // Modular approach
- import HtmlEditor from "devextreme/ui/html_editor";
- ...
- let element = document.getElementById("myHtmlEditor");
- let instance = HtmlEditor.getInstance(element) as HtmlEditor;
- // Non-modular approach
- let element = document.getElementById("myHtmlEditor");
- let instance = DevExpress.ui.dxHtmlEditor.getInstance(element);
See Also
getLength()
Embedded items have a length of 1.
getSelection()
The selected content's range. Has the following structure:
- index
A zero-based index at which the selection starts. - length
The selected content's length.
Embedded items have a length of 1.
insertText(index, text, formats)
Inserts formatted text at the specified position. Used with all formats except embedded.
instance()
See Also
- Call Methods: Angular | Vue | React | jQuery | AngularJS | Knockout | ASP.NET MVC 5 | ASP.NET Core
off(eventName)
See Also
- Handle Events: Angular | Vue | React | jQuery | AngularJS | Knockout | ASP.NET MVC 5 | ASP.NET Core
off(eventName, eventHandler)
See Also
- Handle Events: Angular | Vue | React | jQuery | AngularJS | Knockout | ASP.NET MVC 5 | ASP.NET Core
on(eventName, eventHandler)
Use this method to subscribe to one of the events listed in the Events section.
See Also
- Handle Events: Angular | Vue | React | jQuery | AngularJS | Knockout | ASP.NET MVC 5 | ASP.NET Core
on(events)
Use this method to subscribe to several events with one method call. Available events are listed in the Events section.
See Also
- Handle Events: Angular | Vue | React | jQuery | AngularJS | Knockout | ASP.NET MVC 5 | ASP.NET Core
option()
Gets all UI component properties.
See Also
- Get and Set Options
- Call Methods: Angular | Vue | React | jQuery | AngularJS | Knockout | ASP.NET MVC 5 | ASP.NET Core
option(optionName)
See Also
- Get and Set Options
- Call Methods: Angular | Vue | React | jQuery | AngularJS | Knockout | ASP.NET MVC 5 | ASP.NET Core
option(optionName, optionValue)
See Also
- Get and Set Options
- Call Methods: Angular | Vue | React | jQuery | AngularJS | Knockout | ASP.NET MVC 5 | ASP.NET Core
option(options)
See Also
- Get and Set Options
- Call Methods: Angular | Vue | React | jQuery | AngularJS | Knockout | ASP.NET MVC 5 | ASP.NET Core
register(components)
- import React from 'react';
- import 'devextreme/dist/css/dx.common.css';
- import 'devextreme/dist/css/dx.light.css';
- import HtmlEditor from 'devextreme-react/html-editor';
- class App extends React.Component {
- constructor(props) {
- super(props);
- this.htmlEditorRef = React.createRef();
- }
- get htmlEditor() {
- return this.htmlEditorRef.current.instance;
- }
- render() {
- return (
- <HtmlEditor ...
- ref={this.htmlEditorRef}>
- </HtmlEditor>
- );
- }
- componentDidMount() {
- this.htmlEditor.register({ "modules/myModule": moduleObject });
- }
- }
- export default App;
See Also
registerKeyHandler(key, handler)
A handler. Accepts the keydown event as the argument. It is a dxEvent or a jQuery.Event when you use jQuery.
The key argument accepts one of the following values:
- "backspace"
- "tab"
- "enter"
- "escape"
- "pageUp"
- "pageDown"
- "end"
- "home"
- "leftArrow"
- "upArrow"
- "rightArrow"
- "downArrow"
- "del"
- "space"
- "F"
- "A"
- "asterisk"
- "minus"
A custom handler for a key cancels the default handler for this key.
See Also
- Call Methods: Angular | Vue | React | jQuery | AngularJS | Knockout | ASP.NET MVC 5 | ASP.NET Core
removeFormat(index, length)
repaint()
See Also
- reload() in DataSource | List
- refresh() in DataGrid | TreeList
- Call Methods: Angular | Vue | React | jQuery | AngularJS | Knockout | ASP.NET MVC 5 | ASP.NET Core
reset()
Resets the value property to the default value.
See Also
- Call Methods: Angular | Vue | React | jQuery | AngularJS | Knockout | ASP.NET MVC 5 | ASP.NET Core
resetOption(optionName)
See Also
- Call Methods: Angular | Vue | React | jQuery | AngularJS | Knockout | ASP.NET MVC 5 | ASP.NET Core
setSelection(index, length)
If you have technical questions, please create a support ticket in the DevExpress Support Center.