Package Installation
Canvas Editor is distributed as an npm package and can be installed using your preferred package manager.Canvas Editor requires Node.js 16.9.1 or higher. Make sure your development environment meets this requirement.
TypeScript Setup
Canvas Editor is built with TypeScript and provides comprehensive type definitions out of the box. No additional@types packages are needed.
Type Definitions
When you install Canvas Editor, TypeScript definitions are automatically available:TypeScript Configuration
For optimal compatibility, ensure yourtsconfig.json includes:
tsconfig.json
Module System
Canvas Editor is distributed as an ES module with UMD fallback.ES Module (Recommended)
UMD (Browser Script Tag)
If you’re not using a module bundler, you can include Canvas Editor via a script tag:Build Tools
Canvas Editor works seamlessly with modern build tools.- Vite
- Webpack
- Rollup
Canvas Editor works out of the box with Vite:
vite.config.ts
Verify Installation
To verify that Canvas Editor is installed correctly, create a simple test:Troubleshooting
Module not found error
Module not found error
If you see a module resolution error:
- Verify the package is in your
package.jsondependencies - Delete
node_modulesand reinstall:rm -rf node_modules && npm install - Clear your build tool’s cache (e.g.,
.cachefor Vite)
TypeScript errors
TypeScript errors
If TypeScript can’t find type definitions:
- Ensure
@hufe921/canvas-editoris in yourdependencies(notdevDependencies) - Check that your
tsconfig.jsonincludes"moduleResolution": "node" - Restart your TypeScript server in your IDE
CSS not loading
CSS not loading
Canvas Editor includes built-in styles. If styles aren’t applying:
- Ensure your bundler is configured to handle CSS imports
- Check that no global CSS is overriding editor styles
- Verify the container element has explicit dimensions
Node version error
Node version error
If you see Node version errors:
- Check your Node version:
node --version - Upgrade to Node 16.9.1 or higher using nvm or your preferred method
- Clear your package manager’s cache after upgrading
Next Steps
Quick Start
Build your first editor in minutes
Configuration
Explore editor configuration options
API Reference
Learn about the Editor class API
Examples
See live examples and demos