@daisychainapp/maily-to-core 0.0.2-2.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/dist/blocks/index.d.mts +40 -0
- package/dist/blocks/index.d.ts +40 -0
- package/dist/blocks/index.js +263 -0
- package/dist/blocks/index.js.map +1 -0
- package/dist/blocks/index.mjs +233 -0
- package/dist/blocks/index.mjs.map +1 -0
- package/dist/index.d.mts +65 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.js +6654 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +6696 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +111 -0
- package/readme.md +121 -0
package/package.json
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@daisychainapp/maily-to-core",
|
|
3
|
+
"version": "0.0.22.1",
|
|
4
|
+
"description": "Powerful editor for creating beautiful, pre-designed, mobile-ready emails.",
|
|
5
|
+
"private": false,
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/**"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
"./package.json": "./package.json",
|
|
14
|
+
".": {
|
|
15
|
+
"browser": "./dist/index.mjs",
|
|
16
|
+
"import": "./dist/index.mjs",
|
|
17
|
+
"require": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./blocks": {
|
|
20
|
+
"browser": "./dist/blocks/index.mjs",
|
|
21
|
+
"import": "./dist/blocks/index.mjs",
|
|
22
|
+
"require": "./dist/blocks/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"typesVersions": {
|
|
26
|
+
"*": {
|
|
27
|
+
"*": [
|
|
28
|
+
"dist/index.d.ts"
|
|
29
|
+
],
|
|
30
|
+
"blocks": [
|
|
31
|
+
"dist/blocks/index.d.ts"
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"dev": "tsup --watch",
|
|
37
|
+
"clean": "rm -rf dist",
|
|
38
|
+
"build": "tsup"
|
|
39
|
+
},
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "git+https://github.com/arikchakma/maily.to.git",
|
|
43
|
+
"directory": "packages/core"
|
|
44
|
+
},
|
|
45
|
+
"author": "Arik Chakma <arikchangma@gmail.com>",
|
|
46
|
+
"keywords": [
|
|
47
|
+
"tiptap",
|
|
48
|
+
"wysiwyg",
|
|
49
|
+
"maily.to",
|
|
50
|
+
"editor",
|
|
51
|
+
"react",
|
|
52
|
+
"email"
|
|
53
|
+
],
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=18.0.0"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@radix-ui/react-dropdown-menu": "^2.1.2",
|
|
59
|
+
"@radix-ui/react-popover": "^1.1.2",
|
|
60
|
+
"@radix-ui/react-slot": "^1.1.0",
|
|
61
|
+
"@radix-ui/react-tooltip": "^1.1.3",
|
|
62
|
+
"@tiptap/core": "^2.9.1",
|
|
63
|
+
"@tiptap/extension-color": "^2.9.1",
|
|
64
|
+
"@tiptap/extension-document": "^2.9.1",
|
|
65
|
+
"@tiptap/extension-dropcursor": "^2.9.1",
|
|
66
|
+
"@tiptap/extension-focus": "^2.9.1",
|
|
67
|
+
"@tiptap/extension-heading": "^2.9.1",
|
|
68
|
+
"@tiptap/extension-horizontal-rule": "^2.9.1",
|
|
69
|
+
"@tiptap/extension-image": "^2.9.1",
|
|
70
|
+
"@tiptap/extension-link": "^2.9.1",
|
|
71
|
+
"@tiptap/extension-list-item": "^2.9.1",
|
|
72
|
+
"@tiptap/extension-mention": "^2.9.1",
|
|
73
|
+
"@tiptap/extension-paragraph": "^2.9.1",
|
|
74
|
+
"@tiptap/extension-placeholder": "^2.9.1",
|
|
75
|
+
"@tiptap/extension-text-align": "^2.9.1",
|
|
76
|
+
"@tiptap/extension-text-style": "^2.9.1",
|
|
77
|
+
"@tiptap/extension-underline": "^2.9.1",
|
|
78
|
+
"@tiptap/pm": "^2.9.1",
|
|
79
|
+
"@tiptap/react": "^2.9.1",
|
|
80
|
+
"@tiptap/starter-kit": "^2.9.1",
|
|
81
|
+
"@tiptap/suggestion": "^2.9.1",
|
|
82
|
+
"clsx": "^2.1.1",
|
|
83
|
+
"fast-deep-equal": "^3.1.3",
|
|
84
|
+
"lucide-react": "^0.453.0",
|
|
85
|
+
"react-colorful": "^5.6.1",
|
|
86
|
+
"tailwind-merge": "^2.5.4",
|
|
87
|
+
"tailwindcss": "^3.4.14",
|
|
88
|
+
"tippy.js": "^6.3.7",
|
|
89
|
+
"uuid": "^10.0.0",
|
|
90
|
+
"y-prosemirror": "^1.2.15"
|
|
91
|
+
},
|
|
92
|
+
"devDependencies": {
|
|
93
|
+
"@types/react": "^18.3.12",
|
|
94
|
+
"@types/uuid": "^10.0.0",
|
|
95
|
+
"postcss": "^8.4.47",
|
|
96
|
+
"tailwind-config": "workspace:*",
|
|
97
|
+
"tsconfig": "workspace:*",
|
|
98
|
+
"typescript": "^5.6.3"
|
|
99
|
+
},
|
|
100
|
+
"peerDependencies": {
|
|
101
|
+
"react": "^18.3.1"
|
|
102
|
+
},
|
|
103
|
+
"publishConfig": {
|
|
104
|
+
"access": "public"
|
|
105
|
+
},
|
|
106
|
+
"license": "ISC",
|
|
107
|
+
"bugs": {
|
|
108
|
+
"url": "https://github.com/arikchakma/maily.to/issues"
|
|
109
|
+
},
|
|
110
|
+
"homepage": "https://github.com/arikchakma/maily.to#readme"
|
|
111
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
<h1 align="center"><img height="150" src="https://maily.to/brand/icon.svg" /><br> @maily.to/core</h1>
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://github.com/arikchakma/maily.to/blob/main/license">
|
|
5
|
+
<img src="https://img.shields.io/badge/License-MIT-yellow.svg" />
|
|
6
|
+
</a>
|
|
7
|
+
<a href="https://maily.to">
|
|
8
|
+
<img src="https://img.shields.io/badge/%E2%9C%A8-Get%20Editor-0a0a0a.svg?style=flat&colorA=0a0a0a" alt="Get Maily Editor" />
|
|
9
|
+
</a>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
> Currently, this package is under development. You can follow the progress [here](https://github.com/arikchakma/maily.to).
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add @maily-to/core
|
|
18
|
+
|
|
19
|
+
# for types
|
|
20
|
+
pnpm add -D @tiptap/core
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import { useState } from 'react';
|
|
27
|
+
import { Editor } from '@maily-to/core';
|
|
28
|
+
import type { Editor as TiptapEditor, JSONContent } from '@tiptap/core';
|
|
29
|
+
|
|
30
|
+
type AppProps = {
|
|
31
|
+
contentJson: JSONContent;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
function App(props: AppProps) {
|
|
35
|
+
const { contentJson: defaultContentJson } = props;
|
|
36
|
+
const [editor, setEditor] = useState<TiptapEditor>();
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<Editor
|
|
40
|
+
contentJson={defaultContentJson}
|
|
41
|
+
onCreate={setEditor}
|
|
42
|
+
onUpdate={setEditor}
|
|
43
|
+
/>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Slash Commands
|
|
49
|
+
|
|
50
|
+
Slash commands are a way to interact with the editor using `/` followed by a command name. For example, `/heading1` will convert the current paragraph to a heading 1.
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
// (Omitted repeated imports)
|
|
54
|
+
import { text, heading1 } from '@maily-to/core/blocks';
|
|
55
|
+
|
|
56
|
+
<Editor
|
|
57
|
+
blocks={[text, heading1]}
|
|
58
|
+
/>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
> Note: The order of the blocks matters. It will be shown in the order you provide.
|
|
62
|
+
|
|
63
|
+
### Variables
|
|
64
|
+
|
|
65
|
+
By default, variables are required. You can make them optional by setting the `required` property to `false`. When a variable is optional and not provided, a placeholder will be displayed in its place.
|
|
66
|
+
|
|
67
|
+
You can pass variables to the editor in two ways:
|
|
68
|
+
|
|
69
|
+
1. As an Array of Objects:
|
|
70
|
+
|
|
71
|
+
For auto-suggestions of variables in the editor when you type `@`, pass the variables as an array of objects to the `variables` prop.
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
// (Omitted repeated imports)
|
|
75
|
+
<Editor
|
|
76
|
+
variableTriggerCharacter="@"
|
|
77
|
+
variables={[
|
|
78
|
+
{
|
|
79
|
+
name: 'currentDate',
|
|
80
|
+
required: false,
|
|
81
|
+
},
|
|
82
|
+
]}
|
|
83
|
+
/>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
2. As a Function:
|
|
87
|
+
|
|
88
|
+
If the variables are dynamic and need to be generated based on the editor's state or other inputs, you can provide a function to the `variables` prop.
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
// (Omitted repeated imports)
|
|
92
|
+
<Editor
|
|
93
|
+
variableTriggerCharacter="@"
|
|
94
|
+
variables={({ query, from, editor }) => {
|
|
95
|
+
// magic goes here
|
|
96
|
+
// query: the text after the trigger character
|
|
97
|
+
// from: the context from where the variables are requested (for, variable)
|
|
98
|
+
// editor: the editor instance
|
|
99
|
+
if (from === 'for') {
|
|
100
|
+
// return variables for the For block `each` key
|
|
101
|
+
return [
|
|
102
|
+
{ name: 'notifications' },
|
|
103
|
+
{ name: 'comments' },
|
|
104
|
+
];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return [
|
|
108
|
+
{ name: 'currentDate' },
|
|
109
|
+
{ name: 'currentTime', required: false },
|
|
110
|
+
];
|
|
111
|
+
}}
|
|
112
|
+
/>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
> Keep it in mind that if you pass an array of variable object Maily will take care of the filtering based on the query. But if you pass a function you have to take care of the filtering.
|
|
116
|
+
|
|
117
|
+
See the [@maily-to/render](../render) package for more information on how to render the editor content to HTML.
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
|
|
121
|
+
MIT © [Arik Chakma](https://twitter.com/imarikchakma)
|