Skip to content

Commit d1c1fb8

Browse files
committed
feat: remove annotations-related concepts; introduce "Special Node Types" for enhanced clarity and consistency in documentation and API structuring
1 parent 20f59a9 commit d1c1fb8

File tree

7 files changed

+42
-96
lines changed

7 files changed

+42
-96
lines changed

website/.vitepress/config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export default defineConfig({
121121
{ text: 'NodeWidget', link: '/docs/components/node-widget' },
122122
{ text: 'PortWidget', link: '/docs/components/port-widget' },
123123
{ text: 'ConnectionsLayer', link: '/docs/components/connections-layer' },
124-
{ text: 'Annotations', link: '/docs/components/annotations' },
124+
{ text: 'Special Node Types', link: '/docs/components/special-node-types' },
125125
{ text: 'Minimap', link: '/docs/components/minimap' },
126126
],
127127
},
@@ -144,7 +144,8 @@ export default defineConfig({
144144
{
145145
text: 'Advanced',
146146
items: [
147-
{ text: 'Annotations', link: '/docs/advanced/annotations' },
147+
{ text: 'Special Node Types', link: '/docs/advanced/special-node-types' },
148+
{ text: 'Level of Detail (LOD)', link: '/docs/advanced/lod' },
148149
{ text: 'Events', link: '/docs/advanced/events' },
149150
{ text: 'Serialization', link: '/docs/advanced/serialization' },
150151
{ text: 'Keyboard Shortcuts', link: '/docs/advanced/keyboard-shortcuts' },

website/docs/advanced/events.md

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ description: Handle user interactions with nodes, connections, and the canvas
66
# Event System
77

88
::: details 🖼️ Event System Overview
9-
Diagram showing event flow architecture: NodeFlowEvents container with five event groups (NodeEvents, PortEvents, ConnectionEvents, ViewportEvents, AnnotationEvents) plus top-level callbacks (onSelectionChange, onInit, onError). Arrows showing event propagation from user interactions.
9+
Diagram showing event flow architecture: NodeFlowEvents container with four event groups (NodeEvents, PortEvents, ConnectionEvents, ViewportEvents) plus top-level callbacks (onSelectionChange, onInit, onError). Arrows showing event propagation from user interactions.
1010
:::
1111

12-
The event system provides comprehensive callbacks for all user interactions. Events are organized into logical groups for nodes, ports, connections, viewport, and annotations.
12+
The event system provides comprehensive callbacks for all user interactions. Events are organized into logical groups for nodes (including GroupNode and CommentNode), ports, connections, and viewport.
1313

1414
## Event Structure
1515

@@ -19,11 +19,10 @@ Events are passed via the `events` parameter on `NodeFlowEditor`:
1919
NodeFlowEditor<MyData>(
2020
controller: controller,
2121
events: NodeFlowEvents(
22-
node: NodeEvents(...),
22+
node: NodeEvents(...), // Includes GroupNode & CommentNode
2323
port: PortEvents(...),
2424
connection: ConnectionEvents(...),
2525
viewport: ViewportEvents(...),
26-
annotation: AnnotationEvents(...),
2726
onSelectionChange: (state) => ...,
2827
onInit: () => ...,
2928
onError: (error) => ...,
@@ -267,23 +266,6 @@ Canvas positions are in **graph coordinates**, not screen coordinates. They acco
267266

268267
:::
269268

270-
## Annotation Events
271-
272-
Handle interactions with sticky notes, groups, and markers.
273-
274-
```dart
275-
AnnotationEvents(
276-
onCreated: (annotation) => print('Created: ${annotation.id}'),
277-
onDeleted: (annotation) => print('Deleted: ${annotation.id}'),
278-
onSelected: (annotation) => _showAnnotationTools(annotation),
279-
onTap: (annotation) => _selectAnnotation(annotation),
280-
onDoubleTap: (annotation) => _editAnnotation(annotation),
281-
onContextMenu: (annotation, position) => _showMenu(annotation, position),
282-
onMouseEnter: (annotation) => _highlight(annotation),
283-
onMouseLeave: (annotation) => _unhighlight(annotation),
284-
)
285-
```
286-
287269
## Selection State
288270

289271
Track the complete selection state across all element types:
@@ -293,7 +275,6 @@ NodeFlowEvents<MyData>(
293275
onSelectionChange: (state) {
294276
print('Selected nodes: ${state.nodes.length}');
295277
print('Selected connections: ${state.connections.length}');
296-
print('Selected annotations: ${state.annotations.length}');
297278
298279
// Update toolbar based on selection
299280
if (state.hasSelection) {
@@ -309,14 +290,21 @@ The `SelectionState` object provides:
309290

310291
```dart
311292
class SelectionState<T> {
293+
/// Currently selected nodes (includes GroupNode and CommentNode)
312294
final List<Node<T>> nodes;
295+
296+
/// Currently selected connections
313297
final List<Connection> connections;
314-
final List<Annotation> annotations;
315298
316-
bool get hasSelection; // True if anything is selected
299+
/// True if anything is selected
300+
bool get hasSelection;
317301
}
318302
```
319303

304+
::: info
305+
GroupNode and CommentNode are included in the `nodes` list since they extend Node.
306+
:::
307+
320308
## Top-Level Events
321309

322310
```dart
File renamed without changes.

website/docs/api-reference/events.md

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ NodeFlowEvents<T>({
1717
PortEvents<T>? port,
1818
ConnectionEvents<T>? connection,
1919
ViewportEvents? viewport,
20-
AnnotationEvents? annotation,
2120
ValueChanged<SelectionState<T>>? onSelectionChange,
2221
VoidCallback? onInit,
2322
ValueChanged<FlowError>? onError,
@@ -26,11 +25,10 @@ NodeFlowEvents<T>({
2625

2726
| Property | Type | Description |
2827
|----------|------|-------------|
29-
| `node` | `NodeEvents<T>?` | Node interaction events |
28+
| `node` | `NodeEvents<T>?` | Node interaction events (includes GroupNode & CommentNode) |
3029
| `port` | `PortEvents<T>?` | Port interaction events |
3130
| `connection` | `ConnectionEvents<T>?` | Connection lifecycle events |
3231
| `viewport` | `ViewportEvents?` | Canvas pan/zoom events |
33-
| `annotation` | `AnnotationEvents?` | Annotation events |
3432
| `onSelectionChange` | `ValueChanged<SelectionState<T>>?` | Selection state changes |
3533
| `onInit` | `VoidCallback?` | Editor initialization |
3634
| `onError` | `ValueChanged<FlowError>?` | Error handling |
@@ -295,48 +293,27 @@ ViewportEvents(
295293
)
296294
```
297295

298-
## AnnotationEvents
299-
300-
Events for annotation interactions (sticky notes, groups).
301-
302-
```dart
303-
AnnotationEvents({
304-
ValueChanged<Annotation>? onCreated,
305-
ValueChanged<Annotation>? onDeleted,
306-
ValueChanged<Annotation?>? onSelected,
307-
ValueChanged<Annotation>? onTap,
308-
ValueChanged<Annotation>? onDoubleTap,
309-
void Function(Annotation, Offset)? onContextMenu,
310-
ValueChanged<Annotation>? onMouseEnter,
311-
ValueChanged<Annotation>? onMouseLeave,
312-
})
313-
```
314-
315-
| Event | Trigger | Signature |
316-
|-------|---------|-----------|
317-
| `onCreated` | Annotation created | `ValueChanged<Annotation>` |
318-
| `onDeleted` | Annotation deleted | `ValueChanged<Annotation>` |
319-
| `onSelected` | Selection changes | `ValueChanged<Annotation?>` |
320-
| `onTap` | Single tap | `ValueChanged<Annotation>` |
321-
| `onDoubleTap` | Double tap | `ValueChanged<Annotation>` |
322-
| `onContextMenu` | Right-click | `(Annotation, Offset)` |
323-
| `onMouseEnter` | Mouse enters bounds | `ValueChanged<Annotation>` |
324-
| `onMouseLeave` | Mouse leaves bounds | `ValueChanged<Annotation>` |
325-
326296
## SelectionState
327297

328298
Provided to `onSelectionChange` when selection changes.
329299

330300
```dart
331301
class SelectionState<T> {
302+
/// Currently selected nodes (includes GroupNode and CommentNode)
332303
final List<Node<T>> nodes;
304+
305+
/// Currently selected connections
333306
final List<Connection> connections;
334-
final List<Annotation> annotations;
335307
308+
/// Whether anything is selected
336309
bool get hasSelection;
337310
}
338311
```
339312

313+
::: info
314+
GroupNode and CommentNode are included in the `nodes` list since they extend Node.
315+
:::
316+
340317
**Example:**
341318
```dart
342319
onSelectionChange: (state) {

website/docs/api-reference/theme.md

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ NodeFlowTheme({
1919
Duration connectionAnimationDuration = const Duration(seconds: 2),
2020
required PortTheme portTheme,
2121
required LabelTheme labelTheme,
22-
required AnnotationTheme annotationTheme,
2322
required GridTheme gridTheme,
2423
required SelectionTheme selectionTheme,
2524
required CursorTheme cursorTheme,
25+
required MinimapTheme minimapTheme,
26+
required ResizerTheme resizerTheme,
2627
Color backgroundColor = Colors.white,
27-
bool debugMode = false,
28+
DebugMode debugMode = DebugMode.none,
2829
DebugTheme debugTheme = DebugTheme.light,
2930
})
3031
```
@@ -44,12 +45,13 @@ Most theme properties are **required**. Use `NodeFlowTheme.light` or `NodeFlowTh
4445
| `connectionAnimationDuration` | `Duration` | No | Animation cycle duration |
4546
| `portTheme` | `PortTheme` | Yes | Port appearance |
4647
| `labelTheme` | `LabelTheme` | Yes | Connection label styling |
47-
| `annotationTheme` | `AnnotationTheme` | Yes | Annotation appearance |
4848
| `gridTheme` | `GridTheme` | Yes | Grid background |
4949
| `selectionTheme` | `SelectionTheme` | Yes | Selection rectangle styling |
5050
| `cursorTheme` | `CursorTheme` | Yes | Mouse cursor styles |
51+
| `minimapTheme` | `MinimapTheme` | Yes | Minimap appearance |
52+
| `resizerTheme` | `ResizerTheme` | Yes | Resize handle styling |
5153
| `backgroundColor` | `Color` | No | Canvas background |
52-
| `debugMode` | `bool` | No | Enable debug overlays |
54+
| `debugMode` | `DebugMode` | No | Debug overlay mode |
5355
| `debugTheme` | `DebugTheme` | No | Debug visualization styling |
5456

5557
::: code-group
@@ -371,24 +373,6 @@ SelectionTheme.light
371373
SelectionTheme.dark
372374
```
373375

374-
## AnnotationTheme
375-
376-
Style configuration for annotations (sticky notes, groups).
377-
378-
```dart
379-
AnnotationTheme({
380-
required Color selectionColor,
381-
required double selectionBorderWidth,
382-
// Additional properties for sticky notes, groups, markers
383-
})
384-
```
385-
386-
**Preset themes:**
387-
```dart
388-
AnnotationTheme.light
389-
AnnotationTheme.dark
390-
```
391-
392376
## CursorTheme
393377

394378
Mouse cursor styles for different interactions.

website/docs/components/annotations.md renamed to website/docs/components/special-node-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ For complete documentation including:
7777
- Complete examples
7878
- Serialization
7979

80-
See **[Special Node Types (Advanced)](/docs/advanced/annotations)**.
80+
See **[Special Node Types (Advanced)](/docs/advanced/special-node-types)**.
8181

8282
## See Also
8383

website/docs/core-concepts/architecture.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ The main widget that renders the interactive flow editor.
2828
The controller manages the graph state and provides APIs for manipulation:
2929

3030
```dart
31-
class NodeFlowController<T extends NodeData> {
31+
class NodeFlowController<T> {
3232
// Core graph data
33-
final Graph<T> graph;
34-
final Viewport viewport;
33+
final Map<String, Node<T>> nodes;
34+
final Map<String, Connection> connections;
35+
final GraphViewport viewport;
3536
3637
// APIs
3738
void addNode(Node<T> node);
@@ -41,12 +42,12 @@ class NodeFlowController<T extends NodeData> {
4142
4243
// Selection
4344
Set<String> get selectedNodeIds;
44-
void selectNode(String nodeId, {bool multiSelect = false});
45+
void selectNode(String nodeId, {bool toggle = false});
4546
4647
// Viewport management
4748
void panTo(Offset position);
4849
void zoomTo(double zoom);
49-
void fitToScreen();
50+
void fitToView();
5051
5152
// And many more...
5253
}
@@ -67,12 +68,11 @@ management is handled by the NodeFlowController:
6768

6869
```dart
6970
class NodeGraph<T> {
71+
/// All nodes including GroupNode and CommentNode
7072
final List<Node<T>> nodes;
7173
final List<Connection> connections;
72-
final List<Annotation> annotations;
7374
final GraphViewport viewport;
7475
final Map<String, dynamic> metadata;
75-
7676
}
7777
```
7878

@@ -118,24 +118,20 @@ class Port {
118118
final String id;
119119
final String name;
120120
final PortPosition position; // left, right, top, bottom
121-
final PortType type; // source, target, both
121+
final PortType type; // input or output
122122
final Offset offset;
123123
final bool multiConnections;
124124
final int? maxConnections;
125125
final PortShape shape;
126126
final double size;
127127
final String? tooltip;
128128
final bool isConnectable;
129-
130-
// Computed properties
131-
bool get isSource;
132-
bool get isTarget;
133129
}
134130
```
135131

136132
**Key Features:**
137133

138-
- Configurable as source (output), target (input), or bidirectional
134+
- Configurable as input or output port type
139135
- Custom shapes via `PortShape` (default: capsule half)
140136
- Multi-connection support with optional max limit
141137
- Tooltips and connectable state
@@ -233,10 +229,10 @@ The architecture provides several extension points:
233229

234230
### Core Customization
235231

236-
1. **Custom Node Data**: Extend `NodeData` for your domain
232+
1. **Custom Node Data**: Use any type for your node's `data` field
237233
2. **Node Builders**: Provide custom node widgets for building the content as
238234
well as the container
239-
3. **Annotations**: Add custom overlays and markers
235+
3. **Special Nodes**: Use `GroupNode` for visual grouping and `CommentNode` for annotations
240236
4. **Validators**: Add connection validation logic
241237

242238
### Theming

0 commit comments

Comments
 (0)