Skip to content

Add keyboard shortcuts, history management, alignment tools, export dialog, and prompt suggestions#5

Open
xiaoju111a wants to merge 2 commits into
masterfrom
feature/keyboard-shortcuts-and-history
Open

Add keyboard shortcuts, history management, alignment tools, export dialog, and prompt suggestions#5
xiaoju111a wants to merge 2 commits into
masterfrom
feature/keyboard-shortcuts-and-history

Conversation

@xiaoju111a
Copy link
Copy Markdown
Owner

@xiaoju111a xiaoju111a commented Jan 15, 2026

✨ Feature

Background

The Lovart design tool needed a comprehensive set of productivity features to improve user workflow and efficiency. Users requested better ways to manage their design process, access their work history, and export their creations in various formats.

Changes

  • Keyboard Shortcuts: Implemented a complete keyboard shortcut system with 40+ shortcuts for editing, navigation, alignment, and file operations
  • Clipboard Management: Added advanced clipboard functionality with copy/paste/cut operations, style copying, and image clipboard support
  • History Management: Created undo/redo system with visual history panel and generation history tracking for AI prompts
  • Alignment Tools: Built comprehensive alignment and distribution tools with visual guides and snap-to-grid functionality
  • Export Dialog: Developed a feature-rich export system supporting multiple formats (PNG, JPG, SVG, PDF, JSON, HTML) with presets and customization options
  • Prompt Suggestions: Implemented an intelligent prompt suggestion system with categorized examples, recent prompts, and bookmark management
  • Canvas Utilities: Added helper functions for element manipulation, bounding box calculations, and geometric operations

Impact

  • Productivity: Users can now work significantly faster with keyboard shortcuts and alignment tools
  • Workflow: Complete history tracking ensures users never lose their work and can easily revert changes
  • Export Flexibility: Multiple export formats and presets make it easy to share designs across different platforms
  • AI Enhancement: Prompt suggestions help users generate better AI artwork with curated examples
  • User Experience: All new features integrate seamlessly with the existing interface while maintaining clean, intuitive design

The implementation includes comprehensive error handling, accessibility features, and performance optimizations to ensure smooth user experience across all supported browsers.

📁 Changed Files

File Type Summary
src/lib/clipboard.ts Complete clipboard management system with copy/paste/cut operations, style copying, image clipboard support, and shareable text format for element data
src/lib/canvas-utils.ts Comprehensive canvas utility functions including bounding box calculations, alignment guides, element transformations, and geometric operations
src/components/lovart/ExportDialog.tsx Feature-rich export dialog with support for 6 formats (PNG/JPG/SVG/PDF/JSON/HTML), quality presets, size customization, and estimated file sizes
src/components/lovart/HistoryPanel.tsx Dual-tab history panel showing undo/redo actions and AI generation history with search, filtering, and regeneration capabilities
src/components/lovart/KeyboardShortcutsDialog.tsx Interactive keyboard shortcuts reference with category filtering, search functionality, and Mac/Windows compatibility
src/components/lovart/PromptSuggestions.tsx Intelligent prompt suggestion system with categorized examples, recent prompts tracking, bookmark management, and random inspiration
src/hooks/useKeyboardShortcuts.ts Comprehensive keyboard shortcut hook with 40+ shortcuts, cross-platform support, and customizable action handlers
src/components/lovart/AlignmentTools.tsx Complete alignment toolbar with positioning, distribution, transformation, and layer management tools for selected elements
src/hooks/useHistory.ts Advanced history management hooks for canvas state and AI generation tracking with debouncing and localStorage persistence

Powered by Kimi | Model: kimi-k2-turbo-preview

…port dialog, and prompt suggestions

- Add useKeyboardShortcuts hook with 50+ shortcuts for editing, navigation, and tools
- Add useHistory hook for undo/redo and generation history tracking
- Add KeyboardShortcutsDialog component with search and category filtering
- Add HistoryPanel for viewing action and generation history
- Add AlignmentTools for multi-element alignment and distribution
- Add PromptSuggestions with categories, search, and saved prompts
- Add ExportDialog with multiple formats, presets, and quality options
- Add clipboard utilities for copy/paste/duplicate operations
- Add canvas-utils with snap guides, bounding box, and color utilities
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Jan 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
open-lovart Ready Ready Preview, Comment Jan 23, 2026 0:21am

