drawui-react 0.3.5 → 0.4.0
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/LICENSE +21 -21
- package/README.md +484 -127
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +1 -1
- package/dist/styles.css +244 -1
- package/package.json +2 -2
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 drawui contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 drawui contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,127 +1,484 @@
|
|
|
1
|
-
# drawui-react
|
|
2
|
-
|
|
3
|
-
**简体中文** | [English](#english)
|
|
4
|
-
|
|
5
|
-
基于 [drawui-core](https://www.npmjs.com/package/drawui-core) 的 React 封装,提供开箱即用的画布组件。
|
|
6
|
-
|
|
7
|
-
## 安装
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install drawui-react # 自动安装 drawui-core
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## 用法
|
|
14
|
-
|
|
15
|
-
```tsx
|
|
16
|
-
import { CanvasBoard } from 'drawui-react'
|
|
17
|
-
import 'drawui-react/styles.css'
|
|
18
|
-
import type { Editor, EditorData } from 'drawui-core'
|
|
19
|
-
|
|
20
|
-
export function App() {
|
|
21
|
-
return (
|
|
22
|
-
<CanvasBoard
|
|
23
|
-
themeColor="#3b82f6"
|
|
24
|
-
language="zh-CN"
|
|
25
|
-
onChange={(data: EditorData) => console.log(data.shapes.length)}
|
|
26
|
-
onReady={(editor: Editor) => editor.setShapes([])}
|
|
27
|
-
/>
|
|
28
|
-
)
|
|
29
|
-
}
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
> 样式需单独引入:`import 'drawui-react/styles.css'`
|
|
33
|
-
|
|
34
|
-
## `<CanvasBoard>` 主要属性
|
|
35
|
-
|
|
36
|
-
| 属性 | 类型 | 说明 |
|
|
37
|
-
| --- | --- | --- |
|
|
38
|
-
| `initialTool` | `ToolType` | 初始工具,默认 `'select'` |
|
|
39
|
-
| `themeColor` | `string` | 主题主色(选中态 / 手柄 / 强调色),默认 `#3b82f6` |
|
|
40
|
-
| `language` | `'zh-CN' \| 'en-US'` | 界面语言,默认 `'zh-CN'` |
|
|
41
|
-
| `data` | `Shape[]` | 初始图形;传入后不读写 localStorage |
|
|
42
|
-
| `onChange` | `(data: EditorData) => void` | 图形 / 相机变化时回调 |
|
|
43
|
-
| `onReady` | `(editor: Editor) => void` | 编辑器实例就绪,可拿到 `Editor` 完全控制 |
|
|
44
|
-
|
|
45
|
-
## 导出组件
|
|
46
|
-
|
|
47
|
-
- `CanvasBoard` — 主画布(含工具栏 / 缩放 / 样式面板 / 思维导图面板等)
|
|
48
|
-
- `Toolbar` — 工具栏
|
|
49
|
-
- `ZoomControl` — 缩放控件
|
|
50
|
-
|
|
51
|
-
## 依赖
|
|
52
|
-
|
|
53
|
-
- `react` / `react-dom` ^18.3(peerDependencies)
|
|
54
|
-
- `drawui-core`(自动安装)
|
|
55
|
-
|
|
56
|
-
## 使用 drawui 的项目
|
|
57
|
-
|
|
58
|
-
- **[myBookEditor](https://github.com/weishell/myBookEditor)** — 基于 [Slate.js](https://github.com/ianstormtaylor/slate) 的富文本 / 文档编辑器,已接入 drawui 画板:可在文档中直接插入并编辑画板,用于绘制图示、UML 类图、思维导图等,并随文档一起导出 / 下载。
|
|
59
|
-
|
|
60
|
-
##
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
1
|
+
# drawui-react
|
|
2
|
+
|
|
3
|
+
**简体中文** | [繁體中文](#繁體中文) | [English](#english) | [日本語](#日本語) | [한국어](#한국어) | [Deutsch](#deutsch) | [Français](#français)
|
|
4
|
+
|
|
5
|
+
基于 [drawui-core](https://www.npmjs.com/package/drawui-core) 的 React 封装,提供开箱即用的画布组件。
|
|
6
|
+
|
|
7
|
+
## 安装
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install drawui-react # 自动安装 drawui-core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## 用法
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { CanvasBoard } from 'drawui-react'
|
|
17
|
+
import 'drawui-react/styles.css'
|
|
18
|
+
import type { Editor, EditorData } from 'drawui-core'
|
|
19
|
+
|
|
20
|
+
export function App() {
|
|
21
|
+
return (
|
|
22
|
+
<CanvasBoard
|
|
23
|
+
themeColor="#3b82f6"
|
|
24
|
+
language="zh-CN"
|
|
25
|
+
onChange={(data: EditorData) => console.log(data.shapes.length)}
|
|
26
|
+
onReady={(editor: Editor) => editor.setShapes([])}
|
|
27
|
+
/>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
> 样式需单独引入:`import 'drawui-react/styles.css'`
|
|
33
|
+
|
|
34
|
+
## `<CanvasBoard>` 主要属性
|
|
35
|
+
|
|
36
|
+
| 属性 | 类型 | 说明 |
|
|
37
|
+
| --- | --- | --- |
|
|
38
|
+
| `initialTool` | `ToolType` | 初始工具,默认 `'select'` |
|
|
39
|
+
| `themeColor` | `string` | 主题主色(选中态 / 手柄 / 强调色),默认 `#3b82f6` |
|
|
40
|
+
| `language` | `'zh-CN' \| 'zh-TW' \| 'en-US' \| 'ja-JP' \| 'ko-KR' \| 'de-DE' \| 'fr-FR'` | 界面语言,默认 `'zh-CN'` |
|
|
41
|
+
| `data` | `Shape[]` | 初始图形;传入后不读写 localStorage |
|
|
42
|
+
| `onChange` | `(data: EditorData) => void` | 图形 / 相机变化时回调 |
|
|
43
|
+
| `onReady` | `(editor: Editor) => void` | 编辑器实例就绪,可拿到 `Editor` 完全控制 |
|
|
44
|
+
|
|
45
|
+
## 导出组件
|
|
46
|
+
|
|
47
|
+
- `CanvasBoard` — 主画布(含工具栏 / 缩放 / 样式面板 / 思维导图面板等)
|
|
48
|
+
- `Toolbar` — 工具栏
|
|
49
|
+
- `ZoomControl` — 缩放控件
|
|
50
|
+
|
|
51
|
+
## 依赖
|
|
52
|
+
|
|
53
|
+
- `react` / `react-dom` ^18.3(peerDependencies)
|
|
54
|
+
- `drawui-core`(自动安装)
|
|
55
|
+
|
|
56
|
+
## 使用 drawui 的项目
|
|
57
|
+
|
|
58
|
+
- **[myBookEditor](https://github.com/weishell/myBookEditor)** — 基于 [Slate.js](https://github.com/ianstormtaylor/slate) 的富文本 / 文档编辑器,已接入 drawui 画板:可在文档中直接插入并编辑画板,用于绘制图示、UML 类图、思维导图等,并随文档一起导出 / 下载。
|
|
59
|
+
|
|
60
|
+
## 更新日志
|
|
61
|
+
|
|
62
|
+
### v0.4.0
|
|
63
|
+
|
|
64
|
+
- 💾 **工具栏新增「导出数据 / 导入数据」**:把完整文档(图形 + 相机 + 版本号)存成 JSON,下次导入即可继续绘制;导入成功提示「已恢复 N 个图形」,导入失败(选错文件 / 格式不对)显示红色 ✕ 提示,不再无声无息(基于 `drawui-core` 的 `exportJSON` / `importJSON`)。
|
|
65
|
+
- 🎛️ **图标库面板大幅扩展**:新增「表情」分类(113 个 Twemoji 表情,CC BY 4.0 可免费商用)与 12 个 Lucide 补充分类(天气 / 交通 / 自然 / 建筑 / 医疗 / 购物 / 科学 / 动物 / 时间 / 编辑 / 食物 / 通讯);**移除全部商业品牌图标**(商标侵权风险);工具栏入口图标改为线稿**笑脸**,语义更直观。
|
|
66
|
+
- 📦 依赖的 `drawui-core` 同步升级到 `0.4.0`。
|
|
67
|
+
|
|
68
|
+
### v0.3.6
|
|
69
|
+
|
|
70
|
+
- 🌏 `language` 新增 5 种语言:`zh-TW`、`ja-JP`、`ko-KR`、`de-DE`、`fr-FR`(连同简体中文 / English 共 7 种),画布内所有界面文案同步翻译。
|
|
71
|
+
- 📦 依赖的 `drawui-core` 同步升级到 `0.3.6`(新增 `LANGUAGES` 导出,含各语言本族语名称)。
|
|
72
|
+
- ℹ️ 语言字典改为 `Record<MessageKey, string>` 强约束,任一语言漏翻 key 会在编译期直接报错。
|
|
73
|
+
|
|
74
|
+
> 更早版本的完整记录见仓库根目录 README。
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
MIT
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
# 繁體中文
|
|
83
|
+
|
|
84
|
+
[简体中文](#drawui-react) | **繁體中文** | [English](#english) | [日本語](#日本語) | [한국어](#한국어) | [Deutsch](#deutsch) | [Français](#français)
|
|
85
|
+
|
|
86
|
+
以 [drawui-core](https://www.npmjs.com/package/drawui-core) 為基礎的 React 封裝,提供開箱即用的畫布元件。
|
|
87
|
+
|
|
88
|
+
## 安裝
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npm install drawui-react # 會自動安裝 drawui-core
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## 用法
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
import { CanvasBoard } from 'drawui-react'
|
|
98
|
+
import 'drawui-react/styles.css'
|
|
99
|
+
import type { Editor, EditorData } from 'drawui-core'
|
|
100
|
+
|
|
101
|
+
export function App() {
|
|
102
|
+
return (
|
|
103
|
+
<CanvasBoard
|
|
104
|
+
themeColor="#3b82f6"
|
|
105
|
+
language="zh-TW"
|
|
106
|
+
onChange={(data: EditorData) => console.log(data.shapes.length)}
|
|
107
|
+
onReady={(editor: Editor) => editor.setShapes([])}
|
|
108
|
+
/>
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
> 樣式需單獨引入:`import 'drawui-react/styles.css'`
|
|
114
|
+
|
|
115
|
+
## `<CanvasBoard>` 主要屬性
|
|
116
|
+
|
|
117
|
+
| 屬性 | 型別 | 說明 |
|
|
118
|
+
| --- | --- | --- |
|
|
119
|
+
| `initialTool` | `ToolType` | 初始工具,預設 `'select'` |
|
|
120
|
+
| `themeColor` | `string` | 主題主色(選取態/手柄/強調色),預設 `#3b82f6` |
|
|
121
|
+
| `language` | `'zh-CN' \| 'zh-TW' \| 'en-US' \| 'ja-JP' \| 'ko-KR' \| 'de-DE' \| 'fr-FR'` | 介面語言,預設 `'zh-CN'` |
|
|
122
|
+
| `data` | `Shape[]` | 初始圖形;傳入後不讀寫 localStorage |
|
|
123
|
+
| `onChange` | `(data: EditorData) => void` | 圖形/相機變化時回呼 |
|
|
124
|
+
| `onReady` | `(editor: Editor) => void` | 編輯器實例就緒,可取得 `Editor` 完全控制 |
|
|
125
|
+
|
|
126
|
+
## 匯出元件
|
|
127
|
+
|
|
128
|
+
- `CanvasBoard` — 主畫布(含工具列/縮放/樣式面板/心智圖面板等)
|
|
129
|
+
- `Toolbar` — 工具列
|
|
130
|
+
- `ZoomControl` — 縮放控制項
|
|
131
|
+
|
|
132
|
+
## 相依
|
|
133
|
+
|
|
134
|
+
- `react` / `react-dom` ^18.3(peerDependencies)
|
|
135
|
+
- `drawui-core`(自動安裝)
|
|
136
|
+
|
|
137
|
+
## 使用 drawui 的專案
|
|
138
|
+
|
|
139
|
+
- **[myBookEditor](https://github.com/weishell/myBookEditor)** — 基於 [Slate.js](https://github.com/ianstormtaylor/slate) 的富文字/文件編輯器,已整合 drawui 畫板:可在文件中直接插入並編輯畫板,用於繪製圖示、UML 類別圖、心智圖等,並隨文件一起匯出/下載。
|
|
140
|
+
|
|
141
|
+
## License
|
|
142
|
+
|
|
143
|
+
MIT
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
# English
|
|
148
|
+
|
|
149
|
+
[简体中文](#drawui-react) | [繁體中文](#繁體中文) | **English** | [日本語](#日本語) | [한국어](#한국어) | [Deutsch](#deutsch) | [Français](#français)
|
|
150
|
+
|
|
151
|
+
React wrapper for [drawui-core](https://www.npmjs.com/package/drawui-core), with drop-in canvas components.
|
|
152
|
+
|
|
153
|
+
## Install
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
npm install drawui-react # installs drawui-core automatically
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Usage
|
|
160
|
+
|
|
161
|
+
```tsx
|
|
162
|
+
import { CanvasBoard } from 'drawui-react'
|
|
163
|
+
import 'drawui-react/styles.css'
|
|
164
|
+
import type { Editor, EditorData } from 'drawui-core'
|
|
165
|
+
|
|
166
|
+
export function App() {
|
|
167
|
+
return (
|
|
168
|
+
<CanvasBoard
|
|
169
|
+
themeColor="#3b82f6"
|
|
170
|
+
language="en-US"
|
|
171
|
+
onChange={(data: EditorData) => console.log(data.shapes.length)}
|
|
172
|
+
onReady={(editor: Editor) => editor.setShapes([])}
|
|
173
|
+
/>
|
|
174
|
+
)
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
> The stylesheet must be imported separately: `import 'drawui-react/styles.css'`
|
|
179
|
+
|
|
180
|
+
## `<CanvasBoard>` props
|
|
181
|
+
|
|
182
|
+
| Prop | Type | Description |
|
|
183
|
+
| --- | --- | --- |
|
|
184
|
+
| `initialTool` | `ToolType` | Initial tool, defaults to `'select'` |
|
|
185
|
+
| `themeColor` | `string` | Theme accent (selection / handles / highlights), defaults to `#3b82f6` |
|
|
186
|
+
| `language` | `'zh-CN' \| 'zh-TW' \| 'en-US' \| 'ja-JP' \| 'ko-KR' \| 'de-DE' \| 'fr-FR'` | UI language, defaults to `'zh-CN'` |
|
|
187
|
+
| `data` | `Shape[]` | Initial shapes; when provided, localStorage is not read or written |
|
|
188
|
+
| `onChange` | `(data: EditorData) => void` | Called when shapes / camera change |
|
|
189
|
+
| `onReady` | `(editor: Editor) => void` | Called once the editor is ready (full `Editor` access) |
|
|
190
|
+
|
|
191
|
+
## Exported components
|
|
192
|
+
|
|
193
|
+
- `CanvasBoard` — the main board (toolbar / zoom / style panel / mind-map panel, …)
|
|
194
|
+
- `Toolbar` — the toolbar
|
|
195
|
+
- `ZoomControl` — the zoom control
|
|
196
|
+
|
|
197
|
+
## Dependencies
|
|
198
|
+
|
|
199
|
+
- `react` / `react-dom` ^18.3 (peerDependencies)
|
|
200
|
+
- `drawui-core` (installed automatically)
|
|
201
|
+
|
|
202
|
+
## Projects using drawui
|
|
203
|
+
|
|
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.
|
|
205
|
+
|
|
206
|
+
## Changelog
|
|
207
|
+
|
|
208
|
+
### v0.4.0
|
|
209
|
+
|
|
210
|
+
- 💾 **New "Export data / Import data" toolbar actions**: save the full document (shapes + camera + version) as JSON and import it later to keep drawing. Successful import shows "restored N shapes"; a wrong file / bad format shows a red ✕ failure toast — no more silent no-ops (backed by `exportJSON` / `importJSON` from `drawui-core`).
|
|
211
|
+
- 🎛️ **Icon picker greatly extended**: new "Emoji" category (113 Twemoji glyphs, CC BY 4.0 free for commercial use) plus 12 supplemental Lucide categories (weather / transport / nature / building / medical / shopping / science / animal / time / edit / food / communication). **All commercial brand icons removed** (trademark risk). The toolbar entry icon is now a line-art **smiley**, clearer at a glance.
|
|
212
|
+
- 📦 Bundled `drawui-core` is bumped to `0.4.0`.
|
|
213
|
+
|
|
214
|
+
### v0.3.6
|
|
215
|
+
|
|
216
|
+
- 🌏 `language` now accepts 5 more languages: `zh-TW`, `ja-JP`, `ko-KR`, `de-DE`, `fr-FR` (7 in total together with Simplified Chinese and English); every UI string inside the board is translated.
|
|
217
|
+
- 📦 The bundled `drawui-core` is bumped to `0.3.6` (adds the `LANGUAGES` export with each language's native name).
|
|
218
|
+
- ℹ️ Dictionaries are now typed as `Record<MessageKey, string>`, so a missing key in any language fails at compile time.
|
|
219
|
+
|
|
220
|
+
> The full history lives in the repository root README.
|
|
221
|
+
|
|
222
|
+
## License
|
|
223
|
+
|
|
224
|
+
MIT
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
# 日本語
|
|
229
|
+
|
|
230
|
+
[简体中文](#drawui-react) | [繁體中文](#繁體中文) | [English](#english) | **日本語** | [한국어](#한국어) | [Deutsch](#deutsch) | [Français](#français)
|
|
231
|
+
|
|
232
|
+
[drawui-core](https://www.npmjs.com/package/drawui-core) の React ラッパー。すぐに使えるキャンバスコンポーネントを提供します。
|
|
233
|
+
|
|
234
|
+
## インストール
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
npm install drawui-react # drawui-core も自動でインストールされます
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## 使い方
|
|
241
|
+
|
|
242
|
+
```tsx
|
|
243
|
+
import { CanvasBoard } from 'drawui-react'
|
|
244
|
+
import 'drawui-react/styles.css'
|
|
245
|
+
import type { Editor, EditorData } from 'drawui-core'
|
|
246
|
+
|
|
247
|
+
export function App() {
|
|
248
|
+
return (
|
|
249
|
+
<CanvasBoard
|
|
250
|
+
themeColor="#3b82f6"
|
|
251
|
+
language="ja-JP"
|
|
252
|
+
onChange={(data: EditorData) => console.log(data.shapes.length)}
|
|
253
|
+
onReady={(editor: Editor) => editor.setShapes([])}
|
|
254
|
+
/>
|
|
255
|
+
)
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
> スタイルは別途インポートが必要です:`import 'drawui-react/styles.css'`
|
|
260
|
+
|
|
261
|
+
## `<CanvasBoard>` の主な props
|
|
262
|
+
|
|
263
|
+
| props | 型 | 説明 |
|
|
264
|
+
| --- | --- | --- |
|
|
265
|
+
| `initialTool` | `ToolType` | 初期ツール。既定は `'select'` |
|
|
266
|
+
| `themeColor` | `string` | テーマのメインカラー(選択状態/ハンドル/強調色)。既定は `#3b82f6` |
|
|
267
|
+
| `language` | `'zh-CN' \| 'zh-TW' \| 'en-US' \| 'ja-JP' \| 'ko-KR' \| 'de-DE' \| 'fr-FR'` | UI の言語。既定は `'zh-CN'` |
|
|
268
|
+
| `data` | `Shape[]` | 初期図形。渡した場合 localStorage の読み書きは行いません |
|
|
269
|
+
| `onChange` | `(data: EditorData) => void` | 図形/カメラの変化時に呼ばれます |
|
|
270
|
+
| `onReady` | `(editor: Editor) => void` | エディタの準備完了時に呼ばれ、`Editor` を完全に操作できます |
|
|
271
|
+
|
|
272
|
+
## エクスポートされるコンポーネント
|
|
273
|
+
|
|
274
|
+
- `CanvasBoard` — メインのボード(ツールバー/ズーム/スタイルパネル/マインドマップパネルなど)
|
|
275
|
+
- `Toolbar` — ツールバー
|
|
276
|
+
- `ZoomControl` — ズームコントロール
|
|
277
|
+
|
|
278
|
+
## 依存関係
|
|
279
|
+
|
|
280
|
+
- `react` / `react-dom` ^18.3(peerDependencies)
|
|
281
|
+
- `drawui-core`(自動でインストール)
|
|
282
|
+
|
|
283
|
+
## drawui を利用しているプロジェクト
|
|
284
|
+
|
|
285
|
+
- **[myBookEditor](https://github.com/weishell/myBookEditor)** — [Slate.js](https://github.com/ianstormtaylor/slate) ベースのリッチテキスト/ドキュメントエディタ。drawui のボードを組み込んでおり、ドキュメント内でボードを挿入・編集して図、UML クラス図、マインドマップなどを描画し、ドキュメントと一緒にエクスポート/ダウンロードできます。
|
|
286
|
+
|
|
287
|
+
## ライセンス
|
|
288
|
+
|
|
289
|
+
MIT
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
# 한국어
|
|
294
|
+
|
|
295
|
+
[简体中文](#drawui-react) | [繁體中文](#繁體中文) | [English](#english) | [日本語](#日本語) | **한국어** | [Deutsch](#deutsch) | [Français](#français)
|
|
296
|
+
|
|
297
|
+
[drawui-core](https://www.npmjs.com/package/drawui-core) 기반의 React 래퍼로, 바로 쓸 수 있는 캔버스 컴포넌트를 제공합니다.
|
|
298
|
+
|
|
299
|
+
## 설치
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
npm install drawui-react # drawui-core도 자동으로 설치됩니다
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## 사용법
|
|
306
|
+
|
|
307
|
+
```tsx
|
|
308
|
+
import { CanvasBoard } from 'drawui-react'
|
|
309
|
+
import 'drawui-react/styles.css'
|
|
310
|
+
import type { Editor, EditorData } from 'drawui-core'
|
|
311
|
+
|
|
312
|
+
export function App() {
|
|
313
|
+
return (
|
|
314
|
+
<CanvasBoard
|
|
315
|
+
themeColor="#3b82f6"
|
|
316
|
+
language="ko-KR"
|
|
317
|
+
onChange={(data: EditorData) => console.log(data.shapes.length)}
|
|
318
|
+
onReady={(editor: Editor) => editor.setShapes([])}
|
|
319
|
+
/>
|
|
320
|
+
)
|
|
321
|
+
}
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
> 스타일은 별도로 불러와야 합니다: `import 'drawui-react/styles.css'`
|
|
325
|
+
|
|
326
|
+
## `<CanvasBoard>` 주요 props
|
|
327
|
+
|
|
328
|
+
| props | 타입 | 설명 |
|
|
329
|
+
| --- | --- | --- |
|
|
330
|
+
| `initialTool` | `ToolType` | 초기 도구, 기본값 `'select'` |
|
|
331
|
+
| `themeColor` | `string` | 테마 기본 색상(선택 상태/핸들/강조색), 기본값 `#3b82f6` |
|
|
332
|
+
| `language` | `'zh-CN' \| 'zh-TW' \| 'en-US' \| 'ja-JP' \| 'ko-KR' \| 'de-DE' \| 'fr-FR'` | UI 언어, 기본값 `'zh-CN'` |
|
|
333
|
+
| `data` | `Shape[]` | 초기 도형. 넘기면 localStorage를 읽거나 쓰지 않습니다 |
|
|
334
|
+
| `onChange` | `(data: EditorData) => void` | 도형/카메라 변경 시 호출 |
|
|
335
|
+
| `onReady` | `(editor: Editor) => void` | 에디터 준비 완료 시 호출되며 `Editor`를 완전히 제어할 수 있습니다 |
|
|
336
|
+
|
|
337
|
+
## 내보내는 컴포넌트
|
|
338
|
+
|
|
339
|
+
- `CanvasBoard` — 메인 보드(툴바/확대·축소/스타일 패널/마인드맵 패널 등)
|
|
340
|
+
- `Toolbar` — 툴바
|
|
341
|
+
- `ZoomControl` — 확대·축소 컨트롤
|
|
342
|
+
|
|
343
|
+
## 의존성
|
|
344
|
+
|
|
345
|
+
- `react` / `react-dom` ^18.3 (peerDependencies)
|
|
346
|
+
- `drawui-core` (자동 설치)
|
|
347
|
+
|
|
348
|
+
## drawui를 사용하는 프로젝트
|
|
349
|
+
|
|
350
|
+
- **[myBookEditor](https://github.com/weishell/myBookEditor)** — [Slate.js](https://github.com/ianstormtaylor/slate) 기반의 리치 텍스트·문서 편집기. drawui 보드를 내장하여 문서 안에서 보드를 삽입·편집해 다이어그램, UML 클래스 다이어그램, 마인드맵 등을 그리고 문서와 함께 내보내기·다운로드할 수 있습니다.
|
|
351
|
+
|
|
352
|
+
## 라이선스
|
|
353
|
+
|
|
354
|
+
MIT
|
|
355
|
+
|
|
356
|
+
---
|
|
357
|
+
|
|
358
|
+
# Deutsch
|
|
359
|
+
|
|
360
|
+
[简体中文](#drawui-react) | [繁體中文](#繁體中文) | [English](#english) | [日本語](#日本語) | [한국어](#한국어) | **Deutsch** | [Français](#français)
|
|
361
|
+
|
|
362
|
+
React-Wrapper für [drawui-core](https://www.npmjs.com/package/drawui-core) mit sofort einsetzbaren Canvas-Komponenten.
|
|
363
|
+
|
|
364
|
+
## Installation
|
|
365
|
+
|
|
366
|
+
```bash
|
|
367
|
+
npm install drawui-react # installiert drawui-core automatisch
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
## Verwendung
|
|
371
|
+
|
|
372
|
+
```tsx
|
|
373
|
+
import { CanvasBoard } from 'drawui-react'
|
|
374
|
+
import 'drawui-react/styles.css'
|
|
375
|
+
import type { Editor, EditorData } from 'drawui-core'
|
|
376
|
+
|
|
377
|
+
export function App() {
|
|
378
|
+
return (
|
|
379
|
+
<CanvasBoard
|
|
380
|
+
themeColor="#3b82f6"
|
|
381
|
+
language="de-DE"
|
|
382
|
+
onChange={(data: EditorData) => console.log(data.shapes.length)}
|
|
383
|
+
onReady={(editor: Editor) => editor.setShapes([])}
|
|
384
|
+
/>
|
|
385
|
+
)
|
|
386
|
+
}
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
> Das Stylesheet muss separat importiert werden: `import 'drawui-react/styles.css'`
|
|
390
|
+
|
|
391
|
+
## `<CanvasBoard>`-Props
|
|
392
|
+
|
|
393
|
+
| Prop | Typ | Beschreibung |
|
|
394
|
+
| --- | --- | --- |
|
|
395
|
+
| `initialTool` | `ToolType` | Startwerkzeug, Standard `'select'` |
|
|
396
|
+
| `themeColor` | `string` | Akzentfarbe des Themes (Auswahl / Griffe / Hervorhebungen), Standard `#3b82f6` |
|
|
397
|
+
| `language` | `'zh-CN' \| 'zh-TW' \| 'en-US' \| 'ja-JP' \| 'ko-KR' \| 'de-DE' \| 'fr-FR'` | UI-Sprache, Standard `'zh-CN'` |
|
|
398
|
+
| `data` | `Shape[]` | Anfangsformen; wenn gesetzt, wird localStorage nicht gelesen oder geschrieben |
|
|
399
|
+
| `onChange` | `(data: EditorData) => void` | Wird bei Änderungen an Formen / Kamera aufgerufen |
|
|
400
|
+
| `onReady` | `(editor: Editor) => void` | Wird aufgerufen, sobald der Editor bereit ist (voller Zugriff auf `Editor`) |
|
|
401
|
+
|
|
402
|
+
## Exportierte Komponenten
|
|
403
|
+
|
|
404
|
+
- `CanvasBoard` — das Hauptboard (Toolbar / Zoom / Stil-Panel / Mindmap-Panel, …)
|
|
405
|
+
- `Toolbar` — die Toolbar
|
|
406
|
+
- `ZoomControl` — die Zoom-Steuerung
|
|
407
|
+
|
|
408
|
+
## Abhängigkeiten
|
|
409
|
+
|
|
410
|
+
- `react` / `react-dom` ^18.3 (peerDependencies)
|
|
411
|
+
- `drawui-core` (wird automatisch installiert)
|
|
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-react) | [繁體中文](#繁體中文) | [English](#english) | [日本語](#日本語) | [한국어](#한국어) | [Deutsch](#deutsch) | **Français**
|
|
426
|
+
|
|
427
|
+
Wrapper React pour [drawui-core](https://www.npmjs.com/package/drawui-core), avec des composants canvas prêts à l'emploi.
|
|
428
|
+
|
|
429
|
+
## Installation
|
|
430
|
+
|
|
431
|
+
```bash
|
|
432
|
+
npm install drawui-react # installe drawui-core automatiquement
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
## Utilisation
|
|
436
|
+
|
|
437
|
+
```tsx
|
|
438
|
+
import { CanvasBoard } from 'drawui-react'
|
|
439
|
+
import 'drawui-react/styles.css'
|
|
440
|
+
import type { Editor, EditorData } from 'drawui-core'
|
|
441
|
+
|
|
442
|
+
export function App() {
|
|
443
|
+
return (
|
|
444
|
+
<CanvasBoard
|
|
445
|
+
themeColor="#3b82f6"
|
|
446
|
+
language="fr-FR"
|
|
447
|
+
onChange={(data: EditorData) => console.log(data.shapes.length)}
|
|
448
|
+
onReady={(editor: Editor) => editor.setShapes([])}
|
|
449
|
+
/>
|
|
450
|
+
)
|
|
451
|
+
}
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
> La feuille de style doit être importée séparément : `import 'drawui-react/styles.css'`
|
|
455
|
+
|
|
456
|
+
## Props de `<CanvasBoard>`
|
|
457
|
+
|
|
458
|
+
| Prop | Type | Description |
|
|
459
|
+
| --- | --- | --- |
|
|
460
|
+
| `initialTool` | `ToolType` | Outil initial, `'select'` par défaut |
|
|
461
|
+
| `themeColor` | `string` | Couleur d'accentuation du thème (sélection / poignées / surlignage), `#3b82f6` par défaut |
|
|
462
|
+
| `language` | `'zh-CN' \| 'zh-TW' \| 'en-US' \| 'ja-JP' \| 'ko-KR' \| 'de-DE' \| 'fr-FR'` | Langue de l'interface, `'zh-CN'` par défaut |
|
|
463
|
+
| `data` | `Shape[]` | Formes initiales ; si fourni, localStorage n'est ni lu ni écrit |
|
|
464
|
+
| `onChange` | `(data: EditorData) => void` | Appelé lors des changements de formes / caméra |
|
|
465
|
+
| `onReady` | `(editor: Editor) => void` | Appelé dès que l'éditeur est prêt (accès complet à `Editor`) |
|
|
466
|
+
|
|
467
|
+
## Composants exportés
|
|
468
|
+
|
|
469
|
+
- `CanvasBoard` — le tableau principal (barre d'outils / zoom / panneau de style / panneau de carte mentale, …)
|
|
470
|
+
- `Toolbar` — la barre d'outils
|
|
471
|
+
- `ZoomControl` — le contrôle de zoom
|
|
472
|
+
|
|
473
|
+
## Dépendances
|
|
474
|
+
|
|
475
|
+
- `react` / `react-dom` ^18.3 (peerDependencies)
|
|
476
|
+
- `drawui-core` (installé automatiquement)
|
|
477
|
+
|
|
478
|
+
## Projets utilisant drawui
|
|
479
|
+
|
|
480
|
+
- **[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.
|
|
481
|
+
|
|
482
|
+
## Licence
|
|
483
|
+
|
|
484
|
+
MIT
|