npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@mmuneebahmad/unlayer-svelte-wrapper

v1.0.5

Published

A Svelte wrapper component for the Unlayer email editor

Readme

Unlayer Svelte Wrapper

A modern, TypeScript-first Svelte wrapper for the Unlayer email editor.

Features

  • 🚀 Easy Integration - Drop-in Svelte component
  • 📝 TypeScript Support - Full type definitions included
  • 🎨 Customizable - Support for all Unlayer configuration options
  • 📱 Responsive - Fills parent container width/height
  • 🔄 Event-Driven - Reactive design updates and exports
  • 🧪 Well Tested - Comprehensive test coverage
  • 📦 Tree Shakeable - Import only what you need

Installation

npm install @mmuneebahmad/unlayer-svelte-wrapper

Quick Start

<script>
  import { UnlayerEditor } from '@mmuneebahmad/unlayer-svelte-wrapper';
  
  let editor;
  let isEditorReady = false;

  function handleEditorLoaded(event) {
    isEditorReady = true;
    console.log('Editor loaded:', event.detail.editor);
  }

  async function exportDesign() {
    if (editor && isEditorReady) {
      const data = await editor.exportHtml();
      console.log('Exported:', data);
    }
  }
</script>

<div style="height: 600px;">
  <UnlayerEditor
    bind:this={editor}
    options={{ displayMode: 'email' }}
    on:loaded={handleEditorLoaded}
  />
</div>

<button on:click={exportDesign} disabled={!isEditorReady}>
  Export Design
</button>

API Reference

UnlayerEditor Component

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | design | UnlayerDesign \| null | null | Initial design JSON to load | | tools | Record<string, any> \| null | null | Tool whitelist/blacklist configuration | | options | UnlayerOptions | {} | Unlayer initialization options |

Events

| Event | Payload | Description | |-------|---------|-------------| | loaded | { editor: UnlayerInstance } | Fired when editor is ready | | design-updated | UnlayerDesign | Fired when design changes | | export-html | ExportData | Fired when HTML is exported |

Methods

| Method | Parameters | Returns | Description | |--------|------------|---------|-------------| | exportHtml() | dispatchEvent?: boolean | Promise<ExportData> | Export current design as HTML | | loadDesign() | design: UnlayerDesign | void | Load a design into the editor | | saveDesign() | - | Promise<UnlayerDesign> | Get current design JSON | | isReady() | - | boolean | Check if editor is ready | | getEditor() | - | UnlayerInstance \| null | Get raw editor instance |

ExportModal Component

A pre-built modal for handling design exports.

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | show | boolean | false | Whether modal is visible | | exportData | ExportData \| null | null | Export data to display |

Events

| Event | Payload | Description | |-------|---------|-------------| | close | void | Fired when modal is closed | | download | DownloadEvent | Fired when download is triggered |

Advanced Usage

Custom Configuration

<script>
  import { UnlayerEditor } from '@mmuneebahmad/unlayer-svelte-wrapper';

  const editorOptions = {
    displayMode: 'email',
    projectId: 1234,
    locale: 'en-US',
    appearance: {
      theme: 'light',
      panels: {
        tools: {
          dock: 'left'
        }
      }
    },
    tools: {
      enabled: ['text', 'image', 'button'],
      disabled: ['video']
    },
    mergeTags: [
      {
        name: 'First Name',
        value: '{{first_name}}',
        sample: 'John'
      }
    ]
  };
</script>

<UnlayerEditor options={editorOptions} />

With Export Modal

<script>
  import { UnlayerEditor, ExportModal } from '@mmuneebahmad/unlayer-svelte-wrapper';
  
  let editor;
  let showExportModal = false;
  let exportData = null;

  async function handleExport() {
    if (editor) {
      exportData = await editor.exportHtml();
      showExportModal = true;
    }
  }
</script>

<UnlayerEditor bind:this={editor} />

<button on:click={handleExport}>Export</button>

<ExportModal
  bind:show={showExportModal}
  {exportData}
  on:download={(e) => console.log('Downloaded:', e.detail)}
/>

Loading Initial Design

<script>
  import { UnlayerEditor, createSampleDesign } from '@mmuneebahmad/unlayer-svelte-wrapper';
  
  const initialDesign = createSampleDesign();
</script>

<UnlayerEditor design={initialDesign} />

TypeScript Support

The package includes comprehensive TypeScript definitions:

import type { 
  UnlayerOptions, 
  UnlayerDesign, 
  ExportData,
  EditorLoadedEvent 
} from '@mmuneebahmad/unlayer-svelte-wrapper';

const options: UnlayerOptions = {
  displayMode: 'email',
  projectId: 123
};

function handleLoaded(event: CustomEvent<EditorLoadedEvent>) {
  const editor = event.detail.editor;
  // editor is fully typed
}

Styling

The component fills its parent container. Ensure the parent has defined dimensions:

<div class="editor-container">
  <UnlayerEditor />
</div>

<style>
  .editor-container {
    width: 100%;
    height: 600px; /* or 100vh for full height */
  }
</style>

Error Handling

The component includes built-in error handling with retry functionality:

<UnlayerEditor
  on:loaded={handleLoaded}
  on:error={handleError}
/>

Browser Support

  • Modern browsers with ES2020+ support
  • Svelte 4.0+ or 5.0+
  • TypeScript 5.0+ (optional)

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

MIT © [Muneeb Ahmad]

Changelog

See CHANGELOG.md for details.