@xiaoju111a
Copy link
Copy Markdown
Owner Author

/review

@xiaoju111a
Copy link
Copy Markdown
Owner Author

/describe --comment

@xiaoju111a
Copy link
Copy Markdown
Owner Author

/label

@xiaoju111a
Copy link
Copy Markdown
Owner Author

/describe

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🌗 Pull request overview

This PR adds comprehensive design tools for a canvas-based editor including clipboard operations,
history management, alignment utilities, export functionality, keyboard shortcuts, and prompt
suggestions. The implementation appears well-structured with proper separation of concerns.

Reviewed changes
Kimi reviewed 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/lib/clipboard.ts Clipboard operations with system fallback, element duplication, style copying, and image paste support
src/lib/canvas-utils.ts Canvas utility functions for geometry, alignment, snapping, color manipulation, and animation
src/components/lovart/ExportDialog.tsx Export dialog component with multiple format support, presets, and customizable options
src/components/lovart/HistoryPanel.tsx New file (typescript)
src/components/lovart/KeyboardShortcutsDialog.tsx New file (typescript)
src/components/lovart/PromptSuggestions.tsx New file (typescript)
src/hooks/useKeyboardShortcuts.ts Comprehensive keyboard shortcut system with platform-specific handling
src/components/lovart/AlignmentTools.tsx New file (typescript)
src/hooks/useHistory.ts History management hooks for canvas undo/redo and AI generation history tracking

Issues found:

  • 🟡 src/lib/clipboard.ts: [P2] Missing error handling for malformed clipboard data
  • 🟡 src/hooks/useKeyboardShortcuts.ts: [P2] Platform detection runs after initial render
  • 🟡 src/lib/clipboard.ts: [P2] Deep copy may fail for complex nested objects

Powered by Kimi | Model: kimi-k2-turbo-preview

