@maily-to/core 0.1.3 → 0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maily-to/core",
3
- "version": "0.1.3",
3
+ "version": "0.2.1",
4
4
  "description": "Powerful editor for creating beautiful, pre-designed, mobile-ready emails.",
5
5
  "private": false,
6
6
  "main": "./dist/index.js",
package/readme.md CHANGED
@@ -149,13 +149,17 @@ You can pass variables to the editor in two ways:
149
149
 
150
150
  ```tsx
151
151
  // (Omitted repeated imports)
152
+ import { VariableExtension, getVariableSuggestions } from '@maily-to/core/extensions';
153
+
152
154
  <Editor
153
- variableTriggerCharacter="@"
154
- variables={[
155
- {
156
- name: 'currentDate',
157
- required: false,
158
- },
155
+ extensions={[
156
+ VariableExtension.configure({
157
+ suggestions: getVariableSuggestions('@'),
158
+ variables: [{
159
+ name: 'currentTime',
160
+ required: false,
161
+ }],
162
+ }),
159
163
  ]}
160
164
  />
161
165
  ```
@@ -166,26 +170,32 @@ You can pass variables to the editor in two ways:
166
170
 
167
171
  ```tsx
168
172
  // (Omitted repeated imports)
173
+ import { VariableExtension, getVariableSuggestions } from '@maily-to/core/extensions';
174
+
169
175
  <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
- }}
176
+ extensions={[
177
+ VariableExtension.configure({
178
+ suggestions: getVariableSuggestions('@'),
179
+ variables: ({ query, from, editor }) => {
180
+ // magic goes here
181
+ // query: the text after the trigger character
182
+ // from: the context from where the variables are requested (repeat, variable)
183
+ // editor: the editor instance
184
+ if (from === 'repeat-variable') {
185
+ // return variables for the Repeat block `each` key
186
+ return [
187
+ { name: 'notifications' },
188
+ { name: 'comments' },
189
+ ];
190
+ }
191
+
192
+ return [
193
+ { name: 'currentDate' },
194
+ { name: 'currentTime', required: false },
195
+ ];
196
+ },
197
+ }),
198
+ ]}
189
199
  />
190
200
  ```
191
201
 
@@ -217,11 +227,7 @@ import { MailyKit, VariableExtension, getVariableSuggestions } from '@maily-to/c
217
227
  });
218
228
  },
219
229
  }).configure({
220
- suggestions: getVariableSuggestions(
221
- variables,
222
- variableTriggerCharacter,
223
- variableListComponent, // optional custom component for variable list
224
- ),
230
+ suggestions: getVariableSuggestions(variableTriggerCharacter),
225
231
  }),
226
232
  ]}
227
233
  />
@@ -242,8 +248,58 @@ import { CustomExtension } from './extensions/custom-extension';
242
248
  />
243
249
  ```
244
250
 
251
+ ### Image Upload
252
+
253
+ 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.
254
+
255
+ ```tsx
256
+ // (Omitted repeated imports)
257
+ import { ImageUploadExtension } from '@maily-to/core/extensions';
258
+
259
+ <Editor
260
+ extensions={[
261
+ ImageUploadExtension.configure({
262
+ onImageUpload: async (file) => {
263
+ // upload the image to wherever you want
264
+ const url = await uploadImage(file);
265
+ return url;
266
+ },
267
+ }),
268
+ ]}
269
+ />
270
+ ```
271
+
245
272
  See the [@maily-to/render](../render) package for more information on how to render the editor content to HTML.
246
273
 
274
+ <br/>
275
+
276
+ ## Sponsors
277
+
278
+ 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).
279
+
280
+ <br/>
281
+
282
+ <h3 align="center">Gold</h3>
283
+
284
+ <table align="center" style="justify-content: center;align-items: center;display: flex;">
285
+ <tr>
286
+ <td align="center">
287
+ <p></p>
288
+ <p></p>
289
+ <a href="https://novu.co?ref=maily.to">
290
+ <picture height="60px">
291
+ <source media="(prefers-color-scheme: dark)" srcset="https://github.com/user-attachments/assets/5e2b9ef1-5ded-4863-995d-62c7e40f946a">
292
+ <img alt="Novu Logo" height="60px" src="https://github.com/user-attachments/assets/d2fdaf14-2211-4946-ab67-a4ce547aabc0">
293
+ </picture>
294
+ </a>
295
+ <p></p>
296
+ <p></p>
297
+ </td>
298
+ </tr>
299
+ </table>
300
+
301
+ <br/>
302
+
247
303
  ## License
248
304
 
249
305
  MIT &copy; [Arik Chakma](https://twitter.com/imarikchakma)