@milkdown/plugin-upload 5.3.1 → 5.3.5
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/lib/index.d.ts +1 -5
- package/lib/{default-uploader.d.ts → src/default-uploader.d.ts} +0 -0
- package/lib/src/default-uploader.d.ts.map +1 -0
- package/lib/src/index.d.ts +5 -0
- package/lib/src/index.d.ts.map +1 -0
- package/lib/{upload.d.ts → src/upload.d.ts} +1 -2
- package/lib/src/upload.d.ts.map +1 -0
- package/package.json +6 -13
- package/lib/default-uploader.d.ts.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/upload.d.ts.map +0 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export type { Uploader } from './upload';
|
|
3
|
-
export { uploadPlugin } from './upload';
|
|
4
|
-
export declare const upload: AtomList<import("@milkdown/utils/lib/types").Metadata<import("@milkdown/utils/lib/types").GetPlugin<string, import("./upload").Options>> & import("@milkdown/core").MilkdownPlugin>;
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
export * from './src/index'
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-uploader.d.ts","sourceRoot":"","sources":["default-uploader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAmBzC,eAAO,MAAM,eAAe,EAAE,QAqB7B,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AtomList } from '@milkdown/utils';
|
|
2
|
+
export type { Uploader } from './upload';
|
|
3
|
+
export { uploadPlugin } from './upload';
|
|
4
|
+
export declare const upload: AtomList<import("@milkdown/utils/lib/src/types").Metadata<import("@milkdown/utils/lib/src/types").GetPlugin<string, import("./upload").Options>> & import("@milkdown/core").MilkdownPlugin>;
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAI3C,YAAY,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,eAAO,MAAM,MAAM,6LAAoC,CAAC"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
/// <reference types="prosemirror-model" />
|
|
2
1
|
import type { Fragment, Node, Schema } from '@milkdown/prose';
|
|
3
2
|
export declare type Uploader = (files: FileList, schema: Schema) => Promise<Fragment | Node | Node[]>;
|
|
4
3
|
export declare type Options = {
|
|
5
4
|
uploader: Uploader;
|
|
6
5
|
enableHtmlFileUploader: boolean;
|
|
7
6
|
};
|
|
8
|
-
export declare const uploadPlugin: import("@milkdown/utils/lib/types").WithExtend<string, Options, {
|
|
7
|
+
export declare const uploadPlugin: import("@milkdown/utils/lib/src/types").WithExtend<string, Options, {
|
|
9
8
|
[x: string]: import("prosemirror-model").NodeType<any>;
|
|
10
9
|
} & {
|
|
11
10
|
[x: string]: import("prosemirror-model").MarkType<any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["upload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAc,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAM1E,oBAAY,QAAQ,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC,CAAC;AAE9F,oBAAY,OAAO,GAAG;IAClB,QAAQ,EAAE,QAAQ,CAAC;IACnB,sBAAsB,EAAE,OAAO,CAAC;CACnC,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;EAsGvB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milkdown/plugin-upload",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./lib/index.es.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -14,24 +14,17 @@
|
|
|
14
14
|
"milkdown",
|
|
15
15
|
"milkdown plugin"
|
|
16
16
|
],
|
|
17
|
-
"peerDependencies": {
|
|
18
|
-
"@milkdown/core": "*"
|
|
19
|
-
},
|
|
20
17
|
"dependencies": {
|
|
21
|
-
"@milkdown/
|
|
18
|
+
"@milkdown/core": "5.3.5",
|
|
19
|
+
"@milkdown/prose": "5.3.5",
|
|
20
|
+
"@milkdown/utils": "5.3.5",
|
|
22
21
|
"tslib": "^2.3.1"
|
|
23
22
|
},
|
|
24
|
-
"devDependencies": {
|
|
25
|
-
"@milkdown/core": "5.3.1",
|
|
26
|
-
"@milkdown/prose": "5.3.1",
|
|
27
|
-
"@milkdown/utils": "5.3.1"
|
|
28
|
-
},
|
|
29
23
|
"scripts": {
|
|
30
|
-
"start": "vite",
|
|
31
|
-
"watch": "vite build --watch",
|
|
24
|
+
"start": "vite build --watch",
|
|
32
25
|
"test": "vitest",
|
|
33
26
|
"tsc": "tsc --noEmit",
|
|
34
|
-
"build": "vite build
|
|
27
|
+
"build": "vite build"
|
|
35
28
|
},
|
|
36
29
|
"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# Config\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## enableHtmlFileUploader\n\nWhen 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.\n\n# License\n\nMilkdown is open sourced software licensed under [MIT license](https://github.com/Saul-Mirone/milkdown/blob/main/LICENSE).\n"
|
|
37
30
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"default-uploader.d.ts","sourceRoot":"","sources":["../src/default-uploader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAmBzC,eAAO,MAAM,eAAe,EAAE,QAqB7B,CAAC"}
|
package/lib/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAI3C,YAAY,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,eAAO,MAAM,MAAM,qLAAoC,CAAC"}
|
package/lib/upload.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAc,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAM1E,oBAAY,QAAQ,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC,CAAC;AAE9F,oBAAY,OAAO,GAAG;IAClB,QAAQ,EAAE,QAAQ,CAAC;IACnB,sBAAsB,EAAE,OAAO,CAAC;CACnC,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;EAsGvB,CAAC"}
|