@send-with-ses/ng-email-designer
TypeScript icon, indicating that this package has built-in type declarations

0.5.21 • Public • Published

Angular Email Designer

This library was generated with Angular CLI version 15.2.0.

Installation

Install via NPM:

npm install @send-with-ses/ng-email-designer

Or via YARN:

yarn add @send-with-ses/ng-email-designer

Live Demo

Check out the live demo here: https://designer.sendune.com (Source Code)

Initialization

Import the Email Editor module in your app's module.

app.module.ts

import { EmailEditorModule } from '@send-with-ses/ng-email-designer';
...

@NgModule({
  ...
  imports: [ EmailEditorModule ],
  ...
});

app.component.ts

import { Component, ViewChild } from '@angular/core';
import { EmailEditorComponent } from '@send-with-ses/ng-email-designer';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
})
export class AppComponent {

  @ViewChild(EmailEditorComponent)
  private emailEditor: EmailEditorComponent;

  selectedTemplate: TemplateBean;
  selectedTemplateType = '';

  // To get the HTML output of the template
  exportHtml() {
    console.log(this.emailEditor.exportHtml());
    this.emailEditor.showHtmlPreview();
  }

  preview() {
    this.emailEditor.showPreview();
  }
}

app.component.html

<div class="container">
  <button (click)="exportHtml()">Export</button>
  <lib-email-designer [type]="selectedTemplateType" [template]="selectedTemplate" #emailEditor></lib-email-designer>
</div>

Documentation

We support 3 types of Templates

  1. SENDUNE Designer (ses_designer)
  2. HTML Editor (html_editor)
  3. Plain Text (plain_text)

Pass the relevant template type as 'selectedTemplateType' to use it.

HTML Editor

to use html editor, please include the following glob in 'assets' of your angular.json

{ "glob": "**/*", "input": "node_modules/monaco-editor/min", "output": "/assets/monaco/min" }

{
  "apps": [
    {
      "assets": [
        { "glob": "**/*", "input": "node_modules/monaco-editor/min", "output": "/assets/monaco/min" }
      ],
      ...
    }
    ...
  ],
  ...
}

And include MonacoEditorModule in Main Module and Feature Modules where you want to use the editor component.(eg: app.module.ts):

import { MonacoEditorModule } from 'ngx-monaco-editor-v2';

@NgModule({
  declarations: [
    ...
  ],
  imports: [
    ...
    MonacoEditorModule.forRoot() // use forRoot() in main app module only.
  ],
  providers: [],
})

Image Handling

Images can be directly uploaded to a cloud storage of your choice (ex: AWS S3, Cloudflare R2, GCP Cloud Storage etc).

<lib-email-designer [type]="selectedTemplateType" [template]="selectedTemplate" #emailEditor class="px-0"
        (imageSelectionTriggered)="onImageSelectionTrigger($event)"
        (imageUploadTriggered)="onImageUploadTrigger($event)"
        (emailContentChanged)="onEmailContentChange($event)"
        ></lib-email-designer>

Please implement your image upload functionality and provide it to the library as above (imageUploadTriggered/imageSelectionTriggered).

🎨 UI Theming and Styles

You can make a few changes to make the Email Designer match your website colors.

Import the following styles into your global styles file (e.g., styles.scss):

@import '../node_modules/@send-with-ses/ng-email-designer/src/lib/theme.scss';
@import '../node_modules/@send-with-ses/ng-email-designer/src/lib/email-editor.css';

To make the Email Designer match your website's UI, include the following in your main.scss or styles.scss file and change the colors as you like.

 :root {
    --sws-icon-color: #ccc;
    --sws-icon-hover-color: #555;
    --sws-header-background: #eee;
    --sws-header-text-color: #555;
    --sws-border-color: #ccc;
 }

Known Issues

  1. If you encounter 'Cannot find name ActiveXObject' error,

    please include 'scripthost' in lib of tsconfig.json

    "lib": [
          "es2018",
          "dom",
          "ScriptHost"
        ],
    

Further help

Write to designer [at] sendune [dot] com if you need any help.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.5.2112latest

Version History

VersionDownloads (Last 7 Days)Published
0.5.2112
0.5.190
0.5.171
0.5.160
0.5.150
0.5.140
0.5.130
0.5.120
0.5.110
0.5.100
0.5.90
0.5.80
0.5.70
0.5.60
0.5.50
0.5.40
0.5.30
0.5.20
0.5.10
0.4.110
0.4.90
0.4.80
0.4.70
0.4.60
0.4.50
0.4.40
0.4.31
0.4.20
0.4.00

Package Sidebar

Install

npm i @send-with-ses/ng-email-designer

Weekly Downloads

14

Version

0.5.21

License

MIT

Unpacked Size

19.1 MB

Total Files

217

Last publish

Collaborators

  • sendwithses
  • ashok_m
  • nkishorchandra
  • yeleti
  • sb401