@oh-just-another/editor 0.59.0 → 0.60.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/CHANGELOG.md CHANGED
@@ -1,5 +1,94 @@
1
1
  # @oh-just-another/editor
2
2
 
3
+ ## 0.60.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 179bad8: Add a built-in `minimap` prop to `<Diagram>`/`<Editor>`. When set, the minimap docks bottom-right above the zoom controls and is hidden in zen mode along with the rest of the chrome (it reads the editor from context). Previously hosts had to mount `<Minimap>` themselves, which sat outside the zen-gated chrome and overlapped the zoom pill. Off by default.
8
+ - 1c4941e: New `<DrawingPanel>` — a floating tool-options panel that appears while the brush or eraser is active. It edits `editor.brushSettings` (via the new `useBrushSettings` hook): line colour, enclosed-fill colour, opacity and width for the brush; only the width (which doubles as the eraser radius) for the eraser. `<Diagram>` mounts it automatically top-right, hidden in zen mode; opt out with the new `hideDrawingPanel` prop. This is a functional scaffold intended for restyling.
9
+ - 6d184ad: Add `defineShape()` — one-call facade for registering a custom shape type (bounder, renderer, optional interactive hit-tester and rotate anchor). Re-export `registerInteractiveHitTester` / `registerRotateAnchor` and plugin types (`ElementBase`, `ElementBounder`, `ElementRenderer`, `RenderTarget`, `InteractiveHitTester`, `AnchorRef`).
10
+ - 2fbc079: Add editor file operations as registry actions + hotkeys: Save as JSON (`⌘S`), Open… (`⌘O`), Export PNG (`⌘⇧E`) and Copy as image to the system clipboard (`⇧⌥C`, PNG blob via the async Clipboard API). Exposed via `registerFileActions()` / `fileActions` and the `downloadScene` / `openSceneFile` / `downloadPng` / `downloadSvg` / `copySceneAsImage` helpers (`setFileActionNotifier` routes errors to a host toast). `<Editor>` registers them on mount and adds a "Copy as image" File-menu item with shortcut hints. All built on the existing serialization + exporter pipelines.
11
+ - bdc847e: Add four editor tools:
12
+ - **Eyedropper** — new `eyedropper` mode (toolbar button, `Alt+I`). Click a
13
+ shape to sample its fill/stroke and apply it to the selection.
14
+ `Editor.pickColorAt` / `applyEyedropperAt` + pure `pickColorAt`.
15
+ - **Convert element type** — `Editor.convertSelection(target)` and pure
16
+ `computeConvertType` switch rectangle ↔ ellipse ↔ diamond (polygon) in place,
17
+ preserving position/size/style. New "Shape type" property-panel control.
18
+ - **Image crop** — optional normalised `crop` rect on `ImageElement` (additive,
19
+ serialised). New `crop` mode entered by double-clicking an image or the
20
+ property-panel Crop button: drag a frame, `Enter` to apply, `Esc` to cancel.
21
+ Canvas2D renders the cropped source region (`RenderTarget.drawImage` gains an
22
+ optional `crop` arg). `Editor.beginImageCrop` / `commitImageCrop` /
23
+ `cancelImageCrop` + pure `computeSetImageCrop` / `cropRectFromWorldDrag`.
24
+ - **Flowchart auto-generate** — `Cmd/Ctrl+Alt+Arrow` spawns a connected node
25
+ from the selected node in that direction. `Editor.spawnConnectedNode` + pure
26
+ `computeSpawnConnectedNode`.
27
+
28
+ Also exposes `worldToLocal` from `@oh-just-another/scene`.
29
+
30
+ - a9558d9: Reworked flowchart keyboard model. Arrow-key bindings are reworked and disambiguated by modifier: `Arrow` nudges (unchanged); `Cmd/Ctrl+Arrow` grows a flowchart CREATE session (each press adds a pending connected sibling, previewed on the overlay, committed as one undo step when Cmd/Ctrl is released, cancelled on Escape); `Alt+Arrow` navigates to the adjacent node (graph neighbour, else spatially nearest); `Cmd/Ctrl+Shift+Arrow` aligns (moved off the old plain `Alt+Arrow`). The old `Cmd/Ctrl+Alt+Arrow` spawn binding is retired.
31
+
32
+ New API: `editor.growFlowchart` / `commitFlowchart` / `cancelFlowchart` / `navigateFlowchart` / `flowchartPreview`, the pure `computeSpawnConnectedNodes`, and `endpointElementId` (scene). `<Diagram>` wires the keyup-commit / Escape-cancel lifecycle for you.
33
+
34
+ ### Patch Changes
35
+
36
+ - Updated dependencies [783749e]
37
+ - Updated dependencies [c189261]
38
+ - Updated dependencies [c189261]
39
+ - Updated dependencies [c189261]
40
+ - Updated dependencies [641842b]
41
+ - Updated dependencies [c189261]
42
+ - Updated dependencies [c58054b]
43
+ - Updated dependencies [b156869]
44
+ - Updated dependencies [0d3934e]
45
+ - Updated dependencies [1c4941e]
46
+ - Updated dependencies [0d3934e]
47
+ - Updated dependencies [b0a9f3b]
48
+ - Updated dependencies [571f13b]
49
+ - Updated dependencies [ca48e8a]
50
+ - Updated dependencies [1975a9b]
51
+ - Updated dependencies [1975a9b]
52
+ - Updated dependencies [bdc847e]
53
+ - Updated dependencies [511a22a]
54
+ - Updated dependencies [a9558d9]
55
+ - Updated dependencies [22b90f9]
56
+ - Updated dependencies [99b5bee]
57
+ - Updated dependencies [dda2e56]
58
+ - Updated dependencies [34ddb22]
59
+ - Updated dependencies [f381039]
60
+ - Updated dependencies [394d3ce]
61
+ - Updated dependencies [295f38b]
62
+ - Updated dependencies [70a08d8]
63
+ - Updated dependencies [bd2e26c]
64
+ - Updated dependencies [97de2fd]
65
+ - Updated dependencies [407f203]
66
+ - Updated dependencies [744f4b8]
67
+ - Updated dependencies [5d8a282]
68
+ - Updated dependencies [71a6c8b]
69
+ - Updated dependencies [71a6c8b]
70
+ - Updated dependencies [7f69f29]
71
+ - Updated dependencies [672b557]
72
+ - Updated dependencies [dde8279]
73
+ - Updated dependencies [cec8f83]
74
+ - Updated dependencies [1975a9b]
75
+ - Updated dependencies [1975a9b]
76
+ - Updated dependencies [1975a9b]
77
+ - Updated dependencies [1975a9b]
78
+ - Updated dependencies [cf8b735]
79
+ - Updated dependencies [571f13b]
80
+ - Updated dependencies [f8302c3]
81
+ - @oh-just-another/scene@0.60.0
82
+ - @oh-just-another/serialization@0.59.0
83
+ - @oh-just-another/state@0.60.0
84
+ - @oh-just-another/renderer-core@0.59.0
85
+ - @oh-just-another/react-ui@0.59.0
86
+ - @oh-just-another/renderer-canvas@0.60.0
87
+ - @oh-just-another/renderer-svg@0.57.3
88
+ - @oh-just-another/raster-wasm@0.57.3
89
+ - @oh-just-another/templates@0.57.3
90
+ - @oh-just-another/text-wasm@0.57.3
91
+
3
92
  ## 0.59.0
