全部组件
Video Editor
受控视频剪辑器,支持多片段时间线、音频混合、文字字幕、分割裁剪与撤销重做。
正在加载交互演示正在加载交互演示…
安装
pnpm dlx media-rig@latest add video-editor目标项目使用 React 19 / Tailwind CSS 4。没有 components.json 时先运行 pnpm dlx media-rig@latest init。CLI 需要 Node.js 22.12+ 和 npm/npx。
pnpm 11 项目在 pnpm-workspace.yaml 合并以下配置,跳过浏览器不需要的 canvas 原生构建并统一 Three.js 类型:
allowBuilds:
canvas: false
overrides:
'@types/three': '^0.168.0'保留项目已有配置;已有 Three.js 依赖时先检查兼容性。示例素材和业务接口由宿主提供。
使用示例
属性
| 属性名 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| value / onChange | VideoEditDocument / (value: VideoEditDocument) => void | 必填 | 受控工程数据;保持未修改对象的引用,更新时立即提交状态。 |
| sources | VideoEditorSource[] | 必填 | 视频和音频素材列表,包含唯一 id、url、label 和 kind。 |
| autoImport | boolean | false | 自动按顺序导入新素材。 |
| services | VideoEditorServices | undefined | 可注入元数据、缩略图和波形加载器。 |
| onExport / exportActions | VideoEditorOptions | undefined | 由宿主实现编码与保存,支持取消及进度回报;组件不内置编码器。 |
| translate | VideoEditorTranslate | English | 可替换内置文案,键以 videoEditor. 开头。 |
| readOnly | boolean | false | 禁用编辑、导入和导出。 |