f1ow 0.1.1 → 0.1.2
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 +46 -39
- package/dist/components/Toolbar/Toolbar.d.ts +1 -0
- package/dist/f1ow.js +3771 -3774
- package/dist/f1ow.umd.cjs +10 -10
- package/dist/lib/FlowCanvasProps.d.ts +9 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,38 +18,41 @@
|
|
|
18
18
|
|
|
19
19
|
---
|
|
20
20
|
|
|
21
|
-
## Features
|
|
22
|
-
|
|
23
|
-
- **10 Drawing Tools** — Rectangle, Ellipse, Diamond, Line, Arrow, Free Draw, Text, Image, Eraser
|
|
24
|
-
- **
|
|
25
|
-
- **
|
|
26
|
-
- **
|
|
27
|
-
- **Pan & Zoom** — Hand tool, scroll-wheel, trackpad pinch, zoom-to-fit
|
|
28
|
-
- **
|
|
29
|
-
- **
|
|
30
|
-
- **
|
|
31
|
-
- **
|
|
32
|
-
- **
|
|
33
|
-
- **
|
|
34
|
-
- **
|
|
35
|
-
- **
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
## Installation
|
|
21
|
+
## ✨ Features
|
|
22
|
+
|
|
23
|
+
- **10 Drawing Tools** — Rectangle, Ellipse, Diamond, Line, Arrow, Free Draw, Text, Image, Eraser.
|
|
24
|
+
- **Smart Connectors** — Arrows and lines snap to shapes with auto-routing (sharp, curved, elbow).
|
|
25
|
+
- **11 Arrowhead Variants** — Triangle, circle, diamond, bar, crow's foot (ERD), and more.
|
|
26
|
+
- **Selection & Transform** — Click, drag, resize, rotate, multi-select, group/ungroup, lock/unlock.
|
|
27
|
+
- **Pan & Zoom** — Hand tool, scroll-wheel, trackpad pinch, zoom-to-fit, zoom-to-selection.
|
|
28
|
+
- **Rich Styling** — Stroke, fill, width, dash, opacity, roughness, fonts.
|
|
29
|
+
- **Customizable UI** — Floating toolbar (top/bottom/hidden), style panel, context menu.
|
|
30
|
+
- **Undo / Redo** — 100-step history snapshot system.
|
|
31
|
+
- **Export** — Export canvas to PNG, SVG, or JSON.
|
|
32
|
+
- **Real-Time Collaboration** — Optional CRDT via Yjs (experimental) with cursor presence.
|
|
33
|
+
- **Fully Themeable** — Dark mode, custom colors, all via props.
|
|
34
|
+
- **Zero CSS Dependencies** — No external stylesheets required. Inline styled.
|
|
35
|
+
- **TypeScript** — Full type safety with strict mode.
|
|
36
|
+
|
|
37
|
+
## 📦 Installation
|
|
39
38
|
|
|
40
39
|
```bash
|
|
41
40
|
npm install f1ow
|
|
41
|
+
# or
|
|
42
|
+
pnpm add f1ow
|
|
43
|
+
# or
|
|
44
|
+
yarn add f1ow
|
|
42
45
|
```
|
|
43
46
|
|
|
44
|
-
> **Peer dependencies:** `react`
|
|
47
|
+
> **Peer dependencies:** `react` (≥17), `react-dom` (≥17), `konva` (≥9), `react-konva` (≥18), `zustand` (≥5)
|
|
45
48
|
|
|
46
49
|
### Next.js / Non-Vite Bundlers
|
|
47
50
|
|
|
48
51
|
f1ow-canvas uses Web Workers for performance-intensive operations. When using Next.js, Webpack, or other non-Vite bundlers, workers auto-fallback to synchronous mode. For optimal performance on large canvases, see the [Next.js Integration Guide](docs/NEXTJS_INTEGRATION.md).
|
|
49
52
|
|
|
50
53
|
**TL;DR:**
|
|
51
|
-
- **No config needed** — auto-fallback works out of the box
|
|
52
|
-
- **For better performance** — copy worker files to `public/` and pass `workerConfig` prop
|
|
54
|
+
- **No config needed** — auto-fallback works out of the box.
|
|
55
|
+
- **For better performance** — copy worker files to `public/` and pass `workerConfig` prop.
|
|
53
56
|
|
|
54
57
|
```tsx
|
|
55
58
|
<FlowCanvas
|
|
@@ -62,7 +65,7 @@ f1ow-canvas uses Web Workers for performance-intensive operations. When using Ne
|
|
|
62
65
|
|
|
63
66
|
See the [integration guide](docs/NEXTJS_INTEGRATION.md) for detailed setup instructions.
|
|
64
67
|
|
|
65
|
-
## Quick Start
|
|
68
|
+
## 🚀 Quick Start
|
|
66
69
|
|
|
67
70
|
```tsx
|
|
68
71
|
import { FlowCanvas } from "f1ow";
|
|
@@ -70,15 +73,18 @@ import { FlowCanvas } from "f1ow";
|
|
|
70
73
|
function App() {
|
|
71
74
|
return (
|
|
72
75
|
<div style={{ width: "100vw", height: "100vh" }}>
|
|
73
|
-
<FlowCanvas
|
|
76
|
+
<FlowCanvas
|
|
77
|
+
onChange={(elements) => console.log('Canvas updated:', elements)}
|
|
78
|
+
toolbarPosition="bottom"
|
|
79
|
+
/>
|
|
74
80
|
</div>
|
|
75
81
|
);
|
|
76
82
|
}
|
|
77
83
|
```
|
|
78
84
|
|
|
79
|
-
That's it — you get a full-featured canvas editor with toolbar, style panel, keyboard shortcuts, and grid out of the box.
|
|
85
|
+
That's it — you get a full-featured canvas editor with a toolbar, style panel, keyboard shortcuts, and grid out of the box.
|
|
80
86
|
|
|
81
|
-
## Props
|
|
87
|
+
## ⚙️ Props
|
|
82
88
|
|
|
83
89
|
| Prop | Type | Default | Description |
|
|
84
90
|
| --- | --- | --- | --- |
|
|
@@ -91,8 +97,9 @@ That's it — you get a full-featured canvas editor with toolbar, style panel, k
|
|
|
91
97
|
| `onElementDoubleClick` | `(id, element) => boolean` | — | Return `true` to prevent default |
|
|
92
98
|
| `width` / `height` | `number \| string` | `'100%'` | Canvas dimensions |
|
|
93
99
|
| `tools` | `ToolType[]` | all | Visible tools in toolbar |
|
|
94
|
-
| `
|
|
95
|
-
| `
|
|
100
|
+
| `defaultTool` | `ToolType` | `'select'` | Default active tool on mount |
|
|
101
|
+
| `toolbarPosition` | `'top' \| 'bottom' \| 'hidden'` | `'bottom'` | Position of the main toolbar |
|
|
102
|
+
| `showToolbar` | `boolean` | `true` | Show toolbar (legacy, use `toolbarPosition`) |
|
|
96
103
|
| `showStylePanel` | `boolean` | `true` | Show style panel |
|
|
97
104
|
| `showStatusBar` | `boolean` | `true` | Show status bar |
|
|
98
105
|
| `showGrid` | `boolean` | `true` | Show grid |
|
|
@@ -105,7 +112,7 @@ That's it — you get a full-featured canvas editor with toolbar, style panel, k
|
|
|
105
112
|
| `collaboration` | `CollaborationConfig` | — | Enable real-time collaboration |
|
|
106
113
|
| `workerConfig` | `{ elbowWorkerUrl?: string, exportWorkerUrl?: string, disabled?: boolean }` | — | Worker URLs for Next.js ([docs](docs/NEXTJS_INTEGRATION.md)) |
|
|
107
114
|
|
|
108
|
-
## Ref API
|
|
115
|
+
## 🕹️ Ref API
|
|
109
116
|
|
|
110
117
|
Control the canvas programmatically via `ref`:
|
|
111
118
|
|
|
@@ -139,7 +146,7 @@ const ref = useRef<FlowCanvasRef>(null);
|
|
|
139
146
|
| `importJSON(json)` | — | Load from JSON |
|
|
140
147
|
| `getStage()` | `Konva.Stage` | Raw Konva stage access |
|
|
141
148
|
|
|
142
|
-
## Keyboard Shortcuts
|
|
149
|
+
## ⌨️ Keyboard Shortcuts
|
|
143
150
|
|
|
144
151
|
`⌘` = Cmd (Mac) / Ctrl (Windows/Linux)
|
|
145
152
|
|
|
@@ -152,7 +159,7 @@ const ref = useRef<FlowCanvasRef>(null);
|
|
|
152
159
|
| `D` Diamond | `E` Eraser | `Del` Delete | `⌘⇧L` Lock toggle |
|
|
153
160
|
| `L` Line | `G` Grid | `⌘+/-/0` Zoom | `⌘]/[` Layer order |
|
|
154
161
|
|
|
155
|
-
## Theming
|
|
162
|
+
## 🎨 Theming
|
|
156
163
|
|
|
157
164
|
```tsx
|
|
158
165
|
<FlowCanvas
|
|
@@ -172,7 +179,7 @@ const ref = useRef<FlowCanvasRef>(null);
|
|
|
172
179
|
|
|
173
180
|
All properties are optional — only override what you need.
|
|
174
181
|
|
|
175
|
-
## Context Menu
|
|
182
|
+
## 🖱️ Context Menu
|
|
176
183
|
|
|
177
184
|
Append custom items or fully replace the built-in menu:
|
|
178
185
|
|
|
@@ -190,7 +197,7 @@ Append custom items or fully replace the built-in menu:
|
|
|
190
197
|
/>
|
|
191
198
|
```
|
|
192
199
|
|
|
193
|
-
## Collaboration (Experimental)
|
|
200
|
+
## 🤝 Collaboration (Experimental)
|
|
194
201
|
|
|
195
202
|
```tsx
|
|
196
203
|
<FlowCanvas
|
|
@@ -204,19 +211,19 @@ Append custom items or fully replace the built-in menu:
|
|
|
204
211
|
|
|
205
212
|
Provides CRDT-based real-time sync with cursor presence overlay. Requires a [Yjs WebSocket server](https://github.com/yjs/y-websocket).
|
|
206
213
|
|
|
207
|
-
## Element Types
|
|
214
|
+
## 🧩 Element Types
|
|
208
215
|
|
|
209
216
|
`CanvasElement` is a discriminated union of 8 types:
|
|
210
217
|
|
|
211
|
-
**Shapes** — `rectangle`, `ellipse`, `diamond`
|
|
212
|
-
**Connectors** — `line`, `arrow` (with bindings, routing, arrowheads)
|
|
213
|
-
**Content** — `text`, `image`, `freedraw`
|
|
218
|
+
- **Shapes** — `rectangle`, `ellipse`, `diamond`
|
|
219
|
+
- **Connectors** — `line`, `arrow` (with bindings, routing, arrowheads)
|
|
220
|
+
- **Content** — `text`, `image`, `freedraw`
|
|
214
221
|
|
|
215
222
|
All elements share: `id`, `x`, `y`, `width`, `height`, `rotation`, `style`, `isLocked`, `isVisible`, `boundElements`, `groupIds`.
|
|
216
223
|
|
|
217
224
|
> Full type definitions are bundled in the package `.d.ts` files.
|
|
218
225
|
|
|
219
|
-
## Development
|
|
226
|
+
## 🛠️ Development
|
|
220
227
|
|
|
221
228
|
```bash
|
|
222
229
|
pnpm install # Install dependencies
|
|
@@ -225,10 +232,10 @@ pnpm build:lib # Build library → dist/
|
|
|
225
232
|
pnpm typecheck # Type check (strict)
|
|
226
233
|
```
|
|
227
234
|
|
|
228
|
-
## Browser Support
|
|
235
|
+
## 🌐 Browser Support
|
|
229
236
|
|
|
230
237
|
Chrome/Edge ≥ 80 · Firefox ≥ 78 · Safari ≥ 14
|
|
231
238
|
|
|
232
|
-
## License
|
|
239
|
+
## 📄 License
|
|
233
240
|
|
|
234
241
|
[MIT](LICENSE) © [Nuumz](https://github.com/nuumz)
|