ngx-grapesjs v19.1.0
Ngx-grapesjs is an Angular library that wraps basic functionality of the GrapesJS editor. It currently supports two modes for editing content: webpage and newsletter. The newsletter mode is preferable when you want to work with email content such as templates.
Install
Install the core GrapesJS library
npm install grapesjsInstall one of the following GrapesJS plugins according to the editor mode that you want to use.
For webpage mode:
npm install grapesjs-preset-webpage grapesjs-blocks-basicFor newsletter mode:
npm install grapesjs-preset-newsletterInstall
ngx-grapesjsng add ngx-grapesjs
The previous command will ask you which editor mode you want to use and it will make all the necessary modifications in the Angular workspace so that you can get started.
Usage
Import
NgxWebpageEditorComponentorNgxNewsletterEditorComponentfrom thengx-grapesjslibrary, according to the editor mode that you want to use and add it to theimportsarray of your Angular component or module.Create an Angular component and add one of the following HTML snippets according to the editor mode that you want to use:
For webpage mode:
<ngx-grapes-webpage-editor></ngx-grapes-webpage-editor>For newsletter mode:
<ngx-grapes-newsletter-editor></ngx-grapes-newsletter-editor>
Both editors support passing the following input properties:
template: the HTML content of the editor in string formatstoragePrefix: the prefix that GrapesJS will use for persisting data to the local storage. By default it uses thegjs-prefix.plugins: additional GrapesJS plugins to use. It requires that the respective npm package of the plugins must have been installed previously.
It is recommended to use a custom prefix when running multiple instances of the editor such as when opening or editing content in different tabs.
Additionally, the newsletter editor component supports the following options:
placeholders: an input property which is a list of variables with a predefined format that represent custom data in the template