DHTMLX RichText. Vue integration example
Demo of DHTMLX RichText integration with Vue using the official GitHub demo. Shows initialization and cleanup for a Vue-based DHTMLX RichText component. For a step-by-step setup guide, see the detailed Vue integration guide.
View on GitHub - open the repository and click "Open in Codespaces" on the README page to launch a fully configured Vue app with DHTMLX RichText in seconds. No local setup required.
DHTMLX RichText integrates with Vue through a single-file component that mounts the editor with a template ref and manages it in the Vue lifecycle hooks. The editor is created in mounted and destroyed in unmounted, so it follows the component's life.
The component accesses its container through this.$refs and creates a Richtext instance in mounted, passing the configuration and the starting value prop. When the component is removed, unmounted calls editor.destructor() to clean up the widget.
Solution overview
To integrate DHTMLX RichText with Vue, follow the standard widget lifecycle pattern:
- Import the package and styles -
import { Richtext } from "@dhx/trial-richtext"and itsrichtext.css. - Add a template ref on the container
<div>sothis.$refscan reach it. - Initialize in
mounted- callnew Richtext(this.$refs.richtext_container, { value: this.value }). - Pass initial content via props - the parent provides
value, which initializes the editor when the component mounts. - Clean up in
unmountedby callingeditor.destructor()to remove the widget and its listeners.
API reference
- RichText constructor: Creates a new RichText instance
- value config: Sets the initial editor content
- destructor method: Destroys the instance on unmount
- API overview: Full list of methods, properties, and events
Related examples
- Svelte integration: the editor mounted in a Svelte app
- React integration: the editor mounted in a React app
- Initialization: the base setup with content and image uploads