@ngroznykh/papirus 0.1.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 -0
- package/README.md +177 -0
- package/README.ru.md +178 -0
- package/dist/constants.d.ts +21 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/core/AnimationManager.d.ts +24 -0
- package/dist/core/AnimationManager.d.ts.map +1 -0
- package/dist/core/ConnectionManager.d.ts +139 -0
- package/dist/core/ConnectionManager.d.ts.map +1 -0
- package/dist/core/ContextMenuManager.d.ts +72 -0
- package/dist/core/ContextMenuManager.d.ts.map +1 -0
- package/dist/core/DiagramRenderer.d.ts +230 -0
- package/dist/core/DiagramRenderer.d.ts.map +1 -0
- package/dist/core/DragManager.d.ts +67 -0
- package/dist/core/DragManager.d.ts.map +1 -0
- package/dist/core/HistoryManager.d.ts +61 -0
- package/dist/core/HistoryManager.d.ts.map +1 -0
- package/dist/core/InteractionManager.d.ts +78 -0
- package/dist/core/InteractionManager.d.ts.map +1 -0
- package/dist/core/NavigationManager.d.ts +89 -0
- package/dist/core/NavigationManager.d.ts.map +1 -0
- package/dist/core/ResizeManager.d.ts +72 -0
- package/dist/core/ResizeManager.d.ts.map +1 -0
- package/dist/core/SearchManager.d.ts +61 -0
- package/dist/core/SearchManager.d.ts.map +1 -0
- package/dist/core/SelectionManager.d.ts +86 -0
- package/dist/core/SelectionManager.d.ts.map +1 -0
- package/dist/core/history/commands.d.ts +140 -0
- package/dist/core/history/commands.d.ts.map +1 -0
- package/dist/core/overlays/BaseOverlay.d.ts +20 -0
- package/dist/core/overlays/BaseOverlay.d.ts.map +1 -0
- package/dist/core/overlays/GridOverlay.d.ts +15 -0
- package/dist/core/overlays/GridOverlay.d.ts.map +1 -0
- package/dist/core/overlays/GuidesOverlay.d.ts +18 -0
- package/dist/core/overlays/GuidesOverlay.d.ts.map +1 -0
- package/dist/core/overlays/MiniMap.d.ts +22 -0
- package/dist/core/overlays/MiniMap.d.ts.map +1 -0
- package/dist/core/overlays/RulersOverlay.d.ts +18 -0
- package/dist/core/overlays/RulersOverlay.d.ts.map +1 -0
- package/dist/elements/Edge.d.ts +182 -0
- package/dist/elements/Edge.d.ts.map +1 -0
- package/dist/elements/Element.d.ts +131 -0
- package/dist/elements/Element.d.ts.map +1 -0
- package/dist/elements/Group.d.ts +65 -0
- package/dist/elements/Group.d.ts.map +1 -0
- package/dist/elements/Node.d.ts +188 -0
- package/dist/elements/Node.d.ts.map +1 -0
- package/dist/elements/NodeImage.d.ts +51 -0
- package/dist/elements/NodeImage.d.ts.map +1 -0
- package/dist/elements/Port.d.ts +72 -0
- package/dist/elements/Port.d.ts.map +1 -0
- package/dist/elements/TextLabel.d.ts +85 -0
- package/dist/elements/TextLabel.d.ts.map +1 -0
- package/dist/elements/nodes/CircleNode.d.ts +21 -0
- package/dist/elements/nodes/CircleNode.d.ts.map +1 -0
- package/dist/elements/nodes/CustomShapeNode.d.ts +48 -0
- package/dist/elements/nodes/CustomShapeNode.d.ts.map +1 -0
- package/dist/elements/nodes/DiamondNode.d.ts +13 -0
- package/dist/elements/nodes/DiamondNode.d.ts.map +1 -0
- package/dist/elements/nodes/RectangleNode.d.ts +19 -0
- package/dist/elements/nodes/RectangleNode.d.ts.map +1 -0
- package/dist/elements/paths/BezierPathStrategy.d.ts +10 -0
- package/dist/elements/paths/BezierPathStrategy.d.ts.map +1 -0
- package/dist/elements/paths/PathStrategy.d.ts +12 -0
- package/dist/elements/paths/PathStrategy.d.ts.map +1 -0
- package/dist/elements/paths/PolylinePathStrategy.d.ts +11 -0
- package/dist/elements/paths/PolylinePathStrategy.d.ts.map +1 -0
- package/dist/elements/paths/StraightPathStrategy.d.ts +10 -0
- package/dist/elements/paths/StraightPathStrategy.d.ts.map +1 -0
- package/dist/elements/paths/index.d.ts +5 -0
- package/dist/elements/paths/index.d.ts.map +1 -0
- package/dist/events/EventEmitter.d.ts +46 -0
- package/dist/events/EventEmitter.d.ts.map +1 -0
- package/dist/events/InputHandler.d.ts +97 -0
- package/dist/events/InputHandler.d.ts.map +1 -0
- package/dist/index.d.ts +71 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/papirus.js +8419 -0
- package/dist/papirus.js.map +1 -0
- package/dist/styles/StyleManager.d.ts +119 -0
- package/dist/styles/StyleManager.d.ts.map +1 -0
- package/dist/types.d.ts +329 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/AlignDistribute.d.ts +12 -0
- package/dist/utils/AlignDistribute.d.ts.map +1 -0
- package/dist/utils/AutoLayout.d.ts +15 -0
- package/dist/utils/AutoLayout.d.ts.map +1 -0
- package/dist/utils/AutoRouting.d.ts +11 -0
- package/dist/utils/AutoRouting.d.ts.map +1 -0
- package/dist/utils/ImageExporter.d.ts +34 -0
- package/dist/utils/ImageExporter.d.ts.map +1 -0
- package/dist/utils/Serializer.d.ts +63 -0
- package/dist/utils/Serializer.d.ts.map +1 -0
- package/dist/utils/SvgExporter.d.ts +26 -0
- package/dist/utils/SvgExporter.d.ts.map +1 -0
- package/dist/utils/applyStyleManager.d.ts +6 -0
- package/dist/utils/applyStyleManager.d.ts.map +1 -0
- package/dist/utils/contentBounds.d.ts +13 -0
- package/dist/utils/contentBounds.d.ts.map +1 -0
- package/dist/utils/download.d.ts +2 -0
- package/dist/utils/download.d.ts.map +1 -0
- package/dist/utils/geometry.d.ts +71 -0
- package/dist/utils/geometry.d.ts.map +1 -0
- package/dist/utils/style.d.ts +2 -0
- package/dist/utils/style.d.ts.map +1 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Papirus 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
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# Papirus
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/papirus)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
TypeScript library for building interactive 2D diagrams and flowcharts on HTML Canvas. Supports nodes, edges, groups, styling, serialization, export, and interactivity.
|
|
7
|
+
|
|
8
|
+
[Русская версия](./README.ru.md)
|
|
9
|
+
|
|
10
|
+
## About
|
|
11
|
+
|
|
12
|
+
Papirus is a diagram rendering and interaction engine designed to be embedded in any UI (SPA, static pages, design systems). The library provides:
|
|
13
|
+
|
|
14
|
+
- `DiagramRenderer` with coordinate system, zoom, and panning
|
|
15
|
+
- Set of elements (nodes/edges/groups) and base types
|
|
16
|
+
- Interaction managers (selection, drag, connection, history)
|
|
17
|
+
- Context menu and search/filtering
|
|
18
|
+
- Basic animations and animated edge flow
|
|
19
|
+
- Theming and styling via `StyleManager`
|
|
20
|
+
- Overlays (grid, minimap, rulers, guides) and export utilities
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install papirus
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Quick Start
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { DiagramRenderer, RectangleNode, Edge } from 'papirus';
|
|
32
|
+
|
|
33
|
+
const renderer = new DiagramRenderer('#canvas', {
|
|
34
|
+
width: 900,
|
|
35
|
+
height: 600,
|
|
36
|
+
backgroundColor: '#fafafa',
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const nodeA = new RectangleNode({ x: 100, y: 100, width: 140, height: 60, label: 'Start' });
|
|
40
|
+
const nodeB = new RectangleNode({ x: 360, y: 100, width: 140, height: 60, label: 'Process' });
|
|
41
|
+
|
|
42
|
+
renderer.addNode(nodeA);
|
|
43
|
+
renderer.addNode(nodeB);
|
|
44
|
+
renderer.addEdge(new Edge({
|
|
45
|
+
from: { nodeId: nodeA.id },
|
|
46
|
+
to: { nodeId: nodeB.id },
|
|
47
|
+
type: 'bezier',
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
renderer.enableInteractions();
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Documentation
|
|
54
|
+
|
|
55
|
+
- [API Overview](./docs/api.md)
|
|
56
|
+
- [Elements](./docs/elements.md)
|
|
57
|
+
- [Interactions](./docs/interactions.md)
|
|
58
|
+
- [Overlays](./docs/overlays.md)
|
|
59
|
+
- [Utils](./docs/utils.md)
|
|
60
|
+
|
|
61
|
+
## Features
|
|
62
|
+
|
|
63
|
+
### Interactivity
|
|
64
|
+
|
|
65
|
+
Built-in `InteractionManager` includes:
|
|
66
|
+
- drag/select/connect/undo/redo/copy/paste
|
|
67
|
+
- Pan on empty canvas area
|
|
68
|
+
- Zoom with mouse wheel, pinch-to-zoom, two-finger pan
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
const interactions = renderer.enableInteractions({ gridSize: 20, snapToGrid: true });
|
|
72
|
+
interactions.navigation.fitToView();
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Default edge creation: `Shift + drag` from node to node (to avoid interfering with regular drag).
|
|
76
|
+
|
|
77
|
+
### Elements & Groups
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
const group = new Group({ label: 'Main Flow', padding: 16 });
|
|
81
|
+
group.addChild(nodeA);
|
|
82
|
+
group.addChild(nodeB);
|
|
83
|
+
renderer.addGroup(group);
|
|
84
|
+
|
|
85
|
+
const node = new RectangleNode({
|
|
86
|
+
x: 20, y: 20, width: 120, height: 60,
|
|
87
|
+
ports: [{ type: 'input', position: 'left' }],
|
|
88
|
+
icon: { source: '/icons/start.svg', fit: 'contain', scaleWithBounds: true },
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Styling
|
|
93
|
+
|
|
94
|
+
`StyleManager` applies themes and classes to nodes/edges/text/ports/groups.
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
const styles = new StyleManager('dark');
|
|
98
|
+
styles.registerClass({
|
|
99
|
+
name: 'error',
|
|
100
|
+
node: { fillColor: '#fee2e2', strokeColor: '#dc2626' },
|
|
101
|
+
text: { color: '#991b1b' },
|
|
102
|
+
});
|
|
103
|
+
renderer.setStyleManager(styles);
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Built-in themes: `DEFAULT_THEME`, `DARK_THEME`.
|
|
107
|
+
|
|
108
|
+
### Serialization
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
import { Serializer } from 'papirus';
|
|
112
|
+
|
|
113
|
+
const serializer = new Serializer(renderer, {
|
|
114
|
+
nodeFactory: (data) => new RectangleNode(data),
|
|
115
|
+
edgeFactory: (data) => new Edge(data),
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const json = serializer.toJSON(true);
|
|
119
|
+
serializer.fromJSON(json);
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Export
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
import { ImageExporter, SvgExporter } from 'papirus';
|
|
126
|
+
|
|
127
|
+
const imageExporter = new ImageExporter(renderer);
|
|
128
|
+
await imageExporter.download('diagram.png', { scale: 2 });
|
|
129
|
+
|
|
130
|
+
const svgExporter = new SvgExporter(renderer);
|
|
131
|
+
await svgExporter.download('diagram.svg');
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Overlays
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
import { GridOverlay, MiniMap } from 'papirus';
|
|
138
|
+
|
|
139
|
+
renderer.use(new GridOverlay({ gridSize: 20 }));
|
|
140
|
+
renderer.use(new MiniMap({ width: 180, height: 120, padding: 12 }));
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Also available: `RulersOverlay`, `GuidesOverlay`, `AutoLayout`, `AutoRouting`, `alignNodes`, `distributeNodes`.
|
|
144
|
+
|
|
145
|
+
## Framework Integrations
|
|
146
|
+
|
|
147
|
+
- [Vue 3](./packages/vue)
|
|
148
|
+
|
|
149
|
+
## Example
|
|
150
|
+
|
|
151
|
+
See [`examples/index.html`](./examples/index.html) for a complete interactive demo.
|
|
152
|
+
|
|
153
|
+
## Development
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
npm install
|
|
157
|
+
npm run dev
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Useful commands:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
npm run typecheck # TypeScript type checking
|
|
164
|
+
npm run lint # ESLint
|
|
165
|
+
npm run format # Prettier formatting
|
|
166
|
+
npm run build # Build library
|
|
167
|
+
npm run test # Run tests
|
|
168
|
+
npm run test:coverage # Tests with coverage
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Contributing
|
|
172
|
+
|
|
173
|
+
Please read [CONTRIBUTING.md](./CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.
|
|
174
|
+
|
|
175
|
+
## License
|
|
176
|
+
|
|
177
|
+
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
|
package/README.ru.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# Papirus
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/papirus)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
Papirus — библиотека на TypeScript для построения интерактивных 2D‑схем на HTML Canvas. Поддерживает узлы, связи, группы, стили, сериализацию, экспорт и интерактивность.
|
|
7
|
+
|
|
8
|
+
[English version](./README.md)
|
|
9
|
+
|
|
10
|
+
## О проекте
|
|
11
|
+
|
|
12
|
+
Papirus — это движок рендера и взаимодействия с диаграммами, рассчитанный на встраивание в любой UI (SPA, статические страницы, дизайн‑системы). Библиотека поставляет:
|
|
13
|
+
|
|
14
|
+
- Рендерер (`DiagramRenderer`) с системой координат, масштабированием и панорамированием.
|
|
15
|
+
- Набор элементов (узлы/рёбра/группы) и базовые типы.
|
|
16
|
+
- Менеджеры взаимодействий (выделение, перемещение, соединение, история).
|
|
17
|
+
- Контекстное меню и поиск/фильтрация.
|
|
18
|
+
- Базовые анимации и анимированный поток рёбер.
|
|
19
|
+
- Темизацию и стили через `StyleManager`.
|
|
20
|
+
- Оверлеи (сетка, миникарта, линейки, направляющие) и утилиты экспорта.
|
|
21
|
+
|
|
22
|
+
## Установка
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install papirus
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Быстрый старт
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { DiagramRenderer, RectangleNode, Edge } from 'papirus';
|
|
32
|
+
|
|
33
|
+
const renderer = new DiagramRenderer('#canvas', {
|
|
34
|
+
width: 900,
|
|
35
|
+
height: 600,
|
|
36
|
+
backgroundColor: '#fafafa',
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const nodeA = new RectangleNode({ x: 100, y: 100, width: 140, height: 60, label: 'Start' });
|
|
40
|
+
const nodeB = new RectangleNode({ x: 360, y: 100, width: 140, height: 60, label: 'Process' });
|
|
41
|
+
|
|
42
|
+
renderer.addNode(nodeA);
|
|
43
|
+
renderer.addNode(nodeB);
|
|
44
|
+
renderer.addEdge(new Edge({
|
|
45
|
+
from: { nodeId: nodeA.id },
|
|
46
|
+
to: { nodeId: nodeB.id },
|
|
47
|
+
type: 'bezier',
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
renderer.enableInteractions();
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Документация
|
|
54
|
+
|
|
55
|
+
- [Обзор API](./docs/api.md)
|
|
56
|
+
- [Элементы](./docs/elements.md)
|
|
57
|
+
- [Интерактивность](./docs/interactions.md)
|
|
58
|
+
- [Оверлеи](./docs/overlays.md)
|
|
59
|
+
- [Утилиты](./docs/utils.md)
|
|
60
|
+
|
|
61
|
+
## Возможности
|
|
62
|
+
|
|
63
|
+
### Интерактивность
|
|
64
|
+
|
|
65
|
+
Встроенный `InteractionManager` включает:
|
|
66
|
+
|
|
67
|
+
- drag/select/connect/undo/redo/copy/paste
|
|
68
|
+
- Панорамирование по пустому месту канваса
|
|
69
|
+
- Zoom колесом, pinch‑to‑zoom, two‑finger pan
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
const interactions = renderer.enableInteractions({ gridSize: 20, snapToGrid: true });
|
|
73
|
+
interactions.navigation.fitToView();
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Создание связи по умолчанию: `Shift + drag` от узла к узлу.
|
|
77
|
+
|
|
78
|
+
### Элементы и группы
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
const group = new Group({ label: 'Main Flow', padding: 16 });
|
|
82
|
+
group.addChild(nodeA);
|
|
83
|
+
group.addChild(nodeB);
|
|
84
|
+
renderer.addGroup(group);
|
|
85
|
+
|
|
86
|
+
const node = new RectangleNode({
|
|
87
|
+
x: 20, y: 20, width: 120, height: 60,
|
|
88
|
+
ports: [{ type: 'input', position: 'left' }],
|
|
89
|
+
icon: { source: '/icons/start.svg', fit: 'contain', scaleWithBounds: true },
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Стили
|
|
94
|
+
|
|
95
|
+
`StyleManager` применяет темы и классы к узлам/рёбрам/тексту/портам/группам.
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
const styles = new StyleManager('dark');
|
|
99
|
+
styles.registerClass({
|
|
100
|
+
name: 'error',
|
|
101
|
+
node: { fillColor: '#fee2e2', strokeColor: '#dc2626' },
|
|
102
|
+
text: { color: '#991b1b' },
|
|
103
|
+
});
|
|
104
|
+
renderer.setStyleManager(styles);
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Доступны готовые темы: `DEFAULT_THEME`, `DARK_THEME`.
|
|
108
|
+
|
|
109
|
+
### Сериализация
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
import { Serializer } from 'papirus';
|
|
113
|
+
|
|
114
|
+
const serializer = new Serializer(renderer, {
|
|
115
|
+
nodeFactory: (data) => new RectangleNode(data),
|
|
116
|
+
edgeFactory: (data) => new Edge(data),
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
const json = serializer.toJSON(true);
|
|
120
|
+
serializer.fromJSON(json);
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Экспорт
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
import { ImageExporter, SvgExporter } from 'papirus';
|
|
127
|
+
|
|
128
|
+
const imageExporter = new ImageExporter(renderer);
|
|
129
|
+
await imageExporter.download('diagram.png', { scale: 2 });
|
|
130
|
+
|
|
131
|
+
const svgExporter = new SvgExporter(renderer);
|
|
132
|
+
await svgExporter.download('diagram.svg');
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Оверлеи
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
import { GridOverlay, MiniMap } from 'papirus';
|
|
139
|
+
|
|
140
|
+
renderer.use(new GridOverlay({ gridSize: 20 }));
|
|
141
|
+
renderer.use(new MiniMap({ width: 180, height: 120, padding: 12 }));
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Доступны также `RulersOverlay`, `GuidesOverlay`, `AutoLayout`, `AutoRouting`, `alignNodes`, `distributeNodes`.
|
|
145
|
+
|
|
146
|
+
## Интеграции
|
|
147
|
+
|
|
148
|
+
- [Vue 3](./packages/vue)
|
|
149
|
+
|
|
150
|
+
## Пример
|
|
151
|
+
|
|
152
|
+
См. [`examples/index.html`](./examples/index.html).
|
|
153
|
+
|
|
154
|
+
## Разработка
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
npm install
|
|
158
|
+
npm run dev
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Полезные команды:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
npm run typecheck # Проверка типов TypeScript
|
|
165
|
+
npm run lint # ESLint
|
|
166
|
+
npm run format # Форматирование Prettier
|
|
167
|
+
npm run build # Сборка библиотеки
|
|
168
|
+
npm run test # Запуск тестов
|
|
169
|
+
npm run test:coverage # Тесты с покрытием
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Contributing
|
|
173
|
+
|
|
174
|
+
См. [CONTRIBUTING.md](./CONTRIBUTING.md).
|
|
175
|
+
|
|
176
|
+
## Лицензия
|
|
177
|
+
|
|
178
|
+
MIT — см. [LICENSE](./LICENSE).
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized constants for the diagram library
|
|
3
|
+
*/
|
|
4
|
+
export declare const EDGE_HANDLE_RADIUS = 6;
|
|
5
|
+
export declare const ARROW_SIZE = 10;
|
|
6
|
+
export declare const ARROW_ANGLE: number;
|
|
7
|
+
export declare const MARKER_SIZES: Record<string, number>;
|
|
8
|
+
export declare const EDGE_LABEL_BACKGROUND_PADDING = 4;
|
|
9
|
+
export declare const EDGE_LABEL_BACKGROUND_RADIUS = 2;
|
|
10
|
+
export declare const RESIZE_HANDLE_SIZE = 8;
|
|
11
|
+
export declare const RESIZE_HANDLE_OFFSET = 6;
|
|
12
|
+
export declare const ANCHOR_POINT_RADIUS = 4;
|
|
13
|
+
export declare const ANCHOR_POINT_HOVER_RADIUS = 6;
|
|
14
|
+
export declare const ANCHOR_POINT_HITBOX_RADIUS = 10;
|
|
15
|
+
export declare const NODE_HITBOX_PADDING = 10;
|
|
16
|
+
export declare const ANCHOR_PORT_PREFIX = "anchor:";
|
|
17
|
+
export declare const BEZIER_MAX_OFFSET = 100;
|
|
18
|
+
export declare const SELECTION_RECT_MIN_SIZE = 1;
|
|
19
|
+
export declare const DEFAULT_SELECTION_COLOR = "#3b82f6";
|
|
20
|
+
export declare const DEFAULT_HOVER_COLOR = "#6366f1";
|
|
21
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,eAAO,MAAM,kBAAkB,IAAI,CAAC;AACpC,eAAO,MAAM,UAAU,KAAK,CAAC;AAC7B,eAAO,MAAM,WAAW,QAAc,CAAC;AAGvC,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAK/C,CAAC;AAGF,eAAO,MAAM,6BAA6B,IAAI,CAAC;AAC/C,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAG9C,eAAO,MAAM,kBAAkB,IAAI,CAAC;AACpC,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAGtC,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAC3C,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAC7C,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAGtC,eAAO,MAAM,kBAAkB,YAAY,CAAC;AAG5C,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAGrC,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,eAAO,MAAM,uBAAuB,YAAY,CAAC;AACjD,eAAO,MAAM,mBAAmB,YAAY,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AnimationOptions } from '../types';
|
|
2
|
+
export interface AnimationState {
|
|
3
|
+
opacity: number;
|
|
4
|
+
scale: number;
|
|
5
|
+
highlight: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class AnimationManager {
|
|
8
|
+
private options;
|
|
9
|
+
private enter;
|
|
10
|
+
private exit;
|
|
11
|
+
private highlight;
|
|
12
|
+
constructor(options?: AnimationOptions);
|
|
13
|
+
configure(options: AnimationOptions): void;
|
|
14
|
+
get enabled(): boolean;
|
|
15
|
+
registerEnter(id: string, now?: number): void;
|
|
16
|
+
registerExit(id: string, onComplete?: () => void, now?: number): void;
|
|
17
|
+
registerHighlight(id: string, now?: number): void;
|
|
18
|
+
isExiting(id: string): boolean;
|
|
19
|
+
hasActive(): boolean;
|
|
20
|
+
update(now?: number): boolean;
|
|
21
|
+
getState(id: string, now?: number): AnimationState;
|
|
22
|
+
private lerp;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=AnimationManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnimationManager.d.ts","sourceRoot":"","sources":["../../src/core/AnimationManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB;AAgBD,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,KAAK,CAA6B;IAC1C,OAAO,CAAC,IAAI,CAAgC;IAC5C,OAAO,CAAC,SAAS,CAA6B;gBAElC,OAAO,GAAE,gBAAqB;IAI1C,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAI1C,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,SAAoB,GAAG,IAAI;IAOxD,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,IAAI,EAAE,GAAG,SAAoB,GAAG,IAAI;IAWhF,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,SAAoB,GAAG,IAAI;IAO5D,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAI9B,SAAS,IAAI,OAAO;IAIpB,MAAM,CAAC,GAAG,SAAoB,GAAG,OAAO;IAgCxC,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,SAAoB,GAAG,cAAc;IA8B7D,OAAO,CAAC,IAAI;CAGb"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { EventEmitter } from '../events/EventEmitter';
|
|
2
|
+
import { DiagramRenderer } from './DiagramRenderer';
|
|
3
|
+
import { InputEvent } from '../events/InputHandler';
|
|
4
|
+
import { Node } from '../elements/Node';
|
|
5
|
+
import { Edge } from '../elements/Edge';
|
|
6
|
+
import { EdgeEndpoint, Point } from '../types';
|
|
7
|
+
/**
|
|
8
|
+
* Connection events
|
|
9
|
+
*/
|
|
10
|
+
export interface ConnectionEvents {
|
|
11
|
+
connectionStart: [fromNode: Node];
|
|
12
|
+
connectionMove: [fromPoint: Point, toPoint: Point];
|
|
13
|
+
connectionEnd: [edge: Edge | null];
|
|
14
|
+
connect: [edge: Edge];
|
|
15
|
+
edgeReconnectStart: [edge: Edge, endpoint: 'start' | 'end', original: EdgeEndpoint];
|
|
16
|
+
edgeReconnect: [edge: Edge, endpoint: 'start' | 'end'];
|
|
17
|
+
}
|
|
18
|
+
export type ConnectionValidator = (sourceNodeId: string, targetNodeId: string) => boolean;
|
|
19
|
+
export interface ConnectionManagerOptions {
|
|
20
|
+
renderer: DiagramRenderer;
|
|
21
|
+
createEdge: (from: EdgeEndpoint, to: EdgeEndpoint) => Edge;
|
|
22
|
+
addEdge?: (edge: Edge) => void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Manages port-to-port connection creation
|
|
26
|
+
*/
|
|
27
|
+
export declare class ConnectionManager extends EventEmitter<ConnectionEvents> {
|
|
28
|
+
private renderer;
|
|
29
|
+
private readonly createEdge;
|
|
30
|
+
private readonly addEdge;
|
|
31
|
+
private _connectionValidator;
|
|
32
|
+
private isConnecting;
|
|
33
|
+
private sourceNode;
|
|
34
|
+
private sourcePoint;
|
|
35
|
+
private previewEndpoint;
|
|
36
|
+
private sourceAnchorId;
|
|
37
|
+
private hoverNodeId;
|
|
38
|
+
private hoverAnchorId;
|
|
39
|
+
private hoverDisabled;
|
|
40
|
+
private reconnectPoint;
|
|
41
|
+
private previewTargetAnchorId;
|
|
42
|
+
private isReconnecting;
|
|
43
|
+
private reconnectingEdge;
|
|
44
|
+
private reconnectingEndpoint;
|
|
45
|
+
private originalEdgeEndpoint;
|
|
46
|
+
constructor(options: ConnectionManagerOptions);
|
|
47
|
+
/**
|
|
48
|
+
* Set a validator that determines whether a connection between two nodes is allowed.
|
|
49
|
+
* When set, disallowed targets show forbidden styling and connections are blocked.
|
|
50
|
+
*/
|
|
51
|
+
set connectionValidator(validator: ConnectionValidator | null);
|
|
52
|
+
/**
|
|
53
|
+
* Check if currently creating a connection
|
|
54
|
+
*/
|
|
55
|
+
get connecting(): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Check if currently reconnecting an edge
|
|
58
|
+
*/
|
|
59
|
+
get reconnecting(): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Get the edge being reconnected (to hide it during preview)
|
|
62
|
+
*/
|
|
63
|
+
get reconnectingEdgeId(): string | null;
|
|
64
|
+
/**
|
|
65
|
+
* Current preview endpoint
|
|
66
|
+
*/
|
|
67
|
+
get previewEnd(): Point | null;
|
|
68
|
+
/**
|
|
69
|
+
* Disable hover and clear state (used when dragging starts)
|
|
70
|
+
*/
|
|
71
|
+
disableHover(): void;
|
|
72
|
+
/**
|
|
73
|
+
* Re-enable hover (used when dragging ends)
|
|
74
|
+
*/
|
|
75
|
+
enableHover(): void;
|
|
76
|
+
/**
|
|
77
|
+
* Handle mouse down on a node
|
|
78
|
+
*/
|
|
79
|
+
handleNodeMouseDown(event: InputEvent, node: Node): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Check if mouse is over a port and start connection
|
|
82
|
+
*/
|
|
83
|
+
tryStartConnection(event: InputEvent): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Try to start connection from a hovered anchor point
|
|
86
|
+
*/
|
|
87
|
+
tryStartConnectionAtPoint(event: InputEvent): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Try to start edge reconnection from handle
|
|
90
|
+
*/
|
|
91
|
+
tryStartReconnection(event: InputEvent): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Update the reconnecting edge to follow cursor
|
|
94
|
+
*/
|
|
95
|
+
private updateReconnectingEdge;
|
|
96
|
+
/**
|
|
97
|
+
* Handle mouse move during connection
|
|
98
|
+
*/
|
|
99
|
+
handleMouseMove(event: InputEvent): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Get the node ID at the other end of the reconnecting edge
|
|
102
|
+
*/
|
|
103
|
+
private getOtherNodeId;
|
|
104
|
+
/**
|
|
105
|
+
* Handle mouse up to complete or cancel connection
|
|
106
|
+
*/
|
|
107
|
+
handleMouseUp(event: InputEvent): boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Cancel current connection
|
|
110
|
+
*/
|
|
111
|
+
cancelConnection(): void;
|
|
112
|
+
/**
|
|
113
|
+
* Render connection preview
|
|
114
|
+
*/
|
|
115
|
+
renderPreview(ctx: CanvasRenderingContext2D): void;
|
|
116
|
+
/**
|
|
117
|
+
* Get control point offset based on direction
|
|
118
|
+
*/
|
|
119
|
+
private getDirectionOffset;
|
|
120
|
+
/**
|
|
121
|
+
* Draw a Bézier curve preview between two points
|
|
122
|
+
*/
|
|
123
|
+
private drawBezierPreview;
|
|
124
|
+
private isCompatibleTarget;
|
|
125
|
+
private setCursor;
|
|
126
|
+
private reset;
|
|
127
|
+
private resetReconnection;
|
|
128
|
+
/**
|
|
129
|
+
* Render anchors when hovering a node (not connecting)
|
|
130
|
+
*/
|
|
131
|
+
renderHoverAnchors(ctx: CanvasRenderingContext2D): void;
|
|
132
|
+
private drawPlus;
|
|
133
|
+
private renderAnchorHighlights;
|
|
134
|
+
private drawCross;
|
|
135
|
+
private getNodeAtPoint;
|
|
136
|
+
private updateHover;
|
|
137
|
+
private getAnchorAtPoint;
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=ConnectionManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConnectionManager.d.ts","sourceRoot":"","sources":["../../src/core/ConnectionManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAY,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGnD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,eAAe,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAClC,cAAc,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IACnD,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC,CAAC;IACnC,OAAO,EAAE,CAAC,I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AwB,GAAG,IAAI;IAwCvD,OAAO,CAAC,QAAQ;IAahB,OAAO,CAAC,sBAAsB;IA4C9B,OAAO,CAAC,SAAS;IAYjB,OAAO,CAAC,cAAc;IAwBtB,OAAO,CAAC,WAAW;IAuBnB,OAAO,CAAC,gBAAgB;CAuBzB"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { EventEmitter } from '../events/EventEmitter';
|
|
2
|
+
import { DiagramRenderer } from './DiagramRenderer';
|
|
3
|
+
import { Point } from '../types';
|
|
4
|
+
import { Node } from '../elements/Node';
|
|
5
|
+
import { Edge } from '../elements/Edge';
|
|
6
|
+
export type ContextMenuIcon = string | {
|
|
7
|
+
type: 'text' | 'svg' | 'html';
|
|
8
|
+
value: string;
|
|
9
|
+
};
|
|
10
|
+
export interface ContextMenuItem {
|
|
11
|
+
label?: string;
|
|
12
|
+
icon?: ContextMenuIcon;
|
|
13
|
+
action?: (target: ContextMenuTarget) => void;
|
|
14
|
+
items?: ContextMenuItem[];
|
|
15
|
+
enabled?: boolean;
|
|
16
|
+
visible?: boolean;
|
|
17
|
+
separator?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export type ContextMenuTarget = {
|
|
20
|
+
type: 'node';
|
|
21
|
+
node: Node;
|
|
22
|
+
point: Point;
|
|
23
|
+
screenPoint: Point;
|
|
24
|
+
originalEvent: MouseEvent;
|
|
25
|
+
} | {
|
|
26
|
+
type: 'edge';
|
|
27
|
+
edge: Edge;
|
|
28
|
+
point: Point;
|
|
29
|
+
screenPoint: Point;
|
|
30
|
+
originalEvent: MouseEvent;
|
|
31
|
+
} | {
|
|
32
|
+
type: 'canvas';
|
|
33
|
+
point: Point;
|
|
34
|
+
screenPoint: Point;
|
|
35
|
+
originalEvent: MouseEvent;
|
|
36
|
+
};
|
|
37
|
+
export type ContextMenuProvider = ContextMenuItem[] | ((target: ContextMenuTarget) => ContextMenuItem[]);
|
|
38
|
+
export interface ContextMenuConfig {
|
|
39
|
+
node?: ContextMenuProvider;
|
|
40
|
+
edge?: ContextMenuProvider;
|
|
41
|
+
canvas?: ContextMenuProvider;
|
|
42
|
+
}
|
|
43
|
+
export interface ContextMenuOptions {
|
|
44
|
+
menu: ContextMenuConfig;
|
|
45
|
+
container?: HTMLElement;
|
|
46
|
+
className?: string;
|
|
47
|
+
minWidth?: number;
|
|
48
|
+
closeOnSelect?: boolean;
|
|
49
|
+
}
|
|
50
|
+
export interface ContextMenuEvents {
|
|
51
|
+
open: [target: ContextMenuTarget];
|
|
52
|
+
close: [];
|
|
53
|
+
}
|
|
54
|
+
export declare class ContextMenuManager extends EventEmitter<ContextMenuEvents> {
|
|
55
|
+
private renderer;
|
|
56
|
+
private options;
|
|
57
|
+
private menuElement;
|
|
58
|
+
private cleanupHandlers;
|
|
59
|
+
constructor(renderer: DiagramRenderer, options: ContextMenuOptions);
|
|
60
|
+
setMenu(menu: ContextMenuConfig): void;
|
|
61
|
+
destroy(): void;
|
|
62
|
+
private attachListeners;
|
|
63
|
+
private resolveItems;
|
|
64
|
+
private open;
|
|
65
|
+
private close;
|
|
66
|
+
private buildMenu;
|
|
67
|
+
private buildList;
|
|
68
|
+
private createIconElement;
|
|
69
|
+
private isSvgString;
|
|
70
|
+
private adjustPosition;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=ContextMenuManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextMenuManager.d.ts","sourceRoot":"","sources":["../../src/core/ContextMenuManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,MAA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