Configuration
Configure the editor engine, canvas dimensions, zoom behavior, and other settings. This page covers the full EditorEngineConfig interface, built-in constants, and canvas presets.
EditorEngineConfig
The configuration object passed when creating a new EditorEngine instance.
interface EditorEngineConfig {
canvasElement: HTMLCanvasElement; // Required: the canvas DOM element
width?: number; // Canvas width in pixels (default: 1080)
height?: number; // Canvas height in pixels (default: 1080)
backgroundColor?: string; // Canvas background color (default: '#ffffff')
}
// Create an engine with custom dimensions
const canvas = document.createElement('canvas');
const engine = new EditorEngine({
canvasElement: canvas,
width: 1920,
height: 1080,
backgroundColor: '#f0f0f0',
});Config Properties
| Name | Type | Default | Description |
|---|---|---|---|
canvasElement* | HTMLCanvasElement | — | The HTML canvas element to render on |
width | number | 1080 | Canvas width in pixels |
height | number | 1080 | Canvas height in pixels |
backgroundColor | string | '#ffffff' | Canvas background color |
Constants
Built-in constants that control editor behavior. These are not configurable at runtime but are useful to know when building integrations.
// Zoom limits
const ZOOM_MIN = 0.1; // 10% minimum zoom
const ZOOM_MAX = 5.0; // 500% maximum zoom
// History
const MAX_HISTORY_SIZE = 50; // Maximum undo steps
// Export defaults
const EXPORT_QUALITY = 1; // Default export quality (0-1)
const EXPORT_MULTIPLIER = 1; // Default resolution multiplier
// Canvas presets (see full list below)
const CANVAS_PRESETS = [
{ name: 'Instagram Post', width: 1080, height: 1080 },
{ name: 'Instagram Story', width: 1080, height: 1920 },
{ name: 'Facebook Post', width: 1200, height: 628 },
{ name: 'Facebook Cover', width: 820, height: 312 },
{ name: 'Twitter Post', width: 1200, height: 675 },
{ name: 'Twitter Header', width: 1500, height: 500 },
{ name: 'YouTube Thumbnail', width: 1280, height: 720 },
{ name: 'LinkedIn Post', width: 1200, height: 627 },
{ name: 'Pinterest Pin', width: 1000, height: 1500 },
{ name: 'Presentation', width: 1920, height: 1080 },
{ name: 'A4 Portrait', width: 2480, height: 3508 },
{ name: 'A4 Landscape', width: 3508, height: 2480 },
{ name: 'Business Card', width: 1050, height: 600 },
{ name: 'Custom', width: 1080, height: 1080 },
];Constants Reference
| Name | Type | Default | Description |
|---|---|---|---|
ZOOM_MIN | number | 0.1 | Minimum zoom level (10%) |
ZOOM_MAX | number | 5.0 | Maximum zoom level (500%) |
MAX_HISTORY_SIZE | number | 50 | Maximum number of undo steps |
EXPORT_QUALITY | number | 1 | Default export quality for lossy formats |
EXPORT_MULTIPLIER | number | 1 | Default resolution multiplier for exports |
Canvas Presets
14 built-in canvas size presets covering common social media, print, and presentation dimensions.
import { CANVAS_PRESETS } from '@design-on-web/core';
// List all presets
CANVAS_PRESETS.forEach(preset => {
console.log(`${preset.name}: ${preset.width}x${preset.height}`);
});
// Apply a preset
const preset = CANVAS_PRESETS.find(p => p.name === 'Instagram Story');
if (preset) {
engine.setCanvasSize(preset.width, preset.height);
}All Canvas Presets
| Name | Type | Default | Description |
|---|---|---|---|
Instagram Post | 1080 x 1080 | — | Square format for Instagram feed posts |
Instagram Story | 1080 x 1920 | — | Vertical format for Instagram/Facebook stories |
Facebook Post | 1200 x 628 | — | Landscape format for Facebook feed posts |
Facebook Cover | 820 x 312 | — | Facebook page cover photo |
Twitter Post | 1200 x 675 | — | Twitter/X feed post image |
Twitter Header | 1500 x 500 | — | Twitter/X profile header |
YouTube Thumbnail | 1280 x 720 | — | YouTube video thumbnail (16:9) |
LinkedIn Post | 1200 x 627 | — | LinkedIn feed post image |
Pinterest Pin | 1000 x 1500 | — | Tall format for Pinterest pins |
Presentation | 1920 x 1080 | — | Standard 16:9 presentation slide |
A4 Portrait | 2480 x 3508 | — | A4 paper at 300 DPI (portrait) |
A4 Landscape | 3508 x 2480 | — | A4 paper at 300 DPI (landscape) |
Business Card | 1050 x 600 | — | Standard business card dimensions |
Custom | 1080 x 1080 | — | Custom size (user-defined) |
Runtime Configuration
Some settings can be changed after the engine is created.
// Change canvas dimensions at runtime
engine.setCanvasSize(1920, 1080);
// Change background color
engine.setBackgroundColor('#000000');
// Get current dimensions
const { width, height } = engine.getCanvasSize();
// Set zoom level
engine.setZoom(1.5); // 150%
engine.zoomToFit(); // Fit canvas in viewport
engine.resetZoom(); // Reset to 100%
// Get current zoom
const zoom = engine.getZoom();Runtime Methods
| Name | Type | Default | Description |
|---|---|---|---|
setCanvasSize(w, h) | void | — | Change canvas dimensions |
setBackgroundColor(color) | void | — | Change canvas background color |
getCanvasSize() | { width, height } | — | Get current canvas dimensions |
setZoom(level) | void | — | Set zoom level (0.1 to 5.0) |
getZoom() | number | — | Get current zoom level |
zoomToFit() | void | — | Zoom to fit the canvas in the viewport |
resetZoom() | void | — | Reset zoom to 100% |
Branding
Customize the editor's visual identity with the branding configuration. This allows you to replace the default logo, set a custom title, and control the "Powered by" footer visibility.
interface BrandingConfig {
logo?: string; // URL to custom logo image
title?: string; // Text shown next to logo in toolbar
poweredBy?: boolean; // Show "Powered by Design on Web" footer (default: true)
}import { DesignEditor } from '@design-on-web/react';
function App() {
return (
<DesignEditor
branding={{
logo: "/my-logo.svg",
title: "My Design Tool",
poweredBy: false,
}}
/>
);
}Branding Properties
| Name | Type | Default | Description |
|---|---|---|---|
logo | string | — | URL to a custom logo image displayed in the toolbar. Supports any image format (SVG recommended for crisp rendering at any size). |
title | string | — | Text shown next to the logo in the toolbar. If omitted, no title text is displayed. |
poweredBy | boolean | true | Controls visibility of the "Powered by Design on Web" footer. Set to false to hide it (e.g., for white-label deployments). |
logo, title, and poweredBy: false for a fully white-labeled editor that matches your brand. CSS custom properties (--dow-*) can further customize colors and fonts.Full Setup Example
A complete initialization example with config, plugins, locale, and design loading.
import { EditorEngine } from '@design-on-web/core';
import { EditorContext, EditorShell } from '@design-on-web/ui';
import { SvgExportPlugin } from '@design-on-web/export-svg';
import { PdfExportPlugin } from '@design-on-web/export-pdf';
import { PsdExportPlugin } from '@design-on-web/export-psd';
import { I18nManager } from '@design-on-web/shared';
// Import styles
import '@design-on-web/ui/themes/variables.css';
import '@design-on-web/ui/themes/light.css';
import '@design-on-web/ui/components/EditorShell.css';
async function initEditor() {
const canvas = document.createElement('canvas');
// 1. Create engine with config
const engine = new EditorEngine({
canvasElement: canvas,
width: 1080,
height: 1080,
backgroundColor: '#ffffff',
});
// 2. Register plugins
await engine.registerPlugin(SvgExportPlugin);
await engine.registerPlugin(PdfExportPlugin);
await engine.registerPlugin(PsdExportPlugin);
// 3. Set locale
I18nManager.instance.setLocale('en');
// 4. Load saved design (optional)
const savedJson = localStorage.getItem('my-design');
if (savedJson) {
await engine.loadJSON(savedJson);
}
return engine;
}