4
93
 
5
94
  ### Minor Changes
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @oh-just-another/editor
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/@oh-just-another/editor.svg)](https://www.npmjs.com/package/@oh-just-another/editor)
4
+
3
5
  Drop-in diagram editor as a single React component. Auto-detects the best
4
6
  renderer (WebGL2 / Canvas2D / OffscreenCanvas), opt-in WASM text-shaping and
5
7
  rasterisation, and worker offloading — then exposes one `<Editor>` component
@@ -124,6 +126,36 @@ bundlers that don't (esbuild, Parcel, no bundler), either:
124
126
 
125
127
  The worker is an optimisation; the editor renders fine without it.
126
128
 
129
+ ## Custom shapes
130
+
131
+ `defineShape` registers a custom element type in one call — bounds (spatial
132
+ index / hit-test / culling), rendering (all backends), and optional
133
+ interaction hooks. Serialization is automatic (unknown types pass through).
134
+
135
+ ```ts
136
+ import { defineShape, type ElementBase } from "@oh-just-another/editor";
137
+
138
+ interface Sticker extends ElementBase {
139
+ readonly type: "sticker";
140
+ readonly size: number;
141
+ }
142
+
143
+ defineShape<Sticker>({
144
+ type: "sticker",
145
+ bounds: (s) => ({ x: 0, y: 0, width: s.size, height: s.size }),
146
+ render: (s, target) => {
147
+ target.setFill(s.style.fill ?? "#facc15");
148
+ target.beginPath();
149
+ target.rect(0, 0, s.size, s.size);
150
+ target.fill();
151
+ },
152
+ // Optional: interactiveHitTest, rotateAnchor.
153
+ });
154
+ ```
155
+
156
+ Returns `{ dispose() }` — currently a no-op (registries are append-only),
157
+ reserved for future deregistration.
158
+
127
159
  ## Plug-in points
128
160
 
129
161
  These registries are re-exported from this package, so the editor is the single
@@ -133,6 +165,8 @@ import for extending the kernel without forking:
133
165
  import { registerBounder, registerElementRenderer } from "@oh-just-another/editor";
134
166
  ```
135
167
 
168
+ - `defineShape` — one-call custom shape (wraps the two registries below plus
169
+ `registerInteractiveHitTester` / `registerRotateAnchor`).
136
170
  - `registerBounder` (AABB) + `registerElementRenderer` (draw) — custom element types.
137
171
  - `registerMigration` — wire-format migrations.
138
172
  - `registerLayoutKind` / `registerAnimationAdapter` — or pass via the