A powerful Strapi 5 plugin that provides a visual editor for raw HTML with live Tailwind CSS preview. Perfect for creating custom HTML blocks with real-time visual feedback.
- Monaco Editor Integration: Professional code editing experience with syntax highlighting, auto-completion, and IntelliSense
- Live Tailwind CSS Preview: Real-time preview of your HTML with Tailwind CSS styling
- Split View Mode: Edit code and preview simultaneously with adjustable split ratio
- Visual Editing: Click-to-edit functionality directly in the preview pane
- Media Library Integration: Insert images and files from Strapi's media library
- Responsive Preview: Test your HTML at different viewport sizes (mobile, tablet, desktop, auto)
- Fullscreen Editor: Distraction-free editing in a fullscreen modal
- Inline Editor: Quick edits directly in the Content Manager
- Tailwind v4 Support: Configure custom theme using Tailwind CSS v4's
@themedirective
# Navigate to your Strapi project
cd your-strapi-project
# The plugin is already in src/plugins/raw-tailwind-editor
# Install dependencies
cd src/plugins/raw-tailwind-editor
yarn install
# Build the plugin
yarn build# Install from npm
npm install raw-tailwind-editor
# or
yarn add raw-tailwind-editorAdd the plugin to your config/plugins.ts:
export default {
"raw-tailwind-editor": {
enabled: true,
},
};In your Content-Type Builder:
- Select a content type or create a new one
- Click "Add another field"
- Select "Custom" tab
- Choose "Raw HTML with Tailwind"
- Configure the field name and settings
- Save
Navigate to Settings β Raw Tailwind Editor to customize your Tailwind CSS v4 theme:
@theme {
--color-primary: #1e40af;
--color-secondary: #db2777;
--font-sans: "Inter", sans-serif;
--spacing-xl: 2rem;
}- Open the Content Manager
- Create or edit an entry with the Raw HTML field
- Use the inline Monaco editor for quick edits
- Click "Open Fullscreen Editor" for advanced editing with live preview
- Quick Access: Edit HTML directly in the Content Manager
- Syntax Highlighting: Full HTML syntax support
- Media Insert: Add images/files from media library
- Compact View: 300px height for efficient content management
- Split View: Code editor + live preview side-by-side
- Adjustable Split: Drag the divider to resize panes
- View Modes:
- Code Only: Focus on writing HTML
- Preview Only: See the final result
- Split View: Best of both worlds
- Preview Sizes:
- Auto: Responsive to available space
- Mobile: 375px viewport
- Tablet: 768px viewport
- Desktop: 1200px viewport
- Visual Editing: Click elements in preview to edit them directly
- Floating Toolbar: Quick access to common HTML tags and formatting
admin/src/
βββ components/
β βββ RawHtmlInput.tsx # Main custom field component
β βββ EditorModal/
β β βββ index.tsx # Fullscreen modal container
β β βββ CodeEditor.tsx # Monaco editor wrapper
β β βββ PreviewPane.tsx # Live preview container
β β βββ EditablePreview.tsx # Visual editing functionality
β β βββ Toolbar.tsx # View mode controls
β β βββ FloatingToolbar.tsx # HTML tag insertion
β β βββ ResizeHandle.tsx # Split view divider
β β βββ hooks.ts # Custom React hooks
β β βββ types.ts # TypeScript definitions
β β βββ utils/ # Helper functions
β βββ Initializer.tsx # Plugin initialization
β βββ PluginIcon.tsx # Custom field icon
βββ pages/
β βββ Settings/ # Theme configuration page
βββ translations/ # i18n support
βββ index.ts # Plugin registration
server/
βββ config/
β βββ index.js # Default theme configuration
βββ controllers/
β βββ settings.js # Settings API controller
βββ routes/
β βββ index.js # API routes
βββ services/
β βββ settings.js # Settings service
βββ index.js # Server registration
- Node.js 18+ or 20+
- Strapi 5.33.0+
- Yarn or npm
# Clone the repository
git clone https://github.com/laofun/raw-tailwind-editor.git
cd raw-tailwind-editor
# Install dependencies
yarn installyarn watch
yarn build
yarn test:ts:front
### Project Structure
raw-tailwind-editor/ βββ admin/ # Frontend code β βββ src/ # Source files β βββ tsconfig.json # TypeScript config β βββ custom.d.ts # Type declarations βββ server/ # Backend code βββ dist/ # Built files βββ package.json # Dependencies βββ .gitignore # Git ignore rules βββ README.md # This file
## π Configuration
### Plugin Configuration
In `config/plugins.ts`:
```typescript
export default {
"raw-tailwind-editor": {
enabled: true,
resolve: "./src/plugins/raw-tailwind-editor",
config: {
themeConfig: `@theme {
--color-primary: #3b82f6;
--color-secondary: #8b5cf6;
}`,
},
},
};
You need to update the config/middlewares.ts file. Replace strapi::security with
{
name: 'strapi::security',
config: {
contentSecurityPolicy: {
useDefaults: true,
directives: {
'script-src-elem': ["'self'", "'unsafe-inline'", 'cdn.tailwindcss.com'],
upgradeInsecureRequests: null,
},
},
},
},
When adding the field to a content type, you can configure:
- Field name: Unique identifier
- Field label: Display name
- Description: Help text
- Required: Make field mandatory
- Landing Pages: Create custom HTML sections with Tailwind styling
- Email Templates: Design responsive email layouts
- Custom Widgets: Build interactive components
- Marketing Blocks: Craft promotional content with precise control
- Documentation: Write technical docs with code examples
GET /api/raw-tailwind-editor/settingsResponse:
{
"config": {
"themeConfig": "@theme { --color-primary: #1e40af; }"
}
}PUT /api/raw-tailwind-editor/settings
Content-Type: application/json
{
"config": {
"themeConfig": "@theme { --color-primary: #3b82f6; }"
}
}Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow the existing code style
- Add TypeScript types for new features
- Test thoroughly before submitting
- Update documentation as needed
MIT License - see LICENSE file for details
- Built for Strapi 5
- Powered by Monaco Editor
- Styled with Tailwind CSS v4
- UI components from Strapi Design System
Made with β€οΈ for the Strapi community