@milkdown/plugin-upload 6.1.0 → 6.1.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.
Files changed (2) hide show
  1. package/README.md +3 -69
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -1,76 +1,10 @@
1
1
  # @milkdown/plugin-upload
2
2
 
3
- Upload image when drop for [milkdown](https://milkdown.dev/).
3
+ The upload plugin of [milkdown](https://milkdown.dev/).
4
4
 
5
- # Example Usage
5
+ # Official Documentation
6
6
 
7
- ```typescript
8
- import { Editor } from '@milkdown/core';
9
- import { commonmark } from '@milkdown/preset-commonmark';
10
- import { nord } from '@milkdown/theme-nord';
11
-
12
- import { upload } from '@milkdown/plugin-upload';
13
-
14
- Editor.make().use(commonmark).use(upload).create();
15
- ```
16
-
17
- # Config
18
-
19
- ## Setup Uploader
20
-
21
- > By default, this plugin will transfer image to base64 and ignore other file types.
22
- >
23
- > If you want to upload file and handle the generated blocks, you should setup the uploader.
24
-
25
- ```typescript
26
- // ...
27
- import { upload, uploadPlugin, Uploader } from '@milkdown/plugin-upload';
28
- import type { Node } from 'prosemirror-model';
29
-
30
- const uploader: Uploader = async (files, schema) => {
31
- const images: File[] = [];
32
-
33
- for (let i = 0; i < files.length; i++) {
34
- const file = files.item(i);
35
- if (!file) {
36
- continue;
37
- }
38
-
39
- // You can handle whatever the file type you want, we handle image here.
40
- if (!file.type.includes('image')) {
41
- continue;
42
- }
43
-
44
- images.push(file);
45
- }
46
-
47
- const nodes: Node[] = await Promise.all(
48
- images.map(async (image) => {
49
- const src = await YourUploadAPI(image);
50
- const alt = image.name;
51
- return schema.nodes.image.createAndFill({
52
- src,
53
- alt,
54
- }) as Node;
55
- }),
56
- );
57
-
58
- return nodes;
59
- };
60
-
61
- Editor.make()
62
- // .use(...)
63
- .use(
64
- upload.configure(uploadPlugin, {
65
- uploader,
66
- }),
67
- )
68
- .create();
69
- ```
70
-
71
- ## enableHtmlFileUploader
72
-
73
- When paste files from html (for example copy images by right click context menu), this option will make the plugin to upload the image copied instead of using the original link.
7
+ Documentation can be found on the [Milkdown website](https://milkdown.dev/plugin-upload).
74
8
 
75
9
  # License
76
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milkdown/plugin-upload",
3
- "version": "6.1.0",
3
+ "version": "6.1.1",
4
4
  "type": "module",
5
5
  "main": "./lib/index.es.js",
6
6
  "types": "./lib/index.d.ts",
@@ -15,15 +15,15 @@
15
15
  "milkdown plugin"
16
16
  ],
17
17
  "devDependencies": {
18
- "@milkdown/core": "6.1.0",
19
- "@milkdown/prose": "6.1.0"
18
+ "@milkdown/core": "6.1.1",
19
+ "@milkdown/prose": "6.1.1"
20
20
  },
21
21
  "peerDependencies": {
22
22
  "@milkdown/core": "^6.0.1",
23
23
  "@milkdown/prose": "^6.0.1"
24
24
  },
25
25
  "dependencies": {
26
- "@milkdown/utils": "6.1.0",
26
+ "@milkdown/utils": "6.1.1",
27
27
  "tslib": "^2.3.1"
28
28
  },
29
29
  "nx": {