Comment thread src/lib/clipboard.ts
Comment on lines +126 to +130
*/
export function duplicateElements(
elements: CanvasElement[],
offset: { x: number; y: number } = { x: PASTE_OFFSET, y: PASTE_OFFSET }
): CanvasElement[] {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSON.parse will throw an error if the clipboard contains invalid JSON. This could happen with
non-Lovart clipboard content. Wrap the parse in a try-catch block to gracefully handle malformed
data and fall back to internal clipboard.

Suggested change
*/
export function duplicateElements(
elements: CanvasElement[],
offset: { x: number; y: number } = { x: PASTE_OFFSET, y: PASTE_OFFSET }
): CanvasElement[] {
try {
const parsed = JSON.parse(text);
if (parsed.type === 'lovart-elements') {
clipboardData = parsed;
}
} catch (e) {
// Invalid JSON, continue to internal clipboard
}

Powered by Kimi | Model: kimi-k2-turbo-preview

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/ask 通俗解释一下

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🌗 Kimi Answer

这段代码定义了一个函数 duplicateElements,用来**原地复制(duplicate)**画布上的元素。

  • 参数 elements 是要被复制的元素列表;
  • 参数 offset 控制新元素相对于原位置的偏移量,默认向右下各移动 20 像素(PASTE_OFFSET 的值);
  • 函数会给每个元素生成全新的 iduuidv4()),然后把它们的 xy 坐标加上偏移量,返回一份“复制体”列表。

简单说:把选中的元素各复制一份,并稍微错开一点位置,避免完全重叠。


Powered by Kimi | Model: kimi-k2-turbo-preview

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/ask 通俗解释一下

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🌗 Kimi Answer

这段代码定义了一个“就地复制”函数:它会把你选中的所有元素直接复制一份到当前画布上,并且在 X、Y 方向各偏移 20 像素,避免新元素完全盖住原元素。复制出的每个元素都会重新生成一个唯一 ID,防止 ID 冲突。


Powered by Kimi | Model: kimi-k2-turbo-preview

Comment on lines +240 to +245

// Format special keys
let keyDisplay = shortcut.key;
switch (shortcut.key) {
case 'ArrowUp': keyDisplay = '↑'; break;
case 'ArrowDown': keyDisplay = '↓'; break;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The isMac detection runs in useEffect, which executes after the first render. This means
shortcuts won't work correctly on the initial render cycle. Move platform detection to
module level or use a synchronous check.

Suggested change
// Format special keys
let keyDisplay = shortcut.key;
switch (shortcut.key) {
case 'ArrowUp': keyDisplay = '↑'; break;
case 'ArrowDown': keyDisplay = '↓'; break;
const isMac = useRef(typeof navigator !== 'undefined' && /Mac|iPod|iPhone|iPad/.test(navigator.platform));

Powered by Kimi | Model: kimi-k2-turbo-preview

Comment thread src/lib/clipboard.ts
Comment on lines +22 to +26
*/
export async function copyElements(elements: CanvasElement[]): Promise<boolean> {
if (elements.length === 0) return false;

const clipboardData: ClipboardData = {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spread operator only performs a shallow copy. If CanvasElement contains nested objects or arrays,
they will be shared between copies. This could cause mutations to affect both original and copied
elements. Consider using a proper deep clone method or structuredClone for complex objects.

Suggested change
*/
export async function copyElements(elements: CanvasElement[]): Promise<boolean> {
if (elements.length === 0) return false;
const clipboardData: ClipboardData = {
elements: elements.map(el => structuredClone(el)), // Deep copy

Powered by Kimi | Model: kimi-k2-turbo-preview

@github-actions
Copy link
Copy Markdown

/describe --comment

🌗 Kimi PR Description

Suggested Title

Add keyboard shortcuts, history management, alignment tools, export dialog

Suggested Description

✨ Feature

Background

The Lovart design tool lacked essential productivity features common in professional design applications. Users needed better ways to navigate, manage their work history, align elements precisely, and export their designs in various formats.

Changes

  • Keyboard Shortcuts: Complete shortcut system with 40+ shortcuts for editing, navigation, and tools
  • History Management: Undo/redo functionality with debounced state tracking and generation history
  • Alignment Tools: Comprehensive alignment, distribution, and transformation tools for precise element positioning
  • Export Dialog: Multi-format export supporting PNG, JPG, SVG, PDF, JSON, and HTML with presets and customization
  • Prompt Suggestions: AI prompt inspiration system with categories, search, and bookmarking
  • Canvas Utilities: Helper functions for bounding boxes, snapping, and element manipulation

Impact

  • Significantly improved user workflow efficiency through keyboard shortcuts
  • Enhanced design precision with professional alignment tools
  • Better project management with comprehensive history tracking
  • Flexible export options for various use cases
  • Improved AI generation experience with prompt suggestions

📁 Changed Files

File Type Summary
src/lib/clipboard.ts Complete clipboard management system with copy/paste for elements, styles, and images
src/lib/canvas-utils.ts Utility functions for canvas operations including alignment, snapping, and transformations
src/components/lovart/ExportDialog.tsx Comprehensive export dialog with multiple formats, presets, and customization options
src/components/lovart/HistoryPanel.tsx History management panel showing action and generation history with search and filters
src/components/lovart/KeyboardShortcutsDialog.tsx Keyboard shortcuts reference dialog with categorized shortcuts and search
src/components/lovart/PromptSuggestions.tsx AI prompt suggestion system with categories, bookmarks, and recent prompts
src/hooks/useKeyboardShortcuts.ts Hook for managing keyboard shortcuts with Mac/Windows compatibility
src/components/lovart/AlignmentTools.tsx Alignment and transformation tools for precise element positioning
src/hooks/useHistory.ts History management hooks for undo/redo functionality and generation tracking

Powered by Kimi | Model: kimi-k2-turbo-preview

@github-actions github-actions Bot added the enhancement New feature or request label Jan 15, 2026
@github-actions
Copy link
Copy Markdown

/label

🏷️ Kimi Labels

✅ Applied labels: enhancement

Reason: Adds new alignment and layout tools to the canvas editor, expanding functionality without fixing bugs or changing documentation


Powered by Kimi | Model: kimi-k2-turbo-preview

@github-actions github-actions Bot changed the title feat: add keyboard shortcuts, history management, alignment tools, ex… Add keyboard shortcuts, history management, alignment tools, export dialog, and prompt suggestions Jan 15, 2026
@github-actions github-actions Bot added the ui/ux label Jan 15, 2026
@github-actions
Copy link
Copy Markdown

/describe

✅ PR description updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request ui/ux

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant