Skip to main content

Migration to newer versions

1.2 -> 2.0

Properties migration

Legacy propertyReplaced byNotes
customStats(Removed)Not available in the new version 2.0
toolbarBlockstoolbarNow supports detailed toolbar structure
defaultStylesdefaultStyles (updated)Structure is now per-block and CSS-based
modelayoutModeReplaced with stricter enum-based setting

- customStats

The customStats property has been removed. The current version of RichText no longer supports displaying user-defined statistics (e.g., character count, word count, sentence count).

If you still need to calculate text metrics, you can do so externally by accessing the editor content and processing it manually:

const content = editor.getValue();
const wordCount = content.split(/\s+/).length;

- toolbarBlockstoolbar

Before 2.0, users were able to specify only blocks with controls

Before 2.0
new dhx.RichText("#root", {
toolbarBlocks: ["undo", "style", "decoration", "colors", "align", "link"]
});

Starting from 2.0, users can spefify separate controls

From 2.0
new richtext.Richtext("#root", {
toolbar: [
"undo", "style", "bold", "italic", "underline", "text-color",
"align", "link"
]
});

- defaultStyles

Before 2.0, users were able to define default values for toolbar selection controls

Before 2.0
defaultStyles: {
"font-family": "Tahoma",
"font-size": "14px"
}

Starting from 2.0, users can specifies default style values for specific block types

From 2.0
defaultStyles: {
"*": {
"font-family": "Tahoma",
"font-size": "14px"
},
h1: {
"font-size": "32px",
"color": "#333"
}
}
note

Use * to define base defaults for all blocks, then override specific elements (p, h1, blockquote, etc.).

- modelayoutMode

Before 2.0
new dhx.RichText("#root", {
mode: "document"
});
From 2.0
new Richtext("#root", {
layoutMode: "document" // or "classic"
});

The new layoutMode strictly supports "classic" and "document" values.

Methods migration

Legacy methodNew equivalentNotes
getValue(mode)getValue(encoder)Encoders replace string modes; separate import needed for encoders
setValue(value, mode)setValue(value, encoder)Encoders replace string modes; separate import needed for encoders
getStats()RemovedNo replacement; manual logic required
getEditorAPI()RemovedInternal; use public API instead
fire()RemovedReplaced by exec() and intercept()
on(), detach()✅ Preserved (api.on, api.detach)Now accessed via richtext.api
fullScreen()RemovedUse fullscreenMode config property
exitFullScreen()RemovedUse fullscreenMode config property
paint()RemovedNo longer needed
destructor()✅ Still availableUnchanged
setConfig()✅ NewEnables live config updates
setLocale()✅ NewAllows dynamic locale switching
getReactiveState()✅ NewEnables reactive state tracking
getState()✅ NewProvides current static config state
intercept()✅ NewIntercept internal actions
exec()✅ NewExecute internal actions

- setValue() / getValue()

Before 2.0
...
editor.setValue("<p>Hello</p>", "html");
editor.getValue("text");
From 2.0
const fromTextEncoder = richtext.text.fromText; 
const fromHTMLEncoder = richtext.html.fromHTML;

const toTextEncoder = richtext.text.toText;
const toHTMLEncoder = richtext.html.toHTML;
...
editor.setValue("<p>Hello</p>", fromHTMLEncoder);
editor.getValue(toTextEncoder);
note

You can still call getValue() and setValue() without an encoder — HTML is used by default

- on / detach

Before 2.0
editor.events.on("Change", function(action, canUndo, canRedo){
// your code here
});

editor.events.detach("Change");
From 2.0
editor.api.on("set-font-size", (obj) => {
console.log(obj.fontSize);
}, { tag: "track" });

editor.api.detach("track");

- fire() → Use exec() and intercept()

Before 2.0
editor.events.fire("some-event", [data]);
From 2.0
editor.api.exec("some-event", obj);

// Preventing execution
editor.api.intercept("some-event", (obj) => false);