This page explains how to quickly embed the DGM.js editor into the web.
Create React project
First, create a React with TypeScript project. Here, Vite is used.
Install TailwindCSS
Here, TailwindCSS is used for styling. However, you can use any other styling method you prefer, such as CSS or Styled Components.
Install packages
To use DGM.js, you need to install two packages as below.
Insert Editor component
Before inserting the actual component, first update the index.html. Here, apply simple styles to the area where the editor will be inserted and load the fonts to be used.
Then, open the App.tsx file and insert the <DGMEditor> as below.
Now, run the application to check if the editor has been embedded. The editor area should be displayed on the screen, and you should be able to select the area using the mouse.
Adding toolbar and palette
Let’s add a toolbar for adding shapes and a palette for editing styles. You can find simple code for this on StackBlitz below.