@creaditor/newsletter-starterkit

中文文档
1.0.76发布于 2026/11/08ISCCommonJS零依赖近 30 天下载 5008

Creaditor Newsletter Editor - Starterkit for creating beautiful email newsletters

原始使用文档
文档目录22 节
  1. ✨ Features
  2. 📦 Installation
  3. 🚀 Quick Start
  4. Simple HTML Integration
  5. With Configuration
  6. 📖 API
  7. Constructor Options
  8. Methods
  9. 🎨 Customization
  10. Custom Fonts
  11. Merge Tags (Personalization)
  12. 🌍 Internationalization
  13. 📁 Package Contents
  14. 📱 Browser Support
  15. 💡 Integration Examples
  16. With CDN (if self-hosting)
  17. With React (Load via useEffect)
  18. Changelog
  19. 1.0.37-preview.3
  20. 1.0.37-preview.1
  21. 📄 License
  22. 🔗 Links

@creaditor/newsletter-starterkit

📧 A powerful visual editor for creating beautiful email newsletters

A drag-and-drop newsletter editor with everything built-in. No external dependencies required!

✨ Features

  • 🎨 Visual Drag & Drop - Intuitive interface for building newsletters
  • 📱 Responsive Design - Mobile-friendly emails out of the box
  • 🔧 Customizable - Full control over styles and components
  • 🌍 i18n Support - Multiple languages supported
  • 💾 Auto-save - Never lose your work
  • 📝 Rich Text Editor - Powerful text editing capabilities
  • 🖼️ Media Gallery - Easy image and media management
  • 🎯 Merge Tags - Personalize emails for each recipient
  • ⚡ Self-Contained - All files bundled, no CDN required

📦 Installation

npm install @creaditor/newsletter-starterkit

Or with yarn:

yarn add @creaditor/newsletter-starterkit

🚀 Quick Start

Simple HTML Integration

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Newsletter Editor</title>
</head>
<body>
    <div id="root"></div>
    
    <!-- Load the editor bundle -->
    <script src="node_modules/@creaditor/newsletter-starterkit/dist/creaditor.bundle.js"></script>
    
    <script>
        // Initialize the editor
        const editor = new cdtrStarter({
            target: document.getElementById('root'),
            width: '650px',
            language: 'en',
            onSave: (data) => {
                console.log('Newsletter saved:', data);
                // Send to your backend
            }
        });
    </script>
</body>
</html>

With Configuration

const editor = new cdtrStarter({
    target: document.getElementById('root'),
    width: '650px',
    language: 'en',
    
    // Document name
    documentName: 'My Newsletter',
    
    // User information
    user: {
        id: 'user123',
        email: '[email protected]',
        name: 'John Doe',
        logo: 'https://example.com/logo.png'
    },
    
    // Initial components (optional)
    components: [],
    
    // Callbacks
    onSave: (data) => {
        console.log('Content saved:', data);
    },
    
    onChange: () => {
        console.log('Content changed');
    },
    
    onSendTestEmail: (email) => {
        console.log('Send test to:', email);
    }
});

📖 API

Constructor Options

OptionTypeDefaultDescription
targetHTMLElementrequiredThe DOM element to mount the editor
widthstring'650px'Width of the newsletter
languagestring'en'Editor language (en, he, etc.)
languageJsonobject-Custom language translations
documentNamestring-Name of the document
componentsarray[]Initial newsletter components
userobject-User information (id, email, name, logo)
onSavefunction-Called when content is saved
onChangefunction-Called when content changes
onSendTestEmailfunction-Called when test email is requested
fontsarray-Available fonts
mergeTagsobject-Merge tags for personalization
pluginsarray[]Additional plugins

Methods

// Get newsletter data as JSON
const data = await editor.commands.toJSON();

🎨 Customization

Custom Fonts

const editor = new cdtrStarter({
    target: document.getElementById('root'),
    fonts: [
        {
            id: 'Roboto',
            cssRule: 'Roboto, sans-serif',
            name: 'Roboto',
            url: 'https://fonts.googleapis.com/css2?family=Roboto&display=swap'
        }
    ]
});

Merge Tags (Personalization)

const editor = new cdtrStarter({
    target: document.getElementById('root'),
    mergeTags: {
        items: [
            { value: 'name', label: 'First Name' },
            { value: 'email', label: 'Email' },
            { value: 'company', label: 'Company' }
        ],
        prefix: '{{',
        suffix: '}}',
        title: 'Personalization'
    }
});

🌍 Internationalization

Supported languages:

  • English (en)
  • Hebrew (he)
  • Custom (provide your own languageJson)
const editor = new cdtrStarter({
    target: document.getElementById('root'),
    language: 'he', // Hebrew
    // Or provide custom translations:
    languageJson: {
        "save": "Save",
        "cancel": "Cancel",
        // ... more translations
    }
});

📁 Package Contents

@creaditor/newsletter-starterkit/
└── dist/
    ├── creaditor.bundle.js     (2.2MB - Main bundle)
    ├── index.html              (Demo page)
    └── [chunk files].js        (Lazy-loaded modules)

📱 Browser Support

  • Chrome (latest)
  • Firefox (latest)
  • Safari (latest)
  • Edge (latest)

💡 Integration Examples

With CDN (if self-hosting)

<script src="https://your-cdn.com/creaditor.bundle.js"></script>
<script>
    const editor = new cdtrStarter({
        target: document.getElementById('root')
    });
</script>

With React (Load via useEffect)

import { useEffect, useRef } from 'react';

function NewsletterEditor() {
    const rootRef = useRef(null);
    
    useEffect(() => {
        // Load script
        const script = document.createElement('script');
        script.src = '/node_modules/@creaditor/newsletter-starterkit/dist/creaditor.bundle.js';
        script.onload = () => {
            new window.cdtrStarter({
                target: rootRef.current,
                width: '100%',
                language: 'en'
            });
        };
        document.body.appendChild(script);
        
        return () => document.body.removeChild(script);
    }, []);
    
    return <div ref={rootRef} />;
}

Changelog

1.0.37-preview.3

Merged updates since 1.0.37-preview.1

  • Link editing and picker fixes:
    • Improved link insertion and unlink behavior in the text editor so selection handling is more reliable and link styles do not leak into surrounding content.
    • Fixed link-related styling resets after insertion and improved URL processing behavior.
  • Transfer data / sharing workflow:
    • Replaced the old import/export panel with a new transfer data flow in the sidebar.
    • Added UI for generating and entering access codes, API versioning support, improved template loading feedback, and multilingual strings for the new flow.
    • Cleaned up related state handling, subscriptions, and timers for better stability.
  • Custom bullet enhancements:
    • Added support for custom bullet icons, including icon URL handling, default images, color and size controls, and conditional icon options in the sidebar.
    • Improved spacing and styling support for bullet content.
  • Editor polish:
    • Swapped the undo/redo icons to match expected behavior.
    • Added smaller editor consistency fixes, including dataset assignment during sorting and preserving default button text when creating new buttons.

1.0.37-preview.1

Link picker URL input

  • Fixed: Typing a dot (.) in the URL field (e.g. sendmsg.co) no longer removes the character. The input was controlled from parent state and re-renders were overwriting the value before the dot was applied.
  • Protocol input (@creaditor/linkpicker):
    • handleInput now triggers onChange for any character when the cursor is at the end, not only alphanumeric characters, so dots and other URL-safe characters are kept.
    • Removed the “last character must be alphanumeric” check; we only skip when the entire value is non-alphanumeric (e.g. ... or ---).
  • Link element:
    • onKeyDown no longer calls onChangeLink(event) or onBlur() on every keypress. On keydown, event.target.value is still the value before the key is applied, which caused the new character to be dropped. Submit (Enter) is handled separately using the current input value.
    • URL field is “uncontrolled while focused”: while the URL input is focused, the displayed value is the raw string the user is typing (_urlInputRawValue) instead of the parent’s myHref, so re-renders no longer overwrite what the user types (e.g. the dot in sendmsg.co).
    • Added focus/blur handling for the URL input (onUrlInputFocus / onUrlInputBlur) and pass onFocus into the protocol input so the focus flag and raw value stay in sync.

📄 License


版本与发布记录

@creaditor/newsletter-starterkit 共发布 83 个版本,首次发布于 2025/11/05;过去 12 个月发布了 81 个版本。

版本发布日期距今
1.0.76latest2026/11/082 天前
1.0.752026/11/082 天前
1.0.742026/11/055 天前
1.0.732026/11/055 天前
1.0.722026/11/055 天前
1.0.712026/11/037 天前

其他发布通道:test → 1.0.15-test.4,preview → 1.0.37-preview.4。

关于 @creaditor/newsletter-starterkit 的常见问题

@creaditor/newsletter-starterkit 是什么?

Creaditor Newsletter Editor - Starterkit for creating beautiful email newsletters

如何安装 @creaditor/newsletter-starterkit?

在项目目录运行 npm install @creaditor/newsletter-starterkit,或使用 pnpm add / yarn add / bun add。

@creaditor/newsletter-starterkit 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/creaditor__newsletter-starterkit 是否存在。

@creaditor/newsletter-starterkit 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@creaditor/newsletter-starterkit 可以商用吗?

@creaditor/newsletter-starterkit 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@creaditor/newsletter-starterkit 的下载量有多少?

根据 npm 官方下载统计,@creaditor/newsletter-starterkit 在 2026/10/11 – 2026/11/09 这 30 天内被下载 5,008 次,日均约 167 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@creaditor/newsletter-starterkit 还在维护吗?

最新版本 1.0.76 发布于 2026/11/08(2 天前);至今共发布 83 个版本,其中过去 12 个月发布了 81 个;首次发布于 2025/11/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。