@hufe921/canvas-editor 0.9.133 → 0.9.134
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/README.md +166 -53
- package/dist/assets/value-CEZhhW6y.js.map +1 -1
- package/dist/canvas-editor.js +1348 -1169
- package/dist/canvas-editor.js.map +1 -1
- package/dist/canvas-editor.umd.cjs +33 -33
- package/dist/canvas-editor.umd.cjs.map +1 -1
- package/dist/src/editor/core/draw/particle/date/DatePicker.d.ts +25 -0
- package/dist/src/editor/core/position/Position.d.ts +5 -0
- package/dist/src/editor/dataset/enum/DatePicker.d.ts +5 -0
- package/dist/src/editor/interface/Editor.d.ts +1 -0
- package/dist/src/editor/interface/Position.d.ts +1 -0
- package/package.json +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
## [0.9.134](https://github.com/Hufe921/canvas-editor/compare/v0.9.133...v0.9.134) (2026-05-22)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Chores
|
|
5
|
+
|
|
6
|
+
* add dependabot config ([4478c59](https://github.com/Hufe921/canvas-editor/commit/4478c59a77bdedf58c655319254be3485a5438b4))
|
|
7
|
+
* lock pnpm version ([c474691](https://github.com/Hufe921/canvas-editor/commit/c47469115dd1ffb5a5251d04e0665547b4022dfc))
|
|
8
|
+
* update workflow config ([0e9aa29](https://github.com/Hufe921/canvas-editor/commit/0e9aa29a16cedbe51bd22130656840797eb02cb9))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Documentation
|
|
12
|
+
|
|
13
|
+
* add CONTRIBUTING.md ([c7b138d](https://github.com/Hufe921/canvas-editor/commit/c7b138d436da7105fb21027fa8cfdba78214f69b))
|
|
14
|
+
* update documentation descriptions ([1322c86](https://github.com/Hufe921/canvas-editor/commit/1322c86a98356110ad3255b8aaf8d209311ce6d4))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* add filterHideElementRow option for print mode #1410 ([67ca33a](https://github.com/Hufe921/canvas-editor/commit/67ca33a1f2002c1e70eee6f04882e55b65fed8ee)), closes [#1410](https://github.com/Hufe921/canvas-editor/issues/1410)
|
|
20
|
+
* add year and month picker for date control #1256 ([fb45ee1](https://github.com/Hufe921/canvas-editor/commit/fb45ee18811f23b733b8fa2c6e7529d31b83691b)), closes [#1256](https://github.com/Hufe921/canvas-editor/issues/1256)
|
|
21
|
+
* use table-relative coordinates for float images #1372 ([1d403ea](https://github.com/Hufe921/canvas-editor/commit/1d403ea6f344217791de151c8606e93788bce533)), closes [#1372](https://github.com/Hufe921/canvas-editor/issues/1372)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
1
25
|
## [0.9.133](https://github.com/Hufe921/canvas-editor/compare/v0.9.132...v0.9.133) (2026-05-05)
|
|
2
26
|
|
|
3
27
|
|
package/README.md
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
<h1 align="center">
|
|
1
|
+
<h1 align="center">Canvas Editor</h1>
|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
|
-
<
|
|
4
|
+
<strong>A Canvas/SVG-based rich text editor.</strong>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://trendshift.io/repositories/8401" target="_blank">
|
|
9
|
+
<img src="https://trendshift.io/api/badge/repositories/8401" alt="Hufe921%2Fcanvas-editor | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/>
|
|
10
|
+
</a>
|
|
5
11
|
</p>
|
|
6
12
|
|
|
7
13
|
<p align="center">
|
|
@@ -18,36 +24,64 @@
|
|
|
18
24
|
<a href="https://deepwiki.com/Hufe921/canvas-editor" target="_blank"><img src="https://img.shields.io/badge/Ask_DeepWiki-_.svg?style=flat&color=0094de&labelColor=000000&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9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pbGw6IzM5NjljYSIvPjxwYXRoIGQ9Im0zOTcgNDg0LTUxLTI5LTMtMS0zLTEtMyAxLTMgMS0yNSAxNWEzMiAzMiAwIDAgMS00OC0yOHYtMjlsLTEtM3YtMWwtMS0ydi0xbC0yLTItMi0xdi0xbC01MS0yOXEtNi0zLTEyIDBsLTUxIDI5cS02IDMtNiAxMXY1OHEwIDggNiAxMWw1MSAyOSAzIDEgMyAxIDMtMSAzLTEgMjUtMTVhMzIgMzIgMCAwIDEgNDggMjh2MjlsMSAzdjFsMSAydjFsMiAyIDIgMiA1MSAyOSA2IDIgNi0yIDUxLTI5cTYtMyA2LTExdi01OHEwLTgtNi0xMSIgc3R5bGU9ImZpbGw6IzAyOTRkZSIvPjwvc3ZnPg==&logoColor=ffffff" alt="DeepWiki"/></a>
|
|
19
25
|
</p>
|
|
20
26
|
|
|
21
|
-
<p align="center">
|
|
27
|
+
<p align="center">
|
|
28
|
+
<a href="https://hufe.club/canvas-editor" target="_blank"><strong>Live Demo</strong></a> ·
|
|
29
|
+
<a href="https://hufe.club/canvas-editor-docs" target="_blank"><strong>Documentation</strong></a> ·
|
|
30
|
+
<a href="https://github.com/Hufe921/canvas-editor/issues/new?assignees=&labels=&projects=&template=bug_report.yml" target="_blank">Report Bug</a> ·
|
|
31
|
+
<a href="https://github.com/Hufe921/canvas-editor/issues/new?assignees=&labels=%3Asparkles%3A+feature+request&projects=&template=feature_request.yml" target="_blank">Request Feature</a> ·
|
|
32
|
+
<a href="https://github.com/Hufe921/canvas-editor/discussions" target="_blank">Discussions</a>
|
|
33
|
+
</p>
|
|
22
34
|
|
|
23
35
|
<p align="center">
|
|
24
|
-
<a href="https://hufe.club/canvas-editor"
|
|
25
|
-
·
|
|
26
|
-
<a href="https://hufe.club/canvas-editor-docs" target="_blank">View Docs</a>
|
|
27
|
-
·
|
|
28
|
-
<a href="https://github.com/Hufe921/canvas-editor/issues/new?assignees=&labels=&projects=&template=bug_report.yml" target="_blank">Report Bug</a>
|
|
29
|
-
·
|
|
30
|
-
<a href="https://github.com/Hufe921/canvas-editor/issues/new?assignees=&labels=%3Asparkles%3A+feature+request&projects=&template=feature_request.yml" target="_blank">Request Feature</a>
|
|
31
|
-
·
|
|
32
|
-
<a href="https://github.com/Hufe921/canvas-editor/discussions" target="_blank">FAQ</a>
|
|
36
|
+
English · <a href="https://hufe.club/canvas-editor-docs">中文文档</a>
|
|
33
37
|
</p>
|
|
34
38
|
|
|
35
|
-
|
|
39
|
+
---
|
|
36
40
|
|
|
37
|
-
##
|
|
41
|
+
## Overview
|
|
38
42
|
|
|
39
|
-
|
|
40
|
-
2. The render layer by svg is under development, see [feature/svg](https://github.com/Hufe921/canvas-editor/tree/feature/svg)
|
|
41
|
-
3. The export pdf feature is available now, see [feature/pdf](https://github.com/Hufe921/canvas-editor/tree/feature/pdf)
|
|
42
|
-
4. The AI-powered text processing demo, see [feature/ai](https://github.com/Hufe921/canvas-editor/tree/feature/ai)
|
|
43
|
-
5. Table pagination [#41](https://github.com/Hufe921/canvas-editor/issues/41) is under active development, see: [poc/table-paging](https://github.com/Hufe921/canvas-editor/tree/poc/table-paging) · [demo](https://hufe.club/canvas-editor-table/)
|
|
43
|
+
**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.
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
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.
|
|
46
|
+
|
|
47
|
+
## Features
|
|
48
|
+
|
|
49
|
+
- **Rich Text** — Undo / Redo, Font, Size, Bold, Italic, Underline, Strikeout, Superscript, Alignment, Headings, Lists, and more
|
|
50
|
+
- **Insertable Elements** — Tables, Images, Hyperlinks, Code Blocks, Page Breaks, Math Formulas (LaTeX), Date Pickers, Block elements
|
|
51
|
+
- **Form Controls** — Select, Text, Date, Radio, Checkbox controls
|
|
52
|
+
- **Pagination** — Native pagination with headers, footers, and page numbers
|
|
53
|
+
- **Page Layout** — Configurable page margins, watermarks, backgrounds
|
|
54
|
+
- **Document Structure** — Catalog (TOC) generation, comments, group annotations
|
|
55
|
+
- **Print & Export** — Print-ready output via canvas-to-image / PDF rendering
|
|
56
|
+
- **Interaction** — Custom context menus, customizable shortcut keys, drag-and-drop for text, elements, and controls
|
|
57
|
+
- **Extensibility** — Plugin system for adding custom functionality
|
|
58
|
+
- **Performance** — Web Workers for word counting, catalog generation, and async value retrieval
|
|
59
|
+
|
|
60
|
+
## Why Canvas Editor?
|
|
61
|
+
|
|
62
|
+
| | Canvas Editor | contenteditable Editors |
|
|
63
|
+
| ----------------------- | -------------------------------- | --------------------------- |
|
|
64
|
+
| Cross-browser rendering | Pixel-perfect, identical | Varies by browser |
|
|
65
|
+
| Pagination | Native, document-style | Manual / unsupported |
|
|
66
|
+
| Print fidelity | Matches on-screen output | Often diverges |
|
|
67
|
+
| Typography control | Full control | Limited by the browser |
|
|
68
|
+
| Document features | TOC, headers/footers, watermarks | Requires heavy custom logic |
|
|
69
|
+
|
|
70
|
+
## Installation
|
|
46
71
|
|
|
47
72
|
```bash
|
|
48
|
-
npm
|
|
73
|
+
# npm
|
|
74
|
+
npm install @hufe921/canvas-editor
|
|
75
|
+
|
|
76
|
+
# pnpm
|
|
77
|
+
pnpm add @hufe921/canvas-editor
|
|
78
|
+
|
|
79
|
+
# yarn
|
|
80
|
+
yarn add @hufe921/canvas-editor
|
|
49
81
|
```
|
|
50
82
|
|
|
83
|
+
## Quick Start
|
|
84
|
+
|
|
51
85
|
```html
|
|
52
86
|
<div class="canvas-editor"></div>
|
|
53
87
|
```
|
|
@@ -55,56 +89,135 @@ npm i @hufe921/canvas-editor --save
|
|
|
55
89
|
```javascript
|
|
56
90
|
import Editor from '@hufe921/canvas-editor'
|
|
57
91
|
|
|
58
|
-
|
|
92
|
+
const container = document.querySelector('.canvas-editor')
|
|
93
|
+
|
|
94
|
+
const editor = new Editor(container, {
|
|
59
95
|
main: [
|
|
60
96
|
{
|
|
61
|
-
value: 'Hello
|
|
97
|
+
value: 'Hello, Canvas Editor!'
|
|
62
98
|
}
|
|
63
99
|
]
|
|
64
100
|
})
|
|
65
101
|
```
|
|
66
102
|
|
|
67
|
-
|
|
103
|
+
For complete API documentation, see the [official docs](https://hufe.club/canvas-editor-docs).
|
|
104
|
+
|
|
105
|
+
## Ecosystem
|
|
106
|
+
|
|
107
|
+
| Project | Description |
|
|
108
|
+
| ---------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
|
|
109
|
+
| [canvas-editor-plugin](https://github.com/Hufe921/canvas-editor-plugin) | Official plugin collection |
|
|
110
|
+
| [feature/svg](https://github.com/Hufe921/canvas-editor/tree/feature/svg) | SVG render layer (in development) |
|
|
111
|
+
| [feature/pdf](https://github.com/Hufe921/canvas-editor/tree/feature/pdf) | PDF export feature |
|
|
112
|
+
| [feature/ai](https://github.com/Hufe921/canvas-editor/tree/feature/ai) | AI-powered text processing demo |
|
|
113
|
+
| [poc/table-paging](https://github.com/Hufe921/canvas-editor/tree/poc/table-paging) | Table pagination POC ([demo](https://hufe.club/canvas-editor-table/)) |
|
|
114
|
+
| [feature/CRDT](https://github.com/Hufe921/canvas-editor/tree/feature/CRDT) | CRDT-based collaboration (experimental) |
|
|
115
|
+
|
|
116
|
+
## Development
|
|
117
|
+
|
|
118
|
+
### Prerequisites
|
|
119
|
+
|
|
120
|
+
- Node.js `>= 24.13.1`
|
|
121
|
+
- pnpm (recommended)
|
|
122
|
+
|
|
123
|
+
### Setup
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
# Install dependencies
|
|
127
|
+
pnpm install
|
|
128
|
+
|
|
129
|
+
# Start the development server
|
|
130
|
+
npm run dev
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Build
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
# Build the application (demo)
|
|
137
|
+
npm run build
|
|
138
|
+
|
|
139
|
+
# Build the library (publishable package)
|
|
140
|
+
npm run lib
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Quality Checks
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
# Lint
|
|
147
|
+
npm run lint
|
|
148
|
+
|
|
149
|
+
# Type check
|
|
150
|
+
npm run type:check
|
|
151
|
+
|
|
152
|
+
# Unit tests (Vitest)
|
|
153
|
+
npm run test:unit
|
|
68
154
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
- Drag and Drop(Text, Element, Control)
|
|
76
|
-
- Header, Footer, Page Number
|
|
77
|
-
- Page Margin
|
|
78
|
-
- Watermark
|
|
79
|
-
- Pagination
|
|
80
|
-
- Comment
|
|
81
|
-
- Catalog
|
|
155
|
+
# E2E tests (Cypress)
|
|
156
|
+
npm run cypress:open # interactive
|
|
157
|
+
npm run cypress:run # headless
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Documentation
|
|
82
161
|
|
|
83
|
-
|
|
162
|
+
```bash
|
|
163
|
+
npm run docs:dev # Start VitePress docs locally
|
|
164
|
+
npm run docs:build # Build the documentation site
|
|
165
|
+
```
|
|
84
166
|
|
|
85
|
-
|
|
86
|
-
2. Control rules
|
|
87
|
-
3. Improve performance
|
|
88
|
-
4. [CRDT](https://github.com/Hufe921/canvas-editor/tree/feature/CRDT)
|
|
167
|
+
## Project Structure
|
|
89
168
|
|
|
90
|
-
|
|
169
|
+
```
|
|
170
|
+
src/editor/
|
|
171
|
+
├── core/
|
|
172
|
+
│ ├── draw/ # Rendering engine (canvas drawing)
|
|
173
|
+
│ │ ├── particle/ # Element renderers (text, image, table, latex, ...)
|
|
174
|
+
│ │ ├── control/ # Form control rendering
|
|
175
|
+
│ │ ├── frame/ # Frame elements (margin, background, borders)
|
|
176
|
+
│ │ ├── richtext/ # Decorations (underline, highlight)
|
|
177
|
+
│ │ └── interactive/# Interactive features (search, graffiti)
|
|
178
|
+
│ ├── command/ # Command pattern (executeBold, executeUndo, ...)
|
|
179
|
+
│ ├── event/ # Canvas and global event handling
|
|
180
|
+
│ ├── observer/ # Mouse, selection, image observers
|
|
181
|
+
│ ├── worker/ # Web Workers for async operations
|
|
182
|
+
│ └── plugin/ # Plugin system
|
|
183
|
+
├── interface/ # TypeScript interfaces
|
|
184
|
+
├── dataset/ # Enums and constants
|
|
185
|
+
└── utils/ # Utility helpers
|
|
186
|
+
```
|
|
91
187
|
|
|
92
|
-
|
|
188
|
+
## Contributing
|
|
93
189
|
|
|
94
|
-
|
|
190
|
+
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.
|
|
95
191
|
|
|
96
|
-
|
|
192
|
+
1. Fork the repository
|
|
193
|
+
2. Create your feature branch (`git checkout -b feat/amazing-feature`)
|
|
194
|
+
3. Commit your changes following [Conventional Commits](https://www.conventionalcommits.org/) (`git commit -m 'feat: add amazing feature'`)
|
|
195
|
+
4. Push to the branch (`git push origin feat/amazing-feature`)
|
|
196
|
+
5. Open a Pull Request
|
|
197
|
+
|
|
198
|
+
> Pre-commit hooks automatically run `lint` and `type:check`. Commit messages must follow Conventional Commits format (`feat:`, `fix:`, `docs:`, `refactor:`, ...).
|
|
199
|
+
|
|
200
|
+
### Contributors
|
|
201
|
+
|
|
202
|
+
Thanks to all the people who have contributed to Canvas Editor!
|
|
203
|
+
|
|
204
|
+
<a href="https://github.com/Hufe921/canvas-editor/graphs/contributors">
|
|
205
|
+
<img src="https://contrib.rocks/image?repo=Hufe921/canvas-editor" />
|
|
206
|
+
</a>
|
|
97
207
|
|
|
98
|
-
##
|
|
208
|
+
## Community & Support
|
|
99
209
|
|
|
100
|
-
|
|
210
|
+
- **Documentation** — [hufe.club/canvas-editor-docs](https://hufe.club/canvas-editor-docs)
|
|
211
|
+
- **Discussions** — [GitHub Discussions](https://github.com/Hufe921/canvas-editor/discussions)
|
|
212
|
+
- **Bug Reports** — [GitHub Issues](https://github.com/Hufe921/canvas-editor/issues)
|
|
213
|
+
- **AI-Assisted Q&A** — [Zread](https://zread.ai/Hufe921/canvas-editor) · [DeepWiki](https://deepwiki.com/Hufe921/canvas-editor)
|
|
101
214
|
|
|
102
|
-
##
|
|
215
|
+
## Sponsors
|
|
103
216
|
|
|
104
|
-
|
|
217
|
+
If you find this project useful, please consider [sponsoring](https://hufe.club/donate.jpg) to support its continued development.
|
|
105
218
|
|
|
106
|
-
|
|
219
|
+
## License
|
|
107
220
|
|
|
108
|
-
|
|
221
|
+
This project is licensed under the [MIT License](./LICENSE).
|
|
109
222
|
|
|
110
|
-
|
|
223
|
+
Copyright © 2022–present, [Hufe921](https://github.com/Hufe921).
|