@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/dist/blocks/index.d.mts +3 -1
- package/dist/blocks/index.d.ts +3 -1
- package/dist/blocks/index.js +41 -26
- package/dist/blocks/index.js.map +1 -1
- package/dist/blocks/index.mjs +36 -22
- package/dist/blocks/index.mjs.map +1 -1
- package/dist/extensions/index.d.mts +203 -141
- package/dist/extensions/index.d.ts +203 -141
- package/dist/extensions/index.js +1455 -1030
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/index.mjs +1293 -873
- package/dist/extensions/index.mjs.map +1 -1
- package/dist/index.d.mts +0 -22
- package/dist/index.d.ts +0 -22
- package/dist/index.js +4864 -4472
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4884 -4490
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/readme.md +86 -30
package/package.json
CHANGED
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
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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 © [Arik Chakma](https://twitter.com/imarikchakma)
|