@cloudgpt/timeline-editor

中文文档
1.0.0发布于 2025/08/13MITTypeScriptESM + CJS近 30 天下载 5644

Enhanced React timeline editor with advanced features including theme system, max duration controls, cursor customization, handle styling, and media support for video editing applications.

原始使用文档
文档目录13 节
  1. ✨ Key Features
  2. 🚀 Installation
  3. 📖 Basic Usage
  4. 🎨 Advanced Features
  5. Theme Configuration
  6. Max Duration Control
  7. Custom Cursor Styling
  8. Handle Customization
  9. 🎬 Media Support
  10. 📚 Enhanced from Original
  11. 🤝 Contributing
  12. 📄 License
  13. 🙏 Acknowledgments

@cloudgpt/timeline-editor

npm version npm downloads

Enhanced React Timeline Editor - A powerful and feature-rich timeline editor component for building video editing applications, animation tools, and media timeline interfaces.

✨ Key Features

  • 🎨 Advanced Theme System - Dark, Light, and Ocean themes with full customization
  • ⏱️ Max Duration Control - Set timeline limits and validate action boundaries
  • 🎯 Custom Cursor Styling - Full control over cursor appearance and behavior
  • 🎛️ Professional Handles - Pill-shaped resize handles with gradient effects
  • 🎬 Video Frame Support - Extract and display video frames on timeline
  • 🖼️ Image Strip Display - Tiled image previews for visual actions
  • 📐 Grid Snapping - Precise alignment and positioning
  • 🎮 Drag Line Assistance - Visual guides for better UX
  • 🚀 Performance Optimized - Smooth animations and interactions
  • 📱 Responsive Design - Works across different screen sizes

🚀 Installation

npm install @cloudgpt/timeline-editor

📖 Basic Usage

import { Timeline, TimelineEffect, TimelineRow } from '@cloudgpt/timeline-editor';
import React, { useState } from 'react';

const mockData: TimelineRow[] = [
  {
    id: "0",
    actions: [
      {
        id: "action00",
        start: 0,
        end: 2,
        effectId: "effect0",
      },
    ],
  },
  {
    id: "1", 
    actions: [
      {
        id: "action10",
        start: 1.5,
        end: 5,
        effectId: "effect1",
      }
    ],
  }
];

const mockEffect: Record<string, TimelineEffect> = {
  effect0: {
    id: "effect0",
    name: "Video Clip",
  },
  effect1: {
    id: "effect1", 
    name: "Audio Track",
  },
};

const TimelineEditor = () => {
  const [data, setData] = useState(mockData);
  
  return (
    <Timeline
      editorData={data}
      effects={mockEffect}
      onChange={setData}
      maxDuration={30} // Limit timeline to 30 seconds
      theme={{
        backgroundColor: '#191b1d',
        foregroundColor: '#ffffff',
        cursorColor: '#ff6b35',
      }}
      cursor={{
        cursorColor: '#ff6b35',
        cursorWidth: 2,
        cursorStyle: 'solid',
        showCursorHead: true,
      }}
      handles={{
        showHandles: true,
        handleOpacity: 0.3,
        handleHoverOpacity: 1,
      }}
      style={{ width: '100%', height: 400 }}
    />
  );
};

🎨 Advanced Features

Theme Configuration

const themeConfig = {
  backgroundColor: '#1a1a1a',
  foregroundColor: '#ffffff', 
  gridColor: 'rgba(255, 255, 255, 0.1)',
  actionBackgroundColor: '#2f3134',
  actionBorderColor: 'rgba(255, 255, 255, 0.2)',
  dragLineColor: '#ff6b35',
};

<Timeline theme={themeConfig} />

Max Duration Control

<Timeline
  maxDuration={60} // Limit to 60 seconds
  validateActionChange={({ action, row, start, end }) => {
    // Custom validation logic
    return end <= 60 && start >= 0;
  }}
/>

Custom Cursor Styling

const cursorConfig = {
  cursorColor: '#00ff88',
  cursorWidth: 3,
  cursorStyle: 'dashed',
  cursorOpacity: 0.8,
  showCursorHead: true,
  cursorShadow: '0 0 10px rgba(0,255,136,0.5)',
};

<Timeline cursor={cursorConfig} />

Handle Customization

const handleConfig = {
  showHandles: true,
  handleBackground: 'linear-gradient(180deg, #ff6b35, #ff4500)',
  handleBorderColor: 'rgba(255, 255, 255, 0.4)',
  handleOpacity: 0.4,
  handleHoverOpacity: 1,
};

<Timeline handles={handleConfig} />

🎬 Media Support

The enhanced timeline editor supports video frame extraction and image previews:

// Custom render function for media actions
const renderAction = (action, row) => {
  if (action.effectId === 'video') {
    return <VideoStrip src="/video/sample.mp4" start={action.start} end={action.end} />;
  }
  if (action.effectId === 'image') {
    return <ImageStrip src="/images/sample.jpg" start={action.start} end={action.end} />;
  }
  return null;
};

<Timeline getActionRender={renderAction} />

📚 Enhanced from Original

This package is an enhanced version of the original @xzdarcy/react-timeline-editor with significant improvements:

  • Enhanced Type System - Better TypeScript support with comprehensive interfaces
  • Advanced Styling - Professional-grade visual design and theming
  • Better Performance - Optimized rendering and interaction handling
  • Extended API - More configuration options and customization capabilities
  • Bug Fixes - Resolved cursor stuttering and validation issues
  • Modern Features - Support for modern React patterns and hooks

🤝 Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.

📄 License

MIT License - see the LICENSE file for details.

🙏 Acknowledgments

Based on the excellent work by @xzdarcy on the original react-timeline-editor.

版本与发布记录

@cloudgpt/timeline-editor 共发布 1 个版本,首次发布于 2025/08/13;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.0latest2025/08/131.2 年前

关于 @cloudgpt/timeline-editor 的常见问题

@cloudgpt/timeline-editor 是什么?

Enhanced React timeline editor with advanced features including theme system, max duration controls, cursor customization, handle styling, and media support for video editing applications.

如何安装 @cloudgpt/timeline-editor?

在项目目录运行 npm install @cloudgpt/timeline-editor,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^15.3.0 || ^16.0.0-alpha || ^17.0.0 || ^18.0.0 || ^19.0.0)、react-dom(^15.3.0 || ^16.0.0-alpha || ^17.0.0 || ^18.0.0 || ^19.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cloudgpt/timeline-editor 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@cloudgpt/timeline-editor 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@cloudgpt/timeline-editor 可以商用吗?

@cloudgpt/timeline-editor 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@cloudgpt/timeline-editor 的下载量有多少?

根据 npm 官方下载统计,@cloudgpt/timeline-editor 在 2026/10/10 – 2026/11/08 这 30 天内被下载 5,644 次,日均约 188 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cloudgpt/timeline-editor 还在维护吗?

最新版本 1.0.0 发布于 2025/08/13(1.2 年前);至今共发布 1 个版本,其中过去 12 个月发布了 0 个;首次发布于 2025/08/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。