drawui-core 0.3.5 → 0.3.6
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/README.md +365 -6
- package/dist/index.cjs +23 -23
- package/dist/index.d.cts +185 -335
- package/dist/index.d.ts +185 -335
- package/dist/index.js +23 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# drawui-core
|
|
2
2
|
|
|
3
|
-
**简体中文** | [English](#english)
|
|
3
|
+
**简体中文** | [繁體中文](#繁體中文) | [English](#english) | [日本語](#日本語) | [한국어](#한국어) | [Deutsch](#deutsch) | [Français](#français)
|
|
4
4
|
|
|
5
5
|
框架无关的核心画布绘图引擎(原生 TypeScript,无 UI 框架依赖)。
|
|
6
6
|
|
|
@@ -38,7 +38,7 @@ editor.setShapes([
|
|
|
38
38
|
- 工具类:`SelectTool`、`HandTool`、`ShapeTool`、`LineTool`、`FreehandTool`、`ArrowTool`
|
|
39
39
|
- 几何:`Vec`、`Mat2d`、`Camera`、`Renderer`
|
|
40
40
|
- 主题:`THEME`、`getTheme`、`setTheme`、`subscribeTheme`、`hexToRgba`、`shadeColor`
|
|
41
|
-
- 国际化:`setLanguage`、`getLanguage`、`subscribeLanguage`、`t`
|
|
41
|
+
- 国际化:`LANGUAGES`、`setLanguage`、`getLanguage`、`subscribeLanguage`、`t`
|
|
42
42
|
- 思维导图:`layoutMindMap`、`mindMapNodeColor`、`mindMapNodeSize` 等
|
|
43
43
|
- 类型:`Shape`、`ShapeType`、`EditorData`、`ToolType`、`MindMapNode` 等
|
|
44
44
|
|
|
@@ -47,16 +47,95 @@ editor.setShapes([
|
|
|
47
47
|
```ts
|
|
48
48
|
interface EditorOptions {
|
|
49
49
|
theme?: Partial<DrawuiTheme>
|
|
50
|
-
language?: 'zh-CN' | 'en-US'
|
|
50
|
+
language?: 'zh-CN' | 'zh-TW' | 'en-US' | 'ja-JP' | 'ko-KR' | 'de-DE' | 'fr-FR'
|
|
51
51
|
shapes?: Shape[]
|
|
52
52
|
persist?: boolean // 是否写入 localStorage,默认 true(提供 shapes 时自动关闭)
|
|
53
53
|
}
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
+
> 可用语言清单也可直接从 `LANGUAGES` 读取(含各语言的本族语名称),便于自行渲染语言切换 UI。
|
|
57
|
+
|
|
56
58
|
## 使用 drawui 的项目
|
|
57
59
|
|
|
58
60
|
- **[myBookEditor](https://github.com/weishell/myBookEditor)** — 基于 [Slate.js](https://github.com/ianstormtaylor/slate) 的富文本 / 文档编辑器,已接入 drawui 画板:可在文档中直接插入并编辑画板,用于绘制图示、UML 类图、思维导图等,并随文档一起导出 / 下载。
|
|
59
61
|
|
|
62
|
+
## 更新日志
|
|
63
|
+
|
|
64
|
+
### v0.3.6
|
|
65
|
+
|
|
66
|
+
- 🌏 国际化新增 5 种语言:`zh-TW`、`ja-JP`、`ko-KR`、`de-DE`、`fr-FR`(连同简体中文 / English 共 7 种);界面文案(工具栏、状态栏、样式面板、生成菜单、小地图、思维导图)已全部翻译。
|
|
67
|
+
- 📦 新增导出 `LANGUAGES`:`{ code, label }[]`,含各语言的本族语名称,便于宿主直接渲染语言切换 UI。
|
|
68
|
+
- ℹ️ 语言字典改为 `Record<MessageKey, string>` 强约束,任一语言漏翻 key 会在编译期直接报错。
|
|
69
|
+
|
|
70
|
+
> 更早版本的完整记录见仓库根目录 README。
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
MIT
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
# 繁體中文
|
|
79
|
+
|
|
80
|
+
[简体中文](#drawui-core) | **繁體中文** | [English](#english) | [日本語](#日本語) | [한국어](#한국어) | [Deutsch](#deutsch) | [Français](#français)
|
|
81
|
+
|
|
82
|
+
框架無關的核心畫布繪圖引擎(原生 TypeScript,無 UI 框架相依)。
|
|
83
|
+
|
|
84
|
+
React 封裝請見 [drawui-react](https://www.npmjs.com/package/drawui-react)。
|
|
85
|
+
|
|
86
|
+
## 安裝
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
npm install drawui-core
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## 用法
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
import { Editor } from 'drawui-core'
|
|
96
|
+
|
|
97
|
+
const canvas = document.getElementById('board') as HTMLCanvasElement
|
|
98
|
+
const editor = new Editor(canvas, { language: 'zh-TW' })
|
|
99
|
+
|
|
100
|
+
editor.subscribe(() => console.log('changed'))
|
|
101
|
+
editor.setShapes([
|
|
102
|
+
{
|
|
103
|
+
id: 'r1',
|
|
104
|
+
type: 'rectangle',
|
|
105
|
+
x: 80, y: 80, width: 160, height: 90, rotation: 0,
|
|
106
|
+
text: 'Hello',
|
|
107
|
+
style: { strokeColor: '#3b82f6', fillColor: '#eff6ff', strokeWidth: 2, strokeDash: null },
|
|
108
|
+
},
|
|
109
|
+
])
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## 主要匯出
|
|
113
|
+
|
|
114
|
+
- `Editor`(`new Editor(canvas, options?)`)、`EditorOptions`、`UiEvent`
|
|
115
|
+
- 工具類別:`SelectTool`、`HandTool`、`ShapeTool`、`LineTool`、`FreehandTool`、`ArrowTool`
|
|
116
|
+
- 幾何:`Vec`、`Mat2d`、`Camera`、`Renderer`
|
|
117
|
+
- 主題:`THEME`、`getTheme`、`setTheme`、`subscribeTheme`、`hexToRgba`、`shadeColor`
|
|
118
|
+
- 國際化:`LANGUAGES`、`setLanguage`、`getLanguage`、`subscribeLanguage`、`t`
|
|
119
|
+
- 心智圖:`layoutMindMap`、`mindMapNodeColor`、`mindMapNodeSize` 等
|
|
120
|
+
- 型別:`Shape`、`ShapeType`、`EditorData`、`ToolType`、`MindMapNode` 等
|
|
121
|
+
|
|
122
|
+
## 建構選項
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
interface EditorOptions {
|
|
126
|
+
theme?: Partial<DrawuiTheme>
|
|
127
|
+
language?: 'zh-CN' | 'zh-TW' | 'en-US' | 'ja-JP' | 'ko-KR' | 'de-DE' | 'fr-FR'
|
|
128
|
+
shapes?: Shape[]
|
|
129
|
+
persist?: boolean // 是否寫入 localStorage,預設 true(提供 shapes 時自動關閉)
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
> 可用語言清單也可直接從 `LANGUAGES` 讀取(含各語言的原生名稱),方便自行渲染語言切換 UI。
|
|
134
|
+
|
|
135
|
+
## 使用 drawui 的專案
|
|
136
|
+
|
|
137
|
+
- **[myBookEditor](https://github.com/weishell/myBookEditor)** — 基於 [Slate.js](https://github.com/ianstormtaylor/slate) 的富文字/文件編輯器,已整合 drawui 畫板:可在文件中直接插入並編輯畫板,用於繪製圖示、UML 類別圖、心智圖等,並隨文件一起匯出/下載。
|
|
138
|
+
|
|
60
139
|
## License
|
|
61
140
|
|
|
62
141
|
MIT
|
|
@@ -65,7 +144,7 @@ MIT
|
|
|
65
144
|
|
|
66
145
|
# English
|
|
67
146
|
|
|
68
|
-
[简体中文](#drawui-core) | **English**
|
|
147
|
+
[简体中文](#drawui-core) | [繁體中文](#繁體中文) | **English** | [日本語](#日本語) | [한국어](#한국어) | [Deutsch](#deutsch) | [Français](#français)
|
|
69
148
|
|
|
70
149
|
Framework-agnostic core canvas drawing engine (vanilla TypeScript, no UI-framework dependency).
|
|
71
150
|
|
|
@@ -103,7 +182,7 @@ editor.setShapes([
|
|
|
103
182
|
- Tools: `SelectTool`, `HandTool`, `ShapeTool`, `LineTool`, `FreehandTool`, `ArrowTool`
|
|
104
183
|
- Geometry: `Vec`, `Mat2d`, `Camera`, `Renderer`
|
|
105
184
|
- Theme: `THEME`, `getTheme`, `setTheme`, `subscribeTheme`, `hexToRgba`, `shadeColor`
|
|
106
|
-
- i18n: `setLanguage`, `getLanguage`, `subscribeLanguage`, `t`
|
|
185
|
+
- i18n: `LANGUAGES`, `setLanguage`, `getLanguage`, `subscribeLanguage`, `t`
|
|
107
186
|
- Mind map: `layoutMindMap`, `mindMapNodeColor`, `mindMapNodeSize`, …
|
|
108
187
|
- Types: `Shape`, `ShapeType`, `EditorData`, `ToolType`, `MindMapNode`, …
|
|
109
188
|
|
|
@@ -112,16 +191,296 @@ editor.setShapes([
|
|
|
112
191
|
```ts
|
|
113
192
|
interface EditorOptions {
|
|
114
193
|
theme?: Partial<DrawuiTheme>
|
|
115
|
-
language?: 'zh-CN' | 'en-US'
|
|
194
|
+
language?: 'zh-CN' | 'zh-TW' | 'en-US' | 'ja-JP' | 'ko-KR' | 'de-DE' | 'fr-FR'
|
|
116
195
|
shapes?: Shape[]
|
|
117
196
|
persist?: boolean // persist to localStorage; defaults to true (auto-off when `shapes` is given)
|
|
118
197
|
}
|
|
119
198
|
```
|
|
120
199
|
|
|
200
|
+
> The list of available languages is also exported as `LANGUAGES` (with each language's native name), handy for rendering your own language switcher.
|
|
201
|
+
|
|
121
202
|
## Projects using drawui
|
|
122
203
|
|
|
123
204
|
- **[myBookEditor](https://github.com/weishell/myBookEditor)** — a rich-text / document editor built on [Slate.js](https://github.com/ianstormtaylor/slate). It embeds drawui boards: insert and edit a board right inside a document to draw diagrams, UML class diagrams and mind maps, and export / download them along with the document.
|
|
124
205
|
|
|
206
|
+
## Changelog
|
|
207
|
+
|
|
208
|
+
### v0.3.6
|
|
209
|
+
|
|
210
|
+
- 🌏 Added 5 languages: `zh-TW`, `ja-JP`, `ko-KR`, `de-DE`, `fr-FR` (7 in total together with Simplified Chinese and English). All UI strings — toolbar, status bar, style panel, create-shape menu, minimap, mind map — are translated.
|
|
211
|
+
- 📦 New export `LANGUAGES`: `{ code, label }[]` with each language's native name, handy for rendering your own language switcher.
|
|
212
|
+
- ℹ️ Dictionaries are now typed as `Record<MessageKey, string>`, so a missing key in any language fails at compile time.
|
|
213
|
+
|
|
214
|
+
> The full history lives in the repository root README.
|
|
215
|
+
|
|
125
216
|
## License
|
|
126
217
|
|
|
127
218
|
MIT
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
# 日本語
|
|
223
|
+
|
|
224
|
+
[简体中文](#drawui-core) | [繁體中文](#繁體中文) | [English](#english) | **日本語** | [한국어](#한국어) | [Deutsch](#deutsch) | [Français](#français)
|
|
225
|
+
|
|
226
|
+
フレームワーク非依存のコア描画エンジン(ピュア TypeScript、UI フレームワークへの依存なし)。
|
|
227
|
+
|
|
228
|
+
React ラッパーは [drawui-react](https://www.npmjs.com/package/drawui-react) をご覧ください。
|
|
229
|
+
|
|
230
|
+
## インストール
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
npm install drawui-core
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## 使い方
|
|
237
|
+
|
|
238
|
+
```ts
|
|
239
|
+
import { Editor } from 'drawui-core'
|
|
240
|
+
|
|
241
|
+
const canvas = document.getElementById('board') as HTMLCanvasElement
|
|
242
|
+
const editor = new Editor(canvas, { language: 'ja-JP' })
|
|
243
|
+
|
|
244
|
+
editor.subscribe(() => console.log('changed'))
|
|
245
|
+
editor.setShapes([
|
|
246
|
+
{
|
|
247
|
+
id: 'r1',
|
|
248
|
+
type: 'rectangle',
|
|
249
|
+
x: 80, y: 80, width: 160, height: 90, rotation: 0,
|
|
250
|
+
text: 'Hello',
|
|
251
|
+
style: { strokeColor: '#3b82f6', fillColor: '#eff6ff', strokeWidth: 2, strokeDash: null },
|
|
252
|
+
},
|
|
253
|
+
])
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## 主なエクスポート
|
|
257
|
+
|
|
258
|
+
- `Editor`(`new Editor(canvas, options?)`)、`EditorOptions`、`UiEvent`
|
|
259
|
+
- ツール:`SelectTool`、`HandTool`、`ShapeTool`、`LineTool`、`FreehandTool`、`ArrowTool`
|
|
260
|
+
- 幾何:`Vec`、`Mat2d`、`Camera`、`Renderer`
|
|
261
|
+
- テーマ:`THEME`、`getTheme`、`setTheme`、`subscribeTheme`、`hexToRgba`、`shadeColor`
|
|
262
|
+
- 国際化:`LANGUAGES`、`setLanguage`、`getLanguage`、`subscribeLanguage`、`t`
|
|
263
|
+
- マインドマップ:`layoutMindMap`、`mindMapNodeColor`、`mindMapNodeSize` など
|
|
264
|
+
- 型:`Shape`、`ShapeType`、`EditorData`、`ToolType`、`MindMapNode` など
|
|
265
|
+
|
|
266
|
+
## コンストラクタオプション
|
|
267
|
+
|
|
268
|
+
```ts
|
|
269
|
+
interface EditorOptions {
|
|
270
|
+
theme?: Partial<DrawuiTheme>
|
|
271
|
+
language?: 'zh-CN' | 'zh-TW' | 'en-US' | 'ja-JP' | 'ko-KR' | 'de-DE' | 'fr-FR'
|
|
272
|
+
shapes?: Shape[]
|
|
273
|
+
persist?: boolean // localStorage に保存するか。既定は true(shapes を渡すと自動でオフ)
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
> 利用可能な言語の一覧は `LANGUAGES` としてもエクスポートされています(各言語のネイティブ表記つき)。独自の言語切り替え UI の実装に便利です。
|
|
278
|
+
|
|
279
|
+
## drawui を利用しているプロジェクト
|
|
280
|
+
|
|
281
|
+
- **[myBookEditor](https://github.com/weishell/myBookEditor)** — [Slate.js](https://github.com/ianstormtaylor/slate) ベースのリッチテキスト/ドキュメントエディタ。drawui のボードを組み込んでおり、ドキュメント内でボードを挿入・編集して図、UML クラス図、マインドマップなどを描画し、ドキュメントと一緒にエクスポート/ダウンロードできます。
|
|
282
|
+
|
|
283
|
+
## ライセンス
|
|
284
|
+
|
|
285
|
+
MIT
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
# 한국어
|
|
290
|
+
|
|
291
|
+
[简体中文](#drawui-core) | [繁體中文](#繁體中文) | [English](#english) | [日本語](#日本語) | **한국어** | [Deutsch](#deutsch) | [Français](#français)
|
|
292
|
+
|
|
293
|
+
프레임워크에 종속되지 않는 코어 캔버스 드로잉 엔진(순수 TypeScript, UI 프레임워크 의존성 없음).
|
|
294
|
+
|
|
295
|
+
React 래퍼는 [drawui-react](https://www.npmjs.com/package/drawui-react)를 참고하세요.
|
|
296
|
+
|
|
297
|
+
## 설치
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
npm install drawui-core
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
## 사용법
|
|
304
|
+
|
|
305
|
+
```ts
|
|
306
|
+
import { Editor } from 'drawui-core'
|
|
307
|
+
|
|
308
|
+
const canvas = document.getElementById('board') as HTMLCanvasElement
|
|
309
|
+
const editor = new Editor(canvas, { language: 'ko-KR' })
|
|
310
|
+
|
|
311
|
+
editor.subscribe(() => console.log('changed'))
|
|
312
|
+
editor.setShapes([
|
|
313
|
+
{
|
|
314
|
+
id: 'r1',
|
|
315
|
+
type: 'rectangle',
|
|
316
|
+
x: 80, y: 80, width: 160, height: 90, rotation: 0,
|
|
317
|
+
text: 'Hello',
|
|
318
|
+
style: { strokeColor: '#3b82f6', fillColor: '#eff6ff', strokeWidth: 2, strokeDash: null },
|
|
319
|
+
},
|
|
320
|
+
])
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
## 주요 내보내기
|
|
324
|
+
|
|
325
|
+
- `Editor`(`new Editor(canvas, options?)`), `EditorOptions`, `UiEvent`
|
|
326
|
+
- 도구: `SelectTool`, `HandTool`, `ShapeTool`, `LineTool`, `FreehandTool`, `ArrowTool`
|
|
327
|
+
- 기하: `Vec`, `Mat2d`, `Camera`, `Renderer`
|
|
328
|
+
- 테마: `THEME`, `getTheme`, `setTheme`, `subscribeTheme`, `hexToRgba`, `shadeColor`
|
|
329
|
+
- 국제화: `LANGUAGES`, `setLanguage`, `getLanguage`, `subscribeLanguage`, `t`
|
|
330
|
+
- 마인드맵: `layoutMindMap`, `mindMapNodeColor`, `mindMapNodeSize` 등
|
|
331
|
+
- 타입: `Shape`, `ShapeType`, `EditorData`, `ToolType`, `MindMapNode` 등
|
|
332
|
+
|
|
333
|
+
## 생성자 옵션
|
|
334
|
+
|
|
335
|
+
```ts
|
|
336
|
+
interface EditorOptions {
|
|
337
|
+
theme?: Partial<DrawuiTheme>
|
|
338
|
+
language?: 'zh-CN' | 'zh-TW' | 'en-US' | 'ja-JP' | 'ko-KR' | 'de-DE' | 'fr-FR'
|
|
339
|
+
shapes?: Shape[]
|
|
340
|
+
persist?: boolean // localStorage에 저장할지 여부. 기본값 true (shapes를 넘기면 자동으로 꺼짐)
|
|
341
|
+
}
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
> 사용 가능한 언어 목록은 `LANGUAGES`로도 내보내집니다(각 언어의 원어 표기 포함). 직접 언어 전환 UI를 만들 때 편리합니다.
|
|
345
|
+
|
|
346
|
+
## drawui를 사용하는 프로젝트
|
|
347
|
+
|
|
348
|
+
- **[myBookEditor](https://github.com/weishell/myBookEditor)** — [Slate.js](https://github.com/ianstormtaylor/slate) 기반의 리치 텍스트·문서 편집기. drawui 보드를 내장하여 문서 안에서 보드를 삽입·편집해 다이어그램, UML 클래스 다이어그램, 마인드맵 등을 그리고 문서와 함께 내보내기·다운로드할 수 있습니다.
|
|
349
|
+
|
|
350
|
+
## 라이선스
|
|
351
|
+
|
|
352
|
+
MIT
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
# Deutsch
|
|
357
|
+
|
|
358
|
+
[简体中文](#drawui-core) | [繁體中文](#繁體中文) | [English](#english) | [日本語](#日本語) | [한국어](#한국어) | **Deutsch** | [Français](#français)
|
|
359
|
+
|
|
360
|
+
Framework-unabhängige Canvas-Zeichenbibliothek (reines TypeScript, keine Abhängigkeit von einem UI-Framework).
|
|
361
|
+
|
|
362
|
+
React-Wrapper: [drawui-react](https://www.npmjs.com/package/drawui-react).
|
|
363
|
+
|
|
364
|
+
## Installation
|
|
365
|
+
|
|
366
|
+
```bash
|
|
367
|
+
npm install drawui-core
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
## Verwendung
|
|
371
|
+
|
|
372
|
+
```ts
|
|
373
|
+
import { Editor } from 'drawui-core'
|
|
374
|
+
|
|
375
|
+
const canvas = document.getElementById('board') as HTMLCanvasElement
|
|
376
|
+
const editor = new Editor(canvas, { language: 'de-DE' })
|
|
377
|
+
|
|
378
|
+
editor.subscribe(() => console.log('changed'))
|
|
379
|
+
editor.setShapes([
|
|
380
|
+
{
|
|
381
|
+
id: 'r1',
|
|
382
|
+
type: 'rectangle',
|
|
383
|
+
x: 80, y: 80, width: 160, height: 90, rotation: 0,
|
|
384
|
+
text: 'Hello',
|
|
385
|
+
style: { strokeColor: '#3b82f6', fillColor: '#eff6ff', strokeWidth: 2, strokeDash: null },
|
|
386
|
+
},
|
|
387
|
+
])
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
## Wichtigste Exporte
|
|
391
|
+
|
|
392
|
+
- `Editor` (`new Editor(canvas, options?)`), `EditorOptions`, `UiEvent`
|
|
393
|
+
- Werkzeuge: `SelectTool`, `HandTool`, `ShapeTool`, `LineTool`, `FreehandTool`, `ArrowTool`
|
|
394
|
+
- Geometrie: `Vec`, `Mat2d`, `Camera`, `Renderer`
|
|
395
|
+
- Theme: `THEME`, `getTheme`, `setTheme`, `subscribeTheme`, `hexToRgba`, `shadeColor`
|
|
396
|
+
- i18n: `LANGUAGES`, `setLanguage`, `getLanguage`, `subscribeLanguage`, `t`
|
|
397
|
+
- Mindmap: `layoutMindMap`, `mindMapNodeColor`, `mindMapNodeSize`, …
|
|
398
|
+
- Typen: `Shape`, `ShapeType`, `EditorData`, `ToolType`, `MindMapNode`, …
|
|
399
|
+
|
|
400
|
+
## EditorOptions
|
|
401
|
+
|
|
402
|
+
```ts
|
|
403
|
+
interface EditorOptions {
|
|
404
|
+
theme?: Partial<DrawuiTheme>
|
|
405
|
+
language?: 'zh-CN' | 'zh-TW' | 'en-US' | 'ja-JP' | 'ko-KR' | 'de-DE' | 'fr-FR'
|
|
406
|
+
shapes?: Shape[]
|
|
407
|
+
persist?: boolean // in localStorage speichern; Standard true (automatisch aus, wenn `shapes` gesetzt ist)
|
|
408
|
+
}
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
> Die Liste der verfügbaren Sprachen wird ebenfalls als `LANGUAGES` exportiert (mit der jeweiligen Eigenbezeichnung) – praktisch für einen eigenen Sprachumschalter.
|
|
412
|
+
|
|
413
|
+
## Projekte, die drawui verwenden
|
|
414
|
+
|
|
415
|
+
- **[myBookEditor](https://github.com/weishell/myBookEditor)** — ein Rich-Text-/Dokumenteneditor auf Basis von [Slate.js](https://github.com/ianstormtaylor/slate). Er bindet drawui-Boards ein: Boards direkt im Dokument einfügen und bearbeiten, um Diagramme, UML-Klassendiagramme und Mindmaps zu zeichnen und zusammen mit dem Dokument zu exportieren / herunterzuladen.
|
|
416
|
+
|
|
417
|
+
## Lizenz
|
|
418
|
+
|
|
419
|
+
MIT
|
|
420
|
+
|
|
421
|
+
---
|
|
422
|
+
|
|
423
|
+
# Français
|
|
424
|
+
|
|
425
|
+
[简体中文](#drawui-core) | [繁體中文](#繁體中文) | [English](#english) | [日本語](#日本語) | [한국어](#한국어) | [Deutsch](#deutsch) | **Français**
|
|
426
|
+
|
|
427
|
+
Moteur de dessin sur canvas indépendant du framework (TypeScript pur, sans dépendance à un framework UI).
|
|
428
|
+
|
|
429
|
+
Wrapper React : [drawui-react](https://www.npmjs.com/package/drawui-react).
|
|
430
|
+
|
|
431
|
+
## Installation
|
|
432
|
+
|
|
433
|
+
```bash
|
|
434
|
+
npm install drawui-core
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
## Utilisation
|
|
438
|
+
|
|
439
|
+
```ts
|
|
440
|
+
import { Editor } from 'drawui-core'
|
|
441
|
+
|
|
442
|
+
const canvas = document.getElementById('board') as HTMLCanvasElement
|
|
443
|
+
const editor = new Editor(canvas, { language: 'fr-FR' })
|
|
444
|
+
|
|
445
|
+
editor.subscribe(() => console.log('changed'))
|
|
446
|
+
editor.setShapes([
|
|
447
|
+
{
|
|
448
|
+
id: 'r1',
|
|
449
|
+
type: 'rectangle',
|
|
450
|
+
x: 80, y: 80, width: 160, height: 90, rotation: 0,
|
|
451
|
+
text: 'Hello',
|
|
452
|
+
style: { strokeColor: '#3b82f6', fillColor: '#eff6ff', strokeWidth: 2, strokeDash: null },
|
|
453
|
+
},
|
|
454
|
+
])
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
## Principaux exports
|
|
458
|
+
|
|
459
|
+
- `Editor` (`new Editor(canvas, options?)`), `EditorOptions`, `UiEvent`
|
|
460
|
+
- Outils : `SelectTool`, `HandTool`, `ShapeTool`, `LineTool`, `FreehandTool`, `ArrowTool`
|
|
461
|
+
- Géométrie : `Vec`, `Mat2d`, `Camera`, `Renderer`
|
|
462
|
+
- Thème : `THEME`, `getTheme`, `setTheme`, `subscribeTheme`, `hexToRgba`, `shadeColor`
|
|
463
|
+
- i18n : `LANGUAGES`, `setLanguage`, `getLanguage`, `subscribeLanguage`, `t`
|
|
464
|
+
- Carte mentale : `layoutMindMap`, `mindMapNodeColor`, `mindMapNodeSize`, …
|
|
465
|
+
- Types : `Shape`, `ShapeType`, `EditorData`, `ToolType`, `MindMapNode`, …
|
|
466
|
+
|
|
467
|
+
## Options de l'éditeur
|
|
468
|
+
|
|
469
|
+
```ts
|
|
470
|
+
interface EditorOptions {
|
|
471
|
+
theme?: Partial<DrawuiTheme>
|
|
472
|
+
language?: 'zh-CN' | 'zh-TW' | 'en-US' | 'ja-JP' | 'ko-KR' | 'de-DE' | 'fr-FR'
|
|
473
|
+
shapes?: Shape[]
|
|
474
|
+
persist?: boolean // écrire dans localStorage ; par défaut true (désactivé si `shapes` est fourni)
|
|
475
|
+
}
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
> La liste des langues disponibles est également exportée sous `LANGUAGES` (avec le nom natif de chaque langue), pratique pour construire votre propre sélecteur de langue.
|
|
479
|
+
|
|
480
|
+
## Projets utilisant drawui
|
|
481
|
+
|
|
482
|
+
- **[myBookEditor](https://github.com/weishell/myBookEditor)** — un éditeur de texte enrichi / de documents basé sur [Slate.js](https://github.com/ianstormtaylor/slate). Il intègre les tableaux drawui : insérez et modifiez un tableau directement dans le document pour dessiner des schémas, des diagrammes de classes UML et des cartes mentales, puis exportez / téléchargez le tout avec le document.
|
|
483
|
+
|
|
484
|
+
## Licence
|
|
485
|
+
|
|
486
|
+
MIT
|