sazmail-vue 0.1.0
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 +98 -0
- package/dist/MailBuilder.vue.d.ts +15 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.es.js +428 -0
- package/dist/types.d.ts +21 -0
- package/package.json +44 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-PRESENT Mazlum Ozdogan <https://github.com/mergehez>
|
|
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,98 @@
|
|
|
1
|
+
# Meyro
|
|
2
|
+
|
|
3
|
+
This is a Vue component that lets you use the [Sazmail](https://github.com/mergehez/sazmail) right inside your Vue 3 applications.
|
|
4
|
+
|
|
5
|
+
It's pretty straightforward to set up and use. The only dependency is Vue itself.
|
|
6
|
+
|
|
7
|
+
If you're working with React, there's a version for that too: [sazmail-react](https://github.com/mergehez/sazmail-react)
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
bun install sazmail-vue
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install sazmail-vue
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Basic Usage
|
|
20
|
+
|
|
21
|
+
```vue
|
|
22
|
+
<script setup lang="ts">
|
|
23
|
+
import {ref} from "vue";
|
|
24
|
+
import MailBuilder from 'sazmail-vue';
|
|
25
|
+
|
|
26
|
+
const form = ref({
|
|
27
|
+
doc: '{}', // Your email template JSON string, or an object.
|
|
28
|
+
// '{}' is a good starting point for a new template.
|
|
29
|
+
html: '' // This will hold the generated HTML output.
|
|
30
|
+
});
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<template>
|
|
34
|
+
<div class="w-full h-full">
|
|
35
|
+
<MailBuilder
|
|
36
|
+
id="my-builder"
|
|
37
|
+
v-model:json="form.doc"
|
|
38
|
+
v-model:html="form.html"
|
|
39
|
+
/>
|
|
40
|
+
</div>
|
|
41
|
+
</template>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
> Make sure the container for <MailBuilder /> has a defined height, as the builder will try to fill it.
|
|
45
|
+
|
|
46
|
+
## Props
|
|
47
|
+
|
|
48
|
+
| Prop | Type | Description |
|
|
49
|
+
|------|------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
50
|
+
| id | string | An optional unique ID for the builder instance. Useful if you have multiple builders on a page. |
|
|
51
|
+
| json | object (see structure below) or string (JSON stringified) or undefined | The core data for the email template. You can pass a JSON string or a JavaScript object directly. Use with `v-model:json`. An empty object or `'{}'` starts a new template. |
|
|
52
|
+
| html | string or undefined | Holds the generated HTML of the email template. Use with `v-model:html`. |
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
### `json` Prop Structure
|
|
56
|
+
|
|
57
|
+
The `json` prop (whether as an object or a string) should conform to this structure:
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
type BlockId = string;
|
|
61
|
+
|
|
62
|
+
// This is the expected type for the 'json' prop when passed as an object
|
|
63
|
+
export type MailBuilderDocument = {
|
|
64
|
+
version: string;
|
|
65
|
+
structure: Record<BlockId, {
|
|
66
|
+
customName?: string;
|
|
67
|
+
blockId: BlockId;
|
|
68
|
+
parentId: BlockId;
|
|
69
|
+
type: string;
|
|
70
|
+
condition?: string; // A liquid.js expression for conditional rendering
|
|
71
|
+
childrenIds?: BlockId[];
|
|
72
|
+
}>;
|
|
73
|
+
data: Record<BlockId, Record<string, any>>;
|
|
74
|
+
testJson?: Record<string, any>; // Sample data for template rendering/testing
|
|
75
|
+
};
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
> Providing an empty object `{}` or an empty JSON string `'{}'` will initialize a new, blank template.
|
|
79
|
+
|
|
80
|
+
## Emits
|
|
81
|
+
The component emits the following events:
|
|
82
|
+
- `update:json`: Emits the updated JSON data whenever it changes. This is useful for two-way binding with the `json` prop.
|
|
83
|
+
- `update:html`: Emits the generated HTML whenever it changes. This is useful for two-way binding with the `html` prop.
|
|
84
|
+
|
|
85
|
+
## A Little More Detail
|
|
86
|
+
|
|
87
|
+
This component is essentially a bridge to the main [Sazmail](https://github.com/mergehez/sazmail). The builder itself is a self-contained HTML file. sazmail-vue takes that file, puts it into an iframe, and then uses Vue's reactivity system to pass data back and forth. This way, you get the full builder experience without a
|
|
88
|
+
complicated setup.
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
This project is shared under the MIT License. You can find the details in the [LICENSE](LICENSE) file.
|
|
93
|
+
|
|
94
|
+
Feel free to use it in both personal and commercial projects.
|
|
95
|
+
|
|
96
|
+
## Contributing
|
|
97
|
+
|
|
98
|
+
Got ideas or improvements? Contributions are definitely welcome! Please read the [CONTRIBUTING.md](CONTRIBUTING.md) file for details on how to contribute.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { MailBuilderDocument, MailBuilderProps } from './types';
|
|
2
|
+
type __VLS_Props = MailBuilderProps<string | MailBuilderDocument>;
|
|
3
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {
|
|
4
|
+
requestDataFromBuilder: any;
|
|
5
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
6
|
+
"update:json": (args_0: any) => any;
|
|
7
|
+
"update:html": (args_0: string | undefined) => any;
|
|
8
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
9
|
+
"onUpdate:json"?: ((args_0: any) => any) | undefined;
|
|
10
|
+
"onUpdate:html"?: ((args_0: string | undefined) => any) | undefined;
|
|
11
|
+
}>, {
|
|
12
|
+
displayMode: "preview" | "edit";
|
|
13
|
+
autoSave: boolean;
|
|
14
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
15
|
+
export default _default;
|
package/dist/index.d.ts
ADDED