@aicut/react 0.1.0 → 0.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.
- package/README.md +59 -33
- package/package.json +35 -2
package/README.md
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
# @aicut/react
|
|
2
2
|
|
|
3
|
-
React
|
|
3
|
+
> React wrapper for the **AiCut** video editor — canvas timeline, custom toolbar slots, theming, i18n, drop-in `<VideoEditor>`.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@aicut/react)
|
|
6
|
+
[](./LICENSE)
|
|
7
|
+
[](https://github.com/ziqiangai/AiCut)
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
## Install
|
|
4
12
|
|
|
5
13
|
```bash
|
|
6
14
|
pnpm add @aicut/react @aicut/core
|
|
@@ -19,12 +27,14 @@ import "@aicut/core/styles.css";
|
|
|
19
27
|
|
|
20
28
|
const project: Project = {
|
|
21
29
|
version: 1,
|
|
22
|
-
sources: [
|
|
23
|
-
|
|
24
|
-
{ id: "t1", kind: "video", clips: [
|
|
25
|
-
{ id: "c1", sourceId: "s1", in: 0, out: 5000, start: 0 },
|
|
26
|
-
]},
|
|
30
|
+
sources: [
|
|
31
|
+
{ id: "s1", url: "/media/a.mp4", kind: "video", name: "a.mp4" },
|
|
27
32
|
],
|
|
33
|
+
tracks: [{
|
|
34
|
+
id: "t1",
|
|
35
|
+
kind: "video",
|
|
36
|
+
clips: [{ id: "c1", sourceId: "s1", in: 0, out: 5000, start: 0 }],
|
|
37
|
+
}],
|
|
28
38
|
};
|
|
29
39
|
|
|
30
40
|
export function Editor() {
|
|
@@ -44,32 +54,45 @@ export function Editor() {
|
|
|
44
54
|
}
|
|
45
55
|
```
|
|
46
56
|
|
|
47
|
-
The component is **uncontrolled for project state** — the editor owns the current project. To restore from JSON later
|
|
57
|
+
The component is **uncontrolled for project state** — the editor owns the current project. To restore from JSON later:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
apiRef.current?.setProject(savedJson);
|
|
61
|
+
```
|
|
48
62
|
|
|
49
63
|
## Props
|
|
50
64
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
```ts
|
|
66
|
+
interface VideoEditorProps {
|
|
67
|
+
defaultProject?: Project;
|
|
68
|
+
|
|
69
|
+
theme?: Theme; // CSS-var overrides; reactive
|
|
70
|
+
locale?: Partial<Locale>; // EN default; pass localeZh for ZH
|
|
71
|
+
|
|
72
|
+
toolbarLeft?: ReactNode; // host controls — left bookend
|
|
73
|
+
toolbarRight?: ReactNode; // right bookend
|
|
74
|
+
|
|
75
|
+
apiRef?: Ref<VideoEditorApi | null>;
|
|
76
|
+
|
|
77
|
+
onReady?: (api: VideoEditorApi) => void;
|
|
78
|
+
onChange?: (project: Project) => void;
|
|
79
|
+
onExport?: (project: Project) => void; // fired by api.requestExport()
|
|
80
|
+
onTimeUpdate?: (ms: number) => void;
|
|
81
|
+
onPlay?: () => void;
|
|
82
|
+
onPause?: () => void;
|
|
83
|
+
onSelectionChange?: (clipId: string | null) => void;
|
|
84
|
+
onError?: (err: Error) => void;
|
|
85
|
+
|
|
86
|
+
className?: string;
|
|
87
|
+
style?: CSSProperties;
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The `apiRef` value exposes the full **`EditorApi`** — `play`, `pause`, `seek`, `split`, `trimLeft`, `trimRight`, `setProject`, `getProject`, `addSource`, `addTrack`, `removeClip`, `undo`, `redo`, `setTheme`, `setLocale`, `requestExport`, and more. See [@aicut/core](https://www.npmjs.com/package/@aicut/core) for the complete surface.
|
|
69
92
|
|
|
70
93
|
## Custom toolbar controls
|
|
71
94
|
|
|
72
|
-
|
|
95
|
+
The editor's top toolbar reserves bookend slots for any React node. The library hides the visual separator until you put something in them.
|
|
73
96
|
|
|
74
97
|
```tsx
|
|
75
98
|
<VideoEditor
|
|
@@ -88,7 +111,7 @@ Drop any React node into `toolbarLeft` / `toolbarRight`. The library renders not
|
|
|
88
111
|
/>
|
|
89
112
|
```
|
|
90
113
|
|
|
91
|
-
`api.requestExport()` fires the `export` event with the current project JSON, which flows back through your `onExport` prop.
|
|
114
|
+
`api.requestExport()` fires the `export` event with the current project JSON, which flows back through your `onExport` prop. Your handler decides whether to POST to a backend, download locally, etc.
|
|
92
115
|
|
|
93
116
|
## Theming
|
|
94
117
|
|
|
@@ -100,7 +123,7 @@ Drop any React node into `toolbarLeft` / `toolbarRight`. The library renders not
|
|
|
100
123
|
controlsBorder: "rgba(0, 0, 0, 0.08)",
|
|
101
124
|
controlsHover: "rgba(0, 0, 0, 0.06)",
|
|
102
125
|
controlsActive: "rgba(0, 0, 0, 0.08)",
|
|
103
|
-
previewBg: "#e4e4e7",
|
|
126
|
+
previewBg: "#e4e4e7", // letterbox colour around the video
|
|
104
127
|
}}
|
|
105
128
|
/* … */
|
|
106
129
|
/>
|
|
@@ -110,18 +133,21 @@ The `theme` prop is reactive — swap it any time and the editor calls `setTheme
|
|
|
110
133
|
|
|
111
134
|
## i18n
|
|
112
135
|
|
|
113
|
-
English is default. Pass the bundled `localeZh` for Chinese, or a partial object to override specific keys.
|
|
114
|
-
|
|
115
136
|
```tsx
|
|
116
137
|
import { VideoEditor, localeZh } from "@aicut/react";
|
|
117
138
|
|
|
139
|
+
// Whole-locale swap
|
|
118
140
|
<VideoEditor locale={localeZh} /* … */ />
|
|
141
|
+
|
|
142
|
+
// Partial override
|
|
119
143
|
<VideoEditor locale={{ undo: "Annuler" }} /* … */ />
|
|
120
144
|
```
|
|
121
145
|
|
|
146
|
+
`locale` is reactive too — runtime swap re-titles the toolbar and re-paints canvas labels in place.
|
|
147
|
+
|
|
122
148
|
## Standalone `<Timeline>`
|
|
123
149
|
|
|
124
|
-
Use the canvas timeline without the rest of the editor.
|
|
150
|
+
Use the canvas timeline without the rest of the editor — frame-pickers, thumbnail strips, read-only previews.
|
|
125
151
|
|
|
126
152
|
```tsx
|
|
127
153
|
import { Timeline, type TimelineApi } from "@aicut/react";
|
|
@@ -138,6 +164,6 @@ import { Timeline, type TimelineApi } from "@aicut/react";
|
|
|
138
164
|
/>
|
|
139
165
|
```
|
|
140
166
|
|
|
141
|
-
|
|
167
|
+
---
|
|
142
168
|
|
|
143
|
-
|
|
169
|
+
[Full docs & demo](https://github.com/ziqiangai/AiCut) · [@aicut/core](https://www.npmjs.com/package/@aicut/core) · [@aicut/vue](https://www.npmjs.com/package/@aicut/vue)
|
package/package.json
CHANGED
|
@@ -1,8 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aicut/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "React wrapper for the AiCut video editor — thin declarative shell over @aicut/core.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"author": "ziqiang <ziqiangytu@gmail.com>",
|
|
7
|
+
"homepage": "https://github.com/ziqiangai/AiCut#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/ziqiangai/AiCut.git",
|
|
11
|
+
"directory": "packages/react"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/ziqiangai/AiCut/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"video-editor",
|
|
18
|
+
"video-editing",
|
|
19
|
+
"react",
|
|
20
|
+
"react-component",
|
|
21
|
+
"timeline",
|
|
22
|
+
"timeline-editor",
|
|
23
|
+
"nle",
|
|
24
|
+
"video-cutter",
|
|
25
|
+
"video-clip",
|
|
26
|
+
"canvas",
|
|
27
|
+
"video",
|
|
28
|
+
"editor",
|
|
29
|
+
"mp4",
|
|
30
|
+
"component",
|
|
31
|
+
"capcut",
|
|
32
|
+
"premiere",
|
|
33
|
+
"final-cut",
|
|
34
|
+
"davinci",
|
|
35
|
+
"imovie",
|
|
36
|
+
"veed",
|
|
37
|
+
"filmora"
|
|
38
|
+
],
|
|
6
39
|
"type": "module",
|
|
7
40
|
"main": "./dist/index.cjs",
|
|
8
41
|
"module": "./dist/index.js",
|
|
@@ -19,7 +52,7 @@
|
|
|
19
52
|
"README.md"
|
|
20
53
|
],
|
|
21
54
|
"dependencies": {
|
|
22
|
-
"@aicut/core": "0.1.
|
|
55
|
+
"@aicut/core": "0.1.1"
|
|
23
56
|
},
|
|
24
57
|
"peerDependencies": {
|
|
25
58
|
"react": "^18.0.0 || ^19.0.0",
|