wedocs-plugin
wedocs-plugin copied to clipboard
feat: AI doc writer
trafficstars
AI Doc Writer Feature Implementation
📋 Overview
This PR introduces a comprehensive AI-powered documentation writing feature that allows users to generate high-quality documentation content using multiple AI providers directly within the WordPress editor. The feature integrates seamlessly with the existing weDocs plugin architecture and provides a modern, intuitive interface for content generation.
✨ Features
🎯 Core Functionality
- AI-Powered Content Generation: Generate documentation content using advanced language models
- Multi-Provider Support: Integration with OpenAI, Anthropic Claude, Google Gemini
- Context-Aware Generation: Uses existing post content to maintain consistency and avoid duplication
- Real-time Preview: Preview generated content before insertion into the document
- Flexible Insertion Modes: Choose between appending to existing content or overwriting the entire document
🛠️ Technical Features
- WordPress Block Editor Integration: Native Gutenberg sidebar plugin with custom AI icon
- Centralized AI Settings: Unified settings panel for managing all AI providers and configurations
- Content Validation: Comprehensive validation of AI-generated content for security and quality
- Error Handling: Robust error handling with user-friendly messages
- Internationalization: Full translation support using WordPress i18n functions
🏗️ Architecture
Frontend Components
AiDocWriterModal.js: Main modal component for content generation interfaceAiDocWriterPreview.js: Preview component for reviewing generated contentAiDocWriter.js: WordPress plugin registration and sidebar integrationAiSettings.js: Settings panel for AI provider configurationaiService.js: Centralized service for AI API interactions
Backend Implementation
SettingsApi.php: REST API endpoints for AI settings managementfunctions.php: AI provider configuration and utility functionsAssets.php: Asset management and script localizationAdmin.php: Admin interface integration
Content Generation Flow
- User Input: Title, keywords, and optional custom instructions
- Context Enhancement: Include existing post content if enabled
- AI Processing: Send request to selected AI provider
- Content Validation: Validate and sanitize generated content
- Preview & Insert: Allow user to review and insert content as WordPress blocks
Workflow
- Access: Click AI Doc Writer icon in Gutenberg sidebar
- Configure: Enter title, keywords, and review auto-generated instructions
- Generate: Click "Generate Content" to create AI-powered documentation
- Preview: Review generated content in preview mode
- Insert: Accept and insert content as properly formatted WordPress blocks
Privacy Considerations
- No Data Storage: AI-generated content is not stored on our servers
- User Control: Users have full control over their content and API usage
- Transparent Processing: Clear indication of which AI provider is being used
🔄 Extensibility
WordPress Filters
// Customize AI provider configurations
add_filter('wedocs_ai_provider_configs', 'my_custom_providers');
// Customize AI service providers
add_filter('wedocs_ai_service_providers', 'my_custom_service_config');
Summary by CodeRabbit
-
New Features
- AI Doc Writer in the editor: modal, preview, and insert/overwrite controls for AI-generated docs
- AI Settings panel: configure providers, models, and API keys
- Centralized AI service and editor integration plus a new icon and editor panel
- Modular data stores for docs and settings (improved client-side data handling)
-
Bug Fixes
- Removed stray debug logging from search
-
Chores
- Bumped asset build versions, added source maps and build metadata
- Removed an unused translation entry