ice-entity-designer 0.0.18 → 0.0.20
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 +43 -0
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/index.umd.js +2 -2
- package/dist/types/flow/FlowDesigner.d.mts +123 -0
- package/dist/types/flow/FlowDesigner.d.ts +123 -0
- package/dist/types/flow/FlowEdge.d.mts +35 -0
- package/dist/types/flow/FlowEdge.d.ts +35 -0
- package/dist/types/flow/FlowNode.d.mts +54 -0
- package/dist/types/flow/FlowNode.d.ts +54 -0
- package/dist/types/flow/flow_shapes.d.mts +18 -0
- package/dist/types/flow/flow_shapes.d.ts +18 -0
- package/dist/types/index.d.mts +7 -0
- package/dist/types/index.d.ts +7 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -76,6 +76,12 @@ IED(ice entity designer)是基于 [ice-render](https://github.com/ice-render
|
|
|
76
76
|
|
|
77
77
|
<img src="./tests/assets/editor.png" alt="交互式编辑器与 TypeORM Schema" />
|
|
78
78
|
|
|
79
|
+
同一套内核也能承载**流程图**(`tests/flowchart-editor.html`):四类节点(开始/结束、处理、判定、输入/输出,
|
|
80
|
+
其中判定菱形与输入输出平行四边形是自定义 `ICEPath` 形状)、正交/贝塞尔连线 + 分支标签(是/否)、
|
|
81
|
+
拖拽 / 连线 / 撤销重做 / 快照存取:
|
|
82
|
+
|
|
83
|
+
<img src="./tests/assets/flowchart-editor.png" alt="流程图编辑器示例" />
|
|
84
|
+
|
|
79
85
|
## 4. 快速开始
|
|
80
86
|
|
|
81
87
|
```bash
|
|
@@ -88,6 +94,7 @@ npm run build
|
|
|
88
94
|
| 示例 | 说明 |
|
|
89
95
|
|---|---|
|
|
90
96
|
| `tests/entity-editor.html` | 交互式编辑器:实时编辑字段、创建/删除实体与关系、校验与保存加载;右侧面板含「TypeORM Schema」标签页 |
|
|
97
|
+
| `tests/flowchart-editor.html` | 流程图编辑器:四类节点形状、拖拽、连线(含分支标签)、撤销重做、localStorage 存取与 JSON 导出;纯 DOM 面板,只依赖 `dist` 产物 |
|
|
91
98
|
| [`ice-entity-designer-react-demo`](../ice-entity-designer-react-demo) | 独立的 React 集成示例工程(webpack + TypeScript),涵盖 ref / hook / onChange / 受控模式 |
|
|
92
99
|
|
|
93
100
|
```bash
|
|
@@ -148,6 +155,36 @@ import { EntitySchema } from 'typeorm';
|
|
|
148
155
|
const schemas = designer.toSchemaObject().map((obj) => new EntitySchema(obj));
|
|
149
156
|
```
|
|
150
157
|
|
|
158
|
+
#### 5.2 流程图(FlowDesigner)
|
|
159
|
+
|
|
160
|
+
包内除 ER 之外还内置了一套**流程图**领域图元与应用层(同一个 `ice` 实例即可承载):
|
|
161
|
+
|
|
162
|
+
```js
|
|
163
|
+
import { ICE, FlowDesigner } from 'ice-entity-designer';
|
|
164
|
+
|
|
165
|
+
const ice = new ICE().init('canvas-1');
|
|
166
|
+
const flow = new FlowDesigner(ice);
|
|
167
|
+
|
|
168
|
+
const start = flow.createNode('terminator', { title: '开始' });
|
|
169
|
+
const check = flow.createNode('decision', { title: '库存充足?' });
|
|
170
|
+
flow.createEdge({ sourceId: start.state.id, targetId: check.state.id, sourcePort: 'B', targetPort: 'T' });
|
|
171
|
+
|
|
172
|
+
flow.fitViewport(); // 适应视图
|
|
173
|
+
flow.serialize(); // 流程图快照(version / kind / nodes / edges)
|
|
174
|
+
flow.undo(); // 100 步历史
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
| 能力 | API |
|
|
178
|
+
|---|---|
|
|
179
|
+
| 节点类型 | `createNode('terminator' \| 'process' \| 'decision' \| 'io', props)`;预设尺寸 / 配色见 `FLOW_NODE_KINDS` |
|
|
180
|
+
| 连线 | `createEdge({ sourceId, targetId, sourcePort, targetPort, label, linkShape })`;插槽位置 `T/R/B/L/C`,节点拖动时连线自动跟随 |
|
|
181
|
+
| 增删改查 | `nodes` / `edges` / `selected` / `select()` / `updateNode()` / `updateEdge()` / `remove()`(删节点级联删连线)/ `clear()` |
|
|
182
|
+
| 历史与快照 | `undo()` / `redo()` / `canUndo()` / `canRedo()`、`serialize()` / `toSnapshot()` / `load()`(返回 `{ loaded, nodes, edges, skipped }`) |
|
|
183
|
+
| 视图与订阅 | `fitViewport(padding)`、`subscribe()`、`dispose()` |
|
|
184
|
+
|
|
185
|
+
自定义形状(判定菱形 / 输入输出平行四边形)在 `src/flow/flow_shapes.ts`,走的是引擎的 `ICEPath` 子类机制。
|
|
186
|
+
可运行的完整示例见 `tests/flowchart-editor.html`;AI Agent 生成流程图的 JSON DSL 见 `ice-entity-designer-dsl`。
|
|
187
|
+
|
|
151
188
|
## 6. 在 React 中使用
|
|
152
189
|
|
|
153
190
|
包内置 React 绑定(子路径导出 `ice-entity-designer/react`),不需要自己写 ref / effect 胶水代码。
|
|
@@ -246,6 +283,11 @@ const session = createDesignerSession(canvasEl);
|
|
|
246
283
|
```
|
|
247
284
|
src/
|
|
248
285
|
├── designer/EntityDesigner.ts # 应用层:选择 / 增删改 / 连接 / 校验 / 历史 / 项目存取 / 变更订阅
|
|
286
|
+
├── flow/ # 流程图(与 ER 并列的第二类领域图元)
|
|
287
|
+
│ ├── flow_shapes.ts # 自定义形状:判定菱形 / 输入输出平行四边形
|
|
288
|
+
│ ├── FlowNode.ts # 节点:四类预设(起止 / 处理 / 判定 / 输入输出)+ 居中标题
|
|
289
|
+
│ ├── FlowEdge.ts # 连线:正交 / 贝塞尔 + 箭头 + 分支标签,插槽吸附
|
|
290
|
+
│ └── FlowDesigner.ts # 应用层:建节点/连线、选择、增删改、历史、快照存取、适应视图
|
|
249
291
|
├── er-component/
|
|
250
292
|
│ ├── Entity.ts # 实体:表头 + 字段列表 + 约束标记 + TypeORM 序列化
|
|
251
293
|
│ └── Relation.ts # 关系:基数 / 箭头 / 标签语义 / 连接槽位
|
|
@@ -270,6 +312,7 @@ src/
|
|
|
270
312
|
| `npm run build` | 清理并完整构建(类型声明 + JS 产物) |
|
|
271
313
|
| `npm run types:check` | 仅做 TypeScript 类型检查 |
|
|
272
314
|
| `npm test` | 运行单元测试(Jest) |
|
|
315
|
+
| `npm run test:e2e` | 浏览器端到端回归(Playwright,覆盖 `tests/entity-editor.html` 与 `tests/flowchart-editor.html`) |
|
|
273
316
|
| `npm run pretty` | Prettier 格式化源码 |
|
|
274
317
|
|
|
275
318
|
## 9. 环境要求与依赖
|