@lab2view/vue-email-editor 0.2.2 → 0.2.3

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.
Files changed (2) hide show
  1. package/README.md +42 -57
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,8 +1,4 @@
1
- <p align="center">
2
- <img src="src/assets/logo.png" alt="@lab2view/vue-email-editor" width="200" />
3
- </p>
4
-
5
- <h1 align="center">@lab2view/vue-email-editor</h1>
1
+ # Vue Email Editor
6
2
 
7
3
  <p align="center">
8
4
  <a href="https://www.npmjs.com/package/@lab2view/vue-email-editor"><img src="https://img.shields.io/npm/v/@lab2view/vue-email-editor.svg?style=flat-square" alt="npm version" /></a>
@@ -19,6 +15,10 @@
19
15
  <strong>Free and open-source alternative to Unlayer, Beefree, and Stripo.</strong>
20
16
  </p>
21
17
 
18
+ <p align="center">
19
+ <a href="https://lab2view.github.io/vue-email-editor/#templates"><strong>Try the editor live &rarr;</strong></a>
20
+ </p>
21
+
22
22
  ## Screenshots
23
23
 
24
24
  | Blocks & Layout | Ready-made Templates |
@@ -454,62 +454,47 @@ Insert dynamic content with merge tag variables:
454
454
 
455
455
  ## AI Template Generation
456
456
 
457
- Generate complete email templates from natural language prompts. The AI chat panel supports multi-turn conversations describe your email, preview the result, then refine it through follow-up messages before applying.
457
+ Generate complete email templates from natural language. Plug in any LLMOpenAI, Anthropic, Google Gemini, or your own.
458
458
 
459
459
  ```vue
460
- <EmailEditor
461
- :ai-provider="{
462
- // Full template generation via chat (enables the AI sidebar tab)
463
- generateTemplate: async (messages, systemPrompt) => {
464
- const response = await fetch('/api/ai/chat', {
465
- method: 'POST',
466
- body: JSON.stringify({
467
- messages: [
468
- { role: 'system', content: systemPrompt },
469
- ...messages,
470
- ],
471
- }),
472
- })
473
- return (await response.json()).content
474
- },
475
-
476
- // Optional: streaming for real-time generation feedback
477
- async *generateTemplateStream(messages, systemPrompt) {
478
- const response = await fetch('/api/ai/chat/stream', {
479
- method: 'POST',
480
- body: JSON.stringify({
481
- messages: [{ role: 'system', content: systemPrompt }, ...messages],
482
- stream: true,
483
- }),
484
- })
485
- const reader = response.body.getReader()
486
- const decoder = new TextDecoder()
487
- while (true) {
488
- const { done, value } = await reader.read()
489
- if (done) break
490
- yield decoder.decode(value)
491
- }
492
- },
493
-
494
- // Inline text generation (generate, improve, shorten, expand, translate)
495
- generateText: async (prompt, context) => {
496
- const res = await fetch('/api/ai/generate', {
497
- method: 'POST',
498
- body: JSON.stringify({ prompt, context }),
499
- })
500
- return (await res.json()).text
501
- },
502
- improveText: async (text, instruction) => {
503
- const res = await fetch('/api/ai/improve', {
504
- method: 'POST',
505
- body: JSON.stringify({ text, instruction }),
506
- })
507
- return (await res.json()).text
508
- },
509
- }"
510
- />
460
+ <script setup lang="ts">
461
+ import { ref } from 'vue'
462
+ import { EmailEditor } from '@lab2view/vue-email-editor'
463
+ import type { AiProvider } from '@lab2view/vue-email-editor'
464
+
465
+ const mjml = ref('')
466
+
467
+ const aiProvider: AiProvider = {
468
+ generateText: async (prompt, context) => {
469
+ const res = await fetch('/api/ai/text', {
470
+ method: 'POST',
471
+ headers: { 'Content-Type': 'application/json' },
472
+ body: JSON.stringify({ prompt, context }),
473
+ })
474
+ return (await res.json()).text
475
+ },
476
+ generateTemplate: async (messages, systemPrompt) => {
477
+ const res = await fetch('/api/ai/chat', {
478
+ method: 'POST',
479
+ headers: { 'Content-Type': 'application/json' },
480
+ body: JSON.stringify({ messages, systemPrompt }),
481
+ })
482
+ return (await res.json()).content
483
+ },
484
+ }
485
+ </script>
486
+
487
+ <template>
488
+ <EmailEditor v-model="mjml" :ai-provider="aiProvider" />
489
+ </template>
511
490
  ```
512
491
 
492
+ Your backend just forwards to any LLM and returns the raw response. The editor handles JSON parsing, repair, and retry automatically.
493
+
494
+ **Want to test without an API key?** Use the [mock provider](https://lab2view.github.io/vue-email-editor/guide/ai#mock-provider-for-testing) — a static `AiProvider` that returns dummy responses for development and testing.
495
+
496
+ **[Full AI integration guide →](https://lab2view.github.io/vue-email-editor/guide/ai)** — complete backend examples for OpenAI, Anthropic, and Google Gemini, streaming setup, error handling, and more.
497
+
513
498
  ## ESP Export
514
499
 
515
500
  Export HTML pre-formatted for your email service provider:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lab2view/vue-email-editor",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Vue 3 drag-and-drop email editor with AI-assisted editing, built on MJML",
5
5
  "license": "MIT",
6
6
  "type": "module",