@milkdown/plugin-upload 5.2.1 → 5.3.0

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 (1) hide show
  1. package/package.json +7 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milkdown/plugin-upload",
3
- "version": "5.2.1",
3
+ "version": "5.3.0",
4
4
  "main": "./lib/index.cjs.js",
5
5
  "module": "./lib/index.es.js",
6
6
  "types": "./lib/index.d.ts",
@@ -24,13 +24,13 @@
24
24
  "@milkdown/core": "*"
25
25
  },
26
26
  "dependencies": {
27
- "@milkdown/utils": "5.2.1",
27
+ "@milkdown/utils": "5.3.0",
28
28
  "tslib": "^2.3.1"
29
29
  },
30
30
  "devDependencies": {
31
- "@milkdown/core": "5.2.1",
32
- "@milkdown/prose": "5.2.1",
33
- "@milkdown/utils": "5.2.1"
31
+ "@milkdown/core": "5.3.0",
32
+ "@milkdown/prose": "5.3.0",
33
+ "@milkdown/utils": "5.3.0"
34
34
  },
35
35
  "scripts": {
36
36
  "start": "vite",
@@ -38,5 +38,6 @@
38
38
  "test": "jest",
39
39
  "tsc": "tsc --noEmit",
40
40
  "build": "vite build && tsc --emitDeclarationOnly"
41
- }
41
+ },
42
+ "readme": "# @milkdown/plugin-upload\n\nUpload image when drop for [milkdown](https://saul-mirone.github.io/milkdown/).\n\n# Example Usage\n\n```typescript\nimport { Editor } from '@milkdown/core';\nimport { commonmark } from '@milkdown/preset-commonmark';\nimport { nord } from '@milkdown/theme-nord';\n\nimport { upload } from '@milkdown/plugin-upload';\n\nEditor.make().use(commonmark).use(upload).create();\n```\n\n# Setup Uploader\n\n> By default, this plugin will transfer image to base64 and ignore other file types.\n>\n> If you want to upload file and handle the generated blocks, you should setup the uploader.\n\n```typescript\n// ...\nimport { upload, uploadPlugin, Uploader } from '@milkdown/plugin-upload';\nimport type { Node } from 'prosemirror-model';\n\nconst uploader: Uploader = async (files, schema) => {\n const images: File[] = [];\n\n for (let i = 0; i < files.length; i++) {\n const file = files.item(i);\n if (!file) {\n continue;\n }\n\n // You can handle whatever the file type you want, we handle image here.\n if (!file.type.includes('image')) {\n continue;\n }\n\n images.push(file);\n }\n\n const nodes: Node[] = await Promise.all(\n images.map(async (image) => {\n const src = await YourUploadAPI(image);\n const alt = image.name;\n return schema.nodes.image.createAndFill({\n src,\n alt,\n }) as Node;\n }),\n );\n\n return nodes;\n};\n\nEditor.make()\n // .use(...)\n .use(\n upload.configure(uploadPlugin, {\n uploader,\n }),\n )\n .create();\n```\n\n# License\n\nMilkdown is open sourced software licensed under [MIT license](https://github.com/Saul-Mirone/milkdown/blob/main/LICENSE).\n"
42
43
  }