Design Principles
The story editor’s architecture follows these core design principles:Whitelabel
Written from scratch as a modern React codebase with only thin layers (usually REST endpoints) connecting to WordPress. This design makes it possible to quickly port the editor to other CMS platforms.
Touch-Friendly
Uses universal pointer events, touch-friendly tap targets, and alternatives for hover UI to work across touch screens, touch pads, and mouse input.
Responsive
Adapts to small and very large screen sizes, from iPad to 6K monitors. The editor doesn’t expect to run full screen.
Extensible
Ships with the minimum viable set of media controls, document-level settings, and analytics. Provides integration points to extend functionality.
Accessible
Clear goal to provide an excellent experience to the broadest user base possible, including keyboard and screen-reader users.
Performant
Performance is a hard requirement. All user actions must have a visual response in less than 100ms. Continuous animations update at 60fps (30fps as fallback).
Project Structure
The Web Stories plugin follows a monorepo architecture using npm workspaces.Root Structure
PHP Architecture
PHP code is organized in theincludes/ directory:
- Story_Post_Type.php - Registers the custom post type for stories
- Assets.php - Manages plugin assets (JS/CSS) and enqueuing
- REST_API/ - Custom REST endpoints for editor and dashboard
- AMP/ - AMP validation and optimization
- Integrations/ - Third-party service integrations (Analytics, Ads)
JavaScript Architecture
The JavaScript codebase uses a monorepo structure with packages inpackages/:
Core JavaScript Packages
Story Editor
Story Editor
Location:
packages/story-editor/The main story editor React application. Contains:- Canvas rendering engine
- Element manipulation tools
- Timeline and animation controls
- Property panels and inspectors
- Media library integration
Dashboard
Dashboard
Location:
packages/dashboard/Stories management dashboard React application. Features:- Story list and grid views
- Template browser
- Story creation wizard
- Bulk operations
- Search and filtering
Design System
Design System
Location:
packages/design-system/Shared UI component library used across editor and dashboard:- Buttons, inputs, dropdowns
- Modal dialogs
- Tooltips and popovers
- Theme system
- Icons and typography
Elements
Elements
Location:
packages/elements/Core story element components:- Text elements with rich formatting
- Image and video elements
- Shape elements
- GIF support
- Element behaviors and interactions
Animation
Animation
Location:
packages/animation/Animation engine and utilities:- Animation definitions
- Keyframe management
- Timeline integration
- Effect presets
Media
Media
Location:
packages/media/Media handling utilities:- Upload management
- Image optimization
- Video processing
- Video transcoding integration
- Media library integration
Output
Output
Location:
packages/output/Story rendering and output generation:- AMP HTML generation
- Story markup rendering
- SEO optimization
- Performance optimization
Build System
The project uses Webpack 5 for bundling JavaScript:webpack.config.cjs- Main Webpack configuration- Multiple entry points for editor, dashboard, and other components
- Code splitting for optimal loading
- Production and development builds
- React Fast Refresh support in development
Build Scripts
package.json:198-208 for complete build script definitions.
REST API
The plugin provides custom REST API endpoints for the editor and dashboard: Base namespace:/web-stories/v1/
Key endpoints:
/web-stories/v1/web-story- Story CRUD operations/web-stories/v1/media- Media upload and management/web-stories/v1/fonts- Font management/web-stories/v1/settings- Plugin settings/web-stories/v1/templates- Story templates
includes/REST_API/.
Data Flow
Testing Architecture
The project includes multiple test suites:- PHP Unit Tests - PHPUnit tests in
tests/phpunit/ - JavaScript Unit Tests - Jest tests alongside source code
- Integration Tests - Karma/Jasmine tests in
packages/*/karma/ - E2E Tests - Puppeteer tests in
packages/e2e-tests/
Browser Support
The editor supports modern browsers:- Chrome (latest 2 versions)
- Firefox (latest 2 versions)
- Safari (latest 2 versions)
- Edge (Chromium-based)
docs/browser-support.md in the source.
Canvas Layering
The story editor uses a sophisticated canvas layering system for element rendering and manipulation. Seedocs/canvas.md in the source repository for detailed documentation.
Next Steps
Testing
Learn how to run and write tests
Contributing
Start contributing to the project