dragble-vue-editor 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +235 -0
- package/dist/index.d.ts +776 -0
- package/dist/index.js +741 -0
- package/dist/index.js.map +1 -0
- package/package.json +128 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dragble
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://dragble.com">
|
|
3
|
+
<img src="logo.png" alt="Dragble Email Editor - Vue Email Template Builder" width="300" />
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://www.npmjs.com/package/dragble-vue-editor"><img src="https://img.shields.io/npm/v/dragble-vue-editor.svg" alt="npm version" /></a>
|
|
9
|
+
<a href="https://github.com/Dragble/dragble-vue-editor/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="license" /></a>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
# dragble-vue-editor
|
|
13
|
+
|
|
14
|
+
Vue 3 component for building **email templates** with drag-and-drop. Embed a full-featured **email editor** into your Vue app — create responsive HTML emails, newsletters, transactional email templates, and email marketing campaigns visually without writing code.
|
|
15
|
+
|
|
16
|
+
[Dragble](https://dragble.com) is a modern **email builder** and **email template editor** that lets your users design professional emails with a visual drag-and-drop interface.
|
|
17
|
+
|
|
18
|
+
[Website](https://dragble.com) | [Documentation](https://docs.dragble.com) | [Dashboard](https://developers.dragble.com)
|
|
19
|
+
|
|
20
|
+
<p align="center">
|
|
21
|
+
<img src="editor_image.png" alt="Dragble Vue Email Editor - Drag and Drop Email Template Builder" width="700" />
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
## Features
|
|
25
|
+
|
|
26
|
+
- Drag-and-drop **email template builder** with 20+ content blocks
|
|
27
|
+
- Responsive **HTML email** output compatible with all major email clients
|
|
28
|
+
- **Newsletter editor** with merge tags, dynamic content, and display conditions
|
|
29
|
+
- Visual **email designer** — no HTML/CSS knowledge required for end users
|
|
30
|
+
- Export to HTML, JSON, image, PDF, or ZIP
|
|
31
|
+
- Built-in image editor, AI content generation, and collaboration tools
|
|
32
|
+
- Full TypeScript support
|
|
33
|
+
- Vue 3 Composition API support with component and composable
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
The SDK is loaded from CDN automatically — you only need to install the Vue wrapper.
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install dragble-vue-editor
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
yarn add dragble-vue-editor
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pnpm add dragble-vue-editor
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Editor Key
|
|
52
|
+
|
|
53
|
+
An `editorKey` is required to use the editor. You can get one by creating a project on the [Dragble Developer Dashboard](https://developers.dragble.com).
|
|
54
|
+
|
|
55
|
+
## Quick Start
|
|
56
|
+
|
|
57
|
+
```vue
|
|
58
|
+
<template>
|
|
59
|
+
<DragbleEditor
|
|
60
|
+
ref="editorRef"
|
|
61
|
+
editor-key="your-editor-key"
|
|
62
|
+
editor-mode="email"
|
|
63
|
+
:height="800"
|
|
64
|
+
@ready="onReady"
|
|
65
|
+
@change="onChange"
|
|
66
|
+
/>
|
|
67
|
+
</template>
|
|
68
|
+
|
|
69
|
+
<script setup lang="ts">
|
|
70
|
+
import { ref } from "vue";
|
|
71
|
+
import { DragbleEditor } from "dragble-vue-editor";
|
|
72
|
+
|
|
73
|
+
const editorRef = ref<InstanceType<typeof DragbleEditor>>();
|
|
74
|
+
|
|
75
|
+
const onReady = () => {
|
|
76
|
+
console.log("Editor ready!");
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const onChange = async (data: { design: unknown; type: string }) => {
|
|
80
|
+
// Design JSON is available directly from the callback
|
|
81
|
+
const json = data.design;
|
|
82
|
+
console.log("Design JSON:", json);
|
|
83
|
+
|
|
84
|
+
// To get HTML, call exportHtml on the editor ref
|
|
85
|
+
const html = await editorRef.value?.exportHtml();
|
|
86
|
+
console.log("HTML:", html);
|
|
87
|
+
};
|
|
88
|
+
</script>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Props
|
|
92
|
+
|
|
93
|
+
| Prop | Type | Default | Description |
|
|
94
|
+
| ------------------- | ---------------------------------------- | ------------ | --------------------------------- |
|
|
95
|
+
| `editorKey` | `String` | **required** | Editor key for authentication |
|
|
96
|
+
| `design` | `DesignJson \| ModuleData \| null` | `undefined` | Initial design to load |
|
|
97
|
+
| `editorMode` | `EditorMode` | `"email"` | `"email"` \| `"web"` \| `"popup"` |
|
|
98
|
+
| `popup` | `PopupConfig` | `undefined` | Popup configuration |
|
|
99
|
+
| `contentType` | `"module"` | `undefined` | Single-row module editor |
|
|
100
|
+
| `ai` | `AIConfig` | `undefined` | AI features configuration |
|
|
101
|
+
| `locale` | `String` | `undefined` | UI locale |
|
|
102
|
+
| `translations` | `Record<string, Record<string, string>>` | `undefined` | Translation overrides |
|
|
103
|
+
| `textDirection` | `TextDirection` | `undefined` | `"ltr"` or `"rtl"` |
|
|
104
|
+
| `language` | `Language` | `undefined` | Template language |
|
|
105
|
+
| `appearance` | `AppearanceConfig` | `undefined` | Visual customization |
|
|
106
|
+
| `tools` | `ToolsConfig` | `undefined` | Tool enable/disable |
|
|
107
|
+
| `customTools` | `DragbleToolConfig[]` | `undefined` | Custom tools |
|
|
108
|
+
| `features` | `FeaturesConfig` | `undefined` | Feature toggles |
|
|
109
|
+
| `fonts` | `FontsConfig` | `undefined` | Fonts configuration |
|
|
110
|
+
| `bodyValues` | `Record<string, unknown>` | `undefined` | Body values |
|
|
111
|
+
| `header` | `unknown` | `undefined` | Locked header row |
|
|
112
|
+
| `footer` | `unknown` | `undefined` | Locked footer row |
|
|
113
|
+
| `mergeTags` | `(MergeTag \| MergeTagGroup)[]` | `undefined` | Merge tags |
|
|
114
|
+
| `specialLinks` | `(SpecialLink \| SpecialLinkGroup)[]` | `undefined` | Special links |
|
|
115
|
+
| `modules` | `Module[]` | `undefined` | Custom modules |
|
|
116
|
+
| `displayConditions` | `DisplayConditionsConfig` | `undefined` | Display conditions |
|
|
117
|
+
| `editor` | `EditorBehaviorConfig` | `undefined` | Editor behavior |
|
|
118
|
+
| `customCSS` | `string[]` | `undefined` | Custom CSS URLs |
|
|
119
|
+
| `customJS` | `string[]` | `undefined` | Custom JS URLs |
|
|
120
|
+
| `height` | `String \| Number` | `"600px"` | Editor height |
|
|
121
|
+
| `minHeight` | `String \| Number` | `"600px"` | Minimum height |
|
|
122
|
+
| `options` | `EditorOptions` | `undefined` | Additional options |
|
|
123
|
+
| `callbacks` | `Omit<DragbleCallbacks, ...>` | `undefined` | SDK callbacks |
|
|
124
|
+
|
|
125
|
+
| `collaboration` | `boolean \| CollaborationFeaturesConfig` | `undefined` | Collaboration features |
|
|
126
|
+
| `user` | `UserInfo` | `undefined` | User info |
|
|
127
|
+
| `designMode` | `"edit" \| "live"` | `undefined` | Template permissions |
|
|
128
|
+
|
|
129
|
+
## Events
|
|
130
|
+
|
|
131
|
+
| Event | Description |
|
|
132
|
+
| --------- | ------------------------------- |
|
|
133
|
+
| `ready` | Editor is initialized and ready |
|
|
134
|
+
| `load` | Design has been loaded |
|
|
135
|
+
| `change` | Design has changed |
|
|
136
|
+
| `error` | An error occurred |
|
|
137
|
+
| `comment` | Comment event |
|
|
138
|
+
|
|
139
|
+
## Exposed Methods
|
|
140
|
+
|
|
141
|
+
All SDK methods are accessible via a template ref. Key methods:
|
|
142
|
+
|
|
143
|
+
| Method | Returns | Description |
|
|
144
|
+
| ---------------------------------- | ---------------------- | ---------------------------------------- |
|
|
145
|
+
| `loadDesign(design, options?)` | `void` | Load a design |
|
|
146
|
+
| `loadBlank(options?)` | `void` | Load a blank design |
|
|
147
|
+
| `getDesign()` | `Promise` | Get current design JSON |
|
|
148
|
+
| `exportHtml(options?)` | `Promise<string>` | Export as HTML |
|
|
149
|
+
| `exportJson()` | `Promise<DesignJson>` | Export design JSON |
|
|
150
|
+
| `exportPlainText()` | `Promise<string>` | Export as plain text |
|
|
151
|
+
| `exportImage(options?)` | `Promise` | Export as image |
|
|
152
|
+
| `exportPdf(options?)` | `Promise` | Export as PDF |
|
|
153
|
+
| `exportZip(options?)` | `Promise` | Export as ZIP |
|
|
154
|
+
| `setMergeTags(config)` | `void` | Set merge tags config |
|
|
155
|
+
| `getMergeTags()` | `Promise` | Get merge tags |
|
|
156
|
+
| `setSpecialLinks(config)` | `void` | Set special links |
|
|
157
|
+
| `setModules(modules)` | `void` | Set custom modules |
|
|
158
|
+
| `setFonts(config)` | `void` | Set fonts config |
|
|
159
|
+
| `setBodyValues(values)` | `void` | Set body values |
|
|
160
|
+
| `setToolsConfig(config)` | `void` | Set tools config |
|
|
161
|
+
| `setAppearance(config)` | `void` | Set appearance |
|
|
162
|
+
| `setEditorMode(mode)` | `void` | Set editor mode |
|
|
163
|
+
| `setLocale(locale, translations?)` | `void` | Set locale |
|
|
164
|
+
| `setTextDirection(direction)` | `void` | Set text direction |
|
|
165
|
+
| `setLanguage(language)` | `void` | Set language |
|
|
166
|
+
| `setDisplayConditions(config)` | `void` | Set display conditions |
|
|
167
|
+
| `setOptions(options)` | `void` | Set additional options |
|
|
168
|
+
| `showPreview(device?)` | `void` | Show design preview |
|
|
169
|
+
| `hidePreview()` | `void` | Hide preview |
|
|
170
|
+
| `undo()` | `void` | Undo last action |
|
|
171
|
+
| `redo()` | `void` | Redo last action |
|
|
172
|
+
| `canUndo()` | `Promise<boolean>` | Check if undo available |
|
|
173
|
+
| `canRedo()` | `Promise<boolean>` | Check if redo available |
|
|
174
|
+
| `save()` | `void` | Trigger save |
|
|
175
|
+
| `audit(options?)` | `Promise<AuditResult>` | Run design audit |
|
|
176
|
+
| `registerTool(config)` | `Promise` | Register a custom tool |
|
|
177
|
+
| `unregisterTool(id)` | `Promise` | Unregister a tool |
|
|
178
|
+
| `addEventListener(event, cb)` | `() => void` | Subscribe to event (returns unsubscribe) |
|
|
179
|
+
| `removeEventListener(event, cb)` | `void` | Unsubscribe from event |
|
|
180
|
+
|
|
181
|
+
## Composable
|
|
182
|
+
|
|
183
|
+
For more control over the editor lifecycle, use the `useDragbleEditor` composable:
|
|
184
|
+
|
|
185
|
+
```vue
|
|
186
|
+
<script setup lang="ts">
|
|
187
|
+
import { useDragbleEditor } from "dragble-vue-editor";
|
|
188
|
+
|
|
189
|
+
const { editor, isReady, containerId } = useDragbleEditor({
|
|
190
|
+
editorKey: "your-editor-key",
|
|
191
|
+
editorMode: "email",
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
const exportHtml = async () => {
|
|
195
|
+
if (editor.value) {
|
|
196
|
+
const html = await editor.value.exportHtml();
|
|
197
|
+
console.log(html);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
</script>
|
|
201
|
+
|
|
202
|
+
<template>
|
|
203
|
+
<div :id="containerId" style="height: 600px" />
|
|
204
|
+
<button @click="exportHtml" :disabled="!isReady">Export</button>
|
|
205
|
+
</template>
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
**Returns:**
|
|
209
|
+
|
|
210
|
+
| Property | Type | Description |
|
|
211
|
+
| ------------- | -------------------------- | ------------------------------------ |
|
|
212
|
+
| `editor` | `Ref<DragbleSDK \| null>` | SDK instance (null until ready) |
|
|
213
|
+
| `isReady` | `Ref<boolean>` | Whether the editor is initialized |
|
|
214
|
+
| `containerId` | `string` | DOM element ID to bind the editor to |
|
|
215
|
+
|
|
216
|
+
## TypeScript
|
|
217
|
+
|
|
218
|
+
Full type definitions are included. Import types directly from the package:
|
|
219
|
+
|
|
220
|
+
```ts
|
|
221
|
+
import type {
|
|
222
|
+
DesignJson,
|
|
223
|
+
EditorMode,
|
|
224
|
+
AppearanceConfig,
|
|
225
|
+
} from "dragble-vue-editor";
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## Contributing
|
|
229
|
+
|
|
230
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines on how to contribute to this project.
|
|
231
|
+
|
|
232
|
+
## License
|
|
233
|
+
|
|
234
|
+
[MIT](./LICENSE)
|
|
235
|
+
|