@mce/gif 0.17.10 → 0.17.13
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/index.js +45 -42
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,47 +1,50 @@
|
|
|
1
1
|
import { definePlugin } from "mce";
|
|
2
2
|
import { render } from "modern-canvas";
|
|
3
3
|
import { Encoder } from "modern-gif";
|
|
4
|
+
//#region src/plugin.ts
|
|
4
5
|
function plugin() {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
6
|
+
return definePlugin((editor, options) => {
|
|
7
|
+
const { assets, fonts, to } = editor;
|
|
8
|
+
const gifWorkerUrl = options.gifWorkerUrl;
|
|
9
|
+
assets.gifWorkerUrl = gifWorkerUrl;
|
|
10
|
+
return {
|
|
11
|
+
name: "mce:gif",
|
|
12
|
+
exporters: [{
|
|
13
|
+
name: "gif",
|
|
14
|
+
saveAs: true,
|
|
15
|
+
handle: async (options) => {
|
|
16
|
+
const { onProgress, ...restOptions } = options;
|
|
17
|
+
const data = to("json", restOptions);
|
|
18
|
+
const { startTime, endTime } = data.meta;
|
|
19
|
+
const width = Math.floor(data.style.width);
|
|
20
|
+
const height = Math.floor(data.style.height);
|
|
21
|
+
const encoder = new Encoder({
|
|
22
|
+
width,
|
|
23
|
+
height,
|
|
24
|
+
workerUrl: gifWorkerUrl
|
|
25
|
+
});
|
|
26
|
+
await render({
|
|
27
|
+
data,
|
|
28
|
+
width,
|
|
29
|
+
height,
|
|
30
|
+
fonts,
|
|
31
|
+
keyframes: Array.from({ length: ~~((endTime - startTime) / 100) }, (_, i) => startTime + i * 100),
|
|
32
|
+
onKeyframe: async (data, { duration, progress }) => {
|
|
33
|
+
await encoder.encode({
|
|
34
|
+
data,
|
|
35
|
+
delay: duration
|
|
36
|
+
});
|
|
37
|
+
onProgress?.(progress);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
return await encoder.flush("blob");
|
|
41
|
+
}
|
|
42
|
+
}]
|
|
43
|
+
};
|
|
44
|
+
});
|
|
43
45
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/index.ts
|
|
48
|
+
var src_default = plugin;
|
|
49
|
+
//#endregion
|
|
50
|
+
export { src_default as default, plugin };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mce/gif",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.17.
|
|
4
|
+
"version": "0.17.13",
|
|
5
5
|
"description": "GIF plugin for mce",
|
|
6
6
|
"author": "wxm",
|
|
7
7
|
"license": "MIT",
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"dist"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"modern-gif": "^2.0
|
|
49
|
+
"modern-gif": "^2.1.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"mce": "0.17.
|
|
52
|
+
"mce": "0.17.13"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"mce": "^0"
|