Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

email-scribe

Package Overview
Dependencies
Maintainers
0
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

email-scribe

Email Scribe is a feature-rich, embeddable email editor (<320kb gzipped), designed for creating modular, email-safe designs. This semi-WYSIWYG editor allows you to build emails using pre-existing template modules, ensuring compatibility across various ema

  • 1.5.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-76.92%
Maintainers
0
Weekly downloads
 
Created
Source

Email Scribe

A feature-rich, embeddable email editor (<250kb gzipped), designed for creating modular, email-safe designs. This semi-WYSIWYG editor allows you to build emails using pre-existing template modules, ensuring compatibility across various email clients. Email Editor

Key Features

  • Import Email Templates: Parse and import email templates (especially StampReady templates) as modular, editable components.
Add Block
  • Embeddable SPA: Completely isolated CSS to prevent conflicts with parent application styles that builds to a single js+css.

  • Export and Import: Save your work as JSON, import previously saved designs, and save/load from server.

  • Download Safe HTML: Generate and download sanitized, email-safe HTML.

  • Responsive Preview: View your design across multiple device sizes (mobile, tablet, PC).

  • Theme Support: Light/Dark mode that can sync with the parent application (defaults to 'theme-dark' class on body).

  • Mock Express Server: Includes a mock server for image upload (with resizing), template serving, and preset management.

  • Bulk Settings: Change overlapping/merged settings for multiple blocks simultaneously.

  • Server-Side Rendering Support: Enables dynamic content injection via server-side processing.

    • Converts editable fields to placeholders (e.g., %field_name%)
    • Wraps blocks in uniquely identified templates
    • Facilitates iterative data population on the server

Certainly! I'll update the README to include the new props and example. Here's an updated version of the README section:

Using as a React Component

Info: This is the client-side aspect of the editor. At the very least, you'll need to implement a server that serves templates and handles image uploads (A fully functional example server is included in git repo of the project, check next section for more details).

import { EmailScribe, PresetMode } from 'email-scribe';
import { Save } from 'lucide-react';

function App() {
  return (
    <EmailScribe
      apiUrl={import.meta.env.VITE_API_URL}
      basePath={import.meta.env.VITE_BASE_PATH}
      templatesToFetch={import.meta.env.VITE_TEMPLATE_ID.split(',')}
      ctaOne={{
        label: 'Download Preset Json',
        icon: <Save />,
        action: (subject, id, plainText, html, preset) => {
          stringtoJsonDownload(preset, 'preset.json');
        },
        hidden: false,
      }}
      ctaTwo={{ hidden: true }}
      presetMode={PresetMode.Default}
      preloadPreset={JSON.stringify(presetTest)}
    />
  );
}

function stringtoJsonDownload(data: string, filename: string) {
  const a = document.createElement('a');
  a.href = URL.createObjectURL(new Blob([data], { type: 'application/json' }));
  a.download = filename;
  a.click();
}

Props

PropDescriptionTypeOptional
apiUrlAPI calls start with this urlstringNo
basePathAPI calls become: apiUrl/basePath/routestringNo
templatesToFetchArray of template names to fetch (purchased by you)string[]No
iconComponentCustom icon component. Can be React Node.ReactNodeYes
titleTitle for the editorstringYes
preloadPresetPreset to load initiallystringYes
presetModeMode for preset handlingPresetModeYes
ctaOneConfiguration for the first CTA buttonCTAPropsYes
ctaTwoConfiguration for the second CTA buttonCTAPropsYes

CTAProps

PropDescriptionTypeOptional
labelLabel for the CTA buttonstringYes
iconIcon component for the CTA buttonReactNodeYes
actionFunction to execute when CTA button is clicked(subject: string, id: string, plainText: string, html: string, preset: string) => voidYes
hiddenWhether to hide the CTA buttonbooleanYes

Action parameters can be used to extract all useful data from the editor to be used in your application.

PresetMode

An enum with the following values:

  • PresetMode.Default
  • PresetMode.LocalOnly
  • PresetMode.RemoteOnly

API and Server Requirements

The application comes with an Express server that handles image uploads, template serving, and preset management. For production use, you'll need to implement similar endpoints:

  • /upload: POST endpoint for image uploads (with optional resizing)
  • /templates: GET endpoint to serve email templates
  • /preset: GET, POST, DELETE endpoints for managing presets (can be ignored if not needed)
  • /presets: GET endpoint to list all presets (same as above)

Refer to the server directory and server.ts for detailed implementation. Note the .env.example file for defaults.

Using as a Standalone Application/Static build

Setup

Note: All bun commands can be replaced with your preferred package manager/runtime environment

  • Clone the repo
  • Run bun i in root as well as in server directory.
  • Extract your templates in server/Templates folder.
    • The folder structure should be like server/Templates/xyzTemplate/ and index.html should be inside it alongside any resources embedded into templates placed relatively.
    • Suggested/Tested template: Matah Responsive Email Set.
  • Copy .env.example to .env and adjust as needed.

Development

  • First cd into server and run bun run serve to start the server (for image uploads, template serving, and preset management)
  • Then in a new terminal in root directory, run bun run dev

Production

  • bun run build:static followed by bun run serve in server directory (or use your preferred compatible server implementation).
  • To embed this SPA in your project, include the compiled JS and CSS files in your projects.

Project Structure

The project is a React SPA (Single Page Application) that uses Tanstack Query for data fetching, Zustand for state management, Radix components for UI, Handlebars for templating alognside other minor packages for various tasks. Project Structure

License

This project is licensed under the MIT License - see the LICENSE file for details.

Keywords

FAQs

Package last updated on 23 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc