@daisychainapp/maily-to-core 0.1.3 → 0.2.8

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/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@daisychainapp/maily-to-core",
3
- "version": "0.1.3",
3
+ "type": "module",
4
+ "version": "0.2.8",
4
5
  "description": "Powerful editor for creating beautiful, pre-designed, mobile-ready emails.",
5
6
  "private": false,
6
- "main": "./dist/index.js",
7
+ "main": "./dist/index.cjs",
7
8
  "module": "./dist/index.mjs",
8
9
  "types": "./dist/index.d.ts",
9
10
  "files": [
@@ -12,20 +13,102 @@
12
13
  "exports": {
13
14
  "./package.json": "./package.json",
14
15
  ".": {
15
- "browser": "./dist/index.mjs",
16
- "import": "./dist/index.mjs",
17
- "require": "./dist/index.js"
16
+ "node": {
17
+ "import": {
18
+ "types": "./dist/index.d.ts",
19
+ "default": "./dist/index.mjs"
20
+ },
21
+ "require": {
22
+ "types": "./dist/index.d.ts",
23
+ "default": "./dist/index.cjs"
24
+ }
25
+ },
26
+ "browser": {
27
+ "import": {
28
+ "types": "./dist/index.d.ts",
29
+ "default": "./dist/index.mjs"
30
+ },
31
+ "require": {
32
+ "types": "./dist/index.d.ts",
33
+ "default": "./dist/index.cjs"
34
+ }
35
+ },
36
+ "default": {
37
+ "import": {
38
+ "types": "./dist/index.d.ts",
39
+ "default": "./dist/index.mjs"
40
+ },
41
+ "require": {
42
+ "types": "./dist/index.d.ts",
43
+ "default": "./dist/index.cjs"
44
+ }
45
+ }
18
46
  },
19
47
  "./blocks": {
20
- "browser": "./dist/blocks/index.mjs",
21
- "import": "./dist/blocks/index.mjs",
22
- "require": "./dist/blocks/index.js"
48
+ "node": {
49
+ "import": {
50
+ "types": "./dist/blocks/index.d.ts",
51
+ "default": "./dist/blocks/index.mjs"
52
+ },
53
+ "require": {
54
+ "types": "./dist/blocks/index.d.ts",
55
+ "default": "./dist/blocks/index.cjs"
56
+ }
57
+ },
58
+ "browser": {
59
+ "import": {
60
+ "types": "./dist/blocks/index.d.ts",
61
+ "default": "./dist/blocks/index.mjs"
62
+ },
63
+ "require": {
64
+ "types": "./dist/blocks/index.d.ts",
65
+ "default": "./dist/blocks/index.cjs"
66
+ }
67
+ },
68
+ "default": {
69
+ "import": {
70
+ "types": "./dist/blocks/index.d.ts",
71
+ "default": "./dist/blocks/index.mjs"
72
+ },
73
+ "require": {
74
+ "types": "./dist/blocks/index.d.ts",
75
+ "default": "./dist/blocks/index.cjs"
76
+ }
77
+ }
23
78
  },
24
79
  "./extensions": {
25
- "browser": "./dist/extensions/index.mjs",
26
- "import": "./dist/extensions/index.mjs",
27
- "require": "./dist/extensions/index.js"
28
- }
80
+ "node": {
81
+ "import": {
82
+ "types": "./dist/extensions/index.d.ts",
83
+ "default": "./dist/extensions/index.mjs"
84
+ },
85
+ "require": {
86
+ "types": "./dist/extensions/index.d.ts",
87
+ "default": "./dist/extensions/index.cjs"
88
+ }
89
+ },
90
+ "browser": {
91
+ "import": {
92
+ "types": "./dist/extensions/index.d.ts",
93
+ "default": "./dist/extensions/index.mjs"
94
+ },
95
+ "require": {
96
+ "types": "./dist/extensions/index.d.ts",
97
+ "default": "./dist/extensions/index.cjs"
98
+ }
99
+ },
100
+ "default": {
101
+ "import": {
102
+ "types": "./dist/extensions/index.d.ts",
103
+ "default": "./dist/extensions/index.mjs"
104
+ },
105
+ "require": {
106
+ "types": "./dist/extensions/index.d.ts",
107
+ "default": "./dist/extensions/index.cjs"
108
+ }
109
+ }
110
+ },
111
+ "./style.css": "./dist/index.css"
29
112
  },
30
113
  "typesVersions": {
31
114
  "*": {
@@ -63,60 +146,55 @@
63
146
  "node": ">=18.0.0"
64
147
  },
65
148
  "dependencies": {
66
- "@radix-ui/react-dropdown-menu": "^2.1.2",
67
- "@radix-ui/react-popover": "^1.1.2",
68
- "@radix-ui/react-slot": "^1.1.0",
69
- "@radix-ui/react-tooltip": "^1.1.3",
70
- "@tiptap/core": "^2.9.1",
149
+ "@radix-ui/react-dropdown-menu": "^2.1.6",
150
+ "@radix-ui/react-popover": "^1.1.6",
151
+ "@radix-ui/react-slot": "^1.1.2",
152
+ "@radix-ui/react-tooltip": "^1.1.8",
153
+ "@tiptap/core": "^2.11.5",
71
154
  "@tiptap/extension-code-block-lowlight": "^2.11.5",
72
- "@tiptap/extension-color": "^2.9.1",
73
- "@tiptap/extension-document": "^2.9.1",
74
- "@tiptap/extension-dropcursor": "^2.9.1",
75
- "@tiptap/extension-focus": "^2.9.1",
76
- "@tiptap/extension-heading": "^2.9.1",
77
- "@tiptap/extension-horizontal-rule": "^2.9.1",
78
- "@tiptap/extension-image": "^2.9.1",
79
- "@tiptap/extension-link": "^2.9.1",
80
- "@tiptap/extension-list-item": "^2.9.1",
81
- "@tiptap/extension-mention": "^2.9.1",
82
- "@tiptap/extension-paragraph": "^2.9.1",
83
- "@tiptap/extension-placeholder": "^2.9.1",
84
- "@tiptap/extension-text-align": "^2.9.1",
85
- "@tiptap/extension-text-style": "^2.9.1",
86
- "@tiptap/extension-underline": "^2.9.1",
87
- "@tiptap/pm": "^2.9.1",
88
- "@tiptap/react": "^2.9.1",
89
- "@tiptap/starter-kit": "^2.9.1",
90
- "@tiptap/suggestion": "^2.9.1",
155
+ "@tiptap/extension-color": "^2.11.5",
156
+ "@tiptap/extension-document": "^2.11.5",
157
+ "@tiptap/extension-dropcursor": "^2.11.5",
158
+ "@tiptap/extension-focus": "^2.11.5",
159
+ "@tiptap/extension-heading": "^2.11.5",
160
+ "@tiptap/extension-horizontal-rule": "^2.11.5",
161
+ "@tiptap/extension-image": "^2.11.5",
162
+ "@tiptap/extension-link": "^2.11.5",
163
+ "@tiptap/extension-list-item": "^2.11.5",
164
+ "@tiptap/extension-mention": "^2.11.5",
165
+ "@tiptap/extension-paragraph": "^2.11.5",
166
+ "@tiptap/extension-placeholder": "^2.11.5",
167
+ "@tiptap/extension-text-align": "^2.11.5",
168
+ "@tiptap/extension-text-style": "^2.11.5",
169
+ "@tiptap/extension-underline": "^2.11.5",
170
+ "@tiptap/pm": "^2.11.5",
171
+ "@tiptap/react": "^2.11.5",
172
+ "@tiptap/starter-kit": "^2.11.5",
173
+ "@tiptap/suggestion": "^2.11.5",
91
174
  "clsx": "^2.1.1",
92
175
  "fast-deep-equal": "^3.1.3",
93
176
  "highlight.js": "^11.11.1",
94
177
  "lowlight": "^3.3.0",
95
- "lucide-react": "^0.453.0",
178
+ "lucide-react": "^0.483.0",
96
179
  "react-colorful": "^5.6.1",
97
180
  "tailwind-merge": "^2.5.4",
98
181
  "tailwindcss": "^3.4.14",
99
182
  "tippy.js": "^6.3.7",
100
- "uuid": "^10.0.0",
101
- "y-prosemirror": "^1.2.15"
183
+ "uuid": "^11.1.0",
184
+ "y-prosemirror": "^1.3.0"
102
185
  },
103
186
  "devDependencies": {
104
- "@types/react": "^18.3.12",
105
- "@types/uuid": "^10.0.0",
106
- "postcss": "^8.4.47",
187
+ "@types/react": "^18.3.18",
188
+ "postcss": "^8.5.3",
189
+ "postcss-replace": "^2.0.1",
107
190
  "tailwind-config": "workspace:*",
108
191
  "tsconfig": "workspace:*",
109
- "typescript": "^5.6.3"
192
+ "typescript": "^5.8.2"
110
193
  },
111
194
  "peerDependencies": {
112
- "react": "^18.3.1"
195
+ "react": "^18 || ^19"
113
196
  },
114
197
  "publishConfig": {
115
198
  "access": "public"
116
- },
117
- "license": "ISC",
118
- "bugs": {
119
- "url": "https://github.com/arikchakma/maily.to/issues"
120
- },
121
- "homepage": "https://github.com/arikchakma/maily.to#readme"
199
+ }
122
200
  }
package/readme.md CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  <p align="center">
4
4
  <a href="https://github.com/arikchakma/maily.to/blob/main/license">
5
- <img src="https://img.shields.io/badge/License-MIT-yellow.svg" />
5
+ <img src="https://img.shields.io/badge/License-MIT-222222.svg" />
6
6
  </a>
7
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>
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
10
  </p>
11
11
 
12
12
  > Currently, this package is under development. You can follow the progress [here](https://github.com/arikchakma/maily.to).
@@ -23,6 +23,8 @@ pnpm add -D @tiptap/core
23
23
  ## Usage
24
24
 
25
25
  ```tsx
26
+ import '@maily-to/core/style.css';
27
+
26
28
  import { useState } from 'react';
27
29
  import { Editor } from '@maily-to/core';
28
30
  import type { Editor as TiptapEditor, JSONContent } from '@tiptap/core';
@@ -149,13 +151,17 @@ You can pass variables to the editor in two ways:
149
151
 
150
152
  ```tsx
151
153
  // (Omitted repeated imports)
154
+ import { VariableExtension, getVariableSuggestions } from '@maily-to/core/extensions';
155
+
152
156
  <Editor
153
- variableTriggerCharacter="@"
154
- variables={[
155
- {
156
- name: 'currentDate',
157
- required: false,
158
- },
157
+ extensions={[
158
+ VariableExtension.configure({
159
+ suggestions: getVariableSuggestions('@'),
160
+ variables: [{
161
+ name: 'currentTime',
162
+ required: false,
163
+ }],
164
+ }),
159
165
  ]}
160
166
  />
161
167
  ```
@@ -166,26 +172,32 @@ You can pass variables to the editor in two ways:
166
172
 
167
173
  ```tsx
168
174
  // (Omitted repeated imports)
175
+ import { VariableExtension, getVariableSuggestions } from '@maily-to/core/extensions';
176
+
169
177
  <Editor
170
- variableTriggerCharacter="@"
171
- variables={({ query, from, editor }) => {
172
- // magic goes here
173
- // query: the text after the trigger character
174
- // from: the context from where the variables are requested (repeat, variable)
175
- // editor: the editor instance
176
- if (from === 'repeat-variable') {
177
- // return variables for the Repeat block `each` key
178
- return [
179
- { name: 'notifications' },
180
- { name: 'comments' },
181
- ];
182
- }
183
-
184
- return [
185
- { name: 'currentDate' },
186
- { name: 'currentTime', required: false },
187
- ];
188
- }}
178
+ extensions={[
179
+ VariableExtension.configure({
180
+ suggestions: getVariableSuggestions('@'),
181
+ variables: ({ query, from, editor }) => {
182
+ // magic goes here
183
+ // query: the text after the trigger character
184
+ // from: the context from where the variables are requested (repeat, variable)
185
+ // editor: the editor instance
186
+ if (from === 'repeat-variable') {
187
+ // return variables for the Repeat block `each` key
188
+ return [
189
+ { name: 'notifications' },
190
+ { name: 'comments' },
191
+ ];
192
+ }
193
+
194
+ return [
195
+ { name: 'currentDate' },
196
+ { name: 'currentTime', required: false },
197
+ ];
198
+ },
199
+ }),
200
+ ]}
189
201
  />
190
202
  ```
191
203
 
@@ -217,11 +229,7 @@ import { MailyKit, VariableExtension, getVariableSuggestions } from '@maily-to/c
217
229
  });
218
230
  },
219
231
  }).configure({
220
- suggestions: getVariableSuggestions(
221
- variables,
222
- variableTriggerCharacter,
223
- variableListComponent, // optional custom component for variable list
224
- ),
232
+ suggestions: getVariableSuggestions(variableTriggerCharacter),
225
233
  }),
226
234
  ]}
227
235
  />
@@ -242,8 +250,58 @@ import { CustomExtension } from './extensions/custom-extension';
242
250
  />
243
251
  ```
244
252
 
253
+ ### Image Upload
254
+
255
+ To enable image upload, you need to pass the `ImageUploadExtension` extension to the editor. The `onImageUpload` function will be called when an image is being uploaded. You can use this function to upload the image to your server and return the URL.
256
+
257
+ ```tsx
258
+ // (Omitted repeated imports)
259
+ import { ImageUploadExtension } from '@maily-to/core/extensions';
260
+
261
+ <Editor
262
+ extensions={[
263
+ ImageUploadExtension.configure({
264
+ onImageUpload: async (file) => {
265
+ // upload the image to wherever you want
266
+ const url = await uploadImage(file);
267
+ return url;
268
+ },
269
+ }),
270
+ ]}
271
+ />
272
+ ```
273
+
245
274
  See the [@maily-to/render](../render) package for more information on how to render the editor content to HTML.
246
275
 
276
+ <br/>
277
+
278
+ ## Sponsors
279
+
280
+ Sponsorship at any level is appreciated and encouraged. If you built a paid product using Maily, consider one of the [sponsorship tiers](https://github.com/sponsors/arikchakma).
281
+
282
+ <br/>
283
+
284
+ <h3 align="center">Gold</h3>
285
+
286
+ <table align="center" style="justify-content: center;align-items: center;display: flex;">
287
+ <tr>
288
+ <td align="center">
289
+ <p></p>
290
+ <p></p>
291
+ <a href="https://novu.co?ref=maily.to">
292
+ <picture height="60px">
293
+ <source media="(prefers-color-scheme: dark)" srcset="https://github.com/user-attachments/assets/5e2b9ef1-5ded-4863-995d-62c7e40f946a">
294
+ <img alt="Novu Logo" height="60px" src="https://github.com/user-attachments/assets/d2fdaf14-2211-4946-ab67-a4ce547aabc0">
295
+ </picture>
296
+ </a>
297
+ <p></p>
298
+ <p></p>
299
+ </td>
300
+ </tr>
301
+ </table>
302
+
303
+ <br/>
304
+
247
305
  ## License
248
306
 
249
307
  MIT &copy; [Arik Chakma](https://twitter.com/imarikchakma)