MCPcopy
hub / github.com/Hufe921/canvas-editor

github.com/Hufe921/canvas-editor @v0.9.136 sqlite

repository ↗ · DeepWiki ↗ · release v0.9.136 ↗
1,620 symbols 4,958 edges 327 files 0 documented · 0%
README

Canvas Editor

A Canvas/SVG-based rich text editor.

Hufe921%2Fcanvas-editor | Trendshift

Version Cypress Passing GitHub Contributors License PRs zread DeepWiki

Live Demo · Documentation · Report Bug · Request Feature · Discussions

English · 中文文档


Overview

Canvas Editor is a feature-rich, WYSIWYG document editor built on top of the HTML <canvas> API. It is designed for use cases that demand pixel-perfect rendering, advanced typography, complex layouts, and Word-like document experiences in the browser — including EMR (Electronic Medical Records), legal contracts, reports, and other document-centric applications.

Unlike traditional contenteditable-based editors, Canvas Editor takes full control of the rendering pipeline, providing consistent typography across browsers, precise pagination, and a uniform export experience.

Features

  • Rich Text — Undo / Redo, Font, Size, Bold, Italic, Underline, Strikeout, Superscript, Alignment, Headings, Lists, and more
  • Insertable Elements — Tables, Images, Hyperlinks, Code Blocks, Page Breaks, Math Formulas (LaTeX), Date Pickers, Block elements
  • Form Controls — Select, Text, Date, Radio, Checkbox controls
  • Pagination — Native pagination with headers, footers, and page numbers
  • Page Layout — Configurable page margins, watermarks, backgrounds
  • Document Structure — Catalog (TOC) generation, comments, group annotations
  • Print & Export — Print-ready output via canvas-to-image / PDF rendering
  • Interaction — Custom context menus, customizable shortcut keys, drag-and-drop for text, elements, and controls
  • Extensibility — Plugin system for adding custom functionality
  • Performance — Web Workers for word counting, catalog generation, and async value retrieval

Why Canvas Editor?

Canvas Editor contenteditable Editors
Cross-browser rendering Pixel-perfect, identical Varies by browser
Pagination Native, document-style Manual / unsupported
Print fidelity Matches on-screen output Often diverges
Typography control Full control Limited by the browser
Document features TOC, headers/footers, watermarks Requires heavy custom logic

Installation

# npm
npm install @hufe921/canvas-editor

# pnpm
pnpm add @hufe921/canvas-editor

# yarn
yarn add @hufe921/canvas-editor

Quick Start






import Editor from '@hufe921/canvas-editor'

const container = document.querySelector('.canvas-editor')

const editor = new Editor(container, {
  main: [
    {
      value: 'Hello, Canvas Editor!'
    }
  ]
})

For complete API documentation, see the official docs.

Ecosystem

Project Description
canvas-editor-plugin Official plugin collection
feature/svg SVG render layer (in development)
feature/pdf PDF export feature
feature/ai AI-powered text processing demo
poc/table-paging Table pagination POC (demo)
feature/CRDT CRDT-based collaboration (experimental)

Development

Prerequisites

  • Node.js >= 24.13.1
  • pnpm (recommended)

Setup

# Install dependencies
pnpm install

# Start the development server
npm run dev

Build

# Build the application (demo)
npm run build

# Build the library (publishable package)
npm run lib

Quality Checks

# Lint
npm run lint

# Type check
npm run type:check

# Unit tests (Vitest)
npm run test:unit

# E2E tests (Cypress)
npm run cypress:open    # interactive
npm run cypress:run     # headless

Documentation

npm run docs:dev        # Start VitePress docs locally
npm run docs:build      # Build the documentation site

Project Structure

src/editor/
├── core/
│   ├── draw/           # Rendering engine (canvas drawing)
│   │   ├── particle/   # Element renderers (text, image, table, latex, ...)
│   │   ├── control/    # Form control rendering
│   │   ├── frame/      # Frame elements (margin, background, borders)
│   │   ├── richtext/   # Decorations (underline, highlight)
│   │   └── interactive/# Interactive features (search, graffiti)
│   ├── command/        # Command pattern (executeBold, executeUndo, ...)
│   ├── event/          # Canvas and global event handling
│   ├── observer/       # Mouse, selection, image observers
│   ├── worker/         # Web Workers for async operations
│   └── plugin/         # Plugin system
├── interface/          # TypeScript interfaces
├── dataset/            # Enums and constants
└── utils/              # Utility helpers

Contributing

Contributions are what make the open-source community such an amazing place. Any contributions you make are greatly appreciated — bug reports, feature requests, documentation improvements, or pull requests.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feat/amazing-feature)
  3. Commit your changes following Conventional Commits (git commit -m 'feat: add amazing feature')
  4. Push to the branch (git push origin feat/amazing-feature)
  5. Open a Pull Request

Pre-commit hooks automatically run lint and type:check. Commit messages must follow Conventional Commits format (feat:, fix:, docs:, refactor:, ...).

Contributors

Thanks to all the people who have contributed to Canvas Editor!

Community & Support

Sponsors

If you find this project useful, please consider sponsoring to support its continued development.

License

This project is licensed under the MIT License.

Copyright © 2022–present, Hufe921.

Extension points exported contracts — how you extend this code

IControlInstance (Interface)
(no doc) [8 implementers]
src/editor/interface/Control.ts
IComment (Interface)
(no doc)
src/mock.ts
ISignatureResult (Interface)
(no doc)
src/components/signature/Signature.ts
IPrismKindStyle (Interface)
(no doc)
src/utils/prism.ts
ICopyWithCopyrightOption (Interface)
(no doc)
src/plugins/copy/index.ts
Chainable (Interface)
(no doc)
cypress/global.d.ts
CreateTestEditorParams (Interface)
(no doc)
tests/factories/editor.ts
MockCallEntry (Interface)
(no doc)
tests/helpers/canvas.ts

Core symbols most depended-on inside this repo

add
called by 182
src/editor/core/observer/ImageObserver.ts
render
called by 153
src/editor/core/draw/Draw.ts
getEditor
called by 122
cypress/global.d.ts
getValue
called by 107
src/editor/interface/Control.ts
getOptions
called by 86
src/editor/core/draw/Draw.ts
createTestEditor
called by 86
tests/factories/editor.ts
isReadonly
called by 84
src/editor/core/draw/Draw.ts
click
called by 74
src/editor/core/event/CanvasEvent.ts

Shape

Method 980
Interface 222
Function 194
Class 175
Enum 49

Languages

TypeScript100%

Modules by API surface

src/editor/core/command/CommandAdapt.ts155 symbols
src/editor/core/draw/Draw.ts140 symbols
src/editor/core/draw/control/Control.ts58 symbols
src/editor/core/draw/particle/date/DatePicker.ts37 symbols
src/editor/utils/element.ts35 symbols
src/editor/interface/Control.ts35 symbols
src/editor/utils/index.ts34 symbols
src/editor/interface/Element.ts34 symbols
src/editor/core/range/RangeManager.ts33 symbols
src/editor/core/position/Position.ts30 symbols
src/editor/core/draw/particle/latex/utils/LaTexUtils.ts30 symbols
src/editor/core/event/CanvasEvent.ts26 symbols

Dependencies from manifests, versioned

@eslint/js10.0.1 · 1×
@rollup/plugin-typescript12.3.0 · 1×
@types/jsdom28.0.3 · 1×
@types/node24.12.4 · 1×
@types/prismjs1.26.6 · 1×
@typescript-eslint/eslint-plugin8.59.3 · 1×
@typescript-eslint/parser8.59.3 · 1×
@vitest/coverage-v84.1.6 · 1×
cypress15.15.0 · 1×
cypress-file-upload5.0.8 · 1×
eslint10.4.0 · 1×
globals17.6.0 · 1×

For agents

$ claude mcp add canvas-editor